akhauriyash/Code-Regression huggingface dataset:
#include<map>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
map<LL, LL> mp;
int A[200011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);

    LL cur = 0;
    LL ans = 0;
    mp[0] = 1;
    REP (i, N) {
	cur += A[i];
	auto it = mp.find(cur);
	if (it != mp.end()) {
	    ans += it->second;
	    it->second++;
	} else {
	    mp.insert(it, make_pair(cur, 1LL));
	}
    }
    printf("%lld\n", ans);
}


int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 13568
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    string str = s1.substr(0, 1) + s2.substr(0, 1) + s3.substr(0, 1);
	transform(str.begin(), str.end(), str.begin(), ::toupper);

    cout << str << endl;
    return 0;
}

Measured memory_bytes: 256
/*💚💚💚 ITS A SLOW PROCESS BUT QUITING WONT SPEED IT UP 💚💚💚*/

#include<bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <complex>
#include <cctype>
using namespace std;

/*-------------define----------------------------*/
#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ceilval(a,b)    (a+b-1)/ b
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define cf(x)            ll x; cin>>x; while(x--)

/*---------------bak****i end-----------------------*/


void zaroorat()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}


int main()

  {
    zaroorat()  ;

    int n;
    cin>>n;
    int a[n];
    int b[n];
    bool flag=0;
    int cnt=0;
    for(int i=0;i<n;i++){
      cin>>a[i]>>b[i];
      if(a[i]==b[i]){
        cnt++;
      }else{
        cnt=0;
      }
      if(cnt==3){
        flag=1;
        break;
      }
    }
    if(flag){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }



      return 0;
}


Measured memory_bytes: 3636
#include<iostream>

int main()
{
    int H,W;
    
    while(1){    
        
        std::cin>>H>>W;
        
        if(H==0 && W==0){
            break;
        }else{
            for (int i=1; i<=H;i++){
                for (int j=1; j<=W;j++){
                    int test=(i+j)%2;
                    
                    if(test==0){
                        std::cout<<'#';
                    }else{
                        std::cout<<'.';
                        
                    }
                }
            std::cout<<std::endl;
            }
        }
        std::cout<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 3096
N = int(input())
edge = [set() for i in range(N)]
for i in range(N-1): #辺の情報と距離を記録
  u, v, w = map(int, input().split())
  edge[u-1].add((v-1, w))
  edge[v-1].add((u-1, w))

#幅優先検索
dist = [0] * N #距離
stack = [(0,-1)] #vrt, from
while stack: #stackが空になるまで
  vrt, _from = stack.pop()
  for _to, w in edge[vrt].copy():
    if _to == _from:
      continue
    stack.append((_to, vrt))
    dist[_to] = dist[vrt] + w
    
for i in range(N):
  print(dist[i]%2)


Measured memory_bytes: 54308
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
#define non __builtin_popcount
#define ml map<ll, ll> 
#define ms map<string , ll> 
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	
	ll a1, a2, a, b;
	cin>>a>>b;
	
	if((a+b)&1)
	cout<<"IMPOSSIBLE";
	
	else
	cout<<(a+b)/2;
	
    return 0;
}























Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int a[200010];
int main(){
	long long mx=0;
	long long ans=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	mx=a[0];
	for(int i=1;i<n;i++){
		if(a[i]<mx){
			ans+=mx-a[i];
			a[i]=mx;
		}
		if(a[i]>mx){
			mx=a[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4392
#include <iostream>
using namespace std;
int main(){
  double m,M,yama;
  M = 0;m = 10000000;
  while( cin >> yama){
  if(M < yama)M = yama;
  if(m > yama)m = yama;
  }
  cout << M-m << endl;
  return 0;
}

Measured memory_bytes: 1284
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());
    long memo = 1;//要素数
    long sumMemo = 0;
    bool answer = false;
    long answerMemo = 1;

    while(sumMemo <= n)
    {
      sumMemo += memo;
      if(sumMemo == n)
      {
        answer = true;
        break;
      }
      memo++;
    }

if(answer)
    {
      Console.WriteLine("Yes");
      Console.WriteLine(memo+1);
      long[,] answers = new long[memo+1, memo];

      for(long i = 0; i < memo; i++)
      {
        for(long j = 0; j < memo-i; j++)
        {
          answers[i,i+j] = answerMemo;
          answers[i+j+1,i] = answerMemo;
          answerMemo++;
        }
      }

      for(long i = 0; i < memo+1; i++)
      {
        string ans = memo.ToString();
        for(long j = 0; j < memo; j++)
        {
          ans += " " + answers[i,j].ToString();
        }
        Console.WriteLine(ans);
      }
      
    }
    else Console.WriteLine("No");

    /*
    if(n == 1)
    {
      Console.WriteLine("Yes");
      Console.WriteLine("2");
      Console.WriteLine("1");
      Console.WriteLine("1");
    }
    else if(n == 3)
    {
      Console.WriteLine("Yes");
      Console.WriteLine("3");
      Console.WriteLine("2 1 2");
      Console.WriteLine("2 3 1");
      Console.WriteLine("2 2 3");
    }else Console.WriteLine("No");
    */
    
	}
}


Measured memory_bytes: 16524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<ll> PQ;
#define MAXN 100005

ll N;

int main()
{
    cin >> N;
    if(N < 1000)printf("ABC\n");
    else printf("ABD\n");

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int N;
set<int> st;

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        st.insert(a);
    }
    if (st.size() == N) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 9600
n=int(input())
a=[int(input()) for i in range(n)]
count=0
def isprime(x):
    A=0
    for i in range(2,int(x**(0.5))+1):
        if x%i==0:
            A=1
            break
    if A==0:
        return True
    else:
        return False
for i in a:
    if isprime(i)==True:
        count+=1
print(count)


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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += a[i];
  }
  int avg = round(float(sum) / N);
  
  int cost = 0;
  for (int i = 0; i < N; i++) {
    cost += pow(a[i] - avg, 2);
  }
  
  cout << cost << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string.h>

using namespace std;

#define _ABS(X) (((X) < 0) ? -(X) : (X))

int input[100005];

int main()
{
	int N;
	bool can = true;

	scanf("%d", &N);

	for (int i = 1; i <= N; ++i)
	{
		scanf("%d", &input[i]);
		if (input[i] > input[i - 1]) input[i]--;
		if (input[i] < input[i - 1])
		{
			can = false;
		}
	}

	if (can) printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
const int MAX=1e6+10;
const int modn=1e9+7;
typedef long long ll ;
#define endl '\n'
#define cwk     freopen("D:\\workplace\\CLion\\in.in","r",stdin),freopen("D:\\workplace\\CLion\\out.out","w",stdout)
using namespace std;
ll fastpow(ll a,ll n){
    ll res=1;
    while(n){
        if(n&1){
            res=(res*a)%modn;
        }
        a=(a*a)%modn;
        n>>=1;
    }
    return res;
}
int n,m;
ll a[MAX],b[10];
void slove(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int h=j+1;h<n;h++){
                b[0]=a[i];
                b[1]=a[j];
                b[2]=a[h];
                sort(b,b+3);
                if(b[0]+b[1]>b[2]) {
                    if(b[0]!=b[1]&&b[1]!=b[2])
                    ans++;
                }
            }
        }
    }
    cout<<ans;
}
int main() {
    //ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    //cwk;
    int _=1;
    //cin>>_;
    while(_--){
        slove();
    }
    return 0;
}

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

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

    for (int i = 0; i < n.length()-1; i++) {
        if (n[i] == n[i+1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}

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

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> X(N),Y;
  for(int i=0;i<N;i++)
    cin>>X[i];
  sort(X.begin(),X.end());
  int cnt=1;
  for(int i=1;i<N;i++){
    if(X[i]!=X[i-1]){
      Y.push_back(cnt);
      cnt=1;
    }else cnt++;
  }
  Y.push_back(cnt);
  sort(Y.begin(),Y.end());
  int ys=Y.size(),ans=0;
  for(int i=0;i<ys-K;i++){
    ans+=Y[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define repl(i, a, b) for (ll i = a; i < (b); ++i)
#define repd(i, a, b) for (int i = b; i >= (a); --i)
#define repdl(i, a, b) for (ll i = b; i >= (a); --i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const ll MOD = 1'000'000'007LL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
ll fac[10005], invfac[10005];
ll ncr(ll n, ll r) {
  return fac[n] * invfac[n - r] % MOD * invfac[r] % MOD;
}
int main() {
  IOS;
  int s; cin >> s;
  if(s < 3) {
    cout << 0 << endl;
    return 0;
  }
  fac[0] = 1;
  invfac[0] = bpow(fac[0], MOD - 2);
  for(int i = 1; i <= 10000; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    invfac[i] = bpow(fac[i], MOD - 2);
  }
  ll ans = 0;
  for (int i = 1; i <= s / 3 + (s % 3 != 0); i++) {
    ll tmp = s - i * 3;
    if (tmp < 0) break;
    ans = (ans + ncr(i + tmp - 1, i - 1)) % MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3800
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std ;
#define N 110
int main()
{
    int t,a,b,c;
    int i=0,j=0,k=0;
    char x[3][N];
    char e;
    for(t=0;t<3;t++)
    {
        scanf("%s",x[t]);
        getchar();
    }
    a=strlen(x[0]);
    b=strlen(x[1]);
    c=strlen(x[2]);
    e=x[0][0];
    a=a-1;
    i++;
    while(a!=-1&&b!=-1&&c!=-1)
    {
        if(e=='a')
        {
            a--;
            e=x[0][i];
            i++;
        }
         if(e=='b')
        {
            b--;
            e=x[1][j];
            j++;
        }
         if(e=='c')
        {
            c--;
            e=x[2][k];
            k++;
        }
    }
    if(a==-1) printf("A");
    else if(b==-1) printf("B");
    else printf("C");
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
using Edge = pair<ll,ll>; //　1つ目は結んでいるノード、2つ目はその辺の重みを指す
using Graph = vector<vector<Edge> >;
const ll INF=99999999999999;
const ll MOD=1000000007;

Graph G;
vector<ll> color;

void dfs(ll v, ll p, ll c) {
  color[v] = c;
  for (auto e : G[v]) {
    if (e.first == p) continue; 
    dfs(e.first, v, c+e.second);
  }
}
 
int main() {
  ll n;
  cin >> n;
  G.assign(n,vector<Edge>());
  color.assign(n,0);
  rep(i,n-1){
    ll u,v,w;
    cin >> u >> v >> w;
    u--;
    v--;
    G[u].push_back(make_pair(v,w));
    G[v].push_back(make_pair(u,w));
  }
  dfs(0,-1,0);
  rep(i,n){
    cout << (color[i]%2) << endl;
  }
  
 return 0;
}

Measured memory_bytes: 9984
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	k := scanInt()
	as := scanInts(n)

	sum := 0
	for i := 0; i < n; i++ {
		sum += as[i]
	}

	div := []int{}
	for i := 1; i*i <= sum; i++ {
		if sum%i == 0 {
			div = append(div, i, sum/i)
		}
	}

	ans := 0
	for _, e := range div {
		sumsum := 0
		m := make([]int, n)
		for i := 0; i < n; i++ {
			m[i] = as[i] % e
			sumsum += m[i]
		}
		sort.Ints(m)
		num := sumsum/e
		c := 0
		for i := 0; i < n-num; i++ {
			c += m[i]
		}

		if c <= k {
			ans = max(ans,e)
		}
		debug(e,num,c,m)
	}

	fmt.Fprintln(wr, ans)
	// debug(div)
}


Measured memory_bytes: 5504
// A - Harmony
#include <stdio.h>

int main(void){
    int a, b, ans;
    scanf("%d%d", &a, &b);
    if((ans=a+b)%2 == 0){
        printf("%d\n", ans/2);
        return 0;
    }
    printf("IMPOSSIBLE\n");
    return 0;
}

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

using namespace std;

using ll = long long;

vector< vector<int> > g;

void dfs(int cur, int par, vector<int>& d) {
    for (int nex : g[cur]) {
        if (nex == par) continue;
        d[nex] = d[cur] + 1;
        dfs(nex, cur, d);
    }
}

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

    if (n == 1) {
        cout << "First" << endl;
        return 0;
    }
    
    g.resize(n);
    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<int> d1(n, 0);
    dfs(0, -1, d1);

    int node1 = 0;
    for (int i = 0; i < n; i++) {
        if (d1[node1] < d1[i]) {
            node1 = i;
        }
    }

    vector<int> d2(n, 0);
    dfs(node1, -1, d2);

    int node2 = 0;
    for (int i = 0; i < n; i++) {
        if (d2[node2] < d2[i]) {
            node2 = i;
        }
    }

    cout << (d2[node2] % 3 == 1 ? "Second" : "First") << endl;

    /*
    vector<int> d3(n, 0);
    dfs(node2, -1, d3);

    vector<int> dd(n, 0);
    for (int i = 0; i < n; i++) {
        dd[i] = min(d2[i], d3[i]);
    }*/

    return 0;
}

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

int main()
{
  int n,m,x;
  cin>>n>>m>>x;
  int a[n][m],c[n],d[m];
  for(int i=0;i<n;i++)
  {
    cin>>c[i];
    for(int j=0;j<m;j++)
      cin>>a[i][j];
  }
  int res=1000000000;
  for(int i=1;i<(1<<n);i++)
  {
    int j=i,r=0,id=0;
    for(int j=0;j<m;j++) d[j]=0;
    while(j)
    {
      if(j%2==0)
      {
        j/=2;
        id++;
        continue;
      }
      r+=c[id];
      //cout<<id<<" "<<d[0]<<"\n";
      for(int k=0;k<m;k++)
      {
        //cout<<id<<" "<<k<<" "<<a[id][k]<<"\n";
        d[k]+=a[id][k];
      }
      
      j/=2;
      id++;
        
    }
    for(int k=0;k<m;k++)
      {
        if(d[k]<x) r=-1;
      }
      if(r>=0&&r<res) res=r;
    
  }
  if(res==1000000000) res=-1;
  cout<<res;
  
  
  
  
 return 0; 
}

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

int main(){
    int N, t[100010], x[100010], y[100010];
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    cin >> N;
    bool a = true;

    for(int i = 1; i <= N; i++){
        cin >> t[i] >> x[i] >> y[i];
    }

    for(int i = 0; i < N; i++){
        if(a){
            bool b = false;
            int T = t[i+1] - t[i];
            int R = x[i+1] - x[i] + y[i+1] - y[i];
            if(-T <= R & R <= T & (R - T) % 2 == 0){
                b = true;
            }
            a = b;
        }
        else{
            break;
        }
    }

    if(a){
        cout << "Yes" << endl;
    }

    else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  
  int n;
  cin>>n;
  long long a[n];
  REP(i,n){
    cin>>a[i];
  }
  
  long long gl[n];
  long long gr[n];
  REP(i,n){
    if(i==0){
      gl[i]=a[i];
    }else{
      gl[i]=gcd_(a[i],gl[i-1]);
    }
  }
  for(int i=n-1;i>=0;i--){
    if(i==n-1){
      gr[i]=a[i];
    }else{
      gr[i]=gcd_(a[i],gr[i+1]);
    }
  }
  
  long long ans=1;
  REP(i,n){
    if(i==0){
      ans = max(ans,gr[1]);
    }else if(i==n-1){
      ans = max(ans,gl[n-2]);
    }else{
      ans = max(ans,gcd_(gl[i-1],gr[i+1]));
    }
  }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2560
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
 
        String strS = scanner.nextLine();
        int iQ = scanner.nextInt();
        
        StringBuilder strStr = new StringBuilder();
        strStr.append(strS);
        StringBuilder strTop = new StringBuilder();
        boolean blTop = true;
        for (int i = 0; i < iQ; i++) {
            int iT = scanner.nextInt();
            if (iT == 1) {
                blTop = !blTop;
            } else {
                int iFn = scanner.nextInt();
                String strC = scanner.next();

                if ((iFn == 1 && blTop == true) || (iFn == 2 && blTop == false))
                    strTop.append(strC);
                else 
                    strStr.append(strC); 
            }
        }
        StringBuilder strOut = new StringBuilder();
        if (blTop) {
            strTop.reverse();
            strOut.append(strTop);
            strOut.append(strStr);
        } else {
            strStr.reverse();
            strOut.append(strStr);
            strOut.append(strTop);
        }
        System.out.println(strOut);  
    }
}


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

int main(){

  int n;
  cin >> n;
  std::vector<int> bar(n);
  for (int i=0;i<n;++i) cin >> bar[i];

  std::sort(bar.begin(),bar.end(),std::greater<int>());

  unsigned long count = 0;

  for(int i=0;i<n;++i){
    for(int j=i+1;j<n;++j){
      for(int l=j+1;l<n;++l){
        if(bar[i] < bar[j] + bar[l]){
          count ++;
        }
      }
    }
  }

  
  cout << count << endl;

  return 0;
}


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

int getDay(int y, int m){
    if(y % 3 == 0) return 20;
    else {
        if(m % 2 == 0) return 19;
        else return 20;
    }
}

int main(){
    int n;
    cin >> n;
    for(int p=0; p < n; p++){
        int y, m ,d;
        int ans = 0;
        cin >> y >> m >> d;

        ans += getDay(y, m)-d+1;
        m++;
        if(10 < m){y++; m=1;}
        if(m != 1){
            for(int i=m; i <= 10; i++){
                ans += getDay(y, i);
            }
            y++;
        }

        while(y != 1000){
            for(int i=1; i <= 10; i++){
                ans += getDay(y, i);
            }
            y++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1160
use std::vec::Vec;

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

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

fn main() {
  let (r, d, x) = {
    let v: Vec<i64> = read_vec();
    (v[0], v[1], v[2])
  };

  let mut res = x;

  for _ in 0..10 {
    res = r * res - d;
    println!("{}", res);
  }
}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <string>

int d(std::string,int);
int BC(int,int);

int main(void){
  int K;
  std::string N;
  std::cin >> N;
  std::cin >> K;
  int ans = d(N,K);
  std::cout << ans << std::endl; 
  return 0;
}

int d(std::string  Nstr,int K){
  
  if(K==0)
    return 1;
    
  if(K!=0){
    // 桁数を求める
    int n = (int)Nstr.length();
    // n+1が桁数 n+1 < Kなら終了
    if(n < K){
      return 0;
    }
    if(n == 0){
      return 0;
    }
    // 最上位の数
    char c = Nstr[0];
    int Xn = (int)atoi(&c);
    //std::cout << Xn << std::endl;
    // あまりの数
    std::string remain = Nstr.substr(1,n);
    // 最上位が0ならremainをもって次へ
    if(Xn == 0){
      return d(remain,K);
    }
    return (Xn-1)*BC(n-1,K-1)*std::pow(9,K-1) + BC(n-1,K)*std::pow(9,K) + d(remain,K-1);
  }else{
    return 0;
  }
  return 0;
}

int BC(int n, int k) {
  if(n < k)
    return 0;
   if (k == 0 || k == n){
   	  return 1;
   }
   return BC(n - 1, k - 1) + BC(n - 1, k);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int res = 0;
    if (a - c <= d && a - c >= d * -1) res++;
    if (a - b <= d && a - b <= d * -1 && b - c <= d && b - c >= d * -1) res++;
    if (res > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
 
/*
max(N- [x2, ..., xN] [ 1 2 3 4 ... 4 3 2], 0)
 
(1 + z + z^2 + ... + z^N) (1 + z^2 + z^4 + ... + z^{2N}) ...
f(z) = 1/[(1-z){(1-z^2)(1-z^3)...(1-z^{N/2})}^2]
 
 
[z^N] (N f(z) - z * f'(z))/(1-z)
[z^N] (f(z)(N - z * f'(z)/f(z)))/(1-z)
 
f'(z)/f(z) = 1/(1-z) + 2(2z/(1-z^2) + 3z^2/(1-z^3) + ...
 
log f = \sum_{i=2}^{N/2}
 
f(z) = (1-z)(1-z^{N/2+1})^2(1-z^{N/2+2})^2... / [(1-z)(1-z^2)...]^2
f(z) = (1-z)(1-2z^{N/2+1})(1-2z^{N/2+2})... / [(1-z)(1-z^2)...]^2
f(z) = (1-z)(1-2z^{N/2+1}-2z^{N/2+2}-...) / [(1-z)(1-z^2)...]^2
f(z) = (1-z-2z^{N/2+1}) / [(1-z)(1-z^2)...]^2

[z^N] (Nz^N + (N-1)z^{N-1} + .. z + 0) f(z)
[z^{N-1}] (Nz^{N-1} + (N-1)z^{N-2} + .. 2z + 1) f(z)
[z^{N-1}] 1/(1-z)^2 f(z)
 
f(z) = 1/[(1-z)(1-z^2)(1-z^3)...(1-z^{N/2})]^2
f(z) = (1-2z^{N/2+1} - ... )/[(1-z)(1-z^2)...]^2
f(z) = (1-z-2z^{N/2+1})/{(1-z)[(1-z)(1-z^2)...]^2}
*/

 
int n, m;
 
int dp[5000];

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

  for(int i = 0; i <= n/2; i++) dp[i] = 1;
  for(int i = (n+1)/2+1, j = 0; i < n; i++, j++) dp[i] = m - (1+2*j);
  
  for(int t = 0; t < 2; t++){ 
    for(int i = 0; i < n; i++){
      long long int tmp = dp[i];
      for(int j = 1; ; j++){
        int k = j * (3 * j - 1) / 2;
        if(k > i) break;
        if(j&1){
          tmp += dp[i - k];
        }
        else {
          tmp -= dp[i - k];
        }
        k += j;
        if(k > i) break;
        if(j&1){
          tmp += dp[i - k];
        }
        else {
          tmp -= dp[i - k];
        }
      }
      dp[i] = tmp % m;
      if(dp[i] < 0) dp[i] += m;
    }
  }

  if(n & 1){
    dp[n-1] -= dp[n-1-(n+1)/2-1];
    if(dp[n-1] < 0) dp[n-1] += m;
  }
 
  printf("%d\n", dp[n-1]);
 
 
  return 0;
}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int main(){
	LL A, B, N, Nc;
	cin >> A >> B >> N;
	if(N>=B) Nc=N/B*B-1;
	else Nc=N;
	LL ans1=floor(A*Nc/B)-A*floor(Nc/B);
	LL ans2=floor(A*N/B)-A*floor(N/B);
	cout << max(ans1, ans2) << endl;

	return 0;
}

Measured memory_bytes: 3584
using System;

class Program
{
	static void Main(string[] args)
	{
		int k = int.Parse(Console.ReadLine());
		string s = Console.ReadLine();

		if (s.Length <= k)
		{
			Console.WriteLine(s);
		}
		else
		{
			string s2 = s.Remove(k);
			Console.WriteLine(s2 + "...");
		}

		return;
	}
}

Measured memory_bytes: 27536
import sys
import heapq

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def dijkstra(start, n_nodes, edge):
    dist = [float("inf")] * n_nodes
    dist[start] = 0

    # 経路を復元するための配列．直前に通った場所を記録
    prev = [None] * n_nodes

    # 優先度キューの準備
    q = [(dist[start], start)]
    heapq.heapify(q)

    while q:
        # スタートから最も最短距離のものを取り出す
        d, i = heapq.heappop(q)

        # 記録してある情報よりも，取り出した要素に入っている距離情報の方が大きければ
        # 打ち切り．次の要素を取り出す操作に戻る
        if dist[i] < d:
            continue

        # そこから移動できる頂点を探し，最短距離が更新できるものがあれば，
        # 距離を更新して，その頂点への距離と頂点の方法を優先度キューにpush
        for j in edge[i]:
            if dist[j] > dist[i] + 1:
                dist[j] = dist[i] + 1
                prev[j] = i  # jにいくために直前にiを通った
                heapq.heappush(q, (dist[j], j))

    return dist, prev


def main():
    N, M = map(int, input().split())
    edges = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        edges[a].append(b)
        edges[b].append(a)

    dist, prev = dijkstra(0, N, edges)

    for d in dist:
        if d == INF:
            print("No")
            return

    print("Yes")
    for i in range(1, N):
        print(prev[i] + 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38708
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define ms(a, x) memset(a, x, sizeof(a))
#define fore(i, a, n) for (long long i = a; i < n; i++)
#define ford(i, a, n) for (long long i = n - 1; i >= a; i--)
#define si(a) scanf("%d", &a)
#define sl(a) scanf("%lld", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define debug(a) cout << a << endl
#define pr(a) printf("%d ", a)
#define endl '\n'
#define pi acos(-1.0)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define ull unsigned long long
#define py puts("Yes")
#define pn puts("No")
#define pY puts("YES")
#define pN puts("NO")
#define re(i, a, b) for (int i = a; i <= b; ++i)
#define de(i, a, b) for (int i = a; i >= b; --i)
const double eps = 1e-8;
inline int sgn(const double &x) { return x < -eps ? -1 : x > eps; }
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;
const ll mode = 192600817;
template <class T>
inline void cmin(T &a, T b) { ((a > b) && (a = b)); }
template <class T>
inline void cmax(T &a, T b) { ((a < b) && (a = b)); }
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
int main()
{
  ll a, b, n;
  cin >> a >> b >> n;
  if(b==1)
  {
    cout<<0<<endl;return 0;
  }
  if (n < b)
  {
    cout << floor((double)(a * n) / b) << endl;
  }
  else
  {
    cout << ll(a - 1) -a/b<< endl;
  }

  return 0;
}

Measured memory_bytes: 3768
#include<iostream>
#include<cstring>
#include<climits>
using namespace std;
int dp[100005];
int frog(int a[],int n)
{
 dp[1]=0,dp[0]=0;
 for(int i=2;i<=n;i++)
 {
     int ans=abs(a[i-1]-a[i-2])+dp[i-1];
     int ans1=(i==2)? 1e9:abs(a[i-1]-a[i-3])+dp[i-2];
     dp[i]=min(ans,ans1);
     
 }
 return dp[n];
}
int main(){
    int n; 
    cin>>n;
    int a[n]={0};
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
     memset(dp,sizeof dp,0);
   cout<<frog(a,n)<<"\n";

return 0;
}

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


a,b,k = LI()
if k >= a:
    print(0,max(b-(k-a),0))
else:
    print(a-k,b)


Measured memory_bytes: 38384
#include <stdio.h>
int main()
{
	int a,b,c,d,n,i;
	while(0<=scanf("%d",&n)){
		i=0;
		if(n<=36)
		for(a=0;a<10;a++){
			for(b=0;b<10;b++){
				for(c=0;c<10;c++){
					for(d=0;d<10;d++){
						if(a+b+c+d==n)
							i=i+1;
					}
				}
			}
		}
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[3];
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=1;i<=a[0];i++){
    bool f=1;
    for(int j=0;j<n;j++)
      if(a[j]%i)f=0;
    if(f)cout<<i<<endl;
  }
  return 0;
}

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

const int MAX = 120;

int main(){

    int x,n;
    int p[MAX] = {0};

    cin >> x >> n;
    if(n == 0){
        printf("%d\n", x);
        return 0;

    }

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


    int check;
    int diff;
    int min = 100;
    int ans = 0;
    for(int i = 0; i <=101; ++i){
        if(p[i] != 0){
            continue;
        }else{
            diff = std::abs(x - i);
            //printf("i:%d:%d\n",i, diff);
            if(diff < min){
                min = diff;
                ans = i;
            }
        }


    }


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

    return 0;

}

Measured memory_bytes: 3760
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath> 
using namespace std; 
int main()
{ 
	int n;  
	cin >> n;
	vector<int> t(n); 
	for (int i = 0; i < n; i++)
	{
		cin >> t.at(i);
	} 
	int m; 
	cin >> m;  
	vector<int> ans(m);
	for (int i = 0; i < m; i++)
	{
		int p, x;  
		cin >> p >> x;  
		int aaa = t.at(p-1); 
		t.at(p-1) = x; 
		for (int k = 0; k < n; k++)
		{
			ans.at(i) += t.at(k);

		} 
		t.at(p-1) = aaa;


	}
	for (int i = 0; i < m; i++)
	{
		cout << ans.at(i) << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n;
    vector<int>t(n);
    for(int i=0;i<n;i++){
        cin>>t.at(i);
    //    cout<<"t["<<i<<"]"<<t.at(i)<<endl;
    }

    cin>>m;
    vector<int>p(m);
    vector<int>x(m);

    for(int i=0;i<m;i++){
        cin>>p.at(i)>>x.at(i);
    //    cout<<p.at(i)<<x.at(i)<<endl;
    }
    
    for(int i=0;i<m;i++){
        int sum=0;
        for(int j=0;j<n;j++){
            
            if(j+1==p.at(i)){
                sum+=x.at(i);
            }else{
                sum+=t.at(j);
            }

        }
        cout<<sum<<endl;
    }
    cout<<endl;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<algorithm>
#include<cctype>
#include<cstring>
#include<map>
#include<bitset>
#include<stack>
#include<queue>
#include<set>
#include<cmath>
#include<vector>

using namespace std;

#define bomb exit(1)
#define INF 1000000000
#define LINF 1000000000000000000ll
#define pprint(x) print(x),putchar(' ')
#define fprint(x) print(x),putchar('\n')
#define EE(x); struct edge { int nxt,to,w; }e[M << 1]; int head[N],cnt = x ^ 1;\
	void add(int u,int v,int w = 0) { e[++cnt].w = w,e[cnt].to = v,e[cnt].nxt = head[u];head[u] = cnt; }\
	void add_edge(int u,int v,int w = 0) { add(u,v,w),add(v,u,w * x); }
#define Mod(x) ((x) >= mod ? x - mod : x)
#define eps 0.0000000001
#define sqr(x) ((x) * (x))
#define iter iterator
#define fi first
#define se second
#define ll long long
//#define getchar() (SS == TT && (TT = (SS = BB) + fread(BB,1,1 << 15,stdin),TT == SS) ? EOF : *SS++)
//char BB[1 << 15],*SS = BB,*TT = BB;
inline ll read()
{
	ll x = 0;int f = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') f = -1;
	for(;isdigit(ch);ch = getchar()) x = x * 10 + (ch ^ 48);
	return x * f;
}
void print(ll x)
{
	if(x < 0) putchar('-'),x = -x;
	if(x > 9) print(x / 10);
	putchar(x % 10 + '0');
}

const int mod = 1000000007,N = 100005;
int n,sum;
char s[N];
int nxt[N][2];
ll f[N];

int main()
{
	scanf("%s",s + 1),n = strlen(s + 1);
	bool fl = 1;
	for(int i = 1;i < n;i++) if(s[i] == s[i + 1]) fl = 0;
	if(fl) { puts("1");return 0; }
	f[n + 1] = 1,nxt[n + 1][0] = nxt[n + 1][1] = nxt[n + 2][0] = nxt[n + 2][1] = n + 2;
	for(int i = n;i;i--)
	{
		(sum += s[i] - 'a' + 1) %= 3;
		nxt[i][0] = s[i] == 'a' ? i + 1 : s[i + 1] == 'b' ? i + 2 : nxt[i + 2][0];
		nxt[i][1] = s[i] == 'b' ? i + 1 : s[i + 1] == 'a' ? i + 2 : nxt[i + 2][1];
		f[i] = (f[nxt[i][0]] + f[nxt[i][1]] + (sum == 0)) % mod;
	}
	fprint((f[1] - (sum == 0) + mod) % mod);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};

int N, H;
P ab[101010];
P ba[101010];
int bsum[101010];

bool check(int x)
{
  // printf("x = %d¥n", x);
  for (int B=0; B<=min(x, N); B++) {
    // printf("B = %d¥n", B);
    // cout << "CCC" << ab[0].first << endl;
    if (bsum[B] + ab[0].first * (x - B) >= H) return true;
  }
  return false;
}

signed main()
{
  cin >> N >> H;
  REP(i,N) {
    cin >> ab[i].first >> ab[i].second;
    ba[i].first = ab[i].second;
    ba[i].second = ab[i].first;
  }

  sort(ab, ab + N);
  reverse(ab, ab + N);
  sort(ba, ba + N);
  reverse(ba, ba + N);
  for (int B=1; B<=N; B++) {
    bsum[B] += bsum[B-1] + ba[B-1].first;
  }
  // REP(i,N+1) {
  //   cout << "BBB" << endl;
  //   printf("bsum[%lld] = %d¥n", i, bsum[i]);
  // }

  // REP(i,N) {
  //   cout << ab[i].first << " " << ab[i].second << endl;
  // }

  int lb = 0, ub = 1010101010;
  while (ub - lb > 1) {
    // cout << "AAA" << endl;
    int mid = (ub + lb) / 2;
    // cout << (check(mid) ? "True" : "False") << endl;
    if (check(mid)) {
      ub = mid;
    } else {
      lb = mid;
    }
  }

  cout << ub << endl;
}

Measured memory_bytes: 4224
#include <iostream>
#include <stdio.h>
using namespace std;

int main(int argc, char *argv[])
{
    int H, W;

    while (true)
    {
        scanf("%d %d", &H, &W);
        if (H == 0 && W == 0)
        {
            break;
        }

        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if ((i + j)%2 == 0)
                {
                    printf("%c", '#');
                }
                else
                {
                    printf("%c", '.');
                }
            }
            printf("\n");
        }
        printf("\n");
    }



    return 0;
}



Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	long long N,X;
	cin>>N>>X;
	int arr[N];
	for(int i=0;i<N;i++)
		cin>>arr[i];
	long long bounce=1;
	long long sum=0;
	for(int i=0;i<N;i++){
		sum+=arr[i];
		if(sum<=X){
			bounce++;
		}
		else
			break;
	}
	cout<<bounce;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
 
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
  ll a,b,c,d; cin >> a>>b>>c>>d;
  if(abs(a-c)<= d || abs(a-b)<=d && abs(b-c) <= d) cout <<"Yes" << endl;
  else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
string trim(string s) {
  if(s == "0") return s;
  string t = "";
  int i = 0;
  while(s[i] == '0') i++;
  while(i < s.size()) {
    t = t + s[i];
    i++;
  }
  return t;
}
int main() {
  int n;
  cin >> n;
  if(n == 0) {
    cout << '0' << endl;
    return 0;
  }
  string s = "";
  while(n != 0) {
    int r = n % (-2);
    dbg(r);
    if(r == 0) s = "0" + s, n /= (-2);
    if(r == 1) s = "1" + s, n /= (-2);
    if(r == -1) s = "1" + s, n--, n /= (-2);
  }
  s = trim(s);
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
ll modding = 998244353;
 
int main() { 
	int K,X;
  cin>>K>>X;
  if(K*500<X){
    puts("No");
  }else{
  	puts("Yes");
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int n;
  cin >> n;
  while(n--){
    double x[4],y[4];
    for(int i=0;i<4;i++){
      cin >> x[i] >> y[i];
    }
    if(abs((x[3]-x[2])*(y[1]-y[0])-(x[1]-x[0])*(y[3]-y[2])) < 1e-10){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
}

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

typedef struct{
 int x;
 int y;
}P;//表示坐标

char graph[1000][1000];
P aim[10];
P s,g;//s起点，g终点
int N,W,H;
int vis[1000][1000]; //用来存储距离
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

int bfs(P s,P g);

int main(){
    int i,j,t,step=0;
    cin>>H>>W>>N;
    
    for(i=0;i<H;i++)
    for(j=0;j<W;j++){
        cin>>graph[i][j];
      if(graph[i][j]<='9'&&graph[i][j]>='1'){ 
         t=graph[i][j]-'0';
         aim[t].x=i;
         aim[t].y=j;
      } //把1-N的坐标保存在 aim数组中 
      else if(graph[i][j]=='S'){
          s.x=i;
          s.y=j;
          graph[i][j]='.';
      }//得到最初的起点 
    }
    
    for(i=1;i<=N;i++){
       g.x=aim[i].x;
       g.y=aim[i].y;//1-N ，从小到大，每次把一个 作为终点 
       step+=bfs(s,g);
       s.x=g.x;
       s.y=g.y;//到达这个终点后变终点为起点 
       graph[g.x][g.y]='.';
    }
   
    cout<<step<<endl;
}

int bfs(P s,P g){
    queue<P> que;
      P n;
    
    for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
     vis[i][j]=-1;
     
     que.push(s);
     vis[s.x][s.y]=0;
     
     while(que.size()){
         
       P p=que.front();
         que.pop();
       if(p.x==g.x&&p.y==g.y)
       break;
       
       for(int i=0;i<4;i++){
           n.x=p.x+dx[i];
           n.y=p.y+dy[i];//向四方漫射 
        if(0<=n.x&&n.x<H&&0<=n.y&&n.y<W&&graph[n.x][n.y]!='X'&&vis[n.x][n.y]==-1){
               que.push(n);
               vis[n.x][n.y]=vis[p.x][p.y]+1;
           }
       }
   }
     return vis[g.x][g.y];
}


Measured memory_bytes: 7944
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    vector<int> a(200), b(200);
    rep(i, (int)s.length()){
        a[s[i]]++;
        b[t[i]]++;
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    rep(i, 200){
        if(a[i] != b[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


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

int main(){
    int sum = 0;
    int m[] = { 1, 5, 10, 50, 100, 500 };
    for(int i = 0; i < 6; ++i){
        int c;
        cin >> c;
        sum += c * m[i];
    }

    cout << (sum < 1000 ? '0' : '1') << endl;
    return 0;
}

Measured memory_bytes: 3088
import java.util.Scanner;

class Main {
  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    String ans  =  "";
    String zero = "0";
    String one  = "1";

    if(n == 0){
      System.out.println("0");
      return;
    }
    
    while(n != 1){
      if(n % -2 == 0){
        ans = ans.concat(zero);
        n /= -2;
      }
      else if(n > 0){
        ans = ans.concat(one);
        n /= -2;
      }
      else{
        ans = ans.concat(one);
        n /= -2;
        n++;
      }       
    }
    ans = ans.concat(one);

    StringBuffer buf = new StringBuffer(ans);
    String res = buf.reverse().toString();

    System.out.println(res);

  }
}

Measured memory_bytes: 23764
m=input()
a=map(int,raw_input().split())
n=input()
b=map(int,raw_input().split())
d={}
flag=True
for i in a:
    d[i]=d.get(i,0)+1
for i in b:
    d[i]=d.get(i,0)-1
    if d[i]<0:
        flag=False
        break
print "YES" if flag else "NO"

Measured memory_bytes: 35324
#include<stdio.h>

int main(void){
    int a,op,b,ans;

    while(1){
        scanf("%d%s%d",&a,&op,&b);

        if (op=='+'){
            ans=a+b;
        } else if (op=='-'){
            ans=a-b;
        } else if (op=='*'){
            ans=a*b;
        } else if (op=='/'){
            ans=a/b;
        } else if (op=='?'){
            break;
        }

        printf("%d\n",ans);
    }


    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int n;
	string s;
	vector<string> ans;
	cin >> n;
	int up = 0;
	map<string, int> dis;
	rep(i, n) {
		cin >> s;
		dis[s]++;
	}
	repi(itr, dis) { chmax(up, itr->S); }
	repi(itr, dis) {
		if (itr->S == up) {
			ans.push_back(itr->F);
		}
	}
	sort(all(ans));
	repi(itr, ans) { cout << (*itr) << endl; }
}

Measured memory_bytes: 27204