akhauriyash/Code-Regression huggingface dataset:
program sample
    implicit none
    character(100)::s
    integer(8) :: i,j,m,n,a,b,c,k
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n,k
    allocate(x(n))
    read(*,*)x
    m=10**9
    do i=1,n
        a=abs(x(i)-k)
        do 
            if(mod(a,m)==0)then
                exit
            end if
            m=mod(a,m)
        end do
    end do
    write(*,*)m
    stop
end program sample
  



Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define INF 0x7FFFFFFF
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

ll N, W, w[105], v[105], dp[105][100005], ans;
//dp[i][j] i番目の荷物までで価値jを達成する詰め方で最小の重み
int main() {
  cin >> N >> W;
  REP(i,N) cin >> w[i+1] >> v[i+1];
  REP(i,105)REP(j,100005) dp[i][j] = INF;
  dp[0][0] = 0;
  REP2(i,1,N+1)REP(j,100001){
	if(j-v[i]>=0)dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
	else dp[i][j]=dp[i-1][j];
  }
  ans = 100000;
  while(dp[N][ans]>W) ans--;
  cout << ans;
  return 0;
}

Measured memory_bytes: 82432
while True:
    a_str,op,b_str=map(str,input().split())
    a=int(a_str)
    b=int(b_str)
    if op=='?':
        break
    elif op=='+':
        print(a+b)
    elif op=='-':
        print(a-b)
    elif op=='/':
        print(a//b)
    else:
        print(a*b)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    string s;cin >> s;
    int a,b;
    a = -1;
    b = -1;
    if(s.size() == 2){
        if(s[0] == s[1]){
            a=1;b=2;
        }
    }
    rep(i,s.size()-2){
        if(s[i] == s[i+1]){
            a = i+1;
            b = i+3;
            break;
        }
        else if(s[i] == s[i+2]){
            a = i+1;
            b = i+3;
            break;
        }
    }
    cout << a << " " << b << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

struct Point{
    double x;
    double y;
    bool f;
};

inline double sq(double x){
    return x*x;
}

inline double dis(Point p1, Point p2){
    return sqrt(sq(p1.x - p2.x) + sq(p1.y - p2.y));
}

int fact(int n){
    if(n<=1) return 1;
    return fact(n-1) * n;
}

double dfs(Point *m, int c, int k, int n){
    if(k == n-1) return 0;
    double sum = 0;
    m[c].f = true;
    for(int i=0;i<n;i++){
        if(m[i].f == false){
            sum += dis(m[c], m[i]) * fact(n-2-k) + dfs(m, i, k+1, n);
        }
    }
    m[c].f = false;
    //cout << c << sum << endl;
    return sum;
}

int main(void){
    int n;
    cin >> n;
    Point *m;
    m = new Point[n];
    for(int i=0;i<n;i++){
        cin >> m[i].x >> m[i].y;
        m[i].f = false;
    }
    //cout << dis(m[0], m[1]) << endl;
    double sum = 0;
    for(int i=0;i<n;i++){
        sum += dfs(m, i, 0, n);
    }
    cout << setprecision(20) << sum/fact(n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  int k,s;
  cin>>k>>s;
  int ans=0;
  rep(i,k+1){
    FOR(j,i,k){
      FOR(l,j,k){
        if(i+j+l==s){
          if(i==j&&j==l) ans++;
          else if(i==j||j==l||l==i) ans+=3;
          else ans+=6;
        }
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
a = gets.to_i
s = gets.split.map(&:to_i)

x = 0
s.each do |i|
  if i % 2 == 0
    if i % 5 == 0 || i % 3 == 0
      next
    else
      x += 1
    end
  end
end

puts x == 0 ? "APPROVED" : "DENIED"

Measured memory_bytes: 14344
#include "bits/stdc++.h"
using namespace std;
int data_ary[8][8]={{1,2,1,2,1,4,1,4},{1,2,1,4,1,4,1,2},{1,4,1,2,1,2,1,4},
		{1,4,1,4,1,2,1,2},{2,1,2,1,4,1,4,1},{2,1,4,1,4,1,2,1},{4,1,2,1,2,1,4,1},{4,1,4,1,2,1,2,1}};
int sum,ans;
int all_sum,result=10000000;
int data[8]={0};
int main(){
	while(~scanf("%d %d %d %d %d %d %d %d",
			&data[0],&data[1],&data[2],&data[3],&data[4],&data[5],&data[6],&data[7])){
		ans=0;
		result=10000000;
		for (int i = 0; i < 8; ++i) {
			sum=0;
			all_sum=0;
			for (int j = 0; j < 8; ++j) {
			sum=data[j]-data_ary[i][j];
			if(sum<0){sum=0;}
			else{all_sum=all_sum+sum;}
		}
		if(all_sum<result){
			result=all_sum;
			ans=i;
		}
	}
    for (int i = 0; i < 8; ++i) {
		if(i){cout<<" "<<data_ary[ans][i];}
		else{cout<<data_ary[ans][i];}
	}
    cout<<endl;
	}
}

Measured memory_bytes: 3136
#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>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> P;
typedef pair<ll,pair<ll,ll>> p;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
static const int MAX_SIZE = 1 << 17; //segment tree のサイズ。この実装では2べきにする必要がある。 2^17 ≒ 1.3 * 10^5

int C[30];

int main(){
    int H,W;
    cin>>H>>W;

    string s[110];

    for(int i=0;i<H;i++) cin>>s[i];

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            C[s[i][j]-'a']++;
        }
    }

    int count1=0,count2=0;
    for(int i=0;i<30;i++){
        if(C[i]%4==0) continue;
        else if(C[i]%2==0) count2++;
        else count1++;
    }
    int num2=0;
    if(H%2) num2++;
    if(W%2) num2++;
    if(H%2==0 && W%2==0){
        if(!count2 && !count1) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }else if(H*W%2==0){
        int num;
        if(H%2==0) num=H/2;
        else num=W/2;
        if(num>=count2 && !count1) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }else{
        if((H+W-2)/2>=count2 && count1==1) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int total = 0;
		int max = 0;
		for (int i = 0; i < N; i++) {
			int L = sc.nextInt();
			if(max < L) {
				max = L;
			}
			total += L;

		}

		total -= max;
		if(max < total) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (13 <= a) {
    cout << b << endl;
  } else if (6 <= a && a <= 12) {
    cout << b / 2 << endl;
  } else {
    cout << 0 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long a,b,k,i,c,d;
  cin>>a>>b>>k;
  if(a==k) cout<<"0"<<" "<<b<<endl;
  else if(a<k)
  {
    if(b-(k-a)<0) cout<<"0"<<" "<<"0"<<endl;
    else cout<<"0"<<" "<<b-(k-a)<<endl;
  }
  else if(a>k)  cout<<a-k<<" "<<b<<endl;

}


Measured memory_bytes: 3620
#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

string S;
int hand[26] = {
  0, 0, 0, 0, 0,
  0, 0, 1, 1, 1,
  1, 1, 1, 1, 1,
  1, 0, 0, 0, 0,
  1, 0, 0, 0, 1,
  0
};

int main(void) {
  while(cin >> S, S != "#") {
    int ans = 0;
    REP(i, 0, S.length() - 1) if(hand[S[i] - 'a'] != hand[S[i + 1] - 'a']) ans++;
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3140
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#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 big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, M, V, P;
  cin>>N>>M>>V>>P;
  vector<ll> A(N);
  for(int i=0;i<N;++i) cin>>A[i];
  sort(A.begin(), A.end());
  ll l=0, r=N-1, m;
  ll score;
  bool can;
  while(l<r){
    m = (l+r)/2;
    if(m>=N-P){
      r = m;
      continue;
    }
    score = M*V;
    score -= M*(m+1);
    score -= M*(P-1);
    can = true;
    for(int i=m+1;i<=N-P;++i){
      if(A[m]+M<A[i]) can = false;
      score -= A[m]+M-A[i];
    }
    if(can && score<=0){
      r = m;
    }
    else{
      l = m+1;
    }
  }
  cout<<N-l<<endl;
}



Measured memory_bytes: 4060
#include <iostream>
#include <vector>
#include <math.h>

bool good_dist(int d, std::vector<int>& p1, std::vector<int>& p2)
{
    int sum = 0;
    for (int i = 0; i < d; i++) {
        sum += ((p1[i] - p2[i]) * (p1[i] - p2[i]));
    }

    for (int i = 1; i <= 200; i++) {
        if (sum == (i * i)) return true;
    }

    return false;
}

int main(int argc, char** argv)
{
    int N, D;
    std::cin >> N >> D;

    std::vector<std::vector<int>> points;
    points.reserve(N);
    for (int i = 0; i < N; i++) {
        std::vector<int> pos(D);
        for (int j = 0; j < D; j++) {
            std::cin >> pos[j];
        }
        points.push_back(pos);
    }

    int ans = 0;
    for (int i = 0; i < N-1; i++) {
        for (int j = i+1; j < N; j++) {
            if (good_dist(D, points[i], points[j])) {
                ans++;
            }
        }
    }

    std::cout << ans <<  std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int ab(int a,int b){
  if(a>b)return a-b;
  else return b-a;
}
int main(){
  int n,p,q;
  cin>>n>>p>>q;
  vector<int> dis(n);
  for(int i=1;i<n;i++){
    for(int j=i+1;j<n+1;j++){
      int d=min(ab(i,j),ab(i,p)+1+ab(j,q));
     //cout<<d<<endl;
      dis[d]++;
    }
  }
  for(int i=1;i<n;i++)cout<<dis[i]<<endl;
}
 
  

Measured memory_bytes: 256
#include<stdio.h>
 
int depth(int);
void P(int);
 
struct NODE{
  int p,l,r;
};
 
struct NODE tree[100005];
int n,D[100005];
 
main(void){
 
  int i,j,d,e,c,l,r;
    
  scanf("%d",&n);
    
  for (i=0;i<n;i++){
    tree[i].p=tree[i].l=tree[i].r=-1;
  }
 
  for(i=0;i<n;i++){
    scanf("%d",&e);
    scanf("%d",&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      tree[c].p=e;
        
      if(j==0){
    tree[e].l=c;
      }
       
      else if(j>=1){
    tree[r].r=c;
      }
      r=c;
       
    }
   }
    
  for(i=0;i<n;i++){
    D[i]=depth(i);
  }
  
  for(i=0;i<n;i++){
    P(i);
  }
  return 0;
}
 
int depth(int a){
 
  int d=0;
  
  while(tree[a].p>=0){
    a=tree[a].p;
    d=d+1;
  }
  return d;
}
void P(int b){
  if(tree[b].p==-1){
    printf("node %d: parent = %d, depth = %d, root, ",b,tree[b].p,D[b]);
  }
    
  else if(tree[b].l==-1){
    printf("node %d: parent = %d, depth = %d, leaf, ",b,tree[b].p,D[b]);
  }
    
  else printf("node %d: parent = %d, depth = %d, internal node, ",b,tree[b].p,D[b]);
    
  printf("[");
  int t;
  t = b;
  if(tree[t].l!=-1){
    printf("%d",tree[t].l);
    if(tree[tree[t].l].r==-1){
      printf("]\n");
    }
    else printf(",");
    t =tree[t].l;
    while(tree[t].r!=-1){
      printf(" %d",tree[t].r);
      if(tree[tree[t].r].r==-1){
    printf("]\n");
      }
      else printf(",");
      t=tree[t].r;
    }
  }
  else printf("]\n");
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define int long long
const int mu=998244353,N=200005;
int f[N],s[N],b[N];
char t[N],c[N];
int n,k,ans;
void count(int x){
	for (int i=1;i<=x;i++)
		f[x]=(f[x]*2ll+s[i])%mu;
	f[x]++;
	for (int i=1;i<=n/x;i++){
		if (i&1){
			for (int j=(i-1)*x+1;j<=i*x;j++) b[j]=s[(j-1)%x+1];	
		}
		else for (int j=(i-1)*x+1;j<=i*x;j++) b[j]=s[(j-1)%x+1]^1;
	}
	for (int i=1;i<=n;i++){
		if (b[i]<s[i]) break;
		if (b[i]>s[i]){
			f[x]--;
			break;
		}
	}
	f[x]=(f[x]+mu)%mu; 
	for (int i=1;i<x;i++)
		if (x%i==0) f[x]=(f[x]-f[i]+mu)%mu;	
}
signed main(){
	scanf("%lld",&n);
	scanf("%s",t+1);
	for (int i=1;i<=n;i++) s[i]=t[i]-'0';
	for (int i=1;i<=n;i++)
		if (n%i==0 && (n/i)&1) 
			count(i);
	for (int i=1;i<=n;i++)
		if (n%i==0 && (n/i)&1) ans=(ans+f[i]*2ll*i)%mu;
	printf("%lld\n",ans);
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=1e3+10;
 int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};

int32_t main()
{
	IOS;
	int n,m,K;
	cin>>n>>m>>K;
	int x,y,source,destination;
	cin>>source>>destination>>x>>y;
	char xxx;
	vector<vector<int> >grid(n+2,vector<int>(m+2,0));
	
	int dis[n+4][m+4][6];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			grid[i][j]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{

			cin>>xxx;
			if(xxx=='.')
			{
				grid[i][j]=1;
			}
			for(int k=0;k<4;k++)
			{
				dis[i][j][k]=MOD;
			}
		}
	}
	
	queue<pair<int,pair<int,int> > >q;
	for(int i=0;i<4;i++)
	{
		dis[x][y][i]=0;
		q.push(make_pair(x,make_pair(y,i)));
	}
	pair<int,pair<int,int> >v;
	int xx,yy;
	int d;
	while(!q.empty())
	{
		v=q.front();
		q.pop();
		//cout<<v.ff<<" "<<v.ss.ff<<" "<<v.ss.ss<<endl;
		for(int k=0;k<4;k++)
		{
			xx=v.ff+dx[k];
			yy=v.ss.ff+dy[k];
			if(!grid[xx][yy])
				continue;
			d=dis[v.ff][v.ss.ff][v.ss.ss];
			if(k==v.ss.ss)
			{
				d++;
			}
			else
			{
				int kk=d/K+(d%K!=0);
				d=kk*K;
				d++;
			}
			if(dis[xx][yy][k]>d)
			{
				
				dis[xx][yy][k]=d;
				q.push(make_pair(xx,make_pair(yy,k)));
 
			}
		}
	}
	int ans=MOD;
	for(int k=0;k<4;k++)
	{
		ans=min(ans,dis[source][destination][k]);
	}
	if(ans==MOD)
	{
		cout<<"-1"<<endl;
		return 0;
	}

	ans=ans/K+(ans%K!=0);
	cout<<ans<<endl;
 
 
}

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

long long mod(long long  s,long long t){
  long long tmp;
  if(s<t) {
    tmp = s;
    s = t;
    t = tmp;
  }
  if(s%t==0) return t;
  else return mod(s-t,t);
}

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


Measured memory_bytes: 256
#include<iostream> 
#include <cassert>
#include <algorithm>
#include <map>
#include <queue>
#include <vector>
#include <cstring>
using namespace std;

int n, m;
map<int,int>cnt;
long long ans;
int a[312345];

int main() {
	cin >> n;


	for(int i = 1; i <= n; i++){
		cin >> a[i];
		ans+=cnt[a[i]-i];
		cnt[-i-a[i]]++;
	}
	cout<<ans;
	return 0; 
}



Measured memory_bytes: 21404
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String ... args) {
        FastReader reader = new FastReader();
        String s1 = reader.next(), s2 = reader.next();

        int n = s1.length(), m = s2.length();
        int [][] dp = new int [n + 1][m + 1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (s1.charAt(i - 1) == s2.charAt(j - 1)) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                } else {
                    dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
                }
            }
        }

        StringBuilder sb = new StringBuilder();
        int i = n, j = m;
        while (dp[i][j] != 0) {
            int left = dp[i][j - 1];
            int up = dp[i - 1][j];
            if (dp[i][j] == left) j--;
            else if (dp[i][j] == up) i--;
            else {
                sb.append(s1.charAt(i - 1));
                i --;
                j --;
            }
        }
        System.out.println(sb.reverse().toString());
    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 76512
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int a[110][110];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    rep(i, 0, n){
        rep(j, 0, n){
            cin >> a[i][j];
        }
    }
    int ans = 0;
    rep(i, 0, n){
        rep(j, 0, n){
            ans += min(a[i][j], a[j][i]);
        }
    }
    cout << ans / 2 << endl;
}


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

void dfs(const string& s, map<pair<string, string>, ll>& r, string a, string b) {
  int i = a.size() + b.size();
  if (i == s.size() / 2) {
    r[{a, b}]++;
    return;
  }
  dfs(s, r, a + s[i], b);
  dfs(s, r, a, b + s[i]);
}

int main() {
  int n;
  string s;
  cin >> n >> s;

  map<pair<string, string>, ll> u, v;
  dfs(s, u, "", "");
  reverse(begin(s), end(s));
  dfs(s, v, "", "");

  ll m = 0;
  for (auto e : u) {
    m += e.second * v[e.first];
  }
  cout << m << endl;
}


Measured memory_bytes: 104192
#include <iostream>

using namespace std;

int main(){
    int N;
    cin>>N;
    int cnt = 0;
    while(N--){
        string s;
        cin>>s;
        // cout<<cnt<<endl;
        if(s[0]=='A')cnt++;
        else cnt--;
        if(cnt<0){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    if(cnt==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}

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

int main(){
    int N,A,B,C,D;
    cin>>N;
    A=N/1000;
    B=(N-1000*A)/100;
    C=(N-1000*A-100*B)/10;
    D= N % 10;
    if(A+B+C+D==7){
        cout<<A<<'+'<<B<<'+'<<C<<'+'<<D<<"=7"<<endl;
    }else if(A-B+C+D==7){
        cout<<A<<'-'<<B<<'+'<<C<<'+'<<D<<"=7"<<endl;
    }else if(A+B-C+D==7){
        cout<<A<<'+'<<B<<'-'<<C<<'+'<<D<<"=7"<<endl;
    }else if(A+B+C-D==7){
         cout<<A<<'+'<<B<<'+'<<C<<'-'<<D<<"=7"<<endl;
    }else if(A-B-C+D==7){
         cout<<A<<'-'<<B<<'-'<<C<<'+'<<D<<"=7"<<endl;
    }else if(A+B-C-D==7){
         cout<<A<<'+'<<B<<'-'<<C<<'-'<<D<<"=7"<<endl;
    }else if(A-B+C-D==7){
        cout<<A<<'-'<<B<<'+'<<C<<'-'<<D<<"=7"<<endl;
    }else if(A-B-C-D==7){
        cout<<A<<'-'<<B<<'-'<<C<<'-'<<D<<"=7"<<endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
    public static boolean isStringPalindrome(String s, int a, int b){
        StringBuilder reverse = new StringBuilder();
        for(int i = b-1; i >= a; i--){
            reverse.append(s.charAt(i));
        }
        return s.contentEquals(reverse);
    }

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int length = s.length();
        int length1 = (length - 1)/2;
        String s1 = s.substring(0,length1);
        
        if(s.length() % 2 != 0 && isStringPalindrome(s,0,length) && isStringPalindrome(s1,0,length1)){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


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

int main() {
  long long R, C;
  cin >> R >> C;
  long long R1 = 0, R2;
  long long ans = 0;
  for (int i = 0; i < C; i += 2) R1++;
  if (C % 2 == 0) R2 = R1;
  else R2 = R1 - 1;
  ans += (R1 + R2) * (R / 2);
  ans += R1 * (R % 2);
  if (C == 1 || R == 1) {
    cout << 1 << endl;
  } else {
  cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main{
    static int max;
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st  = new StringTokenizer(br.readLine());

        int N = Integer.parseInt(st.nextToken());
        int M = Integer.parseInt(st.nextToken());
        int Q = Integer.parseInt(st.nextToken());
        
        int[][] arr = new int[Q][4];

        for (int i=0; i<Q; i++) {
            st  = new StringTokenizer(br.readLine());
            arr[i][0] = Integer.parseInt(st.nextToken())-1;
            arr[i][1] = Integer.parseInt(st.nextToken())-1;
            arr[i][2] = Integer.parseInt(st.nextToken());
            arr[i][3] = Integer.parseInt(st.nextToken());
        }
        max = 0;
        dfs(N,M,Q,arr,1, new ArrayList());
        System.out.println(max);
    }

    public static void dfs(int N, int M, int Q, int[][] arr, int cur, ArrayList<Integer> curlist) {

        if (curlist.size()==N) {
            int score = 0;
            for (int i=0; i<Q; i++) {
                if (curlist.get(arr[i][1])-curlist.get(arr[i][0])==arr[i][2]) {
                    score+=arr[i][3];
                }
            }
            max = Math.max(max, score);
            return;
        }

        for (int i=cur; i<=M; i++) {
            curlist.add(i);
            dfs(N, M, Q, arr, i, curlist);
            curlist.remove(curlist.size()-1);
        }
    }

}

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

void trn(int *check,int a,int b,int c,int d);

int main(){
	int n;
	cin >> n;
	int dices[n][7];
	cin >> dices[0][1] >> dices[0][2] >> dices[0][3] >> dices[0][4] >> dices[0][5] >> dices[0][6];
	
	for(int h = 1;h < n;h++){
		cin >> dices[h][1] >> dices[h][2] >> dices[h][3] >> dices[h][4] >> dices[h][5] >> dices[h][6];
		
		for(int i = 0;i < 4;i++){
			if(dices[0][1] == dices[h][1]){
				for(int j = 0;j < 4;j++){
					if(dices[0][2] == dices[h][2]){
						i = 10;
						j = 10;
					}
					else trn(dices[h],2,4,5,3);
				}
			}
			else trn(dices[h],1,2,6,5);
		}
		for(int i = 0;i < 4;i++){
			if(dices[0][1] == dices[h][1]){
				for(int j = 0;j < 4;j++){
					if(dices[0][2] == dices[h][2]){
						i = 10;
						j = 10;
					}
					else trn(dices[h],2,4,5,3);
				}
			}
			else trn(dices[h],1,3,6,4);
		}
	}

	string ans = "Yes";
	for(int i = 0;i < n-1;i++){
		for(int j = i+1;j < n;j++){
			for(int k = 1;k < 7;k++){
				if(dices[i][k] == dices[j][k]){
					ans = "No";
				}
				else{
					ans = "Yes";
					break;
				}
			}
			if(ans == "No")break;
		}
		if(ans == "No")break;
	}
	cout << ans << "\n";
	
	return 0;
	}
	
	void trn(int *check,int a,int b,int c,int d){
		int tmp = check[a];
		check[a] = check[b];
		check[b] = check[c];
		check[c] = check[d];
		check[d] = tmp;
	}

Measured memory_bytes: 3196
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define SANKOU(n,a,b) cout << ((n) ? (a) : (b) ) << endl;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);// warshall-floyd

#define CIN(x) int x;cin>>x;
#define SCIN(x) string x;cin>>x;
#define COUT(x) cout<<(x)<<endl;
#define SCOUT(x) cout<<(x)<<" ";
#define ENDL cout<<endl;

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_;
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl;

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end());

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    CIN(a);CIN(b);CIN(c);
    V v={a,b,c};
    COUT(accumulate(ALL(v),0)-max({a,b,c}));

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

vector<int> g[101010];
int in[101010];

int main() {
  int n, m;
  cin >> n >> m;
  REP(i, n - 1 + m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    in[b]++;
  }
  queue<int> que;
  REP(i, n) {
    if (in[i] == 0) que.push(i);
  }
  int ans[n];
  REP(i, n) ans[i] = -1;
  while (que.size()) {
    int p = que.front();
    que.pop();
    REP(i, g[p].size()) {
      int q = g[p][i];
      in[q]--;
      if (in[q] == 0) {
        que.push(q);
        ans[q] = p;
      }
    }
  }
  REP(i, n) cout << ans[i] + 1 << endl;
  return 0;
}

Measured memory_bytes: 7040
n=int(input())
a=list(map(int,input().split()))
dp=[1 for i in range(n)]
cnt=0
res=0
my_bool=True
for i in range(1,n):
    if a[i]<=a[i-1]:
        dp[i]=dp[i-1]+1
        if dp[i]>res:
            cnt=i
            res=dp[i]
            my_bool=False


if my_bool:
    print(0)
else:
    print(res-1)

Measured memory_bytes: 64356
#include <iostream>
#include <cmath>
using namespace std;

int main(){
    int d, n; cin >> d >> n;
    if(d == 0){
        if(n != 100) cout << n << endl;
        else cout << 101 << endl;
    } else if (d >= 1){
        if(n != 100) cout << pow(100, d) * n << endl;
        else cout << long(pow(100, d) * (n + 1)) << endl;
    } 
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c,d,e,k;
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);
	if(b-a<=k&&c-a<=k&&d-a<=k&&e-a<=k&&c-b<=k&&d-b<=k&&e-b<=k&&d-c<=k&&e-c<=k&&e-d<=k)
		printf("Yay!\n");
	else
		printf(":(\n");
	return 0;
 } 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    string s[h];
    rep (i, h) cin >> s[i];

    int ans = 1e9;
    range (WB, 1, h - 1) range (BR, WB + 1, h) {
        int sum = 0;
        rep   (i, WB)     rep (j, w) sum += s[i][j] != 'W';
        range (i, WB, BR) rep (j, w) sum += s[i][j] != 'B';
        range (i, BR,  h) rep (j, w) sum += s[i][j] != 'R';
        ans = min(ans, sum);
    }
    cout << ans << endl;

    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  while(n > 0) {
    if (n % 10 == 7) {
      cout << "Yes" << endl;
      return 0;
    }
    n /= 10;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<stdbool.h>


typedef  long long ll;

int int_cmp(const void *a, const void *b){ 
    const int *ia = (const int *)a;
    const int *ib = (const int *)b;
    return *ia  - *ib; 
} 



int max(int a,int b){
	if(a<b)
		a=b;
	return a;	
}

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

int absolu(int n){
	if(n<0)
		n*=-1;
	
	return n;	
}


void solve(){
	int x;
	scanf("%d",&x);
	
	if(400<=x && x<=599){
		printf("8\n");
	}else if(600<=x && x<=799)
		printf("7\n");
	else if(800<=x && x<=999)
		printf("6\n");
	else if(1000<=x && x<=1199)
		printf("5\n");
	else if(1200<=x && x<=1399)
		printf("4\n");
	else if(1400<=x && x<=1599)
		printf("3\n");
	else if(1600<=x && x<=1799)
		printf("2\n");
	else if(1800<=x && x<=1999)
		printf("1\n");						
}



int main(){
   /*int t;
	scanf("%d",&t);
	
	while(t--)*/
		solve();
	
	
	
	return 0;
}	
				

Measured memory_bytes: 1664
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
li = [0 for i in range(N)]
for i in A:
    li[i-1] += 1
for i in li:
    if K - Q + i > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 8628
# from sys import exit, stderr
# from inspect import currentframe
# def debug(*args):
#     names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
#     print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=stderr)
#     return
N = int(input())
a = [int(_) for _ in input().split()]
b = set()
out = []
n = 0
for i in range(N-1, -1, -1):
    if a[i] == 1:
        out.append(i + 1)
        n += 1
        # print(i+1)
        for f in range(1, int((i+1)**0.5)+1):
            if (i+1)%f == 0:
                a[f-1] = 0 if a[f-1] == 1 else 1
                if f != (i+1)//f and f != 1:
                    a[(i+1)//f-1] = 0 if a[(i+1)//f-1] == 1 else 1
    # debug(a)
print(n)
# print(b)
if len(out) > 0:
    for i in range(len(out)):
        print(out[i], end=" ")
    print()


Measured memory_bytes: 69480
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_vec() -> Vec<i32> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().unwrap())
        .collect()
}

fn main() {
    let N: usize = read_line().parse().unwrap();
    let H = read_vec();
    let mut prev = 0;
    for h in H {
        if prev < h {
            prev = h - 1;
        } else if prev > h {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 8444
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 19 22:50:08 2019

@author: Yamazaki Kenichi
"""
import functools

N, K = list(map(int,input().split()))
A = list(map(int,input().split()))
A.sort()

S = sum(A)

def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
def dfs(x,d):
    return x%d

D = make_divisors(S)
ans = 1
for d in D:
    B = list(map(functools.partial(dfs,d=d),A[:]))
    B.sort()
    l, r, tmp = 0, N-1, 0
    res = 0
    while l <= r:
        if B[l] + B[r] + tmp == d:
            res += B[l]
            tmp = 0
            l += 1
            r -= 1
        elif B[l] + B[r] + tmp < d:
            tmp = B[l] + tmp
            res += B[l]
            l += 1
        else:
            tmp = B[r] + tmp - d 
#            res += B[l]
            r -= 1
#        print(l,r,tmp,res)
    if res <= K and d > ans:
        ans = d
print(ans)


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

int main() {
  int a, b;
  string s, t, u;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  
  if (u == s)
    cout << a-1 << " " << b << endl;
  else
    cout << a << " " << b-1 << endl;
  
  return 0;
}

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

int main()
{
	char c;
	int w, n;
	cin >> w >> n;
	vector<int> res(w);
	for (int i = 0; i < w; i++) {
		res[i] = i + 1;
	}
	for (int i = 0, a, b; i < n; i++) {
		cin >> a >> c >> b;
		swap(res[a - 1], res[b - 1]);
	}
	for (int i = 0; i < w; i++) {
		cout << res[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3036
N = int(input())
c,s,f = [],[],[]

for _ in range(N-1):
	c_tmp,s_tmp,f_tmp = map(int, input().split())
	c.append(c_tmp)
	s.append(s_tmp)
	f.append(f_tmp)

for i in range(N-1):
	ans = 0

	for j in range(i, N-1):
		if ans < s[j]:
			ans = s[j] + c[j]
		elif ans % f[j] == 0:
			ans += c[j]
		else:
			ans = ((ans//f[j])+1) * f[j] + c[j]

	print(ans)

print(0)

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

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

    if(D == 0)
    {
        if(N == 100)
        {
            cout << "101";
        }
        else
        {
            cout << N;
        }
    }
    else if(D == 1)
    {
        if(N == 100)
        {
            cout << "10100";
        }
        else
        {
            int a1 = 100 * N;
            cout << a1;
        }
    }
    else if(D == 2)
    {
        if(N == 100)
        {
            cout << "1010000";
        }
        else
        {
            int a2 = 10000 * N;
            cout << a2;
        }
    }
    return 0;
}


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

int main(){
  int N, Q;
  cin >> N >> Q;
  vector<repair_info> a;
  for (auto i = 0; i < N; i++)
  {
    ll s, t, x;
    cin >> s >> t >> x;
    if(s-x<0)s = 0;
    else s = s-x;
    if(t-x<0)t = 0;
    else t = t-x;
    a.push_back(repair_info(x,s,t));
  }
  sort(a.begin(), a.end());
  int d[Q];
  rep(i,Q)cin >> d[i];
  set<P> S;
  rep(i,Q)S.insert(P(d[i],i));
  vector <int> ans(Q,-1);
  rep(i,N){
    int x,l,r;
    tie(x,l,r)= a[i];
    auto it = S.lower_bound(P(l,-1));
    while(it != S.end()){
      if(it->first>=r)break;
      ans[it->second] = x;
      S.erase(it++);
    }
  }
  rep(i,Q)cout << ans[i] << endl;
  // rep(i,N){
  //   int& t = get<0>(a[i]);
  //   std::cout << t << std::endl;
  // }
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  if ((a == b)&&(b == c)) {
    cout << 1 << endl;
  } else if ((a == b)||(b == c)) {
    cout << 2 << endl;
  } else if (a == c) {
    cout << 2 << endl;
  } else {
    cout << 3 << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };

	static int maxS = 3000;
	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt(), a = in.nextInt();
			int[] x = in.nextIntArray(n);

			long[][][] dp = new long[n+1][maxS][n+1];
			dp[0][0][0] = 1;

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < maxS; j++) {
					for (int k = 0; k <= n; k++) {
						if (j-x[i] >= 0 && k-1 >= 0) {
							dp[i+1][j][k] = dp[i][j-x[i]][k-1] + dp[i][j][k];
						} else {
							dp[i+1][j][k] = dp[i][j][k];
						}
					}
				}
			}

			long count = 0;
			for (int k = 1; k <= n; k++) {
				count += dp[n][k*a][k];
			}

			out.println(count);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 132308
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, bool>> submit(N);
  for (int i = 0; i < N; i++) {
    submit[i] = make_pair(0, false);
  }
  if (M == 0) {
    cout << 0 << " " << 0 << endl;
    return 0;
  }
  for (int i = 0; i < M; i++) {
    int p;
    string s;
    cin >> p >> s;
    if (!submit[p-1].second) { //まだWAだったら
      if (s == "AC") {
        submit[p-1].second = true;
      }
      else if (s == "WA") {
        submit[p-1].first++;
      }
    }
    else { //すでにACしていたら
      continue;
    }
  }
  int pena = 0;
  int countAC = 0;
  for (int i = 0; i < N; i++) {
    if (submit[i].second) {
      countAC++;
      pena += submit[i].first;
    }
  }
  cout << countAC << " " << pena << endl;
}

  

      

Measured memory_bytes: 1024
#!/usr/bin/env python3

import sys
import math
import itertools

def main():
    n, m = map(int, sys.stdin.readline().split())
    if m == 0:
        ss = []
        cs = []
    else:
        ss, cs = map(list, zip(*(map(int, sys.stdin.readline().split()) for _ in range(m))))

    ans = [None for _ in range(n)]

    for i in range(m):
        if ans[ss[i] - 1] is None:
            ans[ss[i] - 1] = cs[i]
        elif ans[ss[i] - 1] != cs[i]:
            return "-1"

    if n == 1:
        if ans[0] is None:
            return "0"
        else:
            return str(ans[0])

    if ans[0] == 0:
        return "-1"

    for k in range(n):
        if ans[k] is None:
            if k == 0:
                ans[k] = 1
            else:
                ans[k] = 0

    return ''.join(map(str, ans))

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3188
N = gets.to_i
As = gets.split.map(&:to_i)

# ハッシュで集計してカウントする関数
hsh = As.each_with_object(Hash.new(0)){|v,o| o[v]+=1}

1.upto(N){|n|
  hsh[n] = 0 if hsh[n].nil?
  puts hsh[n]
}

Measured memory_bytes: 39564
#include <iostream>
#include <utility>
#include <cstdio>
#include <cmath>

using namespace std;
int main(){
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?')
            break;
        else if(op=='+')
            printf("%d\n",a+b);
        else if(op=='-')
            printf("%d\n",a-b);
        else if(op=='*')
            printf("%d\n",a*b);
        else if(op=='/')
            printf("%d\n",a/b);
        else
            printf("Not Desined\n");
    }
}

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

#define maxn 300005
int n,a,b,c[maxn];

int main(){
	scanf("%d%d%d",&n,&a,&b);
	int ans=-1;
	for(int i=0;i<=n;++i)
		if(n-i+ceil(i*1.0/b)==a){
			ans=i;break;
		}
	if(a+b>n+1||ans==-1){
		puts("-1");
		return 0;
	}
	for(int i=1;i<=n-ans;++i)c[i]=i;
	int t=ans%b,cur=n-ans+1;
	for(int i=n-ans+t;i>n-ans;)c[i--]=cur++;
	for(int i=n-ans+t+b;i<=n;i+=b)
		for(int j=0;j<b;++j)
			c[i-j]=cur++;
	
	for(int i=1;i<n;++i)printf("%d ",c[i]);
	printf("%d\n",c[n]);
	
	return 0;
} 

Measured memory_bytes: 3328
N,M,X,Y = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]
x.sort()
y = [int(x) for x in input().split()]
y.sort()
for i in range(x[-1]+1,y[0]+1):
  if X<i<=Y:
    print("No War")
    exit()
print("War")

Measured memory_bytes: 3064
h,w=gets.split.map(&:to_i)
s=[]
c=0
h.times do
  s << gets.chomp
  c+=s[-1].count(".")
end
k=1
q=[[0,0]]
s[0][0]="#"
while s[-1][-1]=="."
  if q==[]
    puts "-1"
    exit
  end
  z=[]
  q.each do |i,j|
    [[1,0],[0,1],[-1,0],[0,-1]].each do |dx,dy|
      y,x=i+dy,j+dx
      if x>=0&&x<w&&y>=0&&y<h&&s[y][x]=="."
        z << [y,x]
        s[y][x]="#"
      end
    end
  end
  q=z.dup
  k+=1
end
puts c-k


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  string s = "";
  while (n > 0) {
    n--;
    s += ('a' + n % 26);
    n /= 26;
  }
  reverse(s.begin(), s.end());
  cout << s << '\n';
  return 0;
}

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

#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)

#define ii pair<int, int>
#define mp make_pair
#define FF first
#define SS second

#define vi vector<int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>

#define eb emplace_back
#define ef emplace_front
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()

#define oo 1000000007
#define OO 1000000000000000007LL

using namespace std;

#define Pro "tmp"
#define maxN 1507

int f[maxN][maxN][5], dp[maxN][maxN];
int a[maxN][maxN];

int main() {
//    #ifndef ONLINE_JUDGE
//        freopen(Pro".inp", "r", stdin);
//        freopen(Pro".out", "w", stdout);
//    #endif // ONLINE_JUDGE

    int n, m;
    scanf("%d%d", &m, &n);

    fto (i, 1, n) {
        fto (j, 1, m) {
            scanf("%d", &a[i][j]);
        }
    }

    fdto (i, n, 1) {
        fdto (j, m, 1) {
            dp[i][j] = dp[i+1][j]+dp[i][j+1]-dp[i+1][j+1]+a[i][j];
        }
    }

    fdto (sum, n+m, 2) {
        fto (i, 1, n) {
            int j = sum-i;
            if (j < 1 || j > m) continue;

            f[i][j][0] = max(dp[i][j]-f[i+1][j][1], dp[i][j+1]-f[i][j+1][1]);
            f[i][j][1] = max(dp[i+1][j]-f[i+1][j][0], dp[i][j]-f[i][j+1][0]);
        }
    }

    cout << abs(dp[1][1]-2*f[1][1][0]) << endl;
    return 0;
}



Measured memory_bytes: 38436
object Main extends scala.App {
    import java.util
    import scala.collection._
    import scala.collection.mutable
    import scala.math._

    val sc = new java.util.Scanner(System.in)
    val m1, d1 = sc.nextInt()
    val m2, d2 = sc.nextInt()

    println(if (m1 != m2) 1 else 0)
}

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

int main()
{
	ll x;
	cin>>x;
	
	ll s=100,cnt=0;
	while(s<x)
	{
		s=s*1.01;
		cnt++;
	}
	
	cout<<cnt<< endl;
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    string s, t; cin >> s >> t;

    string ans = s + t;
    for(int i = 0; i < n + 1; i++) {
        if(s.substr(n - i, i) == t.substr(0, i)) {
            ans = s + t.substr(i, n);
        }
    }

    cout << ans.length() << endl;
}


Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
zero=[0]*n
ans=0
while set(h)!={0}:
    for i in range(n):
        if h[i]==0:
            zero[i]=1

        if i==n-1 and h[i]!=0:
            h[i]+=-1
            ans+=1
        elif h[i]>=1:
            h[i]+=-1
        elif h[i]==0 and zero[i-1]==0 and i!=0:
            zero[i]=1
            ans+=1

print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;

int main() {
	int Max, Min;
	int N;
	int R[200000];

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> R[i];
	}

	Min = R[0];
	Max = -2000000000;

	for (int i = 1; i < N; i++) {
		Max = max(Max, R[i] - Min);
		Min = min(Min, R[i]);
	}

	cout << Max << endl;
	return 0;
}


Measured memory_bytes: 3892
#include <bits/stdc++.h>
using namespace std;
int main() 
{
	long long int n;
	cin>>n;
	vector<long long int> A(n);
	for(long long int i=0;i<n;i++)
	{
	    cin>>A[i];
	}
	vector<vector<pair<long long int,long long int>>> dp(n,vector<pair<long long int,long long int>>(n,make_pair(0,0)));
	for(long long int size=0;size<n;size++)
	{
	    for(long long int i=0;i<n-size;i++)
	    {
	        long long int j=i+size;
	        if(size==0)
	        {
	            dp[i][j].first=A[i];
	            dp[i][j].second=0;
	            continue;
	        }
	        long long int temp1=A[j]+dp[i][j-1].second;
	        long long int temp2=A[i]+dp[i+1][j].second;
	        if(temp1>temp2)
	        {
	            dp[i][j].first=temp1;
	            dp[i][j].second=dp[i][j-1].first;
	        }
	        else
	        {
	            dp[i][j].first=temp2;
	            dp[i][j].second=dp[i+1][j].first;
	        }
	    }
	}
    cout<<dp[0][n-1].first-dp[0][n-1].second;
}

Measured memory_bytes: 141056
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	string s;
	cin >> s;
	int n = s.size();
	
	vector<vector<int>> sum(n+1, vector<int>(26,0));
	REP(i,n){
		REP(j,26) sum[i+1][j] = sum[i][j];
		sum[i+1][s[i]-'a']++;
	}
	
	REP(i,n-1) REP(j,26){
		// [i, now)
		int now;
		now = n;
		while(now - i > 1){
			if(sum[now][j]-sum[i][j] > (now-i)/2){
				cout << i+1 << " " << now << endl;
				return 0;
			}else{
				now = i-1 + (sum[now][j]-sum[i][j])*2;
			}
		}
	}
	
	cout << "-1 -1\n";
	
	
	return 0;
}

Measured memory_bytes: 16680
#define _GLIBCXX_DEBUG
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(m);
    vector<pair<int, int>> dat(m, make_pair(0, 0));
    for (int i = 0; i < n; i++) {
        int e; cin >> e;
        a[e%m].emplace_back(e);
    }
    for (int i = 0; i < m; i++) sort(a[i].begin(), a[i].end());
    for (int i = 0; i < m; i++) {
        const auto &v = a[i];
        const int k = (int)v.size();
        for (int j = 0; j < k; j++) {
            if (j+1 < k and v[j] == v[j+1]) dat[i].first++, j++;
            else dat[i].second++;
        }
    }

    int ans = 0;
    for (int i = 0, j = 0; i <= j; i++, j = (m - i) % m) {
        if (i == j) { ans += dat[i].first + dat[i].second / 2; continue; }
        pair<int, int> s = dat[i], t = dat[j];
        if (s.second < t.second) swap(s, t);
        ans += s.first + t.second;
        s.second -= t.second;
        if (s.second & 1) s.second--;
        t.first *= 2;
        ans += min(t.first, s.second);
        t.first = max(0, t.first - s.second);
        ans += t.first / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9600