akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
	#include <ext/pb_ds/assoc_container.hpp> // Common file
	#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
	#include <ext/pb_ds/detail/standard_policies.hpp>


	/* 
	*    coder :: ATUL_PANDEY_2608
	*        >>> INDIA <<<
	*/
	using namespace std;
	using namespace __gnu_pbds;

	// #define  part ..
	#define pb(a) push_back(a)
	#define all(a) a.begin(),a.end() 
	#define mod 1000000007
	//#define maxx 200006
	#define ll long long 
	#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
	#define listll vector< long long > 
	#define listi vector< int> 
	#define pii   pair<int , int> 
	#define pll pair<long long , long long > 
	#define minheap priority_queue<long long , vector< long long >, greater<long long > >
	#define rep(i,a,b) for(int i=a;i<b;i++)
	ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


	template < class T > using oset = tree< T , null_type, less  < T  > , rb_tree_tag , tree_order_statistics_node_update > ;


	// end of #define 

	// define globals ...
	const int maxx = 1e6+26;

	//write function from here ...

	ll ft[maxx] ;

	int n;

	void update( int  i , int val){
		
		for(  ++i ; i<=n;i+=(i&-i) ){
			
			ft[i]+=val;		
		}
		
	}

	ll qry( int i ){
		ll ans  =0 ; 
		for ( ; i ; i-=( i&-i)){
			
			ans += ft[i];
		}
		
		return ans ;
		
		
	}







	int Main(){
	   
	   
	   
	   cin>>n;
	   int q;
	   cin>>q;
	   
	   memset( ft, 0 , sizeof(ft));
	   
	   vector < ll > arr(n);
	   for( int i =0 ; i < n;i++){
		   cin>>arr[i];
		   update( i  , arr[i]);
	   
	   }
	   
	   while(q--){
		   int a;
		   cin>>a;
		   
		   if(a== 1){
			   
			   ll l,r;
			   cin>>l>>r;
			   ll val = qry(r) - qry( l );
			   cout<<val<<endl;
			   
		   }
		   else {
			   
			   ll p ,x;
			   cin>>p>>x;
			   //update( p ,arr[p]);
			   update( p ,x);
			   arr[p]+= x;
			   
			   
			   
		   }
		   
		   
		   
	   }




	return 0;

	}






	int main(){
	 quick;
	int t =1; 
	//cin>>t;
	while(t-- )
	 Main();

	 return 0;


	}


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

int main() {
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  printf("%.5f\n", sqrt(pow(abs(x2-x1), 2) + pow(abs(y2-y1), 2)));

  return 0;
}



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

void QQ(){
  for(int i = 1; i < 10 ; i++)
    for(int j = 1 ; j < 10 ; j++)
      cout << i << 'x' << j << '=' << i*j << endl;
}

int main(){
  QQ();
  return 0;
}

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

ll solve() {
    int N; cin >> N;
    vector<vector<int>> A(N, vector<int>(N));
    vector<vector<int>> B(N, vector<int>(N));
    rep(i, 0, N) rep(j, 0, N) {
        int a; cin >> a;
        A[i][j] = B[i][j] = a;
    }
    rep(k, 0, N) rep(i, 0, N) rep(j, 0, N) {
        B[i][j] = min(B[i][j], B[i][k] + B[k][j]);
    }
    rep(i, 0, N) rep(j, 0, N) if(A[i][j] != B[i][j]) return -1;
    vector<vector<int>> need(N, vector<int>(N, 1));
    rep(k, 0, N) rep(i, 0, N) rep(j, 0, i) {
        if(B[i][j] == B[i][k] + B[k][j] && i != k && j != k) need[i][j] = 0;
    }
    ll ans = 0;
    rep(i, 0, N) rep(j, 0, i) if(need[i][j]) ans += B[i][j];
    return ans;
}

int main() {
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 1280
N = int(input())
D = [False for _ in range(N)]
for i in range(N):
    x, y = map(int, input().split())
    if x == y:
        D[i] = True
tmp = 0
for i in range(N - 2):
    if D[i] == D[i + 1] == D[i + 2] == True:
        print('Yes')
        break
else:
    print('No')

Measured memory_bytes: 9180
#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;
    int N = S.size(), red = 0, blue = 0;
    rep(i, N) {
        if (S[i] == '0') red++;
        else blue++;
    }
    cout << min(red, blue) * 2 << "\n";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n,m,t,p=0,a[102];
    scanf("%d",&n);

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

    for(i=0; i<n-1; i++)
    {
        m=i;
        for(j=n-1; j>=i+1; j--)
        {
            if(a[j]<a[j-1])
            {
                swap(a[j],a[j-1]);
            p++;
            }
        }

    }

    for(i=0; i<n-1; i++)
    {
        printf("%d ",a[i]);
    }
    printf("%d\n",a[n-1]);
    printf("%d\n",p);
    return 0;
}

Measured memory_bytes: 3196
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;

ll compare_ll(const void *a, const void *b){
   return *(ll*)a - *(ll*)b;
}

int main(){
    int n, m;
	ll money=0;
    typedef struct{
        ll a,b;
    }st;
 	st store[100000]={0};
    
    scanf("%d%d", &n, &m);
    for(int i=0; i<n; i++){
        scanf("%lld%lld", &store[i].a, &store[i].b);
    }
    qsort( store, n, sizeof(store[0]), compare_ll );
    for(int i=0; i<n; i++){
        if( m > store[i].b ){ m -= store[i].b;	money += (store[i].a * store[i].b); }
        else				{					money += (store[i].a * m); break;   }
    }
    printf("%lld\n", money);
    return 0;
}

Measured memory_bytes: 4664
S=str(input())
temp=0
j=0
if S[0]!='A':
    print('WA')
    exit()
for i in range(2,len(S)-1):
    if S[i]=='C':
        temp+=1
        j=i
if temp!=1:
    print('WA')
    exit()
for i in range(len(S)):
    if i!=0 and i!=j:
        if S[i].isupper():
            print('WA')
            exit()
print('AC') 
exit()    

Measured memory_bytes: 9016
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  string s;cin>>s;
  int res = 0;
  vector<int> mp[10];
  for(int i=0;i<n;++i){
    mp[s[i]-'0'].push_back(i);
  }
  for(int i=0;i<1000;++i){
    string tmp = to_string(i);
    while(tmp.length()<3){
      tmp = '0'+tmp;
    }
    bool f = true;
    int start = -1;
    for(int j=0;j<3;++j){
      int index = tmp[j]-'0';
      int target = upper_bound(mp[index].begin(),mp[index].end(),start)-mp[index].begin();
      if(target==mp[index].size()){f = false;break;}
      start = mp[index][target];
    }
    if(f){
          res++;}
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 512
n, m = map(int, input().split())

pena = [0 for x in range(n + 1)]

clear = [False for i in range(n + 1)]

for i in range(m):
    p, c = input().split()
    p = int(p)
    if clear[p] is False:
        if c == "AC":
            clear[p] = True
        else:
            pena[p] += 1

ans_ac = 0
ans_pena = 0

for pe, cl in zip(pena, clear):
    if cl:
        ans_ac += 1
        ans_pena += pe

print(ans_ac, ans_pena)

Measured memory_bytes: 4760
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define loop(n) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	string s;
	bool alp[26];
	loop(26)
		alp[i] = false;
	cin >> s;
	loop(s.size())
		alp[s[i] - 'a'] = true;
	loop(26)
		if (alp[i] == false) {
			cout << char(i + 'a') << endl;
			return 0;
		}
	cout << "None" << endl;
	return 0;
}

Measured memory_bytes: 512
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
readInt :: BC.ByteString -> Int
readInt = fst . fromJust . BC.readInt
strToInt s = (read :: String -> Int) s

main = do
    n <- readLn :: IO Int
    fsn <- map ((map readInt . BC.words)) <$> replicateM n BC.getLine
    psn <- map ((map readInt . BC.words)) <$> replicateM n BC.getLine
    let fs = listArray (0,(n-1)) fsn
    let ps = listArray (0,(n-1)) psn

    let cd = [0,1]
    let css = listArray (0,4091) [[c0,c1,c2,c3,c4,c5,c6,c7,c8,c9]|c0 <- cd , c1 <- cd , c2 <- cd , c1 <- cd , c3 <- cd , c1 <- cd , c4 <- cd , c5 <- cd , c6 <- cd , c7 <- cd , c8 <- cd , c9 <- cd ,[c0,c1,c2,c3,c4,c5,c6,c7,c8,c9] /= [0,0,0,0,0,0,0,0,0,0] ]
    
    let ans = [profit fs ps (css!i) n | i<-[0..4091]]
    print (maximum ans)
    
profit fs ps cs n  = sum [profita fs ps cs i | i <- [1..n]]
profita fs ps cs i = (ps ! (i-1)) !! n
                     where n = count (fs ! (i-1)) cs 0


count :: [Int] -> [Int] -> Int -> Int
count [] bn n = n
count (a:an) (b:bn) n = if (a==1) && (b==1)
                        then 1 + (count an bn n)
                        else (count an bn n)


Measured memory_bytes: 3068
import fractions


mod = 1000000007

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def modpower(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, y//2)**2 * x % mod

def powerX(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 
    else            : return power(x, y//2)**2 * x

def power(x,y):
    return x ** y


def div(a, b):
    return mul(a, modpower(b, mod-2))

H,W,T = map(int,input().split())

htgcd = fractions.gcd(H,T)
wtgcd = fractions.gcd(W,T)
n = htgcd * wtgcd

p = pow( 2, ( H // htgcd) ,mod ) +pow( 2, (W // wtgcd) , mod) - 3
p += pow(2,fractions.gcd( H // htgcd , W // wtgcd),mod)

#print (p,n)

ans = pow( p , n , mod )

print (ans)



Measured memory_bytes: 63980
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#define ll long long
using namespace std;
const int maxn=500010,mod=1e9+7;
int a,b,c,d,ans;
bool v[maxn];
void read(int &k)
{
	int f=1;k=0;char c=getchar();
	while(c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();
	while(c<='9'&&c>='0')k=k*10+c-'0',c=getchar();
	k*=f;
}
int main()
{
	read(a);read(b);read(c);read(d);
	printf("%d\n",max(0,min(b,d)-max(a,c)));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <string>
using namespace std;
int ncount;
long n;
void search(string num,int num7,int num5,int num3){
  		if(num != ""){
          if(stol(num) > n){
              return;
        	}
        }
          	if(num7 >0 && num5 >0 && num3 >0&&num !=""){
            	ncount += 1;
            }
          	search(num+"7",num7+1,num5,num3);
          	search(num+"5",num7,num5+1,num3);
          	search(num+"3",num7,num5,num3+1);
  	return;
}
int main(void){
	cin >> n;
  	ncount = 0;
  	search("",0,0,0);
    cout << ncount;
    return 0;
}

Measured memory_bytes: 256
import os, sys, re, math

(N, M) = [int(n) for n in input().split()]
S = []
for i in range(M):
    v = [int(n) for n in input().split()]
    S.append(v[1:])
P = [int(n) for n in input().split()]

result = 0
for i in range(2 ** N):
    bulbs = bin(i)[2:].zfill(N)
    all_ok = True
    for j in range(len(S)):
        l = sum([int(bulbs[s - 1]) for s in S[j]])
        all_ok &= (l % 2 == P[j])
    if all_ok:
        result += 1

print(result)


Measured memory_bytes: 3188
def solve(N,T,L,B):
    route = [-1] * (N + 1)
    for _ in range(L):
        x = int(input())
        route[x] = 0
    for _ in range(B):
        y = int(input())
        route[y] = 1
    
    ans = 0
    before = [0] * (N + 1)
    before[0] = 1
    beforebefore = [0] * (N + 1)
    for _ in range(T):
        now = [0] * (N + 1)
        future = [0] *(N + 1)
        for i in range(N):
            for j in range(1,7):
                X = i + j
                if X >= N + 1:#超えた時
                    X = N - (X - N)
                if route[X] == -1:
                    now[X] += before[i]/6
                elif route[X] == 0:
                    future[X] += before[i]/6
                else:
                    now[0] += before[i]/6
        ans += now[-1]
        before = [0] * (N + 1)
        for i in range(N + 1):
            before[i] = now[i] + beforebefore[i]
        beforebefore = future
    print("{:9f}".format(ans))

def main():
    while True:
        N,T,L,B = map(int,input().split())
        if N == 0:
            return
        solve(N,T,L,B)
if __name__ == '__main__':
    main()



Measured memory_bytes: 5636
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int n;
	while (cin >> n && n) {
		int ma = 0, mi = inf;
		rep(i, n) {
			VI a(5); rep(j, 5)cin >> a[j];
			int sum = accumulate(all(a), 0);
			ma = max(ma, sum);
			mi = min(mi, sum);
		}
		Cout2(ma, mi);
	}
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
int main(){
while(1){
int m, f, r;
cin>>m>>f>>r;
if(m == -1 && f == -1 && r == -1) break;
string ans;
if(m == -1 || f == -1) ans = "F";
else if(m + f >= 80) ans = "A";
else if(m + f >= 65) ans = "B";
else if(m + f >= 50) ans = "C";
else if(m + f >= 30){
if(r >= 50) ans = "C";
else ans = "D";
}
else ans = "F";
cout<<ans<<endl;
}
return 0;
}


Measured memory_bytes: 3136
import sys
from collections import Counter

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    N, K = mi()
    A = list(mi())
    c = list(Counter(A).values())
    c.sort()
    print(sum(c[:-K]))


if __name__ == '__main__':
    main()


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

int main(){
	int n ; cin >> n ;
	int ans = 0 ;
	string s ; cin >> s ;
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			for(int k=0;k<=9;k++){
				bool a,b,c ;
				a = b = c = false ;
				for(int l=0;l<n;l++){
					if(!a){
						if(s.at(l)=='0'+i) a = true ;
					}else if(!b){
						if(s.at(l)=='0'+j) b = true ;
					}else if(!c){
						if(s.at(l)=='0'+k) c = true ;
					}
				}
				if(c) ans++ ;
			}
		}
	}
	cout << ans << endl ;
}


Measured memory_bytes: 256
n,a,b = map(int,input().split())

count = 0
for i in range(1,n+1) :
	s = str(i)
	l = len(s)
	x = 0
	for j in range(l):
		x += int(s[j])
	if 	x >= a and x <= b:
#		print(i)
		count += i

print(count)

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


void solve()
{

   int N,K;
   int counter=0;
   int no=0;

   cin>>N>>K;

   vector<int> arr(N,0);

   for(int i=1;i<=N;i++)
   {
       cin>>arr[i];
   }
   for(int i=1;i<=N;++i)
   {
       if(arr[i]>=K)
       {
           counter++;

       }else{
        no--;
        //cout<<"0";
       }

   }

    cout<<counter<<endl;


}

int main()
{
    solve();


    return 0;
}



Measured memory_bytes: 640
#include<stdio.h>
int main ()
{
	long long a,b,k;
	scanf("%lld%lld%lld",&a,&b,&k);
	if(a>k)
		a=a-k;
	else
		if(a+b>k)
			b=b-k+a,a=0;
		else
			a=0,b=0;
	printf("%lld %lld",a,b);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;




int main() {
    ll n;
    cin>>n;
    queue<ll>que;
    for(ll i=1;i<=9;i++){
        que.push(i);
    }
    ll ans=0;
    for(ll i=0;i<n;i++){
        ans=que.front();
        que.pop();
        if(ans%10!=0){
            que.push(10*ans+ans%10-1);
        }
        que.push(10*ans+ans%10);
        if(ans%10!=9){
            que.push(10*ans+ans%10+1);
        }
    }
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 1792
import bisect,collections,copy,heapq,itertools,math,string
import sys
def I():
    #1 line 1 int
     return int(sys.stdin.readline().rstrip())
def LI():
    #1 line n int
     return list(map(int,sys.stdin.readline().rstrip().split()))
def S():
    #1 line 1 string
     return sys.stdin.readline().rstrip()
def LS():
    #1 line n strings
     return list(sys.stdin.readline().rstrip().split())

A=S()

if A[0] == A[1] == A[2] or A[1] == A[2] == A[3]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9992
#include <stdio.h>

int selectionSort(int A[], int N){
	int i, j, t, sw = 0, mini;
	for( i = 0; i < N-1; i++){
		mini = i;
		for( j = i; j < N; j++){
			if(A[j] < A[mini]) mini = j;
		}
		t = A[i]; A[i] = A[mini]; A[mini] = t;
		if( i != mini ) sw++;
	}
	return sw;
}

int main(){
	int A[100], N, i, sw;

	scanf("%d", &N);
	for(i = 0; i < N; i++) scanf("%d", &A[i]);

	sw = selectionSort(A, N);

	for(i = 0; i < N; i++){
		if(i > 0) printf(" ");
		printf("%d", A[i]);
	}	
	printf("\n");
	printf("%d\n", sw);
	
	return 0;
}

Measured memory_bytes: 1032
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int[] sides = new int[3];
		sides[0] = sc.nextInt();
		sides[1] = sc.nextInt();
		sides[2] = sc.nextInt();
		
		//check if even num
		if((sides[0]%2) == 0 || (sides[1]%2) == 0 || (sides[2]%2) == 0){
			System.out.println(0);
		}
		else{
			//all sides odd
			Arrays.sort(sides);
			long l = sides[0];
			l *= sides[1];
			System.out.println(l);
		}
	}
}

Measured memory_bytes: 9936
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  int n; cin >> n;
  string s;
  map<string, int> m;
  int cnt = 0;
  for(int i=0; i<n; i++) {
    cin >> s;
    m[s]++;
    cnt = max(cnt, m[s]);
  }

  for(auto i=m.begin(); i!=m.end(); i++) {
    if (cnt == i->second) cout << i->first << endl;
  }

}

// EOF


Measured memory_bytes: 25216
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        String S0 = scan.next();

        int[] S = new int[S0.length()];
        boolean[] a = new boolean[1000];

        for (int i = 0; i < S0.length(); i++) {
            S[i] = S0.charAt(i) - '0';
        }

        for (int x = 0; x < 1000; x++) {
            int x0 = (x / 100) % 10;
            int x1 = (x / 10) % 10;
            int x2 = x % 10;
            //System.out.println("" + x0 + x1 + x2);

            for (int i = 0; i < N; i++) {
                if (S[i] == x0) {
                    for (int j = i+1; j < N; j++) {
                        if (S[j] == x1) {
                            for (int k = j+1; k < N; k++) {
                                if (S[k] == x2) {
                                   a[x] = true;
                                   break;
                                }
                            }
                            break;
                        }
                    }
                    break;
                }
            }

        }

        int ans = 0;
        for (int i = 0; i < 1000; i++) {
            if (a[i]) ans++;
        }

        System.out.println(ans);

    }

}


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

int main(){
	int b;
	int a[10];
	for (int i=0;i<10;i++){
		cin >> a[i];
		
	}
	for (int d = 0;d<12;d++){
	for (int j = 0;j<9;j++){
		if(a[j]<a[j+1]){
			b = a[j];
			a[j] = a[j+1];
			a[j+1] = b;
		}
	}
	}
	cout << a[0] << endl;
	cout << a[1] << endl;
	cout << a[2] << endl;
	return 0;




}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;bool b[10];
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='B'){int c=0;
      for(int j=i;j>=0;j--){
        if(!b[j]&&s[j]!='B'){c++;}
        b[j]=1;
        if(c)break;
      }
    }
  }
  for(int i=0;i<s.size();i++)if(!b[i])cout<<s[i];
    cout<<endl;
}

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

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

  int ans;
  if (A-B >= C) ans = 0;
  else ans = C - (A-B);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
typedef long long llong;

#define INFTY 2000000000

llong N, W;
llong w_[110];
llong v[110];

llong C[110][100010];

int main() {
	cin >> N >> W;
	for (int i = 1; i <= N; i++) {
		cin >> w_[i] >> v[i];
	}

	for (llong n = 0; n <= N; n++) {
		for (llong w = 0; w <= W; w++) {
			if (n == 0 || w == 0)C[n][w] = 0;
			else if (w - w_[n] < 0)C[n][w] = C[n - 1][w];
			else {
				C[n][w] = max(C[n - 1][w], C[n - 1][w - w_[n]] + v[n]);
			}
		}
	}

	llong out = 0;
	for (llong i = 0; i <= N; i++) {
		out = max(out, C[i][W]);
	}

	cout << out << endl;


	return 0;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
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; }

string s;

int main() {
    cin >> s;
    int slen = s.length();
    int ans = 0;
    for(int i = slen-2; i >= 0; --i) {
        int nlen = i;
        if(nlen % 2 != 0) {
            int sfstlen = nlen/2 + 1;
            // cout << sfstlen << endl;
            string sfst = s.substr(0, sfstlen);
            string ssnd = s.substr(sfstlen, sfstlen);
            if(sfst == ssnd) {
                ans = nlen+1;
                break;
            }
        }
    }
    cout << ans << endl;
}

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

public class Main {
	public static void main(String[] arges) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		int v = Integer.parseInt(line);
		int[] m = new int[v];

		String line2 = sc.nextLine();
		String[] k = line2.split(" ");
		int[] y = new int[m.length];
		for (int i = 0; i < m.length; i++) {
			y[i] = Integer.parseInt(k[i]);
		}
		Arrays.sort(y);
		long sum = 0;
		for (int i = 0; i < y.length; i++) {
			sum += y[i];
		}
		System.out.print(y[0]);
		System.out.print(" " + y[y.length - 1]);
		System.out.println(" " + sum);
	}
}

Measured memory_bytes: 31636
#include <stdio.h>

int main(void) {
    int N, M;
    int L = 1;
    int R = 1;
    int tmp_l, tmp_r;

    scanf("%d %d\n", &N, &M);

    R = N;

    for (int i = 0; i < M; ++i) {
        scanf("%d %d", &tmp_l, &tmp_r);
        if (L < tmp_l) {
            L = tmp_l;
        }
        if (R > tmp_r) {
            R = tmp_r;
        }
    }


    printf("%d\n", L <= R ? R - L + 1 : 0);

    return 0;
}


Measured memory_bytes: 128
n,x=map(int,input().split())
A=list(map(int,input().split()))

ans=0
for i in range(1,n):
  if A[i-1]+A[i]>x:
    sa=A[i-1]+A[i]-x
    ans+=sa
    if A[i]-sa>0:
      A[i]-=sa
    else:
      A[i-1]-=sa-A[i]
      A[i]=0
print(ans)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
 
void count(int v, bool vis[], int dp[], vector<int> adj[]){
    vis[v]=1;
    for(int i=0; i<adj[v].size(); i++){
        if(!vis[adj[v][i]]) count(adj[v][i],vis,dp, adj);
        dp[v] = max(dp[v], 1+dp[adj[v][i]]);
    }
} 
 
int Lpath(vector<int> adj[], int n){
    bool vis[n]={0};
    int dp[n]={0};
    for(int i=1; i<n; i++){
        if(!vis[i]){
            count(i,vis,dp, adj);
        }
    }
    int ans=0;
    for(int i=0; i<n; i++) ans = max(ans, dp[i]);
    return ans;
}
 
int main(){
  int n,m,x,y;
  cin>>n>>m;
  vector<int> adj[n+1];
  for(int i=0; i<m; i++) {
      cin>>x>>y;
      adj[x].push_back(y);
  }
  cout<<Lpath(adj,n+1);
  return 0;
}

Measured memory_bytes: 12792
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)
 
int main(){
  ll A, B;
  cin >> A >> B;
  
 
  set<ll> couho;
  set<ll> sy;
  
  FOR(i, 1, sqrt(A)+1){
    if(A%i==0){
      couho.insert(i);
      couho.insert(A/i);
    }
  }
    
  for(auto i:couho){
    if(A%i==0 && B%i==0) sy.insert(i);
  }
 
  ll count = 0;
  
  for(auto i : sy){
    ll flag = 1;
    if(i!=2){
      FOR(j, 2, sqrt(i)+1){
      if(i%j==0){
          flag = 0;
          break;
        }
      }
    }
    if(flag==1) count++;
  }
  
  cout << count << endl;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;
  int count = 0;
  for(int i = 0; i < A+B+1; i++) {
    if(S.at(i) == '0' || S.at(i) == '1' || S.at(i) == '2' || S.at(i) == '3' || S.at(i) == '4' || S.at(i) == '5' || S.at(i) == '6' || S.at(i) == '7' || S.at(i) == '8' || S.at(i) == '9') {
      count++;
    }
  }
  if(count == A+B && S.at(A) == '-') {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
zzz a
  | (head a) < (last a) = "a < b"--(show $ head a) ++ " < " ++ (show $ last a)
  | (head a) > (last a) = "a > b"--(show $ head a) ++ " > " ++ (show $ last a)
  | (head a) == (last a) = "a == b"--(show $ head a) ++ " = " ++ (show $ last a)


main = do
  a <- getLine
  putStrLn $ zzz $ map (\x -> read x ::Int) $ words a


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

using namespace std;

typedef long long ll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

	int n;
	cin >> n;

	vector<ll> v(n);
	rep(i, n) cin >> v[i];

	int ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			for(int k = j + 1; k < n; k++){
				ll a = min({v[i], v[j], v[k]});
				ll c = max({v[i], v[j], v[k]});
				ll b = v[i] + v[j] + v[k] - a - c;
				if(a != b && b != c && a + b > c) {
					// cout << i << " " << j << " " << k << endl;
					ans++;
				}
			}
		}
	}

	cout << ans << endl;
}


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

int main() {
  string d;
  cin >> d;
  if(d == "SAT") cout << 1 << endl;
  else if(d == "FRI") cout << 2 << endl;
  else if(d == "THU") cout << 3 << endl;
  else if(d == "WED") cout << 4 << endl;
  else if(d == "TUE") cout << 5 << endl;
  else if(d == "MON") cout << 6 << endl;
  else if(d == "SUN") cout << 7 << endl;
}

Measured memory_bytes: 3596
times = [input() for _ in range(5)]

res = 0
for i in times:
  res += (int(i)//10)*10+(10 if i[-1] != "0" else 0)
  
time = []
for j in times:
  time.append((int(j[-1]) if j[-1] != "0" else 10))
  
print(res - 10 + min(time))

Measured memory_bytes: 9192
N,M,Q = map(int,input().split())
req = []
ans = 0
for i in range(Q):
    req.append(list(map(int,input().split())))

import itertools
lists = list(itertools.combinations_with_replacement(range(1,M+1),N))

def check(ls):
    count = 0
    for i in range(Q):
        if ls[req[i][1] - 1] - ls[req[i][0] - 1] == req[i][2]:
            count += req[i][3]
    return count

for a in lists:
    s = check(a)
    if s > ans:
        ans = s

print(ans)

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

int f(int x){
	return (x*x);
}

int main(){
	int d,s;

	while( cin >> d ){
		s = 0;
		for(int i=1 ; (d*i)<=(600-d) ; i++){
			s += f(d*i)*d;
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
using namespace std;
int main(){
  int sx,sy,tx,ty;
  cin >> sx>> sy>> tx>>ty;
  for(int i=0;i<(ty-sy);i++) cout <<"U";
  for(int i=0;i<(tx-sx);i++) cout<<"R";
  for(int i=0;i<(ty-sy);i++) cout <<"D";
  for(int i=0;i<(tx-sx);i++) cout <<"L";
  cout <<"L";
  for(int i=0;i<(ty-sy+1);i++) cout <<"U";
  for(int i=0;i<(tx-sx+1);i++) cout <<"R";
  cout <<"DR";
  for(int i=0;i<(ty-sy+1);i++) cout <<"D";
  for(int i=0;i<(tx-sx+1);i++) cout <<"L";
  cout <<"U"<<endl;
}


Measured memory_bytes: 256
s=input()
al=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
for i in range(26):
  if al[i] not in s:
    print(al[i])
    exit()
print('None')

Measured memory_bytes: 9176
#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect

n,m=map(int,input().split())
edge=[list(map(int,input().split())) for _ in range(m)]
           
inf=10**9
nextm=[[inf]*n for _ in range(n)]

for i in range(n):
    nextm[i][i]=0
for i in range(m):
    to,f,weight=edge[i]
    nextm[to-1][f-1]=weight
    nextm[f-1][to-1]=weight

for k in range(n):
    for i in range(n):
        for j in range(n):
            if nextm[i][j]>nextm[i][k]+nextm[k][j]:
                nextm[i][j]=nextm[i][k]+nextm[k][j]
res=0               
for i in range(m):
  a,b,c=edge[i]
  if c>nextm[a-1][b-1]:
    res+=1
print(res)

Measured memory_bytes: 42348
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    vector<vector<int>> c(3, vector<int> (3));
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }


    vector<int> a(3); a[0] = 0;
    vector<int> b(3);
    for(int i = 0; i < 3; i++) b[i] =c[0][i] - a[0];
    for(int i = 0; i < 3; i++) a[i] =c[i][0] - b[0];

    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            if(c[i][j] != a[i] + b[j]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

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


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

int main() {
  int x;
  cin >> x;
  
  int a1, a2, a3, a4;
  
  a1 = x/1000;
  a2 = (x%1000)/100;
  a3 = (x%100)/10;
  a4 = x%10;
  cout << ((a2 != a3)? "No" : ((a1 == a2 || a4 == a2)? "Yes" : "No")) << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
using namespace std;
#define int long long
#define mn 3005
#define inf 777777777777777777
#define ZLA "Press F"
#define mod 1000000007

int n,a[mn],ans;

void input()
{
	cin >> n;
	for (int i=1;i<=n;i++)
	{
		cin >> a[i];
		ans+=(a[i]-1);
	}
}

void output()
{
	cout << ans;
}

signed main()
{
//	freopen(ZLA".inp", "r", stdin);
//	freopen(ZLA".out", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	input();
	output();
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



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

	int cnt = 0;
	for (int i = 1; i < n - 1; i++) {
		if ((p[i] < p[i - 1]) ^ (p[i] < p[i + 1])){
		cnt++;
}
	}

	cout << cnt << endl;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PI (acos(-1))
#define ct cout<<
#define cn cin>>
#define spc <<" "<<
#define nl puts("")
#define _fl(x) puts("FLAG " #x);
#define  _(x)  cout<< #x <<" is "<< x <<endl;
#define fs first
#define sc second
#define pb push_back
#define all(v)  (v).begin(), (v).end()
#define _109 (1000000000)
#define _0(arr) memset(arr,0,sizeof ( arr ) )
#define _1(arr) memset(arr,-1,sizeof ( arr ) )
#define _ninp(n,arr) for(int i=0; i<n;i++)cin>>arr[i];
#define _nout(n,arr) for(int i=0; i<n;i++)cout<<arr[i]<<" \n"[i==n-1];
double _eps=1e-6;
long long gcd(long long a, long long b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main() {
ll n,m;
    cn n;
    for (int i = 1; i <10; ++i)
    {
      if(n%i==0 && n/i<10){
        ct "Yes";nl;
        return 0;
      }
    }
ct "No";
nl;





    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int dx[] = {0,0,-1,-1,-1,1,1,1};
const int dy[] = {-1,1,0,-1,1,-1,0,1};
int a[2000][2000];


int main() {
	int n, m;
	scanf("%d%d", &n,&m);
	// for (int i = 1; i <= n; i++) {
	// 	for (int j = 1; j <= m; j++) {
	// 		a[i][j] = 0; //代表着每张牌up
	// 	}
	// }
	// for (int i = 1; i <= n; i++) {
	// 	for (int j = 1; j <= m; j++) {
	// 		a[i][j] = 1-a[i][j];
	// 		for (int k = 0; k < 8; k++) {
	// 			int nx = i + dx[k];
	// 			int ny = j + dy[k];
	// 			a[nx][ny] = 1 - a[nx][ny];
	// 		}
	// 	}
	// }
	// int ans = 0;
	// for (int i = 1; i <= n; i++) {
	// 	for (int j = 1; j <= m; j++) {
	// 		if (a[i][j] == 1) ans++;
	// 	}
	// }
	// //cout << ans << endl;
	// for (int i = 1; i <= n; i++) {
	// 	for(int j = 1; j <=m; j++) {
	// 		printf("%d ", a[i][j]);
	// 	}
	// 	cout << endl;
	// }
	long long ans = 0;
	if (n == 1 && m == 1) ans = 1;
	else if (n == 1) ans = m - 2;
	else if (m == 1) ans = n - 2;
	else if (n == 2 || m == 2) ans = 0;
	else ans = 1LL * (n - 2) * (m - 2);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    buf = input()
    buflist = buf.split()
    N = int(buflist[0])
    M = int(buflist[1])
    LR = []
    for i in range(M):
        buf = input()
        buflist = buf.split()
        LR.append((int(buflist[0]), int(buflist[1])))
    LR = list(sorted(LR))
    left_limit = LR[-1][0]
    LR = list(sorted(LR, key=lambda x:x[1]))
    right_limit = LR[0][1]
    print(max(0, right_limit - left_limit + 1))

if __name__ == '__main__':
    main()


Measured memory_bytes: 18736
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int r, d, x;

void solve() {
  REP(i, 10) {
    x = r * x - d;
    cout << x << endl;
  }
}

int main() {
  cin >> r >> d >> x;
  solve();
}


Measured memory_bytes: 256
s = input()
lst = [int(i) for i in s]
f1 = lambda x: '+' if x else '-'
f2 = lambda x: 1 if x else - 1
for i in range(16):
  tmp1 = [f1(i >> x & 1) for x in range(3)]
  tmp2 = [f2(i >> x & 1) * lst[x + 1] for x in range(3)]
  if lst[0] + sum(tmp2) == 7:
    print(''.join([s[i] + tmp1[i] for i in range(3)] + [s[3] + '=7']))
    break

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int c(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a < b ? -1 : a > b;
}

int N;
int A[333333];

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	qsort(A, N, sizeof(*A), c);
	for (i = 1; i < N; i++) {
		if (A[i - 1] == A[i]) {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0;
}


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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int s;
int a[101010];

int f(int n) {
  if (n % 2 == 0) return n / 2;
  return 3 * n + 1;
}

signed main() {
  cin >> s;

  set<int> st;
  a[1] = s;
  st.insert(s);
  for (int i = 1; i < 101010; i++) {
    a[i + 1] = f(a[i]);
    if (EXIST(st, a[i + 1])) {
      cout << i + 1 << endl;
      return 0;
    }
    st.insert(a[i + 1]);
  }
  return 0;
}


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

int main() {
  int A,B,C,X; cin >>A >>B >>C >>X;
  int ans=0;
  rep_eq(i,0,A) {
    rep_eq(j,0,B) {
      rep_eq(k,0,C) {
        int temp=500*i+100*j+50*k;
        if (temp==X) ans++;
      }
    }
  }
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 256
from sys import stdin, setrecursionlimit


def gcd(x, y):
    if x % y == 0:
        return y
    return gcd(y, x % y)


def main():
    input = stdin.buffer.readline
    k = int(input())
    g = []
    for i in range(1, k + 1):
        gi = []
        for j in range(1, k + 1):
            gi.append(gcd(i, j))
        g.append(gi)
    ans = 0
    for a in range(k):
        for b in range(k):
            for c in range(k):
                tmp = g[a][b] - 1
                ans += g[tmp][c]
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 70380
import java.util.Scanner;

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

		System.out.printf("a %s b\n", (a > b) ? ">" : (a == b) ? "==" : "<");
	}
}

Measured memory_bytes: 17296
while(True):
	H,W=list(map(int,input().split()))
	if H==0 and W==0:
		break
	l1=""
	for i in range(W):
		if i%2==0:
			l1+="#"
		else:
			l1+="."
	l1+="\n"
	l2=""
	for i in range(W):
		if i%2==0:
			l2+="."
		else:
			l2+="#"
	l2+="\n"

	l=""
	for i in range(H):
		if i%2==0:
			l+=l1
		else:
			l+=l2

	print(l)

Measured memory_bytes: 7608
#include<bits/stdc++.h>
#define int long long
#define PB push_back
#define fi first
#define se second
using namespace std;
typedef pair<int,int> pii;
static const int inf =1ll<<60;
static const int MAX_N = 1e6;
struct edge{
    int to;
    int cost;
    edge(){}
    edge(int p1,int p2){
        to=p1;
        cost=p2;
    }
};

int N,M,C;
int maxx=0;
vector<pii> V;
vector<edge> G[MAX_N+5];
int d[MAX_N+5];
bool used[MAX_N+5];
int sum;
int ans=inf;

void dijkstra(){
    priority_queue<pii,vector<pii> ,greater<pii> > que;
    fill(d,d+MAX_N,inf);
    d[0]=0;
    que.push(pii(0,0));
    while(!que.empty()){
        pii p=que.top();
        que.pop();
        int v=p.se;
        if(d[v]<p.fi)continue;
        for(int i=0;i<G[v].size();++i){
            edge e = G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(pii(d[e.to],e.to));
            }
        }
    }
}

signed main(){
    cin>>N>>M>>C;
    for(int i=0;i<M;++i){
        int a,b,d;
        cin>>a>>b>>d;
        a--;b--;
        G[a].PB(edge(b,d));
        G[b].PB(edge(a,d));
        sum+=d;
    }
    dijkstra();
    //int X=0;
    for(int i=0;i<N;++i){
        V.PB(pii(d[i],i));
    }
    sort(V.begin(),V.end());
    fill(used,used+N,false);
    for(int i=0;i<V.size();++i){
        int now=V[i].se;
        for(int j=0;j<G[now].size();++j){
            edge e=G[now][j];
            if(used[e.to]==true){
                sum-=e.cost;
            }
            used[now]=true;
        }
        used[now]=true;
        ans=min(ans,V[i].fi*C+sum);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 45752
#include <iostream>

using namespace std;

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

	cin >> W >> H >> x >> y;

	int d = 0;
	if (x == W - x && y == H - y) {
		d = 1;
	}

	printf("%.9lf %d\n", W * H / 2.0, d);

	return 0;
}

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

using namespace std;
typedef long long ll;

const int maxn = 1e5 + 30;

ll ans[maxn];

int main(){
  int n; cin >> n;
  ll L; cin >> L;
  ll T; cin >> T;
  vector<ll> cw;
  vector<int> cw_ids;
  vector<ll> ccw;
  vector<int> ccw_ids;
  for(int i=0;i<n;i++){
    ll x; int w; cin >> x >> w;
    if(w == 1){
      cw.push_back(x); cw_ids.push_back(i);
    }
    else {ccw.push_back(x); ccw_ids.push_back(i);}
  }
  vector<ll> final_positions;
  for(ll e : ccw){
    ll eprime = (e - T) % L;
    eprime = (eprime + L) % L;
    final_positions.push_back(eprime);
    if(cw.size() == 0){
      cout << eprime << "\n";
    }
  }
  for(ll e : cw){
    ll eprime = (e + T) % L;
    final_positions.push_back(eprime);
    if(ccw.size() == 0){
      cout << eprime << "\n";
    }
  }
  if(ccw.size() == 0 || cw.size() == 0) {
    //assert(false);
    return 0;
  }
  sort(final_positions.begin(), final_positions.end());
  //that was the easy part.
  int me = cw[0]; // every time I bump into someone, my label increases by 1.
  ll num_bumps = 0;
  for(ll x : ccw){
    int t2 = -1;
    if(x < cw[0]){
      t2 = L - (cw[0] - x);
    }
    else{
      t2 = x - cw[0];
    }
    if(t2 > 2 * T) continue;
    num_bumps += 1 + (2 * T - t2) / L;
  }
  int my_label = (cw_ids[0] + num_bumps) % n;
  ll my_position = (cw[0] + T) % L;
  int ee = upper_bound(final_positions.begin(), final_positions.end(), my_position) - final_positions.begin() - 1;
  assert(final_positions[ee] == my_position);
  for(int l = my_label; ; l = (l + 1) % n, ee = (ee + 1) % n){
    ans[l] = final_positions[ee];
    if((l - (my_label - 1)) % n == 0) break;
  }
  for(int i=0;i<n;i++){
    cout << ans[i] << "\n";
    assert(0 <= ans[i] && ans[i] < L);
  }
}


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

long long cut2(long long n , long long m){
	long long A,B,C;
	long long ans=1<<30;
	for(int i=1;i<n;i++){
		A=i*m;
		B=(n-i)*(m/2);
		C=(n-i)*(m-m/2);
		long long MAX=max({A,B,C});
		long long MIN=min({A,B,C});
		ans=min(ans,abs( MAX-MIN));
	}
	return ans;
}

long long cut1(long long n , long long m){
	long long A,B,C;
	long long ans=1<<30;
	for(int i=1;i<n;i++){
		A=i*m;
		B=(n-i)/2*m;
		C=(n-i-(n-i)/2)*m;
		long long MAX=max({A,B,C});
		long long MIN=min({A,B,C});
		ans=min(ans,abs( MAX-MIN));
	}
	return ans;
}

int main() {
	long long n,m;
	cin>>n>>m;
	cout<< min({cut2(m,n),cut2(n,m),cut1(n,m),cut1(m,n)});
}

Measured memory_bytes: 256
readLine()!
var D = [Int: Int]()
readLine()!.characters.split(" ").map({Int(String($0))!}).forEach {
  D[$0] = (D[$0] ?? 0) + 1
}
readLine()!
var ans = "YES"
readLine()!.characters.split(" ").map({Int(String($0))!}).forEach {
  if (D[$0] ?? 0) > 0 {
    D[$0] = (D[$0] ?? 0) - 1
  } else {
    ans = "NO"
  }
}
print(ans)

Measured memory_bytes: 27688
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int a, b;
    cin >> a >> b;
    if (b % a == 0) cout << a + b << endl;
    else            cout << b - a << endl;
    return 0;
}


Measured memory_bytes: 3576
#include <cstdio>
#define REP(i,n) for(int i=0;i<(n);i++)

int main(void) {
    int n;
    const int N = 10;
    while(~scanf("%d", &n)) {
        int ans = 0;
        REP(a,N) REP(b,N) REP(c,N) REP(d,N) {
            if(a+b+c+d == n) ans++;
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
    int n,i;
    scanf("%d",&n);
    for (i=1;i<=n;i++){
        if (i%3==0||i%10==3||i%10000%1000%100/10==3||i%10000%1000/100==3||i%10000/1000==3){
            printf(" %d",i);
        }
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2088
{-# LANGUAGE BangPatterns #-}
 
module Main
  ( main
  )
where
 
import           Control.Applicative
import           Control.Monad
import           Control.Monad.ST
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import           Data.Ord
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import qualified Data.Vector.Unboxed           as UV

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine


main = do
  [w, h, n] <- readIntList
  arr <- forM [1..n] (const readIntList)
  let (lx, ux, ly, uy) = foldl' update (0, w, 0, h) arr
  print $ (max (ux - lx) 0) * (max (uy - ly) 0)

update (lx, ux, ly, uy) [x, y, a]
  | a == 1 = (max x lx, ux, ly, uy)
  | a == 2 = (lx, min x ux, ly, uy)
  | a == 3 = (lx, ux, max y ly, uy)
  | a == 4 = (lx, ux, ly, min y uy)


Measured memory_bytes: 508
#include <iostream>

using namespace std;

int main(){

  int n;
  int d[100001] = {0};
  int ans = 0;

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

  int sum = 0;
  for(int i = 0; i < 100001; i++){

    sum += d[i];
    
    if(sum == n / 2){
      ans++;
    }

    if(sum > n / 2){
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
    int N; 
    cin >> N;
    vector<int> vec(N);
    for(int i=0; i<N; i++){
        cin >> vec.at(i);
    }
    int count=1;
    bool first = false;
    for(int i=0; i<N; i++){
        if(vec.at(i)== count){
            count++;
            first = true;
        }
    }
    if(first){
        cout << N - count + 1 << endl;
    }
    else{
        cout << -1 << endl;
    }
}


Measured memory_bytes: 1024