akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;

int main() {
    int N, M;
    cin >> N >> M;
    rep(i,M){
        int d;
        cin >> d;
        N -= d;
    }

    if(N<0)
        cout << -1;
    else
        cout << N;
    cout << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
using namespace std;
//
const int inf=1e9+7;//0x3f
//
int main(){
	int N,X;
	cin>>N>>X;
	if(N==2){
		if(X!=2){
			cout<<"No"<<endl;
		}else{
			cout<<"Yes"<<endl;
			cout<<1<<endl;
			cout<<2<<endl;
			cout<<3<<endl;
		}
	}else if(X==1||X==2*N-1){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
		int A[300000];
		if(X-2>=1){
			A[N-2]=X-2;
			A[N-1]=X;
			A[N]=X+1;
			A[N+1]=X-1;
			vector<int> V;
			for(int i=1;i<=2*N-1;i++){
				if(i<X-2||X+1<i){
					V.push_back(i);
				}
			}
			for(int i=0;i<2*N-1;i++){
				if(i<N-2||N+1<i){
					A[i]=V.back();
					V.pop_back();
				}
			}
		}else{
			A[N-2]=X+1;
			A[N-1]=X;
			A[N]=X-1;
			A[N+1]=X+2;
			vector<int> V;
			for(int i=1;i<=2*N-1;i++){
				if(i<X-1||X+2<i){
					V.push_back(i);
				}
			}
			for(int i=0;i<2*N-1;i++){
				if(i<N-2||N+1<i){
					A[i]=V.back();
					V.pop_back();
				}
			}
		}
		for(int i=0;i<2*N-1;i++){
			cout<<A[i]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2404
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
int main() {
    int n;cin >> n;
    vi h(n);rep(i, n) cin >> h[i];
    int count = 0;
    rep(q, 10000) {
        int i = 0;
        while(h[i]==0) {
            i++;
            if(i == n) {
                cout << count  << endl;
                return 0;
            }
        }
        while(h[i]!=0) {
            h[i]--;
            i++;
            if(i==n) break;
        }
        count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define cl clear
#define in insert
#define er erase
#define S second
#define F first
#define endl "\n" 
#define all(v) (v).begin(), (v).end()
#define getbit(x, i) ((x >> i)&1)
#define sz(v) (v).size()
#define fr(i, a, b, d) for(ll i = a; i < b; i+= d)
#define frr(i, a, b, d) for(ll i = a; i >= b; i -= d)
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define pll pair < ll, ll >
#define pii pair < int, int >
#define trace1(x)                cerr << #x << ": " << x << "\n";
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << "\n";
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << "\n";
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << "\n";
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << "\n";
using namespace std;
const ll N = 200005;
const ll M = 1e9 + 7;
ll A[N], F[N];
ll n, k;
bool check(ll x){
	ll sum = 0;
	for(ll i = 0; i < n; i++) sum += max(0LL, A[i] - x/F[i]);
	return sum <= k;	
}
int main(){
	fastio;
	cin >> n >> k;
	for(ll i = 0; i < n; i++) cin >> A[i];
	for(ll i = 0; i < n; i++) cin >> F[i];
	sort(A, A + n);
	sort(F, F + n, greater<ll>());
	ll low = 0, high = 1e12;
	while(high - low > 1){
		ll mid = (low + high)/2;
		if(check(mid)) high = mid;
		else low = mid;
	}
	if(check(low)) cout << low;
	else cout << high;
	return 0;
}


Measured memory_bytes: 3328
from math import sqrt
from itertools import accumulate

L = [0 for _ in range(10**5)]
check = [1 for _ in range(10**5)]
check[0],check[1] = 0,0
for i in range(2,10**5):
  if check[i]:
    for j in range(i**2,10**5,i):
      check[j] = 0

for i in range(3,10**5,2):
  if check[i] == 1 and check[((i+1)//2)] == 1:
    L[i] = 1

Q = int(input())
lr = [list(map(int,input().split())) for _ in range(Q)]
ans = list(accumulate(L))
for l,r in lr:
  print(ans[r]-ans[l-1]) 

Measured memory_bytes: 32812
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<n;i++)
int main()
{
    int n,k;
    cin >> n >> k;
    bool num[10]; int dlike[k];
    rep(i,k) cin >> dlike[i];
    rep(i,10) num[i] = false;
    rep(i,k){
        num[dlike[i]] = true;
    }

    int a = n;
    while(1){
        int dig = floor(log10(a)) + 1;
        bool flag = false;
        for(int i = 1;i<pow(10,dig);i = i*10){
            if (num[(a%(i * 10))/i]){
                a += 1; flag = true; break;
            }
        }
        
        if (flag) continue;
        cout << a << endl;
        break;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
long long num[200005];
using namespace std;
long long ans;
int main(){
	long long a;
	scanf("%lld" , &a);
	for(long long i = 1 ;i <= a ; i++)	scanf("%lld" , &num[i]);
	long long anext = 1;
	long long xorr = 0 , plu = 0;
	for(long long i = 1 ; i <= a; i++){
		while(xorr == plu and anext <= a){
			xorr ^= num[anext];
			plu += num[anext];
			if(xorr == plu)	anext++;
			else{
				xorr ^= num[anext];
				plu -= num[anext];
				break;
			}
			if(anext > a)	break;
		}
		ans += anext - i;
		xorr ^= num[i];
		plu -= num[i];
	}
	cout << ans;
	return 0;
} 


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

using namespace std;

typedef long long  ll;

#define SIZ 1000000000
#define mod 10000007

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll n;
	cin >> n;
	
	unordered_map<ll, ll> mp;
	for(ll i = 1; i <= 100; i++){
		for(ll j = 1; j <= 100; j++){
			for(ll k = 1; k <= 100; k++){
				ll z = i*i + j*j + k*k + i*j + j*k + i*k;
				if(!mp.count(z)) mp[z] = 1;
				else mp[z]++;
				
				if(z >= 10004){
					break;
				}
			}
		}
	}
	
	ll cnt = 0;
	for(ll i = 1; i <= n; i++){
		if(mp.count(i)) cout << mp[i] << "\n";
		else cout << 0 << "\n";
	}
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
  string data;
  cin>>n>>data;
  int count=0;
  
  for(int i=0;i<n-2;i++){
  	if(data[i]=='A'){
    
    if(data[i+1]=='B' && data[i+2]=='C'){
    count++;
      i+=2;
    }
    }
  
  }
  cout<<count<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<"[@"<<__LINE__<<"] "<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T>inline int bs(int g,int k,T c){while(abs(k-g)>1){int m=(g+k)/2;(c(m)?k:g)=m;}return k;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}
template<typename T> istream& operator>>(istream& s,vector<T>& v){for(T& x:v)s>>x;return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    int r; cin >> r;
    cout << 2*r*pi << '\n';

    
    
    
    return 0;
}


Measured memory_bytes: 3796
#include <stdio.h>

int main (void){

  int i, k, j;
  int m;
  int height[10];

  for(i=0; i<10; i++){
    scanf("%d",&height[i]);
  } 



for(j=0; j<3; j++){  
    m=height[0];
  for(i=0; i<10; i++){

      if(m<height[i]){

        m=height[i];
        k=i;
        }
      }   height[k]=0;
      printf("%d\n",m);
    }

  
    return 0;

}

Measured memory_bytes: 600
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

long long a, b, c;

int main() { 

  cin >> a >> b >> c;

  long long diff = c - a - b;
  if (diff <= 0) {
    cout << "No" << endl;
    return 0;
  }

  long long sqDiff = 1ll * diff * diff;
  long long ab = 4ll * a * b;

  if (ab < sqDiff) {
    puts("Yes");
  } else {
    puts("No");
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>

#define N_MAX 100000

using namespace std;

int main(){
    int N, K;
    int a[N_MAX];
    int index;
    int ans;
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    ans = ceil((double)(N - K)/(double)(K - 1)) + 1;
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair  <int,int> ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef set   <int>     si;
typedef set   <ii>      sii;
typedef vi::iterator itt;
typedef si::iterator jtt;

#define fori(i,x) for(itt i=x.begin();i!=x.end();i++)
#define forj(j,x) for(jtt j=x.begin();j!=x.end();j++)
#define all(x)   x.begin(), x.end()
#define clr(x,v) memset(x,v,sizeof(x))

#define _ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#define pb push_back
#define endl "\n"
#define MOD int(1e9+7)
#define N 200123
ll a,b,c, n, k, ans;
int main(){_
    cin >> n >> k;
    while(k<=n+1){
        a=(k*(k-1))/2;
        c=n-k;
        b=(n*(n+1)-c*(c+1))/2;
        ans+=(b-a+1);
        ans%=MOD;
        //cout << a << " " << b << endl;
        k++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	vector<int> v{ a, b, c };
	sort(v.begin(), v.end());
	swap(v[1], v[2]);

	int ab = v[1] - v[0];
	int bc = v[1] - v[2];

	int ans = 0;

	if (ab > bc)
	{
		int tmp = ab - bc;
		ans += bc;

		if (tmp % 2 == 0)
		{
			ans += tmp / 2;
		}
		else
		{
			ans++;
			ans += (tmp + 1) / 2;
		}
	}
	else
	{
		int tmp = bc - ab;
		ans += ab;

		if (tmp % 2 == 0)
		{
			ans += tmp / 2;
		}
		else
		{
			ans += (tmp + 1) / 2;
		}
	}

	cout << ans << endl;

	return 0;
}

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


void solve(std::string S){
    int size = S.size();
    for(int i=0;i<size;i++){
        S[i] = 'x';
    }
    cout << S << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#constraint 2 <= K <= N <= 50
N,K = map(int,input().split())
locations = [tuple(map(int,input().split())) for _ in range(N)]
## sort by x coordinate
locations.sort()
## search for [i,j] for i-j>= K-1 (* N^2), remenber delta x (i+K) < N
## copy slice locations[i:j+1] and sort by y  (*(N+ NlogN) = * NlogN)
## search for slice, [k,l] where k - l - 1 == K , remenber delta y, calclate delta x * delta y (*N)
## total it should cost O(N^4 * logN), which is 625*1000 * log50 ~ 7*10^6... Python might TLEs?
# print(locations)
minimalArea = (10**18)*5
for i in range(N-K+1):
    for j in range(i+K-1,N):
        deltaX = locations[j][0] - locations[i][0]
        sliced = locations[i:j+1]
        sliced.sort(key= lambda p: p[1])
        # print(sliced)
        length = j-i+1
        if length < K:
            continue
        for k in range(length-K+1):
            deltaY = sliced[k + K - 1][1] - sliced[k][1]
            area = deltaX * deltaY
            # print(deltaX,deltaY,area)
            # if area == 0: continue
            minimalArea = min(area,minimalArea)
print(minimalArea)

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

#define PI 3.141592653589
#define ll long long int
#define ld long double
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vv vector
int MOD=1e9+7;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
ll min(ll a,ll b){return (a>b)?b:a;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime[1000001];
vi primes;
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for(int p=2;p<1000001;p++)
        if(prime[p])
            primes.pb(p);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int t=1;
	//cin>>t;
	//SieveOfEratosthenes(1000000);
    while(t--){
        int n,k;
        cin>>n>>k;
        int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        int dp[n];
        for(int i=0;i<n;i++)
            dp[i]=INT_MAX;
        dp[0]=0;
        for(int i=0;i<n;i++){
            for(int j=1;j<=k&&i+j<n;j++){
                dp[i+j]=min(dp[i+j],dp[i]+abs(a[i+j]-a[i]));
            }
        }
        cout<<dp[n-1];
    }
}

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

typedef long long ll;
typedef vector< pair<ll , ll > > vll;

ll bigmod(ll b, ll p)
{
	if(p==0)
	{
		return 1;
	}
	ll x = bigmod(b , p/2);
	x= (x*x);
	if(p&1)
	x = x*b;
	return x;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m, k;
	cin>>n>>m>>k;
	ll tm;
	cin>>tm;
	ll tmp = max( n ,max(m, k));
	ll sum = tmp;
	while(tm)
	{
		sum = sum*2;
		tm--;
	}
	 sum = sum + n+ m + k - tmp;
	cout<<sum<<endl;
	
	return 0;
}


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

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strArray = Console.ReadLine().Split(' ').ToArray();
            string A = strArray[0];
            string B = strArray[1];
            string C = strArray[2];
            Console.WriteLine(C + " " + A  + " " + B);
        }
    }
}

//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 26120
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;

pair<int, int> p[60];
int ans[2510], beg[60]={};

int main() {
	int N, K;
	cin >> N >> K;
	int sum=0, opb=(N-1)*(K+1)+1;
	for(int i=0; i<N; ++i){
		cin >> p[i].first;
		p[i].second=i+1;
		sum += max(0, K+1-p[i].first);
	}
	sort(p, p+N);
	if(sum>K || p[0].first<K+1-(K+1)/2){
		cout << -1 << endl;
		return 0;
	}
	int num=0;
	for(int i=0; i<N; ++i){
		if(p[i].first<K+1){
			for(int j=0; j+p[i].first<K+1; ++j){
				beg[num]=p[i].second;
				if(num+2>=K) num=1;
				else num += 2;
			}
		}
		else break;
	}
	for(int i=0; i<K; ++i){
		if(beg[i]==0){
			while(1){
				++beg[i];
				if(i>0){
					if(beg[i-1]==beg[i]) continue;
				}
				if(i+1<K){
					if(beg[i+1]==beg[i]) continue;
				}
				break;
			}
		}
	}
	int a=0, b=beg[0], now=0;
	for(int i=0; i<opb; ++i){
		if(i%(N-1)==0 && i>0 && i<opb-1){
			ans[i]=b;
			a=b;
			b=beg[i/(N-1)];
			now=0;
		}
		else{
			do{
				++now;
			}while(now==a || now==b);
			ans[i]=now;
		}
	}
	cout << opb << endl;
	cout << ans[0];
	for(int i=1; i<opb; ++i) cout << ' ' << ans[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
char t1[1000];
char t2[100];
char t3[100];
int main(){
    int n;
    int a,b;
    int i,j;
    char t;
    scanf("%s",&t1);
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s",&t3);
        if(strcmp(t3,"replace")==0){
            scanf("%d %d %s",&a,&b,&t2);
            for(j=0;j<b-a+1;j++){
                t1[a+j]=t2[j];
            }
        }
        else if(strcmp(t3,"reverse")==0){
            scanf("%d %d",&a,&b);
            for(;a<b;){
                t=t1[a];
                t1[a]=t1[b];
                t1[b]=t;
                a++;
                b--;
            }
        }
        else if(strcmp(t3,"print")==0){
            scanf("%d %d",&a,&b);
            for(j=a;j<b+1;j++){
                printf("%c",t1[j]);
            }
             printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>
#include <vector>
#include <string.h>

#pragma warning(disable:4996)
#define MAX_N 250

int H[MAX_N];
int main(void) {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &H[i]);
	}
	for (int i = 0; i < n; ++i) {
		printf("node %d: key = %d, ", i+1, H[i]);
		if ((i + 1) / 2 - 1 >= 0) {
			printf("parent key = %d, ", H[(i + 1) / 2 - 1]);
		}
		if (2 * (i+1)-1 < n) {
			printf("left key = %d, ", H[2*(i+1)-1]);
		}
		if (2 * (i + 1) < n) {
			printf("right key = %d, ", H[2 * (i + 1)]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2680
#include<iostream>
#include<algorithm>
#include<map>
#include<cstdio>
#define ll long long
#define lson (rt<< 1)
#define rson (rt<< 1 | 1)
#define gmid ((l+r)>> 1 )
using namespace std;

const int maxn=20000050;
int a[maxn];
int main()
{
	ll n,k=0;
	cin>>n;
	for(int i=1;i<=n;++i)
	  {
	      cin>>a[i];
	      k=k^a[i];
      }
    for(int i=1;i<=n;++i)
	  cout<<(k^a[i])<<" ";  
}


Measured memory_bytes: 4416
n = int(input())
bl = list(map(int,input().split()))

ans = []
for k in range(n):
    for i in range(n-1-k, -1, -1):
        if bl[i] == i+1:
            a = bl.pop(i)
            ans.append(a)
            break
    else:
        print(-1)
        exit()

for i in reversed(ans):
    print(i)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <string>
#include <limits.h>
#include <iomanip>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <set>
#include <bitset>
#include <unordered_map>
#include <string.h>
#define fastIo                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define MOD 1000000007

using namespace std;
int par[200005];
int find(int x){
    if(par[x]<0)
        return x;
    return par[x] = find(par[x]);
}
void UNION(int a,int b){
    int parA = find(a);
    int parB = find(b);
    if(parA!=parB){
        par[parB]+=par[parA];
        par[parA] = parB;
    }
}
int main()
{
    fastIo;

    for(int i=0;i<200005;i++)
        par[i] = -1;

    int n;
    cin>>n;

    int m;
    cin>>m;
    while(m--)
    {
        int a,b;
        cin>>a>>b;
        UNION(a,b);
    }
    int ans =1;
    for(int i=1;i<=n;i++)
    {
        if(par[i]<0)
        ans = max(ans,abs(par[i]));
    }
    cout<<ans<<endl;
    

   
    return 0;
}

Measured memory_bytes: 4372
//ABC061B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	for(int i=1;i<=b;i++){
		if(a*i%b == c){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports, unused_variables, dead_code, non_snake_case, unused_macros)]
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

fn getline() -> String{
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) 
        }
    };
}

macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

macro_rules! mvec {
    ($v: expr, $s: expr) => {
        vec![$v; $s]
    };
    ($v: expr, $s: expr, $($t: expr),*) => {
        vec![mvec!($v, $($t),*); $s]
    };
}

macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator, 
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display {
    for (i,e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}

struct ContestPrinter {
    s: String,
}

impl ContestPrinter {
    fn new() -> ContestPrinter {
        ContestPrinter {
        s: String::new(),
        }
    }

    fn print<T>(&mut self, x: T)
        where T: std::fmt::Display {
        self.s.push_str(format!("{}", x).as_str());
    }

    fn println<T>(&mut self, x: T)
        where T: std::fmt::Display {
        self.s.push_str(format!("{}\n", x).as_str());
    }
}

impl std::ops::Drop for ContestPrinter {
    fn drop(&mut self) {
        print!("{}", self.s);
    }
}

// euclidの互除法
fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 { a }
    else { gcd(b, a % b) }
}
// ab = lcm(a, b)gcd(a, b)
fn lcm(a: i64, b: i64) -> i64 {
    let g = gcd(a, b);
    (a / g) * b
}
// 約数列挙 昇順ではない
fn divisors(n: i64) -> Vec<i64> {
    let mut ret = Vec::new();
    if n == 1 { ret.push(1); return ret; }
    let mut i = 1;
    loop {
        if (n % i) == 0 {
            ret.push(i);
            if (i != 1) & ((i*i) != n) {
                ret.push(n / i);
            }
        }
        i += 1; if n < (i*i) { break; }
    }
    ret.push(n);
    ret
}

fn is_max_i64(num: i64) -> bool { if num == i64::max_value() { true } else { false } }

fn main() {
    let mut pr = ContestPrinter::new();
    
    let n = readl!(usize);
    let mut num = readl!(i64);
    for _ in 0..n-1 {
        let t = readl!(i64);
        num = lcm(num, t);
    }
    pr.println(num);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define all_acc(x) (x).begin(),(x).end(),0LL
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;

void output(vector<int> s){
    int n=s.size();
    for(int i=0;i<n;i++){
        if(i!=0) cout<<" ";
        cout<<s[i];
    }
    cout<<endl;
}

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const long long MAX=10;
long long MOD=pow(10,9)+7;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
//前処理にO(n)、計算にはO(1)かかる。
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//mは素数じゃなくてもええで
// mod. m での a の逆元 a^{-1} を計算する
//aのmod mにおける逆元を求めてくれる
//aをmで割って、その後bの逆元を求めると分かる。
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//n>=10^9とかで、kは10^7より小さいくらい
int nCk(int n,int k,int mod){
   int bunbo=1;
   int bunsi=1;
   for(int i=0;i<k;i++){
       bunbo=(bunbo*((n-i)% mod))% mod;
       bunsi=bunsi*((k-i)% mod)% mod;
   }
   int bunsi_inv=modinv(bunsi,mod);
   return ((bunbo%mod) * (bunsi_inv%mod))% mod;

}

signed main(){ 
   int n; cin>>n;
   int a,b; cin>>a>>b;

   int ans=(modpow(2,n,MOD)-1)%MOD;
   if(ans<0) ans+=MOD;

   int aMOD=nCk(n,a,MOD);
   int bMOD=nCk(n,b,MOD);
   ans-=aMOD;
   if(ans<0) ans+=MOD;
   ans-=bMOD;
   if(ans<0) ans+=MOD;

   cout<<ans<<endl;
   //cout<<ans-nCk(n,a,MOD)-nCk(n,b,MOD)<<endl;
}  

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

using namespace std;

const int maxn = 1005,mo = int(1e9) + 7;

int cr[maxn][maxn],fac[maxn],rfac[maxn],f[maxn][maxn],n,a,b,c,d;

int pow(int a,int b)
{
	int tmp = 1;
	for(;b;b >>= 1,a = a * 1ll * a % mo)
		if (b & 1) tmp = tmp * 1ll * a % mo;
	return tmp;
}

int main()
{
	cin >> n >> a >> b >> c >> d;
	for(int i = 0;i <= n;i ++)
	{
		cr[i][0] = 1;
		for(int j = 1;j <= i;j ++)
			cr[i][j] = (cr[i - 1][j - 1] + cr[i - 1][j]) % mo;
	}
	fac[0] = 1;
	for(int i = 1;i <= n;i ++) fac[i] = fac[i - 1] * 1ll * i % mo,rfac[i] = pow(fac[i],mo - 2);
	f[0][0] = 1;
	for(int i = 0;i <= b - a;i ++)
		for(int s = 0;s <= n;s ++)
			if (f[i][s])
			{
				int v = i + a;
				f[i + 1][s] = (f[i + 1][s] + f[i][s]) % mo;
				for(int k = 1,val = 1;k <= d && s + v * k <= n;k ++)
				{
					val = val * 1ll * cr[n - s - v * (k - 1)][v] % mo;
					if (k >= c) f[i + 1][s + k * v] = (f[i + 1][s + k * v] + f[i][s] * 1ll * val % mo * rfac[k] % mo) % mo;
				}
			}
	cout << f[b - a + 1][n] << endl;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
    ll n, m; cin >> n >> m;
    map<ll,ll> mp;
    vector<ll> s(n);
    cin >> s[0]; s[0]%=m;
    mp[s[0]]++;
    rep(i, n-1) {
        int a;
        cin >> a;
        s[i+1] = (s[i]+a)%m;
        mp[s[i+1]]++;
    }
    //rep(i, n) cout << s[i];
    ll ans = 0LL;
    for(auto i = mp.begin(); i != mp.end() ; ++i) {
        ll f = i->first; ll s = i->second;
        if(f == 0) ans += s;
        ans += (s-1)*s/2LL;
    }
    cout << ans;
}



Measured memory_bytes: 4992
#include<iostream>
#include<string>

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	string s;
	cin >> s;

	int ans = 0;

	for(int i=1;i<=n-1;i++)
	{
		int count = 0;
		for(int j='a';j<='z';j++)
		{
			if(s.find(j,i+1)!=-1 && s.rfind(j,i)!=-1)
				count++;
		}
		ans = max(ans,count);
	}
	cout << ans << endl;
}


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

int main() {
	int n;
	
	cin>>n;
  	
	int arr1[n],arr2[n],arr3[n],dp[n+1][3];
	for(int i=0;i<n;i++){
	  cin>>arr1[i];
      cin>>arr2[i];
      cin>>arr3[i];
		
	}
  dp[0][0]=arr1[0];
  dp[0][1]=arr2[0];
  dp[0][2]=arr3[0];
	for(int  i=1;i<n;i++){
    	dp[i][0]=max(dp[i-1][1],dp[i-1][2])+arr1[i];
      dp[i][1]=max(dp[i-1][0],dp[i-1][2])+arr2[i];
      dp[i][2]=max(dp[i-1][1],dp[i-1][0])+arr3[i];
      
    }
  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}
void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        cout << 2 << " ";  
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            cout << i << " ";  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        cout << n << " ";  
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
   int t;
   //cin>>t;
   
  t=1;
  while(t--)
   {
   long long int i,j;
 //long long int b[1000000];
 //set<long long int >s;
       long long int f=0,p=0,z,o=0;
       double pie=3.141592653589793238;
    long long int n,m,l=0,k,c,min1=10000000000000,max2=-100;
   cin>>m>>n;
    long long int a[n];
    for(i=0;i<n;i++)
	cin>>a[i];
    long long int b[2*n];
    for(i=0;i<n;i++)
    {
      if(i==0)
        b[o++]=(a[n-1]-a[i]);
      else
      b[o++]=(m-a[i])+a[i-1];
      //cout<<b[o-1]<<"\n";
      if((i+1)!=n)
        b[o++]=a[i]+(m-a[i+1]);
      else
        b[o++]=a[i]-a[0];
     // cout<<b[o-1]<<" "<<o<<"\n";
    }
    sort(b,b+o);
    cout<<b[0];
   }
   
 return 0;
}


Measured memory_bytes: 8328
#include <iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    int a[100000];
    int b[100000];
    int c[100000];
    for(int i = 0; i < N; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    int dp[3][100000];
    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];
    for(int i = 1; i < N; i++){
        dp[0][i] = max(dp[1][i-1], dp[2][i-1]) + a[i];
        dp[1][i] = max(dp[2][i-1], dp[0][i-1]) + b[i];
        dp[2][i] = max(dp[0][i-1], dp[1][i-1]) + c[i];
    }
    cout << max(dp[0][N-1], max(dp[1][N-1], dp[2][N-1])) << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 1e5 + 5;
const ll LINF = 1e18 + 5;
char s[N], t[N];
int n, m;
int nxt[N][26];
void build(int n)
{
	for(int i=0; i<26; i++) nxt[n][i] = 0;
	for(int i=n;i>0;i--)
	{
		for(int j=0;j<26;j++) nxt[i-1][j] = nxt[i][j];
		nxt[i-1][s[i]-'a'] = i;
	}
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> (s+1) >> (t+1);
 	n = strlen(s+1); m = strlen(t+1);
 	build(n);
 	int i = 0, j = 1;
 	ll cnt = 0;
 	bool ok = 1;
 	while(j<=m && ok)
 	{
 		int nxti = nxt[i][t[j]-'a'];
 		if(!nxti)
 		{
 			if(i)
			{
				nxti = nxt[0][t[j]-'a'];
				if(!nxti) ok = 0;
				else 
				{
					cnt += n - i + nxti;
					i = nxti;
				}
			}
			else ok = 0;
 		}
 		else
 		{
 			cnt += nxti - i;
 			i = nxti;
 		}
 		j++;
 	}
 	if(!ok) cnt = -1;
 	cout << cnt;
	return 0;
}


Measured memory_bytes: 10624
#include"bits/stdc++.h"

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 28);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7

bool judge(vector<int> x,vector<int> y){
	int res = 0;
	REP(i,x.size())
		res+=(x[i]-y[i])*(x[i]-y[i]);
	int half = sqrtl(res);
	return res==half*half;
}


int main()
{
	int N,D;
	cin>>N>>D;
	vector<vector<int>> X(N,vector<int>(D));
	REP(i,N)REP(j,D)cin>>X[i][j];

	int res = 0;
	REP(l,N)FOR(r,l+1,N)
		if(judge(X[l],X[r]))
			res++;
	cout<<res<<endl;
	return 0;
}


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

int main()
{

char day[4];
  
scanf("%s",day);
 // printf("%s",day);
  
  if ( strcmp(day,"SUN")==0)
  	  {	
      printf("7");
   	  return 0;
      } 
  if ( strcmp(day,"MON")==0)
      {
      printf("6");
      return 0;
      } 
  if ( strcmp(day,"TUE")==0)
      {
      printf("5");
      return 0;
      } 
  if ( strcmp(day,"WED")==0)
      {
      printf("4");
      return 0;
      } 
  if ( strcmp(day,"THU")==0)
      {
      printf("3");
      return 0;
      } 
  if ( strcmp(day,"FRI")==0)
      {
      printf("2");
      return 0;
      } 
  if ( strcmp(day,"SAT")==0)
      {
      printf("1");
      return 0;
  	  }

return 0;
}

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

int main() {
    int n, x;
    char com[20];
    list<int> vOut;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin>>com;
        if(com[0]=='i'){
            cin>>x;
            vOut.push_front(x);
        }else if(com[6]=='F'){
            vOut.pop_front();
        }else if(com[6]=='L'){
            vOut.pop_back();
        }else{
            cin>>x;
            for(list<int>::iterator it=vOut.begin(); it !=vOut.end(); it++){
                if(*it==x){
                    vOut.erase(it);
                    break;
                }
            }
        }
    }
    int i=0;
    for(list<int>:: iterator it=vOut.begin(); it !=vOut.end(); it++){
        if(i++) printf(" ");
        cout<< *it;
    }
    cout<<endl;
}


Measured memory_bytes: 34256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int zero = 0, one = 0;
		
		String str;
		Scanner scanner = new Scanner(System.in);
		
		str = scanner.next();
		scanner.close();
		
		for (int i = 0; i < str.length(); i++) {
			if (str.charAt(i) == '0') {
				zero++;
			} else {
				one++;
			}
		}
		System.out.println(Math.min(zero, one)*2);
	}

}


Measured memory_bytes: 25684
while 1:
    c = input()
    r = input()
    if c == 0: break        
    l = [map(int, raw_input().split()) for i in range(r)]
    ans = 0
    d = [(-1,0),(0,-1),(1,0),(0,1)]
    def dfs(j, i, cnt):
        global ans
        ans = max(ans, cnt)
        for x, y in d:
            dx = x + i; dy = y + j
            if 0<=dx<c and 0<=dy<r and l[dy][dx]:
                l[dy][dx] = False
                dfs(dy, dx, cnt+1)
                l[dy][dx] = True
    for i in range(c):
        for j in range(r):
            if l[j][i]:
                l[j][i] = False
                dfs(j,i,1)
                l[j][i] = True
    print ans

Measured memory_bytes: 6360
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

int n, T;
int t[200000];

signed main() {
	int i;
	
	cin >> n >> T;
	for (i = 0; i < n; i++) cin >> t[i];
	
	int ans = 0;
	for (i = 1; i < n; i++) {
		ans += min(T, t[i] - t[i - 1]);
	}
	ans += T;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;


int main() {
  int a[9];
  int o[9];
  REP(i,9) {
    cin >> a[i];
    o[i] = 0;
  }
  int n;
  cin >> n;
  REP(i,n) {
    int b;
    cin >> b;
    REP(i,9) {
      if(a[i] == b) {
        o[i] = 1;
      }
    } 
  }
  int ans = 0;
  if(o[0] == 1 && o[1] == 1 && o[2] == 1) ans = 1;
  if(o[3] == 1 && o[4] == 1 && o[5] == 1) ans = 1;
  if(o[6] == 1 && o[7] == 1 && o[8] == 1) ans = 1;
  if(o[0] == 1 && o[3] == 1 && o[6] == 1) ans = 1;
  if(o[1] == 1 && o[4] == 1 && o[7] == 1) ans = 1;
  if(o[2] == 1 && o[5] == 1 && o[8] == 1) ans = 1;
  if(o[0] == 1 && o[4] == 1 && o[8] == 1) ans = 1;
  if(o[2] == 1 && o[4] == 1 && o[6] == 1) ans = 1;
  if (ans == 1) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int V,E;
int m[111][111];
int v[111][111];
int cnt[111][111];
int ans;
void f(int x,int y){
    if(cnt[x][y]++)return;
    if(v[x][y]==-1){
        ans++;
        return;
    }
    f(x,v[x][y]);f(v[x][y],y);
}
int main(){
    cin>>V>>E;
    for(int i=0;i<V;i++)
        for(int j=0;j<V;j++)
            if(i!=j)m[i][j]=1e9;
    for(int i=0;i<V;i++){
        for(int j=0;j<V;j++){
            int x,y,z;
            cin>>x>>y>>z;
            x--;y--;
            m[x][y]=m[y][x]=z;
            v[i][j]=-1;
        }
    }
    for(int i=0;i<V;i++){
        for(int j=0;j<V;j++){
            for(int k=0;k<V;k++){
                int jik=m[j][i]+m[i][k];
                if(m[j][k]>jik){
                    m[j][k]=jik;
                    v[j][k]=i;
                }
            }
        }
    }
    for(int i=0;i<V;i++){
        for(int j=0;j<V;j++){
            if(i!=j)
                f(i,j);
        }
    }
    cout<<E-ans/2<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long int
#define pi 3.1415926536
using namespace std;

/*ll merge(vector<ll> &v,ll l,ll m,ll r)
{
	ll n1=m-l+1;
	ll n2=r-m;
	ll inv=0;
	vector<ll> a(n1),b(n2);
	for(ll i=0;i<n1;i++)
	a[i]=v[l+i];
	for(ll i=0;i<n2;i++)
	b[i]=v[m+1+i];
	ll i=0,j=0,k=l;
	while(i<n1&&j<n2)
	{
		if(a[i]<=b[j])
		{
			v[k]=a[i];
			i++;
		}
		else
		{   inv+=(m-i+1);
			v[k]=b[j];
			j++;
		}
		k++;
	}
	while(i<n1)
	{
		v[k]=a[i];
		i++;
		k++;
	}
	while(j<n2)
	{
		v[k]=b[j];
		j++;
		k++;
	}
	return inv;
}
ll mergesort(vector<ll> &v,ll l,ll r)
{  ll inv=0;
	if(l<r)
	{
		ll m=l+(r-l)/2;
		inv=mergesort(v,l,m);
		inv+=mergesort(v,m+1,r);
		inv+=merge(v,l,m,r);
	}
	return inv;
}*/

/*ll factorize(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            if((n/i)!=i)
            res.push_back(n/i);
        }
    }
    
    return (ll)res.size();
}*/

void solve()
{ll n,k,ans,z,d=0,q,l=INT_MIN,mini=0,prev;
   cin>>n;
   string s;
   cin>>s;
   if(n<3200)
   cout<<"red";
   else
   cout<<s;
}

int main()
{
  fast
ll t=1;

while(t--)
{solve();
 //cout<<ma<<endl;
}
return 0;}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;
const int Nmax=114514;
int dp[Nmax][2][2];

signed main(){
	int n=read();
	FOR(i,1,n+1){
		int a=read();
		int x=dp[i-1][1][1]+a,s=dp[i-1][1][0];
		if(x<=0){
			s+=(1-x);
			x=1;
		}
		int y=dp[i-1][0][1]+a,t=dp[i-1][0][0];
		if(y>=0){
			t+=y+1;
			y=-1;
		}
		dp[i][0][1]=x;dp[i][0][0]=s;
		dp[i][1][1]=y;dp[i][1][0]=t;
	}
	cout<<min(dp[n][0][0],dp[n][1][0])<<endl;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
double hiritu = 1.08;
int main(){
    int n;cin >> n;
    for(int x=27;x<=25*n;x+=27){

    }
    double x = 1;
    while(1){
        if(floor(x*1.08)==n){
            cout << int(x) << endl;
            return 0; 
        }
        if(x*1.05>n){
            break;
        }
        x++;
    }
    cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    ll nowmax=0;
    ll ans=0;
    int n;
    cin>>n;
    rep(i,n)
    {
        ll a;
        cin>>a;
        if(nowmax>a)
        {
            ans+=(nowmax-a);
        }
        else
        {
            nowmax=a;
        }
        

    }
    cout<<ans;
}


Measured memory_bytes: 3620
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readLine() string {
	sc.Scan()
	return sc.Text()

}

func main() {
	str := strings.Split(readLine(), " ")

	n, _ := strconv.Atoi(str[0])
	k, _ := strconv.Atoi(str[1])
	q, _ := strconv.Atoi(str[2])

	point := []int{}
	for i := 0; i < n; i++ {
		point = append(point, k-q)
	}

	for i := 0; i < q; i++ {
		p, _ := strconv.Atoi(readLine())
		point[p-1]++
	}

	for _, v := range point {
		if v <= 0 {
			fmt.Println("No")
		} else {
			fmt.Println("Yes")
		}
	}
}

Measured memory_bytes: 6912
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  co(n*(n-1)/2)
}
  


Measured memory_bytes: 1024