akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

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

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

    ll ans = 1;
    for(int i = 0; i < N; ++i) {
        ll t;
        cin >> t;
        ll tmp = gcd(ans, t);
        ans *= t / tmp;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll A, B, X;
    in3(A, B, X);
    ll ans=B/X - A/X;
    if(!(A%X))ans++;
    put(ans);
    return 0;
}


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



int main() {
    string s, t, u;
    int a, b;

    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if (u == s) {
        a--;
    } else if (u == t) {
        b--;
    }

    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;

int a,b,c;

int main(){
	cin >> a >> b >> c;
	if(a+ b >= c)cout << "Yes" <<endl;
	else cout << "No" <<endl;
}

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

using namespace std;

bool
is_seq_set(int a, int b, int c) {
  if (a+2==c && b+1==c)
    return true;
  return false;
}

bool
is_same_set(int a, int b, int c) {
  if (a==c && b==c)
    return true;
  return false;
}

bool
is_good_set(int a, int b, int c) {
  return is_seq_set(a,b,c) || is_same_set(a,b,c);
}

bool
has_satisfy_set(int card[]) {
  return
    is_good_set(card[0], card[1], card[2]) &&
    is_good_set(card[3], card[4], card[5]) &&
    is_good_set(card[6], card[7], card[8]);
}

bool
check_all(int card[9]) {
  int s = 0;
  sort(card, card+9);
  do {
    bool has_satisfy = has_satisfy_set(card);
    if (has_satisfy) {
      /*
      cout << "found satisfied card " << endl;
      for (int i=0; i<9; ++i) {
	auto c = card[i];
	cout << c << " ";
      }
      cout << endl;
      */
      return true;
    }

    // s++;
  } while (next_permutation(card, card+9));
  // cout << "s = " << s << endl;
  return false;
}

int
main() {
  int n;
  cin >> n;
  for (int i=0;i<n; ++i) {
    int card[9];
    for (int j=0; j<9; ++j) {
      cin >> card[j];
      // cout << card[j] << " ";
    }
    // cout << endl;
    string color;
    int shift[] {0, 10, 20};
    for (int j=0; j<9; ++j) {
      cin >> color;
      // cout << color << " ";
      int idx = 0;
      switch(color[0]) {
      case 'R': idx = 0; break;
      case 'G': idx = 1; break;
      case 'B': idx = 2; break;
      default: assert(0);
      }
      card[j] += shift[idx];

      // cout << card[j] << " ";
    }
    // cout << endl;
    
    cout << check_all(card) << endl;
    // cout << "Not found ...." << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3124
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;


ll substep(ll stairs);

int main()
{
    
    ll N,K;
    cin >> N >> K;
    vector<ll> x(N);
    for(ll i=0;i<N;i++) cin >> x[i];
    
    ll time=1000000000;
    ll tmp;
    for(ll i=0;i<N-K+1;i++){
        ll l = x[i] , r = x[i+K-1];
        if(l * r < 0){
            tmp = 2 * min( abs(l) , abs(r) ) + max( abs(l) , abs(r) );
            time = min(time,tmp);
        } else {
            tmp = max( abs(l) , abs(r) );
            time = min(time,tmp);
        }
    }
    
    cout << time << endl;
    
    
    return 0;
}


Measured memory_bytes: 1024
count = 0
def insertsort(array):
    for i in range(1,len(array)):
        temp = array[i]
        j = i-1
        while j >= 0 and temp < array[j]:
            array[j+1] = array[j]
            j -= 1
        array[j+1] = temp
    return array

def __insertsort(array,h):
    global count
    for i in range(h,len(array)):
        #print(" ".join(list(map(str,array))))
        temp = array[i]
        j = i-h
        while j >= 0 and temp < array[j]:
            array[j+h] = array[j]
            j -= h
            count += 1
        array[j+h] = temp
    return array


def shellsort(array):
    h = []
    ret = len(array)-1
    for i in range(len(array)):
        if ret > 1:
            h.append(ret)
            ret =int(ret/3)
        else:
            h.append(1)
            break

    for k in h:
        array = __insertsort(array,k)
    return len(h),h,array

n = int(input())
array = []
for i in range(n):
    array.append(int(input()))

a,b,c = shellsort(array)
print(a)
print(" ".join(list(map(str,b))))
print(count)
for i in c:
    print(i)



Measured memory_bytes: 45516
def koch_curve(x1,y1,x5,y5)
	x2 = (2 * x1 + 1 * x5) / 3
	y2 = (2 * y1 + 1 * y5) / 3
	
	x4 = (x2 + x5) / 2
	y4 = (y2 + y5) / 2

	x3=(((x4-x2)*Math.cos(Math::PI/3)-(y4-y2)*Math.sin(Math::PI/3))+x2).to_f
    y3=(((x4-x2)*Math.sin(Math::PI/3)+(y4-y2)*Math.cos(Math::PI/3))+y2).to_f
	
	return [x2,x3,x4],[y2,y3,y4]
end

n = gets.chomp.to_i
px = Array.new
py = Array.new

px[0] = 0.0
py[0] = 0.0
px[1] = 100.0
py[1] = 0.0

n.times {
	line_num = px.length-1
	idx = 0
	line_num.times { |i|
		px[idx+1,0],py[idx+1,0] = koch_curve(px[idx],py[idx],px[idx+1],py[idx+1])
		idx += 4
	}
}

px.length.times { |i|
	puts px[i].to_s + " " + py[i].to_s
}

Measured memory_bytes: 8984
fun main(args: Array<String>) {
    readLine()
    val xs = readLine()!!.split(' ').map { it.toInt() }

    val set = mutableSetOf<Int>()

    var min = xs.first()
    var profit = 0

    for (x in xs.slice(1..xs.lastIndex)) {
        val p = x - min
        min = Math.min(min, x)

        if (p > profit) {
            set.clear()
            set.add(x)
            profit = p
        }

        if (p == profit) {
            set.add(x)
        }

    }

    println(set.size)
}


Measured memory_bytes: 55068
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {

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

	int n;
	cin >> n;
	vector<LL> v(n+2);
	for(int i=1; i<=n; i++) cin >> v[i];

	vector<vector<LL> > dp(n+2, vector<LL>(n+2,0));

	for(int len=1; len<=n; len++)
		for(int i=1, j=len; j<=n; i++, j++)
			if(len%2 == n%2)
				dp[i][j] = max(dp[i+1][j]+v[i], dp[i][j-1]+v[j]);
			else
				dp[i][j] = min(dp[i+1][j]-v[i], dp[i][j-1]-v[j]);

	cout << dp[1][n] << "\n";
	return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const ll N=100000;
const ll R = 1000000007;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,a[N],k,ans=1;
	CLR(a);
	cin >> n;
	FOR(i,0,n){
		cin >> k;
		a[k]++;
	}
	for(int i=0;i<n/2;i++){
		ans*=2;
		ans%=R;
	}
	if(n&1){
		if(a[0]!=1){
			ans=0;
		}
		for(int i=2;i<n;i+=2){
			if(a[i]!=2)ans=0;
		}
		
	}else{
		for(int i=1;i<n;i+=2){
			if(a[i]!=2)ans=0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
using System;

class P
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');

        int h = int.Parse(str[0]);
        int w = int.Parse(str[1]);

        while (h != 0)
        {
            for (int i = 1; i <= h; i++)
            {
                if (i == 1 || i == h)
                {
                    for (int k = 0; k < w; k++)
                    {
                        Console.Write("#");
                    }
                    Console.WriteLine();
                }
                else
                {
                    Console.Write("#");
                    {
                        for (int l = 0; l < w - 2; l++)
                        {
                            Console.Write(".");
                        }
                    }
                    Console.Write("#");
                    Console.WriteLine();    
                }
            }//For(Entity) End

            Console.WriteLine();                    
            //Read new line
            str = Console.ReadLine().Split(' ');
            h = int.Parse(str[0]);
            w = int.Parse(str[1]);
                
        }//While End
    }
}


Measured memory_bytes: 17936
#include <stdio.h>

int main(void)
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a<b){
	if(b<c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
}
else{
	printf("No\n");
}
return 0;
}


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

#define N 100

/** 平面座標を表す */
struct Point
{
  /** x 座標 */
  double x;
  /** y 座標 */
  double y;
  /** グラフ表現用 */
  struct Point *e;
};

/** ピン数 */
static int n;
/** ピン座標 */
static struct Point p[ N ];

/** 2 ベクトル(x1, y1), (x2, y2) の外積を求める． */
static double
outerProduct (
  double x1,
  double y1,
  double x2,
  double y2
  )
{
  return ( x1 * y2 - y1 * x2 );
}

/** 頂点p[ idx ] より最も進行方向左側に存在する頂点を探索する． */
static int
findOtherSideIndex (
  int idx
  )
{
  int otherSideIndex = !( idx ); /*< ( idx == 0 ? 1 : 0 ) */
  int i;

  for ( i = 1; i < n; ++i )
  {
    const double det
      = outerProduct (
          p[ otherSideIndex ].x - p[ idx ].x,
          p[ otherSideIndex ].y - p[ idx ].y,
          p[ i ].x - p[ idx ].x,
          p[ i ].y - p[ idx ].y
          );

    /* 頂点p[ idx ] は探索対象から除く */
    if ( i == idx ) continue ;

    if ( det < 0. )
    {
      otherSideIndex = i;
    }
  }

  return ( otherSideIndex );
}

/** 左端ピンのインデックスを探索する． */
static int
findLeftmostIndex (
  void
  )
{
  int leftmostIndex = 0;
  int i;

  for ( i = 1; i < n; ++i )
  {
    if ( p[ i ].x < p[ leftmostIndex ].x )
      leftmostIndex = i;
  }

  return ( leftmostIndex );
}

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int vertexes = 0;

    scanf ( " %d", &n );
    if ( n == 0 ) break ;
    for ( i = 0; i < n; ++i )
    {
      scanf ( " %lf,%lf", &p[ i ].x, &p[ i ].y );
      p[ i ].e = NULL;
    }

    /* 最左ピンより半時計回りに凸包頂点を一周結ぶ */
    i = findLeftmostIndex ( );
    while ( p[ i ].e == NULL )
    {
      const int nextIndex = findOtherSideIndex ( i );

      p[ i ].e = &p[ nextIndex ];
      i = nextIndex;
    }

    /* 凸包頂点の個数vertexes を数え上げる */
    for ( i = 0; i < n; ++i )
    {
      vertexes += !!( p[ i ].e != NULL );
    }

    printf ( "%d\n", n - vertexes );
  }

  return ( EXIT_SUCCESS );
}

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

int main(){
  int A, B;
  cin >> A >> B;
  int cnt=0,m=1;
  while(m<B){
    m+=A-1;
  	cnt++;
  }
  
  
  cout << cnt << endl;
}

Measured memory_bytes: 3584
#include<stdio.h>
int main(){
	int i,c=0,b[30]={};
	char s[110]={};
	scanf("%s",s);
	for(i=0;s[i];i++)b[s[i]-'a']++;
	for(i=0;i<26;i++)c+=b[i]%2;
	printf("%s",c?"No":"Yes");
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;


int main() {
	int a, b;
	cin >> a >> b;
	cout << a * b - a - b + 1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n, t;
    cin >> n >> t;

    vector<ll> time(n);
    rep(i, n)cin >> time[i];

   ll past = 0;
   ll ans = 0;
   rep(i, n){
       ans += t - max((ll)0, past - time[i]);
       past = time[i] + t;
   }

   cout << ans << endl;
}

Measured memory_bytes: 1792
// Nの要素を0で初期化した後にdiと重なった部分を1に上書きして最後に0だった要素数を取り上げる

#include <bits/stdc++.h>
using namespace std;
int main() {
  int x,n,m,k,y=0;

  int s[100];

  cin >> n >>k; 
//   人数Nとお菓子の種類Kの入力

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

    s[i]=0;

  }
  for(int i=1;i<=k;i++){

    cin >> x;
    // お菓子の個数xの入力


    for(int j=1;j<=x;j++){

      cin >> m;
    //   お菓子を分け与える人の入力

      s[m]=1;

    }
  }

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

    if(s[i]==0){

      y++;

    }

  }

  cout << y << endl;

  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <string>

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

int main() {
  int H, W;
  std::cin >> H >> W;

  std::vector<std::string> S(H);

  for (int i = 0; i < H; i++) {
    std::cin >> S[i];
  }

  bool ng = false;

  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      if (S[y][x] == '.') {
        continue;
      }

      bool ok = false;

      for (int i = 0; i < 4; i++) {
        const int ny = y + dy[i];
        const int nx = x + dx[i];

        if (ny >= 0 && ny < H && nx >= 0 && nx < W && S[ny][nx] == '#') {
          ok = true;
          break;
        }
      }

      if (!ok) {
        ng = true;
        goto end;
      }
    }
  }

end:
  std::cout << (ng ? "No" : "Yes") << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i;
	long long N, T[5];
	scanf("%lld", &N);
	for (i = 0; i < 5; i++) scanf("%lld", &(T[i]));
	
	long long min = T[0];
	for (i = 1; i < 5; i++) if (T[i] < min) min = T[i];
	
	printf("%lld\n", (N - 1) / min + 5);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}
//void chmin(ll &a,ll b){if(a>b) a = b ;}

ll n ;

ll solve(vll &a,vvll &dp,ll l,ll r){
	if(l==r){
		dp.at(l).at(r) = 0 ;
		return 0 ;
	}
	if(dp.at(l).at(r)!=-1) return dp.at(l).at(r) ;
	if((n-r+l+1)&1){
		dp.at(l).at(r) = max(solve(a,dp,l+1,r)+a.at(l),solve(a,dp,l,r-1)+a.at(r-1)) ;
	}else{
		dp.at(l).at(r) = min(solve(a,dp,l+1,r)-a.at(l),solve(a,dp,l,r-1)-a.at(r-1)) ;
	}
	return dp.at(l).at(r) ;
}

int main(){
	cin >> n ;
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	vvll dp(n+10,vll(n+10,-1)) ;
	cout << solve(a,dp,0,n) << endl ;;
//	for(int i=0;i<n;i++){
//		for(int j=0;j<n;j++){
//			cout << dp.at(i).at(j) << (j==n-1?'\n':' ') ;
//		}
//	}
}


Measured memory_bytes: 71424
A,B,K=map(int,input().split())
for k in range(K):
    if k%2==0:
        if A%2==1:
            A-=1
        B+=A//2
        A-=A//2
    else:
        if B%2==1:
            B-=1
        A+=B//2
        B-=B//2
print(A,B)

Measured memory_bytes: 2940
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))



def main():
    R, G, B, N = i2nn()
    #a = []
    cnt = 0
    R, G, B = sorted((R, G, B), reverse=True)
    for r in range(N // R + 1):
        for g in range((N - R * r) // G + 1):
            #print([r, g, 0], N - R * r - G * g)
            if (N - R * r - G * g) % B == 0:
                cnt += 1
                #a.append([r,g,(N - R * r - G * g) // B])
    #print(a)
    print(cnt)
main()

Measured memory_bytes: 3064
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    a_lst = LI()
    ans = float("inf")
    for i in range(-100,100+1):
        cost = 0
        for a in a_lst:
            cost += (a-i)**2
        ans = min(ans, cost)
    print(ans)
main()


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

int main(){
	int a;
    cin >> a;
    a = a % 10;
    if (a == 2 || a==4 || a==5 || a==7 || a==9){
    cout << "hon" << endl;
    }
    else if(a==3){
    cout << "bon"<< endl;
    }
    else{
    cout << "pon" << endl;
    }
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int r,D,x;
    cin >> r >> D >> x;
    for(int i=0;i<10;i++){
        x = x*r-D;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    string s;
    cin>>s;
    int f=0;
    for(int i=0; i<n; i++)
    {
        if(s[i]>='0' && s[i]<='9')continue;
        f=1;
    }
    if(f==1)
    {
        cout<<"No\n";
        return 0;
    }
    else
    {
        if(s[n]!='-')f=1;
        if(f==1)
        {
            cout<<"No\n";
            return 0;
        }
        else
        {
         for(int i=n+1; i<s.size(); i++)
         {
            if(s[i]>='0' && s[i]<='9')continue;
            f=1;
         }
         if(f==1)
        {
            cout<<"No\n";
            return 0;
        }
        }
    }
    cout<<"Yes\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<deque>
#define ll long long
using namespace std;
#define BUF_SIZE 1048576
char _buf[BUF_SIZE],*_is=_buf,*_it=_buf;
inline char rdc(){
	if (_is==_it) _it=(_is=_buf)+fread(_buf,1,BUF_SIZE,stdin);
	return *_is++;
}
inline void rdi(int &x){
	int f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	if(f) x=-x;
}
inline void rdi(ll &x){
	ll f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	if(f) x=-x;
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(int x){
	write(x);
	putchar(' ');
}
inline void print(int x){
	write(x);
	putchar('\n');
}
inline void write(ll x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(ll x){
	write(x);
	putchar(' ');
}
inline void print(ll x){
	write(x);
	putchar('\n');
}
struct dsu{
	int par[200200];
	inline void init(int _n){for(int i=0;i<_n;++i) par[i]=i;}
	inline int find(int now){
		if(par[now]==now) return now;
		return par[now]=find(par[now]);
	}
	inline bool unite(int a, int b){
		int Pa(find(a)),Pb(find(b));
		if(Pa==Pb) return false;
		par[Pa]=Pb;
		return true;
	}
};
int n;
string s;
int pre[555555];
int a[555555],b[555555];
inline void builda(string s){
	for(int i=2,j=0;i<=n;++i){
		while(j and s[j+1]!=s[i]) j=pre[j];
		if(s[j+1]==s[i]) ++j;
		pre[i]=j;
	}
	for(int i=1;i<=n;++i) if(!pre[i] or i%(i-pre[i])) a[i]=1;
}
inline void buildb(string s){
	for(int i=2,j=0;i<=n;++i){
		while(j and s[j+1]!=s[i]) j=pre[j];
		if(s[j+1]==s[i]) ++j;
		pre[i]=j;
	}
	for(int i=1;i<=n;++i) if(!pre[i] or i%(i-pre[i])) b[i]=1;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>s;
	n=s.size();
	builda(' '+s);
	if(a[n]){
		cout<<1<<'\n'<<1<<endl;
		return 0;
	}
	reverse(s.begin(),s.end());
	buildb(' '+s);
	int cnt=0;
	for(int i=1;i<=n;++i) cnt+=(bool)(a[i] and b[n-i]);
	if(!cnt) cout<<n<<' '<<1<<endl;
	else cout<<2<<' '<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 7472
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

int N, lim, check_mask;

ll pw10[50];
ll dp[50][1<<20];
ll solve(const int n, const int mask, const int sum){
  if((mask & check_mask) == check_mask){
    return pw10[N - n];
  }
  if(n >= N)return 0;
  if(dp[n][mask] != -1)return dp[n][mask];
  ll res = 0;
  for(int i=1;i<=10;i++){
    int nsum = sum + i;
    int nmask = mask | (1 << nsum);
    if(nsum > lim){
      for(int i=nsum-lim;;i++){
        if((nmask >> i) & 1){
          nmask = (nmask >> i) ^ 1;
          nsum -= i;
          break;
        }
      }
    }
    ll tmp = solve(n + 1, nmask, nsum);
    res = (res + tmp) % MOD;
  }
  return dp[n][mask] = res;
}

int main(){
  pw10[0] = 1;
  for(int i=1;i<50;i++)pw10[i] = pw10[i-1] * 10 % MOD;

  int X, Y, Z;
  cin >> N >> X >> Y >> Z;
  lim = X + Y + Z;
  check_mask = (1 << X) | (1 << (X + Y)) | (1 << (X + Y + Z));
  memset(dp, -1, sizeof(dp));
  cout << solve(0, 0, 0) << endl;
  return 0;
}


Measured memory_bytes: 409856
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int H,h,K,k,a,b,c,d,r=0,m=0,i=0,j=0;
  cin >> H >> h;
  cin >> K >>k;
  cin >> a >> b >> c >> d;
  if(H>=10){
    r=H/10;
    r=r*c;
  }
  if(h>=20){
    m=h/20;
    m=m*d;
  }
  H=H*a+h*b+r+m;
  if(K>=10){
    i=K/10;
    i=i*c;
  }
  if(k>=20){
    j=k/20;
    j=j*d;
  }
  K=K*a+k*b+i+j;
  if(H>K){
    cout << "hiroshi" <<endl;
  }else if(K>H){
    cout << "kenjiro" <<endl;
  }else if(K==H){
    cout << "even" <<endl;
  }
  return(0);
}



Measured memory_bytes: 3108
#include<cstdio>
#include<cstring>
using namespace std;
const int N=1e5+5;
char s[N];
int n,ans,k;
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;++i){
		if(s[i]=='0') ++ans;
		else ++k;
	}
	if(ans<k) printf("%d",ans<<1);
	else printf("%d",k<<1);
}

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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(s[i] != s[n - 1 - i]){
            ans++;
            s[i] = s[n - 1 - i];
        }
    }
    cout << ans << endl;
}

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

#define ll long long

using namespace std;

int main(){
	ll n,i,sum;
	string s;
	
	while(1){
		cin>>s;
		if(s=="0") break;
		n=s.size();
		sum=0;
		for(i=0;i<n;i++){
			sum+=s[i]-'0';
		}
		cout<<sum<<"\n";
	}
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int N;
  cin>>N;
  map<int,int> A;
  rep(i,0,N){
    int X;
    cin>>X;
    if(A.count(X))
      A.at(X)++;
    else
      A[X]=1;
    }
  int top=0,second=0;
  for(auto p:A){
    int K=p.first,V=p.second;
    if(V>=4){
      top=K;
      second=K;
      }
    else if(V>=2){
      second=top;
      top=K;
      }
    }
  cout<<top*second;
  }


Measured memory_bytes: 6528
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;
int n;
string s;
bool memoo[18][18];
int memo[18][18];
string front, endd;
long long func(int len1, int len2){
    int curind = n+len1+len2;
    if (curind >= 2*n){
        return 1;
    }
    if (memoo[len1][len2]){
        return memo[len1][len2];
    }
    long long res = 0;
    if (len1 < front.size() && len2 < endd.size()){
        if (s[curind] == front[len1]){
            res += func(len1+1, len2);
        }
        if (s[curind] == endd[len2]){
            res += func(len1, len2+1);
        }
    }else if (len1 < front.size()){
        if (s[curind] == front[len1]){
            res += func(len1+1, len2);
        }
    }else{
        if (s[curind] == endd[len2]){
            res += func(len1, len2+1);
        }
    }
    memoo[len1][len2] = true;
    memo[len1][len2] = res;
    return res;
}
int main(){
  prep();
  
  cin >> n;
  cin >> s;
  int cnts[26] = {0};
  int cnts2[26] = {0};
  for (int i=0; i<n; i++){
      cnts[s[i]-'a']++;
  }
  for (int i=n; i<2*n; i++){
      cnts2[s[i]-'a']++;
  }
  for (int i=0; i<26; i++){
      if (cnts[i] != cnts2[i]){
          cout << 0;
          return 0;
      }
  }
  int poww = pow(2, n);
  long long res = 0;
  for (int i=0; i<poww; i++){
      bitset<18> bs(i);
      front = "";
      endd = "";
      for (int j=0; j<n; j++){
          if (bs[j]){
              front += s[j];
          }else{
              endd += s[j];
          }
      }
      //cout << front << " " << endd << endl;
      reverse(front.begin(), front.end());
      reverse(endd.begin(), endd.end());
      memset(memoo, false, sizeof(bool)*18*18);
      res += func(0, 0);
  }
  cout << res;
  return 0; 
}

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

using namespace std;

#define FaSt ios::sync_with_stdio(0),cin.tie(0);
#define random uniform_int_distribution<long long>(1, 2000000000000000LL)(rng)

const int N = 105, K = 100005, M = 1e9 + 7;
int n, k, a[N];
long long dp[N][K];

int main()
{
    FaSt
    cin >> n >> k;
    
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    
    for (int i = 0; i < n; i++)
    {
        dp[i][0] = 1;
    }
    
    for (int i = n - 1; i >= 0; i--)
    {
        for (int j = 1; j <= k; j++)
        {
            if (i == n - 1)
            {
                if (j <= a[i])
                {
                    dp[i][j] = dp[i][j - 1] + 1;
                }
                else
                {
                    dp[i][j] = dp[i][j - 1];
                }
            }
            else
            {
                int h = j, l = max(0, j - a[i]);
                dp[i][j] = dp[i][j - 1] + (l == 0 ? dp[i + 1][h] : dp[i + 1][h] - dp[i + 1][l - 1] + M);
                dp[i][j] %= M;
            }
        }
    }
    
    cout << (dp[0][k] - dp[0][k - 1] + M) % M;
}


Measured memory_bytes: 80128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, l;
  cin >> n >> l;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> ans;
  for (int i = 0; i + 1 < n; i++) {
    if (a[i] + a[i + 1] >= l) {
      ans.push_back(i);
      for (int j = i - 1; j >= 0; j--) {
        ans.push_back(j);
      }
      for (int j = i + 1; j + 1 < n; j++) {
        ans.push_back(j);
      }
      break;
    }
  }
  if (ans.size() == 0) {
    puts("Impossible");
    return 0;
  } 
  reverse(ans.begin(), ans.end());
  cout << "Possible" << endl;
  for (int i : ans) {
    cout << i + 1 << endl;
  }
  return 0;
}

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

typedef long long ll;

string s;

int main(){
    cin >> s;

    int cnt = 700;
    if (s[0] == 'o') cnt += 100;
    if (s[1] == 'o') cnt += 100;
    if (s[2] == 'o') cnt += 100;

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
int cnt[26];
ll comb(int n) {
	return (1ll*n*(n-1))/2;
}
void solve(string s){
	int n=s.length();
	for (int i=0;i<n;i++) {
		cnt[s[i]-'a']++;
	}
	ll all=comb(n);
	for (int i=0;i<26;i++) {
		all-=comb(cnt[i]);
	}
	all++;
	printf("%lld\n",all);
}

int main(){	
	ios_base::sync_with_stdio(false); cin.tie(0);
	string A;
	cin >> A;
	solve(A);
	return 0;
}



Measured memory_bytes: 788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b,c;
    cin >>a >> b >> c;

    map<int,int> mp;
    mp[a]++;
    mp[b]++;
    mp[c]++;

    cout << mp.size() << endl;
}

Measured memory_bytes: 256
X = raw_input()

y = []
for n in xrange(len(X)):
    y.append(X[n])

    while (1):
        if len(y) < 2: break
        if y[-2] == 'S' and y[-1] == 'T':
            y.pop()
            y.pop()
        else:
            break

print len(y)

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

int main()
{
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
  {
    cout << "vowel" << endl;
  }
  else
  {
    cout << "consonant" << endl;
  }
}

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

int const N = 100005;
vector<int> adj[N];

int32_t main(){
  int n,m;
  cin>>n>>m;
  int h[n+1];
  for(int i=1;i<=n;i++){
  	cin>>h[i];
  }
  for(int i=0;i<m;i++){
  	int u,v;
    cin>>u>>v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  
  int ans = 0;
  
  for(int i=1;i<=n;i++){
  	int is = 1;
    for(auto j:adj[i]){
      if(h[j] >= h[i]) is = 0;
    }
    ans += is;
  }
  cout<<ans<<endl;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, 1, sizeof(p))

#define INF 1000000000

ll N;
list<ll> A;
int main()
{
    cin >> N;
    REP(i, N) {
        ll a;
        cin >> a;
        if(i % 2 == 0) {
            A.push_back(a);
        } else {
            A.push_front(a);
        }
    }
    if(N % 2 != 0) {
        auto it = A.end();
        it--;
        for(int i = N - 1; i >= 0; --i) {
            printf("%lld", *it);
            if(i != 0) { printf(" "); }
            it--;
        }
    } else {
        auto it = A.begin();
        REP(i, N) {
            printf("%lld", *it);
            if(i != N - 1) { printf(" "); }
            it++;
        }
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 8448
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

/** ワーシャル・フロイド法による全点対最短路探索

    経路を逐次最小化していく。

    頂点番号は0オリジン。

    知らないパスにはコスト大きめを設定しておくこと。
    ただ、内部で加算するのでオーバーフローに注意。MAXダメ、絶対。
    std::fill(mat.data(), mat.data() + mat.num_elements(), MAXCOST+1);

    O(|V|^3)

    @note 反対方向もいれた？
    mat[a][b] = mat[b][a] = c;

    @note 自分自身へのルートはコスト0か？
    for (int i = 0; i < N; ++i) {
    mat[i][i] = 0;
    }

    @param[in] V  頂点数
    @param[in, out] distance[i][j]: 頂点i -> jのコスト
*/
template<typename T, typename M>
void warshall_floyd(T V, M& distance)
{
    for (T k = 0; k < V; ++k) {
        for (T i = 0; i < V; ++i) {
            for (T j = 0; j < V; ++j) {
                distance[i][j] = std::min(distance[i][j],
                                          distance[i][k] + distance[k][j]);
            }
        }
    }
}

template<typename T>
constexpr T almost_max() {
    return std::numeric_limits<T>::max() / 2 - 1;
}

int main()
{
    int64_t N, M, R;
    std::cin >> N >> M >> R;

    std::vector<int64_t> route;
    for (decltype(R) i = 0; i < R; ++i) {
        int64_t t;
        std::cin >> t;
        t--;
        route.push_back(t);
    }

    boost::multi_array<int64_t, 2> g(boost::extents[N][N]);

    std::fill(g.data(), g.data() + g.num_elements(), almost_max<int64_t>());

    for (int i = 0; i < N; ++i) {
        //     g[i][i] = 0;
    }

    for (decltype(M) i = 0; i < M; ++i) {
        int64_t a, b, c;
        std::cin >> a >> b >> c;
        a--;
        b--;
        g[a][b] = g[b][a] = c;
    }

    warshall_floyd(N, g);

    //int64_t ans =  INT64_MAX;

    std::sort(std::begin(route), std::end(route));

    
    int64_t dist = INT64_MAX;
    std::sort(route.begin(), route.end());
    do {
        int64_t d = 0;
        for (int i = 1; i < R; ++i) {
            d += g[route[i-1]][route[i]];
        }
        dist = std::min(dist, d);
    } while (std::next_permutation(route.begin(), route.end()));
    std::cout << dist << std::endl;
    #if 0
    do {
        int64_t sum = 0;
        auto route_itr = route.begin();
        int64_t prev_c = *route_itr;
        route_itr++;
        for (; route_itr != route.end(); ++route_itr) {
            sum += g[prev_c][*route_itr];
            prev_c = *route_itr;
        }
        ans = std::min(ans, sum);
    } while (std::next_permutation(route.begin(), route.end()));

    std::cout << ans << std::endl;
#endif
    return 0;
}


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

using namespace std;

int main(void) {

	bool flag[201] = {};
	const int half = 100;

	int x, n;
	cin >> x >> n;
	int in;
	for (int i = 0; i < n; i++) {
		cin >> in;
		flag[(in - x) + half] = true;
	}


	if (flag[half] == false) {
		cout << x << endl;
			return 0;

	}
	for (int i = 1; i <= half; i++) {
		if (flag[half - i] == 0) {
			cout << x - i << endl;
			return 0;
		}
		if (flag[half + i] == 0) {
			cout << x + i << endl;
			return 0;
		}

	}


	return 0;
}


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

#define ll long long

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if (a==b) {
        if ((a!=c)&&(b!=c)){
            cout<<"Yes";
        }
        else {
            cout<<"No";
        }
    }
    else if (b==c) {
        if (a!=c){
            cout<<"Yes";
        }
        else {
            cout<<"No";
        }
    }
    else if (a==c) {
        if (b!=c){
            cout<<"Yes";
        }
        else {
            cout<<"No";
        }
    }
    else {
        cout<<"No";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n; cin>>n;
    for(int i = 0; i < n; ++i) {
        char c; cin>>c;
        if(c == 'Y') {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
#define rep(i,j) for(int i = 0; i < (j); i++)
int main(){int n;cin >> n;string c[] = {"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};	while(n--){string str;cin >> str;string ans = "";rep(i,str.size()){if(str[i] == '0')continue;int sub = i;while(str[i] == str[++sub]);ans += c[str[sub-1]-48][(sub-i-1)%c[str[sub-1]-48].size()];i = sub;}cout << ans << endl;}return 0;}

Measured memory_bytes: 1216
import java.util.*;
import java.util.function.*;
import java.lang.*;
import java.io.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] a = new int[N+1];
        for(int n=1; n<=N; n++) a[n] = sc.nextInt();

        int ans = 0;

        for(int n=1; n<=N; n++){
            if(n%2==1 && a[n]%2==1) ans++;
        }

        System.out.println(ans);
    }
}


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

int main() {

    long long int n;
    cin >> n;

    vector< long long int > v;

    for ( long long int i = 0; i <= n; i++ ) {
        long long int in;
        cin >> in;
        v.push_back( in );
    }

    long long int ans = 0;
    for ( long long int i = 0; i < n; i++ ) {
        long long int in;
        cin >> in;
        if ( v[i] >= in ) {
            ans += in;
        } else {
            ans += v[i];
            in -= v[i];
            if ( v[i+1] >= in ) {
                ans += in;
                v[i+1] -= in;
            } else {
                ans += v[i+1];
                v[i+1] = 0;
            }
        }
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 1400
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int c[3][3];
    rep(i, 3) rep(j, 3) cin >> c[i][j];
    rep(i, 2) {
        rep(j, 2) {
            if(c[i][j] - c[i][j + 1] != c[i + 1][j] - c[i + 1][j + 1]) {
                cout << "No" << endl;
                return 0; 
            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}
// a1+b1 a1+b2 a1+b3
// a2+b1 a2+b2 a2+b3
// a3+b1 a3+b2 a3+b3


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

m=max(a)

if K%2==0:
    if m<=K//2:
        ans=0
    elif m==K//2+1:
        ans=1
    else:
        ans=1+2*(m-1-K//2)
else:
    if m<=(K+1)//2:
        ans=0
    else:
        ans=2*(m-(K+1)//2)

print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int a[3],b[3],c[3];
    for(int i=0;i<3;i++){
        cin>>c[0]>>c[1]>>c[2];
        a[i]=c[0]-c[1];
        b[i]=c[1]-c[2];
    }
    if(a[0]==a[1]&&a[1]==a[2]&&b[0]==b[1]&&b[1]==b[2]){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <string>

using namespace std;

constexpr int SURFACE_NUM = 6;
enum {TOP, FRONT, RIGHT, LEFT, BACK, BOTTOM};

class Dice {
private:
    array<int, SURFACE_NUM> m_surface;

public:
    Dice(array<int, SURFACE_NUM> surface)
        : m_surface(surface) {}

    int surface(int i) const
    {
        return m_surface.at(i);
    }

    void roll(char direction)
    {
        switch (direction) {
        case 'N':
            roll(TOP, FRONT, BOTTOM, BACK);
            break;
        case 'S':
            roll(TOP, BACK, BOTTOM, FRONT);
            break;
        case 'E':
            roll(TOP, LEFT, BOTTOM, RIGHT);
            break;
        case 'W':
            roll(TOP, RIGHT, BOTTOM, LEFT);
            break;
        }
    }

    void roll(int i, int j, int k, int l)
    {
        int tmp = m_surface.at(i);
        m_surface.at(i) = m_surface.at(j);
        m_surface.at(j) = m_surface.at(k);
        m_surface.at(k) = m_surface.at(l);
        m_surface.at(l) = tmp;
    }

    void spin()
    {
        int tmp = m_surface.at(FRONT);
        m_surface.at(FRONT) = m_surface.at(LEFT);
        m_surface.at(LEFT) = m_surface.at(BACK);
        m_surface.at(BACK) = m_surface.at(RIGHT);
        m_surface.at(RIGHT) = tmp;
    }

    int right(int top, int fr)
    {
        if (m_surface.at(RIGHT) == top || m_surface.at(LEFT) == top) {
            (*this).roll('E');
        }
        while (m_surface.at(TOP) != top) {
            (*this).roll('N');
        }
        while (m_surface.at(FRONT) != fr) {
            (*this).spin();
        }

        return m_surface.at(RIGHT);
    }

    void printDice()
    {
        cout << m_surface.at(TOP) << m_surface.at(FRONT)
             << m_surface.at(RIGHT) << m_surface.at(LEFT)
             << m_surface.at(BACK) << m_surface.at(BOTTOM) << endl;
    }
};

int main()
{
    array <int, SURFACE_NUM> init;
    for (auto i = 0; i < SURFACE_NUM; i++) {
        cin >> init.at(i);
    }
    Dice one(init);

    int n;
    cin >> n;
    while (n--) {
        int top, fr;
        cin >> top >> fr;
        cout << one.right(top, fr) << endl;
    }
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <map>
#include <set>

using namespace std;

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

	vector<long long int> a(n);
	vector<long long int> b(n);

	set<long long int> st;

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

	map<long long int, long long int> mp;

	b[0] = a[0];
	mp[b[0]]++;
	st.insert(b[0]);
	for (long long int i = 1; i < n; i++) {
		b[i] = b[i - 1] + a[i];
		mp[b[i]]++;
		st.insert(b[i]);
	}

	long long int ans = 0;

	for (set<long long int>::iterator ite = st.begin(); ite != st.end(); ite++) {
		long long int c = mp[*(ite)];
		//cout << *(ite) << ' ' << c << endl;
		ans += c*(c - 1) / 2;
	}

	//cout << ans << endl;

	ans += mp[0];

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 25216
// khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;

const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;
const ll LOG = 20;
ll mark[N][2], a[N], n, v;
vpl Se, So;
int main(){
	IOS;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> v;
		a[i] = v;
		mark[v][i % 2] ++;
	}
	for (int i = 1; i <= 100000; i++){
		Se.pb({mark[i][0], i});
		So.pb({mark[i][1], i});
	}
	sort(all(Se));
	sort(all(So));
	ll tah = Se.size() - 1;
	ll ans = 0;
	if (Se[tah].S != So[tah].S){
		ans = n / 2 - Se[tah].F + n / 2 - So[tah].F;
	}else{
		ans = min(n / 2 - Se[tah].F + n / 2 - So[tah - 1].F, n / 2 - Se[tah - 1].F + n / 2 - So[tah].F);
		
	}
	
	cout << ans;
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 6892