akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
Int dp[2][33][33][33][33];
Int cnt[2][33][33][33][33];
signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int w,h;
  while(cin>>w>>h,w){
    vector<string> s(h);
    for(Int i=0;i<h;i++) cin>>s[i];
    memset(dp,-1,sizeof(dp));
    memset(cnt,0,sizeof(cnt));
    {
      using T = tuple<Int, Int, Int, Int, Int>;
      queue<T> q;
      Int dy[]={0,0,1,-1,0};
      Int dx[]={1,-1,0,0,0};
      auto in=[&](Int y,Int x){
	return 0<=y&&y<h&&0<=x&&x<w;
      };
      
      for(Int qy=0;qy<h;qy++){
	for(Int qx=0;qx<w;qx++){
	  if(s[qy][qx]=='#') continue;
	  for(Int ay=0;ay<h;ay++){
	    for(Int ax=0;ax<w;ax++){
	      if(s[ay][ax]=='#') continue;
	      // t == 0	      
	      {		
		if(s[qy][qx]=='E'&&!(qy==ay&&qx==ax)){
		  dp[0][qy][qx][ay][ax]=1;
		  q.emplace(0,qy,qx,ay,ax);
		}
		for(Int k=0;k<5;k++){
		  Int ny=qy+dy[k],nx=qx+dx[k];
		  if(!in(ny,nx)||s[ny][nx]=='#') continue;
		  cnt[0][qy][qx][ay][ax]++;
		}
	      }
	      // t == 1
	      {
		for(Int k=0;k<5;k++){
		  Int ny=ay+dy[k],nx=ax+dx[k];
		  if(!in(ny,nx)||s[ny][nx]=='#') continue;
		  if(ny==qy&&nx==qx){		    
		    dp[1][qy][qx][ay][ax]=1;
		    q.emplace(1,qy,qx,ay,ax);		  
		  }
		  cnt[1][qy][qx][ay][ax]++;
		}
	      }
	    }
	  }	
	}
      }
      //cout<<cnt[0][0][0][0][1]<<endl;
      const Int DBG = 0;
      
      while(!q.empty()){
	Int t,qy,qx,ay,ax;
	tie(t,qy,qx,ay,ax)=q.front();q.pop();
	Int d=dp[t][qy][qx][ay][ax];
	if(DBG) cout<<t<<":"<<qy<<" "<<qx<<" "<<ay<<" "<<ax<<":"<<d<<endl;
	
	if(t){
	  for(Int k=0;k<5;k++){
	    Int ny=qy+dy[k],nx=qx+dx[k];
	    if(!in(ny,nx)||s[ny][nx]=='#') continue;
	    if(~dp[!t][ny][nx][ay][ax]) continue;
	    cnt[!t][ny][nx][ay][ax]--;
	    if(!d||cnt[!t][ny][nx][ay][ax]==0){
	      if(DBG) cout<<"->"<<!t<<" "<<ny<<" "<<nx<<" "<<ay<<" "<<ax<<":"<<!d<<endl;
	      dp[!t][ny][nx][ay][ax]=!d;
	      q.emplace(!t,ny,nx,ay,ax);
	    }
	  }
	}else{
	  for(Int k=0;k<5;k++){
	    Int ny=ay+dy[k],nx=ax+dx[k];
	    if(!in(ny,nx)||s[ny][nx]=='#') continue;
	    if(~dp[!t][qy][qx][ny][nx]) continue;
	    cnt[!t][qy][qx][ny][nx]--;
	    if(!d||cnt[!t][qy][qx][ny][nx]==0){
	      if(DBG) cout<<"->"<<!t<<" "<<qy<<" "<<qx<<" "<<ny<<" "<<nx<<":"<<!d<<endl;
	      dp[!t][qy][qx][ny][nx]=!d;
	      q.emplace(!t,qy,qx,ny,nx);
	    }
	  }
	}
      }
      
    }
    
    
    {
      Int qx,qy,ax,ay;
      for(Int i=0;i<h;i++){
	for(Int j=0;j<w;j++){
	  if(s[i][j]=='Q') qy=i,qx=j;
	  if(s[i][j]=='A') ay=i,ax=j;
	}
      }
      if(dp[0][qy][qx][ay][ax]==1)
	cout<<"Queen can escape."<<endl;
      if(dp[0][qy][qx][ay][ax]==0)
	cout<<"Army can catch Queen."<<endl;
      if(dp[0][qy][qx][ay][ax]==-1)
	cout<<"Queen can not escape and Army can not catch Queen."<<endl;
    }
  }
  
  return 0;
}



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

int main() {
  int N;
  string S;	
  int count=0;
  cin >> N >> S;	
  
  for(int i=0;i<N;i++){
    if(S[i]=='A'){
      if(S[i+1]=='B'){
        i++;
        if(S[i+1]=='C'){
          i++;
          count++;
        }
        else continue;
      }
      else continue;
    }
    else continue;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function getArray(str) {
    return str.split(' ').map(x => Number(x));
}

function getInt(str) {
    return Number(str);
}

function getStrArray(str) {
    return str.split(' ').map(x => x);
}
// ---------------------------------------



function main() {
    let n = getInt(readline());
    let totalArray = getArray(readline());
    // console.log(totalArray);
    while(n > 1) {
        const x = getArray(readline());
        const temp0 = x[0] + Math.max(totalArray[1], totalArray[2]);
        const temp1 = x[1] + Math.max(totalArray[0], totalArray[2]);
        const temp2 = x[2] + Math.max(totalArray[0], totalArray[1]);
        totalArray = [temp0, temp1, temp2];
        // console.log(totalArray);
        n--;
    }
    console.log(Math.max(totalArray[0], Math.max(totalArray[1], totalArray[2])));
}

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

#define int long long 
#define MOD 1000000007


using namespace std;


signed main(){

	int n,k;
	cin >> n >> k;

	int count=0;
	
	int max = 2*n;
	
	int s = max/k;//kの１~s倍まで考えられる

	set<int> x;

	if(k%2==0){
	
		int i=n/k;
		
		int j= (n+k/2)/k;
		count = i*i*i+j*j*j;
		
	}
	
	else if(k%2==1){

		int i = n/k;
		count = i*i*i;
	
	
	
	
	}
	
/*
	for(int a:x){	
		for(int i=1;i<=s;i++){
			int b = k*i-a;
			if(b>n){
				break;
			}
			
			if(b<=0){
				continue;
			}
			
			else{
				for(int j=1;j<=s;j++){
					int c = k*j-a;
					if(c>n){
						break;
					}
					
					if(c<=0){
						continue;
					}
					
					if((b+c)%k==0){
						count++;
						//cout <<a<<b<<c<<endl;
					}
					
					
					
				}
			}
			
		}
	}
	*/

	
					
					
					
	

	cout <<count << endl;

 	
 	return 0;
	

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n,k;
  cin >> n >> k;
  ll h[n];
  rep(i,n)cin >> h[i];
  ll ans=0;
  sort(h,h+n,greater<ll>());
  REP(i,k,n){
    ans+=h[i];
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 1792
loop do
  n, p = gets.split.map(&:to_i)
  total = p
  break if n == 0 && p == 0
  stone = [0] * n
  (0..1/0.0).each do |i|
    x = i % n
    if p == 0
      if stone[m = (x + n - 1) % n] == total
        puts m
        break
      else
        if stone[x] > 0
          p = stone[x]
          stone[x] = 0
        end
      end
    else
      p -= 1
      stone[x] += 1
    end
  end
end

Measured memory_bytes: 8504
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
signed main(){
    int n;
    cin>>n;
    int a[314514];
    for(int i=0;i<n*3;i++){
        cin>>a[i];
    }
    priority_queue<int,vector<int>,greater<int>> front;
    priority_queue<int> back;
    int sumf[314514];
    int sumb[314514];
    for(int i=0;i<3*n;i++){
        front.push(a[i]);
        if(i==0)sumf[i]=a[i];
        else sumf[i]=sumf[i-1]+a[i];
        if(i>=n){
            sumf[i]-=front.top();
            front.pop();
        }
    }
    for(int i=3*n-1;i>=0;i--){
        back.push(a[i]);
        if(i==3*n-1)sumb[i]=a[i];
        else sumb[i]=sumb[i+1]+a[i];
        if(i<2*n){
            sumb[i]-=back.top();
            back.pop();
        }
    }
    int ans=-INF;
    for(int i=n-1;i<2*n;i++){
        ans=max(ans,sumf[i]-sumb[i+1]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9972
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

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

    map<int, int> nums;
    ll sum = 0;
    rep(i, n){
        int a;
        cin >> a;
        nums[a] ++;

        if(nums[a] % 2 == 1) sum ++;
        else sum --;
    }

    cout << sum << endl;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
#define plll pair <ll, pair <ll, ll>>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define pld pair <ld, ld>
#define all(a) a.begin(), a.end()
#define vvl vector <vector <ll> >
 
typedef long long ll;
 
typedef long double ld;
 
using namespace std;
 
const ll maxn = 1e6 + 100;
const ll inf = 1e15;

ll n, m, k, t;

vector <pll> V[maxn];

vector <pll> E;

vector <ll> V1[maxn];

bool used[maxn];

ll bad[maxn];

void dfs(ll v, ll i) {
    used[v] = 1;
    for (auto p : V[v]) {
        ll v1 = p.first;
        if (!used[v1]) {
            dfs(v1, p.second);
            bad[v] += bad[v1];
        }
    }
    if (bad[v] % 2 == 1) {
        swap(E[i].first, E[i].second);
    }
}

int main() {
    pyshnapyshnakaa;
    ll q, w, e, a, b;
    cin >> n >> m;
    if (m % 2 == 1) {
        cout << -1;
        return 0;
    }
    for (q = 0; q < m; q++) {
        cin >> a >> b;
        a--; b--;
        V[a].pb(mp(b, q));
        V1[a].pb(b);
        V[b].pb(mp(a, q));
        E.pb(mp(a, b));
    }
    for (q = 0; q < n; q++) {
        if (V1[q].size() % 2 == 1) {
            bad[q] = 1;
        }
    }
    dfs(0, -1);
    for (q = 0; q < E.size(); q++) {
        cout << E[q].first + 1 << " " << E[q].second + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 67340
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int n, a[200005];
    int i;
    cin>>n;
    FOR0(i, n) cin>>a[i];
    int left[200005], right[200005];
    FOR0(i, n)
    {
        if(i == 0) left[i] = a[i];
        else
        {
            left[i] = MAX2(left[i-1], a[i]);
        }
        
    }
    FORD(i, n-1, 0)
    {
        if(i == n-1) right[i] = a[i];
        else right[i] = MAX2(a[i], right[i+1]);
    }
    FOR0(i, n)
    {
        int ll = -1, rr = -1;
        if(i > 0) ll = left[i-1];
        if(i < n-1) rr = right[i+1];
        cout<<MAX2(ll, rr)<<endl;
    }
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  vector<int> p(m);
  rep(i, m) {
    int k;
    cin >> k;
    vector<int> si(k);
    rep(j, k) {
      cin >> si[j];
      si[j]--;
    }
    s[i] = si;
  }
  rep(i, m) cin >> p[i];

  int ans = 0;
  int loop = pow(2, n);
  rep(ptt, loop) {
    int on = 0;
    rep(i, m) {  // light
      int cnt = 0;
      rep(j, s[i].size()) {  // switch
        int shift = s[i][j];
        if (ptt & (1 << shift)) cnt++;
      }
      if (cnt % 2 == p[i]) on++;
    }
    if (on == m) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
import numpy as np
import scipy as sp
from scipy import signal

H,W = map(int,input().split())
A = []
for i in range(H):
  A.append(list(input()))

B = np.array(A)
B = np.where(B=="#",1,B)
B = np.where(B==".",0,B)
B = B.astype("int32")

s = np.ones(9).reshape(3,3)
s[1][1]=0

C = sp.signal.convolve2d(B,s,"same").astype("int32")

for h in range(H):
  for w in range(W):
    if A[h][w] == "#":
      print("#",end="")
    elif A[h][w] == ".":
      print(C[h][w],end="")
  print("")

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

int main()
{
    int n, count=0;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n - 1);

    for (int i = 0; i < n;i++){
        cin >> a.at(i);
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b.at(i);
    }
    for (int i = 0; i < n-1; i++)
    {
        cin >> c.at(i);
    }
    
    for (int i = 0; i < n;i++){
        count += b.at(a.at(i)-1);
        if(i<n-1&&a.at(i+1)==a.at(i)+1){
            count += c.at(a.at(i)-1);
        }
        //cout << count << endl;
    }

    cout << count << endl;
}

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

#define INF 1000000000000

int n;
vector<char> sc(0),tc(0);
//sc,tcはSとCに含まれるアルファベットの種類を管理する配列
//ex s="ogamokazuki" sc={ogamkzui}
char c;
//sc,tcにS,Cのi文字目が含まれているならFalse,含まれていないならTrueを返す
bool arukanaika(char c,vector<char>sc){
  rep(i,sc.size()){
    if(sc.at(i)==c){

      return false;
    }
  }
  return true;
}

signed main(){
string s,t;
cin>>s>>t;
n=s.size();

vector<int>sn(n),tn(n);
//S,Tのn文字目が種類を表す数字だと、何になるかを表す配列
//ex　S=apple sn={1,2,2,3,4}となるようにします
int k=0;
rep(i,n){
  //if s[i] is not in sc
  if(arukanaika(s.at(i),sc)){
    //新たな文字ということなので、種類を表す数字を１増やしておく
    k++;
    sn[i]=k;
    //scにSのi文字目を追加
    sc.push_back(s.at(i));
  }
  else{
    rep(j,sc.size()){if(s.at(i)==sc.at(j)){sn.at(i)=j+1;break;}}

  }
}

k=0;
rep(i,n){
  //if t[i] is not in tc
  if(arukanaika(t.at(i),tc)){
    k++;
    tn[i]=k;
    tc.push_back(t.at(i));
  }
  else{
    rep(j,tc.size()){if(t.at(i)==tc.at(j)){tn.at(i)=j+1;break;}}

  }
}


if (sn==tn){
  cout<<"Yes";
}
else {
  cout<<"No";
}
}


Measured memory_bytes: 2440
#include <cstdio>
using namespace std;
int main(){
    int n, a, b, maxv, maxi;
    scanf("%d", &n);
    maxv = -1, maxi = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &a, &b);
        if (b > maxv) { maxv = b; maxi = a; }
        if (b == maxv && maxi > a) maxi = a;
    }
    printf("%d %d\n", maxi, maxv);
    return 0;
}




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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    string s2 = s;
    reverse(s.begin(), s.end());
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        if(s[i] != s2[i])
            ans++;
    }

    cout << ans / 2;

    return 0;
}


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

int triangle(int a,int b,int c){
    a = a*a;
    b = b*b;
    c = c*c;

    if(a == (b+c))      return 0;
    else if(b == (a+c)) return 0;
    else if(c == (a+b)) return 0;
    else                return 1;
}

int main(){
   int n;
   int a,b,c;
   int i = 0;

   scanf("%d",&n);

  while(i < n){
   scanf("%d %d %d",&a,&b,&c);
  
   if(triangle(a,b,c) == 0){ 
     cout << "YES\n";
   }else{
     cout << "NO\n"; 
 }
 i++;
}
    return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<int,int>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i,n) for (ll i=(ll)n-1;i>=0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
#define INF 1<<30
#define INFTY 1LL<<60
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}//最大公約数
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}//最小公倍数
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
const int MOD = 998244353;

inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;
x=x*x%mod;n>>=1;}return res;}
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back
int main(){
   ll n,m;cin>>n>>m;
   VI x(n),y(n),z(n);
   rep(i,n)cin>>x[i]>>y[i]>>z[i];
   VI X(n),Y(n),Z(n);
   ll ans=-INF;
   for(int bit=0;bit<(1<<3);bit++){
      if(bit & 1){
         rep(i,n)X[i]=-x[i];
      }
      else{
         rep(i,n)X[i]=x[i];
      }
      if(bit & 2){
         rep(i,n)Y[i]=-y[i];
      }
      else{
         rep(i,n)Y[i]=y[i];
      }
      if(bit & 4){
         rep(i,n)Z[i]=-z[i];
      }
      else {
         rep(i,n)Z[i]=z[i];
      }
      VI sum(n);
      rep(i,n)sum[i]=X[i]+Y[i]+Z[i];
      sort(rALL(sum));
      ll temp=0;
      rep(i,m)temp+=sum[i];
      chmax(ans,temp);
   }
   cout<<ans<<Endl;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
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;}

int main(){
    int n;
    cin >> n;
    map<string, int> m;
    string s;
    rep(i, n){
        cin >> s;
        m[s]++;
    }
    ll cnt = 0;
    for (auto p : m) {
      cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 19264
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll h, w, n; cin >> h >> w >> n;
  vector<ll> a(n); rep(i, n) cin >> a[i];

  const int MAX = 100;
  int grid[MAX][MAX] = {{}};

  int i = 0, j = 0, cnt = 0, color = 0, dist = 1;
  while (i < h) {
    // debug3(i, j, color);
    grid[i][j] = color;
    cnt++;
    if (a[color] == cnt) {
      cnt = 0;
      color++;
    }
    j += dist;
    if (j == w || j == -1) {
      i++;
      j = j == w ? w - 1 : 0;
      dist *= -1;
    }
  }

  rep(i, h) {
    cout << grid[i][0] + 1;
    for (int j = 1; j < w; j++)
      cout << " " << grid[i][j] + 1;
    cout << endl;
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 1016
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class C
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var S = Console.ReadLine();
            var t = new[] { "remaerd", "resare", "maerd", "esare" };
            var answer = true;
            var reversed = new string(S.Reverse().ToArray());
            var current = 0;
            while (answer)
            {
                if (current == S.Length) break;
                // Console.WriteLine(current);
                var tmp = false;
                for (var i = 0; i < 4; i++)
                {
                    if (reversed.IndexOf(t[i], current) == current)
                    {
                        current = current += t[i].Length;
                        tmp = true;
                        break;
                    }
                }
                if (!tmp && current < S.Length) answer = false;
            }

            Console.WriteLine(answer ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 27904
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]

from collections import Counter

blue = Counter(S)
red = Counter(T)

pnt = []

for b in blue:
    if b in red:
        pnt.append(blue[b] - red[b])
    else:
        pnt.append(blue[b])
        
print(max(pnt) if max(pnt) > 0 else 0)

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

using namespace std;

void test()
{
   int n;
   cin>>n;

   int a=0,t=0,w=0,r=0;

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

       if(s=="AC")
        a++;

       if(s=="WA")
        w++;

       if(s=="TLE")
        t++;

       if(s=="RE")
        r++;
   }


    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<w<<endl;

    cout<<"TLE x "<<t<<endl;

    cout<<"RE x "<<r<<endl;
}

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

    test();

    return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	long long n, i, j, k, MOD = 1000000007, ans, x;
	map<int, int> c;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> x;
		c[x] = 1;
	}
	for (i = 0; i < n; i++) {
		cin >> x;
		c[x] = -1;
	}

	ans = 1; x = 0;
	for (auto p : c) {
		if (x == 0) x += p.second;
		else {
			if ((x > 0) && (p.second > 0)) x += p.second;
			else if ((x < 0) && (p.second < 0)) x += p.second;
			else {
				ans = (ans * (abs(x))) % MOD;
				x += p.second;
			}
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 9728
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

#define FOR(I, A, B) for (int I = int(A); I < int(B); ++I)

const int N(105);
const double EPS(1e-7);

struct Point {
    int x, y;
    Point(int _x = 0, int _y = 0) {
        x = _x; y = _y;
    }
    void get() {
        scanf("%d%d", &x, &y);
    }
};

int t;
Point p[N];
Point s[2 * N];

vector<Point> ca, cb;

bool cmp(Point p1, Point p2) {
    return p1.x < p2.x || p1.x == p2.x && p1.y < p2.y;
}

int cross(Point a, Point b, Point c) {
    return (b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y);
}

void convexHull(int n, vector<Point> &c) {
    sort(p, p + n, cmp);
    t = 0;
    FOR(i, 0, n) {
        for(; t >= 2 && cross(s[t - 2], s[t - 1], p[i]) <= 0; --t);
        s[t++] = p[i];
    }
    int tt = t - 1;
    for (int i = n - 2; i != -1; --i) {
        for (; t - tt >= 2 && cross(s[t - 2], s[t - 1], p[i]) <= 0; --t);
        s[t++] = p[i];
    }
    c.clear();
    FOR(i, 0, t)
       c.push_back(s[i]);
}

int dcmp(int x) {
    return x == 0 ? 0 : (x > 0 ? 1 : -1);
}

double dis(Point a, Point b) {
    return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}

bool online(Point a, Point b, Point c) {
    return fabs(dis(a, c) + dis(c, b) - dis(a, b)) < EPS;
}

bool intersect(Point a, Point b, Point c, Point d) {
    return dcmp(cross(a, b, c)) * dcmp(cross(a, b, d)) == -1 && dcmp(cross(c, d, a)) * dcmp(cross(c, d, b)) == -1;
}

bool check() {
    FOR(i, 0, ca.size()) {
        bool flag = true;
        if (cb.size() == 1) {
            if (dis(ca[i], cb[0]) < EPS) return false;
            continue;
        }
        FOR(j, 1, cb.size()) {
            if (online(cb[j - 1], cb[j], ca[i])) return false;
            flag = flag && cross(cb[j - 1], cb[j], ca[i]) > 0;
        }
        if (flag) return false;
    }
    FOR(i, 0, cb.size()) {
        bool flag = true;
        if (ca.size() == 1) {
            if (dis(cb[i], ca[0]) < EPS) return false;
            continue;
        }
        FOR(j, 1, ca.size()) {
            if (online(ca[j - 1], ca[j], cb[i])) return false;
            flag = flag && cross(ca[j - 1], ca[j], cb[i]) > 0;
        }
        if (flag) return false;
    }
    FOR(i, 1, ca.size())
        FOR(j, 1, cb.size())
            if (intersect(ca[i - 1], ca[i], cb[j - 1], cb[j])) return false;
    return true;
}

int main() {
    int n, m;
	while (scanf("%d%d", &n, &m), n + m) {
	    FOR(i, 0, n)
	        p[i].get();
	    convexHull(n, ca);
	    FOR(i, 0, m)
	        p[i].get();
	    convexHull(m, cb);
	    if (check()) printf("YES\n");
	    else printf("NO\n");
	}
	return 0;

}

Measured memory_bytes: 1172
<?php
  fscanf(STDIN, "%d", $n);
while ($a = fgets(STDIN)){
$a = str_replace(PHP_EOL, '', $a);// 改行削除
$line = explode(" ", $a);
// フィルタリング
$even = array_filter($line, function($num) {
    // 条件
    return $num % 2 === 0;
});
  $ans ="APPROVED";
  for($i=0;$i<$n;++$i){
     if($even[$i]%3!=0&&$even[$i]%5!=0){
  $ans= "DENIED";
       break;
  }
}
}
  echo $ans;
  ?>



Measured memory_bytes: 3828
N, M = [int(i) for i in input().split()]
range(M)
switches = [[int(i) for i in input().split()] for _ in range(M)]
P = [int(i) for i in input().split()]
count=0
for i in range(2**N):
    ss = [int(i) for i in list(bin(i))[2:]]
    ss = [0] * (N - len(ss)) + ss
    t = True
    for e, switch in enumerate(switches):
        a = P[e]
        if len([ss[i-1] for i in switch[1:] if ss[i-1]==1]) %2 !=a:
            t = False
            break
    if t:
        count +=1

print(count)


Measured memory_bytes: 3064
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

//vector//
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

typedef pair<int,int> P;  //q(p.first,p.second)

int main (){
    int x; cin >> x;
    if(x==0){
        cout << 1;
    }else{
        cout << 0;
    }
}

Measured memory_bytes: 3632
import numpy as np
N, K, Q = map(int, input().split())
A = []
for q in range(Q):
    a = int(input())
    A.append(a)
points2 = np.zeros(N)
for a in A:
    points2[a-1] += 1
results = []
for p in points2:
    if K - (Q - p) > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 22020
#include <bits/stdc++.h>
using namespace std;
inline int rd() {
	int x=0,f=1;char ch=getchar();
	while (ch>'9'||ch<'0') {if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return x*f;
}
int a,b,c,d,n;
int main() {
	a = rd(), b = rd(), c = rd(), d = rd();
	n = rd();
	c = min(c, 4 * a);
	c = min(c, 2 * b);
	d = min(d, 2 * c);
	long long ans = 1LL * (n >> 1) * d + 1LL * (n & 1) * c;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
vector<int>adj[MAX];
int v[MAX],dist[MAX];
void bfs(int src)
{
    v[src] = 1;
    queue <int> q;
    q.push(src);
    while(!q.empty())
    {
        int parent = q.front();
        q.pop();
        for(int i=0; i<adj[parent].size(); i++)
        {
            int child = adj[parent][i];
            if(v[child] == 0)
            {
                v[child]=1;
                dist[child]=dist[parent]+1;
                q.push(child);
            }
        }
    }
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,m;
    cin>>n>>m;
    while(m--)
    {
        int u,v;
        cin>>u>>v;
        adj[v].push_back(u);
        adj[u].push_back(v);
    }
    bfs(1);
    if(dist[n]<=2 && v[n])
        cout<<"POSSIBLE"<<endl;
    else
        cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


Measured memory_bytes: 35480
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int sum = 0;
		for(int i = 0; i  < n; i++) {
			int q = scan.nextInt();
			while (q % 2 == 0) {
				q /= 2;
				sum++;

			}
		}

		System.out.println(sum);
	}
}

Measured memory_bytes: 39832
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
const int max_n = 1e5;
const ll mod = 1e9+7;
ll f[101010], rf[101010];
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    rep(i, 1, 101010) f[i] = (f[i - 1] * i) % mod;
    rep(i, 0, 101010) rf[i] = inv(f[i]);
}
//---------------------------------------------------------------------------------------------------
ll C(int n, int k) {
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % mod;

    return (a * bc) % mod;
}
int main(){
  ll n,k; cin >> n;
  vector<ll> v(n);
  rep(i,0,n){
    cin >> v[i];
  }
  sort(all(v), greater<ll>());
  ll x = v[0];
  ll y = -1;
  ll ans = 0;
  rep(i,1,n){
    ll k = min(v[i], x-v[i]);
    if(y < k){
      y = k;
      ans = v[i];
    }
  }
  cout << x << " " << ans  << endl;
  return 0;
}


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

int N;
string S;

int main(){
  int i, j;
  int flag = 0;
  cin >> N >> S;
  if (N % 2 == 0) {
    j = N/2;
    for (i = 0; i < N/2; i++) {
      if (S[i] != S[j]) {
        flag = 1;
        puts("No");
        break;
      }
      j++;
    }
    if (flag == 0)
      puts("Yes");
  }
  else
    puts("No");
}

Measured memory_bytes: 256
mod = 1000003
"""
for i in range(2,57000):
    if n%i==0:
        print("nonPrime")
        exit()
print("prime")
"""
q = int(input())
fct = [0]
tmp = 1
for i in range(1,mod+3):
    tmp *=i
    tmp%=mod
    fct.append(tmp)
for i in range(q):
    x,d,n = map(int, input().split( ))
    if d%mod == 0:
        print(pow(x,n,mod))
        continue
    if n>=mod:
        print(0)
        continue
    rev_d = pow(d,mod-2,mod)
    x*=rev_d
    x%=mod
    tmp = pow(d,n,mod)
    try:
        tmp*=fct[x+n-1]
    except:
        print(0)
        continue
    if x>=2:
        tmp*=pow(fct[x-1],mod-2,mod)
    tmp%=mod
    print(tmp)
    
    
            

Measured memory_bytes: 82056
package main

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

const inf = 1 << 60

func main() {
	n := getInt()
	k := getInt()
	hs := getIntSlice(n)

	dp := make([]int, n)
	for i := range dp {
		dp[i] = inf
	}
	dp[0] = 0

	for i := 1; i < n; i++ {
		for j := 1; j <= i && j <= k; j++ {
			dp[i] = min(dp[i], dp[i-j]+abs(hs[i]-hs[i-j]))
		}
	}

	fmt.Println(dp[n-1])
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


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

int n;
vector<pair<int, int>> adj[1000000];
int dst[1000000];

void dfs(int u, int prv, int w){
  dst[u] = w & 1;
  for (int i = 0, nx, l; i < adj[u].size(); i++){
    nx = adj[u][i].first, l = adj[u][i].second;
    if (nx != prv){
      dfs(nx, u, w ^ l);
    }
  }
}
int main(){
  cin >> n;
  for (int i = 1, u, v, w; i < n; i++){
    cin >> u >> v >> w;
    w &= 1;
    adj[u].push_back(make_pair(v, w));
    adj[v].push_back(make_pair(u, w));
  }
  dfs(1, -1, 0);
  for (int i = 1; i <= n; i++) cout << dst[i] << '\n';
  return 0;
}


Measured memory_bytes: 32128
from collections import defaultdict
def main():
    n = int(input())
    ls = list(input().split())
    dc = defaultdict(int)
    for i in ls:
        dc[i] += 1
    cnt1 = 0
    cnt2 = 0

    for i in dc.values():
        if i%2==1:
            cnt1 += 1
        else:
            cnt2 += 1
    if cnt2%2==0:
        print(cnt1+cnt2)
    else:
        print(cnt1+cnt2-1)
    

    
if __name__ == "__main__":
    main()

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

int main() {
    int a, b, c, d, e, k;
    scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &k);

    if (e - a <= k) {
      puts("Yay!");
    } else  {
      puts(":(");
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        if ((n.charAt(0) == n.charAt(1) && n.charAt(1) == n.charAt(2)) ||
            (n.charAt(1) == n.charAt(2) && n.charAt(2) == n.charAt(3))) {
                System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23124
//submitted by Himj
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;

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

  int t=1;
  //cin>>t;
    while(t--){
      int n,m,i,j;
      cin>>n>>m;
      ll dp[n][m];
      ms(dp,0);
      dp[0][0]=1;
      string arr[n];
      fr(i,0,n)
      cin>>arr[i];
      fr(i,0,n)
      {
        fr(j,0,m)
        {
          if(arr[i][j]=='.')
          {
            if(i)
            dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
          if(j)
          dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
        }
        }
      }
      cout<<dp[n-1][m-1];
      
       
    }
  return 0;
  }



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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
        static void SolveA()
        {
            string c0 = Console.ReadLine();
            string c1 = Console.ReadLine();
            bool ans = true;
            if( c0[0] != c1[2] || c0[1] != c1[1] || c0[2] != c1[0]) { ans = false; }
            string anss = ans ? "YES" : "NO";
            Console.WriteLine(anss);
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if( n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if( n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> pii;
#define INF 0x3f3f3f3f
const int N = 100010;
int mod = 1000000007;
int main()
{
	//freopen("in.txt", "r", stdin);
	int T, n, k;
	while (~scanf("%d", &n))
	{
		printf("%d\n", n/3);
	}
   	return 0;
}

Measured memory_bytes: 256
x=list(map(int,input().split()))
ww=[]
min=x[1]
flag=0
min2=100000


for i in range(x[0]):
    ww.append([])
    ww[i] = list(map(int, input().split()))
    if ww[i][1]<=min:
        if ww[i][0]<min2:
            min2=ww[i][0]



    else:
       flag+=1
if flag== x[0]:
    print("TLE")
else:
    print(min2)


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

int main() {
  int n;
  cin >> n;
  cout << 3*n*n << endl;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll X, Y;
  cin >> X >> Y;
  if((4*X-Y)%2==0 and (Y - 2*X)%2==0){
    ll a = (4*X-Y)/2;
    ll b = (Y-2*X)/2;
    if(0<=a and a<=X and 0<=b and b<=Y){
      cout << "Yes";
    }else{
      cout << "No";      
    }
  }else{
    cout << "No";      
  }
  return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
 
int main()
{
  int A=0,B=0,C=0,D=0;
  scanf("%d%d%d",&A,&B,&C);
  
  if(A<C)
  {
    D = A;
    A = C;
    C = D;
  }
  
  if(A<B)
  {
    D = A;
    A = B;
    B = D;
  }
  
    if(B<C)
  {
    D = B;
    B = C;
    C = D;
  }
  
  printf("%d",A*10+B+C);
  
  return 0;
}

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

using namespace std;

const int M = 1000000007;

int main() {
	int n;
	cin >> n;
	long long ans = 1;
	for (int i = 1; i <= n; i++) {
		ans *= i;
		ans %= M;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
# encoding: utf-8
D_MAX = 10
P_MAX = 100

num_and_pnt = lambda x: [int(x[0]), int(x[1]) // 100]
D, G = num_and_pnt(input().split())
# [pi, ci]
pc = [num_and_pnt(input().split()) for i in range(D)]

G_list = [(i + 1) * x[0] + x[1] for i, x in enumerate(pc)]
cnt_list = [x[0] for i, x in enumerate(pc)]
idx = [map(int, format(i, "b")) for i in range(2 ** D)]

# i, G_comp, cnt_comp
table = [ (i, sum([((i // (2 ** j)) % 2) * G_list[j] for j in range(D)]), sum([((i // (2 ** j)) % 2) * cnt_list[j] for j in range(D)])) for i in range(2 ** D)] # very long
# print(table)
mincnt = D_MAX * P_MAX
for i, (G_last, cnt_last) in enumerate(zip(G_list, cnt_list)):
    for j, G_comp, cnt_comp in filter(lambda x: (((x[0] // (2 ** i)) % 2 == 0) and (x[1] <= G < x[1] + G_last) and (x[2] < mincnt)), table):
        # print(i, (G_last, cnt_last), j, G_comp, cnt_comp)
        cnt_last_tmp = min((-((G_comp - G) // (i + 1)), cnt_last))
        if cnt_comp + cnt_last_tmp < mincnt: mincnt = cnt_comp + cnt_last_tmp

print(mincnt)


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using  namespace std;
#define ll long long
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int p=s.length();
    int sum=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='A' && s[i+1]=='B'&& s[i+2]=='C') sum++;

    }
    cout<<sum<<endl;
    return 0;
}


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

int main(){
  int n,alice=0,bob=0,tmp;
  cin >> n;
  vector<int> line(n);
  for(int i=0;i<n;i++){
    cin >> line.at(i);
  }
  for(int i=0;i<n-1;i++){
    for(int j=n-1;j>i;j--){
      if(line.at(j)>line.at(j-1)){
        tmp=line.at(j);
        line.at(j)=line.at(j-1);
        line.at(j-1)=tmp;
      }
    }
  }
  for(int i=0;i<n;i++){
      if((i+1)%2==1)alice+=line.at(i);
      else bob+=line.at(i);
  }
  cout << alice - bob << endl;
}
      

Measured memory_bytes: 3584
import java.util.*;
import java.util.function.*;
import java.lang.*;
import java.io.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        long K = sc.nextLong();

        long[] A = new long[N];
        long[] B = new long[M];

        for(int n=0; n<N; n++) A[n] = sc.nextLong();
        for(int m=0; m<M; m++) B[m] = sc.nextLong();

        TreeMap<Long, Integer> sumA = new TreeMap<>();
        sumA.put(0L, 0);
        long a = 0;
        for(int n=0; n<N; n++){
            a += A[n];
            sumA.put(a, n+1);
        }

        TreeMap<Long, Integer> sumB = new TreeMap<>();
        sumB.put(0L, 0);
        long b = 0;
        for(int m=0; m<M; m++){
            b += B[m];
            sumB.put(b, m+1);
        }

        int ans = 0;
        for(long s: sumA.keySet()) if(K-s >= 0){
            long t = sumB.floorKey(K-s);
            ans = Math.max(ans, sumA.get(s)+sumB.get(t));
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 93240
import scala.math.{min,max}

object Main {
  val sc = new java.util.Scanner(System.in);
  def main(args: Array[String]) {
    val d = sc.nextInt()
    for(i <- 1 to d) {
      if(i > 1) {
        println
      }
      var n = sc.nextInt()
      val m = Array.ofDim[Char](n, n)
      for(j <- 0 until n) {
        for(k <- 0 until n) {
          m(j)(k) = ' '
        }
      }
      var x, y = 0
      while(n > 0) {
        n match {
          case 1 => {
            m(x)(y) = '#'
          }
          case 2 => {
            m(x+0)(y+0) = '#'
            m(x+1)(y+0) = '#'
            m(x+1)(y+1) = '#'
          }
          case 3 => {
            for(j <- 0 to 2) {
              m(x+j)(y+0) = '#'
              m(x+j)(y+2) = '#'
              m(x+2)(y+j) = '#'
            }
          }
          case 4 => {
            for(j <- 0 to 3) {
              m(x+j)(y+0) = '#'
              m(x+j)(y+3) = '#'
              m(x+3)(y+j) = '#'
            }
            m(x)(y+2) = '#'
          }
          case _ => {
            for(j <- 0 until n) {
              m(x+j)(y) = '#'
              m(x+j)(y+n-1) = '#'
              m(x+n-1)(y+j) = '#'
            }
            for(j <- 2 until n) {
              m(x)(y+j) = '#'
            }
            m(x+1)(y+2) = '#'
          }
        }
        x = x+2
        y = y+2
        n = n-4
      }
      m.reverse.foreach(a => println(a.mkString("")))
    }
  }
}

Measured memory_bytes: 49124