akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize(3)
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<utility>
#include<iterator>
#include<iomanip>
using namespace std;
#define lowbit(x) x&(-x)
typedef long long ll;
typedef long double lb;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const int maxn = 5005;
int bit[maxn];
int read();
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int ans = 0;
    for(int i = 1;i<=n;i++)
    {
    	if(i<=9||(i>=100&&i<=999)||(i>=10000&&i<=99999))
    	{
    		ans++;
    	}
    }
   cout<<ans<<endl;


    return 0;
}
inline int read()
{
	int x = 0,w = 0;
	char ch = 0;
	while(!isdigit(ch)){
		w |= (ch == '-');
		ch = getchar();
	}
	while(isdigit(ch)){
		x = (x<<3)+(x<<1)+(ch^48);
		ch = getchar();
	}
	return w?-x:x;
}


Measured memory_bytes: 256
import numpy as np
N, M = map(int, input().split())
H = list(map(int, input().split()))
result = np.array([1]*N)
for i in range(M):
    A, B = map(int, input().split())
    if H[A-1]>H[B-1]:
        result[B-1] = 0
    elif H[A-1]<H[B-1]:
        result[A-1] = 0
    else:
        result[A-1] = 0
        result[B-1] = 0
print(result.sum())

Measured memory_bytes: 38588
a = gets.to_i
a1 = a / 100
a2 = a % 100

if a1.between?(0,99) == true && a2.between?(1,12) == true
    if a1.between?(1,12) == true && a2.between?(0,99) == true
        puts "AMBIGUOUS"        
    else
        puts "YYMM"
    end
elsif a1.between?(1,12) == true && a2.between?(0,99) == true
    puts "MMYY"
else
    puts "NA"
end


Measured memory_bytes: 1788
n = int(input())
alphabetMin = [50]*(26)
for i in range(n):
    tmp = list(input())
    for j in range(ord('a'), ord('z') + 1):
        cnt = tmp.count(chr(j))
        if cnt < alphabetMin[j - ord('a')]:
            alphabetMin[j - ord('a')] = cnt
ans = ''
for i, alpha in enumerate(alphabetMin):
    ans += chr(ord('a') + i) * alpha
print(ans)


Measured memory_bytes: 9092
#include<cstdio>
bool a[500000];
int main(void)
{
    int n,k,t,cnt=0,num=0;
    scanf("%d %d" ,&n,&k);
    for(int i=0;i<n;i++)
        scanf("%d" ,&t);
    while(a[n-1]==false){
        for(int i=cnt;i<cnt+k;i++)
            a[i]=true;
        cnt+=k-1;
        num++;
    }
    printf("%d" ,num);
    return 0;
}


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


int main(){

    string S;
    cin >> S;

    
    bool accept = true;

    if( S[0] == 'A' && 'a' <= S[1] && 'a' <= S.back() ){
        int num_C = 0;
        for( int i = 2; i < S.size()-1; i++ ){
            if( S[i] == 'C' ) num_C++;
        }
        if( num_C != 1 ) accept = false;
    }else accept = false;

    if( accept ) cout << "AC" << endl;
    else cout << "WA" << endl;

    return 0;

}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	set<char> s;
	for (int i = 0; i < N; ++i) {
		char x;
		cin >> x;
		s.insert(x);
	}
	if (s.size() == 3) {
		cout << "Three" << endl;
	}
	else {
		cout << "Four" << endl;
	}
}


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



ll N, T;


/*
  DP
  料理nまで で (時間 t、最高スコア)
*/


int d[3001];

struct food {
	int time;
	int score;
};
vector<food> f;



void calc( int n ){
	/* 0..n-1 までの料理の中から時間tまでに選ぶ場合のスコアが d[t]
	   0..n   までの料理の中から時間tまでに選ぶ場合のスコアが dd[t]
	   dd[t] = max( d[t], d[t-f[n].time] + f[n].score )
	*/
	
	for ( int t = T; t >= 1; t-- ){
		if ( t-f[n].time >= 1 ){
			d[t] = max( d[t], d[t-f[n].time] + f[n].score );
		}
	}
	d[1] = max( d[1], f[n].score ); // f[n] だけを食べた場合
}


int main(){
	cin >> N >> T;
	
	f.resize(N);
	for ( int i = 0; i < N; i++ ){
		cin >> f[i].time >> f[i].score;
	}
	
	// 時間が大きいものを先頭に
	sort(f.begin(), f.end(), [](food &l, food &r){ return -l.score-l.time*6000 < -r.score-r.time*6000; });
	
	for ( int n = 0; n < N; n++ ){
		calc( n );
	}
	
	//for ( int t = 1; t <= T; t++ ){
	//	cout << "d:" << t << " " << d[t] << endl;
	//}
	
	int best_score = 0;
	for ( int t = 1; t <= T; t++ ){
		best_score = max( best_score, d[t] );
	}
	
	cout << best_score << endl;
	
	return 0;
}



Measured memory_bytes: 256
import numpy as np

n,a = map(int, input().split())
X = np.array(input().split(), dtype=np.int64)
Y = X-a
U = max(X.max(), a) * n
dp = np.zeros(2*U+1, dtype=np.int64)
dp[U] = 1
for i in range(n):
  y = Y[i]
  if y >= 0:
    dp[y:] = dp[y:] + dp[:2*U+1-y]
  else:
    dp[:y] = dp[:y] + dp[-y:]
print(dp[U]-1)

Measured memory_bytes: 12492
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
using namespace std;
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
typedef long long ll;
typedef unsigned long long ull;
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<double,double>
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-8;
const int MAX=5e5+10;
const ll mod=1e9+7;
int main()
{
	int n,i,t,x,y,px,py,ok,pt;
	while(~scanf("%d",&n))
	{
		pt=px=py=0;
		ok=1;
		for(i=0;i<n;i++)
		{
			scanf("%d%d%d",&t,&x,&y);
			int temp=(t-pt)-(abs(x-px)+abs(y-py));
			if(temp<0) ok&=0;
			else if(temp%2==0) ok&=1;
			else ok&=0;
			px=x;
			py=y;
			pt=t;
		}
		ok?puts("Yes"):puts("No");
	}
	return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007; // 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const ld PI = acos((ld)-1);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
  return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
  os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}

template<typename T>
struct UnionFind {
	vector<T> Parent;
 
	UnionFind(T N) {
		Parent = vector<T>(N, -1);
	}
 
	T root(T A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	T size(T A) {
		return -Parent[root(A)];
	}
 
	bool connect(T A, T B) {
		A = root(A);
		B = root(B);
		if (A == B) return false;
		if (size(A) < size(B)) swap(A, B);
		Parent[A] += Parent[B];
		Parent[B] = A;
 
		return true;
	}

    bool same(T A,T B){
      return root(A)==root(B);
    }
};

signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,m;cin>>n>>m;
  UnionFind<ll> u(n);
  rep(i,0,m){
    int a,b;cin>>a>>b;
    --a;--b;
    u.connect(a,b);
  }

  ll ans=0;
  rep(i,0,n)chmax(ans,u.size(i));
  cout<<ans<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 4776
#include <iostream>

using namespace std;

int main()
{
    int a , b , x;
    cin>> a >> b;
    if (a==b) {
        cout<< 2*a;
    }
    else {
        if (a>b) {
            x = a+a-1 ;
            cout<< x;
        }
        else {
            x = b+b-1;
            cout<< x;
        }

    }
    return 0;
}


Measured memory_bytes: 3564
import java.util.Scanner;
public class Main {
 
	public static void main(String[] args) {
		  Scanner sc = new Scanner(System.in);	         
          int X = sc.nextInt();
		  int a = X/500;
      	  int b = X%500;
      	  int c = (b/5);
      System.out.println((a*1000)+(c*5));
    }
}

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

int n;

int C[100000];

void CountingSort(int,short*,short*);

int main(){
  int i,k=0;
  unsigned short *A, *B;
  scanf("%d",&n);

  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(k<=A[i]){
      k=A[i];
    }
  }

  CountingSort(k,A,B);
  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[n]);
}


void CountingSort(int k,short* A,short* B){
  int i,j;
  for(i=0;i<=k;i++)C[i]=0;

  for(j=0;j<n;j++){
    C[A[j]]++;
    //printf("%d %d\n",C[A[j]],A[j]);
  }
  
  
  for(i=1;i<=k;i++)C[i]=C[i]+C[i-1];

  
  for(j=n;j>=0;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  
}



Measured memory_bytes: 9548
#include <bits/stdc++.h>
using namespace std;
#define LOG(k,m) (cout << k << ":" << m << endl)
//#define LOG(k,m) (void)0

int main(){

    string S;
    cin >> S;
    long long int l=S.length();
    for(long long int i=0;i<l;i++){
        if(S[i]=='?')S[i]='D';
    }
    cout << S << endl;

    return 0;
}


Measured memory_bytes: 3756
#include <algorithm>
#include <bits/stdc++.h>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
using namespace std;
// const int MAX = 1e6 + 1;
// typedef vector<vector<ll>> matrix;
//  const ll PRIME = 1e9 + 7;
// typedef pair<int,pair<int,int> >  ppi;
// const ll MAX = 1e6 + 1;

void solve()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int ans= max(a*c , a*d);
  ans= max(ans , b*c);
  ans= max(ans, b*d);
  cout<<ans;

}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    // int k = 1;
    // cin >> t;
    t = 1;
    while (t--)
    {
        // cout << "Case #" << k++ << ": ";
        solve();
    }
}


Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
ll n, h;
vector<ll> a;
vector<ll> b;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>h;
    vector<bool> used(n,false); 
    for (int i = 0; i < n; i++)
    {
        ll tempa, tempb;
        cin >> tempa>>tempb;
        a.push_back(tempa);
        b.push_back(tempb);    
    }
    sort(ALL(a));
    sort(ALL(b));
    ll maxa=a[n-1];
    ll count=0;
    ll score=0;
    int j=n-1;
    while(score<h&&j>=0){
        if(b[j]<=maxa){
            break;
        }
        score+=b[j];
        j--;
        count++;
    }
    if(score<h){
        count+=(h-score+maxa-1)/maxa;
    }
    cout << count << "\n";
}


Measured memory_bytes: 2036
n = int(input())
while n != 0:
 A = 0
 B = 0
 for i in range(n):
  a, b = map(int, input().split())
  if a > b:
   A += (a + b)
  elif a < b:
   B += (a + b)
  else:
   A += a
   B += b
 print("{0} {1}".format(A, B))
 n = int(input())

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

int main() {
	int h,m,s;
	cin >> s;

	h = s / 3600;
	s = s % 3600;
	m = s / 60;
	s = s % 60;
	cout << h<<":"<< m <<":"<< s << endl;
	return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int parent(int i) {return i/2;};
int left(int i) {return 2*i;};
int right(int i) {return 2*i+1;};
int main(){
  int H,A[250];
  scanf("%d",&H);
  REP(i,H) scanf("%d",&A[i]);
  REP(i,H){
    printf("node %d: key = %d, ",i+1,A[i]);
    if(parent(i+1)>=1) {
      printf("parent key = %d, ",A[parent(i+1)-1]);
    }
    if(left(i+1)<=H) {
      printf("left key = %d, ",A[left(i+1)-1]);
    }
    if(right(i+1)<=H) {
      printf("right key = %d, ",A[right(i+1)-1]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 3200
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    string win;

    cin >> a >> b;
    if (a == b) win = "Draw";
    else if (a == 1) win = "Alice";
    else if (b == 1) win = "Bob";
    else if (a > b) win = "Alice";
    else win = "Bob";
    cout << win << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
using ll=long long;
int main(){
  ll n;cin>>n;
  vector<int> name;
  ll c=1;
  for(int i=0;n!=0;n/=26){
    int d=n%26;
    if(d==0){
      d=26;
      n--;
    }
    name.push_back(d);
  }
  reverse(name.begin(),name.end());
  for(auto v:name){
    cout<<char(v+96);
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

    string S;
	cin >> S;
    int count = 0;
    int cmax = 0;
	for (int i=0; i < S.size(); i++) {
        if (S[i] == 'A' || S[i] == 'G' || S[i] == 'C' || S[i] == 'T') {
            count++;
            cmax = max(cmax, count);
        } else {
            count = 0;
        }
    }
	cout << cmax << "\n";
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y, h;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++)
		sum *= (x--);
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}
#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n, a;
	cin >> n >> a;
	n %= 500;
	if (n <= a) cout << "Yes\n";
	else cout << "No\n";
	getchar(); getchar();
}

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

int main() {
	int N, A;
	int max = 31;  
    cin >> N;
	for (int i = 0; i < N; i++) {
		int c = 0;
        cin >> A;
		while(A % 2 == 0) {//どこまで割れるのか
        	c++;
        	A /= 2;
        }
        if (c < max) {
        	max = c;
        }
    }
cout << max << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  long long n,k,x[100000],ans=1000000000;
  cin >> n >> k;
  for(int i=0; i<n; i++) {
    cin >> x[i];
  }
  for(int i=0; i<n-k+1; i++) {
    ans=min(ans,abs(x[i+k-1]-x[i])+min(abs(x[i]),abs(x[i+k-1])));
  }
  cout << ans << endl;
}

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

namespace paiza2
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Int32.Parse(Console.ReadLine());
            string read = Console.ReadLine();
            string[] split = read.Split(' ');
            int[] a = new int[N];
            for (int c = 0; c < N; c++)
            {
                a[c] = Int32.Parse(split[c]);
            }
            int n = bibunshite0(a);
            int a2 = 0;
            for (int c = 0; c < a.Length; c++)
                a2 += a[c] * a[c];
            int a1 = 2 * a.Sum() * n;
            int a0 = a.Length*n * n;
            Console.WriteLine(a2-a1+a0);
        }

        static int bibunshite0(int[] a)
        {
            double d_output = a.Average();
            int output = (int)Math.Round(d_output);
            return output;
        }

    }
}


Measured memory_bytes: 13268
//2017-10-18
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define N (100+2)

char mp[N][N];
short f[N][N][N][N], sumr[N][N], sumc[N][N];

inline short Calc(short *sum, int l, int r){
	if(l > r) return 0;
//	printf("add = %d\n", sum[r] - sum[l-1]);
	return sum[r] - sum[l-1];
}

inline void Add(short &me, short add){
	if(me < add) me = add;
}

int main(){
	int n, m, ex, ey;

	scanf("%d%d", &n, &m);
	For(i, 1, n){
		scanf("%s", mp[i]+1);
		For(j, 1, m){
			sumr[i][j] = sumr[i][j-1] + (mp[i][j]=='o');
			if(mp[i][j] == 'E') ex = i, ey = j;
		}
	}
	For(i, 1, m) For(j, 1, n) sumc[i][j] = sumc[i][j-1] + (mp[j][i]=='o');

//	printf("ex = %d ey = %d\n", ex, ey);

	int ans = 0, A = ex-1, B = n-ex, C = ey-1, D = m-ey;
	int me, nxt;

	For(a, 0, A) For(b, 0, B) For(c, 0, C) For(d, 0, D){
		ans = max(ans, me = f[a][b][c][d]);
	//	printf("f[%d][%d][%d][%d] = %d\n", a, b, c, d, f[a][b][c][d]);

		nxt = 0;
		if(a < A){
	//		puts("UP");
			if(ex-a-1 > b) nxt = Calc(sumr[ex-a-1], max(d+1,ey-c), min(m-c,ey+d));
			Add(f[a+1][b][c][d], nxt+me);
		}
		
		nxt = 0;
		if(b < B){
	//		puts("DOWN");
			if(ex+b+1 < n-a+1) nxt = Calc(sumr[ex+b+1], max(d+1,ey-c), min(m-c,ey+d));
			Add(f[a][b+1][c][d], nxt+me);
		}

		nxt = 0;
		if(c < C){
	//		puts("LEFT");
			if(ey-c-1 > d) nxt = Calc(sumc[ey-c-1], max(b+1,ex-a), min(n-a,ex+b));
			Add(f[a][b][c+1][d], nxt+me);
		}

		nxt = 0;
		if(d < D){
	//		puts("RIGHT");
			if(ey+d+1 < m-c+1) nxt = Calc(sumc[ey+d+1], max(b+1,ex-a), min(n-a,ex+b));
			Add(f[a][b][c][d+1], nxt+me);
		}
	//	puts("====================="); puts("");
	}

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

	return 0;
}

Measured memory_bytes: 203008
#include <stdio.h>

int main(){
  int S,h,m,s,x;
  scanf("%d", &S);
  h = S/3600;
  x = S%3600;
  m = x/60;
  s = x%60;

  printf("%d:%d:%d\n", h, m, s);
  return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int P = s.nextInt();
			final int Q = s.nextInt();
			final int R = s.nextInt();

			System.out.println(P + Q + R - Math.max(Math.max(P, Q), R));
		}
	}
}


Measured memory_bytes: 25044
import java.util.*;
import java.lang.*;

class Process {
    String id;
    int time;
    Process(String x, int t) {
        id = x;
        time = t;
    }
}


public class Main {
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int qtm = sc.nextInt();
        int count = 0;
        ArrayList<Process> queue = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            queue.add(new Process(sc.next(), sc.nextInt()));
        }

        while(true) {
            if (queue.isEmpty()) {
                break;
            }
            Process element = queue.get(0);
            if (element.time > qtm) {
                element.time -= qtm;
                count += qtm;
                queue.remove(0);
                queue.add(element);
            } else {
                count += element.time;
                queue.remove(0);
                System.out.println(element.id + " " + count);
            }
        }
    }
}


Measured memory_bytes: 71764
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
  ll d,s;
  double t;
  cin>>d>>t>>s;
  double t1=(double)d/(double)s;
  if(t>=t1)
    cout<<"Yes\n";
  else
    cout<<"No\n";
}
  

Measured memory_bytes: 3740
import java.util.Scanner;

public class Main {
	static long MOD = 1000000007;
	static long modFact(int n){
		long ret = 1;
		for(int i = 2 ; i <= n ; ++i){
			ret = ret * i;
			ret = ret % MOD;
		}
		return ret;
	}
	static long modpow(long n, long y){
		if(y == 0){
			return 1;
		}else if(y == 1){
			return n % MOD;
		}else{
			if(y % 2 == 0){
				long r = modpow(n , y / 2);
				return (r * r) % MOD;
			}else{
				long r = modpow(n , y / 2);
				long r2 = (r * r) % MOD;
				return (r2 * n) % MOD;				
			}
		}
	}
	static long modinv(long n){
		return modpow(n , MOD - 2);
	}
	static long modComb(int n , int k){
		long a1 = modFact(n);
		long a2 = modFact(k);
		long a3 = modFact(n - k);
//		System.out.println(a1+" "+a2+" "+a3);
//		System.out.println(modinv(a2 * a3));
		return (a1 * (modinv((a2 * a3) % MOD)) ) % MOD;
	}
	static long solve(int X , int Y){
		int xx = - X + 2 * Y;
		int yy = 2 * X - Y;
		if(xx < 0 || yy < 0 || xx % 3 != 0 || yy % 3 != 0){
			return 0;
		}
		xx = xx / 3;
		yy = yy / 3;
//		System.out.println(xx+" "+yy);
		return modComb(xx+ yy , xx);
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		System.out.println(solve(X , Y));
	}
}


Measured memory_bytes: 22608
#include <iostream>
#include <ios>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

using i64 = long long;
using P = pair<i64, i64>;

int main(){
    i64 n, m;
    cin >> n >> m;
    priority_queue<i64> pq;
    for(int i = 0; i < n; ++i){
        i64 a;
        cin >> a;
        pq.push(a);
    }
    for(int i = 0; i < m; ++i){
        i64 t = pq.top(); pq.pop();
        t /= 2;
        pq.push(t);
    }
    i64 ans = 0;
    for(int i = 0; i < n; ++i){
        ans += pq.top(); pq.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 1400
n, a, b = (int(i) for i in input().split())
ans = 0
for i in range(1,n+1):
    cur = i
    cur_sum = 0
    while cur > 0:
        cur_sum += cur%10
        cur //= 10
    if a <= cur_sum <= b:
        ans += i
print(ans)

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

LL N,M;
const int mod = 1e9+(7.1);
const int maxp = 1e5;
const int maxn = 150000;
map<int,int> prime;
LL C[maxp];

LL fac[maxn];
LL ifac[maxn];


int modpow(int n,int p){
    if(p == 0) return 1;
    LL ret_val = modpow(n,p/2);
    ret_val = (ret_val*ret_val)%mod;
    if(p & 1) ret_val = (ret_val*n)%mod;
    return (int)ret_val;
}

int inv(int n){
    return modpow(fac[n],mod-2);
}
void init(){
    fac[0] = 0;
    fac[1] = 1;
    _for(i,2,maxn){
        fac[i] = (i*fac[i-1])%mod;
    }
}

int cal(int q,int r){
    if(q <= 0 || r <= 0 || q-r <= 0) return 1;
    LL res = ((LL)fac[q]*(LL)inv(r))%mod;
    res = (res*inv(q-r))%mod;
    return (int)res;
}



int main()
{
    init();
    cin >> N >> M;
    if(M == 1) {printf("1\n");return 0;}
    _for(i,2,maxp){
        while(!(M%i)){
            prime[i]++;
            M/=i;
        }
    }
     if(M!=1){
        prime[M]++;
    }


    LL ans = 1;
    for(auto a:prime){
        int k = a.second;
        //calculate  C(N-1+k,k)
        //cout << N-1+k << endl;
        ans = (ans*(cal(N-1+k,k)%mod))%mod;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>

#include <queue>
#include <algorithm>

using namespace std;

#define NMAX 1000

static char mat[NMAX + 10][NMAX + 10];
static bool mark[NMAX + 10][NMAX + 10];

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) scanf("%s", mat[i] + 1);
    struct Point {
        int x, y, s = 0;
    };
    queue<Point> q;
    for (int x = 1; x <= n; x++) for (int y = 1; y <= m; y++) if (mat[x][y] == '#') {
        q.push({x, y});
        mark[x][y] = true;
    }
    int ans;
    while (!q.empty()) {
        auto u = q.front();
        ans = u.s;
        q.pop();
        constexpr int dx[] = {-1, 1, 0, 0};
        constexpr int dy[] = {0, 0, -1, 1};
        for (int i = 0; i < 4; i++) {
            int tx = u.x + dx[i], ty = u.y + dy[i];
            if (1 <= tx && tx <= n && 1 <= ty && ty <= m && !mark[tx][ty]) {
                mark[tx][ty] = true;
                q.push({tx, ty, u.s + 1});
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}



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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int m1= cin.Int();
			int d1 = cin.Int();
			int m2 = cin.Int();
			int d2 = cin.Int();
			if (m1 != m2) {
				Console.WriteLine(1);
			} else {
				Console.WriteLine(0);
			}
		}
	}


	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

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; }
const ll INF = 1e9;
const long long INFL = 1LL<<60;

const int MAX_V = 205;

int d[MAX_V][MAX_V];
int V;

void warshall_floyd() {
  for (int k = 0; k < V; k++) {
    for (int i = 0; i < V; i++) {
      if (d[i][k] == INF) continue;
      for (int j = 0; j < V; j++) {
        if (d[k][j] == INF) continue;
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main() {
  int N, M, R;
  cin >> N >> M >> R;
  V = N;
  vector<int> r(R);
  rep(i, R) {
    cin >> r[i];
    r[i]--;
  }
  rep(i, N) rep(j, N) d[i][j] = INF;
  rep(i, N) d[i][i] = 0;
  rep(i, M) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    d[a][b] = c;
    d[b][a] = c;
  }

  warshall_floyd();

  sort(ALL(r));

  ll ans = INFL;

  do {
    ll tmp = 0;
    rep(i, R-1) {
      tmp += d[r[i]][r[i+1]];
    }
    chmin(ans, tmp);
  } while(next_permutation(ALL(r)));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 2003;
int n,k,ans;
int u[MaxN],v[MaxN];
vector<int> e[MaxN];

int solve(int x,int fa,int d) {
    int ret=d>(k/2);
    for (int i:e[x]) if (i!=fa)
        ret+=solve(i,x,d+1);
    return ret;
}

int main() {
    scanf("%d%d",&n,&k);
    for (int i=1;i<n;++i) {
        scanf("%d%d",u+i,v+i);
        e[u[i]].push_back(v[i]),e[v[i]].push_back(u[i]);
    }
    ans=n;
    if (k%2==1) {
        for (int i=1;i<n;++i) {
            int x=solve(u[i],v[i],0)+solve(v[i],u[i],0);
            ans=min(ans,x);
        }
    } else {
        for (int i=1;i<=n;++i) {
            int x=solve(i,i,0);
            ans=min(ans,x);
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

ll MOD = 1000003ll;

ll power(ll x, ll e) {
  ll v = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) {
      v = v * x % MOD;
    }
    x = x * x % MOD;
  }
  return v;
}

ll inverse(ll x) {
  return power(x, MOD - 2);
}

vector<ll> fact, factInv;
void initFact(int N) {
  fact.resize(N + 1);
  factInv.resize(N + 1);
  fact[0] = 1;
  for (int i = 1; i <= N; i++) {
    fact[i] = fact[i - 1] * i % MOD;
  }
  factInv[N] = inverse(fact[N]);
  for (int i = N - 1; i >= 0; i--) {
    factInv[i] = factInv[i + 1] * (i + 1) % MOD;
  }
}

ll f(ll x, ll d, ll n) {
  if (d == 0) {
    return power(x, n);
  }
  if (d == 1) {
    if (MOD <= x + n - 1) return 0;
    return fact[x + n - 1] * factInv[x - 1] % MOD;
  }
  return f(x * inverse(d) % MOD, 1, n) * power(d, n) % MOD;
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  initFact(MOD - 1);
  int Q;
  while (cin >> Q) {
    for (int q = 0; q < Q; q++) {
      ll x, d, n;
      cin >> x >> d >> n;
      cout << f(x, d, n) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 16512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 20
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P; 
#define INF 100000000
const int MAX = 1000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算 COMinit()を先に使用すること
long long COM(int n, int k){
	if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    REP(i,n){
        cin>>a[i];
    }
    sort(ALL(a));
    COMinit();
    ll ans=0;
    if(k!=1){
        REP(i,n-k+1){
        ans+=(ll)((a[n-1-i]-a[i])*COM(n-1-i,k-1));
        ans%=MOD;
        if(ans<0) ans=(ans+MOD)%MOD;
        }
    }
    
    OUT(ans);
	return 0;
}

Measured memory_bytes: 24064
import numpy as np
N = int(input())
A = np.array(input().split(), dtype = np.int32)
B = np.array(input().split(), dtype = np.int32)
ans = 0
for i in range(29)[::-1]:
    res = 0
    p = 1<<i
    A&=(p*2-1)
    B&=(p*2-1)
    B.sort()
    i, j, k = [np.searchsorted(B, t-A).sum() for t in [p, p*2, p*3]]
    res = (i+k-j)
    if (N-res)%2:
        ans+=p
print(ans)






Measured memory_bytes: 35920
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	string S;
	cin >> S;
    int res, size;
    size = S.size();
    res = 0;
    for (int i = 0; i < size; i++) {
        int resTmp = 0;
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
            resTmp++;
            int i_C = i;
            while (true) {
                i_C++;
                if (i_C >= size) {
                    break;
                }
                if (S[i_C] == 'A' || S[i_C] == 'C' || S[i_C] == 'G' || S[i_C] == 'T') {
                    resTmp++;
                } else {
                    break;
                }
            }
            if (res < resTmp) {
                res = resTmp;
            }
        }
        
    }
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
//File Name: arc073_E.cpp
  //Created Time: 2017年05月14日 星期日 20时13分47秒
                                   
#include <bits/stdc++.h>
#define LL long long
#define pii pair<int,int>
#define fir first
#define sec second
using namespace std;
const int MAXN = 200000 + 5;
const int INF = (int)1e9 + 5;
pii a[MAXN];
set<pii> rem;
LL solve(const int n){
	sort(a,a + n);
	int b_mi(a[0].fir),b_ma(a[n - 1].fir);
	int r_mi(INF),r_ma(0);
	for(int i(0);i<n;++i){
		r_mi = min(r_mi,a[i].sec);
		r_ma = max(r_ma,a[i].sec);
	}
	LL res = (LL)(b_ma - b_mi) * (r_ma - r_mi);
	LL len = r_ma - b_mi;
	rem.insert(pii(a[0].sec,n));
	for(int i(1);i<n;++i)
		rem.insert(pii(a[i].sec,i));
	while(true){
		int tmp = (*rem.rbegin()).fir - (*rem.begin()).fir;
		res = min(res,len * tmp);
		auto cur = *rem.rbegin();
		rem.erase(cur);
		if(cur.sec == n) break;
		rem.insert(pii(a[cur.sec].fir,n));
	}
	return res;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i(0);i<n;++i){
		scanf("%d %d",&a[i].fir,&a[i].sec);
		if(a[i].fir > a[i].sec) 
			swap(a[i].fir,a[i].sec);
	}
	printf("%lld\n",solve(n));
	return 0;
}


Measured memory_bytes: 11264
#include<stdio.h>
#include<string.h>
int main()
{
  char s[12];
  scanf("%s",s);
  int l=strlen(s);
  if(l%2)
  {
    printf("No");return 0;}
  for(int i=0;i<l;i++)
  {
    if(i%2)
    {
      if(s[i]!='i')
      {
        printf("No");
        return 0;
      }
    }
    else
    {
        if(s[i]!='h')
      {
        printf("No");
        return 0;
      }
    }
  }
    printf("Yes");  
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int A =  scan.nextInt();
        int B =  scan.nextInt();
        if(A==1&&B==2)System.out.printf("3");
        if(A==1&&B==3)System.out.printf("2");
        if(A==2&&B==3)System.out.printf("1");
        if(A==2&&B==1)System.out.printf("3");
        if(A==3&&B==1)System.out.printf("2");
        if(A==3&&B==2)System.out.printf("1");
    }
}

Measured memory_bytes: 21588
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(void){
    int A1,A2,A3;
    int result=0;
    cin>>A1>>A2>>A3;

    int a[]={A1,A2,A3};
    if(A1==A2==A3){
        cout<<0<<endl;
    }else{
        sort(a,a+3);
        result+=a[1]-a[0];
        result+=a[2]-a[1];

        cout<<result<<endl;
    }
    
    return 0;
    
}

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

typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

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

#define DEBUG

void solve(long long N, std::vector<long long> A){
    // 可能かどうかだけさきにみる
    ll current = -1;
    for(auto iter: A){
        if(iter <= current + 1){
            // ok
        }else{
            // 不可能
            cout << -1 << endl;
            return;
        }
        current = iter;
    }

    // 個数をもとめる
    ll res = 0;
    for(int i=0; i < A.size() - 1; i++){
        if(A.at(i) < A.at(i+1)){
            // 増加してるならよいい
        }else{
            // iが増加しているところのうち末尾
            res += A.at(i);
        }
    }
    res += A.back();

    cout << res << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

vector<int>a(200000);
int n;
int d_4 = 0;
int odds = 0;
bool existsD_2 = false;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a.at(i);

    for (int i = 0; i < n; ++i)
    {
        if (a.at(i)%4==0) {
            d_4++;
        } else if(a.at(i)%2==0){
            existsD_2 = true;
        } else {
            odds++;
        }
    }

    if (existsD_2)
    {
        if (odds <= d_4) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        if (odds <= d_4 + 1) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int N = scanner.nextInt();
            long X = scanner.nextLong();
            long[] as = new long[N];
            long[] ps = new long[N];
            as[0] = 1;
            ps[0] = 1;
            for (int i = 1; i < N; i++) {
                as[i] = as[i - 1] * 2 + 3;
                ps[i] = ps[i - 1] * 2 + 1;
            }
            System.out.println(f(N, X, as, ps));
        }
    }

    static long f(int n, long x, long[] a, long[] p) {
        if (n == 0) {
            return x > 0 ? 1 : 0;
        }
        long anp = a[n - 1];
        long pnp = p[n - 1];
        if (x <= anp + 1) {
            return f(n - 1, x - 1, a, p);
        }
        if (x == x + anp) {
            return pnp;
        }
        if (x <= 2 * anp + 2) {
            return pnp + 1 + f(n-1, x - anp - 2, a, p);
        }
        return 2 * pnp + 1;
    }

    static class Pair {
        final int kind;
        final long point;

        Pair(int kind, long point) {
            this.kind = kind;
            this.point = point;
        }
    }

}


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

int main(){
	string s; cin >> s;
	for(int i = 0; i <= 2; i++){
		if(s[i] == '7'){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;
int main(){
  ll d,t,s;
  cin >> d >> t >> s;
  if(t * s >= d){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

using namespace std;

int change_pixel(int v, string &str)
{
    int nv = v;
    const int d[7][7] =
        {
            { 8,  9,  3,  4,  5,  0,  1},
            { 9, 10,  4,  5,  6,  1,  2},
            {12, 13,  7,  8,  9,  3,  4},
            {13, 14,  8,  9, 10,  4,  5},
            {14, 15,  9, 10, 11,  5,  6},
            {16, 17, 12, 13, 14,  8,  9},
            {17, 18, 13, 14, 15,  9, 10}
        };

    for (int i = 0; i < 7; i++) {
        int bit = 0;
        nv &= ~(1<<d[i][3]);
        for (int j = 0; j < 7; j++) {
            bit |= (v >> d[i][j] & 1) ? (1<<j) : 0;
        }        
        nv |= (1 << d[i][3])*(str[bit] - '0');
    }
    return nv;
}

bool is_idempotent(string &str)
{
    for (int i = 0; i < (1<<19); i++) {
        int before = i, after;
        before = change_pixel(before, str);
        after  = change_pixel(before, str);
        if ((before >> 9 & 1) != (after >> 9 & 1)) {
            return false;
        }
    }
    return true;
}

int main()
{
    string str;
    while (cin >> str, str != "#") {
        cout << (is_idempotent(str) ? "yes" : "no") << endl;
    }
    return 0;
}

Measured memory_bytes: 1180
def resolve():
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    re = 1000
    for a in range(1, (n//2)+1):
        b = n - a
        sumnum = 0
        while a >= 1:
            sumnum += a % 10
            a = a //10
        while b >= 1:
            sumnum += b % 10
            b = b //10
        if re > sumnum:
            re = sumnum

    print(re)
resolve()

Measured memory_bytes: 38896
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int mod = (int) 1e9 + 7;

int mul(int a, int b) {
  return (long long) a * b % mod;
}

void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

const int maxn = (int) 1e5 + 5;
int n;
string s;
char tmp[maxn];

int read() {
  if (scanf("%s", tmp) < 1) {
    return false;
  }
  s = tmp;
  n = sz(s);
  return true;
}

int a[maxn];
int sum[maxn];
int dp[maxn];

void solve() {
  for (int i = 0; i < n; i++) {
    a[i] = (s[i] - 'a' + 1);
  }
  {
    bool eq = false;
    for (int i = 0; i + 1 < n; i++) {
      if (a[i] == a[i + 1]) {
        eq = true;
        break;
      }
    }
    if (!eq) {
      printf("1\n");
      return;
    }
  }
  sum[0] = 0;
  for (int i = 0; i < n; i++) {
    sum[i + 1] = (sum[i] + a[i]) % 3;
  }
  int lst[3] = {-1, -1, -1};
  dp[0] = 1;
  for (int i = 0, j = 0; i < n; i++) {
    if (i && a[i - 1] == a[i]) {
      while (j < i) {
        lst[sum[j]] = j;
        j++;
      }
    }
    dp[i + 1] = dp[i];
    int x = (a[i] == 1 ? 2 : 1);
    x = (sum[i + 1] + 3 - x) % 3;
    if (lst[x] != -1) {
      add(dp[i + 1], dp[lst[x]]);
    }
    if (!sum[i + 1] && i + 1 < n) {
      add(dp[i + 1], 1);
    }
  }
  printf("%d\n", dp[n]);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 1664
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.28 21:03:06
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int d;
    cin >> d;
    vector< int > c(26);
    for (int i = 0; i < 26; i++) {
        cin >> c[i];
    }
    vector < vector< pair< int, int > >> p(d, vector< pair< int, int > >(26));
    vector< vector< int > > s(d, vector< int >(26));
    for (int i = 0; i < d; i++) {
        for (int j = 0; j < 26; j++) {
            cin >> s[i][j];
            p[i][j] = make_pair(s[i][j], j);
        }
        sort(p[i].begin(), p[i].end());
    }
    for (int i = 0; i < d; i++) {
        cout << p[i][25].second + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3772