akhauriyash/Code-Regression huggingface dataset:
//file_name:ABC97_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


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

    if(abs(n-y)<=z){
        puts("Yes");
    }else if(abs(n-x)<=z&&abs(x-y)<=z){
        puts("Yes");
    }else{
        puts("No");
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int main(){

  string s = stin();
  if( SZ(s) >= 4 && s.substr( 0, 4 ) == "YAKI" ){
    puts( "Yes" );
  } else {
    puts( "No" );
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a,b;
  cin >> a >> b;
  int c;
  c=a*b;
  int d;
  d=c%2;
  if (d == 0){
    cout <<"Even"<<endl;
      }
      else{
        cout <<"Odd"<<endl;
      }
      return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    ll a, v, b, w; cin >> a >> v >> b >> w;
    ll t; cin >> t;
    if (v-w > 0 && (v-w)*t >= abs(b-a)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
int main(){
  int N,cnt = 0,i,a,b;cin >> N;
  for(i=0;i<N;i++){
    cin >> a >> b;
    if(a == b) cnt++;
    else cnt = 0;
    if(cnt == 3){
      cout << "Yes\n";return 0;
    }
  }
  cout << "No\n";
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll MOD=1e9+7 ;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
const int MX = 100000 + 7;
int n,m;
vector<ll> A;
//priority_queue<ll, vector<ll>, greater<ll> > que;
vector<pair<ll, int>> bc;

int main(){
	cin >> n >> m;
	FOR(i,1,n){
		ll a;
		cin >> a; A.push_back(a);
	}
	FOR(i,1,m){
		int b; ll c; cin >> b >> c;
		bc.push_back(MP(c,b));
	}
	sort(ALL(A));
	sort(ALL(bc), greater<pair<ll,int>>());
	ll sm = 0;
	int cur = 0;
	FOR(i,0,n-1){
		if(A[i] < bc[cur].FI){
			sm += bc[cur].FI;
			//cout << bc[cur].FI;
			bc[cur].SE -= 1;
			if(bc[cur].SE == 0) cur += 1;
		}
		else{
			sm += A[i];
		}
	}
	cout << sm;
    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, a, b; cin >> n >> a >> b;
  if(a > b) cout << 0 << "\n";
  else if(n==1 && a!=b) cout << 0 << "\n";
  else cout << b*(n-1)+a-(a*(n-1)+b)+1 << "\n";
  return 0;
}


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

using namespace std ;
typedef long long ll;
typedef string str;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<double> vdou ;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<str> vstr;
typedef pair<ll,ll> pll ;
typedef vector<pii> vpii ;
typedef vector<pll> vpll ;

#define REP(i, n) for (ll (i) = 0; (i) < (ll)(n); i++) 
#define FOR(i, a, b) for(ll (i) = a; (i) < (ll)b; i++)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define CHI 1000000000000000003
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (ll)x.size()
#define SP(x)  setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

void yes(){
  cout <<"POSSIBLE"<<endl ;
}
void no(){
  cout <<"IMPOSSIBLE"<<endl ;
}
//-----------------------------------------


const int MAX_V = 1e6;

struct edge{
  int to, cost ;
  //iからの行き先とそのコストの情報
};

int V ;
vector<edge> G[MAX_V] ;
int d[MAX_V] ;
//d[i]...sからiへ行くのにかかるコストの最小


void dijkstra(int s){
  priority_queue<pii, vector<pii>, greater<pii>> que;
  //pair<sからiへ行くのの暫定最小コスト、i>の優先度付きキュー
  REP(i,V){
    d[i] = INF ;
    //はじめコストはINFとして初期化
  }
  d[s] = 0 ;
  que.push(MP(0,s)) ;
  //自身へのコストは0としてqueへ入れる
  
  while(!que.empty()){
    pii p = que.top() ;
    que.pop() ;
    int v = p.SE ;
    //queが空になるまで取り出す
    if(d[v]<p.FI){
      //すでにそれ以下があれば見る必要はない
      continue ;
    }
    REP(i,SZ(G[v])){
      //vを経由した行き先について
      edge e = G[v][i] ;
      if(d[e.to]>d[v]+e.cost){
        //vを経由した方がコストが小さいなら更新し、queに入れる
        d[e.to] = d[v]+e.cost ;
        que.push(MP(d[e.to],e.to)) ;
      }
    }
  }
}

















//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int m ;
  cin >> V >> m ;
  REP(i,m){
    int a, b ;
    cin >> a >> b ;
    edge e = {b-1,1} ;
    G[a-1].PB(e) ;
  }
  dijkstra(0) ;
  if(d[V-1]==2){
    yes() ;
  }
  else{
    no() ;
  }
  
  
  
  
  return 0 ;
}

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


int main() {
    int N; cin >> N;
    vector<pair<pair<string, int>, int>> list(N);
    for (int i = 0; i < N; i ++) {
        string S; cin >> S;
        int P; cin >> P;
        list[i].first = make_pair(S, -P);
        list[i].second = i + 1;
    }

    sort(list.begin(), list.end());
    for (int i = 0; i < N; i++) {
        cout << list[i].second << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;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
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;



int main() {
    int a,b;cin >> a >> b;
    if(abs(a-b) %2 == 0) cout << (a+b)/2;
    else cout << "IMPOSSIBLE";
}



Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline().rstrip())
N = I()
a = [0]+[I() for _ in range(N)]
ans,now = 0,1
for _ in range(N):
    temp = a[now]
    ans += 1
    if temp==2:
        print(ans)
        break
    else:
        now = temp
else:
    print(-1)


Measured memory_bytes: 7852
def slove():
    import sys
    import fractions
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    ls = [[0] * (n + 1) for _ in range(2)]
    for i in range(n):
        ls[0][i+1] = fractions.gcd(ls[0][i], a[i])
        ls[1][-i-2] = fractions.gcd(ls[1][-i-1], a[-i-1])
    m_gcd = 0
    for i in range(n):
        gcd = fractions.gcd(ls[0][i], ls[1][i+1])
        m_gcd = max(m_gcd, gcd)
    print(m_gcd)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 89580
#include"stdio.h"
#include"string.h"
#include "algorithm"
#include "math.h"
using namespace std;
int main()
{
	int i,j,n,x,p[110][110],f,y,ca;
   //freopen("E:\\in.txt","r",stdin);
	ca=1;
   while(scanf("%d",&n))
   {
	   if(n==0) break;
	   y=n*n;
	   i=0;
	   j=0;
	   p[i][j]=1;
	   x=2;
	   f=0;
	   while(x<=y)
	   { 
            if(i==0||j==n-1)
			{
               j++;
			   if(j>=n)
			   {
				   j=n-1;
				   i++;
			   }
			   p[i][j]=x;
	
			   x++;
               while(j>0&&i<n-1)
			   {
                   i++;
                   j--;
				   p[i][j]=x;
	
			       x++;
			   }
		
			}
			else if (j==0||i==n-1)
			{
               i++;
			   if(i>=n)
			   {
				   i=n-1;
				   j++;
			   }
               p[i][j]=x;
			   x++;
			   while(i>0&&j<n-1)
			   {
				   i--;
				   j++;
				   p[i][j]=x;
			       x++;
			   }
			   
			}
	   } 
	   printf("Case %d:\n",ca++);
	   for (i=0;i<n;i++)
	   {
          for (j=0;j<n;j++)
          {
			 printf("%3d",p[i][j]);
          }
		  printf("\n");
	   }
   }
   return 0;
}

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

using namespace std;

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


int main(){
 int k,x;
   cin >> k >> x;

 
  rep(i,2*k-1) {
   cout << x-k+i << " ";
  }
  cout << endl;
  }

Measured memory_bytes: 256
n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]
p = [0 for i in range(n+1)]

for i in range(q):
    p[a[i]]+=1

for i in range(1, n+1):
    if p[i]>q-k:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 8640
//#include <bits/stdc++.h>                          //include all library
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <string.h>
#include <functional> // greater<int> はfunctionalヘッダ
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)          //REP(i, 10){...} //i=0～i=9までのループ
#define REPR(i, n) for(int i = n;i >= 0;i--)        //REPR(i, 10){...} //i=10～i=0までのループ
#define FOR(i, m, n) for(int i = m;i < n;i++)       //FOR(i, 3, 10){...} //i=3～i=9までのループ
#define FORR(i, m, n) for(int i = m;i >= n;i--)     //FORR(i, 10, 3){...} //i=10～i=3までのループ
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define PI 3.141592653589
#define npos -1

int main()
{
  int h,w;
  cin >> h >>w;
  int bom[h][w];
  //int b[h][w];
  //REP(i,h) REP(j,w) b[i][j]=0;
  int array_x[8] ={1,1,1,0,-1,-1,-1,0};
  int array_y[8] ={1,0,-1,-1,-1,0,1,1};

  REP(i,h)
  {
  	string str;
  	cin >> str;
  	REP(j,w)
  	{
  		char str1 = str[j];
  		if(str1=='.') bom[i][j]=0;
  		else bom[i][j]=1;
  	}
  }

  REP(i,h)
  {
  	REP(j,w)
  	{
  		int count=0;
 		 	if(bom[i][j]==1) cout << "#";
 		 	else
 		 	{
  			REP(k,8)
  			{
  				int x=i+array_x[k];
  				int y=j+array_y[k];
  				if(x>=0 and y>=0 and x<h and y<w and bom[x][y]==1) count++;
  			}
  			cout << count;
  		}

  	}

  	cout << endl;

  }

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

using P = pair<string, int>;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<P> v(n);
    REP(i, 0, n) {
        cin >> v[i].first >> v[i].second;
        v[i].second = -v[i].second;
    }
    vector<int> ind(n);
    iota(ind.begin(), ind.end(), 0);
    sort(ind.begin(), ind.end(), [&](int a, int b) {
        return v[a] < v[b];
    });
    REP(i, 0, n) {
        cout << ind[i] + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int fre,gam,tag[100],a[100][100],pp,poi[100]={0};
    cin>>fre>>gam;
    for(int i=0;i<gam;i++)cin>>tag[i];
    for(int i=0;i<gam;i++){
        for(int j=0;j<fre;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<gam;i++){
        pp=0;
        for(int j=0;j<fre;j++){
            if(tag[i]==a[i][j])poi[j]+=1;
            else pp++;
        }
        poi[tag[i]-1]+=pp;
    }
    for(int i=0;i<fre;i++){
        cout<<poi[i]<<endl;
    }
}

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

int main() {
  int n, a, b, c, d;;
  cin >> n;
  int win_point[n] = {};
  int i, j;
  for (i = 0; i < (n * (n - 1) / 2); i++) {
    cin >> a >> b >> c >> d;
    if (c == d) {
      win_point[a - 1]++;
      win_point[b - 1]++;
    } else if (c < d) {
      win_point[b - 1] += 3;
    } else {
      win_point[a - 1] += 3;
    }
  }
  int result[n] = {};
  int m1_point = 0, m1_index = 0;
  for (i = 0; i < n; i++) {
    int point = 0, index = 0;
    for (j = 0; j < n; j++) {
      if (point < win_point[j]) {
        point = win_point[j];
        index = j;
      }
    }
    if (m1_point == win_point[index]) {
      result[index] = result[m1_index];
    } else {
      result[index] = i + 1;
    }
    m1_point = win_point[index];
    m1_index = index;
    win_point[index] = 0;
  }
  for (i = 0; i < n; i++) {
    cout << result[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3088
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

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

const LL M=1e9+7;
const int L=1e5+1;
LL v[L];
int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%lld",v+i);
		v[i]+=v[i-1];
		v[i]%=M;
	}
	LL x=0;
	for(int i=1;i<=n;i++){
		x+=v[n]+M-v[i];
		x%=M;
		x+=(M-(v[i]+M-v[i-1])%M*(n-i)%M)%M;
		x%=M;
	}
	for(int i=1;i<=m;i++){
		scanf("%lld",v+i);
		v[i]+=v[i-1];
		v[i]%=M;
	}
	LL y=0;
	for(int i=1;i<=m;i++){
		y+=v[m]+M-v[i];
		y%=M;
		y+=(M-(v[i]+M-v[i-1])%M*(m-i)%M)%M;
		y%=M;
	}
	printf("%lld\n",x*y%M);

	return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int gcd(int x,int y);

#define MAX(p,q) (p>q)?p:q
#define MIN(p,q) (p<q)?p:q

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

int main(void)
{
  int N;
  scanf("%d",&N);
  int i;
  int a[100000];
  REP(i,N)
  {
    scanf("%d",&a[i]);
    //printf("%d",a[i]);
  }
  int ans = a[0];
  REP(i,N)
  {
    ans = gcd(ans,a[i]);
  }
  printf("%d\n",ans);
  return 0;
}
//全探索バージョン
int gcd(int x,int y)
{
  int ans = 0,m = 0,n = 0;
  int i = 0;
  m = MAX(x,y);
  n = MIN(x,y);
  if(m%n != 0)
  {
    gcd(m%n,n);
  }
  else
  {
    return n;
  }
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
using namespace std;

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    //差が奇数かつ、全体
    int flag = 0;
    if(b - a < 2*k) flag = 1;

    if(flag)for(int i=0; i <= (b-a); i++) cout << a + i << endl;
    else{
        for(int i=0; i < k; i++) cout << a + i << endl;
        for(int i=0; i < k; i++) cout << b-k+1+i << endl;}
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,a,b,i,t=0;
	cin>>k>>a>>b;
	for(i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			cout<<"OK";
			t=1;
			break;
		}
	}
	if(t==0)
	cout<<"NG";
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

ll n;
ll ans = 0;

void input(){
    cin >> n;
}

void dfs(ll num){
    if(num > n) return;
    string s = to_string(num);
    if(s.find('3') != string::npos && s.find('5') != string::npos && s.find('7') != string::npos) ans++;
    dfs(num * 10 + 3);
    dfs(num * 10 + 5);
    dfs(num * 10 + 7);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    dfs(3);
    dfs(5);
    dfs(7);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long n,num=1,summand=1;
double S(long long x){
	long long sum=0,div=x;
	while(div){
		sum+=div%10;
		div=div/10;
	}
//	cout << (double)(x) << ' ' << (double)(sum) << ' ' << (double)(x)/(double)(sum) << endl;
	return (double)(x)/(double)(sum);
}
int main(){
	cin >> n;
	for(int i=1;i<=n;i++){
		cout << num << endl;
		double ii=S(num+summand),jj=S(num+summand*10);
		if(ii>jj) summand*=10;
		num+=summand;
	}
	return 0;
}

Measured memory_bytes: 256
# A - Product

# 2つの正の整数 a, b の積が
# 奇数ならOdd, 偶数ならEven を返す

a, b = map(int, input().split())

if (a * b) % 2 == 0:
    print('Even')           # a*bを2で割った余りが0なら偶数
else:
    print('Odd')            # そうでないなら奇数


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

int gcd(int x, int y);

signed main() {
    int n, a, left[100002], right[100002], ans;

    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> a;
        left[i+1] = a;
        right[i+1] = a;
    }

    left[0] = right[0] = left[n+1] = right[n+1] = 0;

    for ( int i = 0; i < n; i++ ) {
        left[i+1] = gcd(left[i], left[i+1]);
    }

    for ( int i = n; i > 0; i-- ) {
        right[i] = gcd(right[i], right[i+1]);
    }

    ans = 0;
    for ( int i = 1; i <= n; i++ ) {
        ans = max(ans, gcd(left[i-1], right[i+1]) );
    }

    cout << ans << endl;

    return (0);
}

int gcd(int x, int y) {
    if ( x < y ) {
        swap(x, y);
    }

    if ( y == 0 ) {
        return (x);
    } 

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

    return (y);
}

Measured memory_bytes: 4340
#include<bits/stdc++.h>
using namespace std;
#define l long long
int main()
{
  l n;
  cin>>n;
  l a;
  l c4=0,c2=0;
  for(int i=0;i<n;i++)
  {
    cin>>a;
    if(a%4==0)
      c4++;
    else if(a%2==0)
      c2++;
  }
  if(c4>=n/2)
    cout<<"Yes"<<endl;
  else if(2*c4+c2>=n)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}
    

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

int main() 
{
    string s;
    cin >> s;
    rep(i,s.size()) {
        if (i%2 == 1 && s[i] == 'R') {
            cout << "No" << endl;
            return 0;
        }
        if (i%2 == 0 && s[i] == 'L') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;
int an[30];


int main()
{
    int n;
    cin>>n;
    int key = 0;
    int ans = 0;
    for (int i = 0;i < n;i++)cin>>an[i];
    for (int i = 1;i < n;i++){
        for (int j = i-1;j >= 0;j--){
            if (an[i] < an[j]){
                key = -1;
                break;
            }
        }
        if (key == 0){
            ans++;
        }
        key = 0;
    }
    cout<<ans+1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,k,q,cnt[300005];
int main(){
    cin>>n>>k>>q;
    rep(i,q){
        int a; cin >> a; cnt[a-1]++;
    }
    rep(i,n){
        ll cur = k-(q-cnt[i]);
        if(cur <= 0) puts("No");
        else puts("Yes");
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
#define int long long
#define All(v) (v.begin(),v.end())
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
int modpow(int a,int b){
    if(!b)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int fac(int a){
    int Ans=1;
    for(int i=1;i<=a;i++){
        Ans*=i;
        Ans%=MOD;
    }
    return Ans;
}//kaijo
int comb(int a,int b){
    return fac(a)*modpow(fac(a-b),MOD-2)%MOD*modpow(fac(b),MOD-2)%MOD;
}
signed main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if((a*b)%2&&(c+d)%2)puts("No");
	else puts("Yes");
	return 0;
}




Measured memory_bytes: 3072
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            // write your code here
            int N = in.nextInt();
            int[] a = in.nextIntArray(N);

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

            System.out.println(ans);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }
    }
}

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

int main(){
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    A.push_back(A[0] + K);
    int mx = 0;
    for(int i=0; i<N; i++) mx = max(mx, A[i+1] - A[i]);
    cout << K-mx << endl;
    return 0;
}


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

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

    long long res = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i >= j) continue;

            bool flag = true;
            for (int k = 0; k < N; k++) {
                if (i == k || j == k) continue;

                if (A[i][k] + A[k][j] < A[i][j]) {
                    cout << -1 << endl;
                    return 0;
                }

                if (A[i][k] + A[k][j] == A[i][j]) flag = false;
            }

            if (flag) res += A[i][j];
        }
    }

    cout << res << endl;
    return 0;
}

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

//structure definition
typedef struct{
  int top;
  int front;
  int right;
  int left;
  int back;
  int under;
} DICE;

#define TOP   Dice.top
#define FRONT Dice.front
#define RIGHT Dice.right
#define LEFT  Dice.left
#define BACK  Dice.back
#define UNDER Dice.under

//prototype
int main(void);
DICE direction_judge(char* judge, DICE Dice);

//main()
int main(void){
  DICE Dice;
  char direction[101];

  scanf("%d %d %d %d %d %d", &TOP, &FRONT, &RIGHT, &LEFT, &BACK, &UNDER);
  scanf("%s", direction);

  for (int i = 0; i < strlen(direction); i++) {
    Dice = direction_judge(&direction[i], Dice);
  }
  printf("%d\n", TOP);
  return 0;
}

//direction_judge()
DICE direction_judge(char* judge, DICE Dice){
  int save = 0;
  switch (*judge) {
    case 'N':
      save = UNDER;
      UNDER = BACK;
      BACK = TOP;
      TOP = FRONT;
      FRONT = save;
    break;
    case 'E':
      save = UNDER;
      UNDER = RIGHT;
      RIGHT= TOP;
      TOP = LEFT;
      LEFT = save;
    break;
    case 'S':
      save = UNDER;
      UNDER = FRONT;
      FRONT = TOP;
      TOP = BACK;
      BACK = save;
    break;
    case 'W':
    save = UNDER;
    UNDER = LEFT;
    LEFT= TOP;
    TOP = RIGHT;
    RIGHT = save;
    break;
  }
  return Dice;
}



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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define mp make_pair


int main () {
  long long n;
  cin >> n;
  if (n == 0) {
    cout << 0 << endl;
    return 0;
  }

  string ans;
  ll now = 0;
  rep (i, 50) {
    ll mo = pow(2, i + 1);
    ll nokori = n % mo;
    nokori = ((nokori - now) % mo + mo) % mo;
    if (nokori == 0) {
      ans.push_back('0');
    }
    else {
      ans.push_back('1');
      now = now + pow(-1, i % 2) * pow(2, i);
    }
    
  }
  reverse(all(ans));
  while (ans[0] == '0') {
    ans.erase(ans.begin());
  }
  cout << ans << endl;
}
      
  






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  string ans="Yes";
  vector<int> alpha(26,0);
  for(int i=0;i<s.size();i++){
    alpha[(int)(s.at(i)-'0')%26]++;
  }
  for(int i=0;i<26;i++){
    if(alpha[i]%2==1){ans="No"; break;}
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdlib>
#include<string>
#include <bitset>

#define SIZE 100001
typedef long long ll;
using namespace std;

int main(){
    int N,X,T;
    int time=0;
    cin >> N >> X >> T;
    for(int i = 0 ; i < N ; i += X){
        time += T;
    }
    cout << time << endl;
    return 0;
}

Measured memory_bytes: 3632
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        A: usize,
        B: usize,
        X: usize,
    }

    let yes = "YES";
    let no = "NO";

    if X < A {
        println!("{}", no);
        return;
    }

    if X <= A + B {
        println!("{}", yes);
        return;
    }

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


Measured memory_bytes: 2132
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	ll X, Y;
	cin >> X >> Y;
	int ans = 0;
	ll num = X;
	while (num <= Y) {
		num *= 2;
		ans++;
	}
	cout << ans;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long x = sc.nextLong();
        int min = Integer.MAX_VALUE;
        int minpos = 0;
        int[] a = new int[n];
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
            if(a[i] < min){
                 min = a[i];
                 minpos = i;
            }
        }
        sc.close();

        long ans = 0;
        int[][] b = new int[n][n];
        
        for(int i=0; i<n; i++){
            ans += b[0][i] = a[i];
        }
        for(int i=1; i<n; i++){
            long mans = i*x + min;
            b[i][minpos] = min;
            for(int j=1; j<n; j++){
                int mpos = minpos + j;
                if(mpos >= n) mpos -= n;
                {
                    int npos = mpos - i;
                    if(npos < 0) npos += n;
                    mans += b[i][mpos] = Math.min(b[i-1][mpos], a[npos]);
                }
            }
            if(mans < ans) ans = mans;
        }

        System.out.println(ans);
	}
}


Measured memory_bytes: 55280
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7

N,M = map(int,input().split())
ways = []
for i in range(M):
    way = [int(i) for i in input().split()]
    ways.append(way)

ways.sort()
dp = [None for i in range(N+1)]

dp[1] = 0
cnt_way = 0
for j in range(N+1):
    for i in range(M):
        a,b,c = ways[i]
        if dp[a] != None:
            if dp[b] == None:
                dp[b] = dp[a] + c
            else:
                dp[b] = max(dp[b],dp[a]+c)

    if j == N-1:
        ans = dp[-1]

if ans == dp[-1]:
    pass
elif ans < dp[-1]:
    ans = "inf"

print(ans)


Measured memory_bytes: 5844
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>

using namespace std;

int main()
{
    char s[11];
    cin >> s;
    int ans=0;
    int tmp=0;
    for(int i=0; i<strlen(s); i++){
        if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
            tmp++;
        }else{
            ans=max(ans, tmp);
            tmp=0;
        }
    }
    ans=max(ans, tmp);
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
/* 2012-07-07T08:22:03 */
#define DEBUG_ON
#define CONDITION true
using namespace std;/*{{{*/

#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <sys/time.h>
#include <vector>

#define INF (1e9)
static const double PI (3.14159265358979323846);
static const double EPS (1e-10);

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef complex<double> P;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
inline double now(){ struct timeval tv; gettimeofday(&tv, NULL); return ((double)(tv.tv_sec) + (double)(tv.tv_usec) * 1e-6); }

#define FOR(i, b, e) for (typeof(b) i = (b); assert((i) <= (e)), i != (e); ++i)
#define REP(i, n) FOR(i, 0, n)

#define IFC(c) if(c) continue;
#define IFB(c) if(c) break;
#define IFR(c, r) if(c) return r;

#define OPOVER(_op, _type) inline bool operator _op (const _type &t) const

#define arrsz(a) ( sizeof(a) / sizeof(a[0]) )

#define F first
#define S second
#define MP(a, b) make_pair(a, b)

#define SZ(a) ((ll)a.size())
#define PB(e) push_back(e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())

#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(c,it) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define EXIST(s,e) ((s).find(e)!=(s).end())

#define BIT(n) (1ULL << (n))
#define BITOF(n, m) ((n) >> (m) & 1)

#define RANGE(a, b, c) ((a) <= (b) && (b) <= (c))

#ifdef DEBUG_ON
#define dprt(fmt, ...) if (CONDITION) fprintf(stderr, fmt, __VA_ARGS__)
#define darr(a) if (CONDITION) copy( (a), (a) + arrsz(a), ostream_iterator<int>(cerr, " ") ); cerr << endl
#define darr_range(a, f, t) if (CONDITION) copy( (a) + (f), (a) + (t), ostream_iterator<int>(cerr, " ") ); cerr << endl
#define dvec(v) if (CONDITION) copy( ALL(v), ostream_iterator<int>(cerr, " ") ); cerr << endl
#define darr2(a, n, m) if (CONDITION) FOR(i, 0, (n)){ darr_range( (a)[i], 0, (m) ); }
#define dvec2(v) if (CONDITION) FOR(i, 0, SZ(v)){ dvec( (v)[i] ); }
#define WAIT() if (CONDITION) { string _wait_; cerr << "(hit return to continue)" << endl; getline(cin, _wait_); }
#else
#define cerr if(0) cerr
#define dprt(fmt, ...)
#define darr(a)
#define darr_range(a, f, t)
#define dvec(v)
#define darr2(a, n, m)
#define dvec2(v)
#define WAIT()
#endif
/*}}}*/

int main(int argc, char const* argv[])
{
	vector<int> heights;
	REP (i, 10) {
		int h; cin >> h;
		heights.PB(h);
	}
	RSORT(heights);
	REP (i, 3) {
		cout << heights[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

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

int calc(vector<pair<int,int> >a){
    int n = a.size();
    if(n==0)return 0;
    vector<pair<int,int> > b;
    int sm = 0;
    rep(i,n){
        if(a[i]==MP(0,0)){
            sm += calc(b);
            b.clear();
        }else{
            b.push_back(a[i]);
        }
    }
    if(b.size()!=n){
        sm += calc(b);
        return sm;
    }
    bool flag = 0;
    rep(i,n){
        if(b[i]!=MP(1,0)){
            if(!flag){
                flag = 1;
                sm++;
            }
            b[i] = MP(b[i].first-1,b[i].second-1);
        }else{
            if(flag){
                flag = 0;
                b[i] = MP(0,0);
            }else{
                flag = 1;
                b[i] = MP(0,0);
                sm++;
            }
        }
    }
    return sm + calc(b);
}

int main(){
    int n;
    cin >> n;
    vector<int> s(n);
    rep(i,n){
        cin >> s[i];
    }
    vector<pair<int,int> > a(n);
    rep(i,n){
        int k = 1;
        int c = 0;
        while(k*2<=s[i]){
            k *= 2;
            c++;
        }
        if(k==s[i]){
            a[i] = MP(c,c);
        }else{
            a[i] = MP(c+1,c);
        }
    }
    cout << calc(a) << endl;
    return 0;
}

Measured memory_bytes: 49396
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>



int main(void)
{
	int x;
	scanf("%d", &x);
	if (x == 0)
		printf("1");
	else
		printf("0");
	return 0;
}

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

using namespace std;
const int maxn = 2e5+2;
const int mod = 1e9+7;
const int inf = 1e9;

typedef long long ll;

int n;
int arr[maxn], dp[maxn];

int solve_dp (int pos){
    if (pos > n) return inf;
    if (pos == n - 1) return 0;

    if (dp[pos] != -1) return dp[pos];

    int ans = inf;
    ans = min(ans, solve_dp(pos + 1) + abs(arr[pos + 1] - arr[pos]));
    ans = min(ans, solve_dp(pos + 2) + abs(arr[pos + 2] - arr[pos]));

    return dp[pos] = ans;
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> n;

    for (int i = 0; i < n; i++){
        cin >> arr[i];
    }

    memset(dp, -1, sizeof dp);

    cout << solve_dp(0) << "\n";

    return 0;
}


Measured memory_bytes: 4608
N, *S = map(int, open(0).read().split())
sum_S = sum(S)
if sum_S % 10:
    print(sum_S)
else:
    ans = 0
    for s in S:
        score = sum_S - s
        if score % 10 == 0:
            continue
        ans = max(ans, score)
    print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int B[N-1];
  for(int i=0;i<N-1;++i) cin>>B[i];
  int ans = 0;
  ans += B[0]+B[N-2];
  for(int i=1;i<N-1;++i) {
    ans += min(B[i-1], B[i]);
  }
  cout<<ans<<endl;
}



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

const ll INF = 1e18;

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

  ll nk = n * k;
  int lognk = 0;
  for (ll i = nk; i > 1; i >>= 1) lognk++;
  
  map<int, int> nxt;
  vector<vector<ll>> dbl(lognk + 1, vector<ll>(n, INF));
  for (int i = 2 * n - 1; i >= 0; i--) {
    if (i < n) dbl[0][i] = nxt[a[i]] - i + 1;
    nxt[a[i]] = i;
  }

  for (int k = 0; k < lognk; k++) {
    for (int i = 0; i < n; i++) {
      if (dbl[k][i] == INF) continue;
      dbl[k + 1][i] = dbl[k][i] + dbl[k][(i + dbl[k][i]) % n];
      if (dbl[k + 1][i] > INF) dbl[k + 1][i] = INF;
    }
  }
  
  ll p = 0;
  for (int k = lognk - 1; k >= 0; k--) {
    if (p + dbl[k][p % n] > nk) continue;
    p += dbl[k][p % n];
  }

  vector<int> ans;
  set<int> st;
  for (ll i = p; i < nk; ++i) {
    int x = a[i % n];
    if (st.find(x) != end(st)) {
      while (st.find(x) != end(st)) {
        st.erase(ans.back());
        ans.pop_back();
      }
    } else {
      ans.push_back(x);
      st.insert(x);
    }
  }

  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << ((i + 1 == ans.size()) ? '\n' : ' ');
  }
}


Measured memory_bytes: 110548
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    double now = a[0];
    reps(i, 1, n) {
        now = (now + a[i]) / 2;
    }
    cout << fixed << setprecision(15) << now << endl;
}


Measured memory_bytes: 3812
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    string s;
    cin >> s;

    int ans = 0, cnt = 0;
    rep(i, s.size()){

        if(s[i] == 'A') cnt++;
        else if(s[i] == 'T') cnt++;
        else if(s[i] == 'C') cnt++;
        else if(s[i] == 'G') cnt++;
        else cnt = 0;
        ans = max(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main(void){
  int n, a, max=0, ans=0, i;
  std::cin >> n;
  std::vector<int> card(n), scard(n);
  for(i=0; i<n; i++){
    std::cin >> card.at(i);
    if(card.at(i) > max) max = card.at(i);
  }
  std::vector<int> count(max+1);
  for(i=0; i<n; i++) count.at(card.at(i))++;
  for(i=0; i<max; i++) count[i+1] += count[i];
  for(i=n-1; i>=0; i--){
    scard.at(count.at(card.at(i))-1) = card.at(i);
    count.at(card.at(i))--;
  }
  for(i=n-1; i>=0; i--){
    if(i%2 == (n-1)%2) ans += scard.at(i);
    if(i%2 != (n-1)%2) ans -= scard.at(i);
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 3644