akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(2147483647)

class Node:
  def __init__(self,p,l,r):
    self.p=p
    self.l=l
    self.r=r

def getDepth(u):
  #d=0
  #while T[u].parent!=None:
  #  u=T[u].parent
  #  d+=1
  #return d
  return D[u]

def setDepth(u,p):
  global D
  D[u]=p
  if T[u].r!=-1:
    #print("debug:",T[u].r)
    setDepth(T[u].r,p)
  if T[u].l!=-1:
    setDepth(T[u].l,p+1)

def getChildren(u):
#def printChildren(u):
  C=[]
  c=T[u].l
  while c!=-1:
    #print(c,end=', ')
    C.append(str(c))
    c=T[c].r
  return C

n=int(input())
#T=[Node(-1,-1,-1)]*n
T=[Node(-1,-1,-1) for _ in range(n)]
for _ in range(n):
  C=list(map(int,input().split()))
  if C[1]>0:
    T[C[0]].l=C[2]
  k=C[1]
  for i in range(2,k+2):
    T[C[i]].p=C[0]
    if i+1<k+2:
      T[C[i]].r=C[i+1]

#for i in range(n):
#  print(i,":",T[i].r)
#exit(0)

r=-1
for i in range(n):
  if T[i].p==-1:
    r=i
    break
D=[-1]*n
setDepth(r,0)

for i in range(n):
  node=T[i]
  C=getChildren(i)
  d=getDepth(i)
  t='root' if T[i].p==-1 else 'leaf' if T[i].l==-1 else 'internal node'
  print('node '+str(i)+': parent = '+str(T[i].p)+', depth = '+str(d)+', '+t+', [',end='')
  print(', '.join(C),end='')
  print(']')



Measured memory_bytes: 125172
#include <stddef.h>
#include <iostream>
#include <string>
using namespace std;
int gcd(int a, int b) {
  return (b == 0) ? a : gcd(b, a % b);
}
int main() {
  int n, i, j;
  size_t k;
  string line, a;
  getline(cin, line);
  n = stoi(line);
  while (n--) {
    getline(cin, line);
    a.resize(line.size());
    for (i = 0; i < 26; i++) {
      if (gcd(i, 26) != 1) continue;
      for (j = 0; j < 26; j++) {
        for (k = 0; k < line.size(); k++)
          if (line[k] == ' ') a[k] = ' ';
          else a[k] = (i * (line[k] - 'a') + j) % 26 + 'a';
        if (a.find("this") != string::npos || a.find("that") != string::npos) {
          cout << a << endl;
          goto NEXT;
        }
      }
    }
    NEXT:
    ;
  }
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,k;
cin>>n>>k;
int dp[n+1]={};
while(k--)
{
    int d;
    cin>>d;
    while(d--)
    {
        int x;
        cin>>x;
        dp[x]+=1;
    }
}
int ans=0;
for(int i=1;i<=n;i++)
{
    if(!dp[i])
        ans++;
}
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	string s;
	cin >> s;
	int n = sz(s);
	bool ok = true;
	for(int i = 0; i < n/2; i++) {
		if(s[i]!=s[n-i-1]) {
			ok = false;
			break;
		}
	}
	for(int i = 0; i < (n-1)/4; i++) {
		if(s[i] != s[(n-1)/2-i-1]) {
			ok = false;
			break;
		}
	}
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  int n,m; cin >> n >> m;
  vector<vector<int>> jobs(m);
  rep(i,n) {
    int a,b;
    cin >> a >> b;
    if (a > m) continue;
    jobs[m-a].push_back(b);
  }
  priority_queue<int> q;
  ll ans = 0;
  for(int i = m-1; i >= 0; --i) {
    for(int b : jobs[i]) {
      q.push(b);
    }
    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5504
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
int main()
{
	int n,m;
	int a[1001],b[1001],c[1001]={0};
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<m;i++){
		cin>>b[i];
	}
	for(int i=0;i<m;i++){
		for(int i2=0;i2<n;i2++){
			if(b[i]>=a[i2]){c[i2]++;break;}
		}
	}
	int u,o;
	for(int i=0;i<n;i++){
	u=max(u,c[i]);
	if(u==c[i])o=i+1;
	
	}

	cout<<o<<endl;

	
	return 0;
	
}

Measured memory_bytes: 1172
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,w,h;
    string s;
    cin>>s;
    if(s=="A"){
        cout<<"T";
    }
    if(s=="C"){
        cout<<"G";
    }
    if(s=="T"){
        cout<<"A";
    }
    if(s=="G"){
        cout<<"C";
    }
  
  
    return(0);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
using namespace std;
int main(){
int A, B, C, D ,E ,F;
  A = 0;
  B = 0;
  C = 0;
  D = 0;
long long int V[10000000] = {};
long long int G[10000000] = {};
string S,Sa,Sb,Sc;
bool ans = true;
cin >> V[0] >> G[0] >> V[1] >> G[1] >> V[2] >> G[2];
for(int i = 0;i < 3;i++){
if(V[i] == 1)A++;
if(G[i] == 1)A++;
if(V[i] == 2)B++;
if(G[i] == 2)B++;
if(V[i] == 3)C++;
if(G[i] == 3)C++;
if(V[i] == 4)D++;
if(G[i] == 4)D++;
}
if(A > 2 || B > 2 || C > 2 || D > 2)ans = false;
if(A == 0 || B == 0 || C == 0 || D == 0)ans = false;
if(ans)cout << "YES" << endl;
else cout << "NO" << endl;
return 0; 
}



Measured memory_bytes: 156544
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int
#define Vec vector

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int N, M;
	cin>> N >> M;
	Vec<Vec<int>> A(N);
	for(int i=0;i<N;i++) A[i].resize(M, 0);
	for(int i=0;i<N;i++){
		int k; cin >> k;
		int v;
		for(int j=0;j<k;j++){
			cin >> v;
			A[i][v - 1] = 1;
		}
	}
	
	int cnt = 0;
	for(int i=0;i<M;i++){
		bool chk = true;
		for(int j=0;j<N;j++){
			chk &= A[j][i] == 1;
		}
		if(chk) cnt++;
	}
	
	cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))


journey = [1]

for i in range(2*n + 1000):
    nxt = a[journey[-1]]
    journey.append(nxt)

if k < n+1:
    print(journey[k])
    exit()

loop_end = n

loop_start = n-1

while(journey[loop_start] != journey[loop_end]):
    loop_start -= 1

period = loop_end - loop_start
k %= period


while k < n:
    k += period

print(journey[k])


                 


Measured memory_bytes: 32396
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// using namespace __gnu_pbds;
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define mii map<int, int>
#define msi map<string, int>
#define pb push_back
#define ff first
#define ss second
#define coutp cout<<fixed<<setprecision
#define FR(n) for(int i=0;i<n;i++)
#define W(n) while(n--)
#define I(v) for(int i=0;i<v.size();i++)
#define srt(v) sort(v.begin(),v.end())
#define srtd(v) sort(v.begin(),v.end(),greater<int> ())
#define ALL(v) v.begin(),v.end()
#define IT(m) for(auto it=m.begin();it!=m.end();it++)
#define M 1000000007
#define imin INT_MIN
#define imax INT_MAX
#define SIEVE 100000

int n,m,k,a,b,mx=imin,mn=imax,mxi,mni;
double x,y;
string s,s1,s2;
vector<bool> prime(SIEVE+1,1);
vi primes;

void precomputation();
void solve();
void solvecase();
void sieve();
int pow(int, unsigned int, int);
bool miillerTest(int, int);
bool isPrime(int, int);

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	clock_t start_time = clock();
	precomputation();
	solve();
	clock_t end_time = clock();
  	double elapsed_secs = double(end_time - start_time) / CLOCKS_PER_SEC;
	cerr<<elapsed_secs<<"\n";
	return 0;

}

void solvecase(){
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		cin>>m;
		if(m&1&&i&1)
		{
			ans++;
		}
	}
	cout<<ans;
}

void solve(){
	int T=1;
	//cin>>T;
	for(int i=1;i<=T;i++)
	{
		//cout<<"Case #"<<i<<":"<<" ";
		solvecase();
		cout<<"\n";
	}
}

void precomputation(){
}

void sieve(){
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<=SIEVE;i++){
		if(prime[i]){
			primes.pb(i);
			for(int j=i+i;j<=SIEVE;j+=i){
				prime[j]=0;
			}
		}
	}
	sort(primes.begin(),primes.end());
}

int pow(int X, unsigned int Y, int P)
{
	int res = 1;
	X = X % P;
	while (Y > 0)
	{
		if (Y & 1)
			res = (res*X) % P;
		Y = Y>>1;
		X = (X*X) % P;
	}
	return res;
}

bool miillerTest(int D, int N)
{
	int A = 2 + rand() % (N - 4);
	int X = pow(A, D, N);
	if (X == 1 || X == N-1)
	return true;
	while (D != N-1)
	{
		X = (X * X) % N;
		D *= 2;
		if (X == 1)	 return false;
		if (X == N-1) return true;
	}
	return false;
}

bool isPrime(int N, int K)
{
	if (N <= 1 || N == 4) return false;
	if (N <= 3) return true;
	int D = N - 1;
	while (D % 2 == 0)
		D /= 2;
	for (int i = 0; i < K; i++)
		if (!miillerTest(D, N))
			return false;
	return true;
}


Measured memory_bytes: 3852
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            List<Integer> numList = Arrays.stream(args.get(0).split(" ")).map(Integer::valueOf).collect(Collectors.toList());
            int n = numList.get(0);
            int k = numList.get(1);
            System.out.println(n - k + 1);
        };
    }

    private static int makeFactorial(int n) {
        return (n == 1) ? 1 : n * makeFactorial(n - 1);
    }

}


Measured memory_bytes: 28756
#include <stdio.h>

int main(void) 
{
	int i,j,k,ans;
	int a[4]={0};
	int sgn[3]={0};
	for(i=0;i<4;i++)
	scanf("%1d",&a[i]);
	
	for(i=0;i<=1;i++)
		for(j=0;j<=1;j++)
			for(k=0;k<=1;k++)
			{
				if(i==0) sgn[0]=-1; else sgn[0]=1;
				if(j==0) sgn[1]=-1; else sgn[1]=1;
				if(k==0) sgn[2]=-1;	else sgn[2]=1;
				ans=a[0]+sgn[0]*a[1]+sgn[1]*a[2]+sgn[2]*a[3];
				if(ans==7) goto LABEL;
 			}
 			
 	LABEL:
 	
 	printf("%d",a[0]);
 	if(sgn[0]==1) printf("+"); else printf("-");
 	printf("%d",a[1]);
 	if(sgn[1]==1) printf("+"); else printf("-");
 	printf("%d",a[2]);
 	if(sgn[2]==1) printf("+"); else printf("-");
 	printf("%d=7\n",a[3]);
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b){
	return a%b ? gcd(b,a%b) : b;
}
int main(void){
	int n; scanf("%d",&n);
	int ans; scanf("%d",&ans);
	for(int i=1;i<n;i++){
		int x; scanf("%d",&x);
		ans = gcd(ans,x);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>

using namespace std;


long long int c=1;
int fact(int );

int main() {
    long long int n,m,t,i,j,k,l,a,b;
    cin>>a>>b;
    t=a+b;
    n=a-b;
    m=a*b;
    cout<<max(max(t,n),m);


    return 0;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/
  
  int s;
  int ans=0;

  for(int i=0;i<10;i++){
    cin>>s;

    ans+=s;

  }

  cout<<ans<<endl;

  return 0;

}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
int read(){
	int sum=0,f=1;
	char s=getchar();
	while (s<'0' or s>'9'){
		if (s=='-')f=-1;
		s=getchar();
	}
	while (s>='0' and s<='9'){
		sum=sum*10+s-'0';
		s=getchar();
	}
	return sum*f;
}
int n;
int main(){
	char s=getchar();
	if (s>='A' and s<='Z')printf("A");
	else printf("a"); 
	return 0;
}



Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define long long ll

int main() {
	int n, a, b, c = 0, v;
	cin >> n >> a >> b;
	--b;
	for (int i = 0; i < n; ++i) {
		cin >> v;
		if (v < a || v > b)
			++c;
	}
	cout << c << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  ll N,K;
  cin >> N >> K;
  map<ll,ll> mp;
  rep(i,N) {
    ll a,b;
    cin >> a >> b;
    mp[a]+= b;
  }
  ll tmp = 0;
  for(auto m : mp) {
    tmp += m.second;
    if(tmp >= K) {
      cout << m.first << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 4224
#include <stdio.h>



int main (void){
    char s[6];
    int i;
    int wa = 0;
    scanf("%s",s);
    for(i=0;i<6;i++){
        if(s[i] == '1'){
            wa++;
        }
    }
    
    printf("%d\n",wa);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long LL;
LL a[300005];
priority_queue<LL, vector<LL>, greater<LL> > q1;
priority_queue<LL> q2;
LL sum1,sum2;
LL ans1[300005], ans2[300005];
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1 ; i <= 3 * n ;i++){
		scanf("%lld", &a[i]);
	}
	sum1 = 0, sum2 = 0;
	for(int i = 1 ; i <= 3 * n ; i++){
		sum1 += a[i];
		ans1[i] = sum1;
		q1.push(a[i]);
		if(q1.size() > n){
			sum1 -= q1.top();
			q1.pop();
			ans1[i] = sum1;
		}
	}
	for(int i = 3 * n ; i >= 1 ; i--){
		sum2 += a[i];
		ans2[i] = sum2;
		q2.push(a[i]);
		if(q2.size() > n){
			sum2 -= q2.top();
			q2.pop();
			ans2[i] = sum2;
		}
	}
	LL ans = -1e18;
	for(int i = n ; i <= 2 * n ; i++){
		ans = max(ans , ans1[i] - ans2[i + 1]);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 8948
package main

import "fmt"

func main() {
	var K, A, B int

	fmt.Scan(&K)
	fmt.Scan(&A, &B)

	i := 1
	for {
		ans := K * i

		if ans >= A && ans <= B {
			fmt.Println("OK")
			break
		}

		if ans >= A && ans >= B {
			fmt.Println("NG")
			break
		}
		i++
	}
}


Measured memory_bytes: 1752
#include<algorithm>
#include<bitset>
#include <cmath>
#include<cstdio>
#include<cstring>
#include<cstring> 
#include<cmath>
#include<deque>  
#include<functional>
#include<iostream>
#include<map> 
#include<vector>
#include<queue>
#include<string>  
#include<stack>  
#include<set>
#define mst(x,y) memset(x,y,sizeof x)
#define mp(x,y) make_pair((x),(y))
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<long long,long long> pll;
typedef pair<int,int> pii;
int a,b,x,y;
char ch[101][101];
bool clr;
int main()
{
	scanf("%d%d",&a,&b);
	for(x=0;x<100;x++){
		for(y=0;y<100;y++){
			int &cur=clr?a:b;
			if(cur<=1){
				ch[x][y]=clr?'#':'.';
				break;
			}
			ch[x][y]=clr?'.':'#';
			cur--;
			if(cur<=1)break;
			clr=!clr;
		}
		if(a<=1||b<=1) break;
		clr=!clr;
	}
	clr=!clr;//换色 
	int pos=y; 
	y++;
	for(;y<100;y++){//填充完该行 
		ch[x][y]=clr?'.':'#';
		if(x>0&&ch[x-1][y]==ch[x][y])clr?++a:++b;//多者++ 
	}x++;//较多色填充隔离行
	for(y=0;y<100;y++){
		ch[x][y]=clr?'.':'#';
		if(y<pos&&ch[x-1][y]==ch[x][y])clr?++a:++b;
	}x++;//较少色填充 
	clr?--a:--b;
	for(;x<100;x++){
		for(y=0;y<100;y++){
			ch[x][y]=clr?'#':'.';//较少色 
		}x++;
		for(y=0;y<100;y++){
			if((y&1)==clr){
				if((clr?a:b)>0){
					ch[x][y]=clr?'.':'#';
					clr?--a:--b;
				}else goto end;
			}else ch[x][y]=clr?'#':'.';//较少色 
		}
	}
	end:
		for(;y<100;y++)ch[x][y]=clr?'#':'.';
		printf("%d 100\n",x+1);
		for(int i=0;i<=x;i++){
			for(int j=0;j<100;j++){
				printf("%c",ch[i][j]);
			}
			printf("\n");
		}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int f[2];

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n; cin >> n;
  while (n--) {
    int x; cin >> x;
    f[x & 1]++;
  }
  f[0] += f[1] / 2;
  f[0] = min(f[0], 1);
  f[1] %= 2;
  if (f[0] + f[1] <= 1) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }

  return 0;
}




Measured memory_bytes: 3592
#include <iostream>

#define MAX_N 110
#define MAX_W 100010

typedef long long ll;

int N, W;
ll  weight[MAX_N], value[MAX_N];
ll  dp[MAX_N][MAX_W];

// dp[i][w] := i 番目までの品物で，重さが w 以下という制約で，価値の総和が最大になるように選んだ時の価値の総和の最大値
// dp[i][w'] = max( dp[i-1][w' - w[i]] + v[i], dp[i-1][w'] )
// dp[N-1][W] が答え？

void solve() {
    for (int i=0; i<=N; ++i) {
        for (int w=0; w<=W; ++w) {
            if ( w >= weight[i] ) {
                dp[i+1][w] = std::max( dp[i][w-weight[i]] + value[i], dp[i][w] );
            } else {
                dp[i+1][w] = dp[i][w];
            }
        }
    }
    std::cout << dp[N][W] << std::endl;
}

int main() {
    std::cin >> N >> W;
    for (int i=0; i<N; ++i) {
        std::cin >> weight[i] >> value[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N;
    cin >> N;

    int ceil_ = ceil(N / 1.08);
    if (floor((ceil_ - 1) * 1.08) == N)
    {
        cout << ceil_ - 1 << endl;
    }
    else if (floor(ceil_ * 1.08) == N)
    {
        cout << ceil_ << endl;
    }
    else if (floor((ceil_ + 1) * 1.08) == N)
    {
        cout << ceil_ + 1 << endl;
    }
    else
    {
        cout << ":(" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>k;i--)
using namespace std;
int main(){
    long long n,m,ans=0;
    cin>>n;
    string s;
    map<string,long long> a;
    f(i,0,n){
        cin>>s;
        a[s]++;
    }
    cin>>m;
    f(i,0,m){
        cin>>s;
        a[s]--;
    }
    for(auto x:a){
        ans=max(ans,x.second);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3604
#include<cstdio>
const int N(1e5+5),M(105);
int n,m,cnt,c1,c2;
int a[M];
template<class Tp>
inline void swap(Tp &a,Tp &b)
{
	Tp t=a;
	a=b;b=t;
	return;
}
signed main()
{
	int i;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]&1)
		{
			cnt++;
			if(cnt==1)
				c1=i;
			else if(cnt==2)
				c2=i;
			else
			{
				puts("Impossible");
				return 0;
			}
		}
	}
	if(m==1)
	{
		if(a[1]==1)
			printf("1\n1\n1\n");
		else
			printf("%d\n2\n%d 1\n",a[1],a[1]-1);
		return 0;
	}
	if(c1)
		swap(a[1],a[c1]);
	if(c2)
		swap(a[m],a[c2]);
	for(i=1;i<=m;i++)
		printf("%d ",a[i]);
	putchar('\n');
	printf("%d\n",m-(a[1]==1));
	if(a[1]>1)
		printf("%d ",a[1]-1);
	for(i=2;i<m;i++)
		printf("%d ",a[i]);
	printf("%d\n",a[m]+1);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <unordered_set>
#include <algorithm>

using namespace std;

long long MOD = 1e9+7;
int N,M;
long long dp[100001];
unordered_set<int> s;

int main(){
    cin >> N >> M;
    int a;
    for(int i=0;i<M;i++){
        cin >> a;
        s.insert(a);
    }
    dp[0] = 1;
    if(s.find(1)!=s.end()){
        dp[1] = 0;
    }else{
        dp[1] = 1;
    }
    for(int i=2;i<=N;i++){
        if(s.find(i)!=s.end()){
            dp[i] = 0;
        }else{
            dp[i] = dp[i-1] + dp[i-2];
            dp[i] %= MOD; 
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 5156
import java.util.*;
import java.util.Scanner;
 
public class Main{
	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		int k=sc.nextInt();
		char[][] c=new char[h][w];
		
		for(int i=0;i<h;i++) {
			String s=sc.next();
			c[i]=s.toCharArray();
		}
		
		int ans=0;
		for(int i=0;i<(Math.pow(2, h));i++) {
			for(int j=0;j<(Math.pow(2, w));j++) {
				int count=0;
				for(int row=0;row<h;row++) {
					for(int col=0;col<w;col++) {
						if(((i>>row & 1)==1) && ((j>>col & 1)==1)) {
							if (c[row][col] == '#')count++;
							//ystem.out.println(c[row][col]);
						}
					}
				}	
				if(count==k)ans++;
			}
		}
		
	    System.out.println(ans);
	}
}

Measured memory_bytes: 35824
#include<iostream>
#include<cstdlib>
main(){for(int n,a[20],S,s,m,i,j,t;std::cin>>n,n;printf("%d\n",m)){for(i=S=0;i<n;S+=a[i++])std::cin>>a[i];m=1<<30;for(i=(1<<n);i-->0;t=abs(S-s-s),m>t&&(m=t))for(j=s=0;j<n;j++)if(i&1<<j)s+=a[j];}}

Measured memory_bytes: 868
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int A[] = new int[N];
        int ans = 0;
        int sum = 0;
        for(int i=0;i<N;i++)
        {
            A[i] = sc.nextInt();
            sum = sum + A[i];
        }
        double san = 1 / (4 * (double)M);
        for(int j=0;j<N;j++)
        {
            if(A[j]>=san*sum)
            {
                ans++;
            }
        }
        if(ans>=M)
        {
            System.out.println("Yes");
        }
        else
        {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int par[60];int n,m;

int root(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = root(par[x]);
  }
}

bool same(int x, int y){
  return root(x) == root(y);
}

void unite(int x, int y){
  x = root(x);
  y = root(y);
  if(x == y)return;
  par[x] = y;
}

signed main() {
  cin>>n>>m;int a[50], b[50];rep(i,m)cin>>a[i]>>b[i];int ans = 0;
  rep(i,m){
    rep(j,60)par[j] = j;
    rep(j,m){
      if(i == j)continue;
      unite(a[j],b[j]);
    }
    bool c = true;
    repd(j,1,n+1){
      repd(k,j+1,n+1){
        if(!same(j,k))c = false;
      }
    }
    if(!c){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
//team04 lyt

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
//#include <io.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <sstream>
#include <fstream>

using namespace std;

int a[10005];

int main()
{
    int n;
    while(scanf("%d",&n)==1)
    {
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        int ans=-1;
        for(int i=0;i<n;i++)
            for(int j=i+1;j<n;j++)
        {
            int x=a[i]*a[j];
            int y=x;
            while(y&&y/10%10==y%10-1)
            {
                y/=10;
            }
            if(y<10)
            {
                ans=max(ans,x);
            }
        }
        printf("%d\n",ans);
    }

    return 0;
}

Measured memory_bytes: 3232
#include <cstdio>
#include <cstring>
using namespace std;

int ans;
char buf[10000];

int main() {
  while (1) {
    if (scanf("%s", buf) != 1) break;

    int n = strlen(buf);
    bool is_palindrome = true;
    for (int i=0; i<n/2; i++) {
      if (buf[i] != buf[n-1-i]) {
        is_palindrome = false;
        break;
      }
    }

    if (is_palindrome) ans++;
  }

  printf("%d\n", ans);
}

Measured memory_bytes: 2636
#include <bits/stdc++.h>

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  std::string S;
  std::cin >> S;

  ll left = 0;
  rep(i, 0, N) {
    if ('(' == S[i]) left++;
    if (')' == S[i]) left = max(0LL, left - 1);
  }

  ll right = 0;
  rrep(i, N, 0) {
    if (')' == S[i]) right++;
    if ('(' == S[i]) right = max(0LL, right - 1);
  }

  cout << string(right, '(') + S + string(left, ')') << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

template <class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) {
  T c = min(a, b), d = max(a, b);
  return c * (d / gcd(c, d));
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int ans,table[41],n;

struct Info{
	Info(int arg_start,int arg_grade,int arg_tmp){
		start = arg_start;
		grade = arg_grade;
		tmp = arg_tmp;
	}
	Info(){
		start = grade = tmp = 0;
	}
	int grade,tmp,start;
};

void recursive(int index,Info info){

	if(info.grade == 5){
		ans = min(ans,info.start);
		return;
	}

	if(index == n+1)return;

	switch(info.grade){
	case 0: //5
		if(table[index]+info.tmp < 5){
			recursive(index+1,Info(info.start,0,info.tmp+table[index]));
		}else if(table[index]+info.tmp == 5){
			recursive(index+1,Info(info.start,1,0));
		}else{
			return;
		}
		break;
	case 1: //7
		if(table[index]+info.tmp < 7){
			recursive(index+1,Info(info.start,1,info.tmp+table[index]));
		}else if(table[index]+info.tmp == 7){
			recursive(index+1,Info(info.start,2,0));
		}else{
			return;
		}
		break;
	case 2: //5
		if(table[index]+info.tmp < 5){
			recursive(index+1,Info(info.start,2,info.tmp+table[index]));
		}else if(table[index]+info.tmp == 5){
			recursive(index+1,Info(info.start,3,0));
		}else{
			return;
		}
		break;
	case 3: //7
		if(table[index]+info.tmp < 7){
			recursive(index+1,Info(info.start,3,info.tmp+table[index]));
		}else if(table[index]+info.tmp == 7){
			recursive(index+1,Info(info.start,4,0));
		}else{
			return;
		}
		break;
	case 4: //7
		if(table[index]+info.tmp < 7){
			recursive(index+1,Info(info.start,4,info.tmp+table[index]));
		}else if(table[index]+info.tmp == 7){
			recursive(index+1,Info(info.start,5,0));
		}else{
			return;
		}
		break;
	}
}


void func(){
	int length;
	char tmp[11];

	for(int loop = 1; loop <= n; loop++){
		scanf("%s",tmp);

		for(length = 0; tmp[length] != '\0'; length++);

		table[loop] = length;
	}

	for(int i = 1; i <= n-4; i++){
		recursive(i,Info(i,0,0));
	}

	printf("%d\n",ans);
}


int main(){

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		ans = 1000000;
		func();
	}
    return 0;
}

Measured memory_bytes: 2664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll n, a;
    cin >> n;
    map<ll, ll> m;
    rep1(i, n){
        cin >> a;
        m[a]++;
    }
    ll ans = 0;
    for (auto x: m){
        ans += x.second - 1;
    }
    ans += (ans & 1);
    cout << n - ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 9660
# include <iostream>
# include <string>
# include <algorithm>
# include <vector>
# include <cstring>
# include <stdio.h>
# include <map>
# include <queue>

# define ll long long
# define pii pair<int,int>
# define FOR(a,b) for(int a=1; a<=b; a++)
# define REP(a,b) for(int a=0; a<b; a++)
# define FORU(a,b,c) for(int a=b; a<=c; a++)
# define FORD(a,b,c) for(int a=b; a>=c; a--)

using namespace std;

int main(){

    ios :: sync_with_stdio(false);
    int N;
    cin >> N;

    map<int,int> occ;

    FOR(i,N){
        int x;
        cin >> x;
        occ[x]++;
    }

    int ans = 0;
    for(auto state : occ){
        int key = state.first;
        int val = state.second;
        if(val < key) ans += val;
        else ans += val-key;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;

int dp[100100];
bool isBroken[100100];

signed main () {

    int n, m;
    scanf("%d %d", &n, &m);
    for ( int i = 0; i < m; i++ ) {
        int hori;
        scanf("%d", &hori);
        isBroken[hori] = true;
    }

    dp[0] = 1;
    for ( int i = 0; i < n; i++ ) {
        for ( int j = 1; j <= 2; j++ ) {
            if ( !isBroken[i+j] ) {
                dp[i+j] += dp[i];
                dp[i+j] %= (int)1e9+7;
            }
        }
    }

    printf("%d\n", dp[n]);


    return 0;
}

Measured memory_bytes: 768
#include <iostream>
//#include <string>
using namespace std;


int min(int a,int b)
{
	if(a>b)
		return b;
	
	return a;
}

int main()
{
	int i,n,b[100],p;
	
	cin>>n;
	for(i=0;i<n-1;i++)
		cin>>b[i];
	
	p=b[0];
	
	for(i=1;i<n-1;i++)
		p+=min(b[i-1],b[i]);
	
	p+=b[i-1];
	
	cout<<p;
	
	return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashMap;
use std::cmp::{max,min};
fn main(){
    input!{
        n:i64,
    }
    let mut ans = 0;
    for j in 1..n+1 {
        if j.to_string().len() % 2 == 1 {
            ans += 1;
        }
    }
    println!("{}",ans);
}


fn is_prime(x:i64) -> bool {
    if x == 2 {return true;}
    if x < 2 || x % 2 == 0 {return false;}
    let mut j = 3;
    while j <= (x as f64).sqrt() as i64 {
        if x % j == 0 {
            return false;
        }
        j += 2;
    }
    true
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        long A = sc.nextLong();
        long B = sc.nextLong();

        int[] X = new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = sc.nextInt();
        }

        long ret = 0;

        for (int i = 0; i < N - 1; i++) {
            int distance = X[i+1] - X[i];

            ret += Math.min(distance * A, B);
        }

        System.out.println(ret);
    }
}

Measured memory_bytes: 51708
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
#define All(v) (v).begin(),(v).end()
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define REPS(i,n) for(int i = 1; i <= (int)n; i++)
#define FOR(i,m,n) for(int i = m; i < n; i++)
#define FORS(i,m,n) for(int i = m; i <= n; i++)
#define INF 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main (){
    int n;
    string s;
    cin >> n >> s;
    int b = 0,w = 0;
    REP(i,n){
        if(s[i] == '#') b++;
        else w++;
    }
    int cntb = 0,cntw = 0;
    vector<int> ans(n+1);
    for(int i = 0; i <= n; i++){
        if(i == 0) ans[i] = w;
        else if(i == n){
            ans[i] = b;
            break;
        }
        else{
            ans[i] = cntb+(w-cntw);
        }
        if(s[i] == '#') cntb++;
        else cntw++;
    }
    cout << *min_element(All(ans)) << "\n";
}

Measured memory_bytes: 1300
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		int[] a = new int[n];
		int wildCount = 0;
		for(int i=0;i<n;i++){
			a[i] = Integer.parseInt(scan.next());
			if(a[i]>=3200)wildCount++;
		}
		int min,sum = 0;
		for(int j=0;j<8;j++){//jは色
			if(check(a,j))sum ++;
		}
		//最小値
		if(sum==0){
			min = 1;
		}else{
			min = sum;
		}
		//最大値
		int max = sum;
		max += wildCount;


		System.out.println(min+" "+max);


	}

	static boolean check(int[] a,int b){
		for(int i=0;i<a.length;i++){
			if(400*b<=a[i] && a[i]<400*(b+1)){
				return true;
			}
		}
		return false;
	}
}


Measured memory_bytes: 23636
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
//int CHMAX

int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int MODFACT(int a, int mod) {
	if (a == 0)
		return 1;
	else
		return (a * FACT(a - 1))%mod;
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
int MODnPr(int n, int r, int mod) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++) {
		sum *= i;
		sum = sum % MOD;
	}
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
int NUMOFDIV(int n) {
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	return (n + 9) / 10 * 10;
}
int DIGITSUM(int n) {
	int sum = 0, dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
int DIVTIME(int n, int k) {
	int div = 0;
	while (n % k == 0) {
		div++;
		n /= k;
	}
	return div;
}
int MODPOW(int a, int n, int mod) {
	// a^n mod
	int ans = 1;
	while (n > 0) {
		if (n & 1)
			ans = ans * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return ans;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion
signed main() {
	int N;
	cin >> N;
	cout << N * (N - 1) / 2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define cerr if(true) cerr

template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
    out << "(" << p.first << ", " << p.second << ")";
    return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print(const ContainerType<ValueType, Args...> &c)
{
    for (const auto &v : c)
        cout << v << ' ';
    cout << '\n';
}

void print() { cout << '\n'; }
template <typename T, typename... Args>
void print(T a, Args... args)
{
    cout << a << " ";
    print(args...);
}

lli llipower(lli x, lli y, lli p = LLONG_MAX)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}

//---------------------------------------------------------------------------------
lli ovf(lli n){
    if(n<0) return LLONG_MAX;
    return n;
}
lli n, a, b, c, d;
map<lli,lli> stored;
lli rec(lli n){
    //print(n);
    if(n==0) return 0;
    if(n==1) return d;
   if(stored.count(n)) return stored[n];
    lli ans=LLONG_MAX;
    if(n%2==0){
        ans=min({ans,a+rec(n/2),ovf(ovf(d*(n/2))+rec(n/2))});
    }
    else{
        ans=min({ans, d + a + min(rec((n - 1) / 2), rec((n + 1) / 2))});
        ans = min({ans, ovf(d+ovf(d * ((n - 1) / 2)) + rec((n - 1) / 2)), ovf(d+ovf(d * ((n + 1) / 2)) + rec((n + 1) / 2))});
    }
    if(n%3==0){
        ans=min(ans,rec(n/3)+b);
    }
    else if(n%3==1){
        ans = min(ans, rec((n - 1) / 3) + b + d);
    }
    else{
        ans = min(ans, rec((n + 1) / 3) + b+d);
    }
    if(n%5==0){
        ans=min(ans,rec((n)/5)+c);
    }
    else if (n % 5 == 1)
    {
        ans = min(ans, rec((n-1) / 5) + c + d);
    }
    else if (n % 5 == 2)
    {
        ans = min(ans, rec((n-2) / 5) + c+d+d);
    }
    else if (n % 5 == 3)
    {
        ans = min(ans, rec((n+2) / 5) + c+d+d);
    }
    else if (n % 5 == 4)
    {
        ans = min(ans, rec((n+1) / 5) + c+d);
    }
    
    stored[n]=ans;
    return ans;
}

int main(){
    int t;
    cin>>t;
    while(t--){
        stored.clear();
        cin>>n>>a>>b>>c>>d;
        cout<<rec(n)<<endl;
        
    }
}
// , d *(n - 1) / 2 + rec((n - 1) / 2), d *(n + 1) / 2 + rec((n + 1) / 2)

Measured memory_bytes: 4412
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
using namespace std;

int main() {
  int r;
  cin >> r;
  cout << r * 2 * 3.14;
}


Measured memory_bytes: 3776
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int p[13][13] = {};
    int x, y, s;
    char c;
    int w = 0, dens = 0;

    while (cin >> x >> c >> y >> c >> s)
    {
        switch (s)
        {
        case 1:
            p[x][y]++;
            p[x + 1][y]++;
            p[x - 1][y]++;
            p[x][y + 1]++;
            p[x][y - 1]++;
            break;
        case 2:
            p[x][y]++;
            p[x + 1][y]++;
            p[x - 1][y]++;
            p[x][y + 1]++;
            p[x][y - 1]++;
            p[x + 1][y + 1]++;
            p[x - 1][y + 1]++;
            p[x - 1][y - 1]++;
            p[x + 1][y - 1]++;
            break;
        case 3:
            p[x][y]++;
            p[x + 1][y]++;
            p[x - 1][y]++;
            p[x][y + 1]++;
            p[x][y - 1]++;
            p[x + 1][y + 1]++;
            p[x - 1][y + 1]++;
            p[x - 1][y - 1]++;
            p[x + 1][y - 1]++;
            p[x + 2][y]++;
            p[x - 2][y]++;
            p[x][y + 2]++;
            p[x][y - 2]++;
            break;
        }
    }

    rep(i, 10)
    {
        rep(j, 10)
        {
            if (p[i][j] == 0)
            {
                w++;
            }
            if (p[i][j] >= dens)
            {
                dens = p[i][j];
            }
        }
    }
    OP(w)
    OP(dens)

    return 0;
}


Measured memory_bytes: 3044
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

void dfs(Graph &G, vector<int> &res, int v, int cur, int p = -1)
{
    res[v] = cur;
    for (auto u : G[v])
    {
        if (res[u.to] != -1)
            continue;
        if (u.weight % 2 == 0)
        {
            dfs(G, res, u.to, cur, v);
        }
        else
        {
            dfs(G, res, u.to, 1 - cur, v);
        }
    }
    return;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    Graph G(N);
    for (int i = 0; i < N - 1; i++)
    {
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        G[u].push_back({v, w});
        G[v].push_back({u, w});
    }

    vector<int> res(N, -1);
    dfs(G, res, 0, 0);
    for (auto it : res)
    {
        cout << it << endl;
    }

    return 0;
}


Measured memory_bytes: 11772
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


int main(){
	int h,w;
	std::cin >> h >> w;
	char stage[51][51];
	bool check[51][51] = {false};
	int bcnt=0;
	for ( int i = 1 ; i <= h ; i++ ) {
		for ( int ii = 1 ; ii <= w ; ii++ ) {
			std::cin >> stage[i][ii];
			if(stage[i][ii]=='#') bcnt++;
		}
	}
	std::queue<std::tuple<int,int,int>> que;
	que.push(std::make_tuple(1,1,0));
	int x,y,step;
	while(!que.empty()){
		std::tie(x,y,step) = que.front();
		que.pop();
		if(x<1||y<1||x>w||y>h) continue;
		if(check[y][x]) continue;
		check[y][x] = true;
		if(stage[y][x]=='#') continue;
		if(x==w&&y==h) break;
		step++;
		que.push(std::make_tuple(x+1,y,step));
		que.push(std::make_tuple(x-1,y,step));
		que.push(std::make_tuple(x,y+1,step));
		que.push(std::make_tuple(x,y-1,step));
	}
	if(check[h][w]){
		std::cout << h*w - 2 - bcnt - (step -1) << std::endl;
	}else{
		std::cout << -1 << std::endl;
	}
	return 0;
}


Measured memory_bytes: 256