akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define INF 1e9
using namespace std;

#define REPR(i, n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

typedef long long ll;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


ll Resolve(ll N) {
    ll st5 = 10;
    ll ans = 0;
    while ((st5 / 2) <= N) {
        ans += N / st5;
        st5 *= 5;
    }

    return ans;
}

int main() {
    ll N;
    cin >> N;
    ll ans = ((N % 2) == 0) ? Resolve(N) : 0;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/

int main()
{
	int a, b, c;

	cin >> a >> b >> c;
	if (a == b) {
		cout << c;
	}
	else if (a == c) {
		cout << b;
	}
	else {
		cout << a;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"yes"<<endl;}else cout<<"no"<<endl;//条件によってYes、Noを出力する
int main(){
    int h,w;
    cin>>h>>w;
    vector<string> s(h);
    rep(i,h){
        cin>>s[i];
    }
    rep(i,h+2){
        if(i==0 || i==h+1){
            rep(j,w+2){
                cout<<"#";
            }
        }
        else{
            cout<<"#"<<s[i-1]<<'#';
        }
        cout<<endl;
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
#define pb push_back
int main(void){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=max(max(a*c,a*d),max(b*c,b*d));
    cout<<ans;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define rrep(i,n) for (int i = (n - 1);i >= 0;i--)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    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 <iostream>

using namespace std;

const string from = "Hoshino";
const string to = "Hoshina";

int main()
{
    int n;

    cin >> n;
    cin.ignore();
    
    while (n--) {
        string inp;

        getline(cin, inp);
        string::size_type pos = 0;
        while (pos = inp.find(from, pos), pos != string::npos) {
            inp.replace(pos, to.length(), to);
            pos += to.length();
        }
        cout << inp << endl;
    }

    return 0;
}

Measured memory_bytes: 1220
program main
 implicit none
 character(len=3) S
 integer :: bus=0

 read *, S

 if ( S(1:1) /= S(2:2) ) bus=1
 if ( S(1:1) /= S(3:3) ) bus=1
 if ( S(2:2) /= S(3:3) ) bus=1

 if (bus==0) print '(A)','No'
 if (bus==1) print '(A)','Yes'

endprogram main


Measured memory_bytes: 768
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;






int main(){
    ll n;
    cin>>n;
    vector<ll> dp1(n,0),dp2(n,0);
    dp1[0]=dp2[0]=1;
    ll ans=(n-1)*(n-1)%MOD;
    if(1>=n-1){ans+=1;}
    else{ans+=2;}
    for(int i=1;i+1<n;i++){
        dp1[i]=dp1[i-1]+(i-3>=0?dp2[i-3]:0);
        dp1[i]%=MOD;
        dp2[i]=dp2[i-1]+dp1[i];
        dp2[i]%=MOD;
        ans+=dp1[i]*(n-1)%MOD*(n-1)%MOD;
        if(i+1==n-1){ans+=dp1[i]*(i+1)%MOD;}
        else{ans+=dp1[i]*(i+2)%MOD;}
        ans%=MOD;
    }
    ans+=((n-1-1>=0?dp1[n-1-1]:0)+(n-1-3>=0?dp2[n-1-3]:0))*n%MOD;
    ans%=MOD;
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 15872
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rr(x,y) read(x);read(y)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
#define pb(x) push_back(x)
#define sss(str) scanf("%s",str+1)
#define ssf(x) scanf("%lf",&x)
#define aLL(x) x.begin(),x.end()
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef double dd;
typedef pair<int,int> pt;
const int N=2e5+5;
const int M=2e3+50;
const int INF=0x7fffffff;
const int mod=1e9+7;
const int sz=18;
const double eps=1e-10;
const double pi=acos(-1);
//***********************
LL n,m;
char str[M];
int f[N];
//***********************
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    LL a,b;
    rrr(n,a,b);
    LL t=n/(a+b);
    LL left=n%(a+b);
    LL ans=t*a+min(left,a);
    cout<<ans<<endl;
    return 0;
}


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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>

using namespace std;

double dist(int d, int y[], int z[]) {
    double dist = 0;
    for(int i = 0; i < d; i++) {
        dist += (y[i] - z[i]) * (y[i] - z[i]);
    }
    return sqrt(dist);
}

int main() {
    ios_base::sync_with_stdio(false);

    int n, d;
    cin >> n >> d;
    int points[n][d];

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < d; j++) {
            cin >> points[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            double dis = dist(d, points[i], points[j]);
            if(dis - (int) dis == 0) ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> void Max(T &m, const T q) { if (m < q) m = q; }
template<typename T> void Min(T &m, const T q) { if (m > q) m = q; }
template<typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N;
lint x;
vector<lint> a, atmp;

int main()
{
    cin >> N >> x;
    a.resize(N);
    cin >> a;

    lint ans = 1E17;
    REP(m, N + 1) // m = 魔法を使う回数
    {
        Min(ans, m * x + accumulate(a.begin(), a.end(), 0LL));
        atmp = a;
        REP(i, N) atmp[i] = min(a[i], a[(i - 1 + N) % N]);
        swap(a, atmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100000
#define INFTY 1000000000

struct Card{
  char suit;
  int value;
};

struct Card L[N], R[N];

void merge(struct Card [], int , int , int );
void mergeSort(struct Card [], int , int ); 
int partition(struct Card [], int , int );
void quickSort(struct Card [], int , int );


int main(){
  
  int n, i, v;
  struct Card A[N], B[N];
  char S[10];
  int stable = 1;
  
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    scanf("%s %d", S, &v);
    A[i].suit = S[0];
    B[i].suit = S[0];
    A[i].value = v;
    B[i].value = v;
  }

  mergeSort(A, 0, n);
  quickSort(B, 0, n-1);

  for ( i = 0; i < n; i++ ){
    if ( A[i].suit != B[i].suit ) {
      stable = 0;
    }
  }

  if ( stable == 1 ) {
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }
  for ( i = 0; i < n; i++ ) {
    printf("%c %d\n", B[i].suit, B[i].value);
  }
  return 0;
}

void merge(struct Card A[], int left, int mid, int right){
  
  int i, j, k, n1, n2;
  
  n1 = mid - left;
  n2 = right - mid;
  
  for(i=0;i<n1;i++){
    L[i] = A[left + i];
  }
  for(i=0;i<n2;i++){
    R[i] = A[mid + i];
  }

  L[n1].value=INFTY;
  R[n2].value=INFTY;
  i=0;
  j=0;
  
  for ( k = left; k < right; k++ ){
    if ( L[i].value <= R[j].value ){
      A[k] = L[i];
      i++;
    }
    else {
      A[k] = R[j];
      j++;
    }
  }
}

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

int partition(struct Card A[], int p, int r){

  int i, j;
  struct Card t, x;

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

void quickSort(struct Card A[], int p, int r){

  int q;
  
  if ( p < r ){
    q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
  }
}

Measured memory_bytes: 2956
#include <bits/stdc++.h>
using namespace std;
string a, b;
int n, m;
int dp[1005][1005];

int main() {
    cin >>n >> m;
   // vector<vector<char>> v(n, vector<char>(m));
    char v[n][m];
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cin >> v[i][j];
        }
    }
    /*for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cout << v[i][j];
        }
        cout << endl;
    }*/
    dp[1][1] = 1;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            if(v[i-1][j-1] == '.') {
                dp[i][j] = max(dp[i][j], ((dp[i-1][j] % 1000000007)+ (dp[i][j-1] % 1000000007)) % 1000000007);
              //  cout << "now" << endl;
            }
            else if(v[i-1][j-1] == '#')dp[i][j] = 0;
        }
    }
   /* for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/
    cout << dp[n][m];
    return 0;
}

Measured memory_bytes: 5120
//AtCoder
//(2368) AGC013B Hamiltonish Path

#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

const int MAXN=100000+10;
vector<int> edge[MAXN];
bool vis[MAXN];
vector<int> path1,path2;
int n,m;

void dfs(int t)
{
	vis[t]=true;
	path1.push_back(t);
	
	for(int i=0;i<edge[t].size();++i)
	{
		if(!vis[edge[t][i]])
		{
			dfs(edge[t][i]);
			return;
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=0;i<m;++i)
	{
		int x,y;
		cin>>x>>y;
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	
	dfs(1);
	swap(path1,path2);
	dfs(1);
	
	cout<<path1.size()+path2.size()-1<<endl;
	for(int i=path2.size()-1;i>=1;--i)
	{
		cout<<path2[i]<<' ';
	}
	for(int i=0;i<path1.size();++i)
	{
		cout<<path1[i]<<' ';
	}
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 9720
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

ll dp[110][100010];

int main(){
    int n, k; cin>>n>>k;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin>>a[i];

    dp[0][0] = 1;
    for(int i=0; i<n; i++){
        vector<ll> sum(k+10, 0);

        for(int j=0; j<=k; j++){
            sum[j+1] = sum[j] + dp[i][j];
        }

        for(int j=0; j<=k; j++){
            dp[i+1][j] += (sum[j+1] - sum[max(0LL, j-a[i])]);
            dp[i+1][j] %= MOD;
        }
    }
    
    cout << dp[n][k] << endl;
}

Measured memory_bytes: 80124
// AOJ ITP1_10_D Distance II
// 2018.4.29 bal4u
 
#include <stdio.h>
#include <math.h>
 
#define gc() getchar_unlocked()
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc();
    while (c >= '0');
    return n;
}
 
int x[102], y[102];
 
int main()
{
    int n, i, t, t2;
    int d, d1, d2;
    long long d3;
     
    n = in();
    for (i = 0; i < n; i++) x[i] = in();
    for (i = 0; i < n; i++) y[i] = in();
    d = 0, d1 = 0, d2 = 0, d3 = 0;
    for (i = 0; i < n; i++) {
        t = x[i] - y[i];
        if (t < 0) t = -t;
        if (t > d) d = t;
        d1 += t;
        t2 = t*t, d2 += t2;
        d3 += t2*t;
    }
    printf("%d\n", d1);
    printf("%.8lf\n", sqrt((double)d2));
    printf("%.8lf\n", pow((double)d3, 1.0/3));
    printf("%d\n", d);
    return 0;
}


Measured memory_bytes: 2132
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    ll n;
    ll k;
    cin >> n >> k;
    int a[n];
    rep(m,n){
        int b;
        cin >> b;
        b--;
        a[m] = b;
    }
    int i=0;
    int key;
    vector<int> path;
    path.push_back(0);
    vector<bool> memo(n,false);
    memo[0] = true;
    while(1){
        if(memo[a[i]]){
            key = a[i];
            break;
        }
        memo[a[i]] = true;
        path.push_back(a[i]);
        i = a[i];
    }
    int start,loop;
    for(int j=0;j<path.size();j++){
        if(path[j]==key){
            start = j;
            loop = path.size()-j;
        }
    }
    if(k<start){
        cout << path[k]+1 << endl;
    }else{
        k -= start;
        k %= loop;
        cout << path[start+k]+1 << endl;
    }
}

Measured memory_bytes: 5128
import java.util.Scanner;
import java.lang.Math;

public class Main
{
  public static void main(String[] args)
  {
  Scanner in=new Scanner(System.in);
  
  while(in.hasNext())
  {
    int a , b , len=1, l;
    
    a=in.nextInt();
    b=in.nextInt();
   
    l=a+b;
    
    if(l==0) System.out.println(len);
    
    else
    {
       len=(int) Math.log10(l)+1;
    
    System.out.println(len);
    }
    
   
  }
      }
    }
 

Measured memory_bytes: 20432
#include <cstdio>
#include <iostream>

using namespace std;

typedef unsigned long long ullong;

ullong d = 1000000007;

ullong power(int m, int n) {
	ullong v = 1;

	if (n > 0) {
		v = power(m, n / 2);
		if (n % 2 == 0) {
			v = (v * v) % d;
		} else {
			v = (((v * v) % d) * m) % d;
		}
	}
	return v;
}

int main() {

	int m, n;
	scanf("%d %d", &m, &n);

	cout << power(m, n) << endl;

	return 0;
}

Measured memory_bytes: 3212
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <map>
// #include <bits/stdc++.h>
using namespace std;

int main()
{
  long long N;
  cin >> N;
  long long min = 10000000000000000;
  long long x;
  for (int i = 0; i < 5; i++){
    cin >> x;
    if (x < min) min = x;
  }

  if (N % min == 0) {
    cout << (N / min + 4) << endl;
  } else {
    cout << (N / min + 5) << endl;
  }

  return 0;
}

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

int main(){
  int x,y,a,b;
  scanf("%d %d",&x,&y);
  if(x<=0 || y>1000000000) exit(1);
  if(x < y){
    a = x;
    x = y;
    y = a;
  }

  b = x%y;
  while(b != 0){
    x = y;
    y = b;
    b = x%y;
  }

  printf("%d\n",y);

  return 0;
}


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

using namespace std;

int main(){
    char s[13];
    scanf("%s", s);
    int ans = 0, cur = 0;
    for (int i = 0; s[i]; i++){
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
            cur++;
        }
        else {
            ans = max(ans, cur);
            cur = 0;
        }
    }
    ans = max (ans, cur);
    printf("%d\n", ans);
    return 0;
}


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

int main() {
	int n;scanf("%d",&n);
	rep(i,n){
		string s,t;cin>>s>>t;
		string ans;
		int back=0;
		for(int j=1;j<=min(s.size(),t.size());j++){
			int d=s[s.size()-j]-'0'+t[t.size()-j]-'0'+back;
			ans=(char)(d%10+'0')+ans;
			back=d/10;
		}
		string u;
		if(s.size()>t.size())u=s;
		else u=t;
		for(int j=min(s.size(),t.size())+1;j<=u.size();j++){
			int d=u[u.size()-j]-'0'+back;
			ans=(char)(d%10+'0')+ans;
			back=d/10;
		}
		if(back)ans='1'+ans;
		if(ans.size()>80)puts("overflow");
		else cout<<ans<<endl;
	}
}

Measured memory_bytes: 3220
def insertion_sort(a_list, n, g):
    cnt = 0
    for i in range(g, n):
        v = a_list[i]
        j = i - g
        while j >= 0 and a_list[j] > v:
            a_list[j + g] = a_list[j]
            j = j - g
            cnt = cnt + 1
        a_list[j + g] = v
    return cnt


n = int(input())
a_list = []
for i in range(0, n):
    a_list.append(int(input()))

cnt = 0
g_list = [1]
g = 1
while g < n:
    g_list.append(g)
    g = 3 * g + 1
g_list = list(reversed(g_list))
m = len(g_list)
cnt = 0
for i in range(0, m):
    cnt = cnt + insertion_sort(a_list, n, g_list[i])

print(m)
print(' '.join(map(str, g_list)))
print(cnt)
for a in a_list:
    print(a)


Measured memory_bytes: 45520
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == "?":
        break
    if op == "+":
        print(a + b)
    elif op =="-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)



Measured memory_bytes: 5592
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cstdlib>
#include <cmath>

using namespace std;

#define rep(i, n)      for (int i=0; i<int(n); i++)
#define rep3(i, s, n)  for (int i=int(s); i<int(n); i++)
#define rev_rep(i, n)  for (int i=int(n)-1; i>=0; i-=1)

string s;
string t;
int dp[4010][4010];
int main() {
  while (cin >> s >> t) {
  int s_len = s.length(), t_len = t.length();
  rep(i, s_len+1) {
    rep(j, t_len+1) {
      dp[i][j] = 0;
    }
  }
  rep(i, s_len) {
    rep(j, t_len) {
      if (s[i] == t[j]) dp[i+1][j+1] = dp[i][j] + 1;
      else              dp[i+1][j+1] = 0;
    }
  }
  int ans = 0;
  rep(i, s_len+1) {
    rep (j, t_len+1) {
      ans = max(ans, dp[i][j]);
    }
  }
  cout << ans << "\n";
  }
  return 0;
}

Measured memory_bytes: 65880
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: String,
    }
    let mut tmp = 0;
    for x in n.chars() {
        tmp+=x.to_digit(10).unwrap();
        // println!("{},{}",x,tmp);
    }
    // println!("{}",tmp);
    if tmp%9!=0 && tmp!=0 {println!("No")}else{println!("Yes")}
    
}


Measured memory_bytes: 2428
#include<iostream>
#include<vector>
using ll =  long long;

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

using namespace std;

int main(){

    int x;
    cin >> x;
    for(int a=1; a<1000; ++a){
        ll a5=1;
        rep(i,5) a5*=a;
        for(int b=-1000; b<1000; b++){
            ll b5=1;
            rep(i,5) b5*=b;
            if(a5-b5==x){
                printf("%d %d\n", a, b);
                return 0;
            }
        }
    }

}

Measured memory_bytes: 3724
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ld a;
    ld b;
    ld x;
    cin>>a>>b>>x;
    x=x/a;
    ld be = 0.0;
    ld en = pi/2.0;
    ld E = 1.0e-10;
    ld ans = pi/2.0;
    while((en-be)>E)
    {
        ld mid  = (be+en)/2.0;
        ld lefth = b*sin(mid);
        ld righth = a*cos(mid);
        if((lefth-righth)>E)
        {
            ld vol = b*a;
            vol -= (a*a*0.5/tan(mid));
//            vol = vol*(a*1.0/sin(mid));
            if(vol>=x)
            {
                ans = mid;
                en = mid;
            }
            else
            {
                be = mid;
            }
        }
        else if(abs(righth-lefth)<=E)
        {
            ld vol = (a*b*0.5);
            if(vol >= x)
            {
                ans = mid;
                en=mid;
            }
            else
            {
                be = mid;
            }
        }
        else
        {
            ld vol = b*b*tan(mid)*0.5;
            if(vol>=x)
            {
                ans = mid;
                en=mid;
            }
            else
            {
                be=mid;
            }
        }
    }
    ans = (be+en)/2.0;
    ans = (ans*(180.0)/pi);
//    ld vol = a*a*b;
//    ld temp = 2.0*x;
//    ld ans;
//    if(temp >= vol)
//    {
//        ld exp = (a*a*a);
//        exp /= (a*a*b-x);
//        exp /= 2.0;
//        ans = atan(exp);
//    }
//    else
//    {
//        ld exp = (2.0*x/(a*b*b));
//        ans = atan(exp);
//    }
//    ans = (180.0*ans/pi);
    ans = (90.0-ans);
    cout<<fixed<<setprecision(10)<<ans;
    return 0;
}































Measured memory_bytes: 512
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    s = str(input().rstrip('\n'))
    if s == "Sunny":
        print("Cloudy")
    elif s == "Cloudy":
        print("Rainy")
    elif s == "Rainy":
        print("Sunny")


if __name__ == '__main__':
    solve()


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

int main () {

  int a , b , res;

  char op;

  while(1) {

    cin >> a >> op >> b;

    if ( op == '?') break;

    if ( op == '+') {

      res = a + b;

      cout << res << "\n" ;

    }

    if ( op == '-') {

      res = a - b;

      cout << res << "\n" ;

    }

    if ( op == '*') {

      res = a * b;

      cout << res << "\n";

    }

    if ( op == '/') {

      res = a / b;

      cout << res << "\n";

    }

  }

  return 0;

}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll, int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 100005;

struct query{
	int i, l, r, ans;
};

void solve(){
	int n,qq;
	cin >> n >> qq;
	vector<int> a(n), see(n+1);
	vector<query> q(qq);
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < qq; i++){
		cin >> q[i].l >> q[i].r;
		q[i].i = i;
		q[i].l--, q[i].r--;
	}
	int len = sqrt(n) + 1;
	sort(q.begin(), q.end(), [&len](query &a, query &b){
		if(a.l/len != b.l/len)
			return a.l/len < b.l/len;
		return a.r < b.r;
	});
	int l = 0, r = -1, cnt = 0;
	for(auto &q:q){
		while(l < q.l){
			see[a[l]]--;
			if(see[a[l]] == 0)cnt--;
			l++;
		}
		while(l > q.l){
			l--;
			if(see[a[l]] == 0)cnt++;
			see[a[l]]++;
		}
		while(r < q.r){
			r++;
			if(see[a[r]] == 0)cnt++;
			see[a[r]]++;
		}
		while(r > q.r){
			see[a[r]]--;
			if(see[a[r]] == 0)cnt--;
			r--;
		}
		q.ans = cnt;
	}
	sort(q.begin(), q.end(), [](query &a, query &b){
		return a.i < b.i;
	});
	for(int i = 0; i < qq; i++)
		cout << q[i].ans << '\n';
}

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


Measured memory_bytes: 15356
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		int[] K = new int[N];
		int[][] A = new int[N][M];
		int[] food = new int[M + 1];
		
		for(int i = 0; i < N; i++) {
			K[i] = sc.nextInt();
			for(int j = 0; j < K[i]; j++) {
				A[i][j] = sc.nextInt();
				for(int k = 1; k <= M; k++) {
					if(A[i][j] == k) {
						food[k]++;
					}
				}				
			}			
		}
		
		int sum = 0;
		
		for(int i = 1; i <= M; i++) {
			if(food[i] == N) {
				sum++;
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 22484
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<map>
#include<functional>
using namespace std;
typedef long long int llint;
typedef bool izryt;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const int big=1e9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <typename T>
class seg_tree{
public:
	T treemax,treemin,lazyplus;
	int seghi,segmg;
	seg_tree *left;
	seg_tree *right;
	seg_tree(int hi,int mg){
		treemax=0;treemin=0;lazyplus=0;
		seghi=hi;segmg=mg;
		left=NULL;right=NULL;
		int tyu=(hi+mg)/2;
		if(hi+1<mg){make_left(hi,tyu);make_right(tyu,mg);}
	}
	~seg_tree(){delete left;delete right;}
	void make_left(int hi,int mg){if(this->left!=NULL){cout<<"ばぐ"<<endl;throw(1);}this->left=new seg_tree(hi,mg);}
	void make_right(int hi,int mg){if(this->right!=NULL){cout<<"ばぐ"<<endl;throw(1);}this->right=new seg_tree(hi,mg);}
	void seg_plus(int hi,int mg,T val){//区間加算クエリ
	//timecount++;//計算量
		if(hi<=seghi&&segmg<=mg){lazyplus+=val;return;}
		if(mg<=seghi||segmg<=hi){return;}
		left->seg_plus(hi,mg,val);
		right->seg_plus(hi,mg,val);
		treemin=min(left->treemin+left->lazyplus,right->treemin+right->lazyplus);
		treemax=max(left->treemax+left->lazyplus,right->treemax+right->lazyplus);
		return;
	}
	/*T ask_min(int hi,int mg){//区間(hi,mg]について,最小を返す
		//timecount++;//計算量
		if(hi<=seghi&&segmg<=mg){return treemin+lazyplus;}
		if(mg<=seghi||segmg<=hi){return big;}
		T leret,riret;
		if(right!=NULL&&left!=NULL&&lazyplus!=0){
			right->lazyplus+=this->lazyplus;
			left->lazyplus+=this->lazyplus;
			treemax+=lazyplus;
			treemin+=lazyplus;
			lazyplus=0;
		}
		leret=left->ask_min(hi,mg);
		riret=right->ask_min(hi,mg);
		return min(leret,riret);
	}*/
	T ask_max(int hi,int mg){
		//timecount++;//計算量
		if(hi<=seghi&&segmg<=mg){return treemax+lazyplus;}
		if(mg<=seghi||segmg<=hi){return -big;}
		T leret,riret;
		if(right!=NULL&&left!=NULL&&lazyplus!=0){
			right->lazyplus+=this->lazyplus;
			left->lazyplus+=this->lazyplus;
			treemax+=lazyplus;
			treemin+=lazyplus;
			lazyplus=0;
		}
		leret=left->ask_max(hi,mg);
		riret=right->ask_max(hi,mg);
		return max(leret,riret);
	}
};
const int mod=1e9+7;
//実装にかかった。
int main(void){
	int i,j,n,m,q,w,ans=0;
	cin>>n>>m;
	maxeq(ans,n-m);
	vector<pair<int,int>>taka(n);
	seg_tree<int> isu(0,m+2);
	for(i=0;i<n;i++){cin>>q>>w;taka[i]=mp(q,w);}
	sort(taka.begin(),taka.end());
	for(i=0;i<m+2;i++){isu.seg_plus(i,i+1,i-m-1);}
	//ans=maxeq(ans,高橋君の数-椅子の数)
	//この↑高橋君は椅子の集合以外に座れない
	for(i=0;i<n;i++){
		isu.seg_plus(0,taka[i].sec+1,1);
		int nowisu=isu.ask_max(0,m+2)-taka[i].fir;
		//cout<<"nowisu="<<nowisu<<endl;
		//for(j=0;j<m+2;j++){cout<<i<<" "<<j<<" "<<isu.ask_max(j,j+1)<<endl;}
		maxeq(ans,nowisu);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 20608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    int n;
    cin >> n;
    vector <string> t(n);
    rep(i,n){
        string s;
        cin >> s;
        sort(all(s));
        t[i] = s;
    }

    map <char,int> table;
    for(char i='a'; i <='z'; i++){
        int cnti = count(all(t[0]),i);
        for(int j=0; j < n; j++){
            int cnt = count(all(t[j]),i);
            if(cnt < cnti){
                cnti = cnt;
            }
        }
        table[i] = cnti;
    }

    string ans = "";

    for(char i = 'a' ;  i <= 'z'; i++){
        if(table.at(i) >= 1){
            for(int j=0; j<table.at(i); j++){
                ans.push_back(i);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool arr[1000002];
vector<int>vec,vec2;
void sieve()
{
    arr[1]=1;
    arr[0]=1;
    for(int i=4;i<=1000000;i+=2)
        arr[i]=1;
    for(int j=3;j*j<=1000000;j+=2)
    {
        if(arr[j]==0)
        {
            for(int k=j*j;k<=1000000;k+=j)
            {
                arr[k]=1;
            }
        }
    }
    for(int j=2;j<=1000000;j++)
    {
        if(arr[j]==0)
        {
           vec.push_back(j);
        }
 
    }
 
 
 
 
}
int main()
{
    sieve();
    int a,b,c,d,f,i,j;
    cin >> b;
    cin >> c;
    b--;
    d=c;
    map<int,int>mp;
    vec2.push_back(d);
    while(b--)
    {
        cin >> c;
        d=__gcd(c,d);
        vec2.push_back(c);
    }
    int e=0;
    for(i=0;i<vec2.size();i++)
    {
        int l=vec2[i];
        for(j=0;j<vec.size() && vec[j]<=l;j++)
        {
            if(arr[vec2[i]]==0)
            {
                mp[vec2[i]]++;
                e=max(e,mp[vec2[i]]);
                break;
            }
            else if(vec2[i]%vec[j]==0)
            {
                while(vec2[i]%vec[j]==0)
                {
                    vec2[i]/=vec[j];
 
                }
                mp[vec[j]]++;
                e=max(e,mp[vec[j]]);
            }
             if(vec2[i]==1)
            {
                break;
            }
        }
 
 
    }
    if(d==1)
    {
        if(e>1)
        {
            cout << "setwise coprime" << endl;
        }
        else{
            cout << "pairwise coprime" << endl;
        }
 
    }
    else{
        cout << "not coprime" << endl;
    }
 
 
 
 
}
 

Measured memory_bytes: 11876
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	var n int64
	fmt.Scan(&n)

	ab := int64((1 << 63)-1)
	
	for i := int64(1); i*i <= n; i++ {
		if n%i == 0 && ab>i+n/i {
			ab = i+n/i
		}
	}

	fmt.Println(ab-2)

}


Measured memory_bytes: 640
/*
    title: e_multiplication_4.cpp
    author: Akhil
    date: 2020-09-19
    time: 10:16:50
*/
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <climits>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <numeric>
#include <cmath>
#include <stdio.h>

using namespace std;

long long mod = 1e9 + 7;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<long long> neg, pos;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        if (x >= 0)
            pos.push_back(x);
        else
            neg.push_back(x);
    }
    if (k == n)
    {
        long long ans = 1;
        for (int i = 0; i < neg.size(); i++)
            ans = (ans * neg[i]) % mod;
        for (int i = 0; i < pos.size(); i++)
            ans = (ans * pos[i]) % mod;
        cout << (ans + mod) % mod << endl;
        return 0;
    }
    if (pos.size() == 0 and (k & 1))
    {
        sort(neg.rbegin(), neg.rend());
        long long ans = 1;
        for (int i = 0; i < k; i++)
        {
            ans = (ans * neg[i]) % mod;
        }
        cout << (ans + mod) % mod << endl;
        return 0;
    }
    sort(pos.rbegin(), pos.rend());
    sort(neg.begin(), neg.end());
    int i = 0, j = 0;
    long long ans = 1;
    while (k > 0)
    {
        long long t1 = -1, t2 = -1;
        if (i < (int) pos.size() - 1) t1 = pos[i] * pos[i + 1];
        if (j < (int) neg.size() - 1) t2 = neg[j] * neg[j + 1];
        if (k == 1 or t1 > t2)
            ans = (ans * pos[i]) % mod, i++, k--;
        else
        {
            ans = (ans * neg[j]) % mod, ans = (ans * neg[j + 1]) % mod;
            j += 2, k -= 2;
        }
    }
    cout << (ans + mod) % mod << endl;
    return 0;
}

Measured memory_bytes: 5476
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  if (((A+B)-(C+D))>0)
	cout<<"Left"<<endl;
  else if (((A+B)-(C+D))<0)
	cout<<"Right"<<endl;
  if (((A+B)-(C+D))==0)
	cout<<"Balanced"<<endl;

}

Measured memory_bytes: 256
import itertools
n, m, q = map(int, input().split())
params = []
for _ in range(q):
    a1, a2, a3, a4 = map(int, input().split())
    params.append([a1, a2, a3, a4])

high_score = 0
for x in itertools.combinations_with_replacement(range(1, m + 1), n):
    score = 0
    for a, b, c, d in params:
        if x[b - 1] - x[a - 1] == c:
            score += d
    high_score = max(high_score, score)

print(high_score)

Measured memory_bytes: 9208
#include <iostream>

using namespace std;

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

    bool flag = true;

    if (n <= 6 && n % 4 != 0){
        flag = false;
    }
    if (n == 9 || n == 10 || n == 13 || n == 17){
        flag = false;
    }
    
    if (flag == false){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
#      .      '                    Udit Gupta @luctivud         ,              
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                            ##     ##  #######  # #  ######
                            ##     ##  ##   ##  ###    ##
                            ##     ##  ##    #  # #    ##
                            #########  #######  # #    ##
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import sys
import math as mt
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))

def printwsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end="tst, ")

MOD = int(1e9+7); BABYMOD = 998244353;
# ################################ HELPER PROGRAMS USED ###################################
# ################################## MAIN STARTS HERE #####################################
# for _testcases_ in range(int(input())):
a, b, c, k = get_ints()
ans = 0
ans += min(a, k)
k = k - ans
k = max(0, k-b)
ans -= min(k, c)
print(ans)

# #########################################################################################
'''
THE LOGIC AND APPROACH IS BY ME @luctivud.
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
: DO NOT PLAGIARISE.
'''

Measured memory_bytes: 62056
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
using namespace std;

int main(){
    int n;cin>>n;
    int x[n],y[n],h[n],flag;

    rep(i,n){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i]>=1) flag=i;
        
    }

    for(int px=0;px<=100;px++){
        for(int py=0;py<=100;py++){
            int H= h[flag]+abs(px-x[flag])+abs(py-y[flag]);
            bool ok = true;
            for(int i=0;i<n;i++){
                if(h[i] != max(H-abs(x[i]-px)-abs(y[i]-py),0)) ok=false;
            }
            if (ok){
                cout << px <<" " << py << " " << H << endl;
                return 0;
            }
        }
    }

    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
typedef vector<long long> vi;
typedef pair<long long,long long> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pai
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define loop(i, len) for (long long i = 0; i < len; ++i)
#define loopr(i, len) for (long long i = len; i >=0; --i)

#define LOCAL 0

bool myfunc(char ch1, char ch2) {
    return ch1<ch2;
}
ll A[1000001],k;
bool valid(ll x,ll i)
{
    ll z=1;
    for (ll j = i; j <=x ; ++j) {
        z*=A[j];
        if(z>A[i])return false;
        else return true;
    }

}
ll bs(ll a,ll d,ll i)
{
    ll l=a,r=d,ans=-1;
    while(l<=r)
    {
        ll mid=(l+r)/2;
        if(valid(mid,i))ans=mid,l=mid+1;
        else r=mid-1;
    }
    return ans;
}





int main() {
    ll t;
    ll n,k;
    cin>>n>>k;
    cout<<((k>=n)?"unsafe":"safe");
}







Measured memory_bytes: 3636
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

N, K, Q = MI()
A = [K - Q] * N

for i in range(Q):
    A_i = INT()
    A[A_i - 1] += 1
    
for a in A:
    print("Yes" if a > 0 else "No")

Measured memory_bytes: 76492
a,b,k = map(int, input().split( ))

for i in range(k):
    if i%2 == 0:
        if a%2 != 0:
            a -=1
        b = b+(a//2)
        a = a//2
    else:
        if b%2 != 0:
            b -=1
        a = a+(b//2)
        b = b//2
print(a, b)


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;


public class Main {
	 static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	       
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreTokens()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken();
	            
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        }

			public Character charAt(int i) {
				// TODO Auto-generated method stub
				return null;
			} 
	    } 
	
	public static void main(String[] args)throws IOException  {
		FastReader s=new FastReader();		
		int n = s.nextInt();
		int[] ar = new int[n];
		
		for(int i=0;i<n;i++) {
			ar[i] =  s.nextInt();
		}
		int flag=0;
		Arrays.sort(ar);
		for(int i=0;i<n-1 && flag==0;i++) {
			if(ar[i]==ar[i+1] && ar[i]!=0) {
				System.out.println("NO");
				flag=1;
				
			}
			
		}
		if(flag==0)System.out.println("YES");
		
		
	}
}

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

int main(){
    int n,c; cin >> n >> c;
    int d[c][c];
    int c0[n][n];
    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++){
            cin >> c0[i][j];
            c0[i][j]--;
        }
    }
    int dmod3[3][c];
    for(int i=0;i<3;i++){
        for(int j=0;j<c;j++){
            dmod3[i][j] = 0;
        }
    }
    for(int l=0;l<c;l++){
        for (int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                dmod3[(i+j)%3][l] += d[c0[i][j]][l];
            }
        }
    }
    int res = 10000000000;
    for(int i=0;i<c;i++){
        for(int j=0;j<c;j++){
            for(int l=0;l<c;l++){
                if(i!=j && j!=l && l!=i){
                    res = min(res,dmod3[0][i]+dmod3[1][j]+dmod3[2][l]);
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI (acos(-1))
#define _GLIBCXX_DEBUG

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

  vector<int> v(n);
  rep(i, n) cin >> v[i];

  sort(v.begin(), v.end(), greater<int>());

  int ans = 0, current = 255;
  for(int i : v){
    if(i != current){
      ans++;
      current = i;
    } 
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
using in = int64_t;

int main(){
in a, b, r, x, tmp;
 cin>>a>>b;
 
  x = a * b;
 
 
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  
cout<<x/b;

}


Measured memory_bytes: 256
/*
*
*   Bismillah Hir Rahman Nir Raheem
*   Name: Jaied Al Sabid
*
*/

#include <iostream>
#include <string>
#include <bits/stdc++.h>

using namespace std;

#define pf printf
#define sf scanf
#define elf else if
#define Size 100

int main()
{
    int x,y;

    sf("%d%d",&x,&y);

    pf("%d\n",(6-(x+y)));

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <numeric>
 
using namespace std;
typedef long long ll;

int f(vector<int> &a, const string &s, int N, int C){
  int l=-C-10;
  for(int i=0;i<N;i++){
    if(s[i]=='o' & l+C<i){
      l=i; a[i]=1;
    }
  }
  return 0;
}


int main(){
  int N,K,C;
  cin >> N >> K >> C;
  string s;
  cin >> s;
  vector<int> a(N,0);
  vector<int> b(N,0);

  f(a,s,N,C);
  int sum;
  sum=accumulate(a.begin(),a.end(),0);
  if(K<sum){
    cout << endl;
    return 0;
  }
  reverse(s.begin(),s.end());
  f(b,s,N,C);
  reverse(b.begin(),b.end());
  for(int i=0;i<N;i++){
    if(a[i]==1 & b[i]==1){
      cout << i+1 << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3332
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
int n,q,l,r,a[100010];
string s;
int main(){
	cin>>n>>q>>s;
	for (int i=1;i<n;i++){
		a[i+1]=a[i];
		if (s[i-1]=='A'&&s[i]=='C') a[i+1]+=1;
	}
	for (int i=0;i<q;i++){
		cin>>l>>r;
		cout<<a[r]-a[l]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1408