akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int gcd(int x,int y) {
  return (x%y==0)?y:gcd(y,x%y);
}

int num[100005],n;

bool dfs() {
  bool ok=0;
  int s=0,now=0;
  for(int i=1;i<=n;i++) {
  	ok^=(!(num[i]&1));
  	if (num[i]&1) {
  		s++;now=num[i];
	  }
  }
  if (ok) return 1;
  else if (s>1||now==1) return 0;
  else {
  	for(int i=1;i<=n;i++)
  	  if (num[i]==now) num[i]--;
  	int d=num[1];
  	for(int i=2;i<=n;i++) d=gcd(d,num[i]);
  	for(int i=1;i<=n;i++) num[i]/=d;
  	return !dfs();
  }
}

int main() {
  scanf("%d",&n);
  if (n==1) {
  	puts("Second");
  	return 0;
  }
  for(int i=1;i<=n;i++) scanf("%d",&num[i]);
  puts((dfs())?"First":"Second");
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, C;
  cin>>N>>C;
  int D[C][C], c[N][N];
  for(int i=0;i<C;++i) {
    for(int j=0;j<C;++j) {
      cin>>D[i][j];
    }
  }
  for(int i=0;i<N;++i) {
    for(int j=0;j<N;++j) {
      cin>>c[i][j];
      c[i][j]--;
    }
  }
  int ans[3][C];
  for(int i=0;i<3;++i) {
    for(int j=0;j<C;++j) {
      ans[i][j] = 0;
    }
  }
  for(int i=0;i<N;++i) {
    for(int j=0;j<N;++j) {
      for(int k=0;k<C;++k) {
        ans[(i+j)%3][k] += D[c[i][j]][k];
      }
    }
  }
  int ans1 = inf;
  for(int i=0;i<C;++i) {
    for(int j=0;j<C;++j) {
      if(i==j) continue;
      for(int k=0;k<C;++k) {
        if(j==k || k==i) continue;
        ans1 = min(ans1, ans[0][i]+ans[1][j]+ans[2][k]);
      }
    }
  }
  cout<<ans1<<endl;
}


Measured memory_bytes: 4564
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cassert>
#include <cmath>


using namespace std;
using ll = long long int;

#define rep(i, n) for(ll i = 0; i < (n); i++)

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  ll N; cin >> N;
  vector<ll> b(N, 0);
  rep(i, N - 1) {
    ll a;
    cin >> a; a--;
    b[a]++;
  }

  for (ll a : b) {
    cout << a << endl;
  }
  

  return 0;
}

Measured memory_bytes: 4448
from copy import deepcopy
N, M = map(int, input().split())
INF = 10**9+7
graph = [[INF for _ in range(N)] for l in range(N)]

for i in range(M):
  a, b, c = map(int, input().split())
  a -= 1
  b -= 1

  graph[b][a] = c
  graph[a][b] = c

newGraph = deepcopy(graph)

for k in range(N):
  for i in range(N):
    for j in range(N):
      newGraph[i][j] = min(newGraph[i][j], newGraph[i][k] + newGraph[k][j])

res = 0
for (i, row) in enumerate(newGraph):
  for (j, weight) in enumerate(row):
    if graph[i][j] != weight and graph[i][j] != INF:
      res += 1
print(res//2)

Measured memory_bytes: 43992
def num_divisors_cnt(n):
    table = [0] * (n + 1)
    
    for i in range(1, n+1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table

def main():
    N, K = map(int, input().split())
    ans = 0
    
    for i in range(K+1,N+1):
        cnt = i - K
        cnt *= N // i
        cnt += max((N % i) - K + 1,0)
        ans += cnt
    if K == 0:
        ans -= N
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 64024
#include <stdio.h>
int main(){
 
  int d[6],n,i,j,blank,ue,mae;
   
  for(i = 0; i < 6; i++){
     
    scanf("%d",&d[i]);
     
  }
   
  scanf("%d",&n);
   
  for(j = 0; j < n; j++){
     
    scanf("%d %d",&ue,&mae);
     
    for(i = 0; d[1] != mae && i < 3; i++){
 
      //3S
      blank=d[0];
      d[0]=d[4];
      d[4]=d[5];
      d[5]=d[1];
      d[1]=blank;
       
    }
     
    if(d[1] != mae){
 
      //1E
      blank=d[0];
      d[0]=d[3];
      d[3]=d[5];
      d[5]=d[2];
      d[2]=blank;
       
      for(i = 0; d[1] != mae; i++){
 
    //3S
    blank=d[0];
    d[0]=d[4];
    d[4]=d[5];
    d[5]=d[1];
    d[1]=blank;
     
      }
       
    }
     
    for(i = 0; d[0] != ue; i++){
 
      //3E
      blank=d[0];
      d[0]=d[3];
      d[3]=d[5];
      d[5]=d[2];
      d[2]=blank;
       
    }
     
    printf("%d\n",d[2]);
     
  }
   
  return 0;
 
}


Measured memory_bytes: 2140
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main(){
	int n,c;
	
	while(0<=scanf("%d",&n)){
		if(n==0)break;
		c=0;
		while(n!=1){
			if(n%2==0){
				n=n/2;
			}else{
				n=3*n+1;
			}
			++c;
		}
		printf("%d\n",c);
	}
	return 0;
}

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

using namespace std;

int main(void)
{
  int e;
  while(cin >> e, e) {
    int min = e;
    for(int z = 0; z*z*z <= e; z++) {
      for(int y = 0; y*y <= e - z*z*z; y++) {
        int x = e - z*z*z - y*y;
        if (x + y + z < min) min = x + y + z;
      }
    }
  cout << min << endl;
  }

  return 0;
}

Measured memory_bytes: 3068
#include        <bits/stdc++.h>
using   namespace       std;
typedef long long ll;

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        int N, K;
        cin >>N >>K;
        vector<int> A(N+1, 0);
        Rep0(i, K) {
                int d;
                cin >>d;
                int a;
                Rep0(j, d) {
                        cin >>a;
                        A.at(a)=1;
                }
        }
        int S=N;
        Rep1(i, N)
                S-=A.at(i);
        cout <<S <<endl;
        return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, D, l, r;
  cin >> A >> B >> C >> D;
  l = A + B;
  r = C + D;
  if (l > r) printf("Left\n");
  else if (l < r) printf("Right\n");
  else printf("Balanced\n");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N;
  cin >> N;
  vector<long long> A(N);
  
  long long sum = 0;
  long long minus = 0;
  long long min = INF;
  for (int i = 0; i < N; i++) 
  {
    long long a;
    cin >> a;
    A.at(i) = a;
    sum += abs(a);
    if (a < 0) minus++;
    chmin(min, abs(a));
  }
  
  long long ans;
  if (minus % 2 == 0) ans = sum;
  else ans = sum - min * 2;
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,K,A[200001],B[200001],res=0;
  vector<int> a(0);
  cin >> N >> K;
  for(int i=0;i<200001;i++){
    B[i] = 0;
  }
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  for(int i=0;i<N;i++){
    B[A[i]]++;
  }
  for(int i=0;i<200001;i++){
    if(B[i])
      a.push_back(B[i]);
  }
  sort(a.begin(),a.end());
  for(int i=0;i<max(int(a.size())-K,0);i++){
    res += a[i];
  }
   
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 2936
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		boolean j = false;

		int n = sc.nextInt();

		for(int i = 1; i < 10; i++) {
			if(n%i==0) {
				int a = n/i;
				if(0 < a &&  a < 10) {
					j = true;
					break;
				}
			}
		}

		System.out.println(j ? "Yes" : "No");
	}
}

Measured memory_bytes: 35636
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

from collections import deque
import itertools

h,w = map(int,readline().split())
cx,cy = map(int,readline().split())
gx,gy = map(int,readline().split())
cx -= 1
cy -= 1
grid = [readline().rstrip() for i in range(h)]

dist = [[INF]*w for i in range(h)]
dist[cx][cy] = 0

l2 = list(itertools.product([-2,-1,0,1,2],repeat = 2))
l1 = [(-1,0),(1,0),(0,-1),(0,1)]
q1 = deque([(cx,cy)])

while q1:
    if q1:
        x,y = q1.popleft()
        for dy,dx in l1:
            ny,nx = y+dy, x+dx
            if not (0 <= ny < w and 0 <= nx < h):
                continue
            if grid[nx][ny] == '#':
                continue
            if dist[nx][ny] > dist[x][y]:
                dist[nx][ny] = dist[x][y]
                q1.appendleft((nx,ny))
        for dy,dx in l2:
            ny,nx = y+dy, x+dx
            if not (0 <= ny < w and 0 <= nx < h):
                continue
            if grid[nx][ny] == '#':
                continue
            if dist[nx][ny] > dist[x][y]+1:
                dist[nx][ny] = dist[x][y]+1
                q1.append((nx,ny))

print(dist[gx-1][gy-1] if dist[gx-1][gy-1] != INF else -1)




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

int main(){
  int a,b;
  cin >> a >> b;
  if((a+b)%2==1){
    cout << (a+b+1)/2 << endl;
  }
  else{
    cout << (a+b)/2 << endl;
  }
}
      


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#ifdef LOCAL
	#define debug(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define debug(...) 42
#endif

#define sf scanf
#define pf printf
#define nl printf("\n")
#define ps(s) printf("%s",s.c_str())
#define mem(x,val) memset(x,val,sizeof x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

inline string getString(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string getLine(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
typedef long long ll;

const int mod=1e9+7;
const int S=100100;
int main()
{
	int n;
	while(~sf("%d",&n))
	{
		ll ara[n+5];
		ll tot=0;
		for(int i=1;i<=n;i++)
		{
			sf("%lld",&ara[i]);
			tot+=ara[i];
		}

		ll ans=0;
		for(int i=n;i>=1;i--)
		{
			tot-=ara[i];
			ll cur=tot%mod;
			cur=(cur*ara[i])%mod;
			ans=(ans+cur)%mod;
		}
		pf("%lld\n",ans);
	}	
    return 0;
}



































Measured memory_bytes: 5340
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    int N;
    scanf("%d", &N);
    ll a[N];
    REP(i,0,N) scanf("%lld", &a[i]);

    ll res = 0;
    REP(i,0,N) while(a[i]%2==0) a[i]/=2, ++res;
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 384
import numpy as np
A,B,H,M=map(int,input().split())

def MAP(num,u,t,nu,nt):
    return (num-u)*(nt-nu)/(t-u)+nu

shitah=MAP(H*60+M,0,12*60,np.radians(90),np.radians(-270))
posh=[A*np.cos(shitah),A*np.sin(shitah)]
shitam=MAP(M,0,60,np.radians(90),np.radians(-270))
posm=[B*np.cos(shitam),B*np.sin(shitam)]
ans=((posh[0]-posm[0])**2+(posh[1]-posm[1])**2)**0.5
print(ans)



Measured memory_bytes: 27240
#include <iostream>
#include <cmath>
#define ROPE 50.0
#define NEXTD -30

using namespace std;
void reachable();
double dist(int,int);
int inv_in(int,int);

int index_[1000],x[1000],y[1000];
double dst[1000][1000];
int next[1000][1000];

int main(){
  //  int tmp;
  int b_num,root_num;
  //int index[1000],x[1000],y[1000];
  int s_index[1000],g_index[1000];
  //int map[1000];
  while(cin >> b_num && b_num!=0){
    //cin >> a;
    //cout << b_num << " Number of Buildings." <<endl;
    //cout << a << endl;

    //rîñÇÝÝA£vZ
    for(int i=0;i<b_num;i++){  
      //while(cin >>tmp){
      cin >> index_[i] >> x[i] >> y[i];
      //cout << index_[i] <<" " << x[i] <<" "<< y[i] << endl;
      for(int j=0;j<=i;j++){
	dst[i][j]= (dist(i,j) > ROPE) ? 10000000.0 : 100000+dist(i,j);
	dst[j][i]= dst[i][j];
	next[i][j] = (dist(i,j) > ROPE) ? NEXTD : j;
	next[j][i] = (dist(i,j) > ROPE) ? NEXTD : i;
      }
    }

    for(int k=0; k<b_num;k++){
      for(int i =0; i<b_num; i++){
	for(int j =0; j<b_num; j++){
	  if(dst[i][j] > dst[i][k] + dst[k][j]){
	    //cout << dst[i][j] << "Í" << dst[i][k] << "Æ" << dst[k][j] << "æèå«¢";
	    dst[i][j] = dst[i][k] + dst[k][j];
	    next[i][j] = next[i][k];
	    //cout << i << "ida" << j << "jda" << next[i][j] << "£XV" << endl;
	  }
	  //cout << i <<"ida" << j << "jda" << next[i][j] <<endl;
	}
      }
    }
    
    cin >> root_num;
    for(int i=0;i < root_num;i++){
      cin >> s_index[i] >> g_index[i];
      int S=inv_in(b_num,s_index[i]);
      int G=inv_in(b_num,g_index[i]);
      //cout << s_index[i] <<" " << g_index[i] <<" Start and Goal index"<< endl;
      //cout << inv_in(b_num,s_index[i]) <<" " << inv_in(b_num,g_index[i]) 
      //	   <<" Start and Goal num"<< endl;
      
      //cout << "S" << S << "G" << G << endl;
 
      if(next[S][G]!=NEXTD){
	for(int j=S;j!=G;j=next[j][G]){
	  cout << index_[j] << ' ' ;
	}
	cout << index_[G] << endl;
      }
      else{
	cout << "NA" << endl;
      }    
    }
    
    
    /*
    for(int i=0;i<b_num;i++){
      for(int k=0;k<b_num;k++){
	cout << next[i][k] << " -> " << i << "Æ" << k << "ÆÌÔÌÌs«æ" << endl; 
	//	dst[i][j]
      }
      cout << endl;
    }
    */
  }
  
}

double dist(int i,int j){
  double dis;
  dis = pow(pow(double(x[i]-x[j]),2.0)+pow(double(y[i]-y[j]),2.0),0.5);
  return dis;
}

int inv_in(int b_num,int b_ind){
  int inv;
  for(int j=0;j<b_num;j++){
    if(index_[j]==b_ind){
      inv = j;
      break;
    }
  }
  return inv;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define vl vector
#define pb push_back
using namespace std;
int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    bool turn=true;
    while(1)
    {
        if(turn)
        {
            c-=b;
            if(c<=0)
            {
                cout<<"Yes";
                return 0;
            }
        }
        else 
        {
            a-=d;
            if(a<=0)
            {
                cout<<"No";
                return 0;
            }
        }
        turn=!turn;
    }
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

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

		int a = sc.nextInt();
		String op = sc.next();
		int b = sc.nextInt();
		if (op.equals("+")) {
			System.out.println(a + b);
		} else {
			System.out.println(a - b);
		}
	}

}


Measured memory_bytes: 21844
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const int MOD = 1000000007;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }

int main() {
    int n, k;
    cin >> n >> k;
    cout << mod_pow(k, n, MOD) << endl;

    return 0;
}


Measured memory_bytes: 3104
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from heapq import heappush,heappop
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input().rstrip()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
# mod=1000000007
mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')



    
def solve():

    
    # for _ in range(ii()):

    n,k = mi()

    seg = []

    for i in range(k):
        seg.append(li())

    dp = [0]*(n+1)

    dp[1] = 1
    for i in range(2,n+1):
        dp[i] += dp[i-1]
        dp[i] %= mod
        for j in range(k):
            if seg[j][0] >= i:
                continue


            l = max(1,i - seg[j][1])

            r =  i - seg[j][0]

            dp[i] += dp[r] - dp[l-1]
            dp[i] += mod
            dp[i] %= mod


    print((dp[n] - dp[n-1] + mod)%mod)


        









        
if __name__ =="__main__":

    
    if path.exists('input.txt'):
        sys.stdin=open('input.txt', 'r')
        sys.stdout=open('output.txt','w')
    else:
        input=sys.stdin.readline
    solve()

Measured memory_bytes: 76476
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int x = saori.saori_hayami();
		int y = saori.saori_hayami()/2;
		System.out.println(x+y);
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21200
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	string S, T;
	cin >> S >> T;
	int ans = 0;
	REP(i, S.size()) ans += S[i] != T[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3920
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1010;
const int MAXV = MAXN * (MAXN - 1) / 2;
vector<int64_t> to[MAXV];
int id[MAXN][MAXN];

int toId(int i, int j)
{
  if (i > j)
    swap(i, j);
  return id[i][j];
}

int dp[MAXV]; // max length if path from v
bool visited[MAXV];
bool calculated[MAXV];
int dfs(int v)
{
  if (visited[v])
  {
    if (!calculated[v])
      return -1;
    return dp[v];
  }
  visited[v] = true;
  dp[v] = 1;
  for (int u : to[v])
  {
    int res = dfs(u);
    if (res == -1)
      return -1;
    dp[v] = max(dp[v], res + 1);
  }
  calculated[v] = true;
  return dp[v];
}

int main()
{
  int64_t N;
  cin >> N;
  vector<vector<int64_t>> A(N, vector<int64_t>(N - 1));
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N - 1; j++)
    {
      cin >> A.at(i).at(j);
      A.at(i).at(j)--;
    }
  }
  int V = 0;
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      if (i < j)
        id[i][j] = V++;
    }
  }
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N - 1; j++)
    {
      A[i][j] = toId(i, A[i][j]);
    }
    for (int j = 0; j < N - 2; j++)
    {
      to[A[i][j + 1]].push_back(A[i][j]);
    }
  }
  int ans = 0;
  for (int i = 0; i < V; i++)
  {
    int res = dfs(i);
    if (res == -1)
    {
      cout << -1 << endl;
      return 0;
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
}


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

int main(void) {
  int N;
  cin >> N;
  int n;
  set<int> number;
  for (int i=0;i<N;i++) {
      cin >> n;
      number.insert(n);
  }
  cout << number.size() << endl;
  return 0;
}

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

using namespace std;
long long MOD=1000000007;
long long MOD2=998244353;

long long gcd(long long a, long long b){
  if(a<b) swap(a,b);
  long long r;
  while(b){
    r=a%b;
    a=b;
    b=r;
  }
  return a;
}

long long lcm(long long a, long long b){
  return a/gcd(a,b)*b;
}

int main(){
  long long A,B; cin>>A>>B;
  cout<<lcm(A,B)<<endl;
  return 0;
}


Measured memory_bytes: 256
n =int(input())

S = list(map(int, input().split(' ')))

q = int(input())

T = list(map(int, input().split(' ')))

def BinSearch(S, t):
    l = len(S)
    s = S
    n1 = 0
    n2 = l
    while (n2 - n1) > 4:
        x = (n2 + n1) // 2
        if S[x] == t:
            return True
        elif S[x] < t:
            n1 = x
        else:
            n2 = x
    return t in S[n1:n2]

count = 0
for t in T:
    if BinSearch(S, t):
        count += 1
print(count)


Measured memory_bytes: 16708
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

ll n;
vll w(300);
vvll dp(350, vll(350, -1));
vll result(0);

void reset(){
  for(int i = 0; i < 350; i++){
    for(int j = 0; j < 350; j++){
      dp.at(i).at(j) = -1;
    }
  }
}

ll func(ll a, ll b){ //[a, b)間で叩き出せる上限
  if(dp.at(a).at(b) != -1) return dp.at(a).at(b);
  if(b-a == 1) return dp.at(a).at(b) = 0;
  if(b-a == 2){
    if(abs(w.at(a)-w.at(b-1)) <= 1) return dp.at(a).at(b) = 2;
    return 0;
  }

  if(func(a+1, b-1) == b-a-2 && abs(w.at(a)-w.at(b-1)) <= 1) return dp.at(a).at(b) = b-a;

  ll ans = 0;
  for(int i = a+1; i < b; i++){
    chmax(ans, func(a, i) + func(i, b));
  }
  return dp.at(a).at(b) = ans;
}

int main(){
while(true){
  cin >> n;
  if(n == 0) break;

  reset();

  for(int i = 0; i < n; i++){
    cin >> w.at(i);
  }

  result.push_back(func(0, n));

}

for(auto x: result) cout << x << endl;

}


Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;

bool comp(const pair<int,char>& p1, const pair<int,char>& p2){
    return p1.first < p2.first;
}

int main()
{
    int n;
    cin >> n;
    vector<pair<int, char> > a(n),b(n),c(n);
    for(int i = 0; i < n; ++i){
        string str;
        cin >> str;
        c[i].first = str[1] - '0';
        c[i].second = str[0];
    }
    a = b = c;
    
    stable_sort(c.begin(), c.end(),comp);
    
    for(int i = 0; i < n; ++i){
        for(int j = n - 1; j >= i + 1; --j){
            if(a[j].first < a[j - 1].first){
                swap(a[j], a[j - 1]);
            }
        }
    }
    
    for(int i = 0; i < n; ++i){
        int m = i;
        for(int j = i + 1; j < n; ++j){
            if(b[j].first < b[m].first){
                m = j;
            }
        }
        if(m != i){
            swap(b[m], b[i]);
        }
    }
    
    for(int i = 0; i < n; ++i){
        if(i != 0) cout << ' ';
        cout << a[i].second << a[i].first;
    }
    cout << endl;
    if(a == c){
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
    
    for(int i = 0; i < n; ++i){
        if(i != 0) cout << ' ';
        cout << b[i].second << b[i].first;
    }
    cout << endl;
    if(b == c){
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end() 
 
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
 
const int INF = 1 << 25;
 
template<class T>
void chmin (T& a, const T& b) { a = min(a, b); }
 
template<class T>
void chmax (T& a, const T& b) { a = max(a, b); }
 
 
int main() {
    cin.tie();
 
    int n, a, last = -1, count = 0;
    cin >> n;
 
    REP(i, n) {
      cin >> a;
      if (a == last) {
      	count++;
        last = -1;
      } else {
        last = a;
      }
    }
 
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
    int n,h,w;
    scanf("%d %d %d",&n,&h,&w);
    int a,b;
    int i;
    int count=0;
    for(i=0;i<n;i++){
        scanf("%d %d",&a,&b);
        if(a/h>0){
            if(b/w>0){
                count=count+1;
            }
        }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 256
import itertools
h, w, k = list(map(int, input().split()))

#Hの組み合わせ生成
h_tmp=[]
for i in range(h):
    h_tmp.append(i)
h_kumi = []
for i in range(h):
    h_kumi.extend(itertools.combinations(h_tmp,i))

#Wの組み合わせ生成
w_tmp=[]
for i in range(w):
    w_tmp.append(i)
w_kumi = []
for i in range(w):
    w_kumi.extend(itertools.combinations(w_tmp,i))

c=[]
for i in range(h):
    c.append(list(input()))
ans = 0
for hk in h_kumi:
    for wk in w_kumi:
        counta=0
        for w_ in range(len(c[0])):
            for h_ in range(len(c)):
                #print(w_,h_)
                #if c[h_][w_]=='#'and h_<hk[0] and h_>hk[1] and w_<wk[0] and w_>wk[1]:
                if c[h_][w_]=='#' and not(h_ in hk) and not(w_ in wk):
                    counta+=1
        #print(counta,hk,wk)
        if counta == k:
            ans+=1
print(ans)
exit()


Measured memory_bytes: 9236
#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

double dp[3000][3000];

int main()
{
    string S;

    cin >> S;

    bool ok = false;
    if (S[0] == S[1]) {
        ok = (S[2] == S[3] && S[0] != S[2]);
    } else {
        ok = ((S[0] == S[2] && S[1] == S[3]) || (S[0] == S[3] && S[1] == S[2]));
    }

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <deque>
using namespace std;

int main(){
  int n,c,i;
  for(cin>>n;n;n--){
    deque<char> d;
    string s;
    cin>>s;
    d.push_back(s[0]);
    for(i=1,c=0;i<s.size();i+=3){
      if(s[i]=='-')c++;
      else c--;
      if(c==d.size())d.push_back(s[i+2]);
      if(c==-1)d.push_front(s[i+2]),c=0;
    }
    for(i=0;i<d.size();i++)cout<<d[i];
    cout<<endl;
  }
}

Measured memory_bytes: 0
/**
 * Copyright (c) 2017, xehoth
 * All rights reserved.
 * 「ARC 085D」ABS 06-12-2017
 *
 * @author xehoth
 */
#include <bits/stdc++.h>

int main() {
    register int n, z, w, a, b;
    std::cin >> n >> z >> w;
    if (n == 1) {
        std::cin >> a, std::cout << std::abs(a - w);
        return 0;
    }
    for (register int i = 1, t; i <= n - 2; i++) std::cin >> t;
    std::cin >> a >> b;
    std::cout << std::max(std::abs(a - b), std::abs(b - w));
    return 0;
}

Measured memory_bytes: 256
n = raw_input()
a = raw_input().split(' ')
a = map(int, a)
s = 0
sunuke = a[0]
arai = a[len(a)-1]
for i in a:
	s = s + i
m = abs(sunuke - (s - sunuke))

for i in range(1,len(a)-2):
	sunuke = sunuke + a[i]
	arai = s - sunuke
	if abs(arai-sunuke) < m:
		m = abs(arai-sunuke)


print m

Measured memory_bytes: 18416
#include <bits/stdc++.h>
#define REP(asd, fgh) for(int asd = 0; asd < fgh; asd++)
using namespace std;
 
int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);
 
  int N, M;
  cin >> N >> M;
  vector<int> white(N+1, 0), blue(N+1, 0), red(N+1, 0);
  REP(i, N){
    REP(j, M){
      char c; cin >> c;
      if(c != 'W'){
        white[i+1]++;
      }
      if(c != 'B'){
        blue[i+1]++;
      }
      if(c != 'R'){
        red[i+1]++;
      }
    }
  }
  for(int i = 1; i < N+1; i++){
    white[i] += white[i-1];
    blue[i] += blue[i-1];
    red[i] += red[i-1];
  }
 
  int ans = INT_MAX/2;
  for(int w = 1; w <= N-2; w++){
    for(int b = w+1; b <= N-1; b++){
      ans = min(ans, white[w] - white[0] +
                     blue[b] - blue[w] +
                     red[N] - red[b]
               );
    }
  }
 
  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 1200
#include <cstdio>
using namespace std;
int main(){
  int w,h,x,y,r;
  scanf("%d %d %d %d %d",&w, &h,&x,&y,&r);
  if( r<=x &&x+r<=w&&r<=y&&r+y<=h)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 2620
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int L, N; cin >> L >> N;
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		int x, w; cin >> x >> w;
		sum += x*w;
	}
	vector<pair<int, int>>anss;
	
		if (sum > 0) {
			for (int i = 0; i < sum; ++i) {
				anss.push_back(make_pair(-1, 1));
			}
		}
		else {
			for (int i = 0; i < -sum; ++i) {
				anss.push_back(make_pair(1, 1));
			}
			sum = -sum;
		}
	
	cout << sum << endl;
	for (int i = 0; i < anss.size(); ++i) {
		cout << anss[i].first << " " << anss[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 3248
#include<cstdio>
#include<iostream>
using namespace std;
char a[5][5];
int main()
{
	for(int i=1;i<=3;i++)
	{
		for(int j=1;j<=3;j++)
		{
			cin>>a[i][j];
		}
	}
	printf("%c%c%c\n",a[1][1],a[2][2],a[3][3]);
	return 0;
} 

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    from collections import Counter
    c = Counter()
    ma = max(A)
    for a in A:
        for i in range(ma//a + 1):
            c[a*i] += 1

    ans = 0
    for a in A:
        if c[a] == 1:
            ans += 1

    return ans


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))

    # from random import randint
    # N = 2* (10**5)
    # A = [randint(1, 10**6) for _ in range(N)]
    # print(slv(N, A))


if __name__ == '__main__':
    main()


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

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

bool t=true;
int x;
vector<int> input;
int inpmax=0;
int ans,ansodd;


int main(){
    while(true){
        cin>>x;
        if(x==0)break;
        input.push_back(x);
        if(inpmax<x)inpmax=x;
    }
    vector<int> tri={1};
    vector<int> tetra={1};
    vector<int> tetraodd={1};
    int oddcnt=2;
    vector<int> dpmin={0},dpmind={0};
    for(int i=2;i<100000;i++){
        tri.push_back(tri.back()+i);
        tetra.push_back(tri.back()+tetra.back());
        
        dpmin.push_back(1);
        if(tetra[i-2]<inpmax){
            for(int k=tetra[i-2]+1;k<tetra[i-1];k++){
                dpmin.push_back(dpmin.back()+1);
                for(int l=1;l<i-1;l++){
                    chmin(dpmin[k],dpmin[k-tetra[l]]+1);
                }
            }
        }
        if(tetra.back()%2){
            tetraodd.push_back(tetra.back());
            dpmind.push_back(1);
            if(inpmax<tetraodd[oddcnt-2])break;
            for(int k=tetraodd[oddcnt-2]+1;k<tetraodd[oddcnt-1];k++){
                dpmind.push_back(dpmind.back()+1);
                for(int l=1;l<oddcnt-1;l++)
                    chmin(dpmind[k],dpmind[k-tetraodd[l]]+1);
            }
            oddcnt++;
        }
    }
    for(int i=0;i<input.size();i++)cout<<dpmin[input[i]]<<" "<<dpmind[input[i]]<<endl;

    return 0;

}


Measured memory_bytes: 10676
// Author : Hardik Upadhyay
// college: SVNIT 
// slogan : Ab to phod dunga
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i = a ; i >= b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int MAXN = 100005;
ll mod=1000000007;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	if(s=="ABC"){
		cout<<"ARC"<<nl;
	}
	else cout<<"ABC"<<nl;
	return 0;
}



Measured memory_bytes: 3612
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

ll solve(ll a, ll b, ll c) {
	return a + b + 1LL >= c ? b + c : (a + b + 1LL) + b;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	ll a, b, c;
	cin >> a >> b >> c;

	ll ans = solve(a, b, c);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define SIZE 131072
class BIT
{
public:
	ll bit[SIZE + 1];
	void add(int a, ll b)
	{
		a+=5;
		for (;;)
		{
			bit[a] += b;
			bit[a] %= mod;
			a += a&-a;
			if (a > SIZE)return;
		}
	}
	ll get(int a)
	{
		a+=5;
		ll ret = 0;
		for (;;)
		{
			ret += bit[a];
			ret %= mod;
			a -= a&-a;
			if (a == 0)return ret;
		}
	}
};
BIT bi;
int main()
{
	int num;
	ll da, db;
	scanf("%d%lld%lld", &num, &da, &db);
	if (da > db)swap(da, db);
	vector<ll>vec;
	vec.push_back(-3000000000000000000LL);
	for (int i = 0; i < num; i++)
	{
		ll z;
		scanf("%lld", &z);
		vec.push_back(z);
	}
	bi.add(0, 1);
	int pt = 0;
	for (int i = 0; i < num; i++)
	{
		int upp = upper_bound(vec.begin(), vec.end(), vec[i + 1] - db) - vec.begin() - 1;
		ll t;
		if (upp >= pt)t = bi.get(upp) - bi.get(pt - 1);
		else t = 0;
		if (vec[i + 1] - vec[i] < da)pt = i;
		if (i > 0)if (vec[i + 1] - vec[i - 1] < da)pt = i + 1;
		bi.add(i + 1, (t + mod) % mod);
	}
	if (num >= pt)printf("%lld\n", (bi.get(num) - bi.get(pt - 1) + mod) % mod);
	else printf("0\n");
}

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

int main() {
  
  int n; cin >> n; int pointT = 0; int pointH = 0;
  
  for (int i = 0; i < n; i++) {
    
    string t, h; cin >> t >> h;
    
    if (t == h) {
      pointT++; pointH++;
    }
    else if (h < t) pointT += 3;
    else if (t < h) pointH += 3;
    
  }
  
  cout << pointT << " " << pointH << endl;
  
}


Measured memory_bytes: 3156
#include<stdio.h>
int main()
{
    long long int i,j,k;
    char x;
   scanf("%11d %c %11d",&i,&x,&j);
    if(x=='+')
    {
        k=i+j;
        printf("%11d\n",k);

    }
    else if(x=='-')
    {
        k=i-j;
        printf("%11d\n",k);
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll dp[100001];
int main()
{
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(int x=0;x<n;x++)
    cin>>a[x];
    for(int x=0;x<n;x++)
        dp[x]=10000000000000;
        dp[0]=0;
    for(int x=1;x<n;x++)
    {
        for(int y=1;y<=k;y++)
        {
            if((x-y)>=0)
                dp[x]=min(dp[x],dp[x-y]+abs(a[x]-a[x-y]));
        }
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1792
import math
 
N = int(input())
h = list(map(int, input().split()))
dp = [float('INF')] * N
 
def chmin(a, b):
    if a >= b:
        return b
    else:
        return a
 
#初期値
dp[0] = 0
 
#Loop
for i in range(1, N):
    dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))
print(dp[-1])

Measured memory_bytes: 13976
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int main(){
  int M;
  cin >> M;
  cout << (48-M) << endl; 

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n)cin >> a[i];
    vector<ll> sum(n, 0);
    sum[0] = a[0];
    for(int i = 1; i < n; i++)sum[i] = sum[i-1] + a[i];
    ll ans = 0;
    rep(i, n){
        sum[i] %= m;
        if(sum[i] == 0)ans++;
    }

    map<ll, int> mp;
    rep(i, n)mp[sum[i]]++;
    for(auto i = mp.begin(); i != mp.end(); i++){
        ll k = i->second;
        ans += k * (k - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5376
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn pow_m(n: i64, mut p: i64, m: i64) -> i64 {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % m;
            p /= 2;
        } else {
            ret = ret * r % m;
            p -= 1;
        }
    }
    ret
}

fn main() {
    // TODO n = 1
    let v = read_vec::<i64>();
    let (n, a, b, c) = (v[0], v[1], v[2], v[3]);
    let big_int = 1000_000_000 + 7;

    let mut numerator = 0;

    for &(a, b) in &[(a, b), (b, a)] {
        let mut coef = pow_m(a, n, big_int);
        let mut denom = pow_m(a + b, n, big_int);

        for i in n..2 * n {
            let mut temp = i * coef;
            // debug!(i, temp, coef);
            temp %= big_int;
            let denom_denom = mod_inverse(denom, big_int);
            temp *= denom_denom;
            temp %= big_int;
            // debug!(temp);
            numerator += temp;
            numerator %= big_int;
            // debug!(mod_inverse(numerator, big_int));

            // update
            coef *= i;
            coef %= big_int;
            coef *= mod_inverse(i - n + 1, big_int);
            coef %= big_int;
            coef *= b;
            coef %= big_int;
            denom *= a + b;
            denom %= big_int;
        }
    }
    // println!("{:?}", mod_inverse(numerator, big_int));
    let mut hikiwake = (100 * mod_inverse(100 - c, big_int)) % big_int;
    if c > 0 {
        numerator *= hikiwake;
        numerator %= big_int;
    }
    println!("{:?}", numerator);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn extgcd(a: i64, b: i64, x: &mut i64, y: &mut i64) -> i64 {
    let mut d = a;
    if b == 0 {
        *x = 1;
        *y = 0;
    } else {
        d = extgcd(b, a % b, y, x);
        *y -= (a / b) * (*x);
    }
    return d;
}

fn mod_inverse(a: i64, m: i64) -> i64 {
    let mut x: i64 = 0;
    let mut y: i64 = 0;
    extgcd(a, m, &mut x, &mut y);
    (m + x % m) % m
}


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

using namespace std;


int main()
{
	int n,m; cin >> n >> m;
	int h[n];
	for(int i = 0; i < n; i++) cin >> h[i];
	vector<int> adj[n];
	for(int i = 0; i < m; i++){
		int x,y; cin >> x >> y;
		adj[--x].push_back(--y);
		adj[y].push_back(x);
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(adj[i].size() == 0){ ans++; continue;}
		bool good = true;
		for(int e : adj[i]){
			good &= h[i] > h[e];	
		}
		if(good) ans++;
	}
	cout << ans;
}



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


int main(){
    int p,q,r;
    cin >> p >> q >> r;
    int a=p+q;
    int b=q+r;
    int c=r+p;
    cout << min(a,min(b,c)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000000000000
#define lli long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n;
    cin>>n;
    lli h[n], dp[n];
    for(int i=0; i<n; i++)
        cin>>h[i];
    dp[0]=0, dp[1]=abs(h[1]-h[0]);
    for(int i=2; i<n; i++)
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 5136
import std.container;
import std.range;
import std.algorithm;
import std.array;
import std.string;
import std.conv;
import std.stdio;
import std.container;

void main() {
	int n, m;
	readf(" %s %s\n", &n, &m);

	auto tree = new int[n];
	foreach (size_t i, ref e;tree) {
		e = cast(int)i;
	}

	int getRoot(int a) {
		if (tree[a] == a) {
			return a;
		}
		return tree[a] = getRoot(tree[a]);
	}

	bool sameRoot(int a, int b) {
		return getRoot(a) == getRoot(b);
	}

	void unite(int a, int b) {
		auto rootA = getRoot(a);
		tree[getRoot(b)] = rootA;
	}

	foreach (i;0..m) {
		int a, b;
		readf(" %s %s", &a, &b);
		--a;
		--b;

		unite(a, b);
	}

	auto count = new int[2 * 10 ^^ 5 + 1];

	foreach (int i;0..n) {
		getRoot(i);
		++count[tree[i]];
	}

	count.reduce!max.writeln;
}


Measured memory_bytes: 5280
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            long A = sc.nextLong();
            String B = sc.next();
            String[] split = B.split("[.]");
            long B1 = Long.parseLong(split[0]);
            long B2 = Long.parseLong(split[1]);
            long B3 = B1 * 100 + B2;
            System.out.println((A * B3) / 100);
        }
    }
}


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

vector<vector<int>> g;
vector<int> o;
map<int, int> ad;
vector<ll> c;

int main(){
	int x;
	cin >> x;
	vector<int> a(1);
	a.at(0) = 1;
	for(int i=2; i<=100; i++) for(int j=2; j<=10; j++){
		int k = pow(i, j);
		if(k > 1000) break;
		a.push_back(k);
	}
	sort(a.begin(), a.end());/*
	rep(i, a.size()) cout << a.at(i) << ' ';
	cout << endl;*/
	int l = upper_bound(a.begin(), a.end(), x) - a.begin();
	cout << a.at(l-1) << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,a,q,b,c,sum=0;
    cin>>n;
    std::map<long long int, long long int> map;
    for (int i=0;i<n;i++) {
        cin>>a;
        map[a]++;
        sum+=a;
    }
    cin>>q;
    for (int i=0;i<q;i++) {
        cin>>b>>c;
        sum-=b*map[b];
        sum+=c*map[b];
        cout<<sum<<endl;
        map[c]+=map[b];
        map[b]=0;
    }
}

Measured memory_bytes: 9444