akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr, class func> void array_output(itr start, itr goal, func out = [](itr x) { return x; } ){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr, class func> void nint_output(itr start, itr goal, func out = [](itr x) { return x; } ){ string ans; for(auto i = start; i != goal; i++){ ans += string(out(*i)) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcount(n)

int main(){
    double a, b, c, d, e, f;
    while(cin >> a >> b >> c >> d >> e >> f){
        double x = (c * e - b * f) / (a * e - b * d), y = (a * f - d * c) / (a * e - b * d);
        cout << fixed << setprecision(3) << (++(--x)) << " " << (++(--y)) << endl;
    }
}



Measured memory_bytes: 3168
top = 0
MAX = 101
S = [0] * MAX


def initialize():
    global top
    top = 0


def isEmpty():
    global top
    return top == 0


def isFull():
    global top
    return top == MAX - 1


def push(a):
    if isFull():
        return
    global top
    top += 1
    S[top] = a


def pop():
    if (isEmpty()):
        return -1
    global top
    top -= 1
    return S[top+1]


def main():
    s = input().split()
    for c in s:
        if c == '+':
            a = pop()
            b = pop()
            push(a + b)
        elif c == '-':
            a = pop()
            b = pop()
            push(b - a)
        elif c == '*':
            a = pop()
            b = pop()
            push(a * b)
        else:
            push(int(c))
    print(pop())


if __name__ == '__main__':
    main()



Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout<<endl
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

int main()
{
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	int cnt = 0;
	rep(i, n)
	{
		if (a[i] == cnt + 1)cnt++;
	}
	int ans = n - cnt;
	if (cnt == 0)ans = -1;
	co(ans);
	return 0;
}


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

int main(){
    int x, y, z;
    cin >> x >> y >> z;

    cout << z <<" "<< x<<" " << y << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
using namespace std;
int main(void){
    while(1){
        int n,m,in;
        cin >> n;//最後のマス
        cin >> m;//さいころのふる事のできる限界値
        if(n==0&&m==0)break;
        int masu[n+1];
        for(int i=1;i<n+1;i++){
            cin>>masu[i];
        }
        int t=1,memo;
        bool sw=true;
        for(int i=0;i<m;i++){
            cin>>in;
            if(sw==true){
                t+=in;
                if(t<=0)t=1;
                if(t>=n){
                    sw=false;
                    memo=i+1;
                }
                t+=masu[t];
                if(t<=0)t=1;
                if(t>=n){
                    sw=false;
                    memo=i+1;
                }
            }
        }
        cout << memo << "\n";
    }
    return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
#define mod 998244353
class BIT {
public:
    ll n; //データの長さ
    vector<ll> bit; //データの格納先
    BIT(ll n):n(n),bit(n+1,0){} //コンストラクタ

    //k & -kはLSB

    //bit_iにxをO(log(n))で加算する
    void add(ll i,ll x){
        if(i==0) return;
        for(ll k=i;k<=n;k+=(k & -k)){
            bit[k]+=x;
        }
    }

    //bit_1 + bit_2 + …  + bit_n をO(log(n))で求める
    ll sum(ll i){
        ll s=0;
        if(i==0) return s;
        for(ll k=i;k>0;k-=(k & -k)){
            s+=bit[k];
        }
        return s;
    }

    //a_1 + a_2 + … + a_i >= x となるような最小のiを求める(a_k >= 0)
    //xが0以下の場合は該当するものなし→0を返す
    ll lower_bound(ll x){
        if(x<=0){
            return 0;
        }else{
            ll i=0;ll r=1;
            //最大としてありうる区間の長さを取得する
            //n以下の最小の二乗のべき(BITで管理する数列の区間で最大のもの)を求める
            while(r<n) r=r<<1;
            //区間の長さは調べるごとに半分になる
            for(int len=r;len>0;len=len>>1) {
                //その区間を採用する場合
                if(i+len<n && bit[i+len]<x){
                    x-=bit[i+len];
                    i+=len;
                }
            }
            return i+1;
        }
    }
};
#define MAXN 200005
ll dp[MAXN];
int main() {
    int n, k;
    cin >> n >> k;
    BIT tree(n);
    memset(dp, 0, sizeof(dp));
    ll l[k + 1];
    ll r[k + 1];
    for (int i = 1; i <= k; i++) {
        cin >> l[i] >> r[i];
    }
    dp[1] = 1;
    tree.add(1, 1);
    for (int i = 2; i <= n; i++) {
        for (int j = 1; j <= k; j++) {
            if (i - l[j] >= 1) {
                ll M = 0;
                if (i - r[j] - 1 > 0) M = i - r[j] - 1;
                dp[i] = (dp[i] + tree.sum(i - l[j]) - tree.sum(M)) % mod;
            }
        }
        tree.add(i, dp[i]);
    }
    while (dp[n] < 0) dp[n] += mod;
    cout << dp[n] << endl;
    return 0;
}

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

int main() {
	int64_t a, b, x;
	cin >> a >> b >> x;
	cout << (a != 0 ? b / x - (a - 1) / x : b / x + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
void main() {
    int hund, tens, unit, n;
    scanf("%d", &n);

    hund = n / 100;
    n %= 100;
    tens = n / 10;
    unit = n % 10;

    if (hund == 7 || tens == 7 || unit == 7)
        printf("Yes");
    else
        printf("No");
}


Measured memory_bytes: 1708
#include<iostream>
#include<cmath>
#include<stack>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef unsigned long long ll;

ll con(string s){
	ll res=0;
	rep(i,s.size()){
		res+=(int)(s[i]-'0')*pow(10,s.size()-i-1);
	}
	return res;
}

ll cal(stack<char> ta){
	ll res=0,size=ta.size();
	char a;
	rep(i,size){
		a=ta.top();
		ta.pop();
		res+=(int)(a-'0')*pow(10,i);
	}
	return res;
}

int main(){
	ll n;
	string s;
	cin>>s;
	n=con(s);
	ll dp[(int)pow(2,s.size()-1)];
	rep(i,(int)pow(2,s.size()-1))dp[i]=0;
	rep(i,(int)pow(2,s.size()-1)){
		stack<char> st;
		rep(j,s.size()-1){
			if((i & (1<<j))){
				st.push(s[j]);
				dp[i]+=cal(st);
				while(!st.empty())st.pop();
			}else{
				st.push(s[j]);
			}
		}
		st.push(s[s.size()-1]);
		dp[i]+=cal(st);
	}
	ll res=0;
	rep(i,(int)pow(2,s.size()-1))res+=dp[i];
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


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

    ll N, K ;
    cin >> N >> K ;
    
    vector<ll> A;
    map<ll, bool> checked;
    
    rep(i, N){
        ll inp; cin >> inp;
        inp --;
        A.pb(inp);
    }
    
    vector<ll> candi;
    candi.pb(0);
    checked[0] = true;
    
    ll roopidx = 0;
    while(true){
        ll lst = candi[candi.size() - 1];
        ll nxt = A[lst];
        if(checked[nxt]) {
            roopidx = nxt;
            break;
        } else {
            candi.pb(nxt);
            checked[nxt] = true;
        }
    }
    
    
    rep(i, candi.size()){
        if(candi[i] == roopidx) {
            roopidx = i;
            break;
        }
    }
    
    if(K < roopidx){
        cout << candi[K] + 1 << endl;
        return 0;
    }
    K -= roopidx;
    K %= (candi.size() - roopidx);
    
    cout << candi[K + roopidx] + 1 << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 18780
l = int(input())

l2 = bin(l)[2:]
n = len(l2)
count = 0
for i in range(len(l2)):
    count += int(l2[i])
m = 2 * (n - 1) + count - 1
print(n, m)
for i in range(n - 1):
    print(i + 1, i + 2, 0)
    print(i + 1, i + 2, 2 ** i)
for i in range(1, n):
    if int(l2[i]) == 0:
        continue
    num = 0
    for j in range(i):
        if int(l2[j]) == 1:
            num += 2 ** (n - j - 1)
    print(n - i, n, num)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int MOD = 1e9 + 7;

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

    int N;
    cin >> N;
    int ma = 0;
    map<string, int> mp;
    for (int i = 0; i < N; ++i) {
        string S;
        cin >> S;
        mp[S]++;
        ma = max(ma, mp[S]);
    }

    for (auto s : mp)
        if (s.second == ma)
            cout << s.first << endl;

    return 0;
}


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

int main(){
  int a,b;
  cin>>a>>b;
  if(a==1) a=14;
  if(b==1) b=14;
  if(a>b) cout<<"Alice"<<endl;
  else if(a<b) cout<<"Bob"<<endl;
  else cout<<"Draw"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <limits>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    float ans = 0;
    vector<float> a(110);
    for(int i = 0;i < n;i++){
        cin >> a[i];
        ans += 1/a[i];
    }
    cout << fixed << setprecision(10) << 1/ans  << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef __int128 lll;
#define print(i) cout << "debug: " << i << endl
#define close() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mem(a, b) memset(a, b, sizeof(a))
const ll mod = 1e9 + 7;
const int maxn = 2e6;
const int inf = 0x3f3f3f3f;

int main()
{
    int n; cin >> n;
    string s; cin >> s;
    int len = s.length();
    int l = 0, r = n - 1;
    int res = 0;
    while(1)
    {
        while(l < n && s[l] == 'R') l++;
        while(r >= 0 && s[r] == 'W') r--;
        if(l < r) res++, l++, r--;
        else break;
    }
    cout << res << endl;
}

Measured memory_bytes: 3720
N = int(input())
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
        
        
print(num2alpha(N).lower())

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll arr[1010];
int main()
{
    //freopen("in.txt", "r", stdin);
    arr[1]=300000;
    arr[2]=200000;
    arr[3]=100000;
    ll x,y;
    cin>>x>>y;
    if(x==1 && y==1){
        cout<<arr[x]+arr[y]+400000<<endl;
    }
    else{
        cout<<arr[x]+arr[y]<<endl;
    }

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
set<int> s;
int x;
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	for(int i = 0;i < 3;i++){
		cin >> x;
		s.insert(x);	
	}
	if(s.size() == 2) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main() {
  char c;
  cin >> c;
    if (c == 'a') {
      cout << "vowel" << endl;
    }
    else if (c == 'i') {
      cout << "vowel" << endl;
    }
    else if (c == 'u') {
      cout << "vowel" << endl;
    }
    else if (c == 'e') {
      cout << "vowel" << endl;
    }
    else if (c == 'o') {
      cout << "vowel" << endl;
    }
    else {
      cout << "consonant" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define fish        push_front
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Deque       std::deque
#define PQueue      std::priority_queue
#define Set         std::set
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm   ( A x,  B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    inline boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    signed call_of_Cthulhu( signed datum ) {

        String s;
        int w;
        read s >> w;
        for ( int i = 0; i < s.size(); i += w ) {
            echo s[i];
        }
        echo endl;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
#include<stdio.h>

int partition(int *A,int p,int r){
  int x,i,j,tmp;

  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++; 
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  }
  tmp=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp;

  return i+1;
}

int main(){
  int n,i,p,r,c;
  scanf("%d",&n);
  int A[n];

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

  c=partition(A,0,n-1);

  for(i=0;i<n;i++){
    if(i!=0) printf(" ");
    if(i==c) printf("[%d]",A[i]);
    else     printf("%d",A[i]);
  }

  printf("\n");
  
  return 0;
}



Measured memory_bytes: 2144
#include<stdio.h>
int main(void)
{
  int n,k;
  long count_k=0;
  long count_g=0;

  scanf("%d %d",&n,&k);
  for(int i=1;i<=n;i++){
    if(i%k==0){
      count_k++;
    }
    if(i%k==k/2){
      count_g++;
    }
  }

  if(k%2==1){
    printf("%ld\n",count_k*count_k*count_k);
  }else{
    printf("%ld\n",(count_k*count_k*count_k)+(count_g*count_g*count_g));
  }


  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int f[MAXN];
int a[MAXN];
int N;
int main()
{
  	cin >> N;
	for (int i = 1; i <= N; i++)
    	cin >> a[i];
  	f[1] = 0;
  	f[2] = abs(a[2] - a[1]);
    for (int i = 3; i <= N; i++)
    	f[i] = min(f[i - 1] + abs(a[i] - a[i - 1]), f[i - 2] + abs(a[i] - a[i - 2]));
  	cout << f[N] << endl;
	return 0;
}

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


namespace ConsoleApp6
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] atoz = new int[26];
			char[] az = new char[26];
			char a = 'a';
			for (int i = 0; i < 26; i++)
					{
						az[i] += a;
						a++;
					}

			while (true)
			{
				var abc = Console.ReadLine();

				if(abc == null)
				{
					break;
				}

				var xyz = abc.ToLower();

				for (int j = 0; j < abc.Length; j++)
				{

					int num = xyz[j] - 'a';

					if (num >= 0)
					{
						atoz[num]++;
					}

				}
				
							
			}

			for (int k = 0; k < 26; k++)
				{
					Console.WriteLine("{0} : {1}", az[k], atoz[k]);
					
				}
		}
	}
}



Measured memory_bytes: 17832
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
  	int n,memo = 0,zero = 0;
  	cin >> n;
  	int cx[n] = {0},cy[n] = {0},ch[n] = {0};
  
  	rep(i,0,n){
      cin >> cx[i] >> cy[i] >> ch[i];
      //if(!i) memo = ch[i];
      //else memo = min(memo,ch[i]);
    }
  
  
  	rep(i,0,101){
      rep(j,0,101){
        rep(k,0,n){
          	if(ch[k]) memo = ch[k] + abs(i-cx[k]) + abs(j-cy[k]);
        }
        rep(k,0,n){
        	if(max(0,memo-abs(i-cx[k])-abs(j-cy[k])) != ch[k]){
              break;
            }
          	else if(k == n-1){
              cout << i << " "<< j << " " << memo << endl;
              return 0;
            }
        }
      }
    }
  	cout << -1 << endl;
	return 0; 
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int N=in.nextInt();
		while(N-->0)
		{
			int nx=0;
			int ny=0;
			int ax=0;
			int ay=0;
			int dis=0;
			for(;;)
			{
				int dx=in.nextInt();
				int dy=in.nextInt();
				if((dx|dy)==0)
					break;
				nx+=dx;
				ny+=dy;
				if(dis<=nx*nx+ny*ny)
				{
					if(dis<nx*nx+ny*ny)
					{
						dis=nx*nx+ny*ny;
						ax=nx;
						ay=ny;
					}
					else if(dis==nx*nx+ny*ny&&nx>ax)
					{
						dis=nx*nx+ny*ny;
						ax=nx;
						ay=ny;
					}
				}
			}
			System.out.println(ax+" "+ay);
		}
	}
}

Measured memory_bytes: 12000
if __name__ == '__main__':
    n = int(input())
    a = [int(i) for i in input().split()]
    mod = 10**9+7
    sumA = sum(a)
    sumB = 0
    count = 0

    for i in range(n-1):
        sumB+=a[i]
        count += ((sumA-sumB)*a[i])%mod
    print(count%mod)



Measured memory_bytes: 31432
s = input()
t = input()

ans = [None for i in range(len(s))]
for i in range(len(s)):
    ans[i] = s[i]

for i in reversed(range(len(s)-len(t)+1)):
    flag = 0
    for j in range(len(t)):
        if s[i+j]!=t[j] and s[i+j]!="?":
            flag = 1
    if flag == 0:
        for j in range(len(t)):
            ans[i+j]=t[j]
        for j in range(len(s)):
            if ans[j]=="?":
                ans[j]="a"
        print("".join(ans))
        exit()

print("UNRESTORABLE")


Measured memory_bytes: 3064
o=lambda:map(int,raw_input().split());s=10**5
n,k=o();r=range(n)
e=[[]for _ in [0]*n]
for _ in [0]*(n-1):a,b=o();e[a-1]+=[b-1];e[b-1]+=[a-1]
def U(x,f):
 if f>=0:l[f]=1
 q=[(x,0)]
 while len(q):
  v,c=q.pop(0)
  if c>k/2:break
  l[v]=1
  for w in e[v]:
   if not l[w]:q+=[(w,c+1)]
 return n-l.count(1)
if k%2:
 for i in r:
  for j in e[i]:
   if i<j:l=[0]*n;U(i,j);s=min(s,U(j,i))
else:
 for i in r:l=[0]*n;s=min(s,U(i,-1))
print s


Measured memory_bytes: 27036
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

struct mypair{
    LL a;
    bool b;

    bool operator <(const mypair &right)const{
        return a < right.a;
    }
};

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

    LL w,h;
    cin >> w >> h;

    vector<mypair> in;

    for(int i = 0; i < w; i++){
        LL a;
        cin >> a;
        in.push_back(mypair{a,true});
    }

    for(int i = 0; i < h; i++){
        LL a;
        cin >> a;
        in.push_back(mypair{a,false});
    }

    sort(in.begin(),in.end());

    h++;w++;

    LL ans = 0;

    for(int i = 0; i < in.size(); i++){
        ans += (in[i].b? in[i].a*h + 0*(w--) : in[i].a*w + 0*(h--) );
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 

void add(vector<pii> &v, vi &arr,int n,int a){
	for(int i=0;i<n;i++) v.pb({arr[i],a});
}
int solve(){
	int x,y,a,b,c;cin>>x>>y>>a>>b>>c;
	vi red(a),green(b),color(c);
	inputarr(red,a);
	inputarr(green,b);
	inputarr(color,c);
	vector<pii> v;
	add(v,red,a,0);
	add(v,green,b,1);
	add(v,color,c,2);
	sort(all(v),greater<pii>());
	int ca=0,cb=0;
	int cnt=x+y;
	int ans=0;
	for(auto i:v){
		if(cnt==0) break;
		if(i.ss==0){
			if(ca==x) continue;
			ca++;
			cnt--;
		}
		else if(i.ss==1){
			if(cb==y) continue;
			cb+=1;
			cnt--;
		}
		else {
			cnt--;
		}
		ans+=i.ff;
	}
	cout<<ans;




    return 0;
}
signed main(){
    asdf
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 12396
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;

int main(){
	string s,t;
	cin>>s;
	cin>>t;
	int n = s.size();
	bool ans;
	for(int i = 0; i < n; i ++){
		ans = true;
		for(int j = 0; j < n; j++){
			if( s[ (i + j) % n] != t[j]){
				ans = false;
				break;
			}
		}
		if( ans == true){
			break;
		}
	}
	if(ans == true){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3028
n = gets.to_i
a = Array.new(n)
n.times do |i|
  a[i] = gets.to_i
end

$pairs_count = 0
def make_pairs_at(a, i)
  if a[i] > 1
    pairs = a[i] / 2
    a[i] -= pairs *2
    $pairs_count += pairs
  end

  if a[i] == 1
    if a[i+1].to_i > 0
      a[i] = 0
      a[i+1] -=1
      $pairs_count += 1
    end
  end

end


(0...n).each do |i|
  make_pairs_at(a, i)
end

puts $pairs_count

Measured memory_bytes: 2812
N = int(input())
L = [0]*(N+1)
sN = int(N**0.5)+1
for x in range(1,sN+1):
    for y in range(1,sN+1):
        for z in range(1,sN+1):
            P = x**2+y**2+z**2+x*y+y*z+z*x
            if 1<=P<=N:
                L[P]+=1
for i in range(1,N+1):
    print(L[i])


Measured memory_bytes: 69884
#include <stdio.h>

int main(void) {
	int y, m, d;
	while(scanf("%d %d %d",&y,&m,&d) != EOF){
		if( ( (y==1868&&m==9&&d>=8) || (y==1868&&m>9) || (y>1868) ) && ( (y==1912&&m==7&&d<=29) || (y==1912&&m<7) || (y<1912) ))
		printf("meiji %d %d %d\n",y-1867,m,d);
		else if( ((y==1912&&m==7&&d>=30)||(y==1912&&m>7)||(y>1912)) && ((y==1926&&m==12&&d<=24)||(y==1926&&m<12)||(y<1926)) )
		printf("taisho %d %d %d\n",y-1911,m,d);
		else if( ((y==1926&&m==12&&d>=25)||(y==1926&&m>12)||(y>1926)) && ((y==1989&&m==1&&d<=7)||(y==1989&&m<1)||(y<1989)) )
		printf("showa %d %d %d\n",y-1925,m,d);
		else if((y==1989&&m==1&&d>=8)||(y==1989&&m>1)||(y>1989))
		printf("heisei %d %d %d\n",y-1988,m,d);
		else printf("pre-meiji\n");
	}
	
	return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define MOD 1000000007

using namespace std;
using ll = long long;

int main() {
	ll x, y;
	string ans = "No";
	cin >> x >> y;
	rep(i,x + 1) {
		ll n = i * 2 + 4 * (x - i);
		if (n == y) ans = "Yes";
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int n,m,a;
	cin >> n >> m;
	REP(i,m){
		cin >> a;
		n -= a;
	}
	println(max(-1,n));
	return 0;
}


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

int N,C;
int D[55][55];
vector<int> cnt[3];
int main() {
  cin >> N >> C;
  for(int i=0;i<C;i++)
    for(int j=0;j<C;j++)
      cin >> D[i][j];

  for(int i=0;i<N;i++) {
    for (int j = 0; j < N; j++) {
      int c;
      cin >> c; --c;
      cnt[(i + j) % 3].emplace_back(c);
    }
  }

  int cost[3][55] = {};
  for(int i=0;i<3;i++)
    for(int c=0;c<C;c++)
      for(auto p : cnt[i])
        cost[i][c] += D[p][c];

  int res = INT_MAX;
  for(int i=0;i<C;i++)
    for(int j=0;j<C;j++)
      for(int k=0;k<C;k++) {
        if (i == j || j == k || i == k) continue;
        res = min( res, cost[0][i] + cost[1][j] + cost[2][k]);
      }

  cout << res << endl;
}

Measured memory_bytes: 1520
#include <bits/stdc++.h>
using namespace std;
#define Endl endl
typedef long long ll;
const int MAXN = (int)2e5 + 5;
ll a, b;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> a >> b)
		cout << max(max(a + b, a - b), a*b) << endl;
}
/*
-13 3

1 -33

13 3
*/

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    int K,A,B;
    cin >> K >> A >> B;
    if(B/K * K >= A){
        fin("OK");
    }else{
        fin("NG");
    }
    return 0;
}

Measured memory_bytes: 3128
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <bitset>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    constexpr ll mod = 1000000007;

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

    vec<int> a(m);
    vec<ll> dp(n + 1);
    for (auto &e : a)
    {
        cin >> e;
        dp[e] = -1;
    }
    dp[0] = 1;

    for (int i = 1; i <= n; ++i)
    {
        if (dp[i] != 0)
            continue;
        if (i - 1 >= 0 && dp[i - 1] >= 0)
            dp[i] += dp[i - 1];
        if (i - 2 >= 0 && dp[i - 2] >= 0)
            dp[i] += dp[i - 2];

        dp[i] %= mod;
        //cout << i << " " << dp[i] << endl;
    }

    cout << max(0ll, dp[n]) << endl;

    return 0;
}


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

using namespace std;

int main()
{
    string S;

    cin >> S;

    int sum = 0;

    for(int i=0; i<S.length(); i++){
        if(S[i] == 'o'){
            sum++;
        }
    }

    sum += 15 - S.length();

    if(sum >= 8){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}

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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int K;
	cin >> K;
	for (int n = 0;n<K;++n) {
		if (B<=A) {
			B *= 2;
		}
		else {
			C *= 2;
		}
	}
	if (A<B &&B<C) {
		cout << "Yes"<<endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

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

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

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

	char c[3]; cin >> c[0] >> c[1] >> c[2];

	sort(c,c+3);

	if(c[0] == 'a' && c[1] == 'b' && c[2] == 'c') cout << "Yes\n";
	else cout << "No\n";

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
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; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}


signed main(){
    cout << fixed << setprecision(10);
    intl x,n;
    cin >> x >> n;
    intl p[n];
    rep(i,n)cin >> p[i];
    intl cnt = 0;
    while(true){
        bool f = true;
        rep(i,n){
            if(x >= cnt)if(x - cnt == p[i])f = false;
        }
        if(f){
            cout << x - cnt << endl;
            break;
        }
        f = true;
        rep(i,n){
            if(x + cnt == p[i])f = false;
        }
        if(f){
            cout << x + cnt << endl;
            break;
        }
        cnt++;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int n,u[21];
vector <int> a,b;
int minsa = 100000;

void kakunin() {
  cout << "ateam" << endl;
  for(int i=0;i<a.size();i++) cout << a[i] <<" ";
  cout << endl<< "bteam" << endl;
  for(int i=0;i<b.size();i++) cout << b[i] << " " ;
  cout << endl<<"----------------------"<<endl;;
}

void sa() {
  //  kakunin();
  int sum = 0;  
  for(int i=0;i<a.size();i++) sum += a[i];
  for(int i=0;i<b.size();i++) sum -= b[i];
  if(sum < 0) sum *= -1;
  if(minsa > sum) minsa = sum;
}
				
				
void check(int x) {
  //  kakunin();
  int flag = 0;
  if(x == n) {
    sa();
    flag = 1;
  }
  else if(flag == 0) {
    a.push_back(u[x]);
    check(x+1);
    a.pop_back();
    
    b.push_back(u[x]);
    check(x+1);
    b.pop_back();
  }
} 

int main() {

  while(1) {
    cin >> n;
    if(n == 0) break;
    for(int i=0;i<n;i++) cin >> u[i];
    minsa = 1000000;
    check(0);
    a.clear();
    b.clear();
    cout << minsa << endl;
  }

  return 0;
}

  
  
  

Measured memory_bytes: 1220
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    // macro_rules! get { () => (get().parse().unwrap()) }
    
    let s = get().as_bytes();
    let t = get().as_bytes();
    
    let mut ss = vec![0; 256];
    let mut tt = vec![0; 256];
    
    for &c in s.iter() {
    	ss[c as usize] += 1;
    }
    for &c in t.iter() {
    	tt[c as usize] += 1;
    }
    
    let mut sx = vec![];
    let mut tx = vec![];
    
	for i in 0..256 {
    	for _ in 0..ss[i] {
        	sx.push(i);
        }
        for _ in 0..tt[255-i] {
        	tx.push(255-i);
        }
    }
    
    for i in 0..std::cmp::min(sx.len(), tx.len()) {
    	if sx[i] < tx[i] {
        	println!("Yes");
            return;
        } else if sx[i] > tx[i] {
        	println!("No");
            return;
        }
    }
    if sx.len() < tx.len() {
    	println!("Yes");
    } else {
    	println!("No");
    }
}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

const int MAXN = 100010;
int a[MAXN];

int main(){
  ios::sync_with_stdio(0); cin.tie(0);
  int n, k;
  cin >> n >> k;
  if(k == n){
    cout << "1\n";
    return 0;
  }
  int mn = (int)1e9, idx = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if(a[i] < mn){
      mn = a[i];
      idx = i;
    }
  }
  int ans = 0;
  int i = idx, j = idx;
  if(idx - k + 1 > 0 && idx + k - 1 < n - 1){
    while(i > 0){
       i -= (k - 1);
       ans++;
     }
     while(j < n - 1){
       j += (k - 1);
       ans++;
     }
  } else {
    for(i = 0; i < n - 1; ){
      i += (k - 1);
      ans++;
    }
  }
  int sh = (k - 1)/2;
  i = idx - sh;
  int ans2 = 0;
  while(i < n - 1){
    i += (k - 1);
    ans2++;
  }
  j = 0;
  while(j < idx - sh){
    j += (k - 1);
    ans2++;  
  }
  cout << min(ans, ans2) << "\n";

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main(){
  string s,t;
  bool f = false;
  cin>>s>>t;
  for(ll i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      f = true;
    }
  }
if(f){
  cout<<"No\n";
}else{
  if(t.size() - 1 == s.size()){
    cout<<"Yes\n";
  }else{
    cout<<"No\n";
  }
}
return 0;
}

Measured memory_bytes: 3592
import sys
from itertools import combinations as combi
input = sys.stdin.readline
N = int(input())
a = [[] for _ in range(N + 1)]
for i in range(1, N + 1):
  t = int(input())
  for _ in range(t):
    a[i].append(tuple(map(int, input().split())))
x = [i for i in range(1, N + 1)]
res = 0
#print(a)
for i in range(N + 1):
  for c in combi(x, i):
    #print(c)
    table = [0] * (N + 1)
    for p in c:
      table[p] = 1
    f = 0
    for p in c:
      #print(a[p])
      for q in a[p]:

        if table[q[0]] != q[1] and (table[q[0]] != -1):
          f = 1
          break
        table[q[0]] = q[1]
      if f: break
    for i in range(1, N + 1):
      if table[i] == 1:
        for q in a[i]:
          if table[q[0]] != q[1] and (table[q[0]] != -1):
            f = 1
            break
          table[q[0]] = q[1]

        if f: break
    if f == 0:
      res = max(res, len(c))
      #print(c, table)

print(res)


Measured memory_bytes: 45036
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int N,M;
int h[1500];
int w[1500];
int sum_w[1500];//横の和
int sum_h[1500];//縦の和
vector<int> wa,wb;
int main()
{
  while(cin>>N>>M,N||M){
    wa.clear();
    wb.clear();
    for(int i = 0;i <1500;i++){
      sum_w[i] =sum_h[i]=0;
    }
    h[0] = 0;
    w[0] = 0;
    for(int i = 1;i <=N;i++){
      cin>>h[i];
      h[i] +=h[i-1];
    }
    for(int i = 1;i <=M;i++){
      cin>>w[i];
      w[i]+=w[i-1];
    }
    for(int i = 0;i <=N;i++){
      for(int j = 0;j <i;j++){
	wa.push_back(h[i]-h[j]);
      }
    }
    for(int i = 0;i <=M;i++){
      for(int j = 0;j <i;j++){
	wb.push_back(w[i]-w[j]);
      }
    }
    sort(wa.begin(),wa.end());
    sort(wb.begin(),wb.end());
    int cnt = 0;
    
    for(int i =0;i <wa.size();i++){
      int d =wa[i];
      int pos =lower_bound(wb.begin(),wb.end(),d)-wb.begin();
      for(;pos<wb.size()&&wb[pos]==d;pos++){
	cnt++;
      }
    }
    cout <<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 16628
using System;
using System.Linq;
using System.Collections.Generic;

class Program {

     
    static void Main(string[] args) {


        string s = Console.ReadLine();
        int num = (int)s.ToCharArray()[0];

        string res = "";
        if (num>=65 && num < 91) {
            res = "A";
        }
        else {
            res = "a";
        }
        Console.WriteLine(res );

    }
}



Measured memory_bytes: 25580
# 符号が同じ 
# -> x <= y なら差分だけ1足すだけ
#    x > y なら差分だけ1足して2回反転
# 符号が違う
# -> x <= yなら絶対値の差分だけ1足して、1回反転
#    x > yなら絶対値の差分だけ1足して、1回反転

import sys
readline = sys.stdin.readline

x,y = map(int,readline().split())

if x * y > 0:
  print(abs(x - y) + (x > y) * 2)
elif x * y < 0:
  print(abs(abs(x) - abs(y)) + 1)
else:
  if x == 0 and y == 0:
    print(0)
  elif x == 0:
    print(abs(y) + (y < 0) * 1)
  else:
    print(abs(x) + (x > 0) * 1)
  
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(i, n) repr((i), 0, (n))
#define repr(i, a, t) reps((i), (a), (t), 1)
#define reps(i, a, t, s) for (long long (i) = (a); (i) < (long long)(t); (i) += (s))
#define rrep(i, n) rrepr((i), (n) - 1, 0)
#define rrepr(i, a, t) rreps((i), (a), (t), 1)
#define rreps(i, a, t, s) for (long long (i) = (a); (i) >= (long long)(t); (i) -= (s))
#define each(v, c) for (auto &&(v) : (c))
using namespace std;
namespace mp = boost::multiprecision;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ml = mp::cpp_int;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;

/**
 * https://ja.wikipedia.org/wiki/クヌース–モリス–プラット法
 * 文字列検索
 */
class KMP {
 private:
  string needle;
  vector<ll> kmp;

 public:
  explicit KMP(const string &needle) : needle(needle), kmp(needle.size() + 2, 0) {
    kmp[0] = -1;
    kmp[1] = 0;
    {
      ll i = 2;
      ll j = 0;
      while (i < needle.size()) {
        if (needle[i - 1] == needle[j]) {
          kmp[i++] = ++j;
        } else if (j > 0) {
          j = kmp[j];
        } else {
          kmp[i++] = 0;
        }
      }
    }
  }

  vector<ll> search(const string &haystack) {
    vector<ll> ret(haystack.size(), false);

    ll m = 0;
    ll i = 0;
    while (m + i < haystack.size()) {
      if (needle[i] == haystack[m + i]) {
        i++;
        if (i == needle.size()) {
          ret[m] = true;
          m += i - kmp[i - 1] - 1;
          if (i >= 0) {
            i = max(0ll, kmp[i - 1]);
          }
        }
      } else {
        m += i - kmp[i];
        if (i > 0) {
          i = kmp[i];
        }
      }
    }
    return ret;
  }

};

ll solve() {

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

  ll ls, lt;
  ls = s.size();
  lt = t.size();

  do {
    s += s;
  } while (s.size() < t.size() * 3);

  ll ret = 0;
  KMP kmp = KMP(t);
  vector<ll> matches = kmp.search(s);
  vector<bool> seen(ls, false);

  ll i = -1;
  while (++i < ls) {
    while (i < matches.size() && !matches[i]) i++;
    if (i > ls) break;
    if (seen[i]) continue;

    ll j = 0;
    while (matches[i + j * lt]) {
      if (i + j * lt < ls) seen[i + j * lt] = true;
      if (j * lt >= ls) return -1;
      j += 1;
    }
    ret = max(ret, j);
  }
  return ret;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ifstream ifs;
  if (getenv("LOCAL") != nullptr) {
    ifs.open("src/_in.txt");
    cin.rdbuf(ifs.rdbuf());
  }

  cout << solve() << endl;

}

Measured memory_bytes: 25232
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>

using namespace std;

struct Edge {
	int to;
	int ticket;
	int cost;
	Edge(int to, int cost, int ticket) : to(to), cost(cost), ticket(ticket) {}
	Edge() {}
};

bool operator < (const Edge &a, const Edge &b)
{
	return (a.cost > b.cost);
}

int main()
{
	int c, n, m, s, d;
	
	while (scanf("%d %d %d %d %d", &c, &n, &m, &s, &d) && c){
		
		vector<Edge> graph[128];
		
		for (int i = 0; i < m; i++){
			int f, t, cost;
			scanf("%d %d %d", &f, &t, &cost);
			graph[--f].push_back(Edge(--t, cost, 0));
			graph[t].push_back(Edge(f, cost, 0));
		}
		
		bool done[16][128];
		memset(done, false, sizeof(done));
		
		priority_queue<Edge> pq;
		
		pq.push(Edge(s - 1, 0, 0));
		
		int ans = -1;
		while (!pq.empty()){
			Edge t = pq.top(); pq.pop();
			
			if (done[t.ticket][t.to]) continue;
			done[t.ticket][t.to] = true;
			
			if (t.to == d - 1){
				if (~ans) ans = min(ans, t.cost);
				else ans = t.cost;
			}
			
			int v = t.to;
			for (int i = 0; i < graph[v].size(); i++){
				pq.push(Edge(graph[v][i].to, t.cost + graph[v][i].cost, t.ticket));
				if (t.ticket < c){
					pq.push(Edge(graph[v][i].to, t.cost + graph[v][i].cost / 2, t.ticket + 1));
				}
			}
		}
		
		printf("%d\n", ans);
	}
	
	return (0);
}

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

long long N, x[200000], X, x_sum[200001] = {};
// x_sum[t] := sum of x in [0, t)

long long E(long long i, long long x){
    if(i == 1){
        return 5 * x;
    }else{
        return (2 * i + 1) * x;
    }
}

int main(){
    cin >> N >> X;
    for(int i = 0; i < N; i++){
        cin >> x[i];
        x_sum[i+1] = x_sum[i] + x[i];
    }
    unsigned long long ans = 4e18;
    for(int k = 1; k <= N; k++){
        unsigned long long ans_k = 0;
        ans_k += N * X + k * X;

        for(int j = 1; j <= (N+k-1)/k; j++){
            int first_idx = N - k * (j - 1);
            int second_idx = max(0LL, N - k * j);
            ans_k += E(j, x_sum[first_idx] - x_sum[second_idx]);
        }
        /*
        for(int i = 1; i <= N; i++){
            ans_k += E((i+k-1)/k, x[N-i]);
            // i = 1, 2, ..., k
            // x[N-1], ..., x[N-k]
            // [N-k, N) = [0, N) \ [0, N-k)
        }
        */
        ans = min (ans, ans_k);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328