akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MOD 1000000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    ll a, b;
    cin >> a >> b;
    if(a > b) cout << "a > b" << endl;
    else if(a < b) cout << "a < b" << endl;
    else cout << "a == b" << endl;

    return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> dist(N);
    for(int i=0;i<N;i++) cin >> dist[i];
    bool ok = true;

    int MAX = 0;
    for(int i=0;i<=min(N-1,MAX);i++) MAX = max(MAX, i+dist[i]/10);
    if(MAX < N-1) ok = false;

    MAX = 0;
    reverse(dist.begin(), dist.end());
    for(int i=0;i<=min(N-1,MAX);i++) MAX = max(MAX, i+dist[i]/10);
    if(MAX < N-1) ok = false;

    if(ok) cout << "yes" << endl;
    else cout << "no" << endl;
}


Measured memory_bytes: 3884
#include<iostream>
#include<cmath>
using namespace std;
typedef long long llong;

//辞書みたいなのがほしいが...strucで保存しておく。
struct NUM{int num;llong inv;};

void merge(int left,int mid,int right,NUM A[]){
    //2つの配列をmerge,つまりソートする
    int n1=mid-left;//本来の要素数より1つ多いのは、最後に
    int n2=right-mid;//番兵をいれたいから。
    NUM L[n1+1],R[n2+1];
    for(int i=0;i<n1;i++){
        L[i]=A[left+i];
    }L[n1].num=pow(10,9)+1;
    for(int j=0;j<n2;j++){
        R[j]=A[mid+j];
    }R[n2].num=pow(10,9)+1;
    int i=0,j=0;//インデックスを比較していく
    while(i<n1 || j<n2){
        //どっちも番兵に来たらオワリ
        if(L[i].num<=R[j].num){
            A[left+i+j]=L[i];
            i++;
        }
        else{
            A[left+i+j]=R[j];
            A[left+i+j].inv+=n1-i;
            j++;
        }
    }
}

void mergeSort(int left,int right,NUM A[]){
    if(right>left+1){
        int mid = (right+left)/2;
        mergeSort(left,mid,A);
        mergeSort(mid,right,A);
        merge(left,mid,right,A);
    }
}

int main(){
    int n;llong cnt=0;
    cin>>n;NUM A[n];for(int i=0;i<n;i++){cin>>A[i].num;A[i].inv=0;}
    mergeSort(0,n,A);
    for(int i=0;i<n;i++){
        cnt+=A[i].inv;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 9344
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

vector<string> pa;
vector<string> lp;
vector<string> str;
#define pb push_back

bool comp(string a,string b)
{
  if(a.length()==b.length())
    return a<b;
  else
    return a.length()>b.length();
}

bool kaibun(string s)
{
  int i;
  int len=s.length();
  for(i=0;i<len/2;i++)
    if(s[i]!=s[len-i-1])
      return false;
  return true;
}

string rev(string s)
{
  reverse(s.begin(),s.end());
  return s;
}

int main()
{
  int n;
  int i;
  cin>>n>>i;
  string s,r;
  //  cin>>s;
  //cout<<kaibun(s)<<endl;

  for(i=0;i<n;i++)
    {
      cin>>s;/*
      r=rev(s);
      if(s>r)
	str.pb(r);
	else*/
      str.pb(s);
    }
  //  sort(str.begin(),str.end());
  //str.pb("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
  /*
  for(i=0;i<n;i++)
    {
      if(str[i]==str[i+1])
	{
	  pa.pb(str[i]);
	  i++;
	  continue;
	}
      else if(kaibun(str[i]))
	{
	  lp.pb(str[i]);
	  continue;
	}
    }
*/
  int j;
  for(i=0;i<n-1;i++)
    for(j=i+1;j<n;j++)
      {
	if(str[i]==rev(str[j]))
	  {
	    pa.pb(str[i]>str[j]?str[j]:str[i]);
	    str[i]=str[j]="zzaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
	  }
      }
  for(i=0;i<n;i++)
    if(kaibun(str[i]))
      lp.pb(str[i]);
  //  printf("pa=%d,lp=%d\n",pa.size(),lp.size());
  if(pa.size()==0 && lp.size()==0)
    {
      puts("");
      return 0;
    }
  
  //  printf("aiu");
  sort(lp.begin(),lp.end(),comp);
  sort(pa.begin(),pa.end());

  string ans="";
  for(i=0;i<(int)pa.size();i++)
    ans+=pa[i];

  if(lp.size()!=0)
    cout<<ans<<lp[0]<<rev(ans)<<endl;
  else
    cout<<ans<<rev(ans)<<endl;
  return 0;
}

Measured memory_bytes: 3304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
#define MAX 100000

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

    vector<ll> v(n), m(2 * MAX + 1, 0);
    //map<P, int> m;
    for (int i = 0; i < n; i++) {
        cin >> v.at(i);
        m.at(i % 2 * MAX + v.at(i))++;
        //auto itr = m.find(make_pair(i%2, v.at(i)));
        //if (itr != m.end()) m[make_pair(i%2, v.at(i))]++;
        //else m[make_pair(i%2, v.at(i))] = 1;
    }

    vector<P> p;
    for (int i = 0; i < 2 * MAX + 1; i++) p.push_back(make_pair(m.at(i), i));
    sort(p.begin(), p.end(), greater<P>());

    ll ans, max_v = 0;
    if ( (p.at(0).second + MAX) != p.at(1).second && p.at(0).second != (p.at(1).second + MAX) ) ans = accumulate(m.begin(), m.end(), 0LL) - p.at(0).first - p.at(1).first;
    else {
        ans = accumulate(m.begin(), m.end(), 0LL);
        for (int i = 0; i < 100; i++) {
            for (int j = i + 1; j < 100; j++) {
                if ( (p.at(i).second + MAX) != p.at(j).second && p.at(i).second != (p.at(j).second + MAX) ) {
                    max_v = max(max_v, p.at(i).first + p.at(j).first);
                }
            }
        }
        ans -= max_v;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9808
#include<bits/stdc++.h>
using namespace std;
int h,w;
int graph[502][502];
struct node{
	int x,y,xx,yy;
}t;
struct node2{
	int v,x,y;
};
vector<node> ans;
node2 a[250000];
int main(){
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>graph[i][j];
		}
	}
	int o=0,p=0,d=1,it=0;
	while(true){
		a[it].v=graph[o][p];
		a[it].x=o;
		a[it].y=p;
		it++;
		p+=d;
		if(p<0){
			p=0;
			o++;
			d=-d;
		}
		else if(p>=w){
			p=w-1;
			o++;
			d=-d;
		}
		if(o>=h) break;
	}
	for(int i=0;i<h*w-1;i++){ 
		if(a[i].v%2==1){
			a[i].v--;
			a[i+1].v++;
			t.x=a[i].x; t.y=a[i].y;
			t.xx=a[i+1].x; t.yy=a[i+1].y;
			ans.push_back(t);
		}
	}
	cout<<ans.size()<<endl;
	for(int i=0;i<ans.size();i++) cout<<ans[i].x+1<<' '<<ans[i].y+1<<' '<<ans[i].xx+1<<' '<<ans[i].yy+1<<endl;
	return 0;
}

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

int main()
{

  int a[3], b[3], c[5]={};
  int cou3=0, cou2=0;
  for(int i=0; i<3; i++){
    cin >> a[i] >> b[i];
    c[a[i]]++;
    c[b[i]]++;
  }

  for(int j=0; j<5; j++){
    if(c[j]==2) cou2++;
    if(c[j]==3) cou3++;
  }

  if(!cou3){
    cout << "YES" << endl;
  }else if(cou2==2){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  return 0;

}


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

int main() {
    string S; cin >> S;
    int N = S.size();
    set<char> C;
    for (char c = 'a'; c <= 'z'; c++) C.insert(c);
    rep(i,N) C.erase(S[i]);
    if (!C.empty()) {
        S.push_back(*C.begin());
    } else { // empty
        int i = N-1;
        while (i > 0 && S[i] < S[i-1]) i--;
        if (i == 0) { // The last word. No next.
            cout << -1 << endl;
            return 0;
        }
        string prefix = S.substr(0, i);
        string suffix = S.substr(i, N - i);
        sort(suffix.begin(), suffix.end());
        auto x = lower_bound(suffix.begin(), suffix.end(), prefix[i-1]);
        prefix[i-1] = *x;
        S = prefix;
    }
    cout << S << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,i;
  cin >> n >> x;
  vector<int> l(n + 1,0);
  for(int i = 1;i <= n;i++){
    cin >> l[i];
    l[i] += l[i - 1];
  }
  for(i = 1;i <= n;i++){
    if(l[i] > x){
      break;
    }
  }
  cout << i << endl;
}

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

using namespace std;

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

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(-1.0);
const int limit = 100010;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())

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

int main() {
    char c[3];
    rep(i, 3) cin >> c[i];
    sort(c,c+3);
    Yes(c[0]=='a' && c[1]=='b' && c[2]=='c');

    return 0;
}


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

class Prog
{
    public Prog() { }
    public static int Main()
    {
        new Prog().calc();
        return 0;
    }

    Scanner cin;

    int mod = 1000000007;
    long pow = 1;
    public void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();

        for(int i = 1;i<=N;i++)
        {
            pow *= i;
            pow %= mod;
        }

        Console.WriteLine(pow);
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  string r="";
  for (char c : s){
    if (c=='B'){
      int newSize=r.size()-1;
      if (newSize<0)newSize=0;
      r.resize(newSize);
    }
    else{
      r+=c;
    }
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 256
#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);
	string s;
	cin >> s;
	s[5] = ' ';
	s[13] = ' ';
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
taro, hanako = 0, 0
for _ in range(n):
    x, y = input().split()
    if x > y:
        taro += 3
    elif x < y:
        hanako += 3
    else:
        taro += 1
        hanako += 1
print(taro, hanako)


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

const int N = 2010;
typedef long long ll;

int min[N], a[N];

int main(){
	int n, x;
	scanf("%d%d", &n, &x);
	for (int i = 0; i < n; ++ i){
		scanf("%d", &a[i]);
		min[i] = a[i];
	}
	ll ans = LLONG_MAX;
	for (int i = 0; i < n; ++ i){
		ll sum = 1ll * i * x;
		for (int j = 0; j < n; ++ j){
			sum += min[j];
		}
		ans = std::min(sum, ans);
		for (int j = 0; j < n; ++ j){
			min[j] = std::min(min[j], a[(j - i - 1 + n) % n]);
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
N = int(input())
p = list(map(int, input().split(' ')))

dif = []
dif_idx = []
for i in range(N):
    if p[i] != (i+1):
        dif.append(p[i])
        dif_idx.append(i)

flag_able = True
if len(dif) > 2:
    flag_able = False
elif len(dif) == 2:
    pass    

if flag_able is True:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
typedef long long ll;

int prime[1010];
bool is_prime[1010];
int x[1010];
int N;
int mo = 1e9+7;

int sieve(int n){
  int p = 0;
  for(int i = 0; i <= n; i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for(int i = 2; i <= n; i++){
    if(is_prime[i]){
      prime[p++] = i;
      for(int j = 2 * i; j <= n; j+=i) is_prime[j] = false;
    }
  }
  return p;
}

int main(){
  cin >> N;
  int p = sieve(N);
  //cout << p << endl;
  fill(x, x+N, 0);
  for(int i = 2; i <= N; i++){
    int y = i;
    for(int j = 0; j < p && prime[j] <= y; j++){
      while(y % prime[j] == 0){
        x[j]++;
        y /= prime[j];
      }
    }
  }

  ll sum = 1;
  for(int i = 0; i < p; i++){
    //cout << x[i] << endl;
    sum = (sum * (1 + x[i])) % mo;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, m;
string a[50];
string b[50];

int main() {
	int i, j, k, l;
	
	cin >> n >> m;
	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];
	
	rep(i, n - m + 1) {
		rep(j, n - m + 1) {
			rep(k, m) {
				rep(l, m) {
					if (a[i+k][j+l] != b[k][l]) break;
				}
				if (l < m) break;
			}
			if (k == m) { cout << "Yes" << endl; return 0; }
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
N, x = map(int, input().split())
a = list(map(int, input().split()))

count = 0
for i in range(N):
    if a[i] > x:
        count += a[i] - x
        a[i] = x

for i in range(N-1):
    if a[i] + a[i+1] > x:
        count += a[i] + a[i+1] - x
        a[i+1] = a[i+1] - (a[i] + a[i+1] - x)

print(count)

Measured memory_bytes: 14052
n=int(input())
s=input()
cntl=0
for i in range(n-1,-1,-1):
    if s[i]==")":
        cntl+=1
    elif s[i]=="(" and cntl>0:
        cntl-=1
sl="("*cntl
cntr=0
for i in range(n):
    if s[i]=="(":
        cntr+=1
    elif s[i]==")" and cntr>0:
        cntr-=1
sr=")"*cntr
print(sl+s+sr)


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

int main() {
    string S;
    cin >> S;
    if (S == "Sunny")
        cout << "Cloudy" << endl;
    else if (S == "Cloudy")
        cout << "Rainy" << endl;
    else
        cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {

  int n, q;
  cin >> n >> q;
  struct E {
    int t, val;
    bool add;
  };
  vector<E> events;
  rep(_, n) {
    int s, t, x;
    cin >> s >> t >> x;
    events.push_back(E{s - x, x, true});
    events.push_back(E{t - x, x, false});
  }
  sort(events.begin(), events.end(), [&](const auto &lhs, const auto &rhs) {
    if (lhs.t == rhs.t) {
      if (lhs.add == rhs.add) {
        return lhs.val < rhs.val;
      } else {
        return !lhs.add; // 時刻がかぶったら先に削除を処理する
      }
    } else {
      return lhs.t < rhs.t; // イベントが起きる時刻の早い順
    }
  });
  const int inf = 1e9 + 7;
  vector<int> cand(n * 2, inf);
  set<int> s;
  rep(i, n * 2) {
    const auto &ev = events[i];
    if (ev.add) {
      s.insert(ev.val);
    } else {
      s.erase(ev.val);
    }
    if (s.size() > 0) {     // 工事中がひとつ以上ある
      cand[i] = *s.begin(); // 最左 (原点に近い座標)
    }
  }
  while (q--) {
    int d;
    cin >> d;
    auto it = upper_bound(
        events.begin(), events.end(), E{d, 0, false},
        [&](const auto &lhs, const auto &rhs) { return lhs.t < rhs.t; });
    // events[j - 1].t <= d となる最大のj
    auto j = it - events.begin();
    if (j == 0 or j == n * 2) {
      cout << -1 << endl;
      continue;
    }
    auto ans = cand[j - 1];
    if (ans == inf) ans = -1;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 16876
S = input()
T = input()
X,Y = len(S),len(T)
L = [[0 for _ in range (Y+1)] for _ in range (X+1)]
for i in range (X):
  for j in range (Y):
    if S[i] == T[j]:
      L[i+1][j+1] = L[i][j]+1
    else:
      L[i+1][j+1] = max(L[i][j+1] , L[i+1][j] , L[i+1][j+1])
K = ''
while X*Y:
  if S[X-1] == T[Y-1]:
    K += S[X-1]
    X -= 1
    Y -= 1
  else:
    if L[X-1][Y] > L[X][Y-1]:
      X -= 1
    else:
      Y -= 1
print(K[::-1])

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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

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

    string S; cin >> S;
    
    cout <<(S<="2019/04/30"?"Heisei":"TBD")<<endl;
}


Measured memory_bytes: 256
x1,y1,x2,y2 = map(int,input().split())

x4 = x1-(y2-y1)
y4 = y1+(x2-x1)
x3 = x4+(x2-x1)
y3 = y4+(y2-y1)

print(x3,y3,x4,y4)

Measured memory_bytes: 3060
from collections import Counter

def a():
    N = int(input())
    A = map(int,input().split(" "))
    c = Counter(map(lambda x:(x%4 and 1)+x%2,A))
    if c[1]:
        return c[2] <= c[0]
    else:
        return c[2] <= c[0] + 1

print(['No','Yes'][a()])

Measured memory_bytes: 11436
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0; i<N; i++)
#define lint long long
#define square_vector(name,N,M) vector<vector<lint>>name(N,vector<lint>(M,0))
#define sort(V) sort(V.begin(),V.end())

lint gcd(lint A,lint B) {
  if (A > B) {
    swap(A,B);
  }
  if (B % A == 0) {
    return A;
  }
  else {
    return gcd(A,B%A);
  }
}

int main() {
  lint A,B;
  cin >> A >> B;
  
  lint ans = A*B;
  ans /= gcd(A,B);
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// longest non increasing subsequence
int A[100005], dp[100005], ans;
int main()
{
	int n; cin >> n;
	for (int i = 0; i < n; ++i) cin >> A[i];
	memset(dp, 0, sizeof(dp));
	for (int i = 1; i < n; ++i)
	{
		if (A[i] <= A[i-1])
		{
			dp[i] = dp[i-1] + 1;
			ans = max(ans, dp[i]);
		}
		else dp[i] = 0;
	}
	cout << ans;
}
		


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

using namespace std;

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

	int n;
	string s;
	cin >> n >> s;
	int cnt = count(s.begin(), s.end(), '1');
	int x0 = 0, x1 = 0;
	auto modpow = [](auto a, auto e, int m) {
		long long r = 1, x = a % m;
		for (; e > 0; e >>= 1, x = x * x % m)
			if (e & 1) r = r * x % m;
		return r;
	};
	for(int i =0; i<n; ++i) {
		if (s[i] == '1') {
			x0 = (x0 + modpow(2, n - i - 1, cnt + 1)) % (cnt + 1);
			if (cnt > 1) x1 = (x1 + modpow(2, n - i - 1, cnt - 1)) % (cnt - 1);
		}
	}
	map<int, int> d;
	function<int(int)> f = [&](int x) {
		if (!x) return 1;
		if (d.count(x)) return d[x];
		return d[x] = f(x % __builtin_popcount(x)) + 1;
	};
	for(int i =0; i<n; ++i) {
		if (s[i] == '0') {
			cout << f((x0 + modpow(2, n - i - 1, cnt + 1)) % (cnt + 1)) << '\n';
		} else if (cnt == 1) {
			cout << 0 << '\n';
		} else {
			cout << f((x1 - modpow(2, n - i - 1, cnt - 1) + cnt - 1) % (cnt - 1)) << '\n';
		}
	}
}

Measured memory_bytes: 4932
N = int(input())
T = list(map(int, input().split()))
M = int(input())

P, X = list(), list()

for m in range(M):
    p, x = list(map(int, input().split()))
    P.append(p)
    X.append(x)

ans = sum(T)

for m in range(M):
    arg = P[m] - 1
    val = X[m]

    print(ans - T[arg] + val)


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

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const ll MOD = (ll)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

priority_queue<int, vector<int>, greater<int>> pq;
vector<int> v;

int main() {
    int n;
    scanf("%d", &n);

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        int t;
        scanf("%d", &t);
        cnt += (i%2==0 && t%2);
    }
    printf("%d", cnt);
}

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

ans = 0
for i in range(n):
  t = 0
  if b[i] <= a[i]:
    ans += b[i]
    a[i] -= b[i]
  else:
    t = a[i] + a[i+1]
    if b[i] > t:
      a[i+1] = 0
      ans += t
    else:
      a[i+1] -= b[i] - a[i]
      ans += b[i]
print(ans)

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

int main() {
    int N;
    cin >> N;
    int cnt, ans = 0;

    for (int i = 1; i < N+1; i++) {
        cnt = 0;
        if (i % 2 == 1) {
            for (int j = 1; j < i+1; j++) {
                if (i % j == 0) cnt += 1;
                if (cnt > 8) {
                    break;
                }
            }
            if (cnt == 8) ans += 1;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int A, B, X;
    cin >> A >> B >> X;
    if (X >= A && X <= A + B)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPI(itr, v) for(auto itr = (v).begin(); itr != (v).end(); ++itr)
#define MAX_N 100000

using namespace std;


vector<pair<int, int>> G_1[MAX_N], G_2[MAX_N];

bool is_line(int N){

  vector<int> is_visit(N, 0);
  vector<int> x(N, 0);

  REP(i, N){
    if(is_visit[i]){
      continue;
    }
    
    queue<int> que;

    que.push(i);
    is_visit[i] = 1;
    while(!que.empty()){
      int j = que.front();
      que.pop();
      
      REPI(itr, G_1[j]){
	int k = itr->first;
	int x_new = x[j] + itr->second;
	if(is_visit[k]){
	  if(x[k] != x_new){
	    return false;
	  }
	}else{
	  que.push(k);
	  is_visit[k] = 1;
	  x[k] = x_new;
	}
      }

      REPI(itr, G_2[j]){
	int k = itr->first;
	int x_new = x[j] - itr->second;
	if(is_visit[k]){
	  if(x[k] != x_new){
	    return false;
	  }
	}else{
	  que.push(k);
	  is_visit[k] = 1;
	  x[k] = x_new;
	}
      }
    }
  }

  return true;
}

int main(void){

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

  REP(i, M){
    int L, R, D;
    cin >> L >> R >> D;
    G_1[L-1].push_back({R-1, D});
    G_2[R-1].push_back({L-1, D});
  }

  cout << (is_line(N) ? "Yes" : "No") << endl;

  return 0;
}


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

#define rep(i,a,b) for(int i=a;i<(b);i++)
#define trav(a,x) for(auto & a :x)
#define all(x) begin(x),end(x)
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vpii vector<pii>
#define F first
#define S second

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


const int M=1e9+7;

/*
ll powermod(ll x, ll y, ll p)  
{  
    ll res = 1;    
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
*/


void solve()
{ 
char a;
cin>>a;

if(isupper(a))
cout<<"A";
else
cout<<"a";
}

int main() 
{   
    ios::sync_with_stdio(0);
	cin.tie(0);
  
   int test=1;
  // cin>>test;
   while(test--)
    {
	  solve();
	  cout<<"\n";
    }
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(998244353)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll n,k;cin>>n>>k;
  vector<ll> A(n);
  ll sum = 0;
  rep(i,n){
    cin>>A[i];
    sum += A[i];
  }

  vector<ll> P;
  P.push_back(1);
  reps(p, sqrt(sum) + 10){
    if(sum%p == 0){
      P.push_back(p);
      P.push_back(sum/p);
    }
  }

  sort(all(P));

  rep(i,P.size()-1){
    if(P[i] == P[i+1]){
      P.erase(P.begin() + i);
      i--;
    }
  }

  REP(p_,P.size()){
    ll p = P[p_];

    vector<ll> sa;
    rep(i,n){
      sa.push_back(A[i]%p);
    }
    sort(all(sa));
    ll ruiseki = 0, gyaku = 0;
    rep(i,n){
      if(sa[i] + ruiseki <= k){
        ruiseki += sa[i];
      }else{
        gyaku += (p - sa[i]);
      }
    }
    if(ruiseki >= gyaku){
      cout<<p<<endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#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 gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.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 pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

int h,w,m;

ll f(vvi a) {
  ll res = 0;
  bool up = false;
  rep(i,h) {
    vi t;
    rep(j,w) {
      if (a[i][j]) t.pb(a[i][j]);
    }
    while (sz(t) < w) t.pb(0);
    a[i] = t;
  }
  rep(i,h)rep(j,w) {
    if (!a[i][j]) continue;
    int s = i;
    while (s < h && a[i][j] == a[s][j]) ++s;
    if (s-i >= m) {
      up = true;
      for (int k = i; k < s; ++k) {
        res += a[k][j];
        a[k][j] = 0;
      }
    }
  }
  if (up) return f(a)*2+res;
  return 0;
}

int main() {
  scanf("%d%d%d",&w,&h,&m);
  vvi a(h,vi(w));
  rep(i,w) {
    string s;
    cin >> s;
    rep(j,h) a[j][w-1-i] = s[j]-'0';
  }
  ll ans = 0;
  rep(i,h)rep(j,w) {
    vvi b = a;
    b[i][j] = 0;
    maxs(ans,f(b));
  }
  cout<<ans<<endl;
  return 0;
}































Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	const int mod = 1000000007;
	int n;
	cin >> n;
    ll ans = 1;
	for (int i = 1; i <= n; ++i) {
		ans *= i;
		ans %= mod;
	}
	dunk(ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> T lcm(T a, T b){return a / gcd(a,b) * b;}


int main() {
  int n,k; cin >>n >>k;
  vector<int> a(n);
  rep(i, n) cin >>a.at(i);
  sort(all(a));
  if (a.at(n-1) < k){
    cout <<"IMPOSSIBLE" <<endl;
    return 0;
  }
  int b = a.at(0);
  rep(i, n) b = gcd(a.at(i), b);
  if (b == 1){
    cout <<"POSSIBLE" <<endl;
    return 0;
  }
  cout <<(k%b==0 ? "POSSIBLE" : "IMPOSSIBLE") <<endl;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
	int a = 0, b = 0;
	char op = 0;

	while(true)
	{
		cin >> a >> op >> b;
		if(op == '?'){ break; }
	
		switch (op)
		{
		case '+':
			cout << a + b << endl;
			break;
		case '-':
			cout << a - b << endl;
			break;
		case '*':
			cout << a * b << endl;
			break;
		case '/':
			cout << a / b << endl;
			break;
		}
	}


	return 0;
}

Measured memory_bytes: 3076
program abc110b
  integer n, m, x, y
  integer, allocatable :: xs(:), ys(:)

  read *, n, m, x, y
  allocate(xs(n), ys(m))
  read *, xs, ys
  if (maxval([xs, x]) < minval([ys, y])) then
     print *, 'No War'
  else
     print *, 'War'
  end if
end program abc110b


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define N 1000

int main(){

  int i, j, c;
  int flag = 0;
  char T[N], P[N];

  scanf("%s", T);
  scanf("%s", P);

  for(i=0; i<strlen(T); i++){
    flag = 0;
    for(j=0, c=i; j<strlen(P); j++, c++){
      if(T[c] != P[j]){
        flag = 1;
      }
    }
    if(flag == 0) printf("%d\n", i);
  }
  return 0;
}

Measured memory_bytes: 540
sx , sy , tx , ty = gets.chomp.split(" ").map(&:to_i)
a = String.new
a="U"*(ty - sy ) + "R" * (tx -sx) + "D" * (ty - sy) + "L"*(tx-sx+1)+"U"*(ty-sy +1)+"R"*(tx - sx +1)+"D"+"R"+"D"*(ty-sy+1)+"L"*(tx-sx+1)+"U"
print(a)


Measured memory_bytes: 1916
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();

        int[] times = new int[n];
        for(int i = 0; i < n; i++)
        	times[i] = sc.nextInt();
        Arrays.sort(times);

        int cnt = 0;
        int idx = 0;
        while(idx < n) {
        	cnt++;
        	int deadLine = times[idx] + k;
        	int startIdx = idx;
        	idx++;
        	while(idx < n && times[idx] <= deadLine && idx - startIdx + 1 <= c) {
        		idx++;
        	}
        }
        System.out.println(cnt);
    }
}


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

int n, g, ans;

int gcd(int p, int q) {return q ? gcd(q, p%q) : p;}

int main() {
	int i, j, k;
	cin >> n;
	for(i=1; i<=n; i++) for(j=1; j<=n; j++) {
		g = gcd(i, j);
		for(k=1; k<=n; k++) ans += gcd(g, k);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int H = sc.nextInt();
   int N = sc.nextInt();
   int a[] = new int[N];
   int sum = 0;
   for(int i=0; i<N; i++){
	   a[i] = sc.nextInt();
   }

   for(int i=0; i<N; i++) {
	   sum += a[i];
   }

   if(H - sum <= 0) {
	   System.out.print("Yes");
	   }else {
	   System.out.print("No");
	   }
   }
}


Measured memory_bytes: 51564
using System;
using System.Linq;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Array.Sort(input);
            Console.WriteLine((input[2] - input[1]) + (input[1] - input[0]) / 2 + ((input[1] - input[0]) % 2 == 0 ? 0 : 2));
#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
const int maxn=500;
vector<int> G[maxn];
int dfn[maxn],low[maxn];
int n,m,u,v,dep,ans;

void init()
{
    dep=ans=0;
    memset(dfn,0,sizeof(dfn));
    memset(low,0,sizeof(low));
    for(int i=0;i<=n;i++) G[i].clear();
}

void Tarjan(int u,int fa)
{
    dfn[u]=low[u]=++dep;
    for(int i=0;i<G[u].size();i++)
	{
        int v=G[u][i];
        if(!dfn[v]){
            Tarjan(v,u);
            low[u]=min(low[u],low[v]);
            if(low[v]>dfn[u]) ans++;
        }else if(v!=fa)
            low[u]=min(low[u],dfn[v]);
    }
}

int main()
{
    while(cin>>n>>m)
    {
        init();
        for(int i=0;i<m;i++){
            cin>>u>>v;
            G[u].push_back(v);
            G[v].push_back(u);
        }
        Tarjan(1,-1);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double PI=3.14159265358979323846;
ll dp;
ll ans;
ll n,m,x,c[101],a[101][101];
void f(ll z,ll sum,vector<ll> y){
   if(z==n){
      rep(i,m){
         if(y[i]<x)return;
      }
      if(ans==-1)ans=sum;
      MIN(ans,sum);
      return;
      
   }
   f(z+1,sum,y);
   rep(i,m){
      
      y[i]+=a[z][i];
      
   }
   f(z+1,sum+c[z],y);
}


int main(){
   ans=-1;
   
   cin>>n>>m>>x;
   vector<ll>y;
   rep(i,m)y.pb(0);
   rep(i,n){
      cin>>c[i];
      
      rep(j,m){
         cin>>a[i][j];
      }
   }
   f(0,0,y);
   cout<<ans<<endl;
   
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define PI acos(-1)
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cerr<<x<<endl;
#define endl "\n"
#define pb push_back
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int nmax=1e5+10;
const int eps=1e-8;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(10);
    //cout<<fixed;
    //cout.tie(NULL);
    int a,b;
    cin>>a>>b;

    int ans=0;

    for(int i=a;i<=b;i++)
    {
        string a=to_string(i);
        string b=a;
        reverse(b.begin(),b.end());

        if(a==b)
            ans++;
    }

    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    int x[N], y[N], h[N];
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> h[i];
    }
    vector<vector<int>> d;
    for (int cx = 0; cx <= 100; cx++) {
        for (int cy = 0; cy <= 100; cy++) {
            int H = 0;
            for (int i = 0; i < N; i++) {
                if (h[i] == 0) continue;
                ll t = abs(x[i] - cx) + abs(y[i] - cy);
                if (H == 0) {
                    H = t + h[i];
                } else if(H != t + h[i]){
                    H = 0;
                    break;
                }
            }
            if (H != 0) {
                d.push_back(vector<int>({cx, cy, H}));
            }
            
        }
    }
    for (vector<int> v : d) {
        bool flag = true;
        for (int i = 0; i < N; i++) {
            if (h[i] != max(v[2] - abs(x[i] - v[0]) - abs(y[i] - v[1]), 0)) {
                flag = false;
                break;
            }
        }
        if (flag) {
            cout << v[0] << " " << v[1] << " " << v[2] << "\n";
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
#define int long long 
using namespace std;
int a[1000005];
int32_t main(){
  int m,n;
  cin >> m >>  n;
  int s= 0;
  for(int i = 0 ; i < n ;i++){ cin >> a[i]; s+=a[i];}
  if(s > m) cout << "-1\n";
  else cout << m-s << "\n";  
    
    return  0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e5+10;
struct node
{
	int a,b,c;
	bool operator < (const node &o) const
	{
		return a-b<o.a-o.b;
	}
}nd[maxn];
int n,n1,n2,n3;
LL sum[maxn];
int main()
{
	cin>>n1>>n2>>n3;
	n=n1+n2+n3;
	LL ans=0;
	for (int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&nd[i].a,&nd[i].b,&nd[i].c);
		ans+=nd[i].c;
		nd[i].a-=nd[i].c;nd[i].b-=nd[i].c;
	}
	sort(nd+1,nd+n+1);
	priority_queue<int,vector<int>,greater<int> >pq;
	LL s=0;
	for (int i=1;i<=n2;i++)
	{
		s+=nd[i].b;
		pq.push(nd[i].b);
	}
	sum[n2]=s;
	for (int i=n2+1;i<=n;i++)
	{
		if (nd[i].b>pq.top())
		{
			s-=pq.top();
			pq.pop();
			s+=nd[i].b;
			pq.push(nd[i].b);
		}
		sum[i]=s;
	}
	while (!pq.empty()) pq.pop();
	s=0;
	for (int i=n;i>n-n1;i--)
	{
		s+=nd[i].a;
		pq.push(nd[i].a);
	}
	sum[n-n1]+=s;
	for (int i=n-n1;i>=1;i--)
	{
		if (nd[i].a>pq.top())
		{
			s-=pq.top();
			pq.pop();
			s+=nd[i].a;
			pq.push(nd[i].a);
		}
		sum[i-1]+=s;
	}
	s=sum[n2];
	for (int i=n2;i<=n-n1;i++) s=max(s,sum[i]);
	cout<<ans+s;
	return 0;
}

Measured memory_bytes: 2812
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<ll> dqll;

int main() {
  double a, b, x;
  cin >> a >> b >> x;

  double ans = 0.0;
  double half = a * a * b / 2;
  if(x >= half){
    ans = atan(-2*(x/(a*a*a) - b/a));
  } else {
    ans = atan((b*b*a)/(2*x));
  }

  printf("%.10f\n", ans*(180.0/M_PI));

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int K, ans;

int main() {
    ios::sync_with_stdio(false);
    cin >> K;
    for(int i = 1; i <= K; i += 2) {
        for(int j = 2; j <= K; j += 2) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;

vector<pair<long long, long long> > prime_factorize(long long n) {
  vector<pair<long long, long long> > res;
  for (long long p = 2; p * p <= n; ++p) {
    if (n % p != 0) continue;
    int num = 0;
    while (n % p == 0) { ++num; n /= p; }
    res.push_back(make_pair(p, num));
  }
  if (n != 1) res.push_back(make_pair(n, 1));
  return res;
}

void solve(long long N){
  map<ll, ll> m;
  for(ll i=1; i<=N; i++) {
    auto v = prime_factorize(i);
    for(auto p : v) {
      m[p.first]+=p.second;
    }
  }
  ll ans = 1;
  for(auto p : m) {
    ans = ans * (p.second+1) % MOD;
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    while(~scanf("%d",&n)){
        int a[100]={0};
        int sum=0;
        for(int i=0;i<n;i++){
            scanf("%d",&a[i]);
            sum+=a[i];
        }
        long long ans=0;
        for(int i=0;i<n;i++){
            if(a[i]==0) continue;
            else{
                ans+=(sum-a[i])*a[i];
            }
        }
        printf("%lld\n",ans/2);
    }
    return 0;
}

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

using namespace std;

namespace Solver {

    const int MAX = 300001;
    vector<bool> isPrime(MAX, false);
    inline void PreCompute() {
        for (int i = 6; i < MAX; i++) {
            if (i % 7 == 1 || i % 7 == 6) {
                isPrime[i] = true;
                for (int j = 2; j * j <= i; j++) {
                    if (isPrime[j] && i % j == 0) {
                        isPrime[i] = false;
                    }
                }
            }
        }
    }

    int N;
    inline bool Read() {
        cin >> N;
        return N != 1;
    }

    inline void Work() {
        vector<int> vi;
        for (int i = 6; i <= N; i++) {
            if (isPrime[i] && N % i == 0) vi.push_back(i);
        }

        cout << N << ": ";
        for (int i = 0; i < vi.size() - 1; i++) {
            cout << vi[i] << " ";
        }

        cout << vi[vi.size() - 1] << endl;
    }

    inline void Solve() {
        PreCompute();
        while(Read()) Work();
    }
}

int main() {
    Solver::Solve();
}

Measured memory_bytes: 1248
import           Control.Applicative
import           Control.Monad
import           Data.List
import           Text.Printf

det []=   1
det (h:t) = foldr1 (-) [v*det [take i l ++ drop (i+1) l | l<-t] | (i,v)<-zip [0..] h]

main :: IO ()
main = do
  n <- readLn
  pts<- replicateM n getLine
  mapM_ (process . map (read :: String -> Double) . words) pts
    where
      process::[Double]->IO()
      process [x1,y1,x2,y2,x3,y3] = printf "%.3f %.3f %.3f\n" (rnd x) (rnd y) (rnd r)
        where
          det0 = det [[x1,y1,1],[x2,y2,1],[x3,y3,1]]
          x = det [[x1^2+y1^2,y1,1],[x2^2+y2^2,y2,1],[x3^2+y3^2,y3,1]] / 2.0 / det0
          y = det [[x1,x1^2+y1^2,1],[x2,x2^2+y2^2,1],[x3,x3^2+y3^2,1]] / 2.0 / det0
          r = sqrt ((x-x1)^2+(y-y1)^2)
          rnd val
            | abs val < 0.0005 = 0.0
            | otherwise = val



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

int main(){
  int a;
  bool flag=false;
  cin >> a;
  r(i,9){
    r(j,9){
      if(a==i*j)flag=true;
    }
  }
  if(flag)cout << "Yes"<<endl;
  else cout << "No"<<endl;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n = read::<usize>();
    let ax = read_vec::<usize>();

    let mut v = vec![0; n];

    for (i, &a) in ax.iter().enumerate() {
        v[a-1] = i + 1;
    }

    let ans = v.iter().map(|i| i.to_string()).collect::<Vec<_>>().join(" ");

    println!("{}", ans);
}

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

int main() {
int64_t n,x,m,a,so,sy,ma;
  a=0;
  so=0;
  sy=0;
  ma=0;
  cin>>n>>x>>m;
  vector<int64_t> vec(m+1);
  vec.at(0)=x%m;
  for(int64_t i=0;i<m;i++){
  vec.at(i+1)=(vec.at(i)*vec.at(i))%m;
  }
  for(int64_t i=m;i>=0;i--){
  if(vec.at(m)==vec.at(i)){a=i;}
  }
  for(int64_t i=a;i<=(n-a-1)%(m-a)+a;i++){
  so=so+vec.at(i);}
  for(int64_t i=a;i<m;i++){
    sy=sy+vec.at(i);
  }
  for(int64_t i=0;i<=a-1;i++){
   ma=ma+vec.at(i);
  }
  cout<<ma+so+((n-a-1)/(m-a))*sy<<endl;
} 

Measured memory_bytes: 3980
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define ALL(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

ll modpow(ll x, ll n) {
    if(n==0){
        return 1;
    }else if(n%2==0){
        ll h = modpow(x,n/2);
        return h * h % MOD;
    } else {
        return x * modpow(x,n-1) % MOD;
    }
}

int main() {
  int P, Q, R; cin >> P >> Q >> R;
  cout << P+Q+R-max(R,max(P,Q)) << endl;

  return 0;
}


Measured memory_bytes: 256
import numpy as np


N, M, C   = [int(i) for i in input().split()]

B = [int(i) for i in input().split()]


A = []
for i in range(N):
    A.append([int(i) for i in input().split()])

#print([N, M, C])

B = np.array(B)
#print(B)

A = np.array(A)
#print(A)


print(np.sum((np.sum(A * B, axis=1) + C) > np.array(0)))



Measured memory_bytes: 21316