akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  int h, w;
  cin >> h >> w;

  vector<string> s(h);
  REP(i,h){
    cin >> s[i];
  }

  vector<pii> v;
  
  for(int i = 0; i < h; ++i){
    REP(j,w){
      if(s[i][j] == 'B'){
        v.pb(MP(i, j));
        break;
      }
    }
    for(int j = w - 1; j >= 0; --j){
      if(s[i][j] == 'B'){
        v.pb(MP(i, j));
        break;
      }
    }
  }

  for(int j = 0; j < w; ++j){
    REP(i,h){
      if(s[i][j] == 'B'){
        v.pb(MP(i, j));
        break;
      }
    }
    for(int i = h - 1; i >= 0; --i){
      if(s[i][j] == 'B'){
        v.pb(MP(i, j));
        break;
      }
    }
  }

 
  int ans = 0;
  REPI(itr1, v){
    REPI(itr2, v){
      ans = max(ans, abs(itr1->first - itr2->first) + abs(itr1->second - itr2->second));
    }
  }

  cout << ans << endl;

  return 0;
}




Measured memory_bytes: 3944
N, C = map(int, input().split())
M = 10 ** 5 * 2 + 5
T = [[0] * M for i in range(C)]
for i in range(N):
    s, t, c = map(int, input().split())
    s = 2 * s - 1
    t = 2 * t
    c -= 1
    T[c][s] += 1
    T[c][t] -= 1

TT = [[0] * (2 * N) for i in range(C)]
for i in range(C):
    for j in range(1, M):
        T[i][j] += T[i][j - 1]

num = 0
for j in range(M):
    tmp = 0
    for i in range(C):
        if T[i][j] >= 1:
            tmp += 1

    num = max(tmp, num)
print(num)

Measured memory_bytes: 135556
import sys
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
def main():
  n=int(input())
  A=sorted(list(map(int,input().split())))
  B=list(map(int,input().split()))
  C=sorted(list(map(int,input().split())))
  lc=len(C)
  ans=0
  for b in B:
    ma = bisect_left(A, b)
    mc = lc-bisect_right(C, b)
    ans += ma*mc
  print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 29140
coin_list = []
for i in range(3):
    s = int(input())
    coin_list.append(s)
target = int(input())
counter = 0

for a in range(coin_list[0]+1):
    for b in range(coin_list[1]+1):
        for c in range(coin_list[2]+1):
            total = 500*a + 100*b + 50*c
            if total == target:
                counter = counter + 1
            if total > target:
                break

print(counter)

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

vector<vector<int>> g;

int get_cutsize(int par, int v, int rem) {
    int sum = (rem < 0 ? 1 : 0);
    for (int child : g[v]) {
        if (child == par) continue;
        sum += get_cutsize(v, child, rem-1);
    }
    return sum;
}

int main(void){
    int n, k;
    cin >> n >> k;
    g.resize(n);
    vector<int> a(n),b(n);
    rep(i,n-1){
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }

    int res = n;
    if (k%2 == 0) {
        rep(v,n) {
            res = min(res, get_cutsize(-1, v, k/2));
        }
    } else {
        rep(i,n-1) {
            res = min(res, get_cutsize(a[i], b[i], k/2) + get_cutsize(b[i], a[i], k/2));
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int n,ans=0;
  cin>>n;
  auto judge_prime=[](int a){
    for (int i = 2; i <= sqrt(a); ++i)
    {
      if(a%i==0) return false;
    }
    return true;
  };
  for (int i = 0; i < n; ++i)
  {
    int a;
    cin>>a;
    if(judge_prime(a)) ans++;
  }
  cout<<ans<<endl;
}


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

using i64 = long long;
using u64 = unsigned long long;

const int mod = (int) 1e9+7;

void __print() {cerr << "]\n";}

template<typename T, typename... V>
void __print(T t, V... v)
{ cerr << t; if(sizeof...(v)) cerr << ", "; __print(v...);}

#define dbg(x...) cerr << "[" << #x << "] = [", __print(x)
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(NULL)


struct Matrix{
    int row, col;
    vector<vector<i64>> mat;
    Matrix(int _row, int _col) {
        row = _row;
        col = _col;
        mat = vector<vector<i64>> (row, vector<i64>(col));
    }
    Matrix operator*(const Matrix m) {
        int r = m.row;
        int c = m.col;
        assert(col == r);
        Matrix res(col, r);
        for(int i = 0; i < row; i++) {
            for(int j = 0; j < c; j++) {
                for(int k = 0; k < col; k++) {
                    res.mat[i][j] += mat[i][k] * m.mat[k][j];
                    res.mat[i][j] %= mod;
                }
            }
        }
        return res;
    }
};

int main()
{
    int n;
    i64 k;
    scanf("%d%lld", &n, &k);
    Matrix m(n, n);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            scanf("%lld", &m.mat[i][j]);
        }
    }
    Matrix res(n, n);
    for(int i = 0; i < n; i++) res.mat[i][i] = 1;
    while(k) {
        if(k & 1) {
            res = res * m;
        }
        m = m * m;
        k/=2;
    }
    i64 ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            ans += res.mat[i][j];
        }
    }
    printf("%lld\n", ans%mod);
}


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

int main (){
    int N,A=0,B=0;
    cin >> N;
    vector<int> vec(N);
    for (int i=0; i<N; i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());

    for(int i=0; i<N; i++){
        if (i % 2 == 0 ){
            A += vec.at(i);
        }else{
            B += vec.at(i);
        }
    }
    cout << A - B << endl;

}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int N,M;
    cin >> N >> M;
    bool ret = true;
    vector<int> vec(N,-1);
    for(int i = 0;i < M;i++) {
        int A,B;
        cin >> A >> B;
        A--;
        if(vec.at(A) == -1) {
            vec.at(A) = B;
        }
        else if(vec.at(A) != B) {
            ret = false;
        }
    }
    if(ret == false || (N != 1 && vec.at(0) == 0)) {
        cout << -1 << endl;
        return 0;
    }
    for(int i = 0;i < N;i++) {
        if(i == 0 && vec.at(i) == -1) {
            if(N == 1) {
                cout << 0;
            }
            else {
                cout << 1;
            }
        }
        else if(vec.at(i) == -1) {
            cout << 0;
        }
        else {
            cout << vec.at(i);
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int cnt=0;
        
        if(n/10==9){
            cnt++;
        }
            n = n%10;
            
        if(n==9){
            cnt++;
        }

        if(cnt>0){
        System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }

}


Measured memory_bytes: 24020
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------
long Pow(long X,int r){
	if(r == 0){
		return 1;
	}
	if(r % 2){
		return min(Pow(X,r-1)*X,(long)1000000000001);
	}
	else{
		long temp = Pow(X,r/2);
		if(temp > 1000000){
			return 1000000000001;
		}
		return temp*temp;
	}
}
void Calc(){
	long N = rel();
	long P = rel();
	if(N > 50){
		cout << 1 << endl;
		return;
	}
	if(N == 1){
		cout << P << endl;
		return;
	}
	if(N > 50){
		cout << 1 << endl;
		return;
	}
	long max = 1;
	for(long x=2;;x++){
		long c = Pow(x,N);
		if(c > P){
			break;
		}
		else{
			if(P % c == 0){
				max = x;
			}
		}
	}
	cout << max << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
//
// Created by 和田邦彦 on 2020/02/16.
//

#include <iostream>
#include <string>

using namespace std;

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

    int len = s.length();
    for (int i = 0; i < len; i++) {
        cout << "x";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;

int main(){
    ll S;
    cin >> S;
    ll W;
    cin >> W;
    for(ll i=0;i<6000000000;i++){
        swap(S,W)
    ;}
    if(S<=W)cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
    return 0;
}


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

using namespace std;

const int N=1e6+10;
int n;
string s;
int psum[N],psumr[N];
int main(){
        cin>>n>>s;
        for(int i=1;i<=n;i++) psum[i]=psum[i-1]+(s[i-1]=='E');
        for(int i=n;i>=1;i--) psumr[i]=psumr[i+1]+(s[i-1]=='E');
        int ans=n;
        for(int i=1;i<=n;i++) ans=min(ans,i-1-psum[i-1]+psumr[i+1]);
        cout<<ans;
}


Measured memory_bytes: 5892
def main():
    n = int(input())

    chars_list = [
        ['a'],
        ['aa', 'ab'],
        ['aaa', 'aab', 'aba', 'abb', 'abc'],
        ['aaaa', 'aaab', 'aaba', 'aabb', 'aabc', 'abaa', 'abab', 'abac', 'abba', 'abbb', 'abbc', 'abca', 'abcb', 'abcc', 'abcd']
    ]
    a = 'abcdefghijkl'

    if n <= 4:
        for s in chars_list[n-1]:
            print(s)
    else:
        while n - 4 > 0:
            appends_list = []
            for char in chars_list[-1]:
                for alphabet in a:
                    appends_list.append(char+alphabet)
                    if alphabet not in char:
                        break
            chars_list.append(appends_list)
            n -= 1

        for s in chars_list[-1]:
            print(s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14532
#!/usr/bin/env ruby
_ = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)

return puts 0 if a.include?(0)

ans = 1

a.each do |a_i|
  ans *= a_i
  if ans > 10**18
    ans = -1
    break
  end
end

puts ans


Measured memory_bytes: 23468
#include<iostream>
using namespace std;
long n,t,h,mh;
main()
{
	cin>>n>>t;
	for(int i=0;i<n;i++)
	{
		cin>>h;
		if(mh<h)mh=h;
		t-=h;
		if(t<0)cout<<1<<endl;
		else cout<<t/mh+2<<endl;
	}
}


Measured memory_bytes: 3112
n = int(input())
perputation = list(map(int, input().split()))
cnt = 1
last_min = perputation[0]

if n == 1:
    print("1")
else:
    for i in range(1, n):
        if last_min >= perputation[i]:
            cnt += 1
            last_min = perputation[i]
    print(cnt)

Measured memory_bytes: 24744
#include <stdio.h>
#define N 100000
#define T 50000
 
main()
{
 
  int i,j;
  int A[N],B[T];
  int n,t,left,right,mid,key=0,f=0;
   
  scanf("%d",&n);
   
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }
 
  scanf("%d",&t);
   
  for(j = 0; j < t; j++){
    scanf("%d",&B[j]);
     
    left = 0;
    right = n;
     
    while(left < right){
      mid = (left + right)/2;
       
      if(B[j] == A[mid]){
    f++;
    break;
      }
       
      if(B[j] > A[mid]){
    left = mid + 1;
      }
       
      else if(B[j] < A[mid]){
    right = mid;
      }
    }
  }
   
   
   
  printf("%d\n",f);
   
  return 0;
   
}

Measured memory_bytes: 1188
#include <stdio.h>

int main(void){

  int k;
  scanf("%d\n", &k);

	int s[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  printf("%d\n", s[k-1]);

  return 0;
}

Measured memory_bytes: 128
import numpy as np
import collections

def main():
    S = str(input())
    n = len(S)

    T = [-1 for i in range(n+1)]
    T[-1] = 0
    # for i in range(n):
    #     #print(S[i:])
    #     T[i] = int(S[i:]) % 2019
    # print(T)
    b = [1 for i in range(n)]
    for i in reversed(range(n-1)):
        b[i] = b[i+1]*10 % 2019
    #print(b)

    # for i in reversed(range(n)):
    #     T[i] = (int(S[i])*10**(n-1 -i) + T[i+1]) % 2019
    # print(T)

    for i in reversed(range(n)):
        T[i] = (b[i]*int(S[i]) + T[i+1]) % 2019
    #print(T)


    C = collections.Counter(T)
    #print(C) # dict 型のサブクラス，Counter
    ans = 0
    for value, count in C.items():
        ans += int(count*(count-1)/2)
    print(ans)

if __name__ == "__main__":
    main()

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

int main() {
	int n, a, p2 = 0, min = 10000;
	cin >> n;
	for (int i = 1; i <= n; i++) {
	    cin >> a;
	    while (a % 2 == 0) {
	        a = a / 2;
	        p2++;
	    }
	    if (min > p2) min = p2;
	    p2 = 0;
	}
	cout << min;
	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
drinkList = [list(map(int, input().split())) for i in range(N)]

drinkList.sort()
drinkCount = 0
money = 0

while drinkCount < M :
    for i in range(N) :
        if M - drinkCount > drinkList[i][1] :
            money += drinkList[i][0] * drinkList[i][1]
            drinkCount += drinkList[i][1]
        else :
            money += drinkList[i][0] * (M - drinkCount)
            drinkCount += M - drinkCount
            break

print(money)


Measured memory_bytes: 27880
#include <bits/stdc++.h>
using namespace std;
int main() {
   int n;
   int a[100003]={};
   cin>>n;
   for(int i=1;i<=n;i++)
   cin>>a[i];

   long long int dp[n+2]={};
   dp[2]=abs(a[2]-a[1]);
   for(int i=3;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];

}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  ll a,b,k;
  cin >> a >> b >> k;

  for (int i = 0; i < k; ++i) {


    if (i % 2 == 0) {
      if (a % 2 == 1) {
        a -= 1;
      }
      b += a / 2;
      a /= 2;
    } else {
      if (b % 2 == 1) {
        b -= 1;
      }
      a += b / 2;
      b /= 2;
    }
  }

  cout << a << " " << b << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);

		StringTokenizer st;
		int a,b;
		for (String line; (line = in.readLine())!=null;) {
			st = new StringTokenizer(line);

			a = Integer.parseInt(st.nextToken());
			b = Integer.parseInt(st.nextToken());

			if((a<0&&b>0)||(a==0||b==0)){
				out.println("Zero");
			}else if((a>0&&b>0)||(Math.abs(Math.abs(b)+Math.abs(a))%2!=0)){
				out.println("Positive");
			}else{
				out.println("Negative");
			}

		}

		out.close();
		in.close();
	}
}


Measured memory_bytes: 21204
#include <cstdio>

using namespace std;

int main() {
	/*
	int p[10][10];
	for (int i=0; i<10; i++) {
		for (int j=0; j<10; j++) {
			p[i][j] = 0;
		}
	}
	int x,y,size;
	int dx[] = { 0, 0,-1, 1,-1,-1, 1, 1, 0, 0,-2, 2};
	int dy[] = {-1, 1, 0, 0,-1, 1,-1, 1,-2, 2, 0, 0};
	while (scanf("%d,%d,%d", &x, &y, &size)!=EOF) {
		p[x][y]++;
		for (int i=0; i<size*4; i++) {
			int mx=x+dx[i];
			int my=x+dy[i];
			if (mx>=0&&mx<10&&my>=0&&my<10) {
				p[mx][my]++;
			}
		}
	}
	int c=0,m=0;
	for (int i=0; i<10; i++) {
		for (int j=0; j<10; j++) {
			if (p[i][j] == 0) {
				c++;
			} else if (p[i][j]>m) {
				m=p[i][j];
			}
		}
	}
	printf("%d\n%d\n",c,m);
	return 0;
	*/
		int map[10][10],ink,x,y,max=0,count=0;
	int dx[] = { 0, 0,-1, 1,-1,-1, 1, 1, 0, 0,-2, 2};
	int dy[] = {-1, 1, 0, 0,-1, 1,-1, 1,-2, 2, 0, 0};

	for(int i=0 ; i<10 ; i++){
		for(int j=0 ; j<10 ; j++){
			map[i][j] = 0;
		}
	}
	while( scanf("%d,%d,%d", &x, &y, &ink) != EOF ){
		map[y][x]++;
		for(int i=0 ; i<ink*4 ; i++){
			int mx = x + dx[i];
			int my = y + dy[i];
			if(mx>=0 && mx<10 && my>=0 && my<10){
				map[my][mx]++;
			}
		}
	}
	for(int y=0 ; y<10 ; y++){
		for(int x=0 ; x<10 ; x++){
			if(map[y][x]==0){
				count++;
			}
			if(map[y][x]>max){
				max = map[y][x];
			}
		}
	}
	printf("%d\n%d\n", count , max);
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <set>

#include <algorithm>
using namespace std;

int main() {
    int a;
    int b;
    int c;
  
   cin >> a >> b >> c;
   int d = a+b;
  
   if (d >= c){
     cout << "Yes" << endl;
   }else{
      cout << "No" << endl;
   }
  
  
  return 0;
}

Measured memory_bytes: 256
// C

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

int main(){
  int N;
  cin>>N;
  ll P(0),Q(0);
  for (int i(0);i<N;i++){
    int p;
    cin>>p;
    P += pow(10,N-i-1)*p;
  }
  for (int i(0);i<N;i++) {
    int q;
    cin>>q;
    Q += pow(10,N-i-1)*q;
  }
  //cout << P <<" " <<  Q << endl;
  vector<int> A(N);
  for (int i(0);i<N;i++) A[i] = i+1;
  int cnt(0),a,b;
	do{
    //cout << "aaa" << endl;
    cnt++; 
      ll now(0);
      for (int i(0);i<N;i++){
        now += pow(10,N-i-1)*A[i];
      }
      //cout << now << endl;
      if (now == P){
        a = cnt;
      }
      if (now == Q){
        b = cnt;
      }
    }while(next_permutation(A.begin(),A.end()));
  cout << abs(a - b) << endl;
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>b){
		printf("a > b\n");
	}
	else if(a<b){
		printf("a < b\n");
	}
	else if(a==b){
		printf("a == b\n");
	}
	return 0;
}

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

int main(){
  int N, Q;
  cin >> N >> Q;
  dsu d(N);
  
  for(int i=0; i<Q; i++){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == 0){
      d.merge(b,c);
    }
    else{
      if(d.same(b,c)){
        cout << 1 << endl;
      }
      else{
        cout << 0 << endl;
      }
    }
  }
}



Measured memory_bytes: 3956
import sys

input = sys.stdin.readline
    
n = int(input())
arm_range = []
for i in range(n):
    x, l = map(int, input().split())
    arm_range.append([x-l, x+l])

arm_range.sort(key=lambda x: x[1])
high = -float('inf')
count = 0
for a in arm_range:
    if a[0] >= high:
        high = a[1]
        count += 1

print(count)



Measured memory_bytes: 57948
fun main(){
    val K = readLine()!!.toInt()

    var ans: Long = 0
    for(a in 1..K){
        for(b in 1..K){
            var tmp = gcd(a, b)
            for(c in 1..K){
                ans += gcd(tmp, c)
            }
        }
    }

    println(ans)
}

fun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)

Measured memory_bytes: 34556
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力

		String str = sc.next();
		String[] strArray = str.split("");
		Arrays.sort(strArray);
		// System.out.println(Arrays.toString(strArray));
		if(strArray[0].equals(strArray[1]) 
		&& strArray[2].equals(strArray[3])
		&&!strArray[0].equals(strArray[2])){

			System.out.println("Yes");
		}else{

			System.out.println("No");
		}

	}
}


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

void fnInput(vector<int>& rvnSeq)
{
  int nSeqSiz;
  cin >> nSeqSiz;
  rvnSeq.resize(nSeqSiz);

  for(int& rnSeq : rvnSeq)
    cin >> rnSeq;
}
  
int fnLowElemCnt(const vector<int>& cnrvnSeq)
{
  int nLowElemCnt = 0;
  int nMinLowElem = 200001;

  for (int i = 0; i < cnrvnSeq.size(); i++)
    if (cnrvnSeq[i] < nMinLowElem)
    {
      nLowElemCnt++;
      nMinLowElem = cnrvnSeq[i];
    }

  return nLowElemCnt;
}
  
int main()
{
  vector<int> vnSeq;

  fnInput(vnSeq);
  cout << fnLowElemCnt(vnSeq) << endl;

  return 0;
}

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

#define rep1(i,n) for (decay_t <decltype (n)> i = 1, i ## __len = (n); i <= i ## __len; ++ i)

template <typename T>
constexpr T inf = numeric_limits <T>::max ();

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n;
  cin >> n;

  vector <int> h (n + 1);
  rep1 (i, n) cin >> h [i];

  vector <int> cost (n + 1, inf <int>);
  cost [1] = 0;
  rep1 (i, n)
  {
    auto j = i + 1;
    cost [j] = min (cost [j], + cost [i] + abs (h [i] - h [j]));
    j = i + 2;
    cost [j] = min (cost [j], + cost [i] + abs (h [i] - h [j]));
  }

  cout << cost [n] << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int i = 1;
while(true) {
    int x = sc.nextInt();
    if(x == 0) break;
    System.out.println("Case " + (i++) + ": " + x);
}
}
}



Measured memory_bytes: 41792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Solve(long N, long M)
        {
            long n = Math.Min(N, M / 2);
            return n + (M - n * 2) / 4;
        }
        static void Main(string[] args)
        {
            long[] v1 = ReadLongs();
            Console.WriteLine(Solve(v1[0], v1[1]));
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,m,q;
  cin>>n>>m>>q;
  vector<Int> a(q);
  for(Int i=0;i<q;i++) cin>>a[i];
  reverse(a.begin(),a.end());
  vector<Int> u(m+1,-1);
  vector<Int> v;
  vector<Int> cnt(m+1,0);
  cnt[0]=n;
  
  for(Int i=0;i<q;i++){
    if(u[a[i]]<0){
      u[a[i]]=v.size();
      v.emplace_back(a[i]);
    }
    if(cnt[u[a[i]]]){
      cnt[u[a[i]]]--;
      cnt[u[a[i]]+1]++;
    }
  }
  
  for(Int i=1;i<=m;i++)
    if(u[i]<0) v.emplace_back(i);

  for(Int i=0;i<m;i++){
    if(!cnt[i]) continue;
    Int flg=1;
    for(Int j=i;j+1<m;j++)
      flg&=v[j]<v[j+1];
    if(!flg){
      cout<<"No"<<endl;
      return 0;
    }
    break;
  }
  
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 3704
from collections import defaultdict
import sys
sys.setrecursionlimit(110000)

def dfs(i):
	if i not in H: return 0
	if memo[i]>=0: return memo[i]
	a=sorted((dfs(e) for e in H[i]),reverse=True)
	memo[i]=max(a[i]+i+1 for i in xrange(len(a)))
	return memo[i]

N=int(sys.stdin.readline())
memo=[-1]*N
H=defaultdict(list)
for i,e in enumerate(xrange(N-1)):
	H[int(sys.stdin.readline())-1].append(i+1)
dfs(N//2)
print(dfs(0))

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

int main() {
    int N;
    cin >> N;
    vector<ll> x(N),y(N),h(N);
    for(int i=0;i<N;i++){
        cin >> x[i] >> y[i] >> h[i];
    }

    ll correctX,correctY;
    for(int cx=0; cx<=100;cx++){
        for(int cy=0;cy<=100;cy++){
            ll H;
            for(int i=0;i<N;i++){
                if(h[i] !=0){
                    H = h[i] + abs(x[i]-cx) + abs(y[i]-cy);
                    break;
                }
            }
            bool ok = true;
            for(int i=0;i<N;i++){
                if(h[i] != max(H-abs(x[i]-cx)-abs(y[i]-cy),0LL)){
                    ok =false;
                }
            }
            if(ok){
                cout <<cx<< " " << cy <<" "<<H << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e9;

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

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

using namespace std;

int main () {
    int N;
    int a, b, c, d;

    cin >> N;

    a = N / 1000;//1000
    b = (N - a * 1000) / 100;
    c = (N - a * 1000 - b * 100) / 10;
    d = N - a * 1000 - b * 100 - c * 10;

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

Measured memory_bytes: 3600
import Foundation

extension String {
    
    func toStrList() -> [String] {
        return self.map{String($0)}
    }
    
    func toIntList() -> [Int] {
        return self.map{Int(String($0))!}
    }
    
    func toSepDoubleList() -> [Double]{
        return self.split(separator: " ").map{Double($0)!}
    }

    func toSepIntList() -> [Int] {
        return self.split(separator: " ").map{Int($0)!}
    }

    func toSepStrList() -> [String] {
        return self.split(separator: " ").map{String($0)}
    }
    
    func zFill(n:Int) -> String {
        return String(format: "%0\(n)d", Int(self)!)
    }
    
    func count(c:Character) -> Int{
        var result = 0

        for e in self{
            if e == c{
                result += 1
            }
        }
        return result
    }

    func counter() -> Dictionary<Character, Int>{
        var result:[Character:Int] = [:]
        
        for c in self{
            guard let _ = result.index(forKey: c) else {
                result[c] = 1
                continue
            }
            result[c]! += 1
        }
        return result
    }
}

extension Int {
    func toBin() -> String {
        return String(self, radix: 2)
    }
    
    func toNBin(_ radix:Int) -> String{
        return String(self, radix: radix)
    }
    
    func toD() -> Double {
        return Double(self)
    }
}

extension Double {
    func toI() -> Int {
        return Int(self)
    }
}

extension Array where Element: Equatable{
    func count(n:Self.Element) -> Int{
        var result = 0
        for e in self{
            if e == n{
                result += 1
            }
        }
        return result
    }
}

extension Array {
    func dump(){
        for x in 0..<self.count-1{
            print(self[x], terminator: " ")
        }
        print(self.last!)
    }
}

func pow(_ base:Int,_ exp:Int) -> Int{
    let d = pow(base.toD(), exp.toD())
    return Int(d)
}

func distance(p1:CGPoint, p2:CGPoint) -> Double {
    let diffp = CGPoint(x:p1.x - p2.x, y:p1.y - p2.y)
    return Double(sqrt(diffp.x*diffp.x + diffp.y * diffp.y))
}

func distance(p1:[Double], p2:[Double]) -> Double{
    let diff = [p1[0] - p2[0], p1[1] - p2[1]]
    return sqrt(diff[0] * diff[0] + diff[1] * diff[1])
    
}

func lotate(theta:Double, point:[Double]) -> [Double] {
    let matrix = [
        [cos(theta), -sin(theta)],
        [sin(theta), cos(theta)]
    ]
    let x = point[0]
    let y = point[1]
    
    let rx = matrix[0][0]*x + matrix[0][1]*y
    let ry = matrix[1][0]*x + matrix[1][1]*y
    
    return [rx, ry]
}

func c() -> Int {
    let K = Int(readLine()!)!
    var mod = 7 % K
    if mod == 0{
        return 1
    }
    for i in 1...K {
        mod = (mod*10 + 7) % K
        if mod == 0 {
            return i+1
        }
    }
    return -1
}

print(c())

Measured memory_bytes: 13120
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int K; cin >> K;
  double A, B; cin >> A >> B;
  if (ceil(A/K) <= B/K) cout << "OK" << endl;
  else           cout << "NG" << endl;
}


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

int main(){
  long long n,k;
  cin >> n >> k;
  long long a = n/k;
  if(abs(n-a*k)<abs(n-a*k-k)){
  	cout << n-a*k << endl;
  }else{
    cout << abs(n-a*k-k) << endl;

  }
}

Measured memory_bytes: 256
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W = lr()

S = [list(sr()) for _ in range(H)]
S = np.array([[1 if x == '.' else 0 for x in row] for row in S])

U = np.zeros((H, W), np.int32)
D = np.zeros((H, W), np.int32)
L = np.zeros((H, W), np.int32)
R = np.zeros((H, W), np.int32)

for h in range(H-1):
    U[h+1] = (U[h] + 1) * S[h]
    D[H-h-2] = (D[H-h-1] + 1) * S[H-h-1]
for w in range(W-1):
    L[:, w+1] = (L[:, w] + 1) * S[:, w]
    R[:, W-w-2] = (R[:, W-w-1] + 1) * S[:, W-w-1]


print(((U + D + L + R) * S).max() + 1)


Measured memory_bytes: 157228
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
#define int long long

signed main() {
  int n;
  cin >> n;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    mp[x]++;
  }
  int ans = 0;
  for (auto i = mp.begin(); i != mp.end(); i++) {
    if (mp[i->first] < i->first) {
      ans += mp[i->first];
    } else {
      ans += mp[i->first] - i->first;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int A, B; cin >> A >> B;
    int m = min(A,B), n = max(A,B);
    int K = abs(A - B)/2;
    if(m+K == n-K)
        cout << m+K << endl;
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
    
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)

        {

            var data = Console.ReadLine().Split();
            var a = int.Parse(data[0]);
            var b = int.Parse(data[1]);
            var ans = a - 2 * b;

            if (ans < 0) ans = 0;
           



            Console.WriteLine(ans);
        
            
        }
    }
}


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

int main(){
  
  string S;
  cin >> S;
  
  int ans01 = 0;
  for (int i=0;i<S.size();i++){
    if(i%2 == 0 && S.at(i) == '1'){
      ans01 ++;
    }
    if(i%2 == 1 && S.at(i) == '0'){
      ans01 ++;
    }
  }
  
  int ans02 = 0;
  for (int i=0;i<S.size();i++){
    if(i%2 == 0 && S.at(i) == '0'){
      ans02 ++;
    }
    if(i%2 == 1 && S.at(i) == '1'){
      ans02 ++;
    }
  }
  
  cout << min(ans01,ans02) << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
  int a,b;
  int v,w;
  int t;
  cin>>a>>v;
  cin>>b>>w;
  cin>>t;
  
  b=abs(b-a);
  v-=w;

  if(v<=0){
    cout<<"NO"<<endl;
  }else if((b+v-1)/v <= t){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return(0);
}

Measured memory_bytes: 3612
import sys

s = set()
input()

for q in sys.stdin:
    q = q.split()
    if q[0] == '0':
        s.add(int(q[1]))
        print(len(s))
    elif q[0] == '1':
        print(int(int(q[1]) in s))
    elif q[0] == '2':
        s.discard(int(q[1]))
    else:
        ans = []
        if len(s) > int(q[2]) - int(q[1]):
            for i in range(int(q[1]), int(q[2])+1):
                if i in s:
                    print(i)
        else:
            for i in s:
                if int(q[1]) <= i <= int(q[2]):
                    ans.append(i)
    
            for i in sorted(ans):
                print(i)


Measured memory_bytes: 23616
package main

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

var (
	N    int
	h, a [212345]int
)

func readVariables() {
	N = nextInt()
	for i := 0; i < N; i++ {
		h[i] = nextInt()
	}
	for i := 0; i < N; i++ {
		a[i] = nextInt()
	}
}

func main() {
	readVariables()
	bit := NewBIT(N)
	answer := 0
	for i := 0; i < N; i++ {
		v := a[i] + bit.Accumulate(h[i]-1)
		bit.Add(h[i], v)
		// fmt.Println(bit.Nodes)
		answer = MaxInt(v, answer)
	}
	fmt.Println(answer)
}

/* 以下、テンプレート*/

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt は、2つの整数を受け取り、最小値を返します。
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt は、2つの整数を受け取り、最大値を返します。
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt は、整数の絶対値を返します。
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow は整数の累乗関数で、剰余もサポートします。
//base^exponentの値をmoduleで割った余りを返します。
//moduloが1以下の場合には、剰余演算をしません。
//baseが負の値である場合には、返す値が負になることがあります。
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd は、引数の整数全ての最大公約数を返します。
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm は、与えられた整数の最小公倍数を返します。
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}

type BIT struct {
	Nodes []int
	Size  int
}

func NewBIT(size int) *BIT {
	bit := new(BIT)
	bit.Size = size
	bit.Nodes = make([]int, size+1)
	return bit
}

func (bit *BIT) Add(location, value int) {
	for i := location + 1; i <= bit.Size; i += (i & -i) {
		bit.Nodes[i] = MaxInt(bit.Nodes[i], value)
	}
}

func (bit *BIT) Sum(start, end int) int {
	return bit.Accumulate(end) - bit.Accumulate(start-1)
}

func (bit *BIT) Accumulate(end int) (result int) {
	result = -1234567890
	if end >= bit.Size {
		end = bit.Size - 1
	}
	for i := end + 1; i > 0; i -= i & -i {
		result = MaxInt(bit.Nodes[i], result)
	}
	return
}


Measured memory_bytes: 10368
package main

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

func main() {
	io := newIo()
	n := io.nextInt()
	k := io.nextInt()

	dic := map[int]int{}

	for range make([]struct{}, n) {
		a := io.nextInt()
		b := io.nextInt()
		dic[a] += b
	}

	seq := []int{}
	for key := range dic {
		seq = append(seq, key)
	}
	sort.Ints(seq)

	var ans int
	for k > 0 {
		ans = seq[0]
		k -= dic[seq[0]]
		seq = seq[1:]
	}

	fmt.Println(ans)
}

type io struct {
	reader    *bufio.Reader
	tokens    []string
	nextToken int
}

func newIo() *io {
	return &io{
		reader: bufio.NewReader(os.Stdin),
	}
}

func (io *io) nextLine() string {
	var buffer []byte
	for {
		line, isPrefix, _ := io.reader.ReadLine()
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *io) nextString() string {
	for io.nextToken >= len(io.tokens) {
		line := io.nextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *io) nextInt() int {
	i, _ := strconv.Atoi(io.nextString())
	return i
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N, x = 1, cnt = 0, z = -1;
  cin >> N;
  vector<int> a(N);
  REP(i,N) {
    cin >> a[i];
    if(a[i] == 1) {
      z = 1;
    }
  }
  if(z == -1) {
    cout << z << endl;
  }
  else {
    REP(i,N) {
      if(a[i] != x) {
        cnt++;
      }
      else x++;
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=5010;
char s1[N][N],s2[N][N],s3[N][N];
int main()
{
    int n,m;scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",s1[i]+1);
        for(int j=2;j<m;j++)s2[i][j]=s3[i][j]=s1[i][j];
        for(int j=2;j<m;j++)(i&1)?s2[i][j]='#':s3[i][j]='#';
    }
    for(int i=1;i<=n;i++)s2[i][1]=s3[i][m]='#',s2[i][m]=s3[i][1]='.';
    for(int i=1;i<=n;i++)
        {for(int j=1;j<=m;j++)putchar(s2[i][j]);printf("\n");}
    cout<<endl;
    for(int i=1;i<=n;i++)
        {for(int j=1;j<=m;j++)putchar(s3[i][j]);printf("\n");}
}


Measured memory_bytes: 17024
//#include <iostream>
#include <cstdio>
#include <ctype.h>
#include <algorithm>
using namespace std;

template<typename T>
inline void read(T &num) {
	num = 0; bool w = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') w = 0; c = getchar(); }
	while(isdigit(c)) { num = num*10+c-'0';; c = getchar(); }
	num = w ? num : -num;
}

const int N = 1e5 + 10;
int n, A[N];

signed main() {
	read(n);
	for(int i = 1; i <= n; i++) read(A[i]);
	sort(A + 1, A + 1 + n); reverse(A + 1, A + 1 + n);
	for(int i = 0; i <= n; i++) {
		if(i + 1 <= A[i+1]) continue;
		int j = 0;
		for(; A[j+i+1] == i; j++) ;
		if(((A[i]-i)&1) || (j&1)) puts("First");
		else puts("Second");
		break;
	}
	return 0;
}

Measured memory_bytes: 512
N = int(input())
L = list(map(int, input().split()))
L.sort()

count = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if L[i] == L[j] or  L[j] ==  L[k] or L[k] == L[i]:
                continue
            # print(L[i], L[j], L[k])
            if L[i] + L[j] > L[k]:
                count += 1

print(count)

Measured memory_bytes: 67968
N = int(input())
rob = [] 

for i in range(N):
    x, l = map(int,input().split())
    t = x + l
    rob.append((t,x,l))

rob.sort()
Max = -float("inf")
ans = 0
for i in range(len(rob)): 
    t = rob[i][0]
    x = rob[i][1]
    l = rob[i][2]
    if x-l < Max:
        continue
    else:
        ans += 1
        Max = t
print(ans)

Measured memory_bytes: 61656
def print_it(l, n):
    print(''.join([l[x % 2] for x in range(n)]))

matrix = []
while True:
    values = input()
    if '0 0' == values:
        break
    matrix.append([int(x) for x in values.split()])

sc = ['#', '.']
cs = ['.', '#']
for height, width in matrix:
    for i in range(height):
        if 0 == i % 2:
            print_it(sc, width)
        else:
            print_it(cs, width)
    print()

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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;

    cout<<max({a*c,a*d,b*c,b*d})<<endl;

}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

#define MOD 1000000007

int main()
{
    int n;
    cin >> n;
    if (n < 2) {
        cout << 0 << '\n';
        return 0;
    }
    long long x, y, z;
    x = y = z = 1;
    for (int i = 1; i <= n; i++) {
        x = (x * 10)%MOD;
        y = (y * 9)%MOD;
        z = (z * 8)%MOD;
    }
    long long ans = x + z;
    ans -=  (2 * y)%MOD;
    ans += MOD;
    ans %= MOD;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3624
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();
        if ((a * b) % 2 == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }

}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<char,int> pci;
typedef vector<pair<int,int>> vpii;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
#define sci(a) scanf("%d",&a)
#define scii(a,b) scanf("%d %d",&a,&b)
#define sciii(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sciiii(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scl(a) scanf("%lld",&a)
#define scll(a,b) scanf("%lld %lld",&a,&b)
#define sclll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c
#define scllll(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define print(a) printf("%d ",a)
#define println(a) printf("%d\n",a)
#define ln printf("\n")
#define pb(a) push_back(a)
#define m_p(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define rep(i,s,n) for(int i=s;i<=n;i++)
#define rrep(i,e,s) for(int i=e;i>=s;i--)
#define repv(i,m) for(auto i = m.begin();i != m.end();i++)
#define FileIO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const long long INF = 4000000000000000000LL;
/************************************* Chocolate *************************************/
int main(){
    int n,k;
    scii(n,k);
    vi a(n);
    for(int &x:a){
        sci(x);
    }
    vb dp(k+1,false);
    rep(stones,1,k){
        for(int i:a){
            if(stones >= i && !dp[stones-i]) dp[stones] = true;
        }
    }
    cout << (dp[k] ? "First":"Second") << endl;
}

Measured memory_bytes: 3668
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
	


int main() {
	int a, b;
	cin >> a >> b;
	cout << (a + b + 1) / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
import sys

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = None
        self.right = None

class BST:
    def __init__(self):
        self.root = None
    def insert(self, key):
        x = self.root
        y = None
        z = Node(key)
        while x != None:
            y = x
            x = x.left if z.key < x.key else x.right
        if y == None: self.root = z
        else:
            if z.key < y.key: y.left = z
            else: y.right = z
    def print_tree(self):
        def inorder(node):
            return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
        def preorder(node):
            return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''
        print(inorder(self.root))
        print(preorder(self.root))

tree = BST()
input()
for e in sys.stdin:
    if e[0] == 'i': tree.insert(int(e[7:]))
    else: tree.print_tree()


Measured memory_bytes: 63272
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 200010
#define MO 1000000007
#define LL long long
int n,sum[MAXN],ans=1;
int main()
{
	scanf("%d",&n);
	for(int i=1,col=0,c;i<=n;i++)
	{
		scanf("%d",&c);
		if(col==c) continue;
		int tmp=sum[c];
		(sum[c]+=ans)%=MO;
		(ans+=tmp)%=MO;
		col=c;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define mll map<ll,ll>
#define pb push_back
#define mp make_pair
#define endl "\n"
#define MAX 1e18
#define F first
#define S second
#define all(s) s.begin(),s.end()
#define mod 998244353
ll lcm(ll a,ll b){return (a*b)/(__gcd(a,b));}
ll cel(ll n,ll d){return (n+d-1)/d;}

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

int main()
{
    //hertz();
    ll t=5;
    ll a;
    ll ans;
   // cin>>t;
    for (int i = 0; i < t; ++i)
    {
    	cin>>a;
    	if(a==0)
    		ans=i+1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        String S;

        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            S = sc.next();

        }
        long result =1;
        char[] arr= S.toCharArray();
        for (int i = 0; i < arr.length -1; i++) {
            if(arr[i] != arr[i+1]){
                result++;
            }
        }
        System.out.println(result);
    }

}


Measured memory_bytes: 27216