akhauriyash/Code-Regression huggingface dataset:
// abc076_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int n,k,ans=1;
  cin>>n>>k;
  rep(i,n){
    if(ans<=k){
      ans*=2;
    }else{
      ans+=k;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

char O[100],E[100];

int main()
{
    scanf("%s%s",O,E);
    for(int i = 0; i < strlen(O); i++)
    {
        printf("%c",O[i]);
        if(i == strlen(O) - 1 && strlen(O) - strlen(E))continue;
        printf("%c",E[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll n;cin>>n;
	for(ll i=1;i<10;i++) if(i*100+i*10+i>=n){cout<<i*100+i*10+i<<endl; return 0;}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long k,_min,_max,x_y,x,y,fibx,fiby,a,i;double mid;
#define MOD 1000000007
int dp[3];
int main(){
	cin>>k;
	a=sqrt(k)/16;
	x_y=(long long)(2*sqrtl(k-a-0.01))-1;
	_max=(x_y+2)*(x_y+2)/4;
	_min=(x_y+1)*(x_y+1)/4+1;
	mid=1.0*(_max+_min)/2;
	if(k<=mid){y=(k-_min)*2;}
	else{y=(_max-k)*2+1;}
	x=x_y-y;
	if(x<3){
		fibx=x+1;
	}
    else{
		dp[0]=1;
		dp[1]=2;
		dp[2]=3;

		for(i=3;i<=x;i+=3)
		{
			dp[0]=(dp[1]+dp[2])%MOD;
			dp[1]=(dp[2]+dp[0])%MOD;
			dp[2]=(dp[0]+dp[1])%MOD;
		}

		fibx=dp[x%3];
    }
	if(y<3)
	{
		fiby=y+1;
	}
    else{
		dp[0]=1;
		dp[1]=2;
		dp[2]=3;

		for(i=3;i<=y;i+=3)
		{
			dp[0]=(dp[1]+dp[2])%MOD;
			dp[1]=(dp[2]+dp[0])%MOD;
			dp[2]=(dp[0]+dp[1])%MOD;
		}

		fiby=dp[y%3];
	}

	cout<<(fibx * fiby)%MOD<<endl;
}

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


int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int total = 0;
  for (int i = 1; i <= N; ++i) {
    int sum = findSumOfDigits(i); // i の各桁の和
    if (sum >= A && sum <= B) { //  i の各桁の和が A 以上 B 以下かどうか
      total += i;
    }
  }
  cout << total << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>



using namespace std;

string s;

int main(){
    cin >> s;
    for(int i=0;i<3;i++){
        cout << s[i] ;
    }
    cout << endl;


return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main()
{
    int n;
    int F[50];

    cin >> n;
    F[0] = F[1] = 1;
    for (int i = 2; i <= n; i++) F[i] = F[i - 1] + F[i - 2];

    cout << F[n] << endl;

    return 0;
}


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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pnn=pair<int ,int>;

#define ft first
#define sd second
#define fn front
#define pb push_back
#define it insert
#define si(v) int((v).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sot(x) sort(x.begin(), x.end())
#define rese(x) reverse(x.begin(), x.end())
#define vnn(x,y,s,name) vector<vector<int>> name(x, vector<int>(y,s))
#define mse(x) memset(x, 0, sizeof(x))
#define mii(x,y,z) min(x,min(y,z))
#define maa(x,y,z) max(x,max(y,z))

string yes="Yes",no="No";

int main() {
  ll h,n;
  cin>>h>>n;
  vll a(n),b(n);
  rep(i,n) cin>>a[i]>>b[i];
  vll mima(h+1,100100100);
  mima[0]=0;
  rep(i,n){
      rep(j,h){
          mima[min(h,j+a[i])]=min(mima[min(h,j+a[i])],mima[j]+b[i]);
      }
      
      rep(j,h) mima[h-j-1]=min(mima[h-j],mima[h-1-j]);
  }

  cout<<mima[h]<<endl;
}


Measured memory_bytes: 3712
n = int(input())
d, x = map(int, input().split())
a = [int(input()) for i in range(n)]

choco = 0

for e_a in a:
    day = 0
    for i in range(d):
        if day*e_a + 1 == (i+1):
            day += 1
            choco += 1

choco += x
print(choco)


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

namespace AtCoder
{
	public class ABC
	{
		//private const int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start();
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			int r = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			double ans = Math.PI * 2 * r;
			Console.WriteLine(ans);



			Console.Out.Flush();
			System.Diagnostics.Debug.WriteLine(stopwatch.Elapsed);
		}
	}
}


Measured memory_bytes: 27612
#include <iostream>
using namespace std;
 
int main() {
  int i=0,j,k,cnt=0;
  string s;
  cin>>s;
  while(s.at(i)!='A'){
    i++;
  }
  for(j=0;j<s.size();j++){
        if(s.at(j)=='Z'){
          k=j;
    }
  }
  k=k-i+1;
  cout<<k<<endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  int type = 1;
  for(int i = 0; i < N-1; i++) {
    if(A.at(i) != A.at(i+1)) {
      type++;
    }
  }
  if(type <= K) {
    cout << "0" << endl;
  }
  else {
    vector<int> B(type);
    B.at(type-1) = 1;
    int j, sum = 0;
    for(int i = 0; i < N-1; i++) {
      if(A.at(i) == A.at(i+1)) {
        B.at(j)++;
      }
      else {
        B.at(j)++;
        j++;
      }
    }
    sort(B.begin(), B.end());
    for(int i = 0; i < type - K; i++) {
      sum += B.at(i);
    }
    cout << sum << endl;
  }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define maxN 100007
using namespace std;
int main(){
  fastio;
  ll n=0;
  cin>>n;
  vector<ll>v(n);
  for(ll i=0;i<n;++i) cin>>v[i];
  sort(v.begin(), v.end());
  ll p=1;
  for(ll i=0;i<n;++i){
    if(v[i]==0){
      p=0;
      break;
    }
    if(v[i]<=(ll)1e18/p)
      p*=v[i];
    else{
      cout<<"-1";
      return 0;
    }
  }
  cout<<p;
}

Measured memory_bytes: 3948
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <sstream>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	int R,G,B,N,ANS=0;
	cin >> R >> G >> B >> N;

	for(int i=0;i<=3000;i++)
	{
		for(int j=0;j<=3000;j++)
		{
			if(N>=R*i+G*j&&(N-R*i-G*j)%B==0)
			{
				ANS++;
			}
		}
	}
	cout << ANS << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <cstring>

// ---------- PBDS -----------------

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
// slow but fast ORZ :)
// ----------------------------------

using namespace std;
using namespace __gnu_pbds; 

#define MEM(a, b) memset(a, (b), sizeof(a))
#define ALL(a) a.begin(), a.end()
#define MP(a, b) make_pair(a, b)
#define PB(a) push_back(a)
#define EB(a) emplace_back(a) // care when use
#define boost ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0),cout << fixed << setprecision(10);
// #define ll long long int
#define int long long int

#define DEBUG

#ifdef DEBUG

    #define debug(args...)(Debugger()) , args

    class Debugger{
        public:
        Debugger(const std::string& _separator = " | ") :
        first(true), separator(_separator){}

        template<typename ObjectType> Debugger& operator , (const ObjectType& v)
        {
            if(!first)
                std::cerr << separator;
            std::cerr << v;
            first = false;
            return *this;
        }
        ~Debugger() {  std::cerr << std::endl;}

        private:
        
        bool first;
        std::string separator;
    };

#else
    #define debug(args...)
#endif


void solve(){

	int n;
	cin >> n;

	int ans = 0;

	for(int i =1 ; i <= n; ++i){

		int x;
		cin >> x;

		if((i % 2 != 0) and (x % 2 != 0))
			ans++;

	}

	cout << ans << "\n";

}


int32_t main(){

	boost;
	
	int T;

	// cin >> T;
	T = 1;
	
	while(T--){
		solve();
	}
}


Measured memory_bytes: 3488
#include <bits/stdc++.h>
using namespace std;
void ok(){
    cout << "Yay!" << endl;
}
void ng(){
    cout << ":(" << endl;
}
int main(){
    int N,K;
    cin >> N >> K;
    int maxx,minn;
    minn = 1;
    N = N-K;
    maxx = N+1;
    if(K==1) cout << 0 << endl;
    else cout << maxx - minn << endl; 

}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    S = input()
    n = len(S)
    acgt = ['A', 'C', 'G', 'T']
    maxlen = 0
    for i in range(n):
        tmp = 0
        if S[i] in acgt:
            tmp += 1
            for j in range(i+1, n):
                if S[j] in acgt:
                    tmp += 1
                else:
                    break
            maxlen = max(maxlen, tmp)
    print(maxlen)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
from math import sqrt

def Divisor_Set(n):
    s = set()
    for i in range(1, int(sqrt(n))+2):
        if n%i == 0:
            s.add(i)
            s.add(n//i)
    return s

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a_sum = sum(a)
    st = Divisor_Set(a_sum)
    ans = 1
    st.remove(1)
    for v in st:
        b = [x%v for x in a]
        b.sort()
        for i in range(n-1):
            b[i+1] += b[i]
        for i in range(n-1):
            if b[i] == v*(n-i-1) - (b[-1] - b[i]):
                if b[i] <= k and ans < v:
                    ans = v
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9168
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int n,a,b;
    scanf("%d%d%d", &n, &a, &b);
    if(abs(b-a)%2==0) {
        printf("Alice\n");
    }
    else {
        printf("Borys\n");
    }
    return 0;
}


Measured memory_bytes: 128
import numpy as np
from scipy.spatial.distance import euclidean

a, b, h, m = map(int, input().split())
M = h*60 + m
A = np.array([np.cos(2*M*np.pi/720),np.sin(2*M*np.pi/720)]) * a
B = np.array([np.cos(2*M*np.pi/60),np.sin(2*M*np.pi/60)]) * b
ans = euclidean(A,B)
print(ans)

Measured memory_bytes: 44732
#include<stdio.h>

int main(){
	int k,a,b;
	while(scanf("%d%d%d",&k,&a,&b)==3){
		if(a>b) printf("%d\n",0);
		else if(a!=b&&k==1) printf("%d\n",0);
		else if(a==b&&k==1) printf("%d\n",1);
		else printf("%lld\n",(long long)(k-2)*(b-a)+1); 
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	LLi n, x, y, ma=-1;
	vector<LLi> v3, v4;

	cin>> n;
	v3.resize(n);
	v4.resize(n);

	rep(i, n){
		cin >> x >> y;
		v3[i]=x+y;
		v4[i]=x-y;
	}
	
	sort(v3.begin(), v3.end());
	sort(v4.begin(), v4.end());

	ma=max(ma, v3[n-1]-v3[0]);
	ma=max(ma, v4[n-1]-v4[0]);

	cout<< ma << endl;
 
	return 0;
}


Measured memory_bytes: 6424
int main(){
  int h,n,loop,a;
  scanf("%d",&h);
  scanf("%d",&n);
  for(loop=0;loop<n;loop++){
    scanf("%d",&a);
    h-=a;
  }
  if(h<=0)
    printf("Yes");
  else
    printf("No");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int a[n];
  unsigned long long sum=0;
  //float selection;
  for(int i=0;i<n;i++)
  { 
    cin>>a[i];
    sum = sum+a[i];
  }
  int count=0;
  //float d=((float)vote/(4*m));
  float selection =((float)sum/(4*m));
  for(int i=0;i<n;i++)
  {
    if(selection<= a[i])
    {
      count++;
    }
  }
  if(count>=m)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}
    


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  ll q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;

  n *= 4;
  ll ans = 0;
  ll tmp;
  tmp = n / 8;
  n %= 8;
  ans = min({tmp * d, tmp * 2 * s, tmp * 4 * h, tmp * 8 * q});
  tmp = n / 4;
  n %= 4;
  ans += min({tmp * s, tmp * 2 * h, tmp * 4 * q});
  tmp = n / 2;
  n %= 2;
  ans += min({tmp * h, tmp * 2 * q});
  if (n) ans += q;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
#include<tuple>

std::string field[51];
int H,W;
int answer=-1;
int maxscore;
bool visited[51][51]={};

struct bfsqueue{
		int x;
		int y;
		int grid;
};

std::queue<bfsqueue> q;

void input(void){
	std::cin>>H>>W;
	for(int i=0;i<H;i++){
		std::cin>>field[i];
	}
}

void maxscorefind(void){
	maxscore=H*W;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(field[i][j]=='#'){
				maxscore--;
			}
		}
	}
}

bool bfs_cango(int x,int y){
	if(x<W && x>=0 && y<H && y>=0){
		if(field[y][x]=='.'&&visited[y][x]==false){
			return true;
		}
	}
	return false;
}

void bfs(void){
	while(q.empty()==false){
	bfsqueue tgtque=q.front();
	q.pop();
	if(tgtque.x==W-1&&tgtque.y==H-1){
		int tempanswer=maxscore-tgtque.grid;
		if(tempanswer>answer){
			answer=tempanswer;
		}
	}else{
		if(bfs_cango(tgtque.x+1,tgtque.y)){
			visited[tgtque.y][tgtque.x+1]=true;
			bfsqueue pushq;
			pushq.x=tgtque.x+1;
			pushq.y=tgtque.y;
			pushq.grid=tgtque.grid+1;
			q.push(pushq);
		}
		if(bfs_cango(tgtque.x-1,tgtque.y)){
					visited[tgtque.y][tgtque.x-1]=true;
					bfsqueue pushq;
					pushq.x=tgtque.x-1;
					pushq.y=tgtque.y;
					pushq.grid=tgtque.grid+1;
					q.push(pushq);
				}
		if(bfs_cango(tgtque.x,tgtque.y+1)){
					visited[tgtque.y+1][tgtque.x]=true;
					bfsqueue pushq;
					pushq.x=tgtque.x;
					pushq.y=tgtque.y+1;
					pushq.grid=tgtque.grid+1;
					q.push(pushq);
				}
		if(bfs_cango(tgtque.x,tgtque.y-1)){
					visited[tgtque.y-1][tgtque.x]=true;
					bfsqueue pushq;
					pushq.x=tgtque.x;
					pushq.y=tgtque.y-1;
					pushq.grid=tgtque.grid+1;
					q.push(pushq);
				}


	}
	}
}

int main(void){
	input();
	maxscorefind();
	bfsqueue pushque;
	pushque.x=0;
	pushque.y=0;
	pushque.grid=1;
	q.push(pushque);
	bfs();
	std::cout<<answer<<std::endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

const ll MOD = 1e9 + 7;
const ll INF = 2e15 + 10;
const ll MAX = 1e14 + 10;
const ld EPS = 1e-9;
const int N = 16;
const int M = 110;

int a[N][N];
ll d1[(1 << N)];
ll d[(1 << N)];

void solve() {
    int n;
    cin >> n;
    fr(i, n)
        fr(j, n)
            cin >> a[i][j];
    fr(mask, (1 << n)) {
        fr(i, n)
            if ((1 << i) & mask)
                frab(j, i + 1, n)
                    if ((1 << j) & mask)
                        d1[mask] += a[i][j];
    }

    fill(d + 1, d + (1 << n), -INF);

    fr(mask, (1 << n))
        for (int s = mask; s; s = (s - 1) & mask) {
            d[mask] = max(d[mask], d1[s] + d[mask ^ s]);
        }
    cout << d[(1 << n) - 1];


}



int main() {
    //freopen("a.in", "r", stdin);
    ios_base::sync_with_stdio(false);
    solve();
}


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

int main() {
	int x;
	int y;
	while(1){
	scanf("%d %d",&x,&y);
	if(x==0&&y==0)break;
	else if(x>y)printf("%d %d\n",y,x);
	else if(x<y)printf("%d %d\n",x,y);
	else if(x==y)printf("%d %d\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<stdio.h>

int main(void){
 char c[3][3];
for (int i = 0; i < 3; i++) {
scanf("%c%c%c\n", &c[i][0], &c[i][1], &c[i][2]);
}

//for (int i = 0; i < 3; i++) {
//printf("%c %c %c \n", c[i][0], c[i][1], c[i][2]);
//}

printf("%c%c%c", c[0][0], c[1][1], c[2][2]);

  return 0;
  
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-

# input


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

diff = []

for v, c in zip(V, C):
    if v-c < 0:
        continue
    diff.append(v-c)

print(sum(diff))


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <cassert>
#include <unordered_set>
#include <chrono>
#include <bitset>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

#include <nmmintrin.h>
#ifdef _MSC_VER

#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct Edge {
	int from, to, s;
};
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}

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

	set<pii> a;
	vector<pii> num(n);
	vector<pii> l(n), r(n);
	REP(i, n) {

		int x, y;
		scnaf("%d %d", &x, &y);

		num[i] = { x,y };
		l[i] = { x,i };
		r[i] = { y,i };
		a.insert({y,i * 2 + 1});
		a.insert({ x,i * 2 });
	}

	ll ans = 0;

	int used[100001] = {};
	auto itr = a.begin();
	bool terval = false, ale = true, ari = true;

	REP(i, n) {
		int retu = (itr->second) / 2;
		ans += itr->first;

		if (itr->second % 2) {
			ale = false;
		}
		else
		{
			ari = false;
		}

		if (used[retu]) {
			terval = true;
		}

		used[retu]++;
		itr++;
	}


	if (ale || ari || terval) {
		cout << ans << endl;
		return 0;
	}

	ll lans = LLONG_MAX;

	REP(i, n) {
		ll ans2 = ans;
		auto itr2 = itr;

		ans2 -= min(num[i].first, num[i].second);

		while (1) {
			int retu = itr2->second / 2;
			if (retu != i) {
				ans2 += itr2->first;
				break;
			}
			itr2++;
		}

		lans = min(lans, ans2);
	}


	cout << lans << endl;

	return 0;
}

Measured memory_bytes: 12416
//#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
//#include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T> using G = greater<T>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), G<type>())
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n, PER) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(roop, n) a[idx][roop] = v[roop]; idx++;} while(next_permutation(ALL(v))); PER = a;} while(0); // int fact(), VVI PERを宣言しておく、n=10が限界(500 ms)
#define ENDL cout << endl;

const int INF = 2e9;
const LL MOD = 1e9 + 7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, G<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;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I "; else cout << A[i] << " ";}}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[0], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string n;
  cin >> n;
  REPx(x, n)
  {
    if (x == '7')
    {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";

  return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int mod = 1e9+7;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string L;
    cin >> L;
    long long a = 1, b = 2;
    for (int i = 1; i < (int)L.size(); i++) {
        a *= 3;
        if (L[i] == '1') {
            a += b;
            b *= 2;
        }
        a %= mod;
        b %= mod;
    }
    printf("%lld\n", (a+b)%mod);
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
template<typename T> inline void debug(const vector<T> &xs){
#ifdef DEBUG
	pr(xs);
#endif
}

int main(){
	int N, M;
	cin >> N >> M;
	vector<vector<int>> A(N, vector<int>(M));
	for(int i=0; i<N; i++) for(int j=0; j<M; j++){
		cin >> A[i][j];
	}

	vector<vector<int>> belongs(M+1);
	for(int i=0; i<N; i++){
		belongs[A[i][0]].push_back(i);
	}
	vector<bool> removed(M+1);
	vector<int> idx(N, 0);
	int ans = 1e9;
	for(int i=0; i<M; i++){
		int m = 0;
		int k = 0;
		for(int j=1; j<=M; j++) if(m < belongs[j].size()) {
			m = belongs[j].size();
			k = j;
		}
		debug(any{k, m});
		ans = min(ans, m);

		removed[k] = true;
		for(int l: belongs[k]){
			idx[l]++;
			while(idx[l]<M && removed[A[l][idx[l]]]) idx[l]++;
			if(idx[l]==M) {
				cout << ans << endl;
				return 0;
			}
			belongs[A[l][idx[l]]].push_back(l);
		}
		belongs[k].clear();
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1280
/*Author : Kartik Bansal
 *Date : 07/09/19
 *Time : 16:14 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
#define tc int t ;cin>>t ;while(t--)
#define pb push_back
#define FOR(i,n) for(int i =0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin() , v.end()
#define sort(v) sort(all(v))
#define vi  vector<int>
#define vll  vector<long long >
#define inf INT_MAX
#define minf INT_MIN
int32_t main()
{
  ios::sync_with_stdio(0) ;
  cin.tie(0) ; cout.tie(0) ;
  ll  a,b ;//,c ,d ;
  cin>>a>>b ;

  ll cnt = 0 ;
FOR(i,a)
{
    int temp ;
    cin>>temp ;
    if(temp >= b)
        cnt++ ;
}
cout<<cnt ;

  return 0 ;
}


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

int main(){
  int n, k, a[N], i, j, min, x=0, num;
  scanf("%d %d", &n, &k);
  for(i=1;i<=n;i++){
    scanf("%d", &a[i]);
    if(a[i] == 1) min = i;
  }
  num = min;
  while(min != 1){
    num -= k;
    x++;
    if(num <= 0) break;
    num++;
  }


  min = n - min + 1;
  if(num < 0) min += num;
  num = min;
  while(min > 1){
    num -= k;
    x++;
    if(num <= 0) break;
    num++;
  }
  printf("%d\n", x);
  return 0;
}

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

using namespace std;

typedef long long ll;

const int mod = 998244353;

ll powmod(ll a, ll b) {
    int res = 1;
    while (b) {
        if (b & 1) {
            res = int(res * 1ll * a % mod), --b;
        } else {
            a = int(a * 1ll * a % mod), b >>= 1;
        }
    }
    return res;
}

ll reverse(ll a) {
    return powmod(a, mod - 2);
}

int main() {
    int n, m;
    cin >> n >> m;
    if (n == m) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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;
}

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll dp[110][110][330];
void solve() {
    ll n, W;
    cin >> n >> W;
    Array w(n), v(n);
    REP(i, n) {
        cin >> w[i] >> v[i];
    }

    REP(i, n + 1) {
        REP(j, n + 1) {
            REP(k, (n + 1) * 3) {
                dp[i][j][k] = -INF;
            }
        }
    }
    dp[0][0][0] = 0;
    REP(i, n) {
        ll ww = w[i] - w[0];
        ll vv = v[i];
        REP(j, n) {
            REP(k, n * 3) {
                if(dp[i][j][k] == -INF)
                    continue;
                chmax(dp[i + 1][j][k], dp[i][j][k]);
                chmax(dp[i + 1][j + 1][k + ww], dp[i][j][k] + vv);
            }
        }
    }

    ll ans = 0;
    REP(i, n + 1) {
        REP(j, n + 1) {
            REP(k, (n + 1) * 3) {
                if(w[0] * j + k > W)
                    continue;
                chmax(ans, dp[i][j][k]);
            }
        }
    }
    cout << ans << en;
}

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

    solve();
    // ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 30312
# https://atcoder.jp/contests/abc068/tasks/abc068_b

import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    N = int(input())
    ans = 0
    count = -1
    for i in range(1, N+1):
        c = 0
        v = i
        while v % 2 == 0:
            c += 1
            v //= 2
        if c > count:
            count = c
            ans = i

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include<cstdio>
#include<cstring>
#define chkmin(a,b) ((a)<(b)?(a):(b))
#define chkmax(a,b) ((a)>(b)?(a):(b))
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~(i)))
char s[100010];
int ans1,ans2;
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);ans1=n,ans2=n;
	f(i,1,n)
	{
		if(s[i]=='0')ans1=chkmin(ans1,chkmax(n-i+1-1,i-1));
		else ans2=chkmin(ans2,chkmax(n-i+1-1,i-1));
	}return printf("%d\n",chkmax(ans1,ans2)),0;
} 

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

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

    int N, M;
    cin >> N >> M;
    vector<int> k(M);
    vector<vector<int> > s(M);
    for (int i = 0; i < M; ++i) {
        cin >> k.at(i);
        s.at(i).resize(k.at(i));
        for (auto &x : s.at(i)) {
            cin >> x;
            x--;
        }
    }
    vector<int> p(M);
    for (auto &x : p) cin >> x;

    int ans = 0;
    for (int tmp = 0; tmp < (1 << N); ++tmp) {
        bitset<12> BIT(tmp);
        bool can = true;
        for (int i = 0; i < M; ++i) {
            int res = 0;
            for (auto &x : s.at(i)) {
                if (BIT.test(x)) res++;
            }
            can *= res % 2 == p.at(i);
        }
        if (can) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
ans = 0
for i in range(n-1):
    c = 0
    for j in range(26):
        if chr(j+97) in s[:i+1] and chr(j+97) in s[i+1:]:
            c += 1
    if c > ans:
        ans = c
print(ans)


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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(c-a)<=d||(abs(b-a)<=d&&abs(c-b)<=d)){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>
#include <iomanip>
#include <functional>
#include <array>
#include <memory>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#undef NDEBUG
#include <assert.h>

using namespace std;
typedef long long ll;

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

	string s, t;
	cin >> s >> t;
	for (int i = 0; i < 100; ++i) {
		rotate(s.begin(), s.begin() + 1, s.end());
		if (s == t) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

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

#n=10
#a=[3, 1, 4, 1, 5, 9, 2, 6, 5, 3]
#a=[3, 14, 159, 2653, 58979, 323846, 2643383, 27950288, 419716939, 9375105820]

mod=10**9+7
asum=0
for i in range(60):
    zcnt=0
    for ii in range(n):
        asht=a[ii]>>i
        if asht&1==0:
            zcnt+=1
    tmp=(zcnt*(n-zcnt))%mod*((2**i)%mod)
    asum+=(tmp)%mod
               
asum=asum%mod
print(asum)


Measured memory_bytes: 118060
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>

using namespace std;
using ll = long long;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;



int main()
{
	int H, N;
	cin >> H >> N;

	std::vector<std::pair<int, int>> AB(N);

	for (int i = 0; i < N; ++i)
	{
		cin >> AB[i].first >> AB[i].second;
	}

	vec dp(H + 1, 1e9);
	dp[0] = 0;
	for (int h = 0; h < H; ++h)
	{
		for (int j = 0; j < N; ++j)
		{
			int i = std::min(H, h + AB[j].first);
			dp[i]
				= std::min(dp[i], dp[h] + AB[j].second);
		}
	}

	cout << dp[H] << endl;
}

Measured memory_bytes: 256
$n = gets.to_i
$v = gets.split(" ").map(&:to_i)
$c = gets.split(" ").map(&:to_i)
#dp

def rec(i)
    res = 0
    #終了条件。品物がない
    if i == $n
        res = 0
    else
        #宝石を選ぶ場合と選ばない場合を両方試す
        res = [rec(i+1),rec(i+1)+$v[i]-$c[i]].max
    end
end

puts rec(0)

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};

int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll n,x,y,sum=0;
    cin>>n>>x>>y;
    map<int,int>mp;
    vector<int>v;
    int st;
    while(n-- && x)
    {
        mp[x]++;
        if(mp[x]==2)
            v.push_back(x);
        if(mp[x]==3)
        {
            n++;
            break;
        }
        sum+=x;
        x=(x*x);
        x%=y;


        //cout<<x<<" "<<mp[x]<<endl;
    }
    int sz=v.size();
    if(sz && n>0)
    {
        ll cur=0;
        for(int i=0; i<sz; i++)
        {
            cur+=v[i];
        }
        ll mul=n/sz;
        ll rem=n%sz;
        for(int i=0; i<rem; i++)
        {
            sum+=v[i];
        }
        sum+=(mul*cur);
    }
    cout<<sum<<endl;

    return 0;
}



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

int main(){
    int N, M;  cin >> N >> M;
    vector<bool> ac(N, false);
    vector<int> s(N, 0);
    for(int i=0; i<M; i++){
        int p; string r;
        cin >> p >> r;
        p--;
        if(!ac[p] && r == "WA"){
            s[p]++;
        }
        if(r == "AC"){
            ac[p] = true;
        }
    }

    int nac = 0, nwa = 0;
    for(int i=0; i<N; i++){
        if(ac[i]){
            nac++;
            nwa += s[i];
        }
    }
    cout << nac << " " << nwa << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    ll N;
    cin >> N;
    vector<ll> vec(N), diff(N-1);
    REP(i, N) cin >> vec[i];
    
    // calculation
    ll minv = vec[0], benefit = LLONG_MIN;
    for (ll i = 1; i < N; ++i) {
        benefit = max(benefit, vec[i] - minv);
        minv = min(minv, vec[i]);
    }
    cout << benefit << "\n";
    return 0;
}



Measured memory_bytes: 5992
#include <iostream>
#include <vector>
#include <string>
//#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n  ;
    cin >> n;

    int p = n%10;
    //cout << p;

    if(p == 2 || p == 4 || p == 5 || p == 7 || p ==9) {
        cout << "hon\n";
        return 0;
    } else if(p == 0 || p == 1 | p == 6 || p == 8) {
        cout << "pon\n";
        return 0;
    } else {
        cout << "bon\n";
        return 0;
    }
    
}

Measured memory_bytes: 3636
[a,b,c] = [int(i) for i in input().split(" ")]
goukei = 0
for i in range(1,a+1):
  kurainowa = 0
  kisuu = [int(k) for k in list(str(i))]
  
  for j in range(0,len(kisuu)-1+1):
    kurainowa = kurainowa + kisuu[j]
  if kurainowa < c+1 and b-1 <kurainowa :
    goukei = goukei + i
print(goukei)

Measured memory_bytes: 9168
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#ifdef TEST
#define getchar_unlocked _getchar_nolock
#endif
#define int long long
#define ins insert
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define pp pop
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long double ld;
typedef long long ll;
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int s, w;
	cin >> s >> w;
	if (w >= s) cout << "unsafe\n";
	else cout << "safe\n";
}


Measured memory_bytes: 3644
import sys
import math

N, P = map(int, sys.stdin.readline().strip().split())
A = map(int, sys.stdin.readline().strip().split())


def nCr(n, r):
    return math.factorial(n) // math.factorial(n - r) // math.factorial(r)

evens = 0
odds = 0
for a_i in A:
    if a_i % 2 == 0:
        evens += 1
    else:
        odds += 1

# 偶数の服からa個、奇数の袋から2b個取れば良い
if P == 0:
    ans = 2**(evens)
    tmp = 0
    for i in range(0, odds+1, 2):
        tmp += nCr(odds, i)
    ans *= tmp
# 偶数の服からa個、奇数の袋から2b+1個取れば良い
else:
    ans = 2**(evens)
    tmp = 0
    for i in range(1, odds+1, 2):
        tmp += nCr(odds, i)
    ans *= tmp

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define For(i,a,b) for(long long i=a;i<b;i++)
#define pb push_back
using namespace std;
typedef long long ll;
ll power(ll x,ll y,ll p){
ll res = 1;x = x % p;
while (y > 0){
if (y & 1){res = (res*x) % p;}
y = y>>1;
x = (x*x) % p;}
return res;}
ll mcd(ll a,ll b){
    if(b>a)swap(a,b);
    if(b==0)return a;
    else return mcd(b,a%b);
}
ll n,m,k;
bool esprimo(ll n){
ll s=0;
for(ll i=1;i*i<=n;i++){
    if(n%i==0){s++;}}
if(s>=2){return false;}
return true;
}
int main(){
    //    cout<<fixed<<setprecision(2);
//cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
 cin>>n;
 ll a[n];
 ll s=0;
 for(int i=0;i<n;i++){cin>>a[i];s+=a[i];s%=(ll)(1e9+7);}
 ll ans=0;
 for(int i=0;i<n;i++){
    s-=a[i];
    s+=1e9+7;
    s%=(ll)(1e9+7);
    ans+=s*a[i];
    ans%=(ll)(1e9+7);
 }

 cout<<ans<<endl;

}


Measured memory_bytes: 5164
while True :
    a, b, c = [int(temp) for temp in input().split()]
    if a == b == c == -1 : break
    if   (a == -1) or (b == -1) or (a + b < 30) : print('F')
    elif (80 <= a + b) : print('A')
    elif (65 <= a + b) : print('B')
    elif (50 <= a + b) or ((30 <= a + b) and (50 <= c)) : print('C')
    else : print('D')

Measured memory_bytes: 7672
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int l = a + b, r = c + d;

    if (l > r) {
        cout << "Left" << endl;
    }
    else if (l == r) {
        cout << "Balanced" << endl;
    }
    else {
        cout << "Right" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author RiaD
 */

#include <iostream>
#include <fstream>

#include <iostream>

using namespace std;

class A {
public:
	void solve(std::istream& in, std::ostream& out) {
		string s;
		in >> s;
		auto res = ((s.find('N') != string::npos) == (s.find('S') != string::npos)) && ((s.find('E') != string::npos) == (s.find('W') != string::npos));
		out << (res ? "Yes" : "No");
	}
};


int main() {
	std::ios_base::sync_with_stdio(false);
	A solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(0);
	out << std::fixed;
	out.precision(20);
	solver.solve(in, out);
	return 0;
}


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

int main()
{
    int n;
    long long d;
    cin >> n >> d;
    d = d * d;
    long long x[n], y[n];
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
        if (x[i] * x[i] + y[i] * y[i] <= d)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    ll a;
    double b;
    cin >> a >> b;

    ll b100 = ll(b*100 + 0.00001);
    cout << a*b100/100 << endl;
}


Measured memory_bytes: 3708
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<long long>::max();
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, s, t, q, ans, sum, last, cnt;
struct Edge { LL to,cost; };
vector<Edge>vec[100];
string a[1000], b[1000];
map<string, LL>ma;
bool f=0;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main(){
	cin >> n;
	ans += n / 11 * 2;
	n %= 11; 
	if (n > 0)
		ans++;
	n -= 6;
	if (n > 0)
		ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int mod = 1e9 + 7;
int main()
{
	SPEED
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> arr[i];
	}
	for (int i = 0; i < n; ++i)
	{
		if (!(arr[i]&1))
		{
			if (arr[i]%3!=0 && arr[i]%5!=0)
			{
				cout << "DENIED";
				return 0;
			}
		}
	}
	cout << "APPROVED";
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    long long ans = 0;
    vector<long long> enemy(n+1);
    vector<long long> hero(n);
    for(int i=0; i<n+1; i++) cin >> enemy[i];
    for(int i=0; i<n; i++) cin >> hero[i];
    
    for(int i=0; i<n; i++){
        if(enemy[i]>=hero[i]) {
            ans += hero[i];
            enemy[i] -=hero[i];
            hero[i]=0;
        }
        else{
            ans += enemy[i];
            hero[i] -= enemy[i];
            enemy[i]=0;
            if(enemy[i+1]>=hero[i]){
                ans += hero[i];
                enemy[i+1] -=hero[i];
                hero[i]=0;
            }
            else{
                ans += enemy[i+1];
                hero[i] -= enemy[i+1];
                enemy[i+1]=0;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792