akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

int dp[1000001];

void test_case(){
	int n; cin >> n;
	vector<int> hash(n);
	for(auto &x : hash )
		cin >> x;
	for(auto x : hash){
		if(dp[x] != 0){
			dp[x] = 2;
			continue;
		}
		for(int i = x ; i < 1e6+1 ; i += x)
			dp[i]++;
	}
	int ans = 0;
	for(int x : hash){
		if(dp[x] == 1)
			ans++;
	}
	cout<<ans<<"\n";
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 7996
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define S second
#define F first
#define all(x) (x).begin(), (x).end()


using namespace std;

const bool dbg_flg = false;
#define debug(x) if (dbg_flg) cerr << #x << ' ' << x << '\n'
#define debug_pair(x) if (dbg_flg) cerr << #x << ' ' << x.F << ' ' << x.S << '\n'
 
const int inf = 1e9 + 7;
const int MAXN = 1e6 + 5;
const ll INF = 1e18;

#define int ll

int n, m;
char s[MAXN], t[MAXN];
map<int, int> x;

main() {
	//~ freopen("input.txt", "r", stdin);
	//~ freopen("output.txt", "w", stdout);
	
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);	

	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> t[i];
	}
	
	int l = (n * m) / __gcd(n, m);
		
	if (s[0] != t[0]) {
		cout << -1;
		return 0;
	}
		
	for (int i = 1; i < n; i++) {
		int id = i * (l / n) + 1;
		x[id] = i;
	}
	
	for (int i = 1; i < m; i++) {
		int id = i * (l / m) + 1;
		
		if (x.find(id) != x.end()) {
			if (s[x[id]] != t[i]) {
				cout << -1;
				return 0;
			}
		}
		
		x[id] = i;
	}
	
	cout << l;
	return 0;
}

Measured memory_bytes: 10880
#include <bits/stdc++.h>
#define bits ____bits
using namespace std;
typedef long long LL;
const int N=200005;
int n,a[N],bits[30];
bool check(){
	for (int i=0;i<20;i++)
		if (bits[i]>1)
			return 1;
	return 0;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	memset(bits,0,sizeof bits);
	LL ans=0;
	int j=0;
	for (int i=1;i<=n;i++){
		while (j<=n&&!check()){
			j++;
			for (int k=0;k<20;k++)
				bits[k]+=(a[j]>>k)&1;
		}
		ans+=j-i;
		for (int k=0;k<20;k++)
			bits[k]-=(a[i]>>k)&1;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{

    int a,b;

    public void input(){
	Scanner scan = new Scanner(System.in);
       a = scan.nextInt();
       b = scan.nextInt();
        
    }
 


    public void output(){
	System.out.print(a*b+" ");
        System.out.println(2*a+2*b);
    }
 public static void main(String[] args){
     Main p = new Main();
     p.input();
     p.output();
 }
}
  

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

int main()
{
  unordered_map<string,int> mp;
  mp["AC"]=0; mp["WA"]=0; mp["TLE"]=0; mp["RE"]=0;
  int n; cin>>n;
  while(n--)
  {
    string s; cin>>s; mp[s]++;
  }
  cout<<"AC x "<<mp["AC"]<<'\n';
  cout<<"WA x "<<mp["WA"]<<'\n';
  cout<<"TLE x "<<mp["TLE"]<<'\n'; 
  cout<<"RE x "<<mp["RE"]<<'\n';
}

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

#define pb         push_back

const int INF = 100000000;

int dx[4] = {-1, 0 , 1, 0}, dy[4] = {0 , -1, 0, 1};
int w, h;
vector<string> ma;

void rec(int y, int x);

int main(void) {
	while(1){
		cin >> w >> h;
		if(w == 0 && h == 0) break;

		ma = vector<string>();

		for(int i=0; i<h; i++){
			string t;
			cin >> t;
			ma.pb(t);
		}

		int sx, sy;
		for(int i=0; i<h; i++){
			//cout << ma[i] << endl;
			for(int j=0; j<w; j++){
				if(ma[i][j] == '@'){
					ma[i][j] = '.';
					sx = j;
					sy = i;
				}
			}
		}

		rec(sy, sx);

		int ans = 0;
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				if(ma[i][j] == 'o'){
					ans++;
				}
			}
		}

		cout << ans << endl;

	}
	
	return 0;
}

void rec(int y, int x){
	//cout << y << ' ' << x << endl;
	if(ma[y][x] == '.') ma[y][x] = 'o';
	else return;
	int nx, ny;
	for(int i=0; i<4; i++){
		nx = x + dx[i];
		ny = y + dy[i];

		if(nx >= 0 && nx < w && ny >= 0 && ny < h){
			rec(ny, nx);
		}
	}
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define FI freopen ("inp.txt", "r", stdin)
#define FO freopen ("out.txt", "w", stdout)
using namespace std;

const int INF = 1e9 + 5;

int main() {
    //FI;

    int n;
    scanf("%d", &n);
    vector<int> h(n);
    for (int& x : h) scanf("%d", &x);

    vector<int> dp(n, INF);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j : {i + 1, i + 2})
            dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
    }
    printf("%d\n", dp[n-1]);

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair

int mod = 1e9+7;
int inf = 1e18;
const int N = 3e5+5;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
      string s;
      cin>>s;
      int n = sz(s);
      int q;
      cin>>q;
      string ans1;
      string ans2;
      int xx = 1;
      while(q--)
      {
         int x;
         cin>>x;
         if(x==1)
            xx = 1-xx;
         else
         {
             int xxx;
             string str;
             cin>>xxx>>str;
             if(xx==1)
             {
                 if(xxx==1)
                    ans1 = str+ans1;
                if(xxx==2)
                    ans2+=str;
             }
             else
             {
                 if(xxx==1)
                    ans2+=str;
                 else
                    ans1 = str+ans1;
             }

         }



      }
      string ans = "";
      ans = ans1+s+ans2;
      if(xx==0)
        reverse(all(ans));
      cout<<ans<<el;



    }

    return 0;
}


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

int main() {
    int n,m;
	cin>>n>>m;
	int sum = 0;
	for(int i=0;i<m;i++){
	    int days;
	    cin>>days;
	    sum = sum + days;
	}
	if(sum<=n) cout<<n-sum;
	else cout<<-1;
	return 0;
}


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

typedef pair<string, int> p;
int main(){

  int n, q, t;
  string name;
  queue<p> que;

  cin >> n >> q;

  for(int i = 0; i < n; i++){
    cin >> name >> t;
    que.push(p(name, t));
  }
  int count = 0;
  while(!que.empty()){
    p tmp = que.front();
    que.pop();
    if(tmp.second <= q){
      count += tmp.second;
      cout << tmp.first << " " << count << endl;
    }else{
      tmp.second -= q;
      count += q;
      que.push(tmp);
    }
  }
  return 0;
}


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

int main() {
    string firstDay;
    cin >> firstDay;
    
    string secondDay;
    cin >> secondDay;

    int preditedForecast=0;
    for (int i = 0; i < firstDay.size(); i++)
    {
        if (firstDay[i] == secondDay[i])
            preditedForecast++;
    }
    
    cout << preditedForecast << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
 
int main(){
	ll n;
	scanf("%lld",&n);
	ll ans=1e10;
	rep(i,0,n){
		ll t;
		scanf("%lld",&t);
		ans=min(ans,log2(t&-t));
	}
	printf("%lld",ans);
}

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

using namespace std;

int main(){
  long long int n , a , b ,x[100010];
  
  cin >> n >> a >> b ;
  
  for(int i=0;i<n;i++)
    cin >> x[i];
  
  for(int i=0;i<n;i++){
    x[i] - x[0] ;
  }
  
  long long int ans = 0;
  
  for(int i=1;i<n;i++){
    
    if((x[i]-x[i-1])*a < b) ans += (x[i]-x[i-1])*a;
    if((x[i]-x[i-1])*a >= b) ans += b;
    
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 1024
from collections import defaultdict, Counter
from heapq import heapify, heappop, heappush
from sys import stdin

def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    cnt = 0
    while True:
        loop = True
        for i in range(N):
            if A[i] % 2 == 1:
                loop = False
                break
            A[i] /= 2
        if not loop:
            break
        cnt += 1
    print(cnt)

input = lambda: stdin.readline().rstrip()
main()

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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

int n;
int a[150], b[150];

int main()
{
	IOS;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	partial_sum(a, a+n, b);
	int res = INT_MAX;
	for (int i = 0; i < n-1; i++) {
		res = min(res, abs(b[i] - (b[n-1] - b[i])));
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(long long i=0;i<n;++i)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
using namespace std;
int main(){
    int q;
    scanf("%d",&q);
    string x,y;
    REP(i,q){
        cin>>x>>y;
        int dp[x.size()+1][y.size()+1];
        fill(dp[0],dp[x.size()],-1);
        REP(j,x.size()+1) dp[j][0]=0;
        REP(j,y.size()+1) dp[0][j]=0;
        FOR(j,1,x.size()+1){
            FOR(k,1,y.size()+1){
                if(x[j-1]==y[k-1]) dp[j][k]=dp[j-1][k-1]+1;
                else dp[j][k]=max(dp[j][k-1],dp[j-1][k]);
            }
        }
        printf("%d\n",dp[x.size()][y.size()]);
    }
    return 0;
}




Measured memory_bytes: 7256
#include <iostream>
#include <cstring>
#include <bits/stdc++.h>
#include<algorithm>

using namespace std;

const int N = 1e5+6, M = 1e5+5, OO = 0x3f3f3f3f;
int n , h[N] ,op1 ,op2,dp[N] ;
int frog(){
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);


    for(int i = 2; i <= n; i++){


        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]),
                    dp[i - 1] + abs(h[i] - h[i - 1]));
    }


    return dp[n - 1];
}

int main(){
  scanf("%d",&n );
  for(int i = 0 ; i<n ;i++)
    scanf("%d",h+i );
  printf("%d\n",frog() );
    return 0;
}


Measured memory_bytes: 1024
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


b, w = LI()
n = b + w
fac = [1] * (n + 1)
inv = [1] * (n + 1)
two_inv = [0] * (n + 1)
for j in range(1, n + 1):
    fac[j] = fac[j-1] * j % mod


inv[n] = pow(fac[n], mod-2, mod)
for j in range(n-1, -1, -1):
    inv[j] = inv[j+1] * (j+1) % mod


two_inv[n] = pow(pow(2, n, mod), mod-2, mod)
for j in range(n-1, -1, -1):
    two_inv[j] = two_inv[j+1] * 2 % mod

def comb(n, r):
    if r > n or n < 0 or r < 0:
        return 0
    return fac[n] * inv[n - r] * inv[r] % mod


LB = [0] * (n + 1)
LW = [0] * (n + 1)
for i in range(n + 1):
    LB[i] = two_inv[i] * comb(i - 1, b - 1) % mod

for j in range(n + 1):
    LW[j] = two_inv[j] * comb(j - 1, w - 1) % mod

for k in range(1, n + 1):
    LB[k] = (LB[k - 1] + LB[k]) % mod
    LW[k] = (LW[k - 1] + LW[k]) % mod



for l in range(1, n + 1):
    print(((1 - LB[l - 1] - LW[l - 1]) * two_inv[1] + LW[l - 1]) % mod)


Measured memory_bytes: 132732
/**Bismillahir Rahmanir Rahim.**/
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using ll=long long;
using db=double;
///***************************************************** CONSTANTS ******************************************************///

int const N=1e6+3;
ll MOD=1e9+7,fact[N];
const long long inf=(long long)1e18;
const long double PI=3.14159265358979;

///************************************************ CONTAINER DEFINITIONS ***********************************************///

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///************************************************ SHORT FORM KEYWORDS *************************************************///

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define I insert
#define lb lower_bound
#define ub upper_bound
#define endl '\n'

///************************************************ SHORT FORM FUNCTIONS ************************************************///

#define loop(a,b) for(ll i=a;i<b;i++)
#define loopr(a,b) for(ll i=a-1;i>=b;i--)
#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sa(v) sort(v.begin(),v.end())
#define sd(v) sort(v.begin(),v.end(),greater<>())
#define rev(s) reverse(s.begin(),s.end())
#define stll(x) stoll(x, nullptr, 10);
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define all(a) a.begin(),a.end()
#define mxa(a,N) *max_element(a,a+N)
#define mna(a,N) *min_element(a,a+N)
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define io() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


///************************************************ SOLUTION STARTS HERE ************************************************///
///======================================================================================================================///

void solve(){
 int n;
 cin>>n;
 for(int i=0; i<n; i++){
    cout<<"ACL";
 }   
}
int main()
{
    io();
    int T=1;//cin>>T;
    while(T--) solve();
    return 0;
}

/****************ALHAMDULILLAH******************/


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

#pragma warning(disable : 4996)

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
//#define int long long;

double distance(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
ll idistance(ll x1, ll y1, ll x2, ll y2) {
  return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
signed main() {
  int N;
  cin >> N;
  vector<int> list(N);
  rep(i, N) { cin >> list[i];
  }
  int q;
  cin >> q;

  vector<int> d(2100);

  for (int bit = 0; bit < (1 << N); ++bit) {
    int tmp = 0;
    vector<int> S(N);  //目的の集合
    for (int i = 0; i < N; ++i) {
      if (bit & (1 << i)) {
        S[i] = 1;
      }
    }
    // cout << "!";
    rep(j, N) { tmp += list.at(j) * S.at(j); }
    if (tmp < 2050) d[tmp] = 1;
  }

  rep(k, q) {
    int g;
    cin >> g;
    if (d[g] == 1) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
}



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

int main(){
  int n;
  cin >> n;
  std::vector<int> vec(n), d(n);
  rep(i,n) {
    int x;
    cin >> x;
    vec.at(i) = x;
    d.at(i) = x;
  }
  sort(d.begin(), d.end());
  reverse(d.begin(), d.end());

  rep(i,n) {
    if (vec.at(i) == d.at(0)) {
      cout << d.at(1) << endl;
    } else {
      cout << d.at(0) << endl;
    }
  }
}


Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7; //10の9乗

ll F(ll A, ll B) {
    return max(log10(A)+1, log10(B)+1);
}

int main(){
    int n;
    cin >> n;
    vector<string> S(n);
    //ソートした各要素を配列にいれる
    for(int i=0; i<n; i++) {
        string ss;
        cin >> ss;
        sort(ss.begin(), ss.end());
        S[i] = ss;
    }

    for(char c='a'; c<='z'; c++) {
        int m = count(S[0].begin(), S[0].end(), c);
        for(int j=0; j<n; j++) {
            int x = count(S[j].begin(), S[j].end(), c);
            m = min(m, x);
        }

        for(int i=0; i<m; i++) cout << c;
    }
}

Measured memory_bytes: 3688
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        char[][] board = new char[h][w];
        for(int i =0; i < h; i++) {
           String s = sc.next();
           for(int k =0; k < w; k++){
               char c = s.charAt(k);
               board[i][k] = c;
           }
        }
        for(int i =0; i < h; i++) {
            for (int k = 0; k < w; k++) {
                if(board[i][k]=='#'){
                    continue;
                }
                int result = 0;
                for(int y =i-1; y <= i+1; y++) {
                    for (int x = k -1; x <= k+1; x++) {
                        if(y < 0 || y >= h || x < 0 || x >= w) continue;
                        if(y == i && x == k) continue;

                        if(board[y][x]=='#'){
                            result++;
                        }
                    }
                }
                board[i][k] = Character.forDigit(result, 10);
            }
        }
        for(int i =0; i < h; i++) {
            for (int k = 0; k < w; k++) {
                System.out.print(board[i][k]);
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ull B = 100000007;
ll mod = 1000000007;
int INF = 0x3f3f3f3f;

int main() {
    string s;
    cin >> s;
    if(s == "ABC") {
        cout << "ARC" << endl;
    }
    else {
        cout << "ABC" << endl;
    }

    return 0;
}



Measured memory_bytes: 3596
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


N = int(input())
A = sorted(inpl())
B = sorted(inpl())
C = sorted(inpl())

ans = 0
i_a = 0
i_c = 0
for i_b in range(N):
    while i_a < N and A[i_a] < B[i_b]:
        i_a += 1
    while i_c < N and C[i_c] <= B[i_b]:
        i_c += 1

    ans += i_a * (N - i_c)

print(ans)


Measured memory_bytes: 23156
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    fast
    FI(); /// skip this line for compile
    int n;
    string s;
    set<string>st;
    cin >> n;
    while(n--){
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
    return 0;
}



Measured memory_bytes: 19244
#include <iostream>
#include <set> 
#include <iterator>
#include <bitset> 
#include <bits/stdc++.h> 
using namespace std;
typedef  long long int ll;
ll mod=1000000007;

    

int main() {
       int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++ )
            cin>>a[i];
        //cout<<binarys(0,n-1,x,a)<<endl;
         ll dp[n];
         dp[0]=0;
         dp[1]=abs(a[1]-a[0]);
         for(int i=2;i<n;i++)
         {  dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
         }
         cout<<dp[n-1];
            
    
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  bool flag = 0;
  rep(i,S.size()){
    if(i%2 == 0){
      if(S[i] != 'R' &&S[i] != 'U' &&S[i] != 'D'){
        flag = 1;
        break;
      }
    }else{
      if(S[i] != 'L' &&S[i] != 'U' &&S[i] != 'D'){
        flag = 1;
        break;
      }
    }
  }
  if(flag == 0) cout << "Yes";
  if(flag == 1) cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define REV(s) (s).rbegin(), (s).rend()
#define MEMSET(v, s) memset(v, s, sizeof(v));
#define MP make_pair
#define X first
#define Y second

using namespace std;

const double EPS = 1e-8;

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

template<class T> inline T sq(T a){return a*a;}
template<class T> T gcd(T m, T n){return n?gcd(n, m%n):m;}

const int N = 210;
int par[N];

int find(int x){
	if(x == par[x]) return x;
	return par[x] = find(par[x]);
}

void unite(int x, int y){
	par[find(x)]=find(y);
}

struct edge{
	int from, to, cost;
	edge(){}
	edge(int f, int t, int c):from(f), to(t), cost(c){}
	bool operator<(const edge &r) const{
		return cost < r.cost;
	}
};

int h[N];
edge E[N*N];
bool used[N*N];

int ans, cnt;

void init(){
	rep(i, N) par[i] = i;
	MEMSET(used, 0);
	ans = 0;
	cnt = 1;
}

int main(){
	int n, m;
	while(cin >> n >> m, n|m){
		init();
		rep(i, n) cin >> h[i];
		MEMSET(used, 0);
		rep(i, m){
			int a, b, c;
			cin >> a >> b >> c;
			a--, b--;
			E[i] = edge(a, b, c);
		}

		priority_queue<P> q;
		rep(i, n) q.push(MP(h[i], i));
		bool ok[N] = {};
		sort(E, E+m);

		int num = 0;
		init();
		while(!q.empty()){
			int x = q.top().first;
			while(!q.empty() && x == q.top().first){
				num++;
				ok[q.top().second] = 1;
				q.pop();
			}
			rep(i, m){
				int f = E[i].from, t = E[i].to;
				if(!used[i] && ok[f] && ok[t]){
					if(find(f) == find(t)) continue;
					unite(f, t);
					cnt++;
					ans += E[i].cost;
					used[i] = 1;
				}
			}
			if(cnt != num) init();
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1492
//https://muttan1203.hatenablog.com/entry/2017/05/30/155343
//参考にさせて頂いた解説

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define rep(i,n) for(int i=0;i<(n);i++)
vector<int> C(0);
vector<int> dp(50001,INF);

int main(){
    int N,M;
    cin>>N>>M;
    C.resize(M);
    rep(i,M)cin>>C[i];
    
    dp[0]=0;

    rep(i,M){
        for(int j=0;j+C[i]<=N;j++){//j+C[i]円まででdpを回すため
            dp[j+C[i]]=min(dp[j+C[i]],dp[j]+1);//dp[j]+1としているのは、コインの枚数カウントを進めるため？
        }//dp[j+c[i]]としているのは、c[i]によって必ず、c[i]円は払うことになっているため。
    }
    cout<<dp[N]<<endl;
    return 0;
}

//a=97,z=122


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

public class Prog
{
    public void run()
    {
        var input = Console.ReadLine().Split();
        int N = int.Parse(input[0]);
        int L = int.Parse(input[1]);
        int ans = 0;
        if(L >= 0)
        {
            ans = L * (N - 1) + N * (N - 1) / 2;
        }
        else
        {
            if(N+L > 0)
            {
                ans = L * N + N * (N - 1) / 2;
            }
            else
            {
                ans = (L - 1) * (N - 1) + N * (N - 1) / 2;
            }
        }
        Console.WriteLine(ans);
    }
    public static void Main()
    {
        var prog = new Prog();
        prog.run();
    }
}

//Array.ConvertAll(int.Parse)
//str.IndexOf("Stage",System.StringComparison.CurrentCulture)


Measured memory_bytes: 13140
def solve(K, N, As):
    longest = 0
    for i in range(len(As)):
        x = 0
        if i == len(As) - 1:
            x = As[0] + (K - As[i])
        else:
            x = As[i + 1] - As[i]
        longest = max(longest, x)
    print(K - longest)


if __name__ == '__main__':
    K, N = map(int, input().split())
    As = [int(a) for a in input().split()]
    solve(K, N, As)


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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    ll n,ans=0;
    cin >> n;
    for(int i=1;i<=n;i++){
        if(i%3==0||i%5==0) continue;
        else ans+=i;
    }
    cout << ans << endl;

    return 0;
}











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

int main()
{
    string s;cin>>s;
    int c=0,a=0;
   for(int i=2;i<s.size()-1;i++){
    if(s[i]=='C'){c++;}
   }
   for(int i=1;i<s.size();i++){
    if(s[i]=='C'){c++;}
    else if(islower(s[i])){a++;}
   }
   if(c==2&&s[0]=='A'&&a==s.size()-2){cout<<"AC";}
   else{cout<<"WA";}
    return 0;
}


Measured memory_bytes: 256
a, b, c, d = map(int,input().split())
if a % d == 0:
    x = a // d
else:
    x = a // d + 1
if c % b == 0:
    y = c // b
else:
    y = c // b + 1
if y == 1:
    print("Yes")
elif y <= x:
    print("Yes")
else:
    print("No")

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

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int t,d,l;
int a[100010];

void solve() {
  for (int i = 0; i < t; i++) {
    cin >> a[i];
  }
  int ans = 0;

  int mx = -1;
  int begin = 0;
  int end = 0;
  bool f = 0;
  for (int i = 0; i < t; i++) {
    if (a[i] >= l) {
      if (f) {
        end = i + d;
        end = min(t-1,end);
      } else {
        f = 1;
        begin = i;
        end = i + d;
        end = min(t-1,end);
      }
    } else {
      if (f) {
        if (i >= end) {
          ans += end - begin;
          f = 0;
        }
      }
    }
  }
  if (f) ans += end - begin;
  cout << ans << endl;
}

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

  /*Regular*/
  // if (argc > 1 && stoi(argv[1])) cin >> case_num;
  // REP(case_no, case_num) {
  //   cerr << endl << "case " << case_no + 1 << endl;
  //   solve();
  // }

  /*ICPC*/
  while (cin >> t >> d >> l, t) {
    solve();
  }

  return 0;
}


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

using namespace std;

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

#define int ll

const ll mod = 1e9 + 7;


main(){
	string s;
	cin >> s;
	int win = 0;
	for(int i=0;i<s.length();i++){
		if(s[i]=='o') win++;
	}
	if(win+(15-s.length())>=8){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 3556
#include<stdio.h> 
long long int max(long long int a,long long int b) { return (a > b)? a : b; } 
long long int knapSack(int W, int wt[], int val[], int n) 
{ 
	int i, w; 
	long long int K[n+1][W+1]; 
	for (i = 0; i <= n; i++) 
	{ 
		for (w = 0; w <= W; w++) 
		{ 
			if (i==0 || w==0) 
				K[i][w] = 0; 
			else if (wt[i-1] <= w) 
				K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]], K[i-1][w]); 
			else
				K[i][w] = K[i-1][w]; 
		} 
	} 
	return K[n][W]; 
} 
int main() {
	int n,W;
	scanf("%d%d",&n,&W);
	int w[n],v[n];
	for(int i=0;i<n;i++) scanf("%d%d",&w[i],&v[i]);
	printf("%lld\n", knapSack(W, w, v, n)); 
	return 0; 
} 



Measured memory_bytes: 79104
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
using namespace std;
 
int main(void){
  string s; cin>>s;
  int ans=0;
  //cout<<s[3]<<endl;
  for(int i=0;i<4;i++){
    if(s[i]=='+') ++ans;
    else --ans;
    //cout<<ans<<endl;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>
#include <stack>
#include <map>
#include <cstdio>
using namespace std;
int N;
int t[86400];
int main() {
   while(cin >> N, N){
       int t[86400+1]={0};
       for(int i=0; i<N; ++i){
           int h, m, s;
           int start, end;
            scanf("%d:%d:%d", &h, &m, &s);
            start = h*3600+m*60+s;
            scanf("%d:%d:%d", &h, &m, &s);
            end = h*3600 + m*60 + s;
            for(int i=start; i<end; ++i) t[i]++;
           
       }
       int ans = 0;
       for(int i=0; i<86400+1; ++i) ans = max(ans, t[i]);
       cout << ans << endl;
   }
   return 0;
}


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

int main(){
	char c;
	cin >> c;
	if(c == 'a'||c == 'i'||c == 'u'||c == 'e'||c == 'o'){
		cout << "vowel" << endl;
	}
	else{
		cout << "consonant" <<endl;
	}
	
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,d,i,t=0,ao=0;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    for(i=c;i>0;i=i-b)
    {
        t=t+1;
    }
    for(i=a;i>0;i=i-d)
    {
        ao=ao+1;
    }
    if(t>ao)
        printf("No");
    else
        printf("Yes");
    return 0;
}


Measured memory_bytes: 1732
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
double fie[55][55];
long long int fieN[55][55];
int main(){
    long long int N,A,B;
    cin>>N>>A>>B;
    long long int vv[100];
    for(int i=0;i<N;i++)cin>>vv[i];
    sort(vv,vv+N);
    for(int i=0;i<N/2;i++)swap(vv[i],vv[N-i-1]);
    fieN[0][0]=1;
    for(int i=0;i<N;i++){
        for(int j=0;j<=N;j++){
            if(fieN[i][j]==0)continue;
            if(fabs(fie[i][j]-fie[i+1][j])<0.000000001){
                fieN[i+1][j]+=fieN[i][j];
            }
            else if(fie[i][j]>fie[i+1][j]){
               fie[i+1][j]=fie[i][j];fieN[i+1][j]=fieN[i][j];
            }
            if(fabs((fie[i][j]*(long double)j+(long double)vv[i])/(long double)(j+1)-fie[i+1][j+1])<0.000000001){
                fieN[i+1][j+1]+=fieN[i][j];
            }
            else if((fie[i][j]*(long double)j+(long double)vv[i])/(long double)(j+1)>fie[i+1][j+1]){
                fie[i+1][j+1]=(fie[i][j]*(long double)j+(long double)vv[i])/(long double)(j+1);fieN[i+1][j+1]=fieN[i][j];
            }

        }
    }
/*
    for(int i=0;i<6;i++){
        for(int j=0;j<6;j++){
            printf("[%5f]",fie[i][j]);
        }
        puts("");
    }
    puts("=======\n");
    for(int i=0;i<6;i++){
        for(int j=0;j<6;j++){
            printf("[%5d]",fieN[i][j]);
        }
        puts("");
    }
*/
    double ans=-1;
    long long int ansN;
    for(int i=A;i<=B;i++){
        if(fieN[N][i]==0)continue;
        if(fabs(ans-fie[N][i])<0.000000001){
            ansN+=fieN[N][i];
        }
        else if(ans<fie[N][i]){
            ans=fie[N][i];
            ansN=fieN[N][i];
        }
    }
    printf("%.12lf\n%lld\n",ans,ansN);
    return 0;
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
edges = Array.new(n+1).map{Array.new()}
m.times do
	a, b = gets.split.map(&:to_i)
	edges[a].push(b)
	edges[b].push(a)
end

# edges.each do |i|
# 	i.uniq!
# end

def dfs(v, edges, visited)
	if visited.length == visited.count{|i| i == true}
		return 1
	end

	ret = 0

	edges[v].each do |i|
		next if visited[i-1] == true
		visited[i-1] = true
		ret += dfs(i, edges, visited)
		visited[i-1] = false
	end

	return ret
end
visited = Array.new(n, false)
visited[0] = true
puts dfs(1, edges, visited)


Measured memory_bytes: 3836
import java.util.Scanner;

public class Main{
	static Scanner s=new Scanner(System.in);
	public static void main(String[] __){
		while(true){
			int bef=s.nextInt(),aft=s.nextInt(),sum=s.nextInt();
			if(bef+aft+sum==0)return;
			int res=0;
			for(int i=1;i<=sum;i++) {
				for(int j=1;j<=sum;j++) {
					int b=(int)(i*(100+bef)/100.0)+(int)(j*(100+bef)/100.0);
					int a=(int)(i*(100+aft)/100.0)+(int)(j*(100+aft)/100.0);
					if(b==sum)
						res=Math.max(res,a);
				}
			}
			System.out.println(res);
		}
	}
}

Measured memory_bytes: 28716
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/
mat(a,1001,1001);
vec(s,1001);
ll cnt(ll i,ll j){
    ll C=0;
    while(1){
        if(i%j==0){
            C++;
            i/=j;
        }else break;
    }
    return C;
}

int main(){
    ll n;
    cin>>n;
    repf(i,1,n+1){
        for(int j=1;j*i<=n;j++){
            a[j*i][i]++;
            a[j*i][0]++;
        }
    }
    for(int i=2;i<=n;i++){
        for(int j=2;j<=i;j++){
            if(a[j][0]==2){
                s[j]+=cnt(i,j);
                s[j]%=MOD;
            }
        }
    }
    ll ans=1;
    rep(i,n+1){
        if(s[i]!=0){
            ans*=(s[i]+1);
            ans%=MOD;
        }
    }
    op(ans);
    /*rep(i,n+1){
        rep(j,n+1){
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }
    rep(i,n+1){
        cout<<s[i]<<endl;
    }*/
    return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define rep(i,n) for(ll i=0;i<n;i++)
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;
// using namespace atcoder;

const ll mod=1000000007;//998244353;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n,q;
  string s;
  cin >> n >> s >> q;

  vector<multiset<ll>> a(26);
  for(ll i=0;i<n;i++){
    ll b=s[i]-97;
    a[b].insert(i);
  }
  for(ll i=0;i<26;i++)a[i].insert(inf);

  vec ans;
  for(ll i=0;i<q;i++){
    ll t;
    cin >> t;
    if(t==1){
      ll j;
      char c;
      cin >> j >> c;
      j--;
      a[s[j]-97].erase(a[s[j]-97].lower_bound(j));
      a[c-97].insert(j);
      s[j]=c;
    }
    else{
      ll l,r;
      cin >>l >> r;
      r--;
      l--;
      ll c=0;
      for(ll j=0;j<26;j++){
        if(a[j].empty())continue;
        ll p=*a[j].lower_bound(l);
        if(p<=r){
          c++;
          //if(i==0)cout << (char)(j+97) << endl;
        }
      }
      ans.push_back(c);
    }
  }

  for(ll i=0;i<ans.size();i++)cout << ans[i] << endl;

  //cout << (char)97 << endl;


  return 0;
}

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

long long n;
int ans=0;
int main()
{
	int i,j,k;
	cin>>n;
	int tmp=0;
	long long x=n;
	while(x>0)
	{
		tmp+=x%10;
		x/=10;
	}
	x=n;
	int c=0;
	ans=tmp;
	while(x>0)
	{
		tmp-=x%10;
		if(x%10>0)
		{
			ans=max(ans,tmp+(int)(x%10-1)+c*9);
		}
		x/=10;
		c++;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if (H==0&&W==0)break;
        for (int i=0;i < H;i++){
            for (int j=0;j < W;j++){
                if ((i%2==1&&j%2==0)||(i%2==0&&j%2==1))cout << ".";
                else cout << "#";
            }cout << endl;
        }cout <<endl;
    }
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
void fl()
{
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
}
int main()
{
//	  fl();
	int k;
	scanf("%d",&k);
	queue<string> que;
	for(char c='1';c<='9';c++)
	{
		string ss="";
		ss+=c;
		que.push(ss);
	}
	int cnt=0;
	while(true)
	{
		string u=que.front();
		que.pop();
		cnt++;
		if(cnt==k)
		{
			cout<<u<<endl;
			return 0;
		}
		char c=u[(int)u.length()-1];
		if(c!='0') 
		{
			string cur=u;
			cur+=(c-1);
			que.push(cur);
		}
		string mid=u;
		mid+=c;
		que.push(mid);
		if(c!='9')
		{
			string cur=u;
			cur+=(c+1);
			que.push(cur);
		}
	}
	return 0;
}
 

Measured memory_bytes: 13824
/**
 * @Author: harshkhajuria
 * @Date:   15-Jul-2019 06:33:52 am
 * @Email:  khajuriaharsh729@gmail.com
 * @Filename: B - Good Distance.cpp
 * @Last modified by:   harshkhajuria
 * @Last modified time: 15-Jul-2019 06:40:07 am
 */

 #include <bits/stdc++.h>
 #define ll long long
 #define mp(a, b) make_pair(a, b)
 #define newline cout << endl;
 #define ff first
 #define ss second
 #define pii pair<int, int>
 #define pll pair<ll, ll>
 #define all(v) v.begin(),v.end()
 using namespace std;

 template <typename S, typename T> ostream& operator<<(ostream& out, pair<S, T> const& p)
 {
 	out << '(' << p.ff << ", " << p.ss << ')';
 	return out;
 }

 template <typename T> ostream& operator<<(ostream& out, vector<T> const& v)
 {
 	int l = v.size();
 	for (int i = 0; i < l - 1; i++)
 		out << v[i] << ' ';
 	if (l > 0)
 		out << v[l - 1];
 	return out;
 }

 template <typename T> void trace(const char* name, T&& arg1) { cout << name << " : " << arg1 << endl; }

 template <typename T, typename... Args> void trace(const char* names, T&& arg1, Args&&... args)
 {
 	const char* comma = strchr(names + 1, ',');
 	cout.write(names, comma - names) << " : " << arg1 << " | ";
 	trace(comma + 1, args...);
 }

 /*Input*/
 const ll size = 100;
 ll n,d;
 vector<vector<ll> > v(size);
 /*Input*/

 int main()
 {
 	//ios::sync_with_stdio(false);
 	//cin.tie(0);
 	//cout.tie(0);
 	clock_t tStart = clock();
 	int test;
 	test = 1;
 	// cin >> test;
 	while (test--) {
    cin >> n >> d;
    for(int i=0;i<n;i++){
      for(int j=0;j<d;j++){
        ll x;
        cin >> x;
        v[i].push_back(x);
      }
    }
    ll ans =  0;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
        ll dist = 0;
        for(int k=0;k<d;k++){
          dist += (v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
        }
        ll base = sqrt(dist);
        if(base*base==dist) ans++;
      }
    }
    cout << ans << endl;
 	}
 #ifdef LOCAL_DEFINE
 	printf("Time taken: %.2fs\n", (double)(clock() - tStart) / CLOCKS_PER_SEC);
 #endif
 	return 0;
 }


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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int main()
{
    

    int n;
    cin>>n;

    int a[n];
    ffor(i,0,n) cin>>a[i];

    if(n==2)
    {
        cout<<a[1]<<" "<<a[0];
        return 0;
    }

    int c=0;
    ffor(i,0,n-2) 
    {
        c=c^a[i];
    }

    int ans[n];

    ans[n-1]=a[n-2]^c;

    bfor(i,n-1,0)
    {
        ans[i]=a[i]^a[i+1]^ans[i+1];
    }

    ffor(i,0,n) cout<<ans[i]<<" ";


    
    return 0;
}



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

long long ans[2];
long long N, a, b, n;

main(){
    scanf("%lld", &N);
    scanf("%lld %lld", ans, ans + 1);
    for(int i = 1; i < N; i++){
        scanf("%lld %lld", &a, &b);
        n = max(((ans[0] - 1) / a + 1), ((ans[1] - 1) / b + 1));
        ans[0] = a * n;
        ans[1] = b * n;
    }
    cout << ans[0] + ans[1] << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> AA(N);
  for(int i=0;i<N;i++) cin >> AA.at(i);
  auto BB=AA;
  sort(BB.begin(), BB.end());
  int max,sec;
  max=BB.at(N-1);
  sec=BB.at(N-2);
  if(max==sec){
  	for(int i=0;i<N;i++) cout << max << endl;
  }
  else{
  	for(int i=0;i<N;i++){
      if(AA.at(i)!=max) cout << max << endl;
      else cout << sec << endl;
    }
  }
}

Measured memory_bytes: 3200
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip() # ignore trailing spaces 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

def abc_c095(a,b,c,x,y):
    ab = x*2
    if y - ab//2 > 0:
        return b*(y - ab//2) + c*ab
    else:
        return c*ab

def main():
    a,b,c,x,y = na()
    ans = a*x + b*y
    ans = min(ans, abc_c095(a,b,c,x,y))
    ans = min(ans, abc_c095(b,a,c,y,x))
    print(ans)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

int print(const int a){
	printf("%d\n", a);
	fflush(stdout);
	char s[7];
	nextstr(s);
	if(s[0]=='M'){
		return 1;
	}else if(s[0]=='F'){
		return 2;
	}else{
		return 0;
	}
}

int main(void){
	int n=nextint();
	int l=1, r=n-1;
	int al, ar;
	if((al=ar=print(0))==0){
		return 0;
	}
	while(1){
		int m=(l+r)/2;
		int f=print(m);
		if(f==0){
			break;
		}
		if((al+l+f+m)&1){
			l=m+1;
			al=f;
		}else{
			r=m-1;
			ar=f;
		}
	}
}


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

string S;

int N, Q, l[100005], r[100005];

int C[100005];

int main(void) {

	cin >> N >> Q;
	cin >> S;
	S = "#" + S;

	for (int i = 1; i <= Q; i++) {
		cin >> l[i] >> r[i];
	}

	C[0] = 0;
	C[1] = 0;
	if (S.substr(1, 2) == "AC") { C[2] = 1; }

	for (int i = 3; i <= N; i++) {
		if (S.substr(i - 1, 2) == "AC") { C[i] = C[i - 2] + 1; }
		else { C[i] = C[i - 1]; }
	}


	/*for (int i = 1; i <= N; i++) {
		cout << "C[" << i << "]= " << C[i] << endl;
	}*/

	for (int i = 1; i <= Q; i++) {
		int ans = C[r[i]] - C[l[i]-1];

		if ((l[i] - 1 >= 0) && S[l[i] - 1] == 'A' && S[l[i]] == 'C') { ans--; }

		cout << ans << endl;
	}



	//system("pause");
	return 0;
}

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

int main() {
    int N, t, i, r = 0;
    cin >> N;
    for (i = 0; i < N; i++) {
        cin >> t;
        if (t%2 == 1) r++;
    }
    (r%2 == 0) ? cout << "YES" : cout << "NO";
    cout << endl;
}

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

#define ll  long long
#define forn(i,n)   for(ll i=0;i<(ll)n;i++)

int minm(int a,int b)
{
    int count=0;
    int num=1;
    while(num<b)
    {
        num+=a;
        num--;
        count++;
    }
    return count;
}
int main()
{
    int a,b;
    cin>>a>>b;
    cout<<minm(a,b)<<endl;
}

Measured memory_bytes: 256