akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)));
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(typename vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)
typedef long  LL;

int N;
int T , A;
LL x , y;

int main(){
	scanf("%d%lld%lld" , &N , &x , &y);
	repp(i,1,N){
		scanf("%d%d" , &T , &A);
		if(x % T != 0) x += (LL)T - (x % T);
		if(y % A != 0) y += (LL)A - (y % A);
		if(x / T < y / A) x = y / A * T;
		else y = x / T * A;
	}
	printf("%lld\n" , x + y);
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX(p,q) ((p>q)?(p):(q))
#define MIN(p,q) ((p<q)?(p):(q))

#define REP(i,n) for(i=0;i<n;i++)

int main(void)
{
  int n,k,ans;
  scanf("%d%d",&n,&k);
  ans = (n%k!=0);
  printf("%d",ans);
  return 0;
}


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

int main(){
	char s[16], c;
	int l = 0;
	while((c=getchar()) != '\n') s[l++] = c;
	
	int ans = 0;
	for(int i=0; i<l; i++) for(int j=i; j<l; j++) {
		bool ok = true;
		for(int k=i; k<=j; k++){
			if(s[k]!='A' and s[k]!='C' and s[k]!='G' and s[k]!='T') ok = false;
		}
		if(ok) ans = std::max(ans, j-i+1);
	}
			
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int N, K;
int A[100010];

int gcd(int a, int b)
{
    return b == 0 ? a : gcd(b, a % b);
}

int main()
{
    cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> A[i];
    int GCD = 0, mx = 0;
    for (int i = 0; i < N; ++i) {
        GCD = gcd(GCD, A[i]);
        mx = max(mx, A[i]);
    }

    if (mx < K) {
        cout << "IMPOSSIBLE\n";
        return 0;
    }

    if (GCD == 1 or K % GCD == 0) {
        cout << "POSSIBLE\n";
    } else {
        cout << "IMPOSSIBLE\n";
    }
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int n, m;
vector<vector<pii>> G; // (to, index)
vector<pii> Q; // query
vector<ll> path;

bool dfs(int v, int p, int fin, int id){
    if (v == fin) {
        return true;
    }

    for (auto &x : G[v]) {
        if (x.first == p) continue;
        if (dfs(x.first, v, fin, id)) {
            path[id] |= (1LL << x.second);
            return true;
        }
    }
    return false;
}

int main(){
    cin >> n;
    G.assign(n, vector<pii>());
    for (int i = 0; i < n-1; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(pii(b, i));
        G[b].push_back(pii(a, i));
    }
    cin >> m;
    Q.resize(m);
    path.assign(m, 0);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        Q[i] = pii(u, v);
    }
    for (int i = 0; i < m; ++i) {
        dfs(Q[i].first, -1, Q[i].second, i);
    }

    ll res = 1LL << (n-1);
    ll com = 0;
    for (int i = 1; i < (1<<m); ++i) {
        ll a = 0;
        for (int j = 0; j < m; ++j) {
            if (i & (1LL << j)) {
                a |= path[j];
            }
        }
        ll b = 1LL << (n - 1 - __builtin_popcountll(a));
        if (__builtin_popcount(i) % 2) com += b;
        else com -= b;
    }
    cout << res - com << endl;
}

Measured memory_bytes: 3600
def main():
    n, x = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    ans = 0
    for v in a:
        if v > x:
            x = 0
            break
        else:
            x -= v
            ans += 1
    if 0 < x:
        ans -= 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    int n;
    cin>>n;
    vector<ll> vec(n);
    for(int i = 0; i < n; i++)
        cin>>vec[i];
    vector<ll> prefix(n), suffix(n);
    for(int i = 0; i < n; i++){
        if(i)
            prefix[i] = prefix[i-1];
        prefix[i] ^= vec[i];
    }
    for(int i = n-1; i >= 0; i--){
        if(i != n-1)
            suffix[i] = suffix[i+1];
        suffix[i] ^= vec[i];
    }
    for(int i = 0; i < n; i++){
        ll ans = 0;
        if(i)
            ans ^= prefix[i]^vec[i];
        if(n-1-i)
            ans ^= suffix[i]^vec[i];
        cout<<ans<<" ";
    }
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 7900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E15;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////


 
int main(){fastio
    
    ll n;cin>>n;
    cout<<(n-1)/2<<endl;
    
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
 
using namespace std;
 
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_2_B&lang=jp
 
struct Edge {
  int dst,weight;
};
 
int ChinesePostmanProblem(int V,int E,vector<int> s,vector<int> t,vector<int> d) {
  int mini = 0;
  vector<vector<Edge> > G(V);
  vector<vector<int> > wf(V,vector<int>(V,INT_MAX));
  for(int i=0;i<V;++i) wf[i][i] = 0;
  for(int i=0;i<E;++i) {
    G[s[i]].push_back((Edge){t[i],d[i]});
    G[t[i]].push_back((Edge){s[i],d[i]});
    wf[s[i]][t[i]] = wf[t[i]][s[i]] = min(wf[s[i]][t[i]],d[i]);
    mini += d[i];
  }
  for(int k=0;k<V;++k) for(int i=0;i<V;++i) for(int j=0;j<V;++j) if( wf[i][k] != INT_MAX && wf[k][j] != INT_MAX ) wf[i][j] = min(wf[i][j],wf[i][k]+wf[k][j]);
  vector<int> odd;
  for(int i=0;i<V;++i) if( (int)G[i].size() & 1 ) odd.push_back(i);
  int n = (int)odd.size();
  vector<int> dp((1<<n),INT_MAX);
  dp[0] = 0;
  for(int state=0;state<(1<<n);++state) {
    for(int sp=0;sp<n;++sp) if( !( (state>>sp) & 1 ) ) {
        for(int ep=0;ep<n;++ep) if( sp != ep && !( (state>>ep) & 1 ) )  {
            dp[state|(1<<sp)|(1<<ep)] = min(dp[state|(1<<sp)|(1<<ep)],
                                            dp[state]+wf[odd[sp]][odd[ep]]);
          }
      }
  }
  return mini + dp[(1<<n)-1];
}
 
int main() {
  int V,E;
  cin >> V >> E;
  vector<int> s(E),t(E),d(E);
  for(int i=0;i<E;++i) cin >> s[i] >> t[i] >> d[i];
  cout << ChinesePostmanProblem(V,E,s,t,d) << endl;
  return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(n);
// string p=s.substr(0,len);
// sort(arr, arr+n, greater<int>());
// cout<<fixed<<setprecision(9)<<pi<<endl
// const  double pi = acos(-1.0);
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	ld a,b;
	cin>>a>>b;
	ld ans = a*b;
	ll fans = trunc(ans);
	cout<<fans<<endl;
}

Measured memory_bytes: 3744
#include<iostream>
#include<list>
using namespace std;
void dump(list<int> &li);
int main()
{
	int num;
	cin >> num;
	list<int> p[num];
	int oper;
	cin >> oper;
	while (oper--)
	{
		int opr;
		cin >> opr;
		switch (opr)
		{
			int num;
		case 0:
			cin >> num;
			int countt;
			cin >> countt;
			p[num].insert(p[num].end(), countt);
			break;
		case 1:
			cin >> num;
			dump(p[num]);
			break;
		case 2:
			cin >> num;
			int num2;
			cin >> num2;
			p[num2].splice(p[num2].end(), p[num]);
			p[num].clear();
			break;
		}
	}
}
void dump(list<int> &li)
{
	 list<int>::iterator p;
	if (li.empty() == false)
	{
		for (p = li.begin();;)
		{
			cout << *p;
			if (++p == li.end())
				{
				    cout<<endl;break;
				}
			else
				cout << " ";
		}
	}
	else
		cout << endl;
}



Measured memory_bytes: 18712
n, a, b = map(int, input().split())
count = 0
total = 0
for i in range(1,n+1,1):
    str_i = str(i)
    for j in range(len(str_i)):
        total+=int(str_i[j])
    if total >= a and total <= b:
        count+=i
    total=0
print(count)
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
#define f first
#define s second
#define pb push_back

string s;
int q, t, f;
char ch;
deque<char> dq;
bool fif = true;

int main() {
	cin >> s >> q;
	FOR(i, 0, s.length()-1) dq.pb(s[i]);
	while (q--) {
		cin >> t;
		if (t == 1) fif = !fif;
		else {
			cin >> f >> ch;
			if (f == 2) f = 0;
			if (fif ^ f) dq.pb(ch);
			else dq.push_front(ch);
		}
	}
	if (!fif) reverse(dq.begin(), dq.end());
	for (auto it:dq) cout << it;
}


Measured memory_bytes: 896
N = input()

T = [[[0]*4 for i in range(4)] for j in range(4)]
for c1 in range(4):
  for c2 in range(4):
    for c3 in range(4):
      if (0, 1, 2) not in [
        (c1, c2, c3),
        (c2, c1, c3),
        (c1, c3, c2),
      ]:
        T[c1][c2][c3] = 1

for i in range(3, N):
  P = T
  T = [[[0]*4 for i in range(4)] for j in range(4)]
  for c1 in range(4):
    for c2 in range(4):
      for c3 in range(4):
        for c4 in range(4):
          if (0, 1, 2) not in [
            (c2, c3, c4),
            (c3, c2, c4),
            (c2, c4, c3),
            (c1, c3, c4),
            (c1, c2, c4),
          ]:
            T[c2][c3][c4] += P[c1][c2][c3]
            T[c2][c3][c4] %= 1000000007
print sum(sum(sum(t2) for t2 in t1) for t1 in T) % 1000000007


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

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

    int N, M;
    cin >> N >> M;
    vector<vector<int> > G(N + 1);
    for (int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;
        G.at(A).push_back(B);
        G.at(B).push_back(A);
    }
    vector<int> ans(N + 1, INT_MAX);
    vector<int> dist(N + 1, INT_MAX);
    dist.at(1) = 0;
    queue<int> que;
    que.push(1);
    while (!que.empty()) {
        auto p = que.front();
        que.pop();
        for (auto &x : G.at(p)) {
            if (dist.at(x) > dist.at(p) + 1) {
                dist.at(x) = dist.at(p) + 1;
                ans.at(x) = p;
                que.push(x);
            }
        }
    }
    for (int i = 2; i <= N; ++i) {
        if (ans.at(i) == INT_MAX) {
            cout << "No" << endl;
            exit(0);
        }
    }
    cout << "Yes" << endl;
    for (int i = 2; i <= N; ++i) {
        cout << ans.at(i) << endl;
    }

    return 0;
}

Measured memory_bytes: 10648
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let x: usize = scan(tokens);
    let n = x / 100;
    if x <= n * 105 {
        println!("1");
    } else {
        println!("0");
    }
}


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

#ifdef DEBUG
#include "../.inc/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

const long long INF = 1e10;
const int MAXV = 2550;

struct Edge {
    long long from, to, cost;
};

long long shortest(vector<Edge> &edges, int n, int s, int t) {
    bool fromS[MAXV] = {};
    fromS[s] = true;
    for (int i=0; i<n; ++i) {
        for (Edge &e: edges) {
            fromS[e.to] |= fromS[e.from];
        }
    }
    bool toT[MAXV] = {};
    toT[t] = true;
    for (int i=0; i<n; ++i) {
        for (Edge &e: edges) {
            toT[e.from] |= toT[e.to];
        }
    }

    long long d[MAXV];
    for (int i=0; i<MAXV; ++i) d[i] = INF;
    d[s] = 0;
    for (int i=0; i<2*n; ++i) {
        for (Edge &e: edges) {
            if (d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                if (i >= n && fromS[e.to] && toT[e.to]) {
                    return INF;
                }
            }
        }
    }
    return d[t];
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    int N, M, P;
    cin >> N >> M >> P;

    vector<Edge> edges;
    for (int i=0; i<M; ++i) {
        int A, B, C;
        cin >> A >> B >> C;
        edges.push_back((Edge){ A, B, -(C-P) });
    }

    long long score = shortest(edges, N, 1, N);
    if (score == INF) {
        cout << -1 << endl;
    } else {
        cout << max(0LL, -score) << endl;
    }

    return 0;
}

Measured memory_bytes: 576
def examA():
    N = I()
    ans = (N-1)//2
    print(ans)
    return

def examB():
    N = I()
    D = LI()
    d = Counter(D)
    loop = max(d.keys())
    if D[0]!=0 or d[0]!=1:
        print(0)
        return
#    print(d,loop)
    ans = 1; cur = 1
    for i in range(loop+1):
        if d[i]==0:
            print(0)
            return
        for _ in range(d[i]):
            ans *= cur
            ans %= mod2
        cur = d[i]
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LFI(): return list(map(float,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examB()

"""

"""

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

string S;
void input(){
    cin>>S;
    return;
}

bool check(string S){
    int N=S.size();
    bool rtn1=true,rtn2=true;
    for(int i=0;i<N;i+=2){
        if(S[i]=='L'){
            rtn1=false;
            break;
        }
    }
    for(int i=1;i<N;i+=2){
        if(S[i]=='R'){
            rtn2=false;
            break;
        }
    }
    if(rtn1&&rtn2) return true;
    else return false;
}

void solve(){
    string ans;
    if(check(S)) ans="Yes";
    else ans="No";
    cout<<ans<<endl; 
    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

ll q, h, s, d, n, dt;

inline ll llmin(ll a, ll b) {
    return a < b ? a : b;
}

void prepare() {
    s = llmin(
        s,
        llmin(
            q * 4,
            llmin(
                h * 2,
                q * 2 + h
            )
        )
    );
    d = llmin(d, s * 2);
}

int main() {
    cin >> q >> h >> s >> d >> n;
    dt = n % 2;
    n -= dt;

    prepare();

    ll total = d * (n / 2) + s * dt;
    cout << total << endl;

    return 0;
}


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

int     main() {
        int N;
        cin >>N;
        vector<int> p(N);
        for (int i=0; i<N; i++) cin >>p.at(i);
        vector<int> q(N);
        q=p;
        sort(q.begin(), q.end());
        int S=0;
        for (int i=0; i<N; i++) {
                if (p.at(i)!=q.at(i)) S++;
        }
        if (S==2) cout <<"YES";
        else if (S==0) cout <<"YES";
        else cout <<"NO";
        cout <<endl;
        return 0;
};

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N, T;
  cin >> N >> T;
  vector<pll> AB(N);
  for (ll i = 0; i < N; ++i) {
    cin >> AB.at(i).first >> AB.at(i).second;
  }
  vector<vector<ll>> dp1(N, vector<ll>(T, 0));
  vector<vector<ll>> dp2(N, vector<ll>(T, 0));
  for (ll i = 0; i < N - 1; ++i) {
    ll a = AB.at(i).first, b = AB.at(i).second;
    for (ll j = 0; j < T; ++j) {
      if (j != 0) {
        dp1.at(i).at(j) = max(dp1.at(i).at(j), dp1.at(i).at(j - 1));
      }
      if (i != 0) {
        dp1.at(i).at(j) = max(dp1.at(i - 1).at(j), dp1.at(i).at(j));
      }
      if (a + j >= T) {
        continue;
      }
      ll now = dp1.at(i).at(j);
      dp1.at(i + 1).at(j + a) = max(dp1.at(i + 1).at(j + a), now + b);
    }
  }
  for (ll i = N - 1; i > 0; --i) {
    ll a = AB.at(i).first, b = AB.at(i).second;
    for (ll j = 0; j < T; ++j) {
      if (j != 0) {
        dp2.at(i).at(j) = max(dp2.at(i).at(j), dp2.at(i).at(j - 1));
      }
      if (i != N - 1) {
        dp2.at(i).at(j) = max(dp2.at(i + 1).at(j), dp2.at(i).at(j));
      }
      if (a + j >= T) {
        continue;
      }
      ll now = dp2.at(i).at(j);
      dp2.at(i - 1).at(j + a) = max(dp2.at(i - 1).at(j + a), now + b);
    }
  }
  ll ans = 0;
  for (ll i = 0; i < N; ++i) {
    for (ll j = 0; j < T; ++j) {
      ans = max(ans, dp1.at(i).at(j) + dp2.at(i).at(T - j - 1) + AB.at(i).second);
    }
  }
  cout << ans << "\n";
  // for (ll i = 0; i < N; ++i) {
  //   for (ll j = 0; j < T; ++j) {
  //     cout << dp1.at(i).at(j) << " ";
  //   }
  //   cout << "\n";
  // }
}


Measured memory_bytes: 141312
#include<cstdio>
#include<cstring>
const int maxs=105;
int n,m;
char map[maxs][maxs];
int vis[maxs][maxs];
int xx[4]={1,0,0,-1};
int yy[4]={0,1,-1,0};
void dfs(int x,int y,char c)
{
    for(int i=0;i<4;i++)
    {
        int a=x+xx[i];
        int b=y+yy[i];
        if(a>=0&&a<n&&b>=0&&b<m&&!vis[a][b]&&map[a][b]==c)
        {
            vis[a][b]=1;
            dfs(a,b,c);
        }
    }
}
int main()
{
    while(scanf("%d%d",&n,&m)!=EOF&&n!=0)
    {
        memset(vis,0,sizeof(vis));
        for(int i=0;i<n;i++)
        scanf("%s",map[i]);
        int ans=0;

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

            for(int j=0;j<m;j++)
            {
                if(!vis[i][j])
                {
                    ans++;
                    vis[i][j]=1;
                    dfs(i,j,map[i][j]);

                }
            }
        }



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

Measured memory_bytes: 1556
def q3():
    W, H, x, y = (int(i) for i in input().split())

    # 最大になるのは面積のちょうど半分
    ans1 = W * H / 2

    # (x,y)が長方形の中心の場合1
    ans2 = 0
    if x*2 == W and y*2 == H:
        ans2 = 1

    print('{0:.6f} {1}'.format(ans1, ans2))


if __name__ == '__main__':
    q3()


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a, b, c, d; cin >> n; 
	int test[101] = { 0 }, uiop[101] = { 1 };
	for (int h = 0; h < n * (n - 1) / 2; h++) {
		cin >> a >> b >> c >> d;
		if (c > d) {
			test[a] += 3;
		}
		else if (c < d) {
			test[b] += 3;
		}
		else {
			test[a] += 1;
			test[b] += 1;
		}
	}
	for (int h = 1; h <= n; h++) {
		int num = 1;
		for (int i = 1; i <= n; i++) {
			if (test[h] < test[i]) {
				num++;
				uiop[h] = num;
			}
			if (num == 1) {
				uiop[h] = 1;
			}
		}
	}
	for (int h = 1; h <= n; h++) {
		cout << uiop[h] << endl;
	}
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,M,a[N];
int calc(int l,int r){
	int Max=0;l<0?l=1:0;
	for (int i=0;i<r-l+1>>1;i++)Max=max((a[l+i]+a[r-i])%M,Max);
	return Max;
}
int main(){
	scanf("%d%d",&n,&M);
	for (int i=1;i<=n*2;i++)scanf("%d",&a[i]);
	sort(a+1,a+n*2+1);
	int l=0,r=n;
	while (l<r){
		int mid=(l+r)/2,i;
		for (i=0;i<n-mid;i++)
			if (a[mid*2+1+i]+a[n*2-i]<M)break;
		if (i<n-mid)l=mid+1;
		else r=mid;
	}
	printf("%d\n",max(calc(1,l*2),calc(l*2+1,n*2)));
	return 0;
}

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

int main(){
  int h, w;
  while(1){
    cin >> h >> w;
    if(h==0 && w==0){ break; }
    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
    if((i+j)%2==0){
      cout << "#";
    }else{
      cout << ".";
    }
      }
      cout << "\n";
    }
    cout << "\n";
  }
  return 0;
}

Measured memory_bytes: 1120
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int64
	scanner.Scan()
	N, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	fmt.Println(solve(N))
}
func solve(R int64) float64 {
	return float64(R) * 2 * 3.14
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
typedef long long ll;
const int MAX_N=100;
const ll INF=1e15;
int N,x[MAX_N],y[MAX_N];
ll h[MAX_N];
int main(){
	cin>>N;
	REP(i,N){
		cin>>x[i]>>y[i]>>h[i];
	}
	int cx,cy;
	ll H;
	REP(s,101){
		REP(t,101){
			ll lb=INF,th=-1;
			bool flg=false;
			REP(i,N){
				if (h[i]>0){
					if (th==-1){
						th=h[i]+abs(x[i]-s)+abs(y[i]-t);
					}else if (th!=h[i]+abs(x[i]-s)+abs(y[i]-t)){
						flg=true;
					}
				}else{
					lb=min(lb,(ll)abs(x[i]-s)+abs(y[i]-t));
				}
			}
			if (!flg && th<=lb && th!=-1){
				cx=s;
				cy=t;
				H=th;
			}
		}
	}
	cout<<cx<<" "<<cy<<" "<<H<<endl;
	return 0;
}

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

typedef long long ll;
typedef vector<int> vec;

int main() {
    int N;
    cin >> N;
    vec A(N);
    rep(i, N) cin >> A[i];
    
    int tmp = 0;
    int rec = 0;
    
    rep(i, N) {
        if (tmp <= A[i]) {
            tmp = A[i];
            rec = i;
        }
       
    }
    
    int cnt = 0;
    
    rep(i, N) {
        if (A[i] == tmp) cnt++;
    }
    
    if (cnt >= 2) {
        rep(i, N) {
            cout << tmp << endl;
        }
        return 0;
    }
    
    A[rec] = 0;
    int tmp2 = 0;
    rep(i, N) {
        tmp2 = max(tmp2, A[i]);
    }
    
    rep(i, N) {
        if (i != rec) {
            cout << tmp << endl;
        } else {
            cout << tmp2 << endl;
        }
    }
    
    
    
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,m,ans,sum,a[N],b[N];
char s[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	n=read();m=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
		sum+=a[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]*4*m>=sum)ans++;
	}
	if(ans>=m)puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin >> N;
	vector<int> vec(N);
	int max=0;
	int min=0;
	long long int sum=0;
	for (int i = 0; i < N; ++i)
	{
		cin >> vec.at(i);
		sum += vec.at(i);
	}
	sort(vec.begin(),vec.end());
	max = vec.at(N-1);
	min = vec.at(0);
	cout << min <<" "<<max <<" "<< sum <<endl;
}


Measured memory_bytes: 3200
n,k=map(int,input().split())
a=list(map(int,input().split()))
a_sum=sum(a)
def devisor(x):
    lst=[]
    i=1
    y=x
    while i**2<=y:
        if x%i==0:
            lst.append(i)
            if i!=x//i:
                lst.append(x//i)
        i+=1
    lst.sort()
    return lst
re=devisor(a_sum)
re.sort(reverse=True)
for u in re:
    w=[]
    for v in a:
        w.append(v%u)
    w.sort()
    b=sum(w)
    count=0
    for i in range(b//u):
        w[-i-1]-=u
    for i in w:
        if i>=0:
            count+=i
        else:
            break
    if count<=k:
        print(u)
        break

Measured memory_bytes: 42860
#include<iostream>
#include<algorithm>
#include<climits>
#include<cstdio>
#include<cmath>
using namespace std;
int Q;
long long a,b;
int main()
{
    scanf("%d",&Q);
    while(Q--)
    {
        scanf("%lld%lld",&a,&b);
        if(a>b)swap(a,b);
        long long c=sqrt(a*b);
        if(c*c==a*b)c--;
        if(a==b)printf("%lld\n",2*a-2);
        else if(a+1==b)printf("%lld\n",2*a-2);
        else if(c*(c+1)>=a*b)printf("%lld\n",2*c-2);
        else if(c*(c+1)<a*b)printf("%lld\n",2*c-1);
    }
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<vector<pair<int, int>>> X(N);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < a; j++) {
      int x, y;
      cin >> x >> y;
      x--;
      X[i].emplace_back(make_pair(x, y));
    }
  }
  int res = 0;
  for (int b = 0; b < (1 << N); b++) {
    int cnt = 0;
    for (int i = 0; i < N; i++) {
      if (!((b >> i) & 1)) continue;
      for (int j = 0; j < (int)X[i].size(); j++) {
        if (X[i][j].second != ((b >> X[i][j].first) & 1)) cnt = -(1 << 28);
      }
      cnt++;
    }
    res = max(res, cnt);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException{
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    String[] a_str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int m = Integer.parseInt(str[1]);
    int[] a = new int[n];
    int sum = 0;
    int count = 0;

    for(int i = 0; i < n; i++) {
      a[i] = Integer.parseInt(a_str[i]);
      sum += a[i];
    }

    for(int i = 0; i < n; i++) {
      if((double)a[i] < (double)sum/(4*m)){
        count += 1;
      }
    }
    System.out.println(n-count>=m?"Yes":"No");
  }
}


Measured memory_bytes: 32568
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int N;cin>>N;
    string ans="";
    while(N!=0){
        int d=N%2;
        if(d<0)d+=2;
        N=-(N-d)/2;
        ans+=(char)(d+'0');
    }
    reverse(ans.begin(),ans.end());
    if(ans=="")ans="0";
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		while (n-- > 0) {
			int s = scanner.nextInt();
			int g = scanner.nextInt();
			int ans = 0;
			while (s < g) {
				int to = 1;
				while (true) {
					int next = to * 2;
					if (s % next != 0)
						break;
					if (s + next > g)
						break;
					to = next;
				}
				s += to;
				ans++;
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 20388
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

class Node{
    public:
        Node* prev;
        Node* next;
        int data;
        Node(){prev = 0; next = 0; data = 0;}
};

class List{
    public:
        Node head;
        Node* btn;
        List(){head.prev = &head; head.next = &head; head.data = -1;}
        int append(int x);
        int del(int a);
        bool search(int d);
};

int List::append(int x){
    Node* p = new Node();

    if(p == 0) 
        return -1;

    Node* q = head.prev;
    Node* r = &head;

    p->prev = q;
    p->next = r;
    p->data = x;

    q->next = p;
    r->prev = p;

    return 0;
}

int List::del(int a){
    if(a%2 == 0){
        for(int i = 0; i < a; i++){
            btn = btn->next;
            if(btn == &head){
                btn = btn->next;
            }
        }
    }else{
        for(int i = 0; i < a; i++){
            btn = btn->prev;
            if(btn == &head){
                btn = btn->prev;
            }
        }
    }

    Node* p = btn;
    btn = btn->next;
    if(btn == &head){
        btn = btn->next;
    }
    Node* q = p->prev;
    Node* r = p->next;

    q->next = r;
    r->prev = q;

    delete p;

    return 0;
}

bool List::search(int d){
    for(Node* p = head.next; p != &head; p = p->next){
        if(p->data == d){
            return true;
        }
    }
    return false;
}

int main(){
    int n,m,q;
    cin >> n >> m >> q;

    List L;

    rep(i,n) L.append(i);

    L.btn = L.head.next;

    rep(i,m){
        int a;
        cin >> a;
        L.del(a);
    }

    rep(i,q){
        int q;
        cin >> q;
        if(L.search(q)){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 9308
#include <bits/stdc++.h>
using namespace std;
int n;
pair<int,int> a[123456];
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>(a[i].first);
        a[i].second=(i+1);
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
        cout<<(a[i].second)<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 1664
#include<stdio.h>
#define N 100

int selectionSort(int *, int);

int main(){
  int i, n, A[N], count;

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

  count = selectionSort(A, n);

  for(i=0; i<n; i++){
    printf("%d", A[i]);
    if(i == n-1) printf("\n");
    else printf(" ");
  }
  printf("%d\n", count);

  return 0;
}

int selectionSort(int *A, int n){
  int i, j, minj, a, count=0;

  for(i=0; i<n; i++){
    minj = i;
    for(j=i; j<n; j++){
      if(A[j] < A[minj]) minj = j;
    }

    if(A[i] != A[minj]){
      a = A[i];
      A[i] = A[minj];
      A[minj] = a;
      count++;
    }
  }

  return count;
}



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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

vector<pair<long long, long long> > prime_factorize(long long N) {
  vector<pair<long long, long long> > res;
  for (long long a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    long long ex = 0;  // 指数

    // 割れる限り割り続ける
    while (N % a == 0) {
      ++ex;
      N /= a;
    }

    // その結果を push
    res.push_back({a, ex});
  }

  // 最後に残った数について
  if (N != 1) res.push_back({N, 1});
  return res;
}

void solve(ll N, ll P) {
  ll ans = 1;

  for (auto p : prime_factorize(P)) {
    if (p.second >= N) {
      ll v = floor(p.second / N);
      ans *= pow(p.first, v);
    }
  }

  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  ll P;
  scanf("%lld", &P);
  solve(N, P);
  return 0;
}


Measured memory_bytes: 4208
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 200010
using namespace std;
string s;
char buf[N];
ll ans=0,dp[2020];
int main(){
	ll i,j,p=1,x=0;
	scanf("%s",&buf);
	s=buf;
	dp[0]=1;
	for(i=s.size()-1;i>=0;i--)
	{
		x=(x+(s[i]-'0')*p)%2019;
		p=(p*10)%2019;
		ans+=dp[x];
		dp[x]++;
	}
	printf("%lld\n",ans);
	return 0;
}

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

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

  for(int i=0;i<n;i++){
    if((i+1)%2==1&&a[i]%2==1){
      cut++;
    }
  }

  cout << cut << endl;

  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);

int n;



signed main(){
    vec(a,3);
    cin >> a[0] >> a[1] >> a[2];
    Sort(a);
    cout << a[0] << " " << a[2] << endl;


    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;

int main()
{
    int r, c;
    cin >> r >> c;

    vector<vector<int>> arr(r + 1, vector<int>(c + 1, 0));
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            cin >> arr[i][j];
            arr[i][c] += arr[i][j];
            arr[r][j] += arr[i][j];
            arr[r][c] += arr[i][j];
        }
    }

    for (int i = 0; i <= r; i++) {
        for (int j = 0; j < c; j++) {
            printf("%d ", arr[i][j]);
        }
        printf("%d\n", arr[i][c]);
    }
}



Measured memory_bytes: 3300
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl
#define YORN(f) cout<<((f)?"YES":"NO")<<endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a * b > c * d) {
        cout << a * b << endl;
    }
    else {
        cout << c * d << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int cnt[100000];

int main(){
    int N, M;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        cnt[a-1]++;
        cnt[b-1]++;
    }
    for(int i = 0; i < N; i++){
        if(cnt[i]%2 == 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

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

using namespace std;

int main() {
	long n, a = 0;
	cin >> n;
	for (int r = 1; r + 1 < n / r; r++)
		if (n%r == 0) a += n / r - 1;
	cout << a << endl;
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Problem: A
# Misterious Gems

require 'scanf'

def scanf(format)
  line = gets
  if line
    line.scanf(format)
  else
    []
  end
end

class Robot
  attr_reader :map, :x, :y, :ngem

  def initialize(map, x, y)
    @map = map
    @x = x
    @y = y
    @ngem = 0
  end

  def go(dir, n)
    vx = 0
    vy = 0
    case dir
    when 'N'
      vy = 1
    when 'S'
      vy = -1
    when 'E'
      vx = 1
    when 'W'
      vx = -1
    end

    n.times do |i|
      @x += vx
      @y += vy

      if @map[@y][@x]
        @ngem += 1
        @map[@y][@x] = nil
      end
    end
  end  
end

while true
  n, = scanf('%d')
  break if n == 0

  map = Array.new(21) do |i|
    Array.new(21)
  end
  
  # ???????????????????¨????
  n.times do
    x, y = scanf('%d %d')
    map[y][x] = true
  end
  
  m, = scanf('%d')
  robot = Robot.new(map, 10, 10)
  
  # ??????????¨????
  m.times do
    dir, len = scanf('%c %d')
    robot.go(dir, len)
  end

  if robot.ngem == n
    puts 'Yes'
  else
    puts 'No'
  end
end

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

using namespace std;

int main(){
    int ans = 0;
    int ans1 = 0;
    int n, a, b;
 
    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> a >> b;
        if(a == b){
            ans++;
        }else{

            if(ans > ans1){
                ans1 = ans;
                ans = 0;
            }else{
                ans = 0;
            }
        }
    }
   if(ans > ans1){
      ans1 = ans;
    }
  if(ans1 >= 3){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int a,b,c,d; cin >> a >> b >> c >> d;
    cout << min(a,b) + min(c,d) << endl;
}


Measured memory_bytes: 256
import heapq
def main():
    k,t=map(int,input().split())
    a=list(map(lambda x: (-int(x[1]), x[0]+1), enumerate(input().split())))
    heapq.heapify(a)
    p=None
    while len(a) > 0:
        n=heapq.heappop(a)
        if len(a) == 0:
            print(-n[0]-1)
            break
        if p == n[1] and len(a) > 0:
            n2 = n
            n = heapq.heappop(a)
            heapq.heappush(a, n2)
        if n[0] < -1:
            heapq.heappush(a, (n[0]+1, n[1]))
        p = n[1]
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9152
// 2012/11/19 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int t1, t2, t3, t4;
	cin >> t1;
	cin >> t2;
	cin >> t3;
	cin >> t4;

	int sum = t1+t2+t3+t4;
	int x = sum/60;
	int y = sum%60;

	cout << x << '\n';
	cout << y << '\n';

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int N;
vector<int> L;

int main()
{
	int ans = 0;

	cin >> N;
	L = vector<int>(N);
	for (int i = 0; i < N; i++) {
		cin >> L.at(i);
	}
	
	sort(L.begin(), L.end(), greater<int>());
		
	for (int i = 0; i < N-2; i++) {
		for (int j = i+1; j < N - 1; j++) {
			int m = L.at(i) - L.at(j);
			for (int k = j+1; k <N; k++) {
				if (L.at(k) > m) {
					ans++;
				}
				else {
					break;
				}
			}
		}
	}



	cout << ans <<endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            for(int i = 0; i < n; i++)
            {
                var ints = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                int left = 0, right = 0;
                bool b = true;
                foreach(var num in ints)
                {
                    if (left < num) left = num;
                    else if (right < num) right = num;
                    else
                    {
                        b = false;
                        break;
                    }
                }
                Console.WriteLine(b ? "YES" : "NO");
            }
        }
    }
}

Measured memory_bytes: 5696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>P;

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

int main(){
    for(ll t, n; cin >> t >> n, t;){
        map<P, ll>flg;
        for(ll i = 0; i < n; i++){
            ll x, y;
            cin >> x >> y;
            flg[P(x, y)] = 100;
        }
        ll ans = 0;
        ll X, Y;
        cin >> X >> Y;
        queue<P>Q;
        Q.push(P(X, Y));
        flg[P(X, Y)] = 1;
        while(!Q.empty()){
            ll x = Q.front().first;
            ll y = Q.front().second;
            Q.pop();
            if(flg[P(x, y)] > t + 1)continue;
            ans++;
            for(ll i = 0; i < 6; i++){
                ll nx = x + dx[i];
                ll ny = y + dy[i];
                if(flg[P(nx, ny)])continue;
                Q.push(P(nx, ny));
                flg[P(nx, ny)] = flg[P(x, y)] + 1;
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3320
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, Q;
	cin >> n >> m >> Q;
	vector<vector<int>> cnt(n, vector<int>(n+1, 0));
	rep(i,m){
		int l, r;
		cin >> l >> r;
		l--; r--;
		for(int i = 0; i <= l; i++){
			cnt[i][r]++;
		}
	}
	rep(i,n){
		rep(j,n) cnt[i][j+1] += cnt[i][j];
	}
	rep(i,Q){
		int p, q;
		cin >> p >> q;
		p--; q--;
		cout << cnt[p][q] << endl;
	}
	return 0;
}

Measured memory_bytes: 1920
import sys
from bisect import bisect_right, bisect_left

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ap = [0 for i in range(n)]
bp = [0 for j in range(m)]

for i in range(n):
	if i == 0:
		ap[i] = a[i]
	else: 
		ap[i] = a[i] + ap[i - 1]

for i in range(m):
	if i == 0:
		bp[i] = b[i]
	else: 
		bp[i] = b[i] + bp[i - 1]

bestRes = 0

#print(bp)

def search(x):
	left = 0 
	right = m - 1
	while right - left > 1:
		mid = left + (right - left) // 2
		if bp[mid] == x:
			return mid

		if bp[mid] < x:
			right = mid - 1
		else:
			left = mid + 1


	if bp[right] <= x:
		return right
	elif bp[left] <= x:
		return left
	else:
		return left - 1

for i in range(n):
	#print(i)
	if ap[i] > k:
		break

	rest = k - ap[i]

	#print(rest)

	if bp[0] > rest:
		bestRes = max(bestRes, i + 1)

	else:
		count = bisect_right(bp, rest)
		#print(i, rest, count)

		bestRes = max(bestRes, i + count + 1)


#print(bp)
#bisect_right(bp, k)

if k > bp[0]:
	count = bisect_right(bp, k)
	bestRes = max(bestRes, count)

print(bestRes)



Measured memory_bytes: 129708
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100
#define INF 1000000001

int n,m,r;

// char X[100][100];
// int dp[1000000001];

// bool used[8];
// int ans;

int p[114514];

int main(void){
    cin >> n;
    REP(i,0,n) {
        int temp;
        cin >> temp;
        p[i] = temp - 1;
    }
    
    int cnt = 0;
    bool check[n];
    REP(i,0,n) {
        if (i == n && p[i] == i) {
            swap(p[i],p[i-1]);
            cnt++;
        }
        else if (p[i] == i) {
            swap(p[i],p[i+1]);
            cnt++;
        }
        // else check[i] = true;
    }
    
    // // REP(i,0,n) {
    // //     cout << check[i] << endl;
    // // }
    
    // REP(i,0,n-1) {
    //     if (!check[i]) {
    //         check[i] = true;
    //         check[i+1] = true;
    //         cnt++;
    //     }
    // }
    
    // REP(i,0,n) {
    //     cout << check[i] << endl;
    // }
    
    cout << cnt << endl;
    
        
}

Measured memory_bytes: 640