akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int64_t gcd(int64_t n, int64_t m) {
    if (n % m == 0) {
        return m;
    } else {
        return gcd(m, n % m);
    }
}

int main() {
    int64_t n, m;
    string s, t;

    cin >> n >> m >> s >> t;

    int64_t d = gcd(n, m);

    int64_t answer = n / d * m;
    for (int64_t i = 0; i < d; i++) {
        if (s.at(i * n / d) != t.at(i * m / d)) {
            answer = -1;
            break;
        }
    }
    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
  static Scanner scan=new Scanner(System.in);
  public static void main(String[] args) {
    int n = scan.nextInt();

    int[] b = new int[n+1];
    for (int i = 1; i < n; ++i) {
      b[i] = scan.nextInt();
    }
    b[0] = b[n] = 100000000;

    int ans = 0;
    for (int i = 0; i < n; ++i) {
      ans += Math.min(b[i], b[i+1]);
    }

    System.out.println(ans);
  }
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string a, b;
	cin >> a >> b;
	a += b;
	stringstream ss;
	ss << a;
	int n;
	ss >> n;
	rep(i, 1, 1001)
	{
		if (n == i * i)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>











const int N=1e5+10;
int n,c[N+10],a,s,res;



void solve()
{
	for(int i=0;i<=N;i++)c[i]=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		c[a+1]++;
	}
	for(int i=1;i<N;i++)
	{
		s=c[i-1]+c[i]+c[i+1];
		if(i==1||res<s)res=s;
	}
	cout<<res<<"\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
#define endl "\n"
#define int long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fb(i, a, b) for(int i=a; i>=b; i--)
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define LB lower_bound
#define UB upper_bound
#define fp(x, y) fixed<<setprecision(y)<<x
#define PI 3.141592653589793238462643383279502884
using namespace std;

const int M = (int)1e5+5;
const int mod = (int)1e9+7;

void solve()
{
    int n;
    cin>>n;
    cout<<(1000-(n%1000))%1000<<endl;
}

int32_t main()
{
    IOS
    int t = 1;
    // cin>>t;
    f(tno, 1, t+1)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
import itertools as it
import collections as col
import heapq
import sys
sys.setrecursionlimit(10**9)
"""
N=int(input())
D=[]
for i in range(N):
  s,p=input().split()
  D.append((s, int(p), i+1))
D.sort(key=lambda d: (d[0], -d[1], d[2]))

for d in D:
  print(d[2])
"""
"""
N,M=map(int, input().split())
K=[]
S=[]
for i in range(M):
  k,*si=map(int, input().split())
  K.append(k)
  S.append(list(sorted(si)))
P=list(map(int, input().split()))

L=it.product([0,1], repeat=N)
cnt=0
#print(S)
for l in L:
  ok=True
  for i,si in enumerate(S):
    pi=P[i]
    sumS=len(list(filter(lambda it: l[it-1]==1, si)))
    #print(l, sumS)
    if sumS%2 != pi: ok=False
  if ok: cnt += 1
print(cnt)
"""
N,K=map(int,input().split())
V=list(map(int, input().split()))
M=max(N,K)

ans=0

#print(M)
for l in range(M+1):
  for r in range(M+1):
    if l+r<=min(N,K):
      H=[]
      U=list(V)
      H+=U[:l] + U[N-r:]
      H.sort(reverse=True)
      #print((l,r),U, H)
      for i in range(K-l-r):
        if H and H[-1] < 0: H.pop()
        else: break
      #print(sum(H), H)
      ans=max(ans, sum(H))
print(ans)


Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
 
int n, ans=0;
set<int> s;
bool div(int num){
	set<int> cnt;
	for(int j=1;j<=sqrt(num);j++){
		if(num % j == 0){
			cnt.insert(j);
			cnt.insert(num/j);
		}
	}
	if(cnt.size() == 8)
		return true;
	else
		return false;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	for(int i=1;i<=200;i+=2){
		if(div(i))
			s.insert(i);
	}
	cin>>n;
	for(auto it=s.begin();it!=s.end();++it){
		if(*it > n)
			break;
		ans++;
	}
	cout<<ans;
	return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k-1] = s[k-1] + 0x20;

    cout << s << endl;
    return 0;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define P 1000000007
using namespace std;
int n,k,ans;
int dp[52][5001][52];
int main(){
	scanf("%d%d",&n,&k);
	dp[0][2500][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=5000;j++){
			for(int k=0;k<=i;k++){
				int num=dp[i][j][k];
				dp[i+1][j][k]=(dp[i+1][j][k]+1ll*num*(k*2+1)%P)%P;
				dp[i+1][j-(i+1)*2][k+1]=(dp[i+1][j-(i+1)*2][k+1]+num)%P;
				if(k)dp[i+1][j+(i+1)*2][k-1]=(dp[i+1][j+(i+1)*2][k-1]+1ll*num*k*k%P)%P;
			}
		}
	}
	if(k+2500>5000)puts("0");
	else if(dp[n][k+2500][0]==-1)puts("0");
	else printf("%d\n",dp[n][k+2500][0]);
	return 0;
}

Measured memory_bytes: 51072
/*=======================
Author    : Shounak Dey
Filename  : b.cpp
=======================	*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define PB push_back
#define MK make_pair 
#define SZ(a) (int)(sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define read(n) scanf("%d",&n)
#define readl(n) scanf("%lld",&n)
#define readul(n) scanf("%llu",&n);


#define SORTV(a) sort(a.begin(),a.end())
#define TEST int Test;cin >> Test;while(Test--)
#define gcd(a,b) __gcd(a,b)
#define ffs(a) __builtin_ffs(a) // find first set
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)


#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

int main()
{
	fast_io;
	int x;
	cin >> x;
	int f=0;
	FOR(i,1,10){
		if((x%i)==0){
			if((x/i)<=9)
				f=1;
		}
	}	
	if(f)
		cout << "Yes" << endl;
	else
		cout << "No" <<endl;
	return 0;
}

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

int main() {
	char a[255], b[255], c[255];
	scanf("%s %s %s", &a, &b, &c);
	int lena = strlen(a);
	int lenb = strlen(b);
	int lenc = strlen(c);
	
	if(a[lena - 1] == b[0] && b[lenb - 1] == c[0]){
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	return 0;
}

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

#define MAX_D 70
#define MAX_N 60
#define INF 1<<30

int X[MAX_D][MAX_D];
int DP[MAX_D][MAX_D];
int Y[MAX_D][MAX_D];
int n, p, a;

int main() {
	while (true) {
		for (int i = 0; i < MAX_D; i++) {
			for (int j = 0; j < MAX_D; j++) {
				X[i][j] = 0;
				Y[i][j] = INF;
			}
		}
		cin >> n;
		if (n == 0) {
			break;
		}
		for (int i = 0; i < n; i++) {
			cin >> p;
			for (int j = 0; j < p; j++) {
				cin >> a;
				X[a][i] = 1;
			}
		}
		int res = INF;
		int res1 = 0;
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < MAX_D; k++) {
				for (int l = 0; l < MAX_D; l++) {
					DP[k][l] = 0;
				}
			}
			DP[0][j] = 1;

			for (int k = 1; k < MAX_D; k++) {
				for (int l = 0; l < n; l++) {
					if (DP[k - 1][l] == 1) {
						DP[k][l] = 1;
					}
				}
				vector<int>V;
				int ok = 0;
				for (int l = 0; l < n; l++) {
					if (X[k][l] == 1) {
						if (DP[k - 1][l] == 1) {
							ok = 1;
						}
						V.push_back(l);
					}
				}
				if (ok == 1) {
					for (int l = 0; l < V.size(); l++) {
						DP[k][V[l]] = 1;
					}
				}
			}
			for (int k = 0; k < n; k++) {
				for (int l = 0; l < MAX_N; l++) {
					if (DP[l][k] == 1) {
						Y[j][k] = min(Y[j][k], l);
					}
				}
			}
		}
		for (int i = 0; i < n; i++) {
			int res2 = 0;
			for (int j = 0; j < n; j++) {
				res2 = max(res2, Y[j][i]);
			}
			res = min(res, res2);
		}
		if (res >= INF) {
			cout << "-1" << endl;
		}
		else {
			cout << res << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<long long>a(N);
    long long sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
        sum += a.at(i);
    }
    
    vector<long long>count(N-1);
    vector<long long>dis(N-1);
    count.at(0) = a.at(0);
    dis.at(0) = abs((sum-count.at(0))-count.at(0));
    for (int i = 1; i < N-1; i++) {
        count.at(i) = count.at(i-1) + a.at(i);
        dis.at(i) = abs((sum-count.at(i))-count.at(i));
    }
    sort(dis.begin(), dis.end());
    cout << dis.at(0) << endl;
}


Measured memory_bytes: 8000
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
A = list(map(int, input().split()))
L = 50
dp = [[-float('inf')]*2 for _ in range(L+1)]
dp[0][0] = 0

for i in range(L):
    Ki = (K>>(L-1-i))&1
    
    for j in range(2):
        for k in range(2 if j else Ki+1):
            add = 0
            
            for Ai in A:
                add += k^((Ai>>(L-1-i))&1)
            
            dp[i+1][j|(k<Ki)] = max(dp[i+1][j|(k<Ki)], dp[i][j]+add*2**(L-1-i))
            
print(max(dp[L]))

Measured memory_bytes: 86640
from bisect import bisect_left

A, B, Q = map(int, input().split())
INF = 10**20
s = [-INF]
for i in range(A):
    s.append(int(input()))
s.append(INF)
t = [-INF]
for i in range(B):
    t.append(int(input()))
t.append(INF)

x = [int(input()) for i in range(Q)]

# x[i]の東にある神社・寺のうち１番近いのと２番めに近いものEastShrine EastTemple
# x[i]の西にある神社・寺のうち１番近いのと２番めに近いものをみてWest~~
# EastShrine,EastTemple
# EastShrine,WastTemple
# WestShrine,EastTemple
# WestShrine,WestTemple

# x[i]-s[i]の符号が変わるタイミングで近い２点を求める
# ではなく二分探索しましょう
# print(s)
# print(t)

for x_i in x:
    s_index = bisect_left(s, x_i)
    t_index = bisect_left(t, x_i)
    WestShrine, EastShrine = s[s_index - 1], s[s_index]
    WestTemple, EastTemple = t[t_index - 1], t[t_index]

    """
    for i in range(len(s)):
        if s[i] < x_i:
            pass
        elif s[i] == x_i:
            if abs(s[i - 1] - x_i) > abs(s[i + 1] - x_i):
                EastShrine = s[i + 1]
                WestShrine = s[i]
            else:
                EastShrine = s[i]
                WestShrine = s[i - 1]
        else:
            WestShrine = s[i - 1]
            EastShrine = s[i]
            #print(WestShrine, EastShrine)
            break
    """
    """
        if t[i] < x_i:
            pass
        elif t[i] == x_i:

            if i == 0:
                WestTemple = t[i]
                EastTemple = t[i + 1]
            elif i == len(t) - 1:
                WestTemple = t[i-1]
                EastTemple = t[i]

            if abs(t[i - 1] - x_i) > abs(t[i + 1] - x_i):
                EastTemple = t[i + 1]
                WestTemple = t[i]
            else:
                EastTemple = t[i]
                WestTemple = t[i - 1]
        else:
            WestTemple = t[i - 1]
            EastTemple = t[i]
            #print(WestTemple, EastTemple)
            break
        """
    #print("WS:", WestShrine, "ES:", EastShrine)
    #print("WT:", WestTemple, "ET:", EastTemple)

    ans1 = abs(max([EastShrine, EastTemple]) - x_i)
    ans2 = abs(min([WestShrine, WestTemple]) - x_i)

    smaller = min(abs(x_i - EastShrine), abs(x_i - WestTemple))
    larger = max(abs(x_i - EastShrine), abs(x_i - WestTemple))
    #print("S:", smaller, "L:", larger)
    ans3 = smaller * 2 + larger

    smaller = min(abs(x_i - WestShrine), abs(x_i - EastTemple))
    larger = max(abs(x_i - WestShrine), abs(x_i - EastTemple))
    ans4 = smaller * 2 + larger

    #print(WestShrine, EastShrine)
    #print(WestTemple, EastTemple)
    #print(ans1, ans2, ans3, ans4)
    print(min([ans1, ans2, ans3, ans4]))


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


int main(){
    int N,L;
    cin >> N >> L;
    int apple[N],m=0,ans=0;
    for (int i=0;i<N;++i){
        apple[i] = L + i;
    }
    
    for (int i=0;i<N;++i){
        if(abs(apple[m])>abs(apple[i])){
            m = i;
        }
    }

    ans = N*L + N*(N-1)/2 - apple[m];

    cout << ans << endl;

    }





Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int d;
int c[27];
int s[366][27];
vector<int> calc(vector<int> t){
    int last[26]={};
    vector<int> ret(d);
    int ans=0;
    for(int i=0; i<d; i++){
        ans+=s[i][t[i]-1];
        last[t[i]-1]=i+1;
        for(int j=0; j<26; j++){
            ans-=c[j]*(i+1-last[j]);
        }
        ret[i]=ans;
    }
    return ret;
}
int main()
{
    cin>>d;
    for(int i=0; i<26; i++) cin>>c[i];
    for(int i=0; i<d; i++) for(int j=0; j<26; j++) cin>>s[i][j];
    vector<int> t(d);
    for(int i=0; i<d; i++) cin>>t[i];
    auto ans=calc(t);
    for(int i=0; i<d; i++) cout<<ans[i]<<endl;
	return 0;
}


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

int main(void) {
    int x,y;
    for (;;) {
        cin >> x >> y;
        if(!x && !y) break;
        if (x < y) {
            cout << x << " " << y << endl;
        } else {
            cout << y << " " << x << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3104
# input
x, y = map(int, input().split())

A = [1, 3, 5, 7, 8, 10, 12]
B = [4, 6, 9, 11]
C = [2]

if (x in A and y in A) or (x in B and y in B):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define DEKAI 1000000007
#define INF (1<<28)
#define FDBST int hogehogehoge;cin>>hogehogehoge;

int main(){
	int n;
	cin>>n;
	int a[10000];
	lp(i,n) cin>>a[i];
	int q;
	cin>>q;
	int b;
	int count=0;
	lp(i,q){
		cin>>b;
		lp(j,n){
			if(a[j]==b){
				count++;
				break;
			}
		}
	}
	cout<<count<<endl;
	return 0;
}



Measured memory_bytes: 3120
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N; R(N);
    VI A(N);
    REP(i,N)R(A[i]);
    multiset<int>AA(ALL(A));
    int two=1;
    while(two<=*AA.rbegin())two<<=1;
    int an=0;
    while(SZ(AA)){
        int x=*AA.rbegin();
        while(two/2>x)two/=2;
        AA.erase(prev(AA.end()));
        if(AA.count(two-x)){
            an++;
            AA.erase(AA.find(two-x));
        }
    }
    W(an);
    return 0;
}

Measured memory_bytes: 10368
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<u64>();
    let (a, b) = (line[0], line[1]);

    if a%2 == 0  || b%2 == 0{
        println!("Even");
    }else{
        println!("Odd");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
 
int main() {
  int n; cin >> n;

  if(n == 1) {
    cout << "? 1" << endl;
    string tmp; cin >> tmp;
    if(tmp == "Red") {
      cout << "! RB" << endl;
    } else {
      cout << "! BR" << endl;
    }
    return 0;
  }


  vector<int> f(2*n);
  int l = 0, r = n;
  cout << "?";
  for(int i=0;i<n;++i) {
    cout << " " << (l+i) % (2*n) + 1;
  }
  cout << endl;
  string tmp1; cin >> tmp1;
  f[l] = tmp1 == "Red";
  cout << "?";
  for(int i=0;i<n;++i) {
    cout << " " << (r+i) % (2*n) + 1;
  }
  cout << endl;
  string tmp2; cin >> tmp2;
  f[r] = tmp2 == "Red";
  
  while(r - l > 1) {
    int mid = (l + r) / 2;
    cout << "?";
    for(int i=0;i<n;++i) {
      cout << " " << (mid+i) % (2*n) + 1;
    }
    cout << endl;
    
    string tmp; cin >> tmp;
    f[mid] = tmp == "Red";
    if(f[l] == f[mid]) {
      l = mid;
    } else {
      r = mid;
    }
  }


  //cout << l << endl;
  
  vector<int> col(2*n, -1);
  col[l] = f[l];
  col[(l+n)%(2*n)] = !f[l];
  for(int i=1;i<n;++i) {
    cout << "?";
    cout << " " << (l-i+2*n)%(2*n) + 1;

    for(int j=1;j<=n-1;++j) {
      cout << " " << (l+j) % (2*n) + 1;
    }
    cout << endl;
    string tmp; cin >> tmp;
    col[(l-i+2*n)%(2*n)] = tmp == "Red";
  }

  for(int i=1;i<n;++i) {
    cout << "?";
    cout << " " << (l+i) % (2*n) + 1;
    
    for(int j=1;j<=n-1;++j) {
      cout << " " << (l-j+2*n) % (2*n) + 1;
    }
    cout << endl;
    string tmp; cin >> tmp;
    col[(l+i)%(2*n)] = tmp == "Red";
  }


  cout << "! ";
  for(int i=0;i<2*n;++i) {
    assert(col[i] != -1);
    cout << (col[i] ? "R" : "B");
  }
  cout << endl;
}

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

int main() {
	int a[10],i,j,n;
	for(int i=0;i<10;i++){
	cin>>a[i];
	}for(i=0;i<9;i++){
	for(j=i+1;j<10;j++)
	if(a[i]<a[j]){
	n=a[i];
	a[i]=a[j];
	a[j]=n;
}
}	
cout<<a[0]<<endl<<a[1]<<endl<<a[2]<<endl;
	return 0;
}

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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if(s == "ABC")
    cout << "ARC"
         << "\n";
  else
    cout << "ABC"
         << "\n";
  return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 15, mod = 998244353;
int n,m;
char s[N][N];

int ans,pw[N],C[N][N],invC[N][N],f[N][N][3],g[N][N][3];
inline int power(int a,int b){
	int ret=1;
	for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) ret=1ll*ret*a%mod;
	return ret;
}
inline int Mod(int x){
	return x>=mod?x-mod:x;
}
inline void init(){
	C[0][0]=pw[0]=1;
	For(i,1,10){
		C[i][0]=1,pw[i]=pw[i-1]*2;
		For(j,1,i) C[i][j]=Mod(C[i-1][j-1]+C[i-1][j]),invC[i][j]=power(C[i][j],mod-2);
	}
	For(i,0,m) g[n][i][1]=1ll*C[m][i]*pw[m-i]%mod;
	Dow(i,n,0)
		Dow(j,m,0){
			For(k,1,n-i){
				f[i][j][1]=(f[i][j][1]+1ll*C[i+k][k]*g[i+k][j][1]%mod*(pw[k]-2))%mod;
				f[i][j][2]=(f[i][j][2]+(1ll*C[i+k][k]*(2*g[i+k][j][1])+1ll*C[i+k][k]*g[i+k][j][2]))%mod;
			}
			f[i][j][0]=Mod(f[i][j][1]+f[i][j][2]);
			For(k,1,m-j){
				g[i][j][1]=(g[i][j][1]+1ll*C[j+k][k]*f[i][j+k][1]%mod*(pw[k]-2))%mod;
				g[i][j][2]=(g[i][j][2]+(1ll*C[j+k][k]*(2*f[i][j+k][1])+1ll*C[j+k][k]*f[i][j+k][2]))%mod;
			}
			g[i][j][0]=Mod(g[i][j][1]+g[i][j][2]);
		}
	ans=0;
	For(i,1,m) ans=Mod(ans+f[0][i][1]);
	For(i,1,n) ans=Mod(ans+g[i][0][1]);
}

int main(){
	n=read(),m=read();
	For(i,1,n) scanf("%s",s[i]+1);
	init();
	For(i,1,(1<<n)-1)
		For(j,1,(1<<m)-1){
			bool flag=1;
			int p=0,q=0;
			For(k,1,n) if (i&(1<<k-1)){
				char x=' ';
				bool Flag=0;
				++p;
				For(l,1,m) if (j&(1<<l-1)){
					if (x==' ') x=s[k][l];
					if (s[k][l]!=x){Flag=1;break;}
				}
				if (!Flag){flag=0;break;}
			}
			if (!flag) continue;
			For(k,1,m) if (j&(1<<k-1)){
				char x=' ';
				bool Flag=0;
				++q;
				For(l,1,n) if (i&(1<<l-1)){
					if (x==' ') x=s[l][k];
					if (s[l][k]!=x){Flag=1;break;}
				}
				if (!Flag){flag=0;break;}
			}
			if (!flag) continue;
			ans=(ans+1ll*Mod(f[p][q][0]+g[p][q][0])*invC[n][p]%mod*invC[m][q])%mod;
		}
	printf("%d\n",ans);
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans=0,MIN=1e10;
  cin >> n;
  long long a[n],b[n];
  bool f=true;
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    ans+=a[i];
    if(a[i]>b[i]) MIN=min(MIN,b[i]);
    if(a[i]!=b[i]) f=false;
  }
  if(f){
    cout << 0 << endl;
    return 0;
  }
  cout << ans-MIN << endl;
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a < b){
		cout<<"a < b"<<endl;
	}else if (a > b) {
		cout<<"a > b"<<endl;
	}else if (a==b) {
		cout<<"a == b"<<endl;
	}
	return 0;
}



Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {

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

        String input_line[] = sc.nextLine().split(" ");
        int N=Integer.parseInt(input_line[0]);
        int M=Integer.parseInt(input_line[1]);
        int sum=0;
        sum=N*(N-1)/2+M*(M-1)/2;
        System.out.print(sum);
	}

}

Measured memory_bytes: 22996
n = int(input())
from itertools import permutations
itr = permutations([i for i in range(1, n + 1)])
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
for i, tpl in enumerate(itr):
  if tpl == p:
    idx1 = i
  if tpl == q:
    idx2 = i
print(abs(idx1 - idx2))

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, r;
  cin >> n >> r;
  (n >= 10) ? cout << r << "\n" : cout << r + 100*(10 - n) << "\n";
return 0;
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
li = []
cnt = 0
for i in range(n):
    li.append(i+1)
    if li[i] != p[i]:
        cnt += 1
if cnt == 0 or cnt == 2:
    print("YES")
else:
    print("NO")

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

using namespace std;
const int maxn=2e5+111;
int n;

int main(){
    scanf("%d", &n);
    int last=0, cnt;
    long long ans=0;
    for (int i=0; i<n; i++){
        scanf("%d", &cnt);
        if (i!=0){
            if (cnt<last) ans=ans+last-cnt;
        }
        last=max(last, cnt);
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 3828
import itertools
n = int(input())
a = list(map(int,input().split()))
ruisekiwa = [0] * n
cnt = 0
ruisekiwa[0] = a[0]
for i in range(1,n):
    ruisekiwa[i] = ruisekiwa[i-1] + a[i]
for i in range(n):
    cnt += a[i] * (ruisekiwa[-1] - ruisekiwa[i])
print(cnt % (10**9 + 7))

Measured memory_bytes: 104076
using System;
using System.Collections;
using System.Collections.Generic;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    void calc()
    {
        while (true)
        {
            string input = Console.ReadLine();
            if (input == null) break;
            string[] st = input.Split(' ');
            int a = int.Parse(st[0]);
            int b = int.Parse(st[1]);
            int g = gcd(a, b);
            Console.WriteLine(g + " " + ((long)a * b / g));
        }

    }

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

Measured memory_bytes: 5628
N = int(input())
a = [] # 行動をまとめて格納
for _ in range(N):
  x = list(map(int, input().split()))
  a.append(x)
dp = [[0, 0, 0] for _ in range(N)]
dp[0] = a[0]
for i in range(1, N):
  for j in range(3):
    dp[i][j] = max(dp[i-1][(j+1)%3] + a[i][j], dp[i-1][(j+2)%3] + a[i][j])
print(max(dp[-1]))

Measured memory_bytes: 47304
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define pr pair<int,int>
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt", "w", stdout);
    // #endif
  int n;cin>>n;
  vector<int> a(n);
  for(int i=0;i<n-1;i++)
    cin>>a[i];

  vector<int> b(n+1,0);
  for(int i=0;i<n-1;i++)
    b[a[i]]++;

  for(int i=1;i<=n;i++)
    cout<<b[i]<<"\n";
  return 0;
}

Measured memory_bytes: 4840
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    VI a(3); REP(i,3) cin >> a[i]; SORT(a);
    YN(a[0]==5&&a[1]==5&&a[2]==7);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  for(int i=10;i<10000;i++){
    if(a==floor(i*0.08)&&b==floor(i*0.1)){
      cout<<i;
      return 0;
    }
  }
  cout<<"-1";
  return 0;
}

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

using namespace std;

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

const ll mod = 1000000007;

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

  int k, q;
  cin >> k >> q;
  vector<ll> d(k);
  for (auto &y: d) cin >> y;
  vector<ll> n(q), x(q), m(q);
  for (int i = 0; i < q; i++) cin >> n[i] >> x[i] >> m[i];

  vector<ll> ans(q);
  for (int i = 0; i < q; i++) {
    vector<ll> d_mod(k);
    for (int j = 0; j < k; j++) {
      d_mod[j] = d[j] % m[i];
      if (d_mod[j] == 0) d_mod[j] = m[i];
    }
    vector<ll> d_sum(k+1);
    for (int i = 0; i < k; i++) d_sum[i+1] = d_sum[i] + d_mod[i];
    ll total = (x[i] % m[i]) + (d_sum[k] * ((n[i]-1) / k)) + d_sum[(n[i]-1)%k];
    ans[i] = (n[i] - 1) - (total / m[i]);
  }

  for (auto &y: ans) cout << y << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
using namespace std;
int main(void) {
    int w, a, b;
    cin >> w >> a >> b;
    if(b - (a+w) > 0) {
        cout << b - (a+w) << endl;
    } else if(a - (b+w) > 0) {
        cout << a - (b+w) << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = "0121313113131";
    int a = sc.nextInt();
    int b = sc.nextInt();
    boolean ans = s.charAt(a) == s.charAt(b);
    System.out.println(ans ? "Yes" : "No");
  }
}

Measured memory_bytes: 35640
import java.util.*;
 
// ABC 19-C
// http://abc019.contest.atcoder.jp/tasks/abc019_3
 
public class Main {
	
	static int MOD = 1000000007;

	public static void main (String[] args) throws java.lang.Exception {
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int m = in.nextInt();
		long answer = 0;
		
		long[] x = new long[n];
		long[] y = new long[m];
		
		for (int i = 0; i < n; i++) {
			x[i] = in.nextInt();
		}
		for (int i = 0; i < m; i++) {
			y[i] = in.nextInt();
		}
		
		long xx = 0;
		long yy = 0;
		for (int i = n - 1; i > 0; i -= 2) {
			xx += i * x[(n + i) / 2];
			xx -= i * x[(n - i) / 2];
		}
		for (int i = m - 1; i > 0; i -= 2) {
			yy += i * y[(m + i) / 2];
			yy -= i * y[(m - i) / 2];
		}
		
		System.out.printf("%d\n", ((xx % MOD) * (yy % MOD)) % MOD);
		
//		for (int i = 0; i < n; i++) {
//			for (int j = i + 1; j < n; j++) {
//				long xx = x[j] - x[i];
//				for (int k = 0; k < m; k++) {
//					for (int l = k + 1; l < m; l++) {
//						long yy = y[l] - y[k];
//						answer += xx * yy;
//						answer %= MOD;
//					}
//				}
//			}
//		}
//		
//		System.out.println(answer);
		
		
//		int t = in.nextInt();
//		int num = 1;
//		while (t-- > 0) {
//			int n = in.nextInt();
//			
//			while (!isTidy(n)) {
//				n--;
//			}
//			System.out.printf("Case #%d: %d\n", num, n);
//			num++;
//		}
	}	
	
	public static boolean isTidy(int n) {
		if (n < 10) {
			return true;
		}
		int pre = n % 10;
		n /= 10;
		int curr = n % 10;
		
		while (n > 0) {
			if (pre < curr) {
				return false;
			}
			pre = curr;
			n /= 10;
			curr = n % 10;
		}
		return true;
	}
}


Measured memory_bytes: 81452
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;

ll f(ll n, ll x)
{
    if (n == -1)
        return 0;
    else
        return n / x + 1;
}

int main()
{
    ll a, b, x;
    cin >> a >> b >> x;

    cout << f(b, x) - f(a - 1, x) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{	
	int a,b,k;
	scanf("%d%d%d",&a,&b,&k);
	int i,j;
	if(k>=b-a+1)
		for(i=a;i<=b;i++)
			printf("%d\n",i);
	else
	{
		for(i=a,j=0;j<k;i++,j++)
			printf("%d\n",i);
		if(a+k-1>=a+(b-a)/2)
			for(i=a+k;i<=b;i++)
				printf("%d\n",i);
		else
			for(i=b-k+1;i<=b;i++)
				printf("%d\n",i);
		
	}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <set>
#include <cmath>
#include <math.h>

using namespace std;
        
int main(){
    string s,t;
    cin>>s;
    cin>>t;
    int cnt=0,iti=60;
    for(int i=0;i<s.size()+1-t.size();i++){
        for(int j=0;j<t.size();j++){
            if(s[i+j]=='?'){
                cnt++;
            }else if(s[i+j]==t[j]){
                cnt++;
            }else{
                break;
            }
        }
        if(cnt==t.size()){
            iti=i;
        }
        cnt=0;
    }
    
    if(iti==60){
        cout<<"UNRESTORABLE"<<endl;
    }else{
        for(int i=0;i<iti;i++){
            if(s[i]=='?'){
                cout<<"a";
            }else{
                cout<<s[i];
            }
        }
        for(int i=0;i<t.size();i++){
            cout<<t[i];
        }
        for(int i=iti+t.size();i<s.size();i++){
             if(s[i]=='?'){
                cout<<"a";
            }else{
                cout<<s[i];
            }
        }
        cout<<endl;
    }
            
    return 0;
}

Measured memory_bytes: 256
def pkconv(s)
  ktable = [ ["X", "X", "X", "X", "X", "X"], \
             ["X", "a", "b", "c", "d", "e"], \
             ["X", "f", "g", "h", "i", "j"], \
             ["X", "k", "l", "m", "n", "o"], \
             ["X", "p", "q", "r", "s", "t"], \
             ["X", "u", "v", "w", "x", "y"], \
             ["X", "z", ".", "?", "!", " "]  ]
  return "NA" if s !~ /^([1-6][1-5])+$/
  f=s.scan(/../)
  g= f.map{|x|
    i,j=x.split(//).map{|y| y.to_i}
    ktable[i][j]
  }
  if g.index("NA") then
    return "NA"
  else
    return g.join
  end
end

def main
  if true then
    fh = STDIN
  else
    fh = open("in1_0127.txt")
  end
  while fh.gets do
    s=$_.chomp
    puts pkconv(s)
  end
end

if $0 == __FILE__ then
  main
end

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

using namespace std;

int main()
{
  int n,a,ans=1,sum=0;
  cin>>n;
  vector<int>v;
  for(int i=0;i<n;i++)
  {
      cin>>a;
      v.push_back(a);
  }

  for(int i=0;i<n;i++)
  {
      for(int j=i+1;j<n;j++)
      {
          if(i!=j)
          {
              ans=v[i]*v[j];
              sum+=ans;
          }
      }
  }
  cout<<sum<<endl;
    return 0;
}


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

#define fs first
#define sc second

typedef double D;
#define EQ(a,b) (abs((a)-(b)) < EPS)
const D EPS = 1e-8;

typedef complex<D> P;
namespace std {
    bool operator<(const P &a,const P &b){
        return real(a)==real(b)?imag(a)<imag(b):real(a)<real(b);
    }
}
D dot(P x,P y){return real(conj(x)*y);}
D cross(P x,P y){return imag(conj(x)*y);}
P unit(P p){return p / abs(p);}
P rotate(P v,double s){
    return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}
D arg(D a,D b,D c){return acos( (b*b+c*c-a*a)/(2*b*c) );}

typedef pair<P, P> L;
int ccw(P a,P b,P c){
    b -= a;c -= a;
    if (cross(b,c)>EPS) return 1; //counter clockwise
    if (cross(b,c)<-EPS) return -1; //clockwise
    if (dot(b, c)<-EPS) return 2; //c−−a−−b on line
    if (abs(b)<abs(c)) return -2; //a−−b−−c on line
    return 0; //on segment
}
D line_dis(L a,P x){return abs(cross(a.sc-a.fs,x-a.fs))/abs(a.sc-a.fs);}
bool is_cp(L a, L b) {
    if (ccw(a.fs, a.sc, b.fs) * ccw(a.fs, a.sc, b.sc) <= 0)
        if (ccw(b.fs, b.sc, a.fs) * ccw(b.fs, b.sc, a.sc) <= 0) return true;
    return false;
}

typedef pair<P, D> C;
vector<P> cp_cir_to_cir(C a, C b){
    vector<P> v;
    D s = arg(b.sc,abs(b.fs-a.fs),a.sc);
    P x = a.sc * unit(b.fs - a.fs);
    v.push_back(a.fs + rotate(x,s));
    v.push_back(a.fs + rotate(x,-s));
    return v;
}

int main() {
    int n;
    while(cin >> n, n) {
        vector<C> c(n);
        vector<tuple<P, int>> v;
        vector<L> check(n);
        for (int i = 0; i < n; i++) {
            double x, y, r; cin >> x >> y >> r;
            c[i] = {{x, y}, r};

            if (i == 0) {
                v.push_back(make_tuple(P{x, y}, 1));
                continue;
            }
            auto pts = cp_cir_to_cir(c[i-1], c[i]);
            for (auto x : pts) v.push_back(make_tuple(x, i));
            check[i] = {pts[0], pts[1]};
            if (i == n - 1) v.push_back(make_tuple(P{x, y}, i));
        }

        vector<double> done(v.size(), 1e9);
        typedef tuple<double, int> State;
        priority_queue<State, vector<State>, greater<State>> Q;
        done[0] = 0;
        Q.push(make_tuple(0, 0));
        while(Q.size()) {
            double cost; int vi;
            tie(cost, vi) = Q.top(); Q.pop();
            if (done[vi] < cost) continue;

            P from, to; int ci, ni;
            tie(from, ci) = v[vi];
            for (int i = 0; i < v.size(); i++) {
                if (vi == i) continue;

                tie(to, ni) = v[i];
                if (ni < ci) continue;

                bool flag = true;
                for (int j = ci; flag && j <= ni; j++)
                    if (!is_cp(check[j], {from, to})) flag = false;
                if (!flag) continue;

                if (done[i] > cost + abs(to - from)) {
                    done[i] = cost + abs(to - from);
                    Q.push(make_tuple(done[i], i));
                }
            }
        }
        printf("%.10lf\n", done[v.size() - 1]);
    }
}



Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.Integer.parseInt;

/**
 * The Secret Number
 */
public class Main {

	static final String EMPTY = "";

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int W, H;
			W = parseInt(line.substring(0, line.indexOf(' ')));
			H = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((W | H) == 0) break;

			char[][] numc;
			String[][] nums;

			numc = new char[H + 1][W + 1];
			nums = new String[H + 1][W + 1];

			for (int i = 0; i < numc.length; i++) {
				Arrays.fill(numc[i], 'X');
			}

			for (int i = 0; i < H; i++) {
				line = br.readLine();
				for (int j = 0; j < W; j++) {
					char c = line.charAt(j);
					numc[i][j] = (c <= '9' ? c : 'X');
				}
			}

			//solve
			for (int i = H - 1; i >= 0; i--) {
				for (int j = W - 1; j >= 0; j--) {
					if (numc[i][j] != 'X') {
						String s1 = (numc[i + 1][j] != 'X' ? nums[i + 1][j] : EMPTY);
						String s2 = (numc[i][j + 1] != 'X' ? nums[i][j + 1] : EMPTY);
						nums[i][j] = numc[i][j] + large(s1, s2);
					}
				}
			}

			String max = EMPTY;

			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if (nums[i][j] != null) {
						nums[i][j] = nums[i][j].replaceFirst("^0+", "");
						max = large(max, nums[i][j]);
					}
				}
			}

			System.out.println(max);

		} //end while

	} //end main

	static String large(String s1, String s2) {

		if (s1.length() > s2.length()) return s1;
		if (s1.length() < s2.length()) return s2;
		if (s1.equals(s2)) return s1;

		String ret = EMPTY;
		for (int i = 0; i < s1.length(); i++) {
			if (s1.charAt(i) > s2.charAt(i)) {
				ret = s1;
				break;
			} else if (s1.charAt(i) < s2.charAt(i)) {
				ret = s2;
				break;
			}
		}
		return ret;
	}
}

Measured memory_bytes: 64492
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{
    string A,B;
    cin>>A>>B;

    reverse(B.begin(),B.end());

    if(A==B){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
 
int main(){
  int n, l, r, ans = 0;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d%d", &l, &r);
    ans += r - l + 1;
  }
  printf("%d\n", ans);
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  long double xh, yh, xm, ym;
  long double thh = ((long double)h + (long double)m / 60.0) / 12.0 * 360.0;
  long double thm = (long double)m / 60.0 * 360.0;
  dump(thh, thm);
  xh = (long double)a * sin(thh * M_PI / 180.0);
  yh = (long double)a * cos(thh * M_PI / 180.0);
  xm = (long double)b * sin(thm * M_PI / 180.0);
  ym = (long double)b * cos(thm * M_PI / 180.0);
  dump(sin(thh*M_PI/180.0));
  dump(xh, yh, xm, ym);
  long double dx = abs(xh - xm);
  long double dy = abs(yh - ym);
  long double dis = sqrt(dx * dx + dy * dy);
  cout << dis << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

//for loop
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//abbreviati
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//constant
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***Snippet**************************************
ifelse, isprime, torad, todeg, lcm, bfs
************************************************/

//adjacency list
vector<int> to[100005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;cin >>n;
    if(400<=n && n<=599) cout << 8 ENDL;
    else if(600<=n && n<=799) cout << 7 ENDL;
    else if(800<=n && n<=999) cout << 6 ENDL;
    else if(1000<=n && n<=1199) cout << 5 ENDL;
    else if(1200<=n && n<=1399) cout << 4 ENDL;
    else if(1400<=n && n<=1599) cout << 3 ENDL;
    else if(1600<=n && n<=1799) cout << 2 ENDL;
    else if(1800<=n && n<=1999) cout << 1 ENDL;
    
    return 0;
}

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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define MP(v) make_pair(v)
#define F first
#define S second

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

  ll N, T;

  cin >> N >> T;

  ll m = 10000;
  ll c, t;
  for (ll i = 0; i < N; i++) {
    cin >> c >> t;

    if (t <= T) {
      m = min(c, m);
    }
  }

  if (m == 10000) {
    cout << "TLE"
         << "\n";
  } else {

    cout << m << "\n";
  }

  return 0;
}


Measured memory_bytes: 256