akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

/*-------------------Define Start-------------------*/
typedef bool BL;    					// 布尔类型
typedef char SB;    					// 有符号1字节,8位
typedef unsigned char UB;    			// 无符号1字节,8位
typedef short SW;    					// 有符号短整型,16位
typedef unsigned short UW;    			// 无符号短整型,16位
typedef long SDW;    					// 有符号整型,32位
typedef unsigned long UDW;   			// 无符号整型,32位
typedef long long SLL;    				// 有符号长整型,64位
typedef unsigned long long ULL;			// 无符号长整型,64位
typedef char CH;    					// 单个字符
typedef float R32;    					// 单精度浮点数
typedef double R64;    					// 双精度浮点数

#define Rep(i, n) for (register SDW i = 0; i < (n); ++i)
#define For(i, s, t) for (register SDW i = (s); i <= (t); ++i)
#define rFor(i, t, s) for (register SDW i = (t); i >= (s); --i)
#define foreach(i, c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,0x7f,sizeof(a))
#define LOWBIT(x) ((x)&(-x))

#define MP make_pair
#define PB push_back
#define ft first
#define sd second

#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl

const ULL mod = 1e9 + 7;				//常用模数(可根据题目需要修改)
const ULL inf = 0x7fffffff;				//用来表示无限大
const ULL infLL = 0x7fffffffffffffffLL;	//用来表示无限大
/*-------------------Define End-------------------*/

const UDW maxN = 2e5 + 7;
UDW N, K;
R64 p[maxN];
R64 ans;

void input(){
	cin >> N >> K;
	ans = 0;
	
	Rep(i, N) {
		cin >> p[i];
	}
}

void solve(){
	R64 sum = 0;
	
	Rep(i, N) {
		p[i] = (1 + p[i]) * p[i] / 2 / p[i];
	}
	
	Rep(i, K - 1) {
		sum += p[i];
	}
	
	For(i, K - 1, N - 1) {
		sum += p[i];
		
		if(sum - ans > 1e-6) {
			ans = sum;
		}
		
		sum -= p[i - K + 1];
	}
}

void output(){
	printf("%.12f\n", ans);
	//cout << ans << endl;
}

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define pq priority_queue
#define st first
#define nd second

using namespace std;
typedef long long ll;
ll const inf = 1e9;
ll const mod = 998244353;

ll p[51];
ll b[51];

string burger(int level){
    if(level == 0) return "P";
    else{
        return "B" + burger(level - 1) + "P" + burger(level - 1) + "B";
    }

}
ll f(ll level, ll k){
    if(k == 0) return 0;
    if(k == 1){
        if(level == 0) return 1;
        else return 0;
    }
    else if(k == b[level] + p[level]){
        return p[level];
    }
    else{
        ll mid = p[level - 1] + b[level - 1] + 2;
        if(k >= mid){
            return p[level - 1] + 1 + f(level - 1, k - mid);
        }
        else{
            return f(level - 1, k - 1);

        }

    }
}

int main()
{
    p[0] = 1;
    b[0] = 0;
    fr(i, 1, 51){
        p[i] = p[i - 1] * 2 + 1;
        b[i] = b[i - 1] * 2 + 2;
    }
    ll n, k;
    cin >> n >> k;
    cout << f(n, k) << endl;
    return 0;

}


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

int main(){
   int a, b;
   cin>>a>>b;
   if(b/10<=0){
       a = (a*10)+b;
   }
    else if(b/100==1){
        a = (a*1000)+b;
   }
   else if(b/10>=0){
        a = (a*100)+b;
   }
    double x = sqrt(a);
    double y = x*100000;
    int z = y;
    if(z%10000>=1){
            cout<<"No"<<endl;
    }
    else{
            cout<<"Yes"<<endl;
    }

}


Measured memory_bytes: 256
#include <utility>
#include <stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main() {
	bool c[200000] = {};
	int a[200000] = {}, b[200001] = {}, n, j = 0;
	cin >> n;
	if (n == 1){
		cout << 0; return 0;
	}
	int64_t ans = 0 , count;
	REP(i, n) {
		cin >> a[i];
		b[a[i]] = i;
	}
	REP(i, n - 1) {
		count = 0;
		j = i;
		if (!c[i]) {
			while (j < b[a[j] + 1] && a[j] < n) {
				c[j] = true;
				j = b[a[j] + 1];
				count++;
			}
			ans = max(count + 1, ans);
		}
	}
	cout << n - ans;
}

Measured memory_bytes: 2048
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
using namespace std;

int main() {
	string n;
	cin >> n;
	if (n[0] == '9') {
		n[0] = '1';
	}
	else if(n[0] == '1') {
		n[0] = '9';
	}

	if (n[1] == '9') {
		n[1] = '1';
	}
	else if (n[1] == '1') {
		n[1] = '9';
	}

	if (n[2] == '9') {
		n[2] = '1';
	}
	else if (n[2] == '1') {
		n[2] = '9';
	}
	cout << n << endl;
	

}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B < C + D){
    cout << "Right" << endl;
  }
  
  if (A + B > C + D){
    cout << "Left" << endl;
  }
  
  if (A + B == C + D){
    cout << "Balanced" << endl;
  }
  
}
  

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

int main() {
  int N ;
  cin >> N ;
  int i = N , j = 0 ;
  
  for ( i ; i != 0 ; i /= 10 )
    j += i % 10 ;
  if ( N % j == 0)
    cout << "Yes" << endl ;
  else
    cout << "No" << endl ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
bool sortbysec(const tuple<int, int, int> &a,
               const tuple<int, int, int> &b)
{
    return (get<1>(a) < get<1>(b));
}

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

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

int main(){
    string s,t;
    cin>>s;
    cin>>t;
    int count=0;
    if(s.at(0)==t.at(0)){
        count++;
    }
    if(s.at(1)==t.at(1)){
        count++;
    }
    if(s.at(2)==t.at(2)){
        count++;
    }
    cout<<count<<endl;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[200100];
		for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextInt();
		}
		for(int i = 0 ; i < n ; i++) {
			b[--a[i]]++;
		}
		Arrays.sort(b);
		long ans = 0;
		for(int i = 0 ; i < n - k ; i++) {
			ans += b[200099 - k - i];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 83924
import java.util.*;
public class Main {
    public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String st = sc.next();
		int count=0;
		int l=0;
		StringBuilder sb = new StringBuilder();
		String prev="";
		for(int i=0;i<st.length();i++){
			sb.append(st.charAt(i));
			if(!sb.toString().equals(prev)){
				count++;
				prev=sb.toString();
				sb = new StringBuilder();
			}
		}
		
		
		System.out.println(count);
		
    }
	
	 private static int computeTemporaryArray(char pattern[]){
        int [] lps = new int[pattern.length];
        int index =0;
		int length=0;
		int y=0;
        for(int i=1; i < pattern.length;){
            if(pattern[i] == pattern[index]){
                lps[i] = index + 1;
                index++;
                i++;
				length++;
				y = Math.max(y,length);
            }else{
                if(index != 0){
                    index = lps[index-1];
                }else{
                    lps[i] =0;
                    i++;
					length=0;
                }
            }
			System.out.println(i+" "+index);
        }
        return y;
    }
	public static class pair{
		long val;
		long bomb;
	}
	public static class comp implements Comparator<pair>{
		public int compare(pair o1, pair o2){
			return Long.compare(o1.bomb,o2.bomb);
		}
	}
} 

Measured memory_bytes: 46268
#include <stdio.h>

int main(){
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if(W-r>=x && r<=x && H-r>=y && r<=y){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
	return 0;
}

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

char incrementChar(char x){
    return static_cast<char>(x + 1);
}

int weekToInt(string x){
    int num;
    if(x == "SUN"){
        num = 1;
    }else if(x == "MON"){
        num = 2;
    }else if(x == "TUE"){
        num = 3;
    }else if(x == "WED"){
        num = 4;
    }else if(x == "THU"){
        num = 5;
    }else if(x == "FRI"){
        num = 6;
    }else if(x == "SAT"){
        num = 7;
    }else{
        num = 0;
    }

    return num;
}

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

    cout << static_cast<float>(N / 2 + N % 2) / static_cast<float>(N) << endl;

    return 0;
}


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


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	vector<int>a(n), b(n), c(n);

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

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

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

	sort(a.begin(), a.end());
	
	sort(c.begin(), c.end());


	LL ans = 0;
	for (int i = 0; i < n; i++) {
		LL key = b[i];

		LL na=lower_bound(a.begin(), a.end(), key) - a.begin();
		LL nc = n-(upper_bound(c.begin(), c.end(), key)-c.begin());

		ans += na*nc;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * AOJ0074 Videotape
 */
public class Main {
    public static void main(String... args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = null;
        while ((line = br.readLine()) != null) {
            String[] in = line.split(" ");
            int hh = Integer.parseInt(in[0]);
            int mm = Integer.parseInt(in[1]);
            int ss = Integer.parseInt(in[2]);
            if(hh<0)break;
            int rem = 2*60*60-(hh*60*60+mm*60+ss);
            System.out.println(format(rem));
            System.out.println(format(rem*3));
        }
    }

    static String format(int x){
        return String.format("%1$02d:%2$02d:%3$02d",x/3600,(x%3600)/60,x%60);
    }

}

Measured memory_bytes: 17036
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define P pair<int,int>

using namespace std;

struct edge{int to,cost;};
vector<edge> G[1000000];


int main(){

    int N,M;
    cin>>N>>M;
    int cnt=1;
    unordered_set<int> type[N+1];
    map<int ,int> mp[N+1];


    REP(i,M){
        int p,q,c;
        scanf("%d%d%d",&p,&q,&c);
        int from=mp[p][c];
        int to  =mp[q][c];
        if(from==0)mp[p][c]=from=cnt++;
        if(to==0)mp[q][c]=to=cnt++;
        G[from].push_back(edge{to,0});
        G[to].push_back(edge{from,0});
        type[p].insert(c);
        type[q].insert(c);
    }


    REP(i,N){
        int p =cnt++;
        auto itr=type[i+1].begin();
        REP(j,type[i+1].size()){
            int p1=mp[i+1][*itr];
            G[p].push_back(edge{p1,1});
            G[p1].push_back(edge{p,1});
            itr++;
        }
    }

    int s=cnt++;
    int t=cnt++;
    int d[cnt];


    auto itr=type[1].begin();
    REP(i,type[1].size()){
        int p1=mp[1][*itr];
        G[s].push_back(edge{p1,0});
        G[p1].push_back(edge{s,0});
        ++itr;
    }
    itr=type[N].begin();
    REP(i,type[N].size()){
        int p1=mp[N][*itr];
        G[t].push_back(edge{p1,0});
        G[p1].push_back(edge{t,0});
        ++itr;
    }
    priority_queue< P,vector<P>,greater<P> > que;//d[x],x;
    fill_n(d,cnt,1000000000);
    d[s]=2;
    que.push(make_pair(d[s],s));

    while(!que.empty()){
        pair<int,int> p =que.top();que.pop();
        if(p.first>d[p.second])continue;
        REP(i,G[p.second].size()){
            edge e=G[p.second][i];
            if(d[e.to]>d[p.second]+e.cost){
                d[e.to]=d[p.second]+e.cost;
                que.push(make_pair(d[e.to],e.to));
            }
        }
    }


    if(d[t]==1000000000)d[t]=-1;
    else d[t]/=2;
    cout<<d[t]<<endl;



    return 0;
}

Measured memory_bytes: 92536
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    String s = sc.next();

    int l = Integer.valueOf(s.substring(0, 2));
    int r = Integer.valueOf(s.substring(2, 4));

    boolean lMonth = false;
    boolean rMonth = false;
    if (0 < l && l <= 12) {
      lMonth = true;
    }
    if (0 < r && r <= 12) {
      rMonth = true;
    }

    if (lMonth && rMonth) {
      os.println("AMBIGUOUS");
    } else if (lMonth) {
      os.println("MMYY");
    } else if (rMonth) {
      os.println("YYMM");
    } else {
      os.println("NA");
    }

  }
}

Measured memory_bytes: 23252
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    a,b,x = i_map()
    print(b//x - (a-1)//x)

if __name__=="__main__":
    main()


Measured memory_bytes: 9924
#include<iostream>
#include<map>
#include<algorithm>
#include<queue>

using namespace std;
int main(){
	int n; cin>>n;
	int d,x; cin>>d>>x;
	int ar[n];
	for(int i=0;i<n;i++) cin>>ar[i];

	int sum[1000]={0};
	for(int i=0;i<n;i++){
		int temp =1;
		while(temp <= d){
			sum[temp] += 1;
			temp += ar[i];
		}
	}
	for(int i=2;i<=d;i++) sum[i] += sum[i-1];
	cout<<x+sum[d];
	return 0;	
}

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

int main() {
	long ma,ans,olda,buf;
	buf = 1;
	int flag2 = 1;
	olda = 0;
	cin >> ma;
	for(long i = 0;i<ma;i++){
		cin >> ans;
		if(ans == olda-buf){
			buf = 0;
			olda = ans;
			continue;
		}
		if(ans < olda - buf){ 
			flag2 = 0;
			olda = ans;
		}
		olda = ans;
		buf = 1;
	}
	if(flag2)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
        	long A = sc.nextLong();
        	long B = sc.nextLong();
        	long C = sc.nextLong();
        	
        	if (A%2!=0||B%2!=0||C%2!=0) {
        		System.out.print("0");
        		return;
        	}
        	else if (A == B && B == C) {
        		System.out.print("-1");
        		return;
        	}
        	
        	swap(A,B,C);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    private void swap(long A, long B, long C){
    	long cnt = 0;
    	long mstA=A,mstB=B,mstC=C;
    	long tempA,tempB,tempC;
    	while (true) {
    		if (mstA%2!=0||mstB%2!=0||mstC%2!=0) break;
    		tempA=mstA/2;tempB=mstB/2;tempC=mstC/2;
    		mstA=tempB+tempC;
    		mstB=tempA+tempC;
    		mstC=tempA+tempB;
    		cnt++;
    	}
    	System.out.print(cnt);
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int firstPlace(string a, string b) { 
    int A = a.at(0), B = b.at(0);
    if (A < B) return true;
    else return false;
}

int main() {
    string a, b; cin >> a >> b;

    if (len(b) < len(a)) {
        cout << "GREATER" << endl;
        return 0;
    }
    else if (len(a) < len(b)) {
        cout << "LESS" << endl;
        return 0;
    }
    else if (a == b) { 
        cout << "EQUAL" << endl;
        return 0;
    }
    else if (len(a) == len(b)) {
        if (firstPlace(a, b)) {
            cout << "LESS" << endl;
            return 0;
        }
        else if (!firstPlace(a, b)) {
            cout << "GREATER" << endl;
            return 0;
        }
    }
}

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

int main() {
  int a,b,c,d;
  std::cin >> a >> b >> c >> d;
  if (a+b>c+d) {
    std::cout << "Left" << '\n';
  } else if(a+b<c+d) {
    std::cout << "Right" << '\n';
  } else {
    std::cout << "Balanced" << '\n';
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

bool f(string A, string B) {
	int N = A.size();
	if (A.size() != B.size()) {
		return false;
	}
	for (int i = 0; i < N; ++i) {
		if (A[i] != B[i])return false;
	}
	return true;
}

void solve() {
	string S;
	cin >> S;
	int N = S.size()-1;
	for (int i = N / 2; i >= 1; i--) {
		if (f(S.substr(0, i), S.substr(i, i))) {
			cout << (i*2) << endl;
			return;
		}
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

Measured memory_bytes: 256
N = int( input() )
red_Point  = [ list( map(int, input().split()) ) for _ in range(N) ]
blue_Point = [ list( map(int, input().split()) ) for _ in range(N) ]

blue_Point.sort()

ans = 0
# x 座標に小さい順に blue point を見ていく
for i in range(N):
    index = -1
    diff  = 200
    for j in range(len(red_Point)):
        if red_Point[j][0] < blue_Point[i][0] and red_Point[j][1] < blue_Point[i][1]:
            if blue_Point[i][1] - red_Point[j][1] < diff:
                diff = blue_Point[i][1] - red_Point[j][1] 
                index = j
    if index != -1:
        del red_Point[index]
        ans += 1

print( ans )

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

int main() {
  int n,a[110000],b[110000],c[110000];
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> a[i] >> b[i] >> c[i];
  
  int dp[110000][5];
  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] = max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
    dp[i][1] = max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
    dp[i][2] = max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
  }
  cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]}) << endl;
}


Measured memory_bytes: 6740
n=int(input())
f=[list(map(int, input().split())) for _ in range(n)]
p=[list(map(int, input().split())) for _ in range(n)]

from itertools import product
bits_l=list(product([0,1], repeat=10))
bits_l.remove((0,0,0,0,0,0,0,0,0,0))

ans=-float("inf")
for bits in bits_l:
    tmp_ans=0
    for shop in range(n):
        tmp_cnt=0
        for i, bit in enumerate(bits):
            if bit==1 and f[shop][i]==1:
                tmp_cnt+=1
        tmp_ans+=p[shop][tmp_cnt]
    ans=max(ans, tmp_ans)

print(ans)

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

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = (1 << 29);
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int main(int argc, char* argv[])
{
  const int MAX_K = 5;
  set<string> s;

  string str;
  cin >> str;
  int k;
  cin >> k;

  for (int len = 1; len <= MAX_K; len++) {
    for (int j = 0; j+len <= str.size(); j++) {
      s.insert(str.substr(j, len));
    }
  }

  auto it = s.begin();
  rep(i, k-1) {
    it++;
  }
  cout << *it << endl;

  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <cstdlib>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define REPV(i,n) for(vector<int>::size_type i=0;i<(n);i++)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
#define SORTR(v) sort((v).begin(),(v).end(),greater<ll>())
const ll INF = (1LL << 40);
typedef pair<int, int> P;
const int MOD = 1000000007;

int main() {

	int k;
	cin >> k;

	int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

	cout << a[k - 1] << endl;

	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#define MAX_N (100000)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define rep(i, n) for(int i = 0; i < n; i++)

int main(void) {
  int N;
  scanf("%d", &N);

  int A[MAX_N+1];
  rep(i, N+1) {
    scanf("%d", &A[i]);
  }
  int B[MAX_N];
  rep(i, N) {
    scanf("%d", &B[i]);
  }

  int64_t ANS = 0;
  rep(i, N) {
    int MIN = MIN(A[i], B[i]);
    ANS     += MIN;
    B[i]    -= MIN;
    int MIN2 = MIN(A[i+1], B[i]);
    ANS    += MIN2;
    A[i+1] -= MIN2;
  }

  printf("%ld\n", ANS);
  return 0;
}


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

s = abs(a[0])
for i in range(1, n):
  s += abs(a[i]-a[i-1])
s += abs(a[-1])

for i in range(n):
  if i==0:
    t1 = 0
  else:
    t1 = a[i-1]
  if i==n-1:
    t3 = 0
  else:
    t3 = a[i+1]
  t2 = a[i]
  ans = s+abs(t3-t1)-(abs(t3-t2)+abs(t2-t1))
  print(ans)

Measured memory_bytes: 14048
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
    string S;
    cin >> S;
    int N = S.size();
    long long dp[100001][4] = {};
    for(int i=N; i>=0; --i) {
        for(int j=3; j>=0; --j) {
            if(i==N) {
                dp[i][j] = (j == 3 ? 1LL : 0LL);
                continue;
            }
            dp[i][j] = dp[i+1][j] * (S[i] == '?' ? 3LL : 1LL);
            if(j < 3 && (S[i] == '?' || S[i] == "ABC"[j])) {
                dp[i][j] += dp[i+1][j+1];
            }
            dp[i][j] %= MOD;
        }
    }
    cout << dp[0][0] << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    std::string s;std::cin>>s;
    lint n=s.length();
    for(char c='a';c<='z';c++){
        std::vector<lint>a(n+1);
        for(lint i=0;i<n;i++){
            a.at(i+1)=a.at(i)+(s.at(i)==c?+1:-1);
        }
        for(lint l=0,r=2;r<=n;r++){
            if(a.at(l)>a.at(r-2))l=r-2;
            if(a.at(l)<a.at(r)){
                std::cout<<l+1<<' '<<r<<'\n';
                return 0;
            }
        }
    }
    std::cout<<-1<<' '<<-1<<'\n';
}


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

int main() {
    int l,r,d;
    cin>>l >>r >>d;
    if(l%d==0) cout<<r/d-l/d+1<<endl;
    else cout<<r/d-l/d<<endl;
}

Measured memory_bytes: 3560
#include<stdio.h>
#include<string.h>
#define LEN 100005
 
typedef struct pp{
  char name[100];
  int t;
}P;
 
P Q[LEN+1];
int head, tail, n;
P temp;
 
void enqueue(P x){ //push
 
  Q[tail]=x;
  if(tail==LEN)
    tail=1;
  else
    tail++;
 
}
 
P dequeue(){ //pop
  P x;
  x=Q[head];
   
  if(head==LEN)
    head=1;
  else
    head++;
 
  return x;
 
}
 
 
int main(){
  int elaps = 0, c;
  int i, q,remain,total=0;
  P u;
  scanf("%d %d", &n, &q);
 
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
 
  head=1;
  tail=n+1;
 
  while(head!=tail){
    temp=dequeue();
    remain=temp.t-q;
    if(remain>0) {
      total+=q;
      temp.t=remain;
      enqueue(temp);
    }
    else {
      total+=temp.t;
      printf("%s %d\n",temp.name,total);
    }
 
  }
 
   
   
    return 0;
}

Measured memory_bytes: 10756
n, x, m = gets.split.map(&:to_i)
memo = Array.new(10 ** 5 + 1, false)
tmp_nums = []
until memo[x]
  memo[x] = true
  tmp_nums << x
  x **= 2
  x %= m
end

tmp_nums_size = tmp_nums.size
first_x_index = tmp_nums.find_index(x)
not_loop_nums = tmp_nums[0, first_x_index]
not_loop_nums_size = not_loop_nums.size
loop_nums = tmp_nums[first_x_index..-1]
loop_nums_size = loop_nums.size

if n <= tmp_nums_size
  puts tmp_nums[0, n].sum
else
  ans = tmp_nums.sum
  rest = n - tmp_nums_size
  loop_count, mod = rest.divmod(loop_nums_size)
  ans += loop_nums.sum * loop_count
  ans += loop_nums[0, mod].sum
  puts ans
end


Measured memory_bytes: 15608
import collections
N = int(input())
A = [int(_) for _ in input().split()]


class Prime:
    @staticmethod
    def trial_division(x):
        if x % 2 == 0:
            return True
        for p in range(3, int(x**0.5 + 1), 2):
            if x % p == 0:
                return False
        return True

    @staticmethod
    def factorization(n):
        a = set()
        while n % 2 == 0:
            a.add(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.add(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.add(n)
        return a

    @staticmethod
    def miller_rabin(n):
        def suspect(a, t, n):
            x = pow(a, t, n)
            n1 = n - 1
            while t != n1 and x != 1 and x != n1:
                x = pow(x, 2, n)
                t <<= 1
            return t & 1 or x == n1

        if n == 2:
            return True
        if n < 2 or n % 2 == 0:
            return False
        d = (n - 1) >> 1
        while d & 1 == 0:
            d >>= 1

        if n < 2**32:
            check_list = (2, 7, 61)
        elif n < 2**48:
            check_list = (2, 3, 5, 7, 11, 13, 17, 19, 23)
        else:
            check_list = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37)

        for i in check_list:
            if i >= n:
                break
            if not suspect(i, d, n):
                return False
        return True


c = collections.defaultdict(int)
for a in A:
    for p in Prime.factorization(a):
        c[p] += 1
ans = 'pairwise coprime'
if c:
    x = max(c.values())
    if x == 1:
        ans = 'pairwise coprime'
    elif x == N:
        ans = 'not coprime'
    else:
        ans = 'setwise coprime'
print(ans)


Measured memory_bytes: 183396
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    vector<vector<int>> light(h, vector<int>(w));

    rep(i,h) {
        rep(j,w) {
            if (s[i][j] == '#') continue;
            int nj = j;
            while (nj+1 < w) {
                if (s[i][nj+1] == '#') break;
                nj++;
            }
            for (int k = j; k <= nj; k++) {
                light[i][k] += nj-j+1;
            }
            j = nj+1;
        }
    }
    rep(i,w) {
        rep(j,h) {
            if (s[j][i] == '#') continue;
            int nj = j;
            while (nj+1 < h) {
                if (s[nj+1][i] == '#') break;
                nj++;
            }
            for (int k = j; k <= nj; k++) {
                light[k][i] += nj-j+1;
            }
            j = nj+1;
        }
    }
    int ans = 0;
    rep(i,h)rep(j,w) {
        ans = max(ans, light[i][j]-1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 26440
import java.util.*;
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();
		
		if ((a+b+c)>=22){
			System.out.print("bust");
		}else{
			System.out.print("win");
		}
	}
}

Measured memory_bytes: 22736
a = int(input())
b = {}
for i in range(a):
    c = input()
    if c in b:
        b[c] += 1
    else:
        b.setdefault(c, 1)
a = int(input())
for i in range(a):
    c = input()
    if c in b:
        b[c] -= 1
    else:
        b.setdefault(c, 1)
b = sorted(b.values(), reverse=True)
print(max(b[0], 0))



Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int a, b, c,count;
		count = 0;
		a = scan.nextInt();
		b = scan.nextInt();
		c = scan.nextInt();

		for(;a<=b;a++){//a???b?????§????????°???????????????
			if(c%a == 0){count++;}
		}
		
		System.out.println(count);
	}
}

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


int main() {
  int N; cin >> N;
  int cnt = 0;
  vector<int> a(N);

  for(int i = 0; i < N; i++){
    cin >> a[i];
    while(a[i]%2 == 0){
      cnt++;
      a[i] /= 2;
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
s = gets.chomp
size = s.size
dp = Array.new(13, 0)
dp[0] = 1

s.size.times do |i|
  dp2= Array.new(13, 0)
  if s[i] != '?'
    si = s[i].to_i
    13.times do |j|
      dp2[(j*10 + si)%13] += dp[j]
    end
  else
    13.times do |j|
      dpj = dp[j]
      10.times do |k|
        dp2[(j*10 + k)%13] += dpj
      end
    end
    13.times do |j|
      dp2[j] %= MOD #=
    end
  end
  dp=dp2
#  p "----"; dp.each{|line| p line}
end

puts dp[5] % MOD

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define REP(a, b) for(int a = 0; a < b; a++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define mp make_pair
#define f first
#define s second
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> LL;
typedef vector<int> vi;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int h, w;
int A[405][405];
string s;
bool sudah[405][405];
ll black, white;

void dfs(int x, int y) {
	if (A[x][y] == 1) black++;
	else white++;
	
	if (x + 1 < h && sudah[x + 1][y] == 0 && A[x + 1][y] == 1 - A[x][y]) {
		sudah[x + 1][y] = 1;
		dfs(x + 1, y);	
	}
	if (x - 1 >= 0 && sudah[x - 1][y] == 0 && A[x - 1][y] == 1 - A[x][y]) {
		sudah[x - 1][y] = 1;
		dfs(x - 1, y);	
	}
	if (y + 1 < w && sudah[x][y + 1] == 0 && A[x][y + 1] == 1 - A[x][y]) {
		sudah[x][y + 1] = 1;
		dfs(x, y + 1);	
	}
	if (y - 1 >= 0 && sudah[x][y - 1] == 0 && A[x][y - 1] == 1 - A[x][y]) {
		sudah[x][y - 1] = 1;
		dfs(x, y - 1);	
	}
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> h >> w;
	REP(i, h) {
		cin >> s;
		REP(j, s.size()) {
			if (s[j] == '#') A[i][j] = 1; //BLACK
			else A[i][j] = 0; //WHITE
		}
	}
	ll res = 0;
	REP(i, h) {
		REP(j, w) {
			if (A[i][j] == 1 && sudah[i][j] == 0) {
				black = 0, white = 0;
				sudah[i][j] = 1;
				dfs(i, j);
				res = res + black * white;	
			}
		}
	}
	cout << res << '\n';
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define tr(container, it) \
	for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c,x) ((c).find(x) != (c).end())   //O(log n) 
#define contains(c,x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define Ichar(_x) char _x;scanf("%c",&_x);
#define Iint(_x) int _x;scanf("%d",&_x); 
#define Ill(_x)  ll _x;scanf("%lld",&_x);
#define inc(a,b,x)(x)>a && (x)<b	
#define incE(a,b,x)(x)>=a && (x)<=b	
//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);





int main()
{
	Ill(a);
	Ill(b);
	if(a*b<=0)std::cout << "Zero";
	else if ((a>0 && b>0) || (b - a) & 1)
	{
		std::cout << "Positive";
	}
	else { std::cout << "Negative"; }

}











Measured memory_bytes: 256
let input=readLine()!.characters.split(" ").map{Int(String($0))!}
let H=input[0],W=input[1]
let a=(0..<H).map{_ in readLine()!.characters.map{String($0)}}
var row=[Bool](count:H,repeatedValue:false)
var col=[Bool](count:W,repeatedValue:false)
for i in 0..<H{for j in 0..<W{if a[i][j]=="#"{row[i]=true;col[j]=true}}}
for i in 0..<H{if row[i]{for j in 0..<W{if col[j]{print(a[i][j],terminator: "")}};print()}}

Measured memory_bytes: 1408
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	static int MOD = (int)1e9 + 7;
	int N;
	int[] a;
	public void solve() {
		N = nextInt();
		a = new int[N];
		for(int i = 0;i < N;i++){
			a[i] = nextInt();
		}

		int[] abs = new int[N];
		for(int i = 0;i < N;i++){
			abs[a[i]]++;
		}

		long ans = 1;
		for(int i = N % 2 == 0 ? 1 : 0;i < N;i+=2){
			if(i == 0){
				ans *= abs[i] == 1 ? 1 : 0;
				ans %= MOD;
			}else{
				ans *= abs[i] == 2 ? 2 : 0;
				ans %= MOD;
			}
		}

		out.println(ans);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;


struct Edge{
  int to, cost;

  Edge(int t, int c = 0): to(t), cost(c)
  {}
  bool operator>(const Edge& rhs) const{
	return cost > rhs.cost;
  }
  bool operator<(const Edge& rhs) const{
	return cost < rhs.cost;
  }

};
using Graph = vector<vector<Edge>>;

void add_edge(Graph& graph, int u, int v, int cost = 0){
  graph[u].push_back(Edge(v,cost));
//  graph[v].push_back(Edge(u,cost));
}


bool topo_sort(const Graph& G, VI& order){
  order.clear();
  int N = G.size();
  VI color(N, 0);
  
  function<bool(int)> visit = [&](int v)->bool{
	color[v] = 1;
	for(const auto& e: G[v]){
	  if(color[e.to] == 2) continue;
	  if(color[e.to] == 1) return false;
	  if(!visit(e.to)) return false;
	}
	order.push_back(v);
	color[v] = 2;
	return true;
  };

  for(int u=0;u<N;++u)
	if(!color[u] && !visit(u))
	  return false;
  reverse(begin(order), end(order));
  return true;
}

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

  int N, M;
  cin >> N >> M;

  Graph G(N);
  REP(i,M){
    int x, y;
    cin >> x >> y;
    add_edge(G, x-1, y-1);
  }

  VI ord(N);
  topo_sort(G, ord);

  VI dp(N);
  for(int u: ord){
    for(auto e: G[u]){
      maxi(dp[e.to], dp[u] + 1);
    }
  }

  cout << *max_element(ALL(dp)) << endl;

  return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

bool f[inf] = {};

void _main() {
  int S;
  cin >> S;
  f[S] = true;

  int ans = 2;
  for (int t=S;; ans++) {
    if (t%2 == 0) t = t / 2;
    else          t = t * 3 + 1;
    if (f[t]) break;
    f[t] = true;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

int myf(int n){
  return n>0?n:-1*n;
}

int main(){
  int N;
  cin >> N;
  int nx=0,ny=0,nt=0;
  int x,y,t;
  LOOP(i,N){
    cin >> t >> x >> y;
    int d = myf(nx-x)+myf(ny-y);
    if(d>t-nt||((t-nt)-d)%2==1){
      cout << "No" << endl;
      return 0;
    }
    nx = x;ny = y;nt = t;
  }
  cout << "Yes" << endl;
}


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

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

    ll ans = 1;
    ll a;
    ll thresh = pow(10,18);
    bool overf = false;
    rep(i,N){
        cin >> a;
        if( a == 0){
            cout << 0 << endl;
            return 0;
        }
        if( ans*a > thresh || ans > thresh/a ) overf = true;
        ans = ans*a;
    }

    if( overf) cout << -1 << endl;
    else cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3524
#include<iostream>
#include<stack>
#include<string>
#include<cstdio>
#include<cstdlib>
using namespace std;
int main()
{
    string ss;
    stack<int> s;
    int a,b;
    while(cin>>ss)
    {

        if(ss[0]=='+')
        {
            a=s.top();
            s.pop();
            b=s.top();
            s.pop();
            s.push(a+b);
        }
        else if(ss[0]=='-')
        {
            a=s.top();
            s.pop();
            b=s.top();
            s.pop();
            s.push(b-a);
        }
        else if(ss[0]=='*')
        {
            a=s.top();
            s.pop();
            b=s.top();
            s.pop();
            s.push(a*b);
        }
        else
        s.push(atoi(ss.c_str()));
    }
    cout<<s.top()<<endl;
    return 0;
}

Measured memory_bytes: 3184
#!/usr/bin/env python3
import sys


def solve(N: int):
    memo = [[0]*10 for _ in range(10)]

    for num in range(1,N+1):
        s_num = str(num)
        memo[int(s_num[0])][int(s_num[-1])] += 1
    
    answer = 0
    for i in range(10):
        for j in range(10):
            answer += memo[i][j]*memo[j][i]
    
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<stdio.h>


#include<string.h>
int main()
{
    long long int ch[1000];
    char arr[1000];
    long long  int a,b,c,d,e=0,i=0,tep=0,temp=0,j=0,k=0,l=0,m=0,n=0;
    
    scanf("%lld",&a);
    scanf("%s",arr);
    k=strlen(arr);
    if(k<=a)
     {
      printf("%s\n",arr);
      
     }
    else
     {
      for(i=0;i<a;i++)
       {
        if(i==a-1)
          printf("%c...\n",arr[i]);
        else
          printf("%c",arr[i]);
       }
    
    
     }
    return 0;
}

Measured memory_bytes: 1724