akhauriyash/Code-Regression huggingface dataset:
c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

def isCorrect():
    if not (c11 - c21 == c12 - c22 == c13 - c23):
        return "No"
    if not (c11 - c31 == c12 - c32 == c13 - c33):
        return "No"
    if not (c11 - c12 == c21 - c22 == c31 - c32):
        return "No"
    if not (c11 - c13 == c21 - c23 == c31 - c33):
        return "No"
    return "Yes"
 
print(isCorrect())

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

/*int rec(int a[], int b[], int c[], int n, int id, int mem[][3], bool af, bool bf, bool cf)
{
  if(id>=n)
    return -1;
  if(id==n-1)
    return max(a[id],max(b[id],c[id]));
  if(af&&bf&&mem[id][0]!=-1&&mem[id][1]!=-1)
    return max(mem[id][0],mem[id][1]);
  if(bf&&cf&&mem[id][1]!=-1&&mem[id][2]!=-1)
    return max(mem[id][1],mem[id][2]);
  if(cf&&af&&mem[id][0]!=-1&&mem[id][2]!=-1)
    return max(mem[id][0],mem[id][2]);
  int aa=0,bb=0,cc=0;
  if(af)
  	aa=a[id]+rec(a,b,c,n,id+1,mem,0,1,1);
  if(bf)
  	bb=b[id]+rec(a,b,c,n,id+1,mem,1,0,1);
  if(cf)
  	cc=c[id]+rec(a,b,c,n,id+1,mem,1,1,0);
  int ans=max(aa,max(bb,cc));
  if(ans==aa)
    mem[id][0]=ans;
  else if(ans==bb)
    mem[id][1]=ans;
  else
    mem[id][2]=ans;
  return ans;
}*/

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

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main(void) {
	int N;
	scanf("%d", &N);
	long long A[100010];
	long long ans = 1;
	for (int i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
		if (A[i] == 0) {
			printf("0");
			return 0;
		}
	}
	for (int i = 0; i < N; i++) {
		// cout << ans << " " << 1000000000000000000 / ans << endl;
		if (1000000000000000000 / ans < A[i]) {
			printf("-1");
			return 0;
		} else {
			ans *= A[i];
		}
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 4596
/*
・足し算結果が0の時、改行が二回出力されていたので, 一回にした
・提出 → Presentation Error

*/

#include<stdio.h>
#define LINE_MAX 83 //入力行サイズ上限, 80文字 + 1文字(overflowチェック用) + \n + \0
#define DATA_MAX 81 //データサイズ上限, 80文字 + \0

//入力データを, 指定した格納領域に, reverseして詰める
// data [o] 格納領域
// return int 0なら正常, 1ならoverflow
int getReversedData(char *data){
  int i; //カウンタ変数
  int len; //入力データのサイズ
  char line[LINE_MAX]; //入力行
  
  //データ格納用変数を 0 で詰める
  //ただし末尾には \0 を入れる
  for(i=0 ; i<DATA_MAX-1 ; i++){
    data[i] = '0';
  }
  data[i] = '\0';

  //データを標準入力から読み込む
  fgets(line, sizeof(line), stdin);
  
  //overflowを判定する
  if(strlen(line) == LINE_MAX-1){
    return 1;
  }

  //改行コードを消す
  line[strlen(line)-1] = '\0';

  //指定した格納領域に, 入力データのreverseをセット
  len = strlen(line);
  for(i=0 ; i<len ; i++){
    data[len-1-i] = line[i];
  }
  
  return 0;
}
//答えを上位要素から出力する
void printAnswer(char *ans){
  int i,j; //カウンタ変数

  //上位桁に続く0は読み飛ばす
  for(i=DATA_MAX-1-1 ; ans[i]=='0' && i>=0 ; i--)
    ;

  //全て読み飛ばした場合, 足し算結果は0なので, 0を出力
  if(i<0){
    printf("0");
  }

  //各桁を出力
  //(!)iを使いまわしできんかった. ブロックスコープのせいやろ.
  for(j=i ; j>=0 ; j--){
    printf("%c",ans[j]);
  }
  printf("\n");
}
int main(){
  int i,j; //カウンタ変数
  int n; //データセット数
  int aret, bret; //入力データ取得時の戻り値(overflow判定用)
  int flagOverflow = 0; //計算結果がoverflowだった時に立つフラグ
  char line[LINE_MAX]; //入力行
  char a[LINE_MAX]; //一つ目のデータ
  char b[LINE_MAX]; //二つ目のデータ
  char c[DATA_MAX]; //繰上げ格納用
  char ans[DATA_MAX]; //答え格納用
  
  //データセット数を受け付ける
  fgets(line, sizeof(line), stdin);
  sscanf(line, "%d", &n);
  
  //データセット数だけ入力を受け付けて, 処理する
  for(i=0 ; i<n ; i++){
    //入力データを受け付ける
    /*
     例:
      2012が入力されたら, こんな感じ.

      21020000000000000…000000\0 (下位桁 --- 上位桁)
      ||||-1000の位(要素3)
      |||--100の位(要素2)
      ||---10の位(要素1)
      |----1の位(要素0)
    */
    aret = getReversedData(a);
    bret = getReversedData(b);
    
    //入力データの片方が80桁を越えていたら, overflowとする
    if(aret || bret){
      printf("overflow\n");
      continue;
    }

    //繰上げ用配列を初期化
    for(j=0 ; j<DATA_MAX-1 ; j++){
      c[j] = '0';
    }
    c[j] = '\0';
    
    //## 答え用配列の末尾にNULLを入れておく
    ans[DATA_MAX-1] = '\0';

    //足し算を計算する
    for(j=0 ; j<DATA_MAX-1 ; j++){
      int ia, ib, ic; //j桁目の整数
      int sum; //j桁目の合計値
      int div; //合計値の商部分
      int mod; //合計値の余り部分
      
      //各データのj桁目の整数値を取得
      ia = a[j] - '0';
      ib = b[j] - '0';
      ic = c[j] - '0';
      
      //j桁目を足し, 10で割った商と余りを求める
      sum = ia + ib + ic;
      div = sum / 10;
      mod = sum % 10;
      
      //繰上げの次の桁に商を代入
      //ただし最上位桁の場合, 次の桁は無いので, overflow用フラグに入れる
      if(j != DATA_MAX-1-1){
        c[j+1] = '0' + div;
      }else{
        flagOverflow = div;
      }
      
      //答え用配列に余り(j桁目の足し算結果)を代入
      ans[j] = '0' + mod;
    }

    //計算結果のoverflow判定
    if(flagOverflow){
      printf("overflow\n");
      continue;
    }

    //計算結果を表示
    printAnswer(ans);

  }
  return 0;
}

/*
    printf("a:%s\n",a);
    printf("b:%s\n",b);
    printf("c:%s\n",c);
    printf("A:%s\n",ans);

*/

Measured memory_bytes: 588
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// Nの入力
		long N = sc.nextLong();
		
		// 愚直に計算
		long a = 1;
		long b = N;
		
		for (long i = 1; i <= Math.sqrt(N); i++) {
			if (N % i == 0) {
				a = i;
				b = N / i;
				if ( a >= b) {
					break;
				}
			}
		}
		
		// 結果の出力
		System.out.println(a + b - 2);
		
		sc.close();
	}
}


Measured memory_bytes: 21844
from itertools import accumulate
n = int(input())
s = input()
aa = {'E':1, 'W':0}
e = list(map(aa.get, s))
aa = {'E':0, 'W':1}
w = list(map(aa.get, s))

ae = list(accumulate(e[::-1]))[::-1]
aw = list(accumulate(w))

ans = float('INF')
for i in range(1, n-1):
    if ans > ae[i+1] + aw[i-1]:
        ans = ae[i+1] + aw[i-1]
print(min([ans, ae[1], aw[-2]]))
# print(ae, aw)


Measured memory_bytes: 33016
#include <iostream>
#include<vector>
#include <math.h>
#include<stdio.h>
#include <climits>
#include<algorithm>
#include<string>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

#define K keyence
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	 //入力
	
	string s,k;
	int i=0,j=0,d=0,kari,old=0, flag = 0; //内部で使用;
	int ans = 0; //出力

	cin >> s;
	k = s;
	//↑ここまで入力パート

	rep(i, s.size()) {
		rep(j, s.size()) {
			k = s;
			k.erase(i, j);
			if (k == "keyence")ans++;//keyeeeeeeeeeeeeeeeeeeence
		}
	}


	if(ans>=1)cout << "YES" << "\n";
	else cout << "NO" << "\n";
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	int n,i,j;cin>>n;
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			int lv=0;
			while((i&(1<<lv))==(j&(1<<lv))){lv++;}
			cout<<lv+1<<" ";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int main()
{
    int a=0,max=0,min=100,i;
    for(i=0;i<3;i++)
    {
        scanf("%d",&a);
        if(a>=max)max=a;
        if(a<=min)min=a;
    }
    printf("%d",(max-min));
}

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

using namespace std;



int main(){
    
    long int N, K;
    cin >> N >> K;
    long int ans = 0;
    
    
    if (K == 0) {
        cout << N*N << endl;
        
    }else{
        
        for (long int i = K+1; i <= N; i++) {
            
            ans += (i-K);
            
            long int a = (N-K)/i;
            
            long int b = K + a*i;
            if (b+i-K-1 <= N) {
                ans += a*(i-K);
            }else{
                long int c = (b+i-K-1) - N;
                ans += a*(i-K);
                ans -= c;
                
            }
            
        }
        
         cout << ans << endl;
    }
    
    
   
    
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int n,m,f[N],d[N];
bool flag=1;
int find(int x){
	if(x==f[x])return x;
	int tmp=find(f[x]);
	d[x]+=d[f[x]];
	return f[x]=tmp;
}
bool work(int x,int y,int z){
	int rx=find(x),ry=find(y);
	if(rx==ry){
		if(d[y]-d[x]==z)return 1;
		else return 0;
	}
	f[ry]=rx;
	d[ry]=d[x]+z-d[y];
	return 1;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)f[i]=i;
	for(int i=1;i<=m;i++){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		if(flag)flag=work(x,y,z); 
	}
	if(flag)puts("Yes");
	else puts("No"); 
	return 0;
}

Measured memory_bytes: 4544
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        final int n = sc.nextInt();
        String s[] = new String[3];
        String nn = String.valueOf(n);
        for (int i  = 0;i<nn.length();++i) s[i] = nn.substring(i,i+1);

        boolean sw = false;
        for (int i = 0;i<s.length;++i)
        {
            if (s[i].equals("7"))
            {
                sw = true;
                break;
            }
        }
        if (sw) System.out.println("Yes");
        else System.out.println("No");
        sc.close();
    }
}

Measured memory_bytes: 35744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

int main(void){
    int x, a, b;
    cin >> x >> a >> b;
    x -= a;
    int c = x / b;
    x -= c*b;
    cout << x;
    return 0;
}

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

const int M = 2e5 + 100;
vector<int> e[M];
int a[M], ans[M];
set<int> st;

void dfs(int u, int pre) {
	auto it = st.lower_bound(a[u]);
	int era = -1;
	if (it != st.end()) {
		era = *it;
		st.erase(it);
	}
	st.insert(a[u]);
	ans[u] = st.size();
	for (auto v : e[u]) {
		if (v != pre) {
			dfs(v, u);
		}
	}
	st.erase(a[u]);
	if (era != -1) st.insert(era);
}

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n - 1; i++) {
		int u, v; cin >> u >> v;
		--u, --v;
		e[u].push_back(v);
		e[v].push_back(u);
	}
	dfs(0, -1);
	for (int i = 0; i < n; i++) cout << ans[i] << "\n";
}

Measured memory_bytes: 28000
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    int cnt=0;
    rep(i,n){
        while(i<n-1&&a[i]==a[i+1]) i++;
        if(i<n-1&&a[i]>a[i+1]){
            while(i<n-1&&a[i]>=a[i+1]) i++;
        }
        else if(i<n-1&&a[i]<a[i+1]){
            while(i<n-1&&a[i]<=a[i+1]) i++;
        }
        cnt++;
    }
    cout<<cnt;
}

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

using namespace std;

int main(void){

    int a, b;
    cin >> a >> b;
    int ans = 0;

    for(int i = a;i <= b;i++){
        string temp = to_string(i);
        if(temp[0] == temp[4] && temp[1] == temp[3]) ans++;
    }

    cout << ans << endl;

    return 0;
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

llint gcd(llint a, llint b) {
    if(a<b) swap(a, b);

    if (a%b==0) return (b);
    else return(gcd(b, a%b));
}

llint modpow(llint a, llint b, llint m) {
    if(b==0) return 1LL;
    if(b%2==0) {
        llint t = modpow(a,b/2,m);
        return t*t%m;
    }   
    return a*modpow(a,b-1,m)%m;
}

int main(void) {
    llint n;
    cin >> n;

    map<pair<llint, llint>,pair<llint, llint>> mp;
    llint a, b, g, zz = 0;
    for(int in=0;in<n;in++) {
        cin >> a >> b;
        if(a==0&&b==0) {
            zz++;
        }
        else if(a==0&&b!=0) { 
            mp[{0, 0}].first++;
        }
        else if(a!=0&&b==0) { 
            mp[{0, 0}].second++;
        }
        else {
            if(b<0) a *= -1, b*=-1;
            g = gcd(abs(a),abs(b));
            a /= g;
            b /= g;
            if(a<0) mp[{b, -a}].first++;
            else mp[{a, b}].second++;
        }
    }

    llint ans = 1;
    for(auto imp:mp) {
        // cout << imp.first.first << imp.first.second << imp.second.first << imp.second.second << endl;
        ans *= modpow(2,imp.second.first,MOD)+modpow(2,imp.second.second,MOD)-1;
        ans %= MOD;
    }
    ans += zz - 1 + MOD;
    ans %= MOD;
    cout << ans << endl;
    return 0;
}


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

int main(){
	int n;
	cin>>n;
	
	string w[100];
	for(int i=0;i<n;i++) cin>>w[i];
	
	
	int ans=1;
	
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			if(w[i]==w[j]){
				ans=0;
				break;
			}
		}
	}
	
	for(int i=0;i<n-1;i++){
		int p=w[i].size();
		
		if(w[i][p-1]!=w[i+1][0]){
			ans=0;
			break;
		}
	}
	
	
	cout<<((ans)?"Yes":"No")<<endl;
	
	return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e10;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
typedef tuple<int, int, int> Q;


int main() {
    int n, m;
    cin >> n >> m;

    vector<P> wars;
    rep(i, m) {
        int a, b;
        cin >> a >> b;

        P p(b, a);
        wars.push_back(p);
    }

    sort(wars.begin(), wars.end());


    int current_broken = wars[0].first - 1;
    int ans = 1;
    for(int i = 1 ; i < wars.size(); i ++) {
        P p = wars[i];
        if(p.second > current_broken ) {
            ans ++;
            current_broken = p.first - 1;
        }
    }

    cout << ans << endl ;

}



Measured memory_bytes: 1400
#include <stdio.h>
#include <math.h>
#define MAX 1000000

int cnt = 0, G[20], m;

void insertionSort(int A[],int n,int g) {
  int v, j;
  for (int i = g; i < n; i++) {
    v = A[i];
    j = i - g;
    while (j >= 0 && A[j] > v) {
      A[j+g] = A[j];
      j -= g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shellSort(int A[], int n) {
  int n2 = n;
  m = floor(log2(n));
  if (m == 0) m = 1;
  for (int i = 0; i < m; i++) {
    if (m == 1) {G[0] = 1; break;}
    n2 /= 2;
    G[i] = n2;
  }
  for (int i = 0; i < m; i++) {
    insertionSort(A, n, G[i]);
  }
}

int main(void) {
  int n, A[MAX];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }

  shellSort(A, n);

  printf("%d\n", m);
  for (int i = 0; i < m; i++) {
    if (i) {
      printf(" %d", G[i]);
    } else {
      printf("%d", G[i]);
    }
  }
  printf("\n");
  printf("%d\n", cnt);
  for (int i = 0; i < n; i++) {
    printf("%d\n", A[i]);
  }

  return 0;
}


Measured memory_bytes: 5772
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int a, b; cin >> a >> b;
    if (a <= 8 && b <= 8) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}

Measured memory_bytes: 3612
S=input()

if S[0]!='A':
  print('WA')
  exit()

count=0
for i in range(2,len(S)-1):
  if S[i]=='C':
    count+=1
if count!=1:
  print('WA')
  exit()

for i in range(2,len(S)-1):
  if S[i]=='C':
    break

S=S[1]+S[2:i]+S[i+1:len(S)]

if S.islower():
  print('AC')
else:
  print('WA')

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
int main() {
    
    int N;
    int A[10000];
    int flag;
    int tmp = 0;
    int count;
    
    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }
//    for(int i = 0; i < N; i++){
//        printf("%d", A[i]);
//    }
//     
    
    flag = 1;
    while (flag == 1){
        flag = 0;
        for( int j = 0; j < N; j++){
            if( A[j]<A[j-1]){
                tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                flag = 1;
                count++;
            }
        }
    }
    printf("%d", A[0]);
    for(int i = 1; i < N; i++){
        printf(" %d", A[i]);

    }
    printf("\n%d\n", count);
    
       return 0;
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)

signed main()
{
  int A, B;
  cin >> A >> B;
  if(A == 1) A += 13;
  if(B == 1) B += 13;

  if(A > B) cout << "Alice" << endl;
  else if(A == B) cout << "Draw" << endl;
  else cout << "Bob" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define Speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define mod 1000000007
#define fr first
#define sc second
#define pb push_back
#define PI acos(-1.0)
#define print(num,ans) cout<<setprecision(num)<<fixed<<ans
#define ordered_set tree<pair<int,int> , null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update>


int main()
{
    Speed;
    int x;
    cin>>x;
    if(x == 3 || x == 7 || x == 5)cout<<"YES";
    else cout<<"NO";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

    int K = 0;
    String prev = "";
    boolean cont = false;
    int head = 0;
    for (int i = 0; i < N-1; i++) {
      String cur = S.substring(head, i+1);
      if (!prev.equals(cur)) {
        K++;
        head = i + 1;
        prev = cur;
      }
    }
    if (!prev.equals(S.substring(head, N))) {
      K++;
    }
    System.out.println(K);
  }
}

Measured memory_bytes: 36700
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long int i = 0, j, N, p;
    cin >> N;
    long int A[N];
    p = 1;
    cin >> A[i];
    p = A[i];
    for (i = 1; i < N; i++)
    {
        cin >> A[i];
        p = __gcd(p, A[i]);
    }
    if (p != 1)
    {
        cout << "not coprime" << endl;
        return 0;
    }
    vector<bool> SOSU(1000010, true);
    vector<int> P(1000010,1);
    for (i = 2; i < (SOSU.size()) - 1; i++)
    {
        if (SOSU[i])
        {
            P[i] = i;
            for (j = 2 * i; j < (SOSU.size()) - 1; j += i)
            {
                SOSU[j] = false;
                P[j] = i;
            }
        }
    }
    bool B;
    vector<bool> soinsu(P.size(),false);
    vector<int> siyoukinsi(0);
    auto it = find(siyoukinsi.begin(), siyoukinsi.end(),0);
    int pp = 0,ppp;
    for(i = 0;i < N;i++){
        while(A[i] != 1){
            if (pp != P[A[i]]){
                siyoukinsi.push_back(pp);
            }
            it = find(siyoukinsi.begin(), siyoukinsi.end(), P[A[i]]);
            if (it != siyoukinsi.end()){
                cout << "setwise coprime" << endl;
                return 0;
            }
            pp = P[A[i]];
            A[i] /= P[A[i]];
        }
        siyoukinsi.push_back(pp);
        pp = 0;
    }
    cout << "pairwise coprime" << endl;
}

Measured memory_bytes: 19236
import java.util.*;
public class Main  
{ 
    
    public static void main(String[] args) 
    { 
        Scanner sc =new Scanner(System.in);
        double N = sc.nextDouble();
        N = N/3;
        double d = Math.pow(N,3);
      	System.out.println(d);
    }
} 

Measured memory_bytes: 22740
//#pragma GCC optimize ("O3")
//#pragma GCC target ("tune=native")
//#pragma GCC target ("avx")
//#include <bits/stdc++.h>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);

int c[26];

int main(){
	string s;
	cin>>s;
	if(s=="zyxwvutsrqponmlkjihgfedcba") cout<<-1<<endl;
	else if(s.size()<26){
		for(auto x: s) c[x-'a']++;
		rep(i, 26){
			if(c[i]==0){
				s += (char)('a'+i);
				break;
			}
		}
		cout<<s<<endl;
	} else {
		string t(s);
		next_permutation(all(t));
		rep(i, 26){
			if(s[i]!=t[i]){
				t = t.substr(0, i+1);
				break;
			}
		}
		cout<<t<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#define INF 0x3f3f3f3f
#define int long long
using namespace std;
//typedef long long LL;
const int maxn=1e6+6;
const int mod=1e9+7;
int cur[maxn];
int read(){        
    int s = 0, f = 1;        
    char ch = getchar();        
    while(!isdigit(ch)) {        
        if(ch == '-') f = -1;        
        ch = getchar();        
    }        
    while(isdigit(ch)) {        
        s = s * 10 + ch - '0';        
        ch = getchar();        
    }        
    return s * f;        
}    
signed main(){
	int n;
	cin>>n;
	int ans=2;
	int cnt=0;
	if(n==2){
		cout<<"1"<<endl;
		return 0;
	}
	for(int i=2;i<=sqrt(n);i++){
		if(n%i==0){
	   	    cur[++cnt]=i;
	   	    if(i*i!=n)
	   	        cur[++cnt]=n/i;
	    }
	}
	for(int i=2;i<=sqrt(n-1);i++)
	    if((n-1)%i==0){
	    	ans++;
	    	if(i*i!=n-1)
	    	   ans++;
		}
	for(int i=1;i<=cnt;i++){
		int tmp=n;
		while(tmp%cur[i]==0)   tmp/=cur[i];
		if((tmp-1)%cur[i]==0)  ans++;
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
struct point{
    double x,y;
};
bool cross(point a,point b,point c,point d){
    double ta=(c.x-d.x)*(a.y-c.y)+(c.y-d.y)*(c.x-a.x);
    double tb=(c.x-d.x)*(b.y-c.y)+(c.y-d.y)*(c.x-b.x);
    double tc=(a.x-b.x)*(c.y-a.y)+(a.y-b.y)*(a.x-c.x);
    double td=(a.x-b.x)*(d.y-a.y)+(a.y-b.y)*(a.x-d.x);
    return tc*td<0&&ta*tb<0;
}
bool parallel(point a,point b,point c,point d){
    return abs((b.y-a.y)*(d.x-c.x)-(d.y-c.y)*(b.x-a.x))<1e-10;
}
double area(point a,point b,point c){
    return abs((b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x))/2;
}
bool collinear(point a,point b,point c){
    return area(a,b,c)<1e-10;
}
point crosspoint(point a,point b,point c,point d){
    if(parallel(a,b,c,d))return {1e9,1e9};
    double xp=((c.y*d.x-c.x*d.y)*(b.x-a.x)-(a.y*b.x-a.x*b.y)*(d.x-c.x))/((b.y-a.y)*(d.x-c.x)-(b.x-a.x)*(d.y-c.y));
    double yp=((c.y*d.x-c.x*d.y)*(b.y-a.y)-(a.y*b.x-a.x*b.y)*(d.y-c.y))/((b.y-a.y)*(d.x-c.x)-(b.x-a.x)*(d.y-c.y));
    return {xp,yp};
}
signed main(){
    int n;
    cin>>n;
    while(n--){
        point a,b,c,d;
        cin>>a.x>>a.y>>b.x>>b.y>>c.x>>c.y>>d.x>>d.y;
        point p=crosspoint(a,b,c,d);
        printf("%.12lf %.12lf\n",p.x,p.y);
    }
    return 0;
}


Measured memory_bytes: 3280
#include <iomanip>
#include <iostream>
#include <vector>

int main()
{
    unsigned N;
    double t;
    std::cin >> N >> t;
    double max = 0;
    for(unsigned i = 0; i != N; ++i)
    {
        double x, h;
        std::cin >> x >> h;
        double target = h / x * t;
        if(target > max)
        {
            max = target;
        }
    }
    std::cout << std::fixed << std::setprecision(15) << max << '\n';
}


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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T> 
struct BIT{
  Int n;
  vector<T> bit;
  //1-indexed
  BIT():n(-1){}
  BIT(Int n_,T d):n(n_),bit(n_+1,d){}
  
  T sum(Int i){
    T s=bit[0];
    for(Int x=i;x>0;x-=(x&-x))
      s+=bit[x];
    return s;
  }
  void add(Int i,T a){
    if(i==0) return;
    for(Int x=i;x<=n;x+=(x&-x))
      bit[x]+=a;
  }
  
  Int lower_bound(Int w){
    if(w<=0) return 0;
    Int x=0,r=1;
    while(r<n) r<<=1;
    for(Int k=r;k>0;k>>=1){
      if(x+k<=n&&bit[x+k]<w){
	w-=bit[x+k];
	x+=k;
      }
    }
    return x+1;
  }
  
  T sum0(Int i){
    return sum(i+1);
  }
  void add0(Int i,T a){
    add(i+1,a);
  }
  
};

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  using P = pair<Int, Int>;
  vector<P> vp;
  for(Int i=0;i<n;i++){
    Int a,b;
    cin>>a>>b;
    vp.emplace_back(b,a);
  }
  sort(vp.rbegin(),vp.rend());

  Int ans=0;
  const Int MAX = 2e5;
  BIT<Int> bit(MAX,0);
  BIT<Int> cnt(MAX,0);
  for(Int i=0;i<n;i++){
    Int x=vp[i].first,a=vp[i].second;
    bit.add0(a,a);
    cnt.add0(a,1);
    Int l=0,r=MAX;
    while(l+1<r){
      Int m=(l+r)>>1;
      Int s=bit.sum0(m),c=cnt.sum0(m);
      if(s<=x*c) l=m;
      else r=m;
    }
    Int res=cnt.sum0(l);
    Int L=0,R=cnt.sum0(r)-cnt.sum0(l)+1;
    while(L+1<R){
      Int M=(L+R)>>1;
      Int s=bit.sum0(l)+M*r,c=cnt.sum0(l)+M;
      if(s<=x*c) L=M;
      else R=M;
    }
    chmax(ans,res+L);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 11208
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        mut a: [i64;n],
    }
    let mut sub = 0;
    a.sort();
    let mut sum = 0;
    for i in 0..n-1 {
        sum+=a[i]*2;
        if sum < a[i+1] {
            sub=i+1;
            // println!("{} {} : {}", a[i], a[i+1], i);
        }
    }
    println!("{}", n - sub);
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int e = c - (a - b);

        if (e >= 0) System.out.println(e);
        else System.out.println("0");
    }
}

Measured memory_bytes: 35752
#include <stdio.h>

int main( void )
{
	long long A,B ;
	scanf("%ld %ld", &A, &B ) ;
	long long a = A ;
	if( B - A < 5 ) {
		for( long long n = A+1 ; n <= B ; n++ ) {
			a ^= n ;
		}
	} else {
		if( B % 2 ) {
			switch((B-A) % 4 ) {
			case 0 : a = A ; break ;
			case 1 : a = 1 ; break ;
			case 2 : a = A-1 ; break ;
			case 3 : a = 0 ; break ;
			}
		} else {
			switch((B-A) % 4 ) {
			case 0 : a = B ^ 0 ; break ;
			case 1 : a = B ^ A ; break ;
			case 2 : a = B ^ 1 ; break ;
			case 3 : a = B ^ (A-1) ; break ;
			}
		}
	}
	printf("%ld\n", a ) ;
	return 0 ;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main() 
{
	int N;
	int a[110];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < N; i++) {
		if (a[i] % 2 == 0) {
			if (a[i] % 3 != 0 && a[i] % 5 != 0) {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool f(int n,int a[])
{
	while(n)
	{
		int p=n%10;
		if(a[p]==1)
		return 0;
		n/=10;
	}
	return 1;
}
int main()
{
 int n,k;
 cin>>n>>k;
 int a[10];
 memset(a,0,sizeof(a));
 while(k-->0)
 {
 	int x;
 	cin>>x;
 	a[x]=1;
 }
 while(1)
 {
 	if(f(n,a))
 	{
 	 cout<<n<<endl;
	  break;	
	}
	n++;
 }
 return 0;
}


Measured memory_bytes: 256
/*
	ARIJIT SUR 
	@duke_knight
	@surcode
    @comeback
	IIT ISM 
 */
#include<bits/stdc++.h>
#define SIZE 100008
#define mod (ll)(1e9+7)
#define INF 0x3f3f3f3f
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(a) (a>0?a:-a)
#define all(a) a.begin(),a.end()
#define maxelem(a) *max_element(all(a))
#define minelem(a) *min_element(all(a))
#define pb push_back
#define pi pair<int,int>
#define sort(a) sort(all(a))
#define reverse(a) reverse(all(a))
#define input(a) {for(int i1=0;i1<a.size();i1++) cin>>a[i1];}
#define display(a) {for(int i1=0;i1<a.size();i1++) cout<<a[i1]<<" "; cout<<endl;}
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long ll;
int changes(string a, string b){
    int ans = 0;
    for(int i=0;i<b.size();i++) ans += abs((a[i]-b[i]));
        return ans;
}
void solve(){
   string s,t;
        cin>>s>>t;
        int l=s.length();
        int len=t.length();
        int ans=len;
        for(int i=0;i<=l-len;i++)
        {
            int k=0;
            for(int j=0;j<len;j++)
            {
                if(t[j]!=s[i+j]) k++;
            }
            ans=min(k,ans);
        }
        cout<<ans;
    }
int main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--){
    	solve();
    }
    return 0;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int i,n,ans;
	string s;
	cin >> s;
	n = s.l_ength();
	ans = n;
	i = n;
	while(s[i-1]!='Z'){
		--ans;
		--i;
	}
	i = 0;
	while(s[i]!='A'){
		++i;
	}
	ans -= i;
	cout << ans << endl;
	return 0;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll N;
  scanf("%lld",&N);
  ll A;
  scanf("%lld",&A);
  ll B;
  scanf("%lld",&B);
  ll ans=0;
  for (int i=1; i<=N; i++) {
    ll t=i;
    ll s=0;
    while(t>0) {
      s+=t%10;
      t/=10;
    }
    if (A<=s&&s<=B) ans+=i;
  }
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


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

int main(){
	string S, T;
	cin >> S >> T;
	int ans = T.length();
	for(int i=0; i<S.length()-T.length()+1; ++i){
		int cnt = 0;
		for(int j=0; j<T.length(); ++j){
			if(T[j]!=S[j+i]) ++cnt;
		}
		ans = min(ans,cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3528
#include <iostream>
#include <cstdlib>
#include <vector>

using namespace std;

struct UnionFind
{
    vector<int> data;
    UnionFind() {}
 
    // initialize
    UnionFind(int size) : data(size, -1) {}
 
    void unite_set(int x, int y){
        x = root(x);
        y = root(y);
        bool is_unite = (x != y);
        
        if (is_unite){
            if (data[y] < data[x]){
                swap(x, y);
            }
            data[x] += data[y];
            data[y] = x;
        }
    }
 
    bool is_same(int x, int y){
        return root(x) == root(y);
    }
 
    int root(int x){
        return (data[x] < 0) ? x : data[x] = root(data[x]);
    }
 
    int size(int x){
        return -data[root(x)];
    }
};

int main()
{
    int n, m, answer;
    int x, y;
    cin >> n >> m;
    answer = 0;
    struct UnionFind d(n);
    vector<int> data;
    data.resize(n);
    
    for (int i=0; i<n; ++i){
        cin >> data[i];
    }
    for (int i=0; i<m; ++i){
        cin >> x >> y;
        d.unite_set(x-1, y-1);
    }
    for (int i=0; i<n; ++i){
        if(i+1 == data[i] || d.is_same(data[i]-1, i)){
            answer++;
        }
    }
    cout << answer << endl;
}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

int main()
{
	cout << setprecision(10);
	cin >> n >> s;
	if(n %2 != 0){
		coN();
		return 0 ;
	}
	int k = n / 2;
	string S , T ;
	S = s.substr(0,k);
	T = s.substr(k,k);
	if(S==T){
		coY();
	}
	else coN();

}


Measured memory_bytes: 256
S = list(input())
# 0 <= Y <= 99
# 1 <= M <= 12
if 1 <= int(S[0]+S[1]) <= 12:
    if 1 <= int(S[2]+S[3]) <= 12:
        print('AMBIGUOUS')
        exit()
if 0 <= int(S[0]+S[1]) <= 99:
    if 1 <= int(S[2]+S[3]) <= 12:
        print('YYMM')
        exit()
if 1 <= int(S[0]+S[1]) <= 12:
    if 0 <= int(S[2]+S[3]) <= 99:
        print('MMYY')
        exit()
print('NA')


Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main(void){
	int A, B;	cin >> A >> B;
	int ans = A + B;
	if (ans < A-B)	ans = A - B;
	if (ans < A*B)	ans = A * B;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
  n = int(input())
  ls = list(map(int, input().split()))
  if 0 in ls:
    print(0)
    return
  ans = 1
  for l in ls:
    ans *= l
    if ans > 1e18:
      print(-1)
      return
  print(ans)
  
main()

Measured memory_bytes: 21640
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int n,m,l;
    int a[100][100],b[100][100];
    long long int c[100][100];
        for(int i=0;i<100;i++){
      for(int j=0;j<100;j++){
          a[i][j]=0;
           b[i][j]=0;
            c[i][j]=0;
      }
    }
    cin>>n>>m>>l;
     
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
          cin>>a[i][j];
      }
    }
     
    for(int i=0;i<m;i++){
      for(int j=0;j<l;j++){
          cin>>b[i][j];
      }
    }
     
      
    for(int i=0;i<n;i++){
      for(int j=0;j<l;j++){
          for(int k=0;k<m;k++){
          c[i][j]+=a[i][k]*b[k][j];
      }
     }
    }
     
    for(int i=0;i<n;i++){
      for(int j=0;j<l;j++){
          cout<<c[i][j];
          if(j!=l-1) cout<<" ";
      }
      cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3252
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
//#include <iomanip> : 表示桁数, ex) cout << fixed << setprecision(15) << ...

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned char Byte;
using namespace std;

//string ans = "Yes";
int ans = 0;
int A, B;
int main() {
	cin >> A >> B;
	ans = A * B;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    int m[5] = {0};
    int ans;
    for(int i=1; i<=5; i++){
        cin >> m[i];
    }
    for(int i=1; i<=5; i++){
        if(m[i]==0){
            ans = i;
        }
    }
    cout << ans << endl;
   
}
 

Measured memory_bytes: 3564
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx,tune=native")

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pii;

template<typename T>
using pq_gt = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using pq_lt = priority_queue<T, vector<T>, less<T>>;

#define se second
#define fi first
#define pb push_back

int a[200],b[200],suma,sumb;
ll tempa,tempb;

int main() {
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    long long int ans = 0;
    for(int i = 0; i < N; ++i) {
    	cin>>a[i];
    	suma+=a[i];
    }
    for(int i = 0; i < N; ++i) {
    	cin>>b[i];
    	sumb+=b[i];
    }
    tempb = sumb;
    for(int i = 0; i < N; ++i) {
    	tempa+=a[i];
    	ans = max(ans, tempa+tempb);
    	tempb-=b[i];
    }
    cout<<ans<<endl;
}

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

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];
ll S[100005];
ll ans[100005];
std::map<ll, ll> m;

int main()
{
	ll N, M;
	cin >> N >> M;
	REP(i, N)
	{
		cin >> A[i];
	}

	S[0] = 0;
	REP(i, N)
	{
		S[i + 1] = A[i] + S[i];
	}
	REP(i, N)
	{
		m[S[i + 1] % M]++;
	}
	ll sum = 0;
	REP(i, N)
	{
		sum += m[S[i] % M];
		m[S[i + 1] % M]--;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 5760
L=int(input());S=bin(L);N=len(S)-2;print(N,2*N+S.count("1")-3)
for i in range(1,N):
 for j in[0,1]:print(i,i+1,j*2**i//2)
 if int(S[-i]):L^=2**i//2;print(i,N,L)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

using namespace std;

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

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

  sort(B.begin(), B.end(), greater<int>());

  for (int i = 0; i < N; i++){
    if (A[i] == B[0]) cout << B[1] << endl;
    else cout << B[0] << endl;
  }
  

  return 0;
}

Measured memory_bytes: 3200
face = map(int, raw_input().split())
order = raw_input()

dice = [ [ 0, face[0] ],
              [ 1, face[1] ],
              [ 2, face[2] ],
              [ 3, face[3] ],
              [ 4, face[4] ],
              [ 5, face[5] ]]
temp = 0

for i in order:
    if i == 'N':
        temp = dice[0][1]
        dice[0][1] = dice[1][1]
        dice[1][1] = dice[5][1]
        dice[5][1] = dice[4][1]
        dice[4][1] = temp
    if i == 'E':
        temp = dice[0][1]
        dice[0][1] = dice[3][1]
        dice[3][1] = dice[5][1]
        dice[5][1] = dice[2][1]
        dice[2][1] = temp
    if i == 'S':
        temp = dice[0][1]
        dice[0][1] = dice[4][1]
        dice[4][1] = dice[5][1]
        dice[5][1] = dice[1][1]
        dice[1][1] = temp
    if i == 'W':
        temp = dice[0][1]
        dice[0][1] = dice[2][1]
        dice[2][1] = dice[5][1]
        dice[5][1] = dice[3][1]
        dice[3][1] = temp

print dice[0][1]

Measured memory_bytes: 6468
/**
 * @author yuichirw
 *
 */
import java.util.*;

public class Main {

	static String n;
	static Scanner sc = new Scanner(System.in);
	static char[][] abacus = {
		"* = ****".toCharArray(),
		"* =* ***".toCharArray(),
		"* =** **".toCharArray(),
		"* =*** *".toCharArray(),
		"* =**** ".toCharArray(),
		" *= ****".toCharArray(),
		" *=* ***".toCharArray(),
		" *=** **".toCharArray(),
		" *=*** *".toCharArray(),
		" *=**** ".toCharArray()
	};
		
	static boolean read() {
		if(!sc.hasNext()) return false;
		n = sc.next();
		return true;
	}
	
	static void solve() {
		char[][] ans = new char[5][8];
		for(int i = 5 - n.length(); i > 0; i--) {
			n = "0" + n;
		}
		
		int a;
		for(int i = 0; i < n.length(); i++) {
			a = n.charAt(i) - '0';
			for(int j = 0; j < 8; j++) {
				ans[i][j] = abacus[a][j];
			}
		}
		
		for(int j = 0; j < 8; j++) {
			for(int i = 0; i < 5; i++) {			
				System.out.print(ans[i][j]);
			}
			System.out.println();
		}
	}
	
	public static void main(String[] args) {
		boolean first = true;
		while(read()) {
			if(!first) {
				System.out.println();
			} else {
				first = false;
			}
			solve();
		}
	}
}

Measured memory_bytes: 12000
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int n = stdin.nextInt();
        int m = stdin.nextInt();
        int[] a = new int[n]; // a日後
        int[] b = new int[n]; // 報酬
        for (int i = 0; i < n; i++) {
            a[i] = stdin.nextInt();
            b[i] = stdin.nextInt();
        }

        PriorityQueue<Integer> q1 = new PriorityQueue<>(Comparator.comparingInt(i -> a[i])); // すぐに報酬がもらえるものから取り出す
        PriorityQueue<Integer> q2 = new PriorityQueue<>(Comparator.comparingInt(i -> b[i] * -1)); // 報酬が大きいものから取り出す。
        IntStream.range(0, n).forEach(q1::add);

        int ans = 0;
        for (int d = m; d >= 0; d--) {
            while (!q1.isEmpty()) {
                int x = q1.peek();
                if (a[x] + d > m) {
                    break;
                }
                q2.add(q1.poll());
            }

            if (!q2.isEmpty()) {
                int x = q2.poll();
                ans += b[x];
            }
        }

        System.out.println(ans);
    }
}

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

using namespace std;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d) {
		cout << "Left" << endl;
	}
	else if (a + b < c + d) {
		cout << "Right" << endl;
	}
	else {
		cout << "Balanced" << endl;
	}
	
	return 0;
}

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

using namespace std;

#define fore(l) for(auto && value:l)

int main()
{
    vector<long long> values;
    values.resize( 3 );
    for ( auto i = 0; i < 3; i++ )
    {
        cin >> values[i];
    }
    values[0] = abs(values[0]);
    const auto straight = min(values[0] / values[2], values[1]);
    values[1] -= straight;
    values[0] -= straight * values[2];
    if ( values[1] % 2 != 0 )
        cout << values[2] - values[0];
    else
        cout << values[0];
    return 0;
}


Measured memory_bytes: 3116