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


using namespace std;


int main() {
    int N;
    cin >> N;
    int A[N];
    for (size_t i = 0; i < N; i++)
    {
       cin >> A[i];
    }
    int counter = 0;

    while (true)
    {
        bool flag = true;
        for (size_t i = 0; i < N; i++)
        {
            if (A[i] % 2 == 1) {
                flag = false;
            } else {
                A[i] = A[i] / 2;
            }
        }
        if (!flag) {
            break;
        }
        if (flag) {
            counter++;
        }
    }

    std::cout << counter << '\n';
    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;
const int oo = 1e8+7;
const ll mod = 1e9+7;

void self_add(ll& x, ll y) {
    x += y;
    if(x >= mod) {
        x -= mod;
    }
}

int main() {
    
    string k;
    getline(cin, k);
    
    int n = (int)k.size();
    
    int d;
    scanf("%d",&d);
    
    vector<vector<ll>> dp(d, vector<ll>(2,0));
    dp[0][1] = 1;
    
    for(int where = 0; where < n; ++where) {
        vector<vector<ll>> new_dp(d, vector<ll>(2,0));
        
        for(int digit = 0; digit < 10; ++digit) {
            for(int sum = 0; sum < d; ++sum) {
                self_add(new_dp[(sum+digit)%d][0], dp[sum][0]);
            }
            if(digit > k[where] - '0') {
                continue;
            } else if(digit < k[where] - '0') {
                for(int sum = 0; sum < d; ++sum) {
                    self_add(new_dp[(sum+digit)%d][0], dp[sum][1]);
                }
            } else if(digit == k[where] - '0') {
                for(int sum = 0; sum < d; ++sum) {
                    self_add(new_dp[(sum+digit)%d][1], dp[sum][1]);
                }   
            }
        }
        
        dp = new_dp;
    }
    
    ll ans = dp[0][0] + dp[0][1];
    ans--;
    if(ans == -1) {
        ans += mod;
    }
    
    cout << ans << endl;
    
    return 0;
}




Measured memory_bytes: 256
#pragma GCC optimize("-O3")
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<cmath>
#include<vector>
#include<bitset>
#define DB long double
#define LL long long
#define ui unsigned int
#define ull unsigned long long
using namespace std;
  
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void Out(int x){
    if(x>9) Out(x/10);
    putchar('0'+x%10);
}
int gcd(int x,int y){
    if(!y) return x;
    return gcd(y,x%y);
}
LL qpow(LL x,LL y,LL P){
    LL re=1;
    while(y){
        if(y&1) re=re*x%P;
        x=x*x%P;y>>=1;
    }
    return re;
}
const DB eps=1e-8;
const LL P=10000019;
const DB PI=acos(-1);
const LL inf=1e9;
const int N=1e5+10;
int n,m;
int du[N];
map<int, map<int,int> > mp;
vector<int> ve[N];
int sss=0;
bool vis[N];
void dfs(int x,int T){
	vis[x]=1;
	for(int i=0;i<ve[x].size();++i){
		if(ve[x][i]==T) ++sss;
		else if(!vis[ve[x][i]]) dfs(ve[x][i],T);
	}
}
int main(){
	cin>>n>>m;
	if(m<9){
		puts("No");
		return 0;
	}
	int u,v;
	for(int i=1;i<=m;++i){
		scanf("%d%d",&u,&v);
		ve[u].push_back(v);
		ve[v].push_back(u);
		++du[u];++du[v];
		mp[u][v]=1;
		mp[v][u]=1;
	}
	int ans=0;
	for(int i=1;i<=n;++i) if(du[i]&1){
		puts("No");
		return 0;
	}
	for(int i=1;i<=n;++i){
		if(du[i]>=6){
			puts("Yes");
			return 0;
		}
	}
	for(int i=1;i<=n;++i){
		ans+=(du[i]/2)-1;
	}
//	puts("Yes");
//	return 0;
	if(ans<2) {
		puts("No");
		return 0;
	}
	if(ans>=3) {
		puts("Yes");
		return 0;
	}
	u=0;v=0;
	for(int i=1;i<=n;++i) if(du[i]==4) {
		if(u==0) u=i;
		else v=i;
	}
	dfs(u,v);
	if(sss==4){
		puts("No");
		return 0;
	}
//	else 
	puts("Yes");
	return 0;
}
/*
5 4 4 1
1 2 3
2 3 4
3 4 5
4 5 6
*/

Measured memory_bytes: 25600
n = int(input())
if n == 3:
    print(2, 5, 63)
elif n == 4:
    print(2, 3, 4, 9)
else:
    l = [2, 3, 4, 9]
    a = 8
    b = 10
    while b <= 30000 and len(l) + 1 < n:
        l.append(a)
        l.append(b)
        a += 6
        b += 6
    c = 15
    d = 21
    while d <= 30000 and len(l) + 1 < n:
        l.append(c)
        l.append(d)
        c += 12
        d += 12
    t = 6
    while t <= 30000 and len(l) < n:
        l.append(t)
        t += 6
    print(' '.join(map(str, l)))


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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  vector<double> q(n);
  rep(i,n) {
    cin >> p[i];
    q[i] = (p[i]+1.0)/2.0;
  }
  
  double sum = 0;
  rep(i,k){
    sum += q[i];
  }
  double ans = sum;
  
  rep(i,n-k){
    sum = sum - q[i] + q[k+i];
    ans = max(sum, ans);
  }

  cout << fixed << setprecision(6) << ans;
}

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

void fnLinkedListSet(list<int> &rltnNum)
{
  list<int>::iterator itltn;
  list<int>::iterator itltEND = rltnNum.end();
  string sCmd;
  int nMaxCmd, nNum;

  cin.tie(0);
  ios::sync_with_stdio(false);
 
  cin >> nMaxCmd;
  for (int i = 0; i < nMaxCmd; i++)
  {
    cin >> sCmd;
    if (sCmd == "insert")
    {
      cin >> nNum;
      rltnNum.push_front(nNum);
    }
    else if (sCmd == "deleteFirst")
      rltnNum.pop_front();
    else if (sCmd == "deleteLast")
      rltnNum.pop_back();
    else if (sCmd == "delete")
    {
      cin >> nNum;
      for (itltn = rltnNum.begin(); itltn != itltEND; ++itltn)
        if (*itltn == nNum)
        {
          rltnNum.erase(itltn);
          break;
        }
    }
  }
}

void fnLinkedListGet(const list<int> &cnrltnNum)
{
  list<int>::const_iterator itltn;
  list<int>::const_iterator itltEND = cnrltnNum.end();

  for (itltn = cnrltnNum.begin(); itltn != itltEND; ++itltn)
  {
    if (itltn != cnrltnNum.begin()) cout << " ";
    cout << *itltn;
  }
  cout << endl;
}

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

  list<int> ltnNum;
  fnLinkedListSet(ltnNum);
  fnLinkedListGet(ltnNum);

  return 0;
}

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

#define WHATS(var) cout<<#var<<"="<<var<<endl;

vector<pair<int,int>>answers;
void solve(long long int K,long long int tx,long long int ty,int atime){
	//cout<<tx<<ty<<endl;
	if(atime>=3){
		long long int usex=min(K,tx);
		long long int usey=K-usex;
		answers.emplace_back(usex,usey);
		solve(K,tx-usex,ty-usey,atime-1);
	}else if(atime==2){
		bool x_flag=false;
		bool y_flag=false;
		if(tx<0){
			tx=-tx;
			x_flag=true;
		}
		if(ty<0){
			ty=-ty;
			y_flag=true;
		}
		long long int asum=tx+ty;
		long long int dif=2*K-asum;
		//cout<<dif<<endl;
		bool sw_flag=false;
		if(tx>ty){
			swap(tx,ty);
			sw_flag=true;
		}
		long long int fst_x=tx+dif/2;
		long long int fst_y=K-fst_x;
		answers.emplace_back(fst_x,fst_y);
		answers.emplace_back(tx-fst_x,ty-fst_y);

		for(int i=answers.size()-2;i<answers.size();++i){
			if(sw_flag){

				swap(answers[i].first,answers[i].second);
			}
			
		}
		for(int i=answers.size()-2;i<answers.size();++i){
			if(y_flag){
				answers[i].second=-answers[i].second;
			}
			
		}
		for(int i=answers.size()-2;i<answers.size();++i){
			if(x_flag){
				answers[i].first=-answers[i].first;

			}
			
		}
	}else if(atime==1){
		assert(tx+ty==K);
		answers.emplace_back(tx,ty);
	}
}
int main() {
	ios::sync_with_stdio(false);
	long long int K;cin>>K;
	long long int X,Y;cin>>X>>Y;
	bool y_sw=false;
	bool x_sw=false;
	if(X<0){
		X=-X;
		x_sw=true;
	}
	if(Y<0){
		Y=-Y;
		y_sw=true;
	}
	long long int sum=abs(X)+abs(Y);
	long long int atime=(sum-1)/K+1;
	if(K%2){
		if(sum%2){
			if(atime==1){
				if(sum==K)atime=1;
				else atime=3;
			}
			if(atime%2==0)atime++;
		}else{
			if(atime==1){
				atime=2;
			}else{
				if(atime%2==1)atime++;
			}
		}
	}else{
		if(sum%2){
			cout<<-1<<endl;
			return 0;

		}else {
			if(atime==1){
				if(sum==K)atime=1;
				else atime=2;
			}
		}
	}
	solve(K,X,Y,atime);
	for(auto &p:answers){
		if(x_sw)p.first=-p.first;
		if(y_sw)p.second=-p.second;
	}
	cout<<atime<<endl;
	long long int nx=0,ny=0;
	for(auto p:answers){
		nx+=p.first;
		ny+=p.second;
		cout<<nx<<' '<<ny<<endl;
	}
	return 0;
}


Measured memory_bytes: 22768
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <limits>
using namespace std;

double inf = numeric_limits<double>::infinity();

int main() {
    int n, m;
    
    cin >> n >> m;
    vector<vector<int>> v = vector<vector<int>>(n, vector<int>(n, 0));
    
    int a, b;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        v[a-1][b-1] = 1;
        v[b-1][a-1] = 1;
    }
    
    vector<int> vlist;
    for (int i = 0; i < n; i++) {
        vlist.push_back(i);
    }
    
    int cnt = 0;
    do {
        if (vlist[0] == 0) {
            bool t = true;
            for (int i = 1; i < n; i++) {
                t = t && v[vlist[i-1]][vlist[i]] == 1;
            }
            if (t) cnt++;
        }
    } while (next_permutation(vlist.begin(), vlist.end()));
    
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    string s;
    cin>>s;
    ll n=s.size();
    s="";
    rep(i,n){
        s.push_back('x');
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,n;
  while(cin>>a>>b>>n){
    int ans = 0;
    a%=b;
    while(n--){
      a*=10;
      ans+=a/b;
      a%=b;
    }
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
$N =int(<STDIN>);
@A1=split(" ",<STDIN>);
@A2=split(" ",<STDIN>);

$x=$N-1;
$B2=$A2[$x];
$B1=$B2+$A1[$x];

for($x=$N-2;$x>=0;$x--){
	$B2=$A2[$x]+$B2;
	$B1=($B2>$B1)?$B2+$A1[$x]:$B1+$A1[$x];
}

print $B1;


Measured memory_bytes: 512
figure = ''
height, width = [int(x) for x in input().split()]
while height or width:
    side = ('#' * width) + '\n'
    fill = '#' + ('.' * (width-2)) + '#\n'
    rect = side + (fill * (height-2)) + side
    figure += rect + '\n'
    height, width = [int(x) for x in input().split()]
  
print(figure[:-1])

Measured memory_bytes: 7788
#include<iostream>
using namespace std;
int main() {
    int n,pre,a,cont=1,g=0;
    cin >> n;
    cin >> pre;
    for (int i = 0;i<n-1;i++) {
        cin >> a;
        if (pre==a) {cont += 1;}
        else {
            g += cont/2;
            cont = 1;
            pre = a;
        }
        if (i == n-2) {g += cont/2;}
    }
    cout << g << 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++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N, i;
  cin >> N >> i;
  int ans = N - i + 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  priority_queue<int> queue;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    queue.push(a);
  }

  int alice = 0;
  int bob = 0;

  for (int i = 0; i < N; ++i) {
    int a = queue.top();
    queue.pop();
    // alice
    if (i % 2 == 0) {
      alice += a;
    } else {
      bob += a;
    }
  }

  cout << alice - bob << endl;

  return 0;
}

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

int main() {
	int w, h;
	do {
		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 == 0 || i == (h - 1)  || j == 0 || j == (w - 1))
					cout << "#";
				else
					cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	} while (true);
	return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int32_t main()
{
	IOS;
	int d,t,s;
	cin>>d>>t>>s;
	if(t*s>=d)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}

}

Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

// calc nCk mod p, O(n + log p)
// 1. init(n, p)
// 2. use mod_nck(n, k, p) 
const int MAX_N = 200000;
ll fact[MAX_N + 1], fact_inv[MAX_N + 1];

ll mod_pow(ll x, ll n, ll p) {
  if(n == 0) return 1;
  ll res = mod_pow(x * x % p, n / 2, p);
  if(n & 1) res = res * x % p;
  return res;
}

void init(ll n, ll p) {
  fact[0] = 1;
  for(int i = 0; i < n; i++) {
    fact[i + 1] = fact[i] * (i + 1) % p;
  }
  fact_inv[n] = mod_pow(fact[n], p - 2, p);
  for(int i = n - 1; i >= 0; i--) {
    fact_inv[i] = fact_inv[i + 1] * (i + 1) % p;
  }
}

ll mod_nck(ll n, ll k, ll p) {
  if(k > n) return 0;
  return (fact[n] * fact_inv[k]) % p * fact_inv[n-k] % p;
}

int n;
int a[MAX_N];

int main(){
  cin >> n;
  REP(i, n + 1) cin >> a[i];
  int b[n + 1];
  REP(i, n + 1) {
    b[i] = 0;
  }
  int db = 0, l, r;
  REP(i, n + 1) {
    b[a[i]]++;
    if(b[a[i]] == 2) {
      db = a[i];
      r = i;
      break;
    }
  }
  REP(i, n + 1) {
    if(a[i] == db) {
      l = i;
      break;
    }
  }

  init(n + 1, MOD);
  REP(i, n + 1) {
    cout << (mod_nck(n + 1, i + 1, MOD) - mod_nck(l + n - r, i, MOD) + MOD) % MOD << endl;
  }

  return 0;
}


Measured memory_bytes: 3584
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;
bool visited[100100];
using Graph = vector<vector<int> >;

int dp[100100];

void dfs(int v, const Graph &G, vector<int> &order) {
    visited[v] = true;
    for (auto to : G[v]) {
        if (visited[to]) continue;
        dfs(to, G, order);
    }
    order.push_back(v);
}

int main() {
    int N, M;
    cin >> N >> M;
    Graph G(N);
    vector<int> order;
    rep(i,M) {
        int x, y;
        cin >> x >> y;
        --x; --y;
        G[x].push_back(y);
    }
    rep(v,N) {
        if (visited[v]) continue;
        dfs(v,G,order);
    }
    reverse(all(order));

    for (auto i : order) {
        //cout << "v : " << i << endl;
        for (auto to : G[i]) {
            dp[to] = max(dp[i]+1, dp[to]);
        }
    }
    int ans = 0;
    rep(i,N) {
        ans = max(ans, dp[i]);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 9464
N,X=map(int,input().split())
for x in range(N+1):
    for y in range(N+1-x):
        z=N-x-y
        if ((10000*x+5000*y+1000*z==X)and(0<=z)):
            print(x,y,z)
            exit()
print(-1,-1,-1)
        

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
using pint = pair<int, int>;

int max(int a,int b){
    if(a > b){
        return a;
    }else{
        return b;
    }
}

int N;
vector<vector<pint>> G;

bool judge(int bit){
    for (int i = 0; i < N;i++){
        if(!(bit & (1 << i)) )
            continue;

        for (pint xy : G[i]){
            int x = xy.first;
            int y = xy.second;

            if(y == 1 && !(bit & (1 << x)))
                return false;
            if(y == 0 && (bit & (1 << x)))
                return false;
        }
    }
    return true;
}

int main()
{
    cin >> N;
    G.resize(N);
    for (int i = 0; i < N;i++){
        int A;
        cin >> A;
        G[i].resize(A);
        for (int j = 0; j < A;j++){
            cin >> G[i][j].first >> G[i][j].second;
            G[i][j].first--;
        }
    }
    int res = 0;
    for (int bit = 0; bit < (1 << N);bit++){
        if(judge(bit)){
            int count = 0;
            for (int i = 0; i < N;i++){
                if(bit & (1 << i))
                    count++;
            }
            res = max(res, count);
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
//
//  abc112_b.cpp
//  sample01
//
//  Created by 花岡州一郎 on 2019/02/09.
//  Copyright © 2019 花岡州一郎. All rights reserved.
//

#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>
#include<tuple>
using namespace std;
int abc112_c(){
    // 入力
    int n;
    cin >> n;
    long long x[n],y[n],h[n];
    long long ansx = -1;
    long long ansy = -1;
    long long ansh = -1;
    tuple<long long,long long,long long> G;
    for (int i=0; i<n; ++i) {
        cin >> x[i] >> y[i] >> h[i];
        if(h[i]) G = make_tuple(x[i],y[i],h[i]);
    }
    
    //処理
    tuple<long long,long long,long long> data[11000];
    for(int i=0; i<=100; ++i){
        for(int j=0; j<=100; ++j){
            data[105*i+j] = make_tuple(i,j,get<2>(G) + abs(get<0>(G) - i) + abs(get<1>(G) - j));
        }
    }
    for(int i=0; i<11000; ++i){
        bool flag = true;
         for(int j=0 ; j<n ; ++j){
             long long V = get<2>(data[i]) - abs(x[j] - get<0>(data[i])) - abs(y[j] - get<1>(data[i]));
             V = max(V,0LL);
             if(V != h[j]){
                flag = false;
            }
        }
        if(flag){
            ansx = get<0>(data[i]);
            ansy = get<1>(data[i]);
            ansh = get<2>(data[i]);
            break;
        }
    }
    
    //出力
    cout << ansx << " " << ansy << " " << ansh << endl;
    return 0;
}

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


Measured memory_bytes: 512
//		HYSO SERIOUS? WHY SO SERIOUS                            RIOUS? WHY SO SERIOUS? WHYSO SERIO
//		 ERIOUS? WHY SO SERIOUS ? WHY                          WHY SO SERIOUS? WHY SOSERIOUSWHYS
//		       OSERIOUS? WHY SO SERIOU         SERIOUS        ERIOUS? WHY SO SERIOUS? WHYS
//		          WHY SO SERIOUS? WHY SOSERIOUS? WHYSOSERIOUS? WHY SO SERIOUS?WHY SO SE
//		           ERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SOSERIO
//		           WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WH
//		            SERIOUS?WHYSO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHYSO SE
//		              ?WHYSOSERIOUS?WHY SO SERIOUS? WHY SO SERIOUS?WHYSO SERIOUS?
//		                           OSERIOUS? WHY SO SERIOUS?WHYSOSER
//		                                 HYSOSERIOUS?WHYSOSERI
//		                                     SOSERIOUS?W
//		                                         SER
//		                                          W


#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;
#include<bits/stdc++.h>
#include <algorithm>
#define ll long long int
#define read(a) long long int a; cin>>a;
#define readstr(s) string s; cin>>s;
#define readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define v(pi) vector<ll>pi
#define vp(pi) vector<pair<ll,ll>>pi
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define pb(p) push_back(p)
#define mp make_pair
#include <cmath>
#include <map>
#include <string>
#define mi(lol) map<ll,ll>lol
#define fsort(vec) sort(vec.begin(),vec.end())
#define rsort(vec) sort(vec.begin(),vec.end(),compare)
#define inf ll inf=INT_MAX
//sorting according to the second element vector 

bool compare(pair<ll,ll> p,pair<ll,ll> q){
	return p.second < q.second;	
}

//   example:-
//   sort(vec.begin(),vec.end(),compare);


int main() {
	fast;
	read(a)
	read(b)
	read(c)
	ll temp=b;
	b=a;
	a=temp;
	ll temp2;
	temp2=c;
	c=a;
	a=temp2;
	cout<<a<<" "<<b<<" "<<c<<endl;
	return 0;
}


Measured memory_bytes: 256
#import numpy as np
s = input()
n = int(input())
#qt = np.ones((n),dtype=np.int32)
#qf = np.zeros((n),dtype=np.int64)
#qc = [''] * n

mode = False
#mode = True : f1->s=c+s,f2->s=s+c
#mode = False : f1->s=s+c,f2->s=c+s

front = ''
back = ''
for i in range(n):
    qs = input()
    if len(qs) == 1:
        mode = not mode
        #s = s[::-1]
        #pass
    else:
        #qt[i] = 2
        #qf[i] = int(qs[1:-2])
        #qc[i] = qs[-1]
        if not mode:
            if int(qs[2]) == 1:
                front += qs[4]
                #s = qs[4] + s
            else:
                back += qs[4]
                #s = s + qs[4]
        else:
            if int(qs[2]) == 1:
                back += qs[4]
                #s = s + qs[4]
            else:
                front += qs[4]
                #s = qs[4] + s


#print(mode,front,back)
#hanten
if mode:
    print(back[::-1] + s[::-1] + front)
#no hanten
else:
    print(front[::-1] + s + back)



Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,x,m,ans,loopans,ac,jdg;cin >> n >> x >> m;
  ans=x;ac=x;loopans=0;jdg=0;
  vector<long long> a(m,0),loopcount(3,0);
  
  for (long long i=1;i<n;i++) {
    ac=ac*ac%m;
	if (a[ac]==0) {a[ac]=i;ans+=ac;}
	else {
	  loopcount[1]=i;
	  loopcount[2]=i-a[ac];
	  break;
	}
  }
  if (loopcount[1]==0) cout << ans << endl;
  else{
  
  for (long long i=0;i<loopcount[2];i++) {
    if (loopcount[1]+i>n-1) {
	  jdg=1;
	  break;
	}
	loopans+=ac;
	ac=ac*ac%m;
  }
  if (jdg==1) cout << ans+loopans << endl;
  else {
    ans+=((((n-loopcount[1])/loopcount[2]))*(loopans));
	loopans=0;
	for (long long i=0;i<(n-loopcount[1])%loopcount[2];i++) {     
	  loopans+=ac;
	  ac=ac*ac%m;
    }
	cout << ans+loopans << endl;
  } 
  }
}

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

int main() {
  int n;string s;
  cin >> n >> s;
  ll r = 0,g = 0,b = 0;
  for(int i = 0; i < n; i++){
    if(s[i] == 'R') r++;
    else if(s[i] == 'G') g++;
    else b++;
  }
  ll all = r*g*b;
  ll sub = 0;
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      if(s[i] == s[j]) continue;
      int k = 2 * j - i;
      if (k >= n || s[k] == s[i] || s[k] == s[j]) continue;
      sub++;
    }
  }
  ll ans = all - sub;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
N = int(input())
E = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    a-=1
    b-=1
    E[a].append(b)
    E[b].append(a)

from collections import deque
def bfs(s):
    dist = [None]*N
    que = deque([s])
    dist[s] = 0
    while que:
        v = que.popleft()
        d = dist[v]
        for w in E[v]:
            if dist[w] is not None:
                continue
            dist[w] = d + 1
            que.append(w)
    d = max(dist)
    return dist.index(d), d
u, _ = bfs(0)
v, d = bfs(u)
#print(d)
if d%3==1:
    print("Second")
else:
    print("First")


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

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;

const int INF=1<<30;
const ll LINF = 1e18+5;

int main() {
    string str;
    cin >> str;
    int ans = 0;
    rep(i, str.size()/2) {
        if(str[i] != str[str.size()-1-i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int flag=0;
    getline(cin,s);
    for(int i=0;i<s.length();i++)
    {
    	if(s[i]=='C') flag=1;
    	if(flag==1)
    	{
    		if(s[i]=='F')
    		{
    			cout<<"Yes";
				return 0; 
			}
		}
	}
	cout<<"No";
	return 0;
}

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

int main() {
	// your code goes here
	long int n;long double d;
	cin>> n>>d;
	int c=0;
	for(int i=1;i<=n;i++)
	{ 
	    long int x,y;
	    cin>>x>>y;
	    long double res = sqrt(x*x+y*y) ;
	    if(res<=d) c++;
	}
	cout << c;
	return 0; 
}


Measured memory_bytes: 3776
#include<iostream>
#include<string>
#include<deque>
#include<algorithm>
using namespace std;

int main(){
    deque<char> s;
    string tmp;
    cin>>tmp;
    for(int i=0;i<tmp.size();++i)s.push_back(tmp[i]);
    int q;
    cin>>q;
    int t,f;
    char c;
    bool flag=false;
    for(int i=0;i<q;i++){
        cin>>t;
        if(t==1){
            if(flag)flag=false;
            else flag=true;
        }
        else{
            cin>>f>>c;
            if(f==1){
                if(flag)s.push_back(c);
                else s.push_front(c);
            }
            else{
                if(flag)s.push_front(c);
                else s.push_back(c);
            }
        }
    }
    if(flag)reverse(s.begin(),s.end());
    for(int i=0;i<s.size();++i)cout<<s[i];
    cout<<""<<endl;
    return 0;
}

Measured memory_bytes: 896
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::cmp::max;
use std::cmp::min;


fn main() {
    input! {
        A: i32,
        B: i32,
    }

    let ans = if B % A == 0 { A + B } else { B - A };
    println!("{}", ans);
}


Measured memory_bytes: 2136
#include<stdio.h>

int main(void){
	int N,V[50],C[50],i,ans=0;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&V[i]);
	}
	for(i=0;i<N;i++){
		scanf("%d",&C[i]);
	}
	
	for(i=0;i<N;i++){
		if(V[i]-C[i]>0){
			ans=ans+V[i]-C[i];
		}
	}
	printf("%d",ans);
	return 0;
}
	

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int N, M;

int x[1005], y[1005], z[1005];

struct Sign {
    int x, y, z;
};
Sign s[8] = {Sign{1, 1, 1},   Sign{-1, 1, 1},  Sign{1, -1, 1},
             Sign{1, 1, -1},  Sign{-1, -1, 1}, Sign{1, -1, -1},
             Sign{-1, 1, -1}, Sign{-1, -1, -1}};

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> N >> M;
    REP(i, N) { cin >> x[i] >> y[i] >> z[i]; }

    int ans = 0;
    REP(k, 8) {
        vector<int> v(N);
        REP(i, N) {
            auto& ts = s[k];
            v[i] = ts.x * x[i] + ts.y * y[i] + ts.z * z[i];
        }
        sort(v.begin(), v.end(), greater<int>());

        int tmp = 0;
        REP(i, M) { tmp += v[i]; }
        ans = max(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)      for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
/*-----------------------------------------------------------------------------------------------*/
const int N = 1e5+10;
int n;
int a[N],b[N],x,ans=0;
int main()
{
    _SAD()
    cin>>n;
    rep(i,n) cin>>a[i];
    x=a[n-1];
    rrep(i,n)
    {
        x=__gcd(x,a[i]);
        b[i]=x;
    }
    ans=max(x,b[1]);
    x=a[0];
    repn(i,n-2)
    {
        ans=max(ans,__gcd(x,b[i+1]));
        x=__gcd(x,a[i]);
    }
    cout<<max(ans,x)<<nl;
    return 0;
}


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

#define ll long long
#define pb push_back

const int maxn = 2e5 + 20;

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

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

	int sx , sy;
	cin >> sx >> sy;

	string s , t;
	cin >> s >> t;

	int l = 1 , r = m;
	for(int i = k - 1; i >= 0; i--)
	{
		if(t[i] == 'L')
			r = min(r + 1 , m);
		if(t[i] == 'R')
			l = max(l - 1 , 1);

		if(s[i] == 'R')
			r--;
		if(s[i] == 'L')
			l++;
		if(l > r)
			return cout << "NO" << endl , 0;
	}
	if(sy < l || r < sy)
		return cout << "NO" << endl , 0;

	l = 1 , r = n;
	for(int i = k - 1; i >= 0; i--)
	{
		if(t[i] == 'U')
			r = min(r + 1 , n);
		if(t[i] == 'D')
			l = max(l - 1 , 1);

		if(s[i] == 'D')
			r--;
		if(s[i] == 'U')
			l++;
		if(l > r)
			return cout << "NO" << endl , 0;
	}
	if(sx < l || r < sx)
		return cout << "NO" << endl , 0;

	cout << "YES" << endl;
}



















Measured memory_bytes: 920
N, M, C = map(int, input().split())
b_list = list(map(int,input().split()))
c = 0
for i in range(N):
	a_list = list(map(int, input().split()))
	sum = 0
	for i in range(M):
		sum = b_list[i] * a_list[i] + sum
	sum = sum + C
	if sum > 0:
		c = c + 1
print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <cstring>
using namespace std;
typedef long long ll;
ll ans;
int n,val[100005],c[100005],pre[100005];
void merge(int a[],int l,int r){
    if(l==r)
        return;
    int mid = (l+r)/2;
    merge(a,l,mid);
    merge(a,mid+1,r);
    int i=l,j=mid+1,index=l;
    while (i<=mid&&j<=r){
        if(a[i]>a[j]){
            c[index++]=a[j];
            ans+=mid-i+1;
            j++;
        } else{
            c[index++]=a[i];
            i++;
        }
    }
    while (i<=mid)
        c[index++]=a[i++];
    while (j<=r)
        c[index++]=a[j++];
    for(int i=l;i<=r;i++)
        a[i]=c[i];
}
bool check(int mid){
    //memset(pre,0, sizeof(pre));
    ans = 0;//逆序对的数量
    for(int i=1;i<=n;i++){
        if(val[i]<mid)
            pre[i]=pre[i-1]-1;
        else
            pre[i]=pre[i-1]+1;
        if(pre[i]<0)
            ans++;
    }
    merge(pre,1,n);
    ll all = 1ll*n*(n+1)/2;
    return all>=2*ans;
}
int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>val[i];
    }
    int l = 1,r = 1e9;
    while (l+1<r){
        int mid = (l+r)>>1;
        if(check(mid)){//增加的区间大于等于一半了(数偏小
            l=mid;
        } else
            r=mid;
    }
    if(check(l+1)) ++l;
    cout<<l<<endl;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long Q,H,S,D,N;
  cin >> Q >> H >> S >> D >> N;
  long long a;
  a=min({4*Q,2*H,S});
  if(2*a<D){cout << N*a << endl;}
  else{
    if(N%2==0){cout << N/2*D << endl;}
    else{cout << (N-1)/2*D+a << endl;}
  }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner(os.Stdin)
	n, _ := sc.NextInt()
	a, _ := sc.NextInts(n)
	fmt.Println(solve(n, a))
}

func solve(n int, a []int) (ans int) {
	divisible := make(map[int]bool, n)
	for _, ai := range a {
		divisible[ai] = false
	}

	sort.Ints(a)
	max := a[n-1]
	for i, ai := range a {
		if divisible[ai] {
			continue
		}
		for j := ai; j <= max; j += ai {
			if _, ok := divisible[j]; ok {
				divisible[j] = true
			}
		}
		if i < n-1 && a[i+1] == ai {
			continue
		}
		ans++
	}
	return
}

// Scanner is a wrapper of bufio.Scanner which is customized for competitive programing.
type Scanner struct {
	bufio.Scanner
}

// NewScanner is a constructor for Scanner.
func NewScanner(r io.Reader) *Scanner {
	sc := Scanner{*bufio.NewScanner(r)}
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
	return &sc
}

// NextInt reads a integer from io stream.
func (sc *Scanner) NextInt() (int, error) {
	if !sc.Scan() {
		return -1, errors.New("failed to scan")
	}
	return strconv.Atoi(sc.Text())
}

// NextInts reads n integers from io stream.
func (sc *Scanner) NextInts(n int) (arr []int, e error) {
	arr = make([]int, n)
	for i := 0; i < n; i++ {
		v, e := sc.NextInt()
		if e != nil {
			return nil, e
		}
		arr[i] = v
	}
	return arr, nil
}


Measured memory_bytes: 8276
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

ll N, A[50];
ll ans = 0;

signed main(){
    cin >> N;
    rep(i, N) cin >> A[i];

    while(true){
        rep(i, N){
            ll tmp = (A[i]-A[i]%N)/N;
            ans += tmp;
            A[i] -= N*tmp;
            rep(j, N){
                if(i == j) continue;
                A[j] += tmp;
            }
        }
        bool flg = true;
        rep(i, N) flg &= (A[i] < N);
        if(flg) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
import java.util.HashSet;
import java.util.Set;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] str_vs = br.readLine().split(" ");
        int vs[] = new int[n];
        int[] count1 = new int[100001];
        int[] count2 = new int[100001];
        int ans = 0;
        
        for (int i = 0; i < n; i++) {
            vs[i] = Integer.parseInt(str_vs[i]);
        }
        
        for (int i = 0; i < n; i+=2) {
            count1[vs[i]]++;
        }
        
        int max1 = 0;
        int second1 = 0;
        //int second_i1 = 0;
        int max_i1 = 0;
        for (int i = 0; i < 100001; i++) {
            if (max1<count1[i]) {
                //second1 = max1;
                //second_i1 = max_i1;
                max1 = count1[i];
                max_i1 = i;
            }
        }
        
        //ans += n/2-max1;
        //count = new int[100001];
        
        for (int i = 1; i < n; i+=2) {
            count2[vs[i]]++;
        }
        
        int max2 = 0;
        int second2 = 0;
        //int second_i2;
        int max_i2 = 0;
        for (int i = 0; i < 100001; i++) {
            if (max2<count2[i]) {
                //second2 = max2;
                //second_i2 = max_i2;
                max2 = count2[i];
                max_i2 = i;
            }
        }
        
        Arrays.sort(count1);
        Arrays.sort(count2);
        
        //System.out.println(max1);
        //System.out.println(max2);
        
        if (max_i1==max_i2) {
            //System.out.println("aaa");
            if (max1>max2) {
                //System.out.println("bbb");
                ans = n/2-count1[100000] + n/2-count2[99999];
            }
            else if (max1<max2) {
                //System.out.println("ccc");
                ans = n/2-count1[99999] + n/2-count2[100000];
            }
            else {
                //System.out.println("ddd");
                if (count1[99999]>count2[99999]) {
                    //System.out.println("eee");
                    ans = n/2-count1[99999] + n/2-count2[100000];
                }
                else {
                    //System.out.println("fff");
                    ans = n/2-count1[100000] + n/2-count2[99999];
                }
            }
            
        }
        else {
            ans = n/2-count1[100000] + n/2-count2[100000];
        }
        
        //ans += n/2-max2;
        System.out.println(ans);
    }
}


Measured memory_bytes: 38556
#include <cstdio>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#define maxn 100009
using namespace std;
int n, m;
vector<int>G[maxn];
vector<int>ans1, ans2;
bool vis[maxn];
void dfs1(int u){
	vis[u] = 1;
	ans1.push_back(u);
	for(auto v: G[u]){
		if(vis[v])
			continue;
		dfs1(v);
		break;
	}
}
void dfs2(int u){
	vis[u] = 1;
	ans2.push_back(u);
	for(auto v: G[u]){
		if(vis[v])
			continue;
		dfs2(v);
		break;
	}
}
int main(){
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; i++){
		int x, y;
		scanf("%d%d", &x, &y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	dfs1(1);
	dfs2(1);
	reverse(ans2.begin(),ans2.end());
	int sz = ans1.size() +  ans2.size() - 1;
	printf("%d\n", sz);
	for(int i = 0 ; i < (int)ans2.size(); i++)
		printf("%d ", ans2[i]);
	for(int i = 1; i < (int)ans1.size();i++)
		printf("%d ", ans1[i]);
	return 0;
}

Measured memory_bytes: 9720
#include<bits/stdc++.h>
#define N 100005
#define mk(x,y) make_pair(x,y)
using namespace std;
int r,c,n,cnt;
int st[N*2],top,in[N];
map<pair<int,int>,int>mp;
struct node
{
    int x,y,be;
    node(){}
    node(int _x,int _y,int _be)
    {
        x=_x;y=_y;be=_be;
    }
}a[N*2];
bool check(int x,int y)
{
    return (x==0||x==r||y==0||y==c);
}
int lix[N*2],liy[N*2],c1,c2;
int main()
{
    scanf("%d%d%d",&r,&c,&n);
    int t1,t2,t3,t4;
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d%d",&t1,&t2,&t3,&t4);
        if(check(t1,t2)&&check(t3,t4))
        {
            mp[mk(t1,t2)]=i;mp[mk(t3,t4)]=i;
            lix[++c1]=t1;lix[++c1]=t3;
            liy[++c2]=t2;liy[++c2]=t4;
        }
    }
    sort(lix+1,lix+c1+1);
    sort(liy+1,liy+c2+1);
    c1=unique(lix+1,lix+c1+1)-lix-1;
    c2=unique(liy+1,liy+c2+1)-liy-1;

    for(int cas=1;cas<=2;cas++)
    {
        for(int i=1;i<c2;i++)
        {
            if(mp.find(mk(0,liy[i]))!=mp.end())
            {
                int id=mp[mk(0,liy[i])];
                if(st[top]==id)top--,in[id]=0;
                else if(!in[id])st[++top]=id,in[id]=1;
                else {puts("NO");return 0;}
            }
        }
        //cout<<top<<endl;
        for(int i=1;i<c1;i++)
        {
            if(mp.find(mk(lix[i],c))!=mp.end())
            {
                int id=mp[mk(lix[i],c)];
                if(st[top]==id)top--,in[id]=0;
                else if(!in[id])st[++top]=id,in[id]=1;
                else {puts("NO");return 0;}
            }
        }
        for(int i=c2;i>1;i--)
        {
            if(mp.find(mk(r,liy[i]))!=mp.end())
            {
                int id=mp[mk(r,liy[i])];
                if(st[top]==id)top--,in[id]=0;
                else if(!in[id])st[++top]=id,in[id]=1;
                else {puts("NO");return 0;}
            }
        }
        for(int i=c1;i>1;i--)
        {
            if(mp.find(mk(lix[i],0))!=mp.end())
            {
                int id=mp[mk(lix[i],0)];
                if(st[top]==id)top--,in[id]=0;
                else if(!in[id])st[++top]=id,in[id]=1;
                else {puts("NO");return 0;}
            }
        }
    }
    puts("YES");
    return 0;
}


Measured memory_bytes: 16768
#include <iostream>

using namespace std;
#define M 8

int h,w,c;

int p[M][M];
int buf[M][M];
int maxv,maxi;


void change(int oc,int nc,int i,int j){
    if(buf[i][j]!=oc)return;
    buf[i][j]=nc;
    if(i>=1)change(oc,nc,i-1,j);
    if(j>=1)change(oc,nc,i,j-1);
    if(i<=h-2)change(oc,nc,i+1,j);
    if(j<=w-2)change(oc,nc,i,j+1);
}
/*
 destroys buf
 */
int count0(int col,int i,int j){
    if(buf[i][j]!=col)return 0;
    buf[i][j]=-1;
    int cnt=0;
    if(i>=1)cnt+=count0(col,i-1,j);
    if(j>=1)cnt+=count0(col,i,j-1);
    if(i<=h-2)cnt+=count0(col,i+1,j);
    if(j<=w-2)cnt+=count0(col,i,j+1);
    return cnt+1;
}
void check(int arg0){
    int ar[5];
    int oldarg=arg0;
    for(int i=0;i<5;i++){
        ar[i]=arg0%6;
        arg0/=6;
    }
    for(int i=0;i<5;i++){
        if(buf[0][0]!=ar[i]){
            change(buf[0][0],ar[i],0,0);
        }
    }
    int c=count0(buf[0][0],0,0);
    if(maxv<c){
        maxv=c;
        maxi=oldarg;
    }
}


int main(void){
    while((cin >> h >> w >> c)&&(h||w||c)){
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>p[i][j];
                p[i][j]--;
            }
        }
        maxv=-1;
        maxi=-1;
        for(int i=0;i<1296;i++){
            for(int x=0;x<h;x++){
                for(int y=0;y<w;y++){
                    buf[x][y]=p[x][y];
                }
            }
            check(i+1296*(c-1));
        }
        cout<<maxv<<endl;
    }
}

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

int main(){
  string S;
  cin >> S;
  int month = stoi(S.substr(5,2));
  if(month<=4){
    cout << "Heisei" << endl;
    return 0;
  }else{
    cout << "TBD" << endl;
  }
}

Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}

	int N;
	long K;
	std::vector<long> A;
	std::cin >> N >> K;
	A.resize(N);
	for (auto& a : A) {
		std::cin >> a;
	}
	
	std::vector<long> B;
	B.resize(N+1);
	B[0] = 0;
	long b = 0;
	for (int i = 0; i < N; ++i) {
		b += A[i];
		B[i+1] = b;
	}

	std::unordered_map<long, std::vector<int>> eqcs; /* 代表値 -> 同値類の各値のvector なる map */
	for (int i = 0; i <= N; ++i) {
		long rem = (B[i] - i) % K;
		eqcs[rem].push_back(i);
	}

#if 0
	for (auto p : eqcs) {
		auto& eqc = p.second;
		for (auto v : eqc) {
			std::cerr << v << " ";
		}
		std::cerr << "\n";
	}
#endif

	long result = 0;
	for (auto p : eqcs) {
		auto& eqc = p.second;
		auto first = eqc.begin();
		auto last = eqc.begin();
		while (first != eqc.end()) {
			while (last != eqc.end() && (*last - *first) < K) {
				++last;
			}
			result += last - first - 1;
#if 0
			std::cerr << "add " << (last - first) << "\n";
#endif
			++first;
		}
	}
	std::cout << result << "\n";
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 300 + 47;

int CNT[MAX];
int A[MAX][MAX];
int U[MAX];
int P[MAX];

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
    int n, m;
    cin >> n >> m;
    FOR(i,0,n)
    {
        FOR(j,0, m)
        {
            cin >> A[i][j];
            A[i][j]--;
        }
    }
    
    int ans = INF;
    while (1)
    {
        bool ex = 0;
        FOR(i,0,n)
        {
            if (P[i] == m)
            {
                ex = 1;
                break;
            }
        }
        
        if (ex) break;
        FILL(CNT, 0);
        FOR(i,0, n)
        {
            int a = A[i][P[i]];
            CNT[a]++;
        }
        
        int mx = -1;
        FOR(i,0,n)
        {
            int a = A[i][P[i]];
            if (mx == -1 || CNT[a] > CNT[mx])
            {
                mx = a;
            }
        }
        
        ans = min(ans, CNT[mx]);
        U[mx] = 1;
        
        FOR(i,0,n)
        {
            while (P[i] != m && U[A[i][P[i]]]) 
            {
                P[i]++;
            }
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 640
import sys,queue,math,copy,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

N,M,Q = LI()
city = [[0] * (N+1) for _ in range(N+1)]
for _ in range(M):
    l,r = LI()
    city[l][r] += 1

for i in range(1,N+1):
    s = 0
    for j in range(1,N+1):
        s += city[i][j]
        city[i][j] = s + city[i-1][j]

for _ in range(Q):
    p,q = LI()
    ans = city[q][q] - city[q][p-1] - city[p-1][q] + city[p-1][p-1]
    print (ans)




Measured memory_bytes: 57560