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

using namespace std;

int main(){
    int n;
    cin >> n;
    int p[n];
    for(int i = 0; i < n; i++) cin >> p[i];
    int cnt = 0;
    for(int i = 0; i < n - 2; i++){
        int tmp[3] = {p[i], p[i+1], p[i+2]};
        sort(tmp, tmp+3);
        if(tmp[1] == p[i+1]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("Out.txt", "w", stdout);

	int n, k;
	cin >> n >> k;
	cout << n - k + 1 << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}
 


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

import sys
import random

def main():
    sys.setrecursionlimit(10 ** 6)
    n = int(input())
    ranks = [0 for i in range(n)]
    adjs = [[] for i in range(n)]
    edges = []
    for i in range(n - 1):
        a, b = map(int, input().split())
        edges.append((a - 1, b - 1))
        ranks[a - 1] += 1
        ranks[b - 1] += 1
        adjs[a - 1].append(b - 1)
        adjs[b - 1].append(a - 1)

    for i in range(n):
        random.shuffle(adjs[i])
    visited = [False for i in range(n)]
    colors = {}  # (mi, ma) |-> color
    dfs(0, adjs, visited, -1, colors)

    print(max(ranks))
    for i in range(n - 1):
        a, b = edges[i]
        mi = min(a, b)
        ma = max(a, b)
        print(colors[(mi, ma)])

def dfs(i, adjs, visited, color_used, colors):
    visited[i] = True
    c = 1
    for j in adjs[i]:
        if visited[j]:
            continue
        if c == color_used:
            c += 1
        mi = min(i, j)
        ma = max(i, j)
        colors[(mi, ma)] = c
        dfs(j, adjs, visited, c, colors)
        c += 1

if __name__ == "__main__":
    main()


Measured memory_bytes: 82948
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  var a = input[1].split(" ").map(i => parseInt(i));
  var bb = new Array(N).fill(0);
  var bsub = new Array();
  var num = 0;
  for(var i=N;i>0;i--){
    var cnt =0;
    for(var j=1;j*i<=N;j++){
      cnt+=bb[j*i-1];
    }
    if(cnt%2!=a[i-1]){
      num++;
      bsub.push(i);
      bb[i-1]++;
    }
  }
  var b = bsub.join(" ");
  var ans = num+"\n"+b;
  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29052
program remaining_balls
  implicit none
  character(10) :: s, t, u
  integer :: a, b
  read(*,*) s, t
  read(*,*) a, b
  read(*,*) u
  if (u == s) then
    write(*,'(i0,x,i0)') a-1, b
  else
    write(*,'(i0,x,i0)') a, b-1
  end if
end program remaining_balls

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

int main(){
    int n, a;
    int flag = 0;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a;
        if(a%2 == 0){
            if(a%3 != 0 && a%5 != 0){
                flag = 1;
            }
        }
    }
    if(flag == 0){
        cout << "APPROVED";
    }else{
        cout << "DENIED";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
using namespace std;
int main(){
  int d;
  cin >> d;
  if(d == 25) cout << "Christmas" << endl;
  else if(d == 24) cout << "Christmas Eve" << endl;
  else if(d == 23) cout << "Christmas Eve Eve" << endl;
  else cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <iterator>

using namespace std;

typedef long long ll;
#define mems(p) memset(p,0,sizeof(p))
#define mp make_pair

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int grid[2005][2005];
pair<int,int> gridVal[2005][2005];

int main(){
	int h,w;
	cin>>h>>w;
	string s;
	for (int i = 1; i <= h; ++i)
	{
		cin>>s;
		for (int j = 0; j < w; ++j)
		{
			if (s[j]=='.') grid[i][j+1]=1;
		}
	}
	/*for (int i = 1; i <=h; ++i)
	{
		for (int j = 1; j <=w; ++j)
		{
			cout<<grid[i][j];
		}
		cout<<endl;
	}*/
	int idx,ctr,start;
	for (int i = 1; i <= h; ++i)
	{
		idx=1;
		while (idx<=w){
			//cout<<start<<'\n';
			ctr=0;
			start=idx;
			while (grid[i][idx]) {
				++idx;
				++ctr;
			}
			for (int j = start; j < idx; ++j)
			{
				gridVal[i][j].first=ctr;
			}
			++idx;
		}
	}
	for (int i = 1; i <= w; ++i)
	{
		idx=1;
		while (idx<=h){
			ctr=0;
			start=idx;
			while (grid[idx][i]) {
				++idx;
				++ctr;
			}
			for (int j = start; j < idx; ++j)
			{
				gridVal[j][i].second=ctr;
			}
			++idx;
		}
	}
	int maxim=0;
	for (int i = 1; i <= h; ++i)
	{
		for (int j = 1; j <= w; ++j)
		{
			//cout<<i<<" "<<j<<" "<<gridVal[i][j].first<<" "<<gridVal[i][j].second<<'\n';
			maxim=max(maxim,gridVal[i][j].first+gridVal[i][j].second-1);
		}
	}
	cout<<maxim<<endl;
}

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

using namespace std;
typedef long long ll;

const int N=2e6+5,P=1e9+7;

inline int Inv(int a){
	int r=1,t=P-2;
	for(;t;t>>=1,a=(ll)a*a%P)if(t&1)r=(ll)r*a%P;
	return r;
}

int fac[N],ifac[N],x[6],y[6],m;
ll ans;

inline int cpv(int x,int y){return (ll)fac[x+y]*ifac[x]%P*ifac[y]%P;}
inline int F(int X,int Y){return (cpv(X-x[0]+1,Y-y[0]+1)-cpv(X-x[1],Y-y[0]+1)-cpv(X-x[0]+1,Y-y[1])+cpv(X-x[1],Y-y[1]))%P;}
inline int G(int X,int Y){return (cpv(x[5]+1-X,y[5]+1-Y)-cpv(x[4]-X,y[5]+1-Y)-cpv(x[5]+1-X,y[4]-Y)+cpv(x[4]-X,y[4]-Y))%P;}

int main(){
	for(int i=0;i<6;i++)cin>>x[i];
	for(int i=0;i<6;i++)cin>>y[i];
	m=x[5]-x[0]+y[5]-y[0]+4;
	fac[0]=1;
	for(int i=1;i<=m;i++)fac[i]=(ll)fac[i-1]*i%P;
	ifac[m]=Inv(fac[m]);
	for(int i=m;i>=1;i--)ifac[i-1]=(ll)ifac[i]*i%P;
	for(int i=x[2];i<=x[3];i++)ans=(ans+(ll)F(i,y[3])*G(i,y[3]+1)%P*(i+y[3]+1)-(ll)F(i,y[2]-1)*G(i,y[2])%P*(i+y[2]))%P;
	for(int i=y[2];i<=y[3];i++)ans=(ans+(ll)F(x[3],i)*G(x[3]+1,i)%P*(i+x[3]+1)-(ll)F(x[2]-1,i)*G(x[2],i)%P*(i+x[2]))%P;
	ans=(ans%P+P)%P;
	printf("%lld\n",ans);
	return 0;
}

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2097162
#define inf 1e9
#define MOD 1000000007

int main()
{


    ll n, mx=0, mx2=0, hm=0;
    vector<ll> v;
    cin >> n;
    for(ll i = 0; i < n; i++)
    {

        ll x;
        cin >> x;
        v.pb(x);
        if(x > mx)
        {

            mx2=mx;
            mx=x;
            hm=1;
        }
        else if(x == mx)
        {

            hm++;
        }
        else if(x > mx2 ) mx2=x;
    }
    for(ll i = 0; i < n; i++)
    {

        if(v[i] != mx) cout << mx << endl;
        else
        {

            if(hm > 1) cout << mx << endl;
            else cout << mx2 << endl;
        }
    }
}


Measured memory_bytes: 3312
// C++ includes
#include <bits/stdc++.h>
// 俳句
using namespace std;

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    ll k,n;
    cin >> k >> n;
    vll a(n);
    vll d(n);
    REP(i,n){
        cin >> a[i];
    }
    FOR(i,0,n-2){
        d[i] = a[i+1]-a[i];
    }
    d[n-1] = a[0] - a[n-1] + k;

    sort(d.begin(),d.end());
    cout << accumulate(d.begin(), d.end(), -d[n-1]) << endl;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;


int findSumOfDigits(int n){ //10進数での各桁の和を求める関数
    int num=0;
    while(n>0){
        num+=n%10;
        n/=10;
    }
    
    return num;

}

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

    int a,b;
    int sum_a, sum_b;

    int min=1e9;

    for(int i=1;i<n;i++){
        a = i;
        b = n - i;

        sum_a = findSumOfDigits(a);
        sum_b = findSumOfDigits(b);

        if(min > sum_a + sum_b) min = sum_a + sum_b;
    }

    cout << min << endl;
}

Measured memory_bytes: 256
A,B,M=list(map(int,input().split()))

a=list(map(int,input().split()))
b=list(map(int,input().split()))
       
x=[list(map(int,input().split())) for i in range(M)]

sum_origin=min(a)+min(b)

sum_=[]

for x_,y_,c_ in x:
  
  sum_disc=a[x_-1]+b[y_-1]-c_
  sum_.append(sum_disc)

if min(sum_)>sum_origin:
  print(sum_origin)

elif min(sum_)<sum_origin: 
  print(min(sum_))

elif min(sum_) == sum_origin:
  print(min(sum_))
	

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

int main(){

  int r, g, b;
  cin >> r >> g >> b;
  int num;
  num = 100 * r + g * 10 + b;
  if (num % 4 == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String answer = "NG";

        for(int i = a;i<=b;i++){
            if(i%k==0){
                answer = "OK";
                break;
            }
        }
        System.out.print(answer);
    }
}

Measured memory_bytes: 35772
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;


int main() {
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int x, a[200005], b = 1, n, m, res = 1, u[200000], v[200000], w[200000];

	string str, str2;
	cin >> n >> m;
	if (max(n, m) - min(n, m) >= 2) {
		cout << 0;
		return 0;
	}
	else {
		for (int i = 1; i <= n; i++) {
			res *= i;
			res %= 1000000007;
		}
		for (int i = 1; i <= m; i++) {
			res *= i;
			res %= 1000000007;
		}
		if (n == m) {
			res *= 2;
			res %= 1000000007;
		}
	}
	cout << res;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main (){
	char s[11],t[11],u[11];
	int a,b;
	scanf ("%s %s",&s,&t);
	scanf ("%d %d",&a,&b);
	scanf ("%s",&u);
	
	if (strcmp(s,u)==0){
		printf ("%d %d",a-1,b);
	}
	else if (strcmp(t,u)==0){
		printf ("%d %d",a,b-1);
	}
	return 0;
}

Measured memory_bytes: 2116
#include<stdio.h>
#define INF 1000000
int graph[101][101],n,c,d;

void warshall_floyd(){
  int i,j;
  for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
      graph[i][j]=graph[j][i]=min(graph[i][j],graph[i][c]+graph[c][d]+graph[d][j]);
}
int min(int x,int y){return x<y?x:y;}

int main(){
  int k,i,j,x,e,a,b;

  while(scanf("%d %d",&n,&k),n,k){
    for(i=1;i<=n;i++)
      for(j=1;j<=n;j++)
	graph[i][j]=i==j?0:INF;
    
    for(i=0;i<k;i++){
      if(scanf("%d",&x),x){
	scanf("%d %d %d",&c,&d,&e);

	if(graph[c][d]>e){
	graph[c][d]=graph[d][c]=e;
	warshall_floyd();
	}
      }else{
	scanf("%d %d",&a,&b);
	printf(graph[a][b]>=INF?"-1\n":"%d\n",graph[a][b]);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
// D - Lazy Faith
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define lower(v,x) lower_bound((v).begin(),(v).end(), (x))
#define INF (10000000000*2)

ll calc(vl &s, vl &t, ll x){//s,t -inf~+inf
	ll mini = INF;
	vl::iterator apos, bpos;

	apos = lower(s, x);
	for(int j=0; j<2; ++j){
		ll ax = *(apos - j);
		bpos = lower(t, ax);
		for(int k=0; k<2; ++k){
			ll bx = *(bpos - k);
			mini = min(mini, abs(x-ax) + abs(ax-bx));
		}
	}

	apos = lower(t, x);
	for(int j=0; j<2; ++j){
		ll ax = *(apos - j);
		bpos = lower(s, ax);
		for(int k=0; k<2; ++k){
			ll bx = *(bpos - k);
			mini = min(mini, abs(x-ax) + abs(ax-bx));
		}
	}

	return mini;
}

int main(){
	int A,B,Q; cin>>A>>B>>Q;

	vl S(A+2, INF), T(B+2, INF);
	for(int i=1; i<=A; ++i) cin>>S[i];S[0] = -INF;
	for(int i=1; i<=B; ++i) cin>>T[i];T[0] = -INF;

	for(int i=0; i<Q; ++i){
		ll x; cin>>x;
		cout<< calc(S, T, x) <<endl;
	}
}

Measured memory_bytes: 2944
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

X, Y = LI()
ans = True
if Y % 2 == 1:
    ans = False

if X * 2 <= Y <= X * 4:
    pass
else:
    ans = False

if ans:
    print("Yes")
else:
    print("No")

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nm = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nm[0];
        var m = nm[1];
        var seqA = new int[m];
        var seqC = new int[m];
        for (int i = 0; i < m; ++i)
        {
            var ab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            seqA[i] = ab[0];
            seqC[i] = Console.ReadLine().Split().Sum(x => 1 << int.Parse(x) - 1);
        }

        var full = (1 << n) - 1;
        if (full - seqC.Aggregate((x, y) => x | y) > 0)
        {
            Console.WriteLine(-1);
            return;
        }

        var dp = new int[full + 2];
        for (int i = 1; i < dp.Length; ++i)
        {
            dp[i] = int.MaxValue;
        }
        for (int i = 0; i < seqC.Length; ++i)
        {
            dp[seqC[i]] = Math.Min(dp[seqC[i]], seqA[i]);
            for (int j = 1; j <= seqC[i]; ++j)
            {
                int jj = seqC[i] & j;
                if (jj == 0)
                {
                    continue;
                }
                
                dp[jj] = Math.Min(dp[jj], seqA[i]);
            }
        }
        for (int i = 1; i < dp.Length; ++i)
        {
            for (int j = 1; j <= i; ++j)
            {
                int jj = i & j;
                int kk = i ^ jj;
                if (jj >= kk)
                {
                    break;
                }
                if (kk == i || dp[jj] == int.MaxValue || dp[kk] == int.MaxValue)
                {
                    continue;
                }

                dp[i] = Math.Min(dp[i], dp[jj] + dp[kk]);
            }
        }
        Console.WriteLine(dp[full]);
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
int main() {
    int a,add,sub,b;
    char p;
    scanf("%d",&a);
    scanf(" %c",&p);
    scanf("%d",&b);
    add=a+b;
    sub=a-b;
    if(p == '+'){
        printf("%d\n",add);
    }
    else {
        printf("%d\n",sub);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,k;
    cin>>k>>n;
    int a[n+1];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    int ans=0;
    ans = max(ans,k-a[n-1]+a[0]);
    for(int i=1; i<n; i++){
        ans = max(ans,a[i]-a[i-1]);
    }

    cout << k - ans << "\n";
    
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.util.Arrays;
import java.util.Set;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();
        int K=sc.nextInt();
        if(B-K+1<=A+K-1){
            for(int i=0;i<=B-A;i++){
                System.out.println(A+i);
            }
        }else{
            for(int i=0;i<K;i++){
                System.out.println(A+i);
            }
            for(int i=K-1;i>=0;i--){
                System.out.println(B-i);
            }
        }


}
        
        
    }


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int a[505][505];

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int H,W,h,w;
	cin>>H>>W>>h>>w;
	if (H%h==0 && W%w==0) {
		cout<<"No\n"<<endl;
		return 0;
	}
	
	cout<<"Yes\n";
	
	const int T=251;
	rep(i,0,H) rep(j,0,W) {
		if (H%h!=0) {
			if (i%h==0) a[i][j]=T*(h-1)-1; else a[i][j]=-T;
		} else {
			if (j%w==0) a[i][j]=T*(w-1)-1; else a[i][j]=-T;
		}
	}
	
	rep(i,0,H) rep(j,0,W) cout<<a[i][j]<<" \n"[j+1==W];
	
	ll sum=0;
	rep(i,0,H) rep(j,0,W) sum+=a[i][j];
	cerr<<sum<<endl;
	assert(sum>0);
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int  main(){
 int y;
cin >> y;
string s;
cin >> s;
int i;

for(int i=0;i<s.size();i++){
  if(s[i]+y>=91){
     s[i]=s[i]+y-26;
  }else{
     s[i]+=y;
  }
}
cout << s << endl;
return 0;
}

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

bool isPrime(int x){
    if (x == 2) return true;
    else if (x < 2 || x % 2 == 0) return false;
    else{
        int i = 3;
        double y = x * 1.0;
        while(i <= sqrt(y)){
            if (x % i == 0) return false;
            i = i + 2;
        }
    }
    return true;
}

int main(){
    int n;
    int cnt = 0;
    cin >> n;
    int A[10000];
    for (int i = 0; i < n; i++){
        cin >> A[i];
        if (isPrime(A[i])) cnt ++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
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;}
const ll INF = 1e18+1;


/*
A<=500 B<=500

Aが白,Bが黒
とりま100*100

最初全部白埋め

100 * 100 マスで、50*20だけモザイク埋めすると
最初どちらも500

白い領域内のポチポチと、黒い領域内のポチポチ

各50 * 100 領域に白と黒を取る

縦に24マス、横に49マスまで取れるので500は余裕

*/

char res[500][500];

int main() {
    int A, B; cin >> A >> B;
    for (int i = 0; i < 50; i++) {
        for (int j = 0; j < 100; j++) res[i][j] = '#';
    }
    for (int i = 50; i < 100; i++) {
        for (int j = 0; j < 100; j++) res[i][j] = '.';
    }
    A--;B--;

    for (int a = 0; a < A; a++) {
        res[2 * (a / 50)][2 * (a % 50)] = '.';
    }
    for (int b = 0; b < B; b++) {
        res[51 + 2 * (b / 50)][2 * (b % 50)] = '#';
    }
    cout << 100 << " " << 100 << endl;
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            cout << res[i][j];
        } cout << endl;
    }




}



Measured memory_bytes: 256
n, m = map(int, input().split())
A = []
for i in range(n):
    A.append(list(map(int, input().split())))

b = []
for i in range(m):
    b.append(int(input()))

for row in A:
    product = 0
    for e_A, e_b in zip(row, b):
        product += e_A * e_b
    print(product)



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

int main() {

  int N;
  cin >> N;
  
  int P = 0, W = 0, G = 0, Y = 0; 
  
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    
//    if (S == "P") 
//      P++;
//    else if (S == "W")
//      W++;
//    else if (S == "G")
//      G++;
//    else if (S == "Y")
    if ( S == "Y")
      Y++;
    
  }
  
  if (Y >= 1)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;

}



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

using namespace std;

using ll = long long int;



int main() {

	int a, b, c;
	cin >> a >> b >> c;

	if (c >= a && c <= b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int H1, M1; cin >> H1 >> M1;
  int H2, M2; cin >> H2 >> M2;
  int K; cin >> K;
  int a = (H2 * 60 + M2) - (H1 * 60 + M1);
  cout << a - K << endl;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cstdio>
const int MAXN = 1e6+5;
char S[MAXN];
int N;

int sgn(int x) { return (x > 0) - (x < 0); }

struct Data {
  int dep, lvl;
  
  bool operator < (const Data& o) const {
    int dl = sgn(lvl);
    int dr = sgn(o.lvl);
    // +1 -> 0 -> -1
    if (dl != dr) return (dl > dr);
    // (dl == dr)
    if (dl >= 0) return (dep < o.dep);
    // (dl == -1)
    return (dep + lvl) > (o.dep + o.lvl);
  }
};
Data A[MAXN];

bool solve() {
  int lvl = 0;
  for (int i = 0; i < N; ++i) {
    if (lvl < A[i].dep) return false;
    lvl += A[i].lvl;
    if (lvl < 0) return false;
  }
  return (lvl == 0);
}

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf(" %s", S);
    int dep = 0;
    int lvl = 0;
    for (char *ptr = S; *ptr; ++ptr) {
      if (*ptr == '(') {
        ++lvl;
      } else {
        --lvl;
      }
      dep = std::min(lvl, dep);
    }
    A[i].dep = -dep;
    A[i].lvl = lvl;
  }
  std::sort(A, A+N);
  puts(solve() ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 10756
/*Program from Luvwgyx*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define int long long
#define write(x) printf("%lld\n",x)
using namespace std;
const int maxn=2e5+10;
int tot,head[maxn],f[maxn];
struct node{int to,nxt;}e[maxn<<1];
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void add(int u,int v){e[++tot].to=v;e[tot].nxt=head[u];head[u]=tot;}
void insert(int u,int v){add(u,v);add(v,u);}
void dfs(int x,int fa){
    for(int i=head[x],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
        if(v!=fa)f[v]+=f[x],dfs(v,x);
}
signed main(){
    int n=read(),Q=read();
    for(int i=1;i<n;i++)insert(read(),read());
    while(Q--){int x=read(),y=read();f[x]+=y;}dfs(1,0);
    for(int i=1;i<=n;i++)printf("%lld ",f[i]);puts("");
    return 0;
}


Measured memory_bytes: 18048
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; i--)
#define REP(i, k, n) for(int i=(int)(k); i<(int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const int INF = INT_MAX;
const ll inf = 1e18;
const ll mod = 998244353;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x, ll y){ if(x>y) swap(x, y);while(x!=0){ y%=x; swap(x, y); }return y; }
ll mpow(ll x, ll r){if(r==0) return 1;if(r%2==1){ return x*mpow(x, r-1)%mod; }else{ ll aa = mpow(x, r/2); return aa*aa%mod; }}

ll ans = 0;
int A[10];
int N, M, Q;
int a[50], b[50], c[50], d[50];

void dfs(int now){
	if(now == N){
		ll cnt = 0;
		rep(i, Q){
			if(A[b[i]-1] - A[a[i]-1] == c[i]) cnt += d[i];
		}
		chmax(ans, cnt);
		return;
	}else if(now == 0){
		for(int i=1; i<=M; i++){
			A[now] = i;
			dfs(now+1);
		}
	}else{
		for(int i=A[now-1]; i<=M; i++){
			A[now] = i;
			dfs(now+1);
		}
	}
}

int main(){
	cin >> N >> M >> Q;
	rep(i, Q) cin >> a[i] >> b[i] >> c[i] >> d[i];
	dfs(0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int N,A,B;
vector<long long> h(100009);
long long lb=-1,ub=20000000000;

bool C(long long x){
  long long cnt=0;
  for(int i=0;i<N;i++){
    if(h[i]-x*B>0){
      long long a=h[i]-x*B;
      cnt+=(a+A-B-1)/(A-B);
    }
  }
  return cnt<=x;
}

int main(){
  cin >> N >> A >> B;
  for(int i=0;i<N;i++)cin >> h[i];
  while(ub-lb>1){
    long long mid=(ub+lb)/2;
    if(C(mid))ub=mid;
    else lb=mid;
  }
  cout << ub << endl;
}

Measured memory_bytes: 1024
let () =
	Scanf.scanf "%d\n" @@ fun n ->
 let arr = Array.init n @@ fun i -> Scanf.scanf "%d\n" @@ fun d -> (i, d) in
 let (ans, _) = Array.fold_left
     (fun (ans, minN) (i, x) ->
        if i <> 0 && x < minN then (ans, x)
        else if i <> 0 && x-minN > ans then (x-minN, minN)
        else (ans, minN)) (snd arr.(1) - snd arr.(0), snd arr.(0)) arr in
  Printf.printf "%d\n" ans


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

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

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

int main(){
  int N; cin >>N;
  vector<long> v(N);
  
  for(int i = 0; i < N; i++){
    cin >> v.at(i);
  }
  
  long ans = 0;
  for(int i = 0; i < N; i++){
    ans += v.at(i) -1 ;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/*
 *  author : Atul Anand   
 *  created on : Thu Apr 02 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();
        int K = in.nextInt();
        char c[] = in.next().toCharArray();
        c[K-1] = Character.toLowerCase(c[K-1]);
        println(String.valueOf(c));
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n;
ll b[101];
ll a[101];

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

  cin>>n;
  rep(i,n-1)cin>>b[i];

  a[0]=b[0];
  a[n-1]=b[n-2];
  repl(i,1,n-1){
    a[i]=min(b[i],b[i-1]);
  }
  ll res=0;
  rep(i,n)res+=a[i];
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
import math        
    
N,A,B=list(map(int,input().split()))
arr=[]

for i in range(N):
    arr.append(int(input()))

max_=max(arr)//B+1
min_=min(arr)//A

d=A-B

while min_!=max_:
    mid=(max_+min_)//2
    
    sum_=0
    for x in arr:
        y=(x-mid*B)
        if y<=0:
            continue
        sum_+=math.ceil(y/d)
        
    if sum_<=mid:
        max_=mid
    else:
        min_=mid+1

print(min_)

Measured memory_bytes: 7068
N,X = (int(i) for i in input().split())
x = [int(i) for i in input().split()]


def euclid(a,b):
    big = max(a,b)
    small = min(a,b)
    
    r = big % small
    while(r != 0):
        big = small
        small = r
        r = big % small

    return small

#first
haba = x[0] - X

for i in range(1,N):
    haba = euclid(haba,x[i]-X)
    if haba == 1:
        break

print(abs(haba))

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

int main()
{
    int a;

    cin>>a;

    if(a==22)cout<<"Christmas Eve Eve Eve"<<endl;
    else if(a==23)cout<<"Christmas Eve Eve"<<endl;
    else if(a==24)cout<<"Christmas Eve"<<endl;
    else if(a==25)cout<<"Christmas"<<endl;



    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

  int A,B,C,X;
  cin>>A>>B>>C>>X;
  int count=0;
  for(int x=0;x<=A;x++){
    
    for(int y=0;y<=B;y++){
    
      if((X-(500*x)-(100*y))>=0&&(X-(500*x)-(100*y))%50==0){
      
        if((X-(500*x)-(100*y))/50<=C){
          count++;
        }
      }
    }
  }
  cout<<count;
}

Measured memory_bytes: 3616
#include <iostream>

using namespace std;

char c[14][14];

void clearing(int x, int y){ 
        int dx[] = {1,0,-1,0};
        int dy[] = {0,1,0,-1};
        c[x][y] = 0;
        for(int i = 0; i < 4; i++){
                if(c[x+dx[i]][y+dy[i]]) clearing(x+dx[i],y+dy[i]);
        }   
}

int main(){
        //for(int i = 0; i < 14; i++)for(int j = 0; j < 14; j++)c[i][j] = 0;
        while(cin >> c[1][1]){
                c[1][1] -= '0';
                for(int i = 1; i < 13; i++){
                        for(int j = 1; j < 13; j++){
                                if(i-1 || j-1){
                                        cin >> c[i][j];
                                        c[i][j] -= '0';
                                }   
                        }   
                }   
                int s = 0;
                for(int i = 1; i < 13; i++){
                        for(int j = 1; j < 13; j++){
                                if(c[i][j]){
                                        s++;
                                        clearing(i,j);
                                }   
                        }   
                }   
                cout << s << endl;
        }   
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		byte[] asciiCodes;
		try {
            asciiCodes = n.getBytes("US-ASCII");
        } catch (Exception e) {
            e.printStackTrace();
            return;
        }
		
		asciiCodes[0]+=1;
		String resultString;
		try {
            resultString = new String(asciiCodes, "US-ASCII");
        } catch (Exception e) {
            e.printStackTrace();
            return;
        }
		System.out.println(resultString);
		
		
	}
}


Measured memory_bytes: 21076
N=input()
n=len(N)
number=int(N[n-1])
if number == 2or number== 4 or number==5 or number==7or  number==9:
    print('hon')
elif number==0 or number==1 or number==6 or number==8:
        print('pon')
else:
    print('bon')


Measured memory_bytes: 9052
#include <iostream>
using namespace std;
string evaluation(int m, int f, int r) {
    // 中間試験、期末試験のいずれかを欠席した場合成績は F。
    if (m == -1 || f == -1) return "F";
    // 中間試験と期末試験の合計点数が 80 以上ならば成績は A 。
    if (m + f >= 80) return "A";
    // 中間試験と期末試験の合計点数が 65 以上 80 未満ならば成績は B。
    if (m + f >= 65) return "B";
    // 中間試験と期末試験の合計点数が 50 以上 65 未満ならば成績は C。
    if (m + f >= 50) return "C";
    //中間試験と期末試験の合計点数が 30 以上 50 未満ならば成績は D。 ただし、再試験の点数が 50 以上ならば成績は C。
    if (m + f >= 30) {
        if (r >= 50) return "C";
        return "D";
    }
    // 中間試験と期末試験の合計点数が 30 未満ならば成績は F。
    return "F";
}
int main() {
    int m, f, r;
    while(1) {
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) break;
        cout << evaluation(m, f, r) << endl;
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    string s, res;
    cin >> s;
    rep(i, s.size())
    {
        if (s.at(i) == '0')
            res.push_back('0');
        else if (s.at(i) == '1')
            res.push_back('1');
        else if (res.size() > 0)
            res.pop_back();
    }
    cout << res << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
using namespace std;

#define ll long long
#define vvi vector<vector<int>>
#define All(X) X.begin(),X.end()

int main(){
	int n;
	cin >> n;
	 int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;

}

Measured memory_bytes: 1164
import sys
#limit=sys.getrecursionlimit()
sys.setrecursionlimit(10000000)
#sys.setrecursionlimit(1000000000)

V=int(input().strip())
E=V-1
inf=3*10**15
G=[]
dist=[inf]*V

for i in range(V):
    G.append([])
for i in range(E):
    at,bt,ct=map(int,input().strip().split(' '))
    G[at-1].append([ct,bt-1])
    G[bt-1].append([ct,at-1])

visited=[False]*V
def dfs(v,p,d):
    #global d
    dist[v]=d
    for q in G[v]:
        if q[1]==p:
            continue
        dfs(q[1],v,d+q[0])

Q, K=map(int,input().strip().split(' '))
K-=1 #0-indexedに直す

dfs(K,-1,0)

x=[]
y=[]

for i in range(Q):
    xt, yt=map(int,input().strip().split(' '))
    x.append(xt-1)#0-indexedに直して入れる
    y.append(yt-1)#0-indexedに直して入れる
for i in range(Q):
    print(dist[x[i]]+dist[y[i]])





Measured memory_bytes: 140456
//2017-8-22
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define Forr(i, a, b) for(int i = (a); i >= (int)(b); --i)

#define V (4000+5)
#define N (200000+5)

const int A = 2001;
const LL P = 1e9+7;

LL Pow(LL a, LL anum){
	LL ret = 1ll;
	while(anum){
		if(anum&1) ret = (ret*a) % P;
		a = (a*a) % P; anum >>= 1;
	}
	return ret;
}

int a[N], b[N];
LL rfac[V<<1], fac[V<<1], f[V][V];

void Init(int n){
	fac[0] = rfac[0] = fac[1] = 1;
	For(i, 2, n) fac[i] = fac[i-1]*i%P;
	
	rfac[n] = Pow(fac[n], P-2);
	Forr(i, n-1, 1) rfac[i] = rfac[i+1]*(i+1)%P;
}

int main(){
	Init(8004);

	int n;
	scanf("%d", &n);
	For(i, 1, n){
		scanf("%d%d", &a[i], &b[i]);
		++f[A-a[i]][A-b[i]];
	}

	int Mx = 4002;
	For(i, 1, Mx) For(j, 1, Mx){
		f[i][j] += (f[i-1][j]+f[i][j-1])%P;
		f[i][j] %= P;
	}

	LL ans = 0;
	For(i, 1, n) ans += f[a[i]+A][b[i]+A], ans %= P;

	For(i, 1, n){
		ans -= fac[2*a[i]+2*b[i]] * rfac[2*a[i]] % P * rfac[2*b[i]] % P;
		ans = (ans%P+P)%P;
	}

	printf("%lld\n", ans * Pow(2, P-2) % P);

	return 0;
}

Measured memory_bytes: 127232
#include <stdio.h>

int main() {
	int a, b, c, k, zan, ret = 0;

  	scanf("%d %d %d %d", &a, &b, &c, &k);
  	if (a + b + c > k ) {
	  zan = k;
    } else {
      zan = a + b + c;
    }
	if (a < k) {
		ret = a;
    } else {
      	ret = k;
    }
  	zan -= a;
  
  	if (zan > b) {
      zan -= b;
      if (zan > 0) {
        ret -= zan;
      }
    }
  
  	printf("%d\n", ret);
  	return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r , int c){
  stack<int> S;
  S.push(r);
  color[r] = c;
  while(!S.empty()){
    int u = S.top(); S.pop();
    for( int i = 0 ; i < G[u].size() ; i++){
      int v = G[u][i];
      if(color[v] == NIL){
        color[v] = c;
        S.push(v);
      }
    }
  }
}

void assignColor(){
  int id = 1;
  for(int i = 0 ; i < n ; i++) color[i] = NIL;
  for(int u = 0 ; u < n ; u++){
    if (color[u] == NIL) dfs(u , id++);
  }
}

int main(){
  int s , t , m , q;
  cin >> n >> m;
  for(int i = 0 ; i < m ; i++){
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }

  assignColor();

  cin >> q;
  for(int i = 0 ; i < q; i++){
    cin >> s >> t;
    if(color[s] == color[t]){
      cout << "yes" << "\n";
    }else{
      cout << "no" << "\n";
    }
  }

  return 0;
}



Measured memory_bytes: 8872
#include <stdio.h>
#include <stdlib.h>
#include <utility>
#include <vector>

#define MAX_N (200000)

using namespace std;

template <typename T>
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template <typename T>
using Edges = vector<edge<T> >;
template <typename T>
using WeightedGraph = vector<Edges<T> >;
using UnWeightedGraph = vector<vector<int> >;
template <typename T>
using Matrix = vector<vector<T> >;

template <typename T>
pair<T, int> dfs(const WeightedGraph<T> &g, int idx, int par) {
  pair<T, int> ret(0, idx);
  for (auto &e : g[idx]) {
    if (e.to == par) continue;
    auto cost = dfs(g, e.to, idx);
    cost.first += e.cost;
    ret = max(ret, cost);
  }
  return ret;
}

template <typename T>
T tree_diameter(const WeightedGraph<T> &g) {
  auto p = dfs(g, 0, -1);
  auto q = dfs(g, p.second, -1);
  return (q.first);
}

int main(int argc, char *argv[]) {
  // read inputs
  int N, as[MAX_N - 1], bs[MAX_N - 1];
  scanf("%d", &N);
  for (int i = 0; i < N - 1; i++) {
    scanf("%d %d", &as[i], &bs[i]);
    as[i]--;  // NOTE : modified input
    bs[i]--;  // NOTE : modified input
  }

  // create graph
  WeightedGraph<int> g(N);
  for (int i = 0; i < N - 1; i++) {
    const int a = as[i], b = bs[i];
    g[a].emplace_back(b, 1);
    g[b].emplace_back(a, 1);
  }

  // calculate diameter of tree
  const int diameter = tree_diameter(g);
  // printf("diameter = %d\n", diameter);

  // calculate dp
  vector<int> dps(N, 0);  // first player wins?
  dps[0] = 1;
  dps[1] = 0;
  for (int i = 2; i <= N - 1; i++) {
    if (!dps[i - 1] || !dps[i - 2]) {
      dps[i] = 1;
    } else {
      dps[i] = 0;
    }
  }

  // print answer
  if (dps[diameter]) {
    printf("First\n");
  } else {
    printf("Second\n");
  }

  return 0;
}


Measured memory_bytes: 29184
#include<stdio.h>
#include<string.h>
#include<iostream>
#include <fstream>
using namespace std;

#define M (4700000+1)	/* your task*/
#define NIL (-1)
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M/* your task */; }
int h2(int key){ return key % 13 + 1/* your task */; }

int find(char str[]){
    /* your task */
	long long k = ::getKey(str);
	int _h1 = h1((int)k*17);
	int _h2 = h2((int)k);
	for(int i=0,j=_h1;i<M;++i,j=(j+_h2) % M){
		if (::H[j][0]=='\0')
			return	0;
		if (strcmp(::H[j],str)==0) {
			return	1;
		}
	}
	return	0;
}

int insert(char str[]){

    /* your task */
	long long k = ::getKey(str);
	int _h1 = h1((int)k*17);
	int _h2 = h2((int)k);
	for(int i=0,j=_h1;i<M;++i,j=(j+_h2) % M){
		if (::H[j][0]=='\0'){
			::strcpy(H[j],str);
			return	j;
		}
		if (strcmp(::H[j],str)==0) {
			return	j;
		}
	}
	return	0;

}

int main(){
    int i, n;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
/*
/*/
	std::istream & c_in = cin;
//*/

	//scanf("%d", &n);
   c_in >> n;

    for ( i = 0; i < n; i++ ){
	//	scanf("%s %s", com, str);
		c_in >> com >> str;

		
		if ( com[0] == 'i' ){
			insert(str);
		} else {
			if (find(str)){
			printf("yes\n");
			} else {
			printf("no\n");
			}
		}
    }

    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int k=s.size();
  int count=0;
  for(int i=1;i<k;i++){
    if(s.at(i)=='9'){
      count++;
    }
  }
  if(count==k-1){
    int f=s.at(0)-'0';
    cout << 9*(k-1)+f << endl;
  }
  else{
    int f=s.at(0)-'0';
    cout << f+9*k-10 << endl;
  }
}

Measured memory_bytes: 256
n,r,i;main() {
scanf("%d",&n);r=n;
for(i=2;i*i<=n;i++) {
if(n%i==0)r=1LL*r*(i-1)/i;
while(n%i==0)n/=i;}
if(n!=1)r=1LL*r*(n-1)/n;
n=!printf("%d\n",r);
}

Measured memory_bytes: 592
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

const int MAXN = 1010;
const int MAXP = 10000000;
const u64 MOD = 1000000007;
const f80 MI = f80(1)/MOD;
const ll INF = 10000000000000000LL;
const ll inf = 5000000000000LL;

int n, m;
int a[MAXN], b[MAXN];

int main()
{
	
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++ i)
		scanf("%d", &a[i]);
	for (int i = 1; i <= m; ++ i)
		scanf("%d", &b[i]);
	sort(a+1, a+n+1, greater<int>());
	sort(b+1, b+m+1, greater<int>());
	
	ll ans = 1;
	for (int i = 1; i < n; ++ i)
		if (a[i] == a[i+1]) ans = 0;
	for (int i = 1; i < m; ++ i)
		if (b[i] == b[i+1]) ans = 0;
	
	int i = 0, j = 0, use = 0;
	for (int k = n*m; k >= 1; -- k)
	{
		if (a[i+1] == k && b[j+1] == k)
		{
			i ++;
			j ++;
			ans = ans;
			use ++;
		}
		else if (a[i+1] == k)
		{
			i ++;
			ans *= j; ans %= MOD;
			use ++;
		}
		else if (b[j+1] == k)
		{
			j ++;
			ans *= i; ans %= MOD;
			use ++;
		}
		else
		{
			if (i*j-use > 0)
			{
				ans *= i*j-use;
				ans %= MOD;
			}
			else
				ans = 0;
			use ++;
		}
	}
	cout << ans << endl;
	
	return 0;
}


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

using namespace std;
int h[100009];int dp[100009];
int main()
{
int n ; 
cin>>n ; 
for(int i = 0 ;i<n ; i++)
scanf("%i",&h[i]);

dp[0]= 0 ; 
dp[1]= abs(h[0]-h[1]);

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


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

int main(){
  int n;
  cin >>n;
  vector<string> str(n);
  rep(i,n) cin >>str[i];
  sort(str.begin(), str.end());
  int cnt = 1;
  for(int i = 1; i<n; i++){
    if(str[i-1]!=str[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 9576
#include "bits/stdc++.h"
using namespace std;

#define OUT(x)  cerr << #x << " = " << x << endl;
#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define piii    pair<int, pair<int, int>>

int main() {
        long long n, a, b, c, d;
        cin >> n >> a >> b >> c >> d;
        bool ans = false;
        for (int i = 0; i < n - 1; i ++) {
                if (a + i * c - (n - 1 - i) * d <= b && b <= a + i * d - (n - 1 - i) * c) ans = true;
        }
        cout << (ans ? "YES" : "NO") << endl;
        return 0;
}



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

typedef unsigned long long int lli;

int main()
{
    int n;

    for(int i = 0; i < 5; i++)
    {
        cin >> n;

        if(n == 0)
        {
            cout << i + 1 << endl;
        }
    }
}



Measured memory_bytes: 3592