akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,c[55],col[55];;
vector<int>edge[55];
void dfs(int v,int cc){
	if(col[v] != -1) return;
	col[v] = cc;
	rep(i,edge[v].size()){
		if(col[edge[v][i]] == -1){
			dfs(edge[v][i],1-cc);
		}
	}
}
int main(){
	cin>>n; rep(i,n) cin>>c[i]; c[n] = 0; n++;
	sort(c,c+n);
	for(int ans=24;ans>=0;ans--){
		rep(i,55) edge[i].clear();
		rep(i,55) col[i] = -1;
		bool bad = 0;
		rep(i,n){
			for(int j=i+1;j<n;j++){
				if(min(24-c[j]-c[i],c[j]+c[i])<ans) bad = 1;
				else if(c[j]-c[i]<ans){
					edge[i].pb(j);
					edge[j].pb(i);
				}
			}
		}
		if(bad == 1) continue;
		rep(i,n){
			if(col[i] != -1) continue;
			dfs(i,0);
		}
		rep(i,n){
			rep(j,edge[i].size()){
				if(col[i] == col[edge[i][j]]){
					bad = 1;
				}
			}
		}
		if(bad == 1) continue;
		cout<<ans<<endl; return 0;
	}
}

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

char classifier(int pm,int pe,int pj){
	if(pm==100||pe==100||pj==100)return 'A';
	if(90<=(pm+pe)/2)return 'A';
	if(80<=(pm+pe+pj)/3)return 'A';
	if(70<=(pm+pe+pj)/3)return 'B';
	if(50<=(pm+pe+pj)/3 && (80<=pm||80<=pe))return 'B';
	return 'C';
}
int main(){
	int n;
	while(cin>>n&&n){
		int a,b,c;
		for(int i=0;i<n;i++){
			cin>>a>>b>>c;
			cout<<classifier(a,b,c)<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1148
import numpy as np
ans=0
D=int(input())
C=np.array(list(map(int,input().split())))
last_day=np.array([-1 for _ in range(26)])
score=np.array([list(map(int,input().split())) for _ in range(D)])

for day in range(D):
    t=int(input())-1
    last_day[t]=day
    tmp=C*(last_day-day)
    ans=ans+score[day][t]+sum(tmp)
    print(ans)




Measured memory_bytes: 26988
from itertools import groupby

N, K = map(int, input().split(" "))
S = input()

# print([list(g) for k, g in groupby(S)])
l = [len(list(g)) for k, g in groupby(S)]

if S[0] == "0":
    l = [0] + l
if S[-1] == "0":
    l += [0]

# print(l)

w = K*2+1

m = sum(l[:w])
max_num = m
for i in range(len(l)-w):
    # print(w, i)
    m -= l[i]
    m += l[w+i]
    if i%2 == 1:
        # print(m)
        max_num = max(max_num, m)

print(max_num)


Measured memory_bytes: 4980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,ans=1;
  	cin>>n;
  
  	for(ll i=1;i<n+1;i++){
		ans*=i;
      	ans%=1000000007;
    }
	cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ");cout<<endl;
#define pdd(a,n,m)for(int i=0;i<n;i++){for(int j=0;j<m;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define mp make_pair
#define pb push_back
#define ll long long
#define int ll
//#define __int64 lng long
#define P pair<int,int>
#define PP pair<P,int>


ll simyu(ll n,ll k){
  ll now=n;

  for(;;){
    if(now%k){
      if(now<k)
        break;
      now-=k;
    }
    else{
      now/=k;
    }
  }
  return now;
}

bool che(ll n,ll k){
  ll now=n;
  if(k==1)return 0;
  while(now%k==0)
    now/=k;
  return now%k==1;
}

ll solve1(ll n){
  ll ans=0;
  for(ll i=2;i<=n;i++){
    if(simyu(n,i)==1){
      ans++;
      //cout<<""
    }
  }
  return ans;
}
ll solve2(ll n){
  ll ans=0;

  for(ll i=1;i*i<n;i++){
    ll a=i,b=(n-1)/i;
    if(a==b){
      if(n%a==1)
      ans++;
      continue;
    }
    if(n%a==1)ans++;
    if(n%b==1)ans++;
  }

  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      if(i==n/i){
        if(che(n,i))
        ans++;
        continue;
      }
      if(che(n,i))ans++;
      if(che(n,n/i))ans++;
    }
  }
 // cout<<ans<<endl;
 return ans;
}

signed main(){
  ll n;
  cin>>n;
  cout<<solve2(n)<<endl;
  return 0;
}


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

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

  int N;
  cin >> N;
  set<int> s;
  for(int i = 0; i < N; i++){
    int A;
    cin >> A;
    if(s.count(A)){
      cout << "NO" <<endl;
      return 0;
    } else{
      s.insert(A);
    }
  }
  cout << "YES" <<endl;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
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(){
	vector<int> a(5);
	for(int i = 0; i < 5; i++) {
		a[i] = i+1;
	}
	for(int i = 0; i < 5; i++) {
		int x;cin>>x;
		if (x != a[i])cout << a[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define ll long long

const int MOD = 1e9 + 7;

int main() {
    int map[500][500];
    int a[310000], b[310000], c[310000], d[310000];
    int H, W;
    cin >> H >>W;
    REP(y, H) REP(x, W) {
        cin >> map[y][x];
    }
    
    int dx = 1, x = 0, y = 0, x2, y2;
    int cnt = 0;
    while(1) {
        if(x + dx == W || x + dx == -1) {
            dx *= -1;
            x2 = x;
            y2 = y + 1;
        } else {
            x2 = x + dx;
            y2 = y;
        }

        if(y2 >= H) {
            break;
        }

        if(map[y][x] % 2 == 1) {
            a[cnt] = y+1;
            b[cnt] = x+1;
            c[cnt] = y2+1;
            d[cnt] = x2+1;
            map[y][x]--;
            map[y2][x2]++;
            cnt++;
        }

        x = x2;
        y = y2;
    }
    printf("%d\n", cnt);
    REP(i, cnt) {
        printf("%d %d %d %d\n", a[i],b[i],c[i],d[i]);
    }
}


Measured memory_bytes: 7296
source = input()
target = input()
t_len = len(target)
answer = "z" * 51
for i in range(len(source) - t_len + 1):
    for j in range(i, i + t_len):
        # print(i, source[j], target[j - i])
        if source[j] == target[j - i] or source[j] == "?":
            pass
        else:
            break
    else:
        temp_s = source[:i] + target + source[i + t_len:]
        temp_s = temp_s.replace("?", "a")
        answer = min(answer, temp_s)

if answer == "z" * 51:
    print("UNRESTORABLE")
else:
    print(answer)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){

  int n;
  int p;
  int sum=0;
  

  while(cin >> n,n){

    for(int i=0;i<(n/4);i++){
      cin >> p; 
      sum+=p;
    }

    cout << sum << endl;
    sum=0;

  }
      
  return 0;

}

Measured memory_bytes: 3076
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
using namespace std;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;

int n;
string s;
map<string,int> cnt;
int res;

int main() {
    ios::sync_with_stdio(false);
    cin>>n;
     while(n--){
         cin>>s;
         if(!cnt[s])
          cnt[s]++,res++;
     }
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 19288
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <ctime>
#include <complex>

#define enp 	printf("**Entry Point**\n")
#define A		first
#define B		second
#define MP		make_pair

using namespace std;

typedef long long ll;

const int INF = 0x6fffffff;
const int MINF = 0x80000000;
const ll mod = 100003;
const int cons = 100001;
const double pi = 3.141592653589793;

int tree[1000001];
int pos[200001];
int n;

void upd(int pos, int vl, int L = 0, int R = n - 1, int node = 1)
{
	if (pos > R || pos < L)return;

	if (L == R)
	{
		tree[node] = vl;
		return;
	}

	int mid = L + R >> 1;

	upd(pos, vl, L, mid, 2 * node);
	upd(pos, vl, mid + 1, R, 2 * node + 1);

	tree[node] = min(tree[2 * node], tree[2 * node + 1]);
}

int query(int L, int R, int cL = 0, int cR = n - 1, int node = 1)
{
	if (cR < L || cL > R)return INF;

	if (L <= cL && R >= cR)
	{
		return tree[node];
	}

	int mid = cL + cR >> 1;

	return min(query(L, R, cL, mid, 2 * node), query(L, R, mid + 1, cR, 2 * node + 1));
}

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

	for (int i = 0, x; i < n; i++)
	{
		scanf("%d", &x);
		pos[x] = i;
	}

	memset(tree, 0x3f, sizeof(tree));

	ll ans = 0;

	for (int i = 1; i <= n; i++)
	{
		int cur = pos[i];
		int l = cur;
		int r = n;
		int R, L;
		
		while (l + 1 < r)
		{
			int mid = l + r >> 1;

			int res = query(cur, mid);

			if (res > i)l = mid;
			else r = mid;
		}

		R = l;

		l = -1;
		r = cur;

		while (l + 1 < r)
		{
			int mid = l + r >> 1;

			int res = query(mid, cur);

			if (res > i)r = mid;
			else l = mid;
		}

		L = r;

		ans += ((ll)cur - L + 1)*((ll)R - cur + 1)*(ll)i;

		upd(cur, i);
	}

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

	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n;
  cin >> n;
  vi d(n);
  rep(i,n){
    cin >> d[i];
  }
  sort(all(d));
  ll count = 1;
  for (ll i = 1; i < n; i++){
    if(d[i]!=d[i-1]){
      count++;
    }
  }
  print(count);
}


Measured memory_bytes: 256
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>

using namespace std;
const int MOD = 1000000007;

#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
#define mod_mul(x, y) x*y%MOD
#define mod_add(x, y) (x+y)%MOD
#define mod_sub(x, y) (x-y)%MOD

long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
}

long lcm( long m, long n ){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}


long nCr(long n, long r){
    if(n==r || r==0){
        return 1;
    } else {
        return mod_add(nCr(n-1,r),nCr(n-1,r-1));
    }
}

char ayy[3];
int nums[4];




int main(){
    string n; cin >>n;
    nums[0] = (int) n[0] - '0';
    nums[1] = (int) n[1] - '0';
    nums[2] = (int) n[2] - '0';
    nums[3] = (int) n[3] - '0';
    
    for(int i=0; i<2; i++){
        for(int j=0; j<2; j++){          
            for(int k=0; k<2; k++){
                int n= nums[0];
                if(i == 0){
                    n+= nums[1];
                    ayy[0] = '+';
                }else{
                    n-= nums[1];
                    ayy[0] = '-';
                }

                if(j == 0){
                    n+= nums[2];
                    ayy[1] = '+';
                }else{
                    n-= nums[2];
                    ayy[1] = '-';
                }

                if(k == 0){
                    n+= nums[3];
                    ayy[2] = '+';
                }else{
                    n-= nums[3];
                    ayy[2] = '-';
                }

                if(n ==7){
                    cout<<nums[0]<<ayy[0]<<nums[1]<<ayy[1]<<nums[2]<<ayy[2]<<nums[3]<<"=7"<<endl;
                    return 0;
                }
            }
        }      
    }

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5+5;
int in_degree[MAX];
vector<int> edges[MAX];
int dist[MAX];
bool vis[MAX];
void dfs(int s)
{
	vis[s] = true;
	for(auto b: edges[s])
	{
		dist[b] = max(dist[b] , dist[s]+1);
		--in_degree[b];
		if(in_degree[b] == 0)
			dfs(b);
	}
}


int main()
{
	int n, m;
	cin >> n >> m;
	std::vector<int> dp(n+1, 0);
	for(int i = 0; i < m; ++i)
	{
		int a, b;
		cin >> a >> b;
		in_degree[b]++;
		edges[a].push_back(b);
	}

	for(int i = 1; i <= n; ++i)
	{
		if(!vis[i] && in_degree[i] == 0)
			dfs(i);
	}

	int ans = 0;
	for(int i = 0; i<=n; ++i)
	{
		ans = max(ans, dist[i]);
	}
	cout << ans ;

}

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

int main(){
	int a, b;
	cin >> a >> b;
	if(a*b%2 == 0) cout << "Even" << endl;
	else cout << "Odd" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
class problem
{
    static void Main()
    {
        int n = Convert.ToInt32( Console.ReadLine() );
        Dictionary<int, string> dic = new Dictionary<int,string>();
        for(int i = 0 ; i < n ; i++)
        {
            var a = Console.ReadLine().Split();
            dic.Add(  Convert.ToInt32( a[1] ),a[0] );
        }
        var kq = dic.OrderBy( x => x.Value ).ThenByDescending(x=>x.Key).Select(x=>x);
        var ls=dic.Select(x=>x.Key).ToList();
        foreach(var v in kq)
            for(int i = 0 ; i < dic.Count ; i++)
                if(v.Key == Convert.ToInt32( ls[i] ))
                    Console.WriteLine( i+1 );

    }
}


Measured memory_bytes: 13792
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var grouped = a.GroupBy(v => v).ToList();

        if (grouped.Count > 3)
        {
            Console.WriteLine("No");
            return;
        }

        var keys = grouped.Select(g => g.Key).ToList();
        var counts = grouped.Select(g => g.Count()).ToList();

        Console.Error.WriteLine("keys:" + string.Join(" ", keys));
        Console.Error.WriteLine("counts:" + string.Join(" ", counts));

        switch (grouped.Count)
        {
            case 1:
                if ((keys[0] ^ keys[0]) == keys[0])
                {
                    Console.WriteLine("Yes");
                    return;
                }
                break;
            case 2:
                if (((keys[0] ^ keys[1]) == keys[1] && (keys[1] ^ keys[1]) == keys[0] && counts[0] * 2 == counts[1])
                    || ((keys[1] ^ keys[0]) == keys[0] && (keys[0] ^ keys[0]) == keys[1] && counts[1] * 2 == counts[0]))
                {
                    Console.WriteLine("Yes");
                    return;
                }
                break;
            case 3:
                if ((keys[0] ^ keys[1]) == keys[2] && counts[0] == counts[1] && counts[0] == counts[2])
                {
                    Console.WriteLine("Yes");
                    return;
                }
                break;
        }

        Console.WriteLine("No");
    }
}

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

int n,k,sz,q[2010],dist[2010],ans=1e9;
vector<int> pos[2010];

inline void bfs()
{
	for(int i=0;i<sz;i++)
	{
		int cur=q[i];
		for(int j:pos[cur])
		{
			int w=dist[cur]+2;
			if(dist[j]<=w) continue;
			dist[j]=w;
			q[sz++]=j;
		}
	}
}

inline int solveVertex(int i)
{
	fill(dist,dist+n,1e9);
	dist[i]=0;
	sz=0;
	
	q[sz++]=i;
	bfs();
	int sum=0;
	for(int j=0;j<n;j++) if(dist[j]>k) sum++;
	
	return sum;
}

inline int solveEdge(int i,int j)
{
	fill(dist,dist+n,1e9);
	dist[i]=dist[j]=1;
	sz=0;
	
	q[sz++]=i;
	q[sz++]=j;
	bfs();
	int sum=0;
	for(int m=0;m<n;m++) if(dist[m]>k) sum++;
	
	return sum;
}

int main()
{
	cin>>n>>k;
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;b--;
		pos[a].push_back(b);
		pos[b].push_back(a);
	}
	
	for(int i=0;i<n;i++) ans=min(ans,solveVertex(i));
	for(int i=0;i<n;i++)
		for(int j:pos[i])
			if(j>i) ans=min(ans,solveEdge(i,j));
	
	cout<<ans;
	
	return 0;
}

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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/
const ll mod=1e9+7;
const ll INF=1e18;
/*****************************************************************************/

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	string s,t; cin >>s >>t;
	int ans=1e9;
	for (int i=0;i<=sz(s)-sz(t);i++) {
		string str=s.substr(i,sz(t));
		int cnt=0;
		for (int j=0;j<sz(t);j++) {
			if (str[j]!=t[j]) cnt++;
		}
		ans=min(ans,cnt);
	}
	cout <<ans;
	return 0;
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 3604
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
//#define int long long
using namespace std;
const int inf=0x3f3f3f3f;
const int N=1e5+10,M=1e6+10;
int n,m,d[N],vis[N];
int head[N],nex[M],to[M],w[M],tot;
priority_queue<pair<int,int>> q;	set<int> s[N];
inline void ade(int a,int b,int c){
	to[++tot]=b; nex[tot]=head[a]; w[tot]=c; head[a]=tot;
}
inline void add(int a,int b,int c){ade(a,b,c);	ade(b,a,c);}
void Dijkstra(){
	memset(d,inf,sizeof d);	d[1]=0; q.push({0,1});
	while(q.size()){
		int u=q.top().second;	q.pop();
		if(vis[u])	continue;	vis[u]=1;
		for(int i=head[u],val;i;i=nex[i]){
			val=(s[u].find(w[i])!=s[u].end()?0:1);
			if(d[to[i]]>d[u]+val){
				d[to[i]]=d[u]+val;	q.push({-d[to[i]],to[i]});
				s[to[i]].clear();	s[to[i]].insert(w[i]);
			}else if(d[to[i]]==d[u]+val)	s[to[i]].insert(w[i]);
		}
	}
}
signed main(){
	cin>>n>>m;
	for(int i=1,a,b,c;i<=m;i++)	scanf("%d %d %d",&a,&b,&c),add(a,b,c);
	Dijkstra();
	if(d[n]==inf)	d[n]=-1;
	cout<<d[n]<<endl;
	return 0;
}


Measured memory_bytes: 23416
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int t1,t2,a1,a2,b1,b2;
    cin>>t1>>t2>>a1>>a2>>b1>>b2;
    a1*=t1,a2*=t2,b1*=t1,b2*=t2;
    a2+=a1,b2+=b1;
    if(a2==b2){
        cout<<"infinity"<<endl;
        return 0;
    }
    if(a2<b2){
        swap(a1,b1);
        swap(a2,b2);
    }
    if(a1>b1){
        cout<<0<<endl;
        return 0;
    }
    cout<<(b1-a1)/(a2-b2)*2+!!((b1-a1)%(a2-b2))<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N, M, A, B, C;
    string s1, s2; 
    cin >> N;
    for(int i = 1; i <= 10; i++){
        if(i * 1000 >= N){
            cout << 1000 * i - N << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 3548
/*input
3 3 3
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}



int main()
{
	ll a,b,k;
	cin>>a>>b>>k;
	REP(I,k){
		if(I&1){
			b>>=1;
			a+=b;
		}
		else{
			a>>=1;
			b+=a;
		}
	}
	cout<<a<<' '<<b<<'\n';
	return 0;
}


Measured memory_bytes: 256
N = int(input())
W = [input().strip() for _ in range(N)]

# 重複があると前者を満たさない。後者を満たさないとしりとりになっていない
if len(W) == len(set(W)) and all(W[i + 1][0] == W[i][-1] for i in range(N - 1)):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <stdio.h>
int main(){
	//N test cases
	//each case, theres a string for the verdict of it
	//find the values of AC, WA, TLE, and RE
	//1<N<1e5
	int n;
	scanf("%d", &n);
	
	int AC = 0;
	int WA = 0;
	int TLE = 0;
	int RE = 0;
	
	for(int i=0; i<n; i++){
		char str[5];
		
		scanf("%s", &str);
		switch (str[0]){	//biar dia bacanya chara pertama aja
			case 'A':	//switch cmn bisa 1 chara ya casenya
				AC++;
				break;
			case 'W':
				WA++;
				break;
			case 'T':
				TLE++;
				break;
			case 'R':
				RE++;
				break;
		}
}
	printf("AC x %d\n", AC);
	printf("WA x %d\n", WA);
	printf("TLE x %d\n", TLE);
	printf("RE x %d\n", RE);
	
	
	return 0;
}

Measured memory_bytes: 1712
/**   
 *   Author:    @glaucoacassioc
 *   Created on 11.09.2020, 15:32:16
**/
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
vector<vii> AdjList;

vi pai, color, dist, ts;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;

	cin >> a >> b >> c;
	swap(a,b);
	swap(a,c);
	cout << a <<" "<< b <<" "<< c <<endl;

	return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
int main(){
	int n[5],k=0,i;
	for(i=0;i<5;i++)scanf("%d",&n[i]);
	n[0]*=n[4];
	if(n[2]<n[4])n[1]+=n[3]*(n[4]-n[2]);
	if(n[0]>n[1])n[0]=n[1];
	printf("%d\n",n[0]);
	return 0;
}


Measured memory_bytes: 2068
s = int(input())
a = []

for i in range(1,1000001):
  if i == 1:
    a.append(s)
  elif s%2 == 0:
    s = s/2
    if s in a:
      print(i)
      exit()
    else:
      a.append(int(s))
  elif s%2 == 1:
    s = 3*s+1
    if s in a:
      print(i)
      exit()
    else:
      a.append(int(s))

Measured memory_bytes: 9124
def getInput():
    """

    :return: list of list of str. 1st dim: row, 2nd dim: column.
    """
    separator = ' '
    ret_array = []
    while True:
        try:
            row = input().split(sep=separator)
            ret_array.append(row)
        except EOFError:
            break
    return ret_array


g = getInput()
A = g[0][0]
B = g[0][1]

if A > B:
    print(">")
elif A < B:
    print("<")
else:
    print("=")



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(void) {
	int N,M;
	cin >> N >> M;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	sort(A.begin(),A.end());
	vector< pair<int,int> > B(M);
	for (int i = 0; i < M; ++i) {
		cin >> B[i].second >> B[i].first;
	}
	sort(B.begin(),B.end());

	int inda = 0;
	int indb = M-1;
	bool end = false;
	while(!end) {
		while (A[inda] < B[indb].first && B[indb].second > 0) {
			A[inda] = B[indb].first;
			if (inda < N-1) {
				++inda;
			}
			--B[indb].second;
		}
		if (indb == 0 || B[indb].second > 0) {
			end = true;
		}
		--indb;
	}
	long long res = 0;
	for (int i = 0; i < N; ++i) {
		res += A[i];
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 1408
///HELLO THERE~!
///CREATED BY MD SADMAN MEHEDI SIVAN(IUT CSE-SWE^19)

#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define read freopen("blue.txt","r",stdin);
#define write freopen("red.txt","w",stdout);
#define pie 2*acos(0.0);

typedef long long ll;

using namespace std;

int  main()
{

    fastio;

    int n;
    cin>>n;

   if(n%10==2 || n%10==4 || n%10==5 ||n%10==7 ||n%10==9)
    cout<<"hon";
   else if(n%10==0 || n%10==1 ||n%10== 6 ||n%10== 8)
    cout<<"pon";
   else
    cout<<"bon";

    return 0;
}


Measured memory_bytes: 3628
S = input()
from collections import defaultdict
dic = defaultdict(int)
dic[0] += 1
# 後ろから見たほうがいい？
S = S[::-1]
d = 1
now = 0
for i in range(len(S)):
    # 2019で割ったあまりで集計する
    now += d*int(S[i]) % 2019
    dic[now%2019] += 1
    d *= 10
    d %= 2019
ans = 0
for k,v in dic.items():
    ans += v*(v-1)//2
print(ans)


Measured memory_bytes: 9588
public partial class IntroductionToProgramming{
	public static void Main(){
		string str = System.Console.ReadLine();
		decimal i = 1;
		while(str != "0")
		{
			System.Console.WriteLine("Case " + i++.ToString() + ": " + str);
			str = System.Console.ReadLine();
		}
	}
}

Measured memory_bytes: 5812
#line 1 "code.cpp"
#include<bits/stdc++.h>
using namespace std;
using lint=long long;

lint n,x,m;

//最初にidxにいた人はk回後にv[idx].firstにいる
//最初にidxにいた人はk回後にv[idx].second点手に入れた
//というように配列を持ちます
//k1回後の情報とk2回後の情報からk1+k2回後の情報が手を手に入れる関数がfです

vector<pair<lint,lint>> f(const vector<pair<lint,lint>>&s,const vector<pair<lint,lint>>&t){
    vector<pair<lint,lint>>ret(m);
    for(int i=0;i<m;++i){
        ret[i]=make_pair(t[s[i].first].first,s[i].second+t[s[i].first].second);
    }
    return ret;
}

int main(){
    cin>>n>>x>>m;
    vector<pair<lint,lint>>v(m),ans(m);
    for(lint i=0;i<m;++i){
        ans[i]=make_pair(i,0);
        v[i]=make_pair(i*i%m,i);
    }
    while(n){
        if(n%2)ans=f(ans,v);
        v=f(v,v);
        n/=2;
    }
    cout<<ans[x].second<<endl;
}


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,t; cin >> s >> t ;
  vector<string> loc1(26,""),loc2(26,"");
  rep(i,s.size()){
    int idx = int(s[i]-'a');
    loc1[idx] += i;
  }
  rep(i,t.size()){
    int idx = int(t[i]-'a');
    loc2[idx] += i;
  }
  sort(ALL(loc1));
  sort(ALL(loc2));
  bool ok = true;
  rep(i,26) ok &= (loc1[i]==loc2[i]);
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
// dp[足場iをみた時] <- INF埋めしてから最小値
int dp[100100];
int main(){
  int n;
  cin >> n;
  vector<int>h(n);
  rep(i,n)cin >> h[i];
  rep(i,100100)dp[i] = INF;
  dp[0] = 0;
  rep(i,n - 1){
    dp[i + 1] = min(dp[i + 1],dp[i] + abs(h[i] - h[i + 1]));
    if(i != n - 2)dp[i + 2] = min(dp[i + 2],dp[i] + abs(h[i] - h[i + 2]));
  }
  cout << dp[n - 1] << endl;
  return 0;
}


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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    unsigned long long int n,x,m,i,j,k,y,z,sum,pref=0,a;
    vector<unsigned long long int>vt;
    map<long long int,long long int>mt;
    vt.push_back(0);
    cin>>n>>x>>m;
    vt.push_back(x);
    mt[x]=1;
    sum=x;
    for(i=2;i<=n;i++){
        x*=x;
        y=x%m;
        if(mt[y]==1){
            k=1;
            pref=y;
            for(j=i-1;j>=1;j--){
                if(vt[j]==y)
                    break;
                 pref+=vt[j];
                 k+=1;
            }
          //  cout<<k<<" "<<pref<<endl;
            sum+=((n-i+1)/k)*pref;
            k=(n-i+1)%k;
            for(a=j;a<j+k;a++){
                sum+=vt[a];
            }
            break;
        }
        //cout<<y<<endl;
        mt[y]=1;
        vt.push_back(y);
        sum+=y;
        x=vt.back();

    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 6720
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,r=0,b=0;
	char x;
	cin>>n;
	while(n--){
		cin>>x;
		(x=='R')?r++:b++;
	}
	cout<<((r>b)?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1e3 + 2;
ll i,n,x,y;
string a;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a;
    n = a.length();
    a = "$" + a;
    rep(i,1,n + 1){
        if(i & 1){
            if(a[i] == '1') x += 1;
            else
                y += 1;
        }
        else{
            if(a[i] == '0') x += 1;
            else
                y += 1;
        }
    }
    cout<<min(x,y);
    return 0;
}

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

typedef long long ll;

int main(){
    int M, K;
    cin >> M >> K;
    if (M == 0) {
        if (K != 0) cout << -1 << endl;
        else cout << 0 << " " << 0 << endl;
    } else if (M == 1) {
        if (K != 0) cout << -1 << endl;
        else cout << 0 <<" "<< 0 <<" "<< 1 << " " << 1 << endl;
    } else {
        int L = 1;
        for (int i=0;i<M;i++){
            L *= 2;
        }
        if (L <= K) cout << -1 << endl;
        else{
           for (int i=0;i<L;i++){
                if (i != K) cout << i << " ";
            }
            cout << K << " ";
            for (int i=L-1;i>=0;i--){
                if (i != K) cout << i << " ";
            }
            cout << K << endl;
        }
    }
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    Fast;
    int n,m,t,x,y,z;
    int a[33]={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};
    cin>>n;
    cout<<a[n-1]<<endl;
}


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

int main() {
    int n;
    cin >> n;
    int arr[n];
    int q;
    for (int x=0; x<n; x++){
        cin >> q;
        arr[q-1] = x+1;

    }
    for (int x=0; x<n; x++){
        cout << arr[x] << " ";
    }
}

Measured memory_bytes: 1152
#ARC052C

n=int(raw_input())
s=[1 for i in range(n+1)]
res=1
for i in range(2,n+1):
 if s[i]:
  for j in range(i*2,n+1,i):
   s[j]=0
  cnt=0
  temp=n
  while temp:
   cnt+=temp/i
   temp/=i
  res=res*(cnt+1)%(10**9+7)
print res


Measured memory_bytes: 2820
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n, k;
    cin >> n >> k;
    long long ans = 0;
    for (long long b = k + 1; b <= n; b++) {
        long long m = n / b;
        ans += (b - k) * m;
        ans += max(n - (b * m + k - 1), 0LL);
        ans -= (k == 0 ? 1 : 0);
        // cout << "b=" << b << " m=" << m << " ans=" << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int N = 0;
    cin >> N;
    int count = 0;
    int ans = 0;
    for (int i = 1; i <= N; i++)
    {
        count = 0;
        for (int j = 1; j <= i; j++)
        {
            if(i % j == 0){
                count++;
            }
        }
        if(count == 8 && i % 2== 1){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
vector<int>V[100100];
int Dist[100100][2];
void Haku(int s, int e, int d, int k) {
	Dist[s][k] = d;
	for (int u : V[s]) if (u != e) Haku(u, s, d + 1, k);
}
int main() {
	int N;
	scanf("%d", &N);
	int x, y;
	scanf("%d%d", &x, &y);
	for (int i = 2; i <= N; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		V[a].push_back(b);
		V[b].push_back(a);
	}
	Haku(x, x, 0, 0);
	Haku(y, y, 0, 1);
	int R = 0;
	for (int i = 1; i <= N; ++i) {
		if (Dist[i][1] < Dist[i][0]) continue;
		R = max(R, Dist[i][1]);
	}
	printf("%d\n", R - 1);
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string bans(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  int ans=n/3;
  cout << ans << endl;
  return 0;
}


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

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

    vector<int> h(n);
    for(int i=0; i<n; i++){
        cin >> h[i];
    }

    vector<int> dp(n);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i=2; i<n; i++){
        dp[i] = min(
            dp[i-2] + abs(h[i] - h[i-2]),
            dp[i-1] + abs(h[i] - h[i-1])
        );
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static int max=0;
	static int N;
	static int M;
	static int[] X;
	static int[] Y;
	public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);

	    N = Integer.parseInt(scanner.next());
	    M = Integer.parseInt(scanner.next());
	    X = new int[M];
	    Y= new int[M-1];


	    for (int i=0; i<M; i++) {
	    	X[i] = Integer.parseInt(scanner.next());
	    }
	    Arrays.parallelSort(X);
	    for (int i=0; i<M-1; i++) {
	    	Y[i] = X[i+1] - X[i];
	    }
	    
	    Arrays.parallelSort(Y);
        long a = 0;
	    for (int i=0; i<M-N;i++) {
	    	a+=Y[i];
	    }
	    

	    System.out.println(a);
	}

}

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

int main() {
    int n, m;
    cin >> n >> m;
    char a[n][n], b[m][m];
    rep(i, n) rep(j, n) cin >> a[i][j];
    rep(i, m) rep(j, m) cin >> b[i][j];

    int d = n - m + 1;
    rep(i, d) rep(j, d) {
        bool ok = true;
        rep(y, m) rep(x, m) if (a[i + y][j + x] != b[y][x]) ok = false;

        if (ok) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	string input;
	cin >> input;

	if (input[1] == input[2])
	{
		if (input[0] == input[1])
		{
			cout << "Yes" << endl;
			return;
		}

		if (input[2] == input[3])
		{
			cout << "Yes" << endl;
			return;
		}
	}

	cout << "No" << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD (1000000007)
#define LL long long
using namespace std;

LL n,k,ans;
vector<LL>v,f;

LL Qpow(LL a,LL b)
{
	LL ans=1;
	while (b)
	{
		if (b&1) ans=ans*a%MOD;
		a=a*a%MOD; b>>=1;
	}
	return ans;
}

int main()
{
	cin>>n>>k;
	for (int i=1; i<=sqrt(n); ++i)
		if (n%i==0)
		{
			v.push_back(i);
			if (n/i!=i) v.push_back(n/i);
		}
	sort(v.begin(),v.end());
	f.resize(v.size());
	for (int i=0,sz=v.size(); i<sz; ++i)
	{
		f[i]=Qpow(k,(v[i]+1)/2);
		for (int j=0; j<i; ++j)
			if (v[i]%v[j]==0) (f[i]-=f[j])%=MOD;
		if (v[i]%2) (ans+=f[i]*v[i]%MOD)%=MOD;
		else (ans+=f[i]*v[i]/2%MOD)%=MOD;
	}
	cout<<(ans+MOD)%MOD<<endl;
}

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

int main() {
	int a, b, x;
  bool ans = false;
    cin >> a >> b >> x;
  for(int i = 0;i <= b; i++){
  	if(a + i == x) ans = true;
  }
  if(ans){
  	cout << "YES" << endl;
  }else{
    cout << "NO" << endl;

  }
return 0;
}



Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize(3)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("sse3","sse2","sse")
#pragma GCC target("avx","sse4","sse4.1","sse4.2","ssse3")
#pragma GCC target("f16c")
#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")
#pragma GCC diagnostic error "-fwhole-program"
#pragma GCC diagnostic error "-fcse-skip-blocks"
#pragma GCC diagnostic error "-funsafe-loop-optimizations"
#pragma GCC diagnostic error "-std=c++14"
#include "bits/stdc++.h"
//#include "ext/pb_ds/tree_policy.hpp"
//#include "ext/pb_ds/assoc_container.hpp"
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) (x&(-x))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9+7;
const ll inf = 1e9+7;
const ld eps = 1e-9;
const db PI = atan(1)*4;
template<typename T>
inline int sign(const T&a) {
    if(a<0)return -1;
    if(a>0)return 1;
    return 0;
}

template<typename T,typename S>inline bool upmin(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T,typename S>inline bool upmax(T&a,const S&b){return a<b?a=b,1:0;}

template<typename T> inline void in(T &x) {
    x = 0;
    T f = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (isdigit(ch))  {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    x *= f;
}

ll twop(int x) {
    return 1LL<<x;
}

template<typename A,typename B > inline void in(A&x,B&y) {
    in(x);
    in(y);
}
template<typename A,typename B,typename C>inline void in(A&x,B&y,C&z) {
    in(x);
    in(y);
    in(z);
}
template<typename A,typename B,typename C,typename D> inline void in(A&x,B&y,C&z,D&d) {
    in(x);
    in(y);
    in(z);
    in(d);
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
namespace SOLVE {
    void main(){
    }
}


int main() {

    
    
    
    
    
    
    
    int n;
    in(n);
    VI a(n),b(n);
    REP(i,0,n)in(a[i]);
    REP(i,0,n)in(b[i]);
    REP(i,1,n)a[i]+=a[i-1];
    RREP(i,n-2,0)b[i]+=b[i+1];
    ll ans = 0;
    REP(i,0,n)upmax(ans, a[i]+b[i]);
    cout<<ans;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
#include <tuple>
#include<iomanip>
#include<stack>
#include<cmath>
#define ll long long
#define N 1000000007
using namespace std;
int main() {
	string s; cin >> s;
	string data[] = { "SAT","FRI","THU", "WED", "TUE", "MON","SUN" };
	for (int i = 0; i < 7; ++i) {
		if (s == data[i]) cout << i+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
A = []
for i in range(5):
    a = int(input())
    A.append(a)
k = int(input())

for n in range(5):
    for m in range(5):
        if n != m:
            if abs(A[n]-A[m])>k:
                print(':(')
                exit()
print('Yay!')

Measured memory_bytes: 3060
class Ford_Fulkerson:

	def __init__(self, v, inf=float("inf")):
		self.V = v
		self.inf = inf
		self.G = [[] for _ in range(v)]
		self.used = [False for _ in range(v)]

	def addEdge(self, fm, to, cap):
		'''
		to:行き先
		cap:容量
		rev:反対側の辺
		'''
		self.G[fm].append({'to':to, 'cap':cap, 'rev':len(self.G[to])})
		self.G[to].append({'to':fm, 'cap':0, 'rev':len(self.G[fm])-1})


	def dfs(self, v, t, f):
		if v == t: return f
		self.used[v] = True

		for i in range(len(self.G[v])):
			e = self.G[v][i]
			if self.used[e["to"]] != True and e['cap'] > 0:
				d = self.dfs(e['to'], t ,min(f, e['cap']))
				if d > 0:
					e['cap'] -= d
					self.G[e['to']][e['rev']]['cap'] += d
					return d
		return 0

	def max_flow(self,s,t):
		flow = 0
		while True:
			self.used = [False for i in range(self.V)]
			f = self.dfs(s,t,self.inf)
			if f == 0: return flow
			flow += f



from sys import stdin, setrecursionlimit
def IL():return list(map(int, stdin.readline().split()))
 
setrecursionlimit(1000000)

def main():
	N = int(input())
	a = IL()
	d = Ford_Fulkerson(N+2)
	res = 0
	for i in range(N):
	    d.addEdge(N,i, max(0, -a[i]))
	    d.addEdge(i,N+1, max(0,a[i]))
	    res+=max(0,a[i])
	    t = 2*i+2
	    while t<=N:
	        d.addEdge(i,t-1,float('inf'))
	        t+=i+1
	print(res-d.max_flow(N,N+1))
	
	
if __name__ == "__main__": main()

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define THINK_TWICE_CODE_ONCE cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n)+1) : 1)
#define mem(x, val)    memset(x, val, sizeof(x))

typedef long long ll;
typedef long double ld;
typedef double dd;
typedef string str;
typedef pair<int, int> pii;

int n;
vector<int> a, b, c;
ll dp[(int)1e5][4];
ll solve(int i, int last){
    if(i==n) return 0;

    ll &ret  = dp[i][last];
    if(~ret) return ret;

    if(last != 1)
        ret = max(ret, a[i] + solve(i+1, 1));

    if(last != 2)
        ret = max(ret, b[i] + solve(i+1, 2));

    if(last != 3)
        ret = max(ret, c[i] + solve(i+1, 3));

    return ret;
}
int main()
{
    THINK_TWICE_CODE_ONCE
    //freopen("test cases\\.txt", "r", stdin) ;
    int w;
    cin>>n;
    a.resize(n), b.resize(n), c.resize(n);
    for(int i =0; i<n; i++) cin>>a[i]>>b[i]>>c[i];
    ///F = w, S = value
    for(int i =0; i<1e5; i++)mem(dp[i], -1);
    cout<<solve(0, 0);
    return 0;
}







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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long double n, m, d;
    cin >> n >> m >> d;
    long double x = (m - 1) * (2 * d + (d == 0 ? 1 : 2) * (n - 2 * d)), ans = x / n / n;
    printf("%.10Lf\n", ans);

}


Measured memory_bytes: 256