akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

#define MAX 500
#define INF (1 << 21)

int cap[MAX][MAX];
bool visited[MAX];
int parent[MAX];
int flow[MAX][MAX];
int layer[MAX];

void make_layer(int n,int s,int t){
  queue<int> Q;
  Q.push(s);
  layer[s]=0;
  while(!Q.empty()){
    int now = Q.front();
    Q.pop();
    rep(i,n){
      if ( cap[now][i]-flow[now][i]>0 && layer[i]==-1){
	layer[i]=layer[now]+1;
	Q.push(i);
      }
    }
  }
}

int augment(int now,int t,int n,int f){
  if (now == t || f == 0)return f;
  if (visited[now])return 0;
  visited[now]=true;
  rep(i,n){
    if (layer[now]<layer[i]){
      int tmp = augment(i,t,n,min(f,cap[now][i]-flow[now][i]));
      if (tmp > 0){
	flow[now][i]+=tmp;
	flow[i][now]=-flow[now][i];
	visited[now]=false;
	return tmp;
      }
    }
  }
  return 0;
}


int dinic(int n,int s,int t){
  int ansflow=0;
  bool flag=true;
  rep(i,n)rep(j,n)flow[i][j]=0;
  while(flag){
    fill(layer,layer+n,-1);
    fill(visited,visited+n,false);
    flag=false;
    make_layer(n,s,t);
    if (layer[t]==-1)break;
    
    for(int f=1;f;flag=true){
      f = augment(s,t,n,INF);
      if ( f==0)break;
      ansflow+=f;
    }
  }
  return ansflow;
}


#define SSOURCE 0
#define Nwin    1
#define Nwout   2
#define Ncin    3
#define Ncout   4
#define Nmin    5
#define Nmout   6
#define SSINK   7

#define IN(i)  (2*i)
#define OUT(i) (2*i+1)

main(){
  int h,w,c,m,nw,nc,nm;
  while(cin>>h>>w>>c>>m>>nw>>nc>>nm && h != -1){
    int n = 8+2*h+2*w+2*c+2*m;
    int He =8;
    int Wa =He+2*h;
    int Cl =Wa+2*w;
    int Ma =Cl+2*c;
    rep(i,n)rep(j,n)cap[i][j]=0;
    cap[Nwin][Nwout]=nw;
    cap[Ncin][Ncout]=nc;
    
    cap[Nmin][Nmout]=nm;
    cap[Nmout][SSINK]=INF;

    rep(i,h){
      cap[SSOURCE][He+IN(i)]=1;
      cap[He+IN(i)][He+OUT(i)]=1;
      cap[He+OUT(i)][Nwin]=1;
    }
    
    rep(i,w){
      int num;
      cin>>num;
      cap[Wa+IN(i)][Wa+OUT(i)]=1;
      cap[Wa+IN(i)][Ncin]=1;
      rep(j,num){
	int t;
	cin>>t;
	t--;
	cap[He+OUT(t)][Wa+IN(i)]=1;
      }
    }
    
    rep(i,c){
      int num;
      cin>>num;
      cap[Nwout][Cl+IN(i)]=1;
      cap[Cl+IN(i)][Cl+OUT(i)]=1;
      cap[Cl+OUT(i)][Nmin]=1;
      rep(j,num){
	int t;
	cin>>t;
	t--;
	cap[Wa+OUT(t)][Cl+IN(i)]=1;
      }
    }
    
    
    
    rep(i,m){
      int num;
      cin>>num;
      cap[Ncout][Ma+IN(i)]=1;
      cap[Ma+IN(i)][Ma+OUT(i)]=1;
      cap[Ma+OUT(i)][SSINK]=1;
      rep(j,num){
	int t;
	cin>>t;
	t--;
	cap[Cl+OUT(t)][Ma+IN(i)]=1;
      }
    }
    
    

    cout << dinic(n,SSOURCE,SSINK) << endl;


  
  }
  
}

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i != n; ++i)
        cin >> arr[i];
    
    vector<int> tmp(1, arr[0]);
    for (int i = 1; i != n; ++i)
    {
        int l = -1;
        int r = tmp.size();
        
        while (r - l != 1)
        {
            int m = l + r >> 1;
            
            if (tmp[m] >= arr[i])
                l = m;
            else
                r = m;
        }
        
        if (r == tmp.size())
            tmp.push_back(arr[i]);
        else
            tmp[r] = max(tmp[r], arr[i]);
    }
    
    cout << tmp.size() << '\n';
    
    return 0;
}

Measured memory_bytes: 1276
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int[][] c = new int[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                c[i][j] = sc.nextInt();
            }
        }

        int[] a = new int[3];
        int[] b = new int[3];
        a[0] = 0;
        b[0] = c[0][0] - a[0];
        b[1] = c[0][1] - a[0];
        b[2] = c[0][2] - a[0];
        a[1] = c[1][0] - b[0];
        a[2] = c[2][0] - b[0];
        boolean isYes = true;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (c[i][j] != a[i] + b[j]) {
                    isYes = false;
                }
            }
        }
        System.out.println(isYes ? "Yes" : "No");
    }
}

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


int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[100005];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  cout<<a[n/2]-a[n/2-1];
  
}



Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
 int a,b,i,k;
 cin>>a>>b;
 if (a<=b){
    for(i=0; i<b; i++){
        cout<<a;
    }
 }
 else{
    for(k=0; k<a; k++){
        cout<<b;
    }
  }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<int,int> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

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

int n;
int squ[1100];
int cub[110];

int main(){
	for(int i=0;i<=1000;i++){
		squ[i]=i*i;
	}
	for(int i=0;i<=100;i++){
		cub[i]=i*i*i;
	}
	while(1){
		cin>>n;
		if(n==0)break;
		int ans=INF;
		for(int i=0;i<=100&&cub[i]<=n;i++){
			for(int j=0;j<=1000&&squ[j]+cub[i]<=n;j++){
				ans=min(ans,i+j+(n-cub[i]-squ[j]));
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3012
import Control.Applicative
import qualified Data.Map.Strict as Map
 
main = do
    [_,capa] <- map (read :: String -> Int) . words <$> getLine
    goods <- map (map (read :: String -> Int) . words) . lines <$> getContents
    print $ maximum $ map snd $ Map.toList (resolve capa (Map.fromList (zip [0..capa] [0,0..])) goods)
 
resolve capa capaMap ([v,w]:xs)
  | xs == []  = koushin'
  | otherwise = resolve capa koushin' xs
  where
    koushin' =  koushin capaMap [v,w] 0
    koushin capaMap [v,w] n
      | n == 0 && capaMap Map.! w <= v      = next'
      | n > (capa - w)                      = capaMap
      | capaMap Map.! (n+w) >= v + oldValue = next
      | otherwise                           = next'
      where
        oldValue = capaMap Map.! n
        next     = koushin capaMap [v,w] (n+1)
        next'    = koushin (Map.insert (n+w) (v + oldValue) capaMap) [v,w] (n+1)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<string> S(N);
    REP(i, N) cin >> S[i];

    ll res = 0;
    REP(i, N){
    	REP(j, S[i].size()-1){
    		if(S[i][j] == 'A' && S[i][j+1] == 'B') res++;
    	}
    }
    dump(res)
    ll X = 0, Y = 0, Z=0;
    REP(i, N){
    	if(S[i][0] == 'B' && S[i][S[i].size()-1] == 'A') Z++;
    	else if(S[i][0] == 'B') X++;
    	else if(S[i][S[i].size()-1] == 'A') Y++;
    }
    //dump(X)
    //dump(Y)
    //dump(Z)
    if(Z > 0){
    	res += Z-1;
	    if(X > 0){
	    	res++;
	    	X--;
	    }
	    if(Y > 0){
	    	res++;
	    	Y--;
	    }
	}
    res += min(X, Y);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pob pop_back
#define vi vector<ll>
#define mp make_pair
#define sz size()
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define maxx 100005
#define edge pair<ll,ll>
#define mod 1000000007
using namespace std;
 
 
// ¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++¦¦¦++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦¦¦¦¦¦¦¦¦+++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦+++++++¦++¦¦
// ¦¦¦¦¦¦¦¦++¦¦¦¦¦¦++++++¦¦¦¦+++++++++++++¦
// ¦¦¦¦¦¦¦++++++¦¦¦++++++¦¦++++++++++++++¦¦
// ¦¦¦¦¦¦¦+++++++¦¦¦+++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++¦¦¦¦¦¦¦¦+++++++¦ 
// ¦¦¦¦¦¦¦¦¦¦++¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦++++¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦ 
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦+¦++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++¦¦+++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦¦+++¦¦¦¦++++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++¦¦+¦¦¦¦¦+++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦+++++++++++¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦¦¦¦


int main(){

	fast;
	float n,a,b,c;
	string s,t;
	ll i,j,k;
	float pi=3.1415926535;
	cin>>n;
	cout<<2*pi*n<<endl;
	



	return 0;
}

Measured memory_bytes: 3828
import numpy as np
import sys

n = int(input())

# jobs = pd.DataFrame(columns=["cost", "deadline"])

a = []
b = []

for i in range(n):
    aa, bb = map(int, input().split(' '))
    a.append(aa)
    b.append(bb)

a = np.array(a)
b = np.array(b)

sortIndex = np.argsort(b)

a = a[sortIndex]
b = b[sortIndex]

sum = 0
for i in range(n):
    sum += a[i]
    if sum > b[i]:
        print('No')
        sys.exit()

print('Yes')

Measured memory_bytes: 28040
#include <iostream>

using namespace std;

int main(){
    int A, B, C;
    int ans;
    cin >> A >> B >> C;
    if(max(A, max(B, C))%2 == (A+B+C)%2){
        ans = (max(A, max(B, C))*3 - (A+B+C))/2;
    }else{
        ans = ((max(A, max(B, C))+1)*3 - (A+B+C))/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>

int main(){


    int n,k,soma=1;

    scanf("%d %d",&n,&k);

    for(int i=0;i<n;i++){
        if(soma*2<=soma+k){
            soma=soma*2;
        }else if(soma+k<=soma*2){
            soma=soma+k;
        }
    }
    printf("%d\n",soma);

    return 0;
}


Measured memory_bytes: 128
loop do
  n, m = gets.split.map(&:to_i)
  break if n == 0 && m == 0
  taro_c = n.times.map{ gets.to_i }
  hana_c = m.times.map{ gets.to_i }
  dif = taro_c.reduce(:+) - hana_c.reduce(:+)
  ans = -1
  if dif.even?
    taro_c.uniq.each do |t|
      hana_c.uniq.each do |h|
        ans = [t, h] if (t - h) * 2 == dif && (ans == -1 || ans.reduce(:+) > t + h)
      end
    end
  end
  puts ans == -1 ? -1 : ans.join(' ')
end

Measured memory_bytes: 8588
class Dice():
    def __init__(self, labels):
        self.top = labels[0]
        self.front = labels[1]
        self.right = labels[2]
        self.left = labels[3]
        self.back = labels[4]
        self.bottom = labels[5]

    def roll(self, axis, count=1):
        while count < 0:
            count += 4
        if axis == "X":
            for _ in range(count):
                self.top, self.back, self.bottom, self.front = self.front, self.top, self.back, self.bottom
        elif axis == "Y":
            for _ in range(count):
                self.top, self.right, self.bottom, self.left = self.left, self.top, self.right, self.bottom
        elif axis == "Z":
            for _ in range(count):
                self.front, self.left, self.back, self.right = self.right, self.front, self.left, self.back
        elif axis == "N":
            self.roll("X", 1)
        elif axis == "W":
            self.roll("Y", -1)
        elif axis == "S":
            self.roll("X", -1)
        elif axis == "E":
            self.roll("Y", 1)


def is_identical(d1, d2):
    for _ in range(4):
        if d1.top == d2.top and d1.bottom == d2.bottom and d1.front == d2.front and d1.back == d2.back and d1.left == d2.left and d1.right == d2.right:
            return True
        d2.roll("Z")
    d2.roll("X")
    for _ in range(4):
        if d1.top == d2.top and d1.bottom == d2.bottom and d1.front == d2.front and d1.back == d2.back and d1.left == d2.left and d1.right == d2.right:
            return True
        d2.roll("Y")
    d2.roll("X")
    for _ in range(4):
        if d1.top == d2.top and d1.bottom == d2.bottom and d1.front == d2.front and d1.back == d2.back and d1.left == d2.left and d1.right == d2.right:
            return True
        d2.roll("Z")
    d2.roll("X")
    for _ in range(4):
        if d1.top == d2.top and d1.bottom == d2.bottom and d1.front == d2.front and d1.back == d2.back and d1.left == d2.left and d1.right == d2.right:
            return True
        d2.roll("Y")
    d2.roll("X")
    d2.roll("Y")
    for _ in range(4):
        if d1.top == d2.top and d1.bottom == d2.bottom and d1.front == d2.front and d1.back == d2.back and d1.left == d2.left and d1.right == d2.right:
            return True
        d2.roll("X")
    d2.roll("Y", 2)
    for _ in range(4):
        if d1.top == d2.top and d1.bottom == d2.bottom and d1.front == d2.front and d1.back == d2.back and d1.left == d2.left and d1.right == d2.right:
            return True
        d2.roll("X")
    return False


from itertools import combinations
N = int(input())
D = [Dice([int(c) for c in input().split()]) for _ in range(N)]
for d1, d2 in combinations(D, 2):
    if is_identical(d1, d2):
        print("No")
        exit(0)
print("Yes")



Measured memory_bytes: 5692
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define LINE 1100
char M[1001][LINE];
char* myfgets(char *b,int n,FILE *f){
	char *r=fgets(b,n,f);
	if(!r)return NULL;
	if(b[strlen(b)-1]=='\n')b[strlen(b)-1]=0;
	if(b[strlen(b)-1]=='\r')b[strlen(b)-1]=0;
	return r;
}
int main(){
	int n,i,j,k;
	for(;myfgets(*M,LINE,stdin),n=strtol(*M,NULL,10);){
		memset(M,0,sizeof(M));
		for(i=0;i<n;i++)myfgets(M[i],LINE,stdin);
		for(i=0;i<n;i++){
			for(j=0;M[i][j]=='.';j++)M[i][j]=' ';
			if(j)M[i][j-1]='+';
		}
		for(i=n-1;i;i--){
			for(j=0;M[i][j]!='+';j++);
			for(k=i-1;M[k][j]==' ';k--)M[k][j]='|';
		}
		for(i=0;i<n;i++)puts(M[i]);
	}
	return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int n;
    ll field[350][350];
    ll ans = 0;
    cin >> n;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cin >> field[i][j];
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j < i; j++){
            bool checker = true;
            for(int k = 1; k <= n; k++){
                if(k == i){
                    continue;
                }
                if(k == j){
                    continue;
                }
                if(field[i][j] > (field[i][k] + field[k][j])){
                    cout << -1 << endl;
                    return 0;
                }
                if(field[i][j] == (field[i][k] + field[k][j])){
                    checker= false;
                }
            }
            if(checker){
                ans += field[i][j];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;

int main() {
	string S, ans;
	int N, siz;
	cin >> S;
	siz = S.size();

	for (int i = 0; i < siz; i++) {
		ans += S[0];
	}

	if (S > ans) {
		ans = "";
		for (int i = 0; i < siz; i++) {
			int a = S[0];
			ans += a + 1;
		}
		cout << ans << endl;
	}
	else {
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
Scanf.scanf "%d %s %s" (fun n s t ->
    let rec loop dup =
        if dup = 0 then dup else
            let rec loop2 a b =
                if b < 0 then dup else
                    if s.[a] = t.[b] then loop2 (a - 1) (b - 1)
                    else loop (dup - 1)
            in
            loop2 (n - 1) (dup - 1)
    in
    let dup = loop n in
    Printf.printf "%d\n" (n * 2 - dup)
)

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[4];
	int max = 0,c = 0;
	cin >> s;
	
	for(int i = 0; i < 3; i++){
	    if(s[i]=='R'){
	        c++;   
	    }else{
	        c = 0;
	    }
	    if(max < c){
	        max=c;
	    }
	}
	cout<<max<<endl;
}

Measured memory_bytes: 3600
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    int n,c[200002],b[200000],m=0;
    ll d[200002],p=1e9+7;
    cin>>n;
    c[0]=-1;
    d[0]=1;
    for(int i=0;i<n;i++){
        cin>>c[m+1];
        c[m+1]--;
        if(c[m+1]!=c[m])m++;
    }
    fill(b, b+200000, 0);
    for(int i=1;i<=m;i++){
        d[i]=d[i-1];
        if(b[c[i]]>0)d[i]+=d[b[c[i]]];
        d[i]%=p;
        b[c[i]]=i;
        //cout<<i<<" : "<<d[i]<<endl;
    }
    cout<<d[m]<<endl;
}


Measured memory_bytes: 3328
#include <stdio.h>

int main(void){

        int a,b,c,tmp;

        scanf("%d%d%d",&a,&b,&c);

        tmp = a;
        a = b;
        b = tmp;

        tmp = a;
        a = c;
        c = tmp;

        printf("%d %d %d\n",a,b,c);
return 0;
}



Measured memory_bytes: 128
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int X, N;
    cin >> X >> N;
    set<int> p;
    REP(i, N) {
        int input;
        cin >> input;
        p.insert(input);
    }

    REP(i, N + 1) {
        if (!p.count(X - i)) {
            cout << X - i;
            return;
        }
        if (!p.count(X + i)) {
            cout << X + i;
            return;
        }
    }
}

#pragma region main
main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3648
N = gets.to_i
W = gets.split.map &:to_i

T = W.inject(:+)
D = Array.new(N+1)
D[0] = 0
N.times do |i|
  D[i+1] = D[i] + W[i]
end

min = 100000
1.upto(N-1) do |t|
  d = (T - 2 * D[t]).abs
  min = d if d < min
end
p min


Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;
const int MOD = 1000000007;
#define MAX_N (110)

int main()
{
	int N;
	scanf("%d", &N);

	int factors[MAX_N][MAX_N];
	memset(factors, 0, sizeof(factors));
	for (int i = 2; i <= 100; i++) {
		for (int j = 2; j <= 100; j++) {
			factors[i][j] = factors[i - 1][j];
		}

		int num = i;
		for (int j = 2; j <= 100; j++) {
			while (num % j == 0) {
				factors[i][j]++;
				num /= j;
			}
		}
	}
	ll res = 0;

	// p0^74
	for (int j = 2; j <= N; j++) {
		if (factors[N][j] >= 74)
			res++;
	}

	// p0^24 * p1^2
	int cnt_24 = 0, cnt_2 = 0;
	for (int j = 2; j <= N; j++) {
		if (factors[N][j] >= 24)
			cnt_24++;
		if (factors[N][j] >= 2)
			cnt_2++;
	}
	if (cnt_2 - 1 > 0)
		res += cnt_24 * (cnt_2 - 1);

	// p0^14 * p1^4
	int cnt_14 = 0;
	int cnt_4 = 0;
	for (int j = 2; j <= N; j++) {
		if (factors[N][j] >= 14)
			cnt_14++;
		if (factors[N][j] >= 4)
			cnt_4++;
	}
	if (cnt_4 - 1 > 0)
		res += cnt_14 * (cnt_4 - 1);

	// p0^4 * p1^4 * p2^2
	cnt_4 = 0;
	cnt_2 = 0;
	for (int j = 2; j <= N; j++) {
		if (factors[N][j] >= 4)
			cnt_4++;
		if (factors[N][j] >= 2)
			cnt_2++;
	}
	if (cnt_4 - 1 > 0 && cnt_2 - 2 > 0)
		res += cnt_4 * (cnt_4 - 1) * (cnt_2 - 2) / 2;

	printf("%lld\n", res);

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int ans;
		if(a>=13){
			ans=b;
		}else if(a<13&&a>=6){
			ans=b/2;
		}else{
			ans=0;
        }
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define step(i, f, n, a) for(int (i) = (f); (i) < (n); (i)+=a)
#define rstep(i, f, n, a) for(int (i) = (f); (i) >= (n); (i)-=a)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

using pii = pair<int, int>;

int main(){
	int sx, sy, tx, ty;
	string result = "";
	gets(sx) gets(sy) gets(tx) gets(ty)
	int dx = tx - sx;
	int dy = ty - sy;

	rep(i, dy){
		result += "U";
	}
	rep(i, dx){
		result += "R";
	}
	rep(i, dy){
		result += "D";
	}
	rep(i, dx){
		result += "L";
	}

	result += "L";

	rep(i, dy+1){
		result += "U";
	}
	rep(i, dx+1){
		result += "R";
	}
	result += "D";
	result += "R";
	rep(i, dy+1){
		result += "D";
	}
	rep(i, dx+1){
		result += "L";
	}
	result += "U";

	puts(result)
}


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




int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    int n;
    cin>>n;
    vector<vector<int>> vec(n,vector<int> (2,0));
    for(int i=0;i<n;i++)cin>>vec[i][0]>>vec[i][1];
    for(int i=0;i+2<n;i++)
    {
        if(vec[i][0]==vec[i][1] && vec[i+1][0] == vec[i+1][1] && vec[i+2][0] == vec[i+2][1]){cout<<"Yes";exit(0);}
    }
    cout<<"No";
    return 0;
}



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

long long N, Cval;
long long D[35][35];
long long C[600][600];
long long first[35];
long long second[35];
long long third[35];

long long cal(long long a, long long b, long long c){
	return first[a] + second[b] + third[c];
}

long long prepare(long long a){
	long long f = 0;
	long long s = 0;
	long long t = 0;

	for(long long i = 0; i < N; i++){
		for(long long j = 0; j < N; j++){
			if((i+j)%3 == 0){
				f += D[C[i][j]][a];
			} else if((i+j)%3 == 1){
				s += D[C[i][j]][a];
			} else {
				t += D[C[i][j]][a];
			}
		}
	}
	first[a] = f;
	second[a] = s;
	third[a] = t;
	return 0;
}

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

	for(long long i = 0; i < Cval; i++){
		for(long long j = 0; j < Cval; j++){
			cin >> D[i][j];
		}
	}

	for(long long i = 0; i < N; i++){
		for(long long j = 0; j < N; j++){
			cin >> C[i][j]; C[i][j]--;
		}
	}

	for(long long i = 0; i < Cval; i++){
		prepare(i);
	}

	long long ret = INT_MAX;
	for(long long i = 0; i < Cval; i++){
		for(long long j = 0; j < Cval; j++){
			for(long long k = 0; k < Cval; k++){
				if(i == j || i == k || j == k){
					continue;
				}
				ret = min(ret, cal(i, j, k));
			}
		}
	}
	cout << ret << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  string s,t;
  cin >> s >> t;
  int ans = 0;
  rep(i,3){
    if(s[i]==t[i]) ans++;
  }
  
  cout << ans;
  
  return 0;
}

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

using namespace std;

int main()
{
    int n,m,i,j,k;
    double x=0,y,z;

    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        y=a[i]*1.0;
        x=x+(1.0/y);
    }
    z=1/x;
    cout<<z<<endl;
}


Measured memory_bytes: 256
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define PI acos(-1)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int main(void) {
  /* 標準入力フラグ */
  int   scan;

  /* 数入力 */
  ll    answer;
  ll    x;
  ll    y; 
  answer = 0;
  scan = scanf("%lld", &x);
  scan = scanf("%lld", &y);

  /* プログラムを書く */
  for (ll i = 0; i <= x; i++) {
    if (y == (2 * i + 4 * (x - i))) {
        printf("Yes");
        return (0);
    }
  }
  printf("No");
  return (0);
}



Measured memory_bytes: 1732
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ll)(1e9)+7)

int main(){
	int n;
	cin >> n;
	vector<ll> t(n+2), a(n+2);
	for(int i=1; i<=n; i++) cin >> t[i];
	for(int i=1; i<=n; i++) cin >> a[i];
	t[0]=0;
	a[n+1]=0;

	ll ans=1;
	for(int i=1; i<=n; i++){
		if(t[i]==t[i-1] && a[i]==a[i+1]){
			ans=ans*min(t[i], a[i])%mod;
		}else if(t[i]>t[i-1] && a[i]==a[i+1]){
			if(t[i]>a[i]) ans=0;
		}else if(t[i]==t[i-1] && a[i]>a[i+1]){
			if(a[i]>t[i]) ans=0;
		}else{
			if(t[i]!=a[i]) ans=0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Linq;

namespace AGC007
{
    class Program
    {
        private static int H;
        private static int W;
        private static char[][] cells;

        static void Main(string[] args)
        {
            var HW = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            H = HW[0];
            W = HW[1];
            cells = Enumerable.Range(0, H)
                .Select(i => (Console.ReadLine() + ".").ToArray())
                .Concat(new[] { new string('.', W + 1).ToArray() })
                .ToArray();

            var expected = cells.Sum(c => c.Count(cc => cc == '#'));
            var actual = Rec(0, 0);

            var result = actual == expected ? "Possible" : "Impossible";
            Console.Write(result);
        }

        static int Rec(int x, int y)
        {
            if (x == W - 1 && y == H - 1) return 1;
            if (cells[x][y] == '.') return 0;

            return Math.Max(Rec(x + 1, y), Rec(x, y + 1)) + 1;
        }
    }
}


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	priority_queue<double, vector<double>, greater<double>> v;
	for (int i = 0; i < N; ++i)
	{
		double a;
		cin >> a;
		v.push(a);
	}
	
	while (v.size() > 1)
	{
		double a = v.top();
		v.pop();
		double b = v.top();
		v.pop();
		v.push((a + b) / 2);
	}
	
	cout << setprecision(5) << fixed << v.top() << '\n';
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    AB = [None] * M
    for i in range(M):
        AB[i] = tuple(map(int, input().split()))

    AB.sort(key=lambda x: x[1])

    ans = 0
    prev_x = -1
    for a, b in AB:
        if a <= prev_x < b:
            pass
        else:
            ans += 1
            prev_x = b - 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 23912
/*
By Tianyi Chen. All rights reserved.
Date: 2016-07-31
*/
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main() {
 scanf("%d%d",&a,&b);
 if (b>=0&&a<=0)return puts("Zero"),0;
 if (a>=0)return puts("Positive"),0;
 if(b>=0)return puts((-a)&1?"Negative":"Positive"),0;
 puts(b-a+1&1?"Negative":"Positive");
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define ll long long
#define INF 2000000000
int cnt[200005];
int main(){
	int n;
	while(~getI(n)){
		FE(i,0,n) cnt[i]=0;
		FE(i,2,n){
			VgetI(u);
			cnt[u]++;
		}
		FE(i,1,n) printf("%d\n",cnt[i]);
	}
}


Measured memory_bytes: 2508
def test(n,t,x,y):
	for i in range(n-1):
		t1=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
		t2=t[i+1]-t[i]
		if (t1>t2 or (t2-t1)%2): return 0
	return 1
def main():
	n=int(input())
	n+=1
	t=[0]*n
	x=[0]*n
	y=[0]*n
	for i in range(1,n):
		t[i],x[i],y[i]=map(int,input().split())
	if (test(n,t,x,y)): print("Yes")
	else: print("No")
main()

Measured memory_bytes: 52568
#include<iostream>
#include<set>
using namespace std;

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

	set<string> st;
	for(int i = 0; i < N; i++) {
		string s;
		cin >> s;
		st.insert(s);
	}

	cout << st.size() << endl;

}

Measured memory_bytes: 19112
s=input()
t=input()
dic1={}
for i in range(len(s)):
    if s[i] in dic1:
        if dic1[s[i]]!=t[i]:
            print("No")
            exit()
    else:
        dic1[s[i]]=t[i]
dic2={}
for k in range(len(t)):
    if t[k] in dic2:
        if dic2[t[k]]!=s[k]:
            print("No")
            exit()
    else:
        dic2[t[k]]=s[k]
print("Yes")


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    vector<int> ans(n,0);
    rrep(i,105)rrep(j,105)rrep(k,105){
        int res = i*i+j*j+k*k+ i*j + j*k + k*i;
        if(res<=n&&res>=1)ans[res-1]++;
    }
    rep(i,n)cout << ans[i] << endl;
}

Measured memory_bytes: 3216
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val A, B, C = in.nextInt
  val result =
    (A == B && B != C) ||
    (B == C && C != A) ||
    (C == A && A != B)

  println(if (result) "Yes" else "No")
}

Measured memory_bytes: 27332
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>

#define ipair pair<int,int>
#define rep(n) for(int i=0;i<n;i++)

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int main() {
	int n;

	cin >> n;

	if (n == 3 || n == 5 || n == 7)
		cout << "YES";
	else
		cout << "NO";

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

	vector<ll> a(N);
	rep(i, N) cin >> a[i];

	vector<ll> b(N);
	rep(i, N) cin >> b[i];

	ll na = 0;
	ll nb = 0;

	rep(i, N - 1)
	{
		ll diff = b[i] - a[i];

		if (diff == 0) continue;

		if (diff > 0)
		{
			//bのほうが大きい

			//aをストックで増やす
			//aは2ずつしか増やせないことに注意
			if (diff <= 2 * na)
			{
				na -= diff / 2;
				diff = (diff % 2 == 0 ? 0 : 1);
			}
			else
			{
				diff -= 2 * na;
				na = 0;
			}

			if (diff == 0) continue;

			//aだけ増やす
			//差が偶数ならちょうど消すことができる
			//奇数の場合はbも増やして調整
			nb += diff / 2;
		}
		else
		{
			//aのほうが大きい
			diff *= -1;

			//bをストックで増やす
			if (diff <= nb)
			{
				nb -= diff;
				diff = 0;
			}
			else
			{
				diff -= nb;
				nb = 0;
			}

			if (diff == 0) continue;

			//bだけ増やす
			//aの増分は後続に押し付け
			na += diff;
		}
	}


	//最後の1項を調整
	//na、nbを使い切る
	ll la = a.back() + 2 * na;
	ll lb = b.back() + nb;

	if (la > lb)
	{
		//aのほうが大きい場合、調整不可能
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}

	return 0;
}

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

using namespace std;

#define LL long long
#define int long long
#define fi first
#define se second
#define pll pair<LL, LL>
#define pii pair<LL, LL>
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

constexpr int N = 100+5;
constexpr int M = 1e9+7;

// #define DEBUG 1  //调试开关
struct IO {
#define MAXSIZE (1 << 20)
#define isdigit(x) (x >= '0' && x <= '9')
    char buf[MAXSIZE], *p1, *p2;
    char pbuf[MAXSIZE], *pp;

    IO() : p1(buf), p2(buf), pp(pbuf) {}
    ~IO() { fwrite(pbuf, 1, pp - pbuf, stdout); }

    inline char gc() {
        if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin);
        return p1 == p2 ? ' ' : *p1++;
    }
    inline bool blank(char ch) {
        return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
    }
    template <class T>
    inline void read(T &x) {
    double tmp = 1;
    bool sign = 0;
    x = 0;
    char ch = gc();
    for (; !isdigit(ch); ch = gc())
        if (ch == '-') sign = 1;
    for (; isdigit(ch); ch = gc()) x = x * 10 + (ch - '0');
    if (ch == '.')
        for (ch = gc(); isdigit(ch); ch = gc())
        tmp /= 10.0, x += tmp * (ch - '0');
    if (sign) x = -x;
    }
    inline void read(char *s) {
    char ch = gc();
    for (; blank(ch); ch = gc())
        ;
    for (; !blank(ch); ch = gc()) *s++ = ch;
    *s = 0;
    }
    inline void read(char &c) {
    for (c = gc(); blank(c); c = gc())
        ;
    }
    inline void push(const char &c) {
    #if DEBUG  //调试，可显示字符
    putchar(c);
    #else
    if (pp - pbuf == MAXSIZE) fwrite(pbuf, 1, MAXSIZE, stdout), pp = pbuf;
    *pp++ = c;
    #endif
    }
    template <class T>
    inline void write(T x) {
    if (x < 0) x = -x, push('-');  // 负数输出
    static T sta[35];
    T top = 0;
    do {
        sta[top++] = x % 10, x /= 10;
    } while (x);
    while (top) push(sta[--top] + '0');
    }
    template <class T>
    inline void write(T x, char lastChar) {
    write(x), push(lastChar);
    }
} io;

int dp[N][N];
int n, m;
char a[N][N];

signed main() {
    fastio;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> a[i][j];
    memset(dp, 0x3f, sizeof(dp));
    dp[1][1] = a[1][1] == '#';
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            if (i+1 <= n) dp[i+1][j] = min(dp[i+1][j], dp[i][j] + (a[i+1][j] != a[i][j]));
            if (j+1 <= m) dp[i][j+1] = min(dp[i][j+1], dp[i][j] + (a[i][j+1] != a[i][j]));
        }
    cout << (dp[n][m]+1)/2 << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    string s,t;cin>>s>>t;ll cnt=0;
    for(int i=0;i<3;i++)if(s[i]==t[i])cnt++;
    cout<<cnt<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int in,count = 0;
  cin >> in;
  if(in % 2 == 1){
    count = count + 1;
    in = in - 1;
  }
  if(in % 20 == 10){
    count = count + 1;
    in = in - 10;
  }
  if(in % 200 == 100){
    count = count + 1;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
fn papers_please() -> Result<&'static str, &'static str> {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input)
        .map_err(|_| "input error")?;
    let n = input.trim_right().parse::<usize>()
        .map_err(|_| "parse error")?;

    let mut input = String::new();
    std::io::stdin().read_line(&mut input)
        .map_err(|_| "input error")?;
    let an: Vec<u32> = input.trim_right().split_whitespace()
        .map(|s| s.parse::<u32>().unwrap())
        .filter(|&a| a % 2 == 0).collect();
    let an_size = an.len();

    let size = an.iter().filter(|&a| a % 3 == 0 || a % 5 == 0).count();
    if size == an_size {
        Ok("APPROVED")
    }
    else {
        Ok("DENIED")
    }
}

fn main() {
    println!("{}", papers_please().unwrap());
}

Measured memory_bytes: 4352
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    n,q = LI()
    bit = [0] * (n+1)

    def bit_add(i,x):
        while i <= n:
            bit[i] += x
            i += i & (-i)

    def sum_bit(i):
        ret = 0
        while i > 0:
            ret += bit[i]
            i -= i & (-i)
        return ret

    for _ in range(q):
        c,x,y = LI()
        if c == 0:
            bit_add(x,y)
        else:
            ans = sum_bit(y) - sum_bit(x-1)
            print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

void ok(int N)
{
    bool ok = false;
    while (N)
    {
        if (N % 10 == 7)
        {
            cout << "Yes" << endl;
            return;
        }
        N /= 10;
    }
    cout << "No" << endl;
    return;
}

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

    return 0;
}


Measured memory_bytes: 3672
#include<iostream>
#include<string>
#include<queue>
#include<map>

using namespace std;

int dx[4] = { 1,-1,4,-4 };
map<string, int>res;

void solve(void) {
    queue<string>que;
    que.push("01234567");
    while (!que.empty()) {
        string v = que.front();
        que.pop();
        int pos = 0;
        for (int i = 0; i < 8; i++)
            if (v[i] == '0')pos = i;

        for (int i = 0; i < 4; i++) {
            if (0 <= pos + dx[i] && pos + dx[i] < 8 &&
                !(pos == 3 && i == 0) && !(pos == 4 && i == 1)) {
                string u = v;
                swap(u[pos], u[pos + dx[i]]);

                if (res[u] == 0) {
                    que.push(u);
                    res[u] = res[v] + 1;
                }
            }
        }
    }
}

int main(void) {
    int in;
    res["01234567"] = 1;
    solve();
    while (true) {
        string s;
        for (int i = 0; i < 8; i++) {
            if (!(cin >> in))return 0;
            s += in + '0';
        }
        cout << res[s] - 1 << endl;
    }
    return 0;
}



Measured memory_bytes: 5372
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[int(input())-1])

Measured memory_bytes: 61480
#include<iostream>
using namespace std;
long long int a[200000];
int main()
{
	int i,j,k,l;
	cin >> i;
	j = 0; k = 0; l = 0;
	for (int z = 0; z < i; z++)
	{
		cin >> a[z];
		if (a[z] % 2 == 0 && a[z] % 4 == 0)
		{
			j++;
		}
		else if (a[z] % 2 == 0 && a[z] % 4 != 0)
		{
			k++;
		}
		else if (a[z] % 2 != 0)
		{
			l++;
		}
	}
	if (j + l == i&&j < l - 1)
	{
		cout << "No";
	}
	else if (j + l != i&&j < l)
	{
		cout << "No";
	}
	else
		cout << "Yes";
}

Measured memory_bytes: 1024
#include<math.h>
#include<time.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
int maxa(int x,int y)
{
	if(x>y)
		return x;
	return y;
}
int mina(int v,int u)
{
	if(v<u)
		return v;
	return u;
}
int main()
{
	int t,n,i,maxv=-2000000000,R[200010];
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&R[i]);
	int minv=R[1];
	for(i=2;i<=n;i++)
	{
		maxv=maxa(maxv,R[i]-minv);
		minv=mina(minv,R[i]);
	}
	printf("%d\n",maxv);
	return 0;
}


Measured memory_bytes: 3508
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }

  sort(a.begin(), a.end());
  
  ll res = 0;
  vector<ll> s(n + 1, 0);
  for (int i = 0; i < n - 1; i++){
    s[i + 1] = s[i] + a[i];
    if (2*s[i+1] < a[i+1]){
      res = i + 1;
    }
  }

  cout << n - res << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  int n;
  scanf("%d", &n);
  const int inf = 1e9;
  vector<int> f(n + 1, inf);
  f[0] = 0;
  for (int b : {6, 9}) {
    for (int w = 1; w <= n; w *= b) {
      for (int j = 0; j <= n - w; j++) {
        f[j + w] = min(f[j + w], f[j] + 1);
      }
    }
  }
  printf("%d\n", f[n]);
  return 0;
}

Measured memory_bytes: 640
#include <cstdio>

using namespace std;
typedef long long ll;

int main() {
	ll x, y; scanf("%lld %lld", &x, &y);
	int ans = 1;
	ll cur = x;
	while ((cur*2) <= y) {
		cur *= 2;
		++ans;
	}
	printf("%d\n", ans);
}

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

int main(){
    char b;
    cin >> b;
    if(b=='A') cout << 'T' << endl;
    else if(b=='T') cout << 'A' << endl;
    else if(b=='G') cout << 'C' << endl;
    else cout << 'G' << endl;
}

Measured memory_bytes: 256
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	a = int(input())
	b = int(input())
	c=int(input())
	d=int(input())
	print(min(a,b)+min(c,d))
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100005];
int main()
{
	ll n,k,q,x;
	scanf("%lld%lld%lld",&n,&k,&q);
	for(int i=1;i<=q;i++)
	{
		scanf("%lld",&x);
		a[x]++;
	}
	for(int i=1;i<=n;i++)
	if(a[i]+k-q>0)
	puts("Yes");
	else
	puts("No"); 
}

Measured memory_bytes: 1408
n = int(input())
A = list(map(int, input().split()))
ans = 1
MOD = 1000000007
c = [0, 0, 0]
for a in A:
    cnt = c.count(a)
    if cnt == 0:
        print(0)
        exit()
    ans *= cnt
    ans %= MOD
    c[c.index(a)] += 1
print(ans)

Measured memory_bytes: 13964
t,_,s=open(0).read().partition('\n')
h,w=map(int,t.split())
d=[h%2&w%2,w%2*h//2+h%2*w//2,0,h//2*(w//2)]
for i in map(s.count,set(s)-{'\n'}):
  for j in(3,1,0):
    while d[j]and i>j:
      i-=j+1
      d[j]-=1
print('YNeos'[sum(d)>0::2])

Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))

count = 1
ind = 1

def check_inc_dec(i):
    global ind
    if i == n-1:
        return False
    if a[i] < a[i+1]:
        return True # 増加
    elif a[i] > a[i+1]:
        return False # 減少
    else: # 等しい
        for j in range(i+1, n):
            if a[i] < a[j]:
                ind = j
                return True
            elif a[i] > a[j]:
                ind = j
                return False

flag = check_inc_dec(0)

while ind < n:
    if flag == True and a[ind] < a[ind-1]:
        count += 1
        flag = check_inc_dec(ind) # つぎにの連蔵した列は増加か減少かを確かめる
    elif flag == False and a[ind] > a[ind-1]:
        count += 1
        flag = check_inc_dec(ind)
    ind += 1

print(count)

Measured memory_bytes: 14480
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n;
	cin>>n;
	ll arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	vector<ll> dp(n,1000000000000000000);
	dp[0] = 0;
	for(int i=0;i<n;i++)
	{
		i+1<n?dp[i+1] = min(dp[i+1],dp[i]+abs(arr[i]-arr[i+1])):true;
		i+2<n?dp[i+2] = min(dp[i+2],dp[i]+abs(arr[i]-arr[i+2])):true;
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,m,c;
  cin >> n >> m >> c;
  vector<int> b(20);
  vector<vector<int>> a(20,vector<int>(20));
  int i,j;
  for(i=0;i<m;i++) cin >> b.at(i);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      cin >> a[i][j];
    }
  }
  int sum = 0;
  int count = 0;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      sum += b[j] * a[i][j];
    }
    if(sum+c > 0) count++;
    sum = 0;
  }
  cout << count << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
 
int main(){
    double r;
    cin >> r;
    cout << fixed;
    cout << setprecision(6);
    cout << r*r*M_PI << " " << 2*r*M_PI << endl;
    return 0;
}


Measured memory_bytes: 3272
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    int sum=0;
    for(int i=0; i<4; i++)
    {
        for(int j=0; j<4; j++)
        {
            if(s[i]==s[j])
            {
                sum++;
            }
        }
    }
    if(sum==8)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}

Measured memory_bytes: 3620