akhauriyash/Code-Regression huggingface dataset:
#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>;

int main()
{
    string s;
    cin >> s;
    string r = s;
    reverse(r.begin(), r.end());
    int ans = 0;
    rep(i, s.size()) if (s[i] != r[i]) ans++;
    cout << ans / 2 << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node{
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node *find(Node *u, int k){
    while(u != NIL && k != u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node*)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }
        else{
            x = x->right;
        }
    }
    
    z->parent = y;
    
    if(y == NIL){
        root = z;
    }
    else{
        if(z->key < y->key){
            y->left = z;
        }
        else{
            y->right = z;
        }
    }
}

void inorder(Node *u){
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u){
    if(u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n, i, x;
    string com;
    
    scanf("%d", &n);
    
    for(i = 0; i < n; i++){
        cin >> com;
        if(com[0] == 'f'){
            scanf("%d", &x);
            Node *t = find(root, x);
            if( t != NIL) printf("yes\n");
            else printf("no\n");
        }
        else if(com == "insert"){
            scanf("%d", &x);
            insert(x);
        }
        else if(com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 22008
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <ctime>

using namespace std;
#define RN cout << "\r\n";
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef long long int ll;
typedef pair<ll, ll> P;

int main() {
    string a, b;
    cin >> a >> b;
    string ans = "No";
    REP(i, a.size()) {
        if (a.substr(i, a.size() - i) + a.substr(0, i) == b) {
            ans = "Yes";
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int W = sc.nextInt();

		int dp[] = new int[W+1];
		for(int i = 0; i < dp.length; i++){
			dp[i] = -1;
		}
		dp[0] = 0;

		int value,weight;

		for(int loop = 0; loop < N; loop++){

			value = sc.nextInt();
			weight = sc.nextInt();

			for(int i = W; i-weight >= 0; i--){
				if(dp[i-weight] == -1)continue;
				dp[i] = Math.max(dp[i],dp[i-weight]+value);
			}
		}

		int ans = 0;
		for(int i = 1; i <= W; i++){
			ans = Math.max(ans, dp[i]);
		}

		System.out.println(ans);
	}
}



Measured memory_bytes: 27204
#include<stdio.h>
int main(){
	int pasta[3],juice[2],i,i2,max=9999;
	for(i=0;i!=3;i++){
		scanf("%d",&pasta[i]);
	}
	for(i=0;i!=2;i++){
		scanf("%d",&juice[i]);
	}
	for(i=0;i!=3;i++){
		for(i2=0;i2!=2;i2++){
			if(max>pasta[i]+juice[i2]-50){
				max=pasta[i]+juice[i2]-50;
			}
		}
	}
	printf("%d\n",max);
}

Measured memory_bytes: 2656
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

int d[1111][2];
vector<ll> v[1111];

void dfs(int x,int t) {
  if(d[x][t]) return;
  d[x][t]=1;
  rep(i,v[x].size()) dfs(v[x][i],t^1);
}

void Main() {
  ll n,m;
  while(cin >> n >> m && n) {
    rep(i,n)v[i].clear();
    mem(d);
    rep(i,m) {
      int x,y;
      cin >> x >> y;
      x--,y--;
      v[x].pb(y);
      v[y].pb(x);
    }
    dfs(0,0);
    int x=0,y=0;
    rep(i,n) {
      x+=d[i][0];
      y+=d[i][1];
    }
    if(x+y!=n) {
      pr(0);
      continue;
    }
    set<int> s;
    if(x/2&&x%2==0) s.in(x/2);
    if(y/2&&y%2==0) s.in(y/2);
    pr(s.size());
    tr(it,s) pr(*it);
  }
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}



Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main(){
    string S;
    cin >> S;
    int i = (int)S.size()-1;
    if(S[i]=='s'){
        S += "es";
    }else{
        S += "s";
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 3628
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1e5+10
#define mod 1e9 + 7
#define pii pair<int,int>
using namespace std;
const int N = 1e5 + 1;
int n,m,i,j,l,k,x,y,a,b,cnt[3],sum[3];
/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	cout<<n*n;
    return 0;
}
//.........

Measured memory_bytes: 888
#include <stdio.h>
#include <string.h>
int main(void){
  char a[90],b[90];
  int n,i,f,m,x[90],y[90],s[90];
  scanf("%d",&n);
  while(n--){
    memset(x,0,sizeof(x));
    memset(y,0,sizeof(y));
    memset(s,0,sizeof(s));
    f=0;
    scanf("%s",a);
    scanf("%s",b);
    if(strlen(a)>80||strlen(b)>80)
      f=1;
    if(!f){
      m=strlen(a);
      for(i=m-1;i>=0;i--){
	x[m-1-i]=(int)a[i]-'0';
	//printf("%d",x[m-1-i]);
      }
      //printf("\n");
      m=strlen(b);
      for(i=m-1;i>=0;i--){
	y[m-1-i]=(int)b[i]-'0';
	//printf("%d",y[m-1-i]);
      }
      //printf("\n");
      m=(strlen(a)>strlen(b))?strlen(a):strlen(b);
      for(i=0;i<m;i++){
	s[i+1]=(s[i]+x[i]+y[i])/10;
	s[i]=(s[i]+x[i]+y[i])%10;
      }
      if(s[m])
	m+=1;
      if(m>80)
	f=1;
    }
    if(!f){
      for(i=m-1;i>=0;i--){
	printf("%d",s[i]);
      }
      printf("\n");
    }
    else{
      printf("overflow\n");
    }
  }
  return 0;
}

Measured memory_bytes: 612
N=int(input())
As = list(map(int,input().split()))
As.sort()
As=As[::-1]
ans = As.pop(0)
N=N-2
if N !=0:
    if N%2==0:
        ans +=sum(As[:N//2])*2
    else:
        ans +=sum(As[:(N-1)//2])*2
        ans +=As[(N-1)//2]

print(ans)

Measured memory_bytes: 31596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

//#define DEBUG


int main(void)
{
  ll A,B,C;
  cin >> A >> B >> C;
  
  if( ( A!=B && B!=C && C!=A) || ( A==B && B==C))
  {
    cout << "No";
  }
  else
  {
    cout << "Yes";
  }
  
  
  return 0;
} 

Measured memory_bytes: 256
ts = []
for _ in range(5):
    ts.append(int(input()))

min_r_t = 12
min_r_t_index = -1
for i, t in enumerate(ts):
    r_t = t % 10
    if r_t == 0:
        continue
    if r_t < min_r_t:
        min_r_t_index = i
        min_r_t = r_t

sum_t = 0
for i, t in enumerate(ts):
    if t % 10 == 0:
        sum_t += t
    elif i == min_r_t_index:
        sum_t += t
    else:
        sum_t += ((t // 10) + 1) * 10

print(sum_t)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

bool compare(pair<int, string> &a, pair<int, string> &b) {
	return a.first < b.first;
}


int main() {

	int n, m;
	cin >> n >> m;

	int cnt_AC = 0;
	int cnt_WA = 0;

	set<int> AC;
	map<int, int> WA;



	for (int i = 0; i < m; i++) {
		int p;
		string s;
		cin >> p >> s;
		auto it = AC.find(p);
		if (it == AC.end()) {

			if (s == "AC") {
				AC.insert(p);

			}
			else {
				WA[p]++;
			}
		}

	}

	cnt_AC = AC.size();
	for (auto it = WA.begin(); it != WA.end(); it++) {
		if (AC.find(it->first) != AC.end()) {
			cnt_WA += it->second;
		}
	}

	cout << cnt_AC << " " << cnt_WA << endl;
}

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

int main() {
  int N;
  cin >> N;
  if ((N / 10) % 111 == 0) cout << "Yes" << endl;
  else if ((N - (N / 1000 * 1000)) % 111 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3576
import sys
import heapq

def main():
	N = int(input())
	a = list(map(int, input().split()))

	left = a[0 : N]
	right = a[N*2 : N*3]

	for i in range(N):
		right[i] *= -1

	left_sum = 0
	right_sum = 0

	heap_left = []
	heap_right = []

	for i in range(N):
		left_sum += left[i]
		heapq.heappush(heap_left, left[i])
		right_sum += right[i]
		heapq.heappush(heap_right, right[i])

	temp1 = [0] * (N + 1)
	temp2 = [0] * (N + 1)

	temp1[0] = left_sum
	temp2[N] = right_sum

	for i in range(0, N):
		left_sum += a[N+i]
		heapq.heappush(heap_left, a[N+i])
		left_sum -= heapq.heappop(heap_left)
		temp1[i+1] = left_sum

	for i in range(0, N):
		right_sum -= a[N*2-1-i]
		heapq.heappush(heap_right, -a[N*2-1-i])
		right_sum -= heapq.heappop(heap_right)
		temp2[N - 1 - i] = right_sum

	ans = -100000000000000000000000000000000000000000
	for i in range(0, N + 1):
		x = temp1[i] + temp2[i]
		if(ans < x):
			ans = x
	print(ans)
main()

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H1,M1,H2,M2,K; cin>>H1>>M1>>H2>>M2>>K;
    int m = (H2-H1)*60+(M2-M1);
    cout<<m-K<<"\n";
    return 0;
}


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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

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

void solve()
{
    ll a, b;
    in2(a, b);
    if ((a + b) % 2 == 1)
    {
        out("IMPOSSIBLE");
    }
    else
    {
        out((a + b) / 2);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(long long)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const long long MAXS = 114514;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    string s,t;
    cin>>s>>t;
    reverse(All(s));
    reverse(All(t));
    int ss = s.size();
    int ts = t.size();
    bool can = false;
    for(int i=0;i<ss-ts+1;i++){
        bool ok = true;
        for(int j=0;j<ts;j++){
            if(s[i+j]!=t[j]&&s[i+j]!='?')ok = false;
        }
        if(ok){
            for(int j=0;j<ts;j++)s[i+j]=t[j];
            can = true;
            break;
        }
    }
    if(!can){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    for(int i=0;i<ss;i++){
        if(s[i]=='?')s[i]='a';
    }
    reverse(All(s));
    cout<<s<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int r = n%1000;
    if(r==0){
      System.out.println(0);
    }
    else{
    System.out.println(1000-r);
    }
  }
}

Measured memory_bytes: 35732
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
using namespace std;
char str[128];
char in[128];
int now[128];
vector<int>g[1100];
char ps[6][128];
int d[1100];
int dfs(int a,int b){
	if(a==b)return 1;
	for(int i=0;i<g[a].size();i++){
		if(dfs(g[a][i],b))return 1;
	}
	return 0;
}
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++)g[i].clear();
		gets(str);
		map<string,int> m;
		for(int i=0;i<a;i++){
			gets(str);
			int dep=0;
			for(int j=0;;j++){
				if(str[j]!=' ')break;dep++;
			}
			d[i]=dep;
			sscanf(str,"%s",in);
			string tmp=in;
			m[tmp]=i;
			now[dep]=i;
			if(dep)g[now[dep-1]].push_back(i);
		}
		for(int i=0;i<b;i++){
			for(int j=0;j<6;j++)scanf("%s",ps[j]);
			for(int j=0;ps[5][j];j++){
				if(ps[5][j]=='.')ps[5][j]=0;
			}
			string tmp=ps[0];
			int X=m[tmp];
			tmp=ps[5];
			int Y=m[tmp];
			bool ok=false;
			if(ps[3][0]=='c'){
				for(int j=0;j<g[Y].size();j++)if(g[Y][j]==X)ok=true;
			}else if(ps[3][0]=='p'){
				for(int j=0;j<g[X].size();j++)if(g[X][j]==Y)ok=true;
			}else if(ps[3][0]=='s'){
				if(d[X]||d[Y]){
					for(int j=0;j<a;j++){
						int x=0;int y=0;
						for(int k=0;k<g[j].size();k++){
							if(g[j][k]==X)x=1;
							if(g[j][k]==Y)y=1;
						}
						if(x&&y){
							ok=true;break;
						}
					}
				}else ok=true;
			}else if(ps[3][0]=='d'){
				if(dfs(Y,X))ok=true;
			}else if(ps[3][0]=='a'){
				if(dfs(X,Y))ok=true;
			}
			if(ok)printf("True\n");
			else printf("False\n");
		}
		printf("\n");
	}
}

Measured memory_bytes: 1256
from math import gcd

n=int(input().strip())
s=input().strip()

r = 0
g = 0
for i in s:
    if i == 'R':
        r += 1
    elif i == 'G':
        g += 1
ans = r * g * (n - r - g)

for i in range(0, n-1):
    for d in range(1, (n - i + 1) // 2):
        if s[i] != s[i+d] and s[i] != s[i+d+d] and s[i+d] != s[i+d+d]:
            ans -= 1
print(ans)


Measured memory_bytes: 9208
#include <stdio.h>

int main() {
	int a, b;
	
	scanf("%d %d", &a, &b);
	
	if(b%a==0){
		printf("%d", a+b);
	}
	
	else if(b%a!=0){
		printf("%d", b-a);
	}
	
	return 0;
}

Measured memory_bytes: 1708
#include <iostream>

int Judge(int n, int remain, int start)
{
	if (n == 1)
	{
		if (remain < 0)
		{
			return 0;
		}
		if (remain < start)
		{
			return 0;
		}
		if (remain > 9)
		{
			return 0;
		}
		return 1;
	}
	else
	{
		int ret = 0;
		for (int i = start; i < 9; ++i)
		{
			ret += Judge(n - 1, remain - i, i + 1);
		}
		return ret;
	}
}

int main()
{
	int n, s;

	while (std::cin >> n >> s )
	{
		if (n == 0 && s == 0)
		{
			break;
		}
		std::cout << Judge(n, s, 0) << std::endl;
	}

	return 0;
}

Measured memory_bytes: 2960
# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append('2')
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(str(f))
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(str(n))
    return a

def main():
    n = int(input())
    ans = prime_factorize(n)
    print(str(n) + ': ' + ' '.join(ans))

if __name__ == "__main__":
    main()



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )

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

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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll lcm(ll a, ll b) {
	return a*b/gcd(a,b);
}

ll factorial(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }
	if (n == r) { return 1; }

	if (r > n / 2) { r = n / 2; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) {
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int main() {
	int num; cin>>num;
	int ab=num/100,cd=num%100;

	if( (ab==0&&cd==0) || (ab>12&&cd>12) || (ab==0&&cd>12) || (ab>12&&cd==0)) {
		cout<<"NA"<<endl;
		return 0;
	}
	if(ab>12||(ab==0&&cd<13)) {
		cout<<"YYMM"<<endl;
		return 0;
	}
	if(cd>12||((cd==0&&ab<13))) {
		cout<<"MMYY"<<endl;
		return 0;
	}

	cout<<"AMBIGUOUS"<<endl;
}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



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

    cout <<setprecision(10) << 2*r*M_PI << endl;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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; }

__attribute__ ((constructor))
void init() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

vector<long long> calc_divisor(long long n) {//約数列挙
    vector<long long> res;
    for (long long i = 1LL; i*i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            long long j = n / i;
            if (j != i) res.push_back(j);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

signed main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    vector<int> div(1000100,0);
    rep(i,n){
        div[v[i]]++;
    }
    int ans = 0;
    rep(i,n){
        bool ok = 1;
        //cout << v[i] << "tern" << endl;
        for(auto u : calc_divisor(v[i])){
            if(div[u]>0 && u != v[i]){
                //cout << u << endl;
                ok = 0;
                break;
            }
        }
        if(div[v[i]] > 1) ok = 0;
        if(ok) ans++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 8008
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FXORMatching solver = new FXORMatching();
        solver.solve(1, in, out);
        out.close();
    }

    static class FXORMatching {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int m = in.nextInt(), k = in.nextInt();

            int n = 1 << m;

            int[] answer = new int[2 * n];

            HashSet<Integer> subset = new HashSet<>();

            int acc = 0;
            for (int i = 1; i < n; i <<= 1) {
                if ((i & k) > 0) {
                    acc ^= i;
                    subset.add(i);
                }
            }

            if (acc != k || (n == 2 && k != 0)) {
                out.println(-1);
                return;
            }

            int index = 0;
            for (int i = 0; i < n; i++) {
                if (subset.contains(i)) {
                    answer[index] = i;
                    index++;
                }
            }
            for (int i = 0; i < n; i++) {
                if (!subset.contains(i)) {
                    answer[index] = i;
                    index++;
                }
            }
            for (int i = n - 1; i >= 0; i--) {
                if (subset.contains(i)) {
                    answer[index] = i;
                    index++;
                }
            }
            for (int i = n - 1; i >= 0; i--) {
                if (!subset.contains(i)) {
                    answer[index] = i;
                    index++;
                }
            }

            StringBuilder sb = new StringBuilder();
            for (int x : answer) {
                sb.append(x + " ");
            }
            sb.deleteCharAt(sb.length() - 1);

            out.println(sb);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 49204
N, A, B = map(lambda x: int(x), input().split(" "))

if A == 0:
    print(0)
else:
    count = N // (A+B)
    result = count*A
    if (N-(count*(A+B))) >= A:
        result += A
    else:
        result += (N-(count*(A+B)))

    print(result)


Measured memory_bytes: 2940
{-# LANGUAGE BangPatterns, OverloadedStrings #-}

import Control.Monad
import Data.Array.Unboxed
import Data.Bits
import Data.Char
import Data.Coerce
import Data.Function
import Data.Int 
import Data.IORef
import Data.List
import Data.Maybe
import qualified Data.Map.Strict as M
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as MV
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  n <- getInt
  ns <- getIntVec n
  print $ sum [ 1 | i <- [0, 2.. n-1], odd (ns V.! i) ]

-- Input

getInt :: IO Int
getInt = readLn

second :: (b -> c) -> (a, b) -> (a, c)
second f (a, b) = (a, f b)

readInt :: BS.ByteString -> Maybe (Int, BS.ByteString)
readInt = fmap (second BS.tail) . BS.readInt

getIntVec :: Int -> IO (V.Vector Int)
getIntVec n = V.unfoldrN n readInt <$> BS.getLine
 
getIntList :: IO [Int]
getIntList = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

getIntegerList :: IO [Integer]
getIntegerList = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

getIntPair :: IO (Int, Int)
getIntPair = do
  v <- getIntVec 2
  return (v V.! 0, v V.! 1)

-- Search

bisearch :: (Int -> Bool) -> (Int, Int) -> (Int, Int)
bisearch check = bis
  where
    bis (l, r)
      | l + 1 == r = (l, r)
      | check mid  = bis (mid, r)
      | otherwise  = bis (l, mid)
      where
        mid = l + (r - l) `div` 2

-- Modular Arithmetic
--
 
modulo :: Int64
modulo = 10^9+7
addMod, subMod, mulMod :: Int64 -> Int64 -> Int64
addMod !x !y | x + y >= modulo = x + y - modulo
             | otherwise = x + y
subMod !x !y | x >= y = x - y
             | otherwise = x - y + modulo
mulMod !x !y = (x * y) `rem` modulo

newtype N = N { unwrapN :: Int64 } deriving (Eq)
instance Show N where
  show (N x) = show x
instance Num N where
  (+) = coerce addMod
  (-) = coerce subMod
  (*) = coerce mulMod
  fromInteger n = N (fromInteger (n `mod` fromIntegral modulo))
  abs = undefined; signum = undefined
---
 
exEuclid :: (Eq a, Integral a) => a -> a -> (a, a, a)
exEuclid !f !g = loop 1 0 0 1 f g
  where loop !u0 !u1 !v0 !v1 !f 0 = (f, u0, v0)
        loop !u0 !u1 !v0 !v1 !f g =
          case divMod f g of
            (q,r) -> loop u1 (u0 - q * u1) v1 (v0 - q * v1) g r
 
recipM :: Int64 -> Int64
recipM !x = case exEuclid x modulo of
             (1,a,_) -> a `mod` modulo
             (-1,a,_) -> (-a) `mod` modulo
divM :: Int64 -> Int64 -> Int64
divM !x !y = x `mulMod` recipM y
 
instance Fractional N where
  (/) = coerce divM
  recip = coerce recipM
  fromRational = undefined

-- 組み合わせ
powerset :: [a] -> [[a]]  
powerset xs = filterM (\x -> [True, False]) xs


Measured memory_bytes: 4172
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using vll = vector<ll>;
const ll INF = 1e15 + 5;
int main() {
	int n, W; cin >> n >> W;
	vi w(n), v(n);
	ll V = 0;
	for (int i = 0; i < n; i++){
		cin >> w[i] >> v[i];
		V += v[i];
	}

	vll dp1(V + 1, INF);
	dp1[0] = 0;
	for (int i = 0; i < n; i++){
		vll dp2(V + 1);
		for (int j = 0; j <= V; j++){
			dp2[j] = dp1[j];
			if (j - v[i] < 0) continue;
			dp2[j] = min(dp2[j], dp1[j - v[i]] + w[i]);
		}
		dp1 = dp2;
	}
	int mx = 0;
	for (int i = 0; i <= V; i++){
		if (dp1[i] <= W) mx = i;
	}
	cout << mx << endl;
}

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

int a[1009][1009];

signed main(){
  int h,w;
  cin>>h>>w;
  string s[h];
  a[0][0]=1;
  r(i,h)cin>>s[i];
  r(i,h){
    r(j,w){
      if(s[i][j]=='#')continue;
      a[i+1][j]+=a[i][j];
      a[i][j+1]+=a[i][j];
      a[i+1][j]%=1000000007;
      a[i][j+1]%=1000000007;
    }
  }
  if(s[h-1][w-1]!='#')cout<<a[h-1][w-1]<<endl;
  else cout<<0<<endl;
}

Measured memory_bytes: 9216
#include <iostream>
#include <map>
#include <vector>
using namespace std;

using lint = long long;
const lint MOD = 1e9 + 7;

lint minv(lint a) {
    lint inv = 1, rem = 1, pw = MOD - 2;
    while (pw > 1) {
        if (pw%2 == 1) {
            rem = (rem*a)%MOD;
        }
        a = (a*a)%MOD;
        pw /= 2;
    }
    return (a*rem)%MOD;
}

int main() {
    int n;
    cin >> n;
    map<int, int> m;
    int r1, r2;
    for (int i = 0; i < n + 1; i++) {
        int a;
        cin >> a;
        if (m[a] > 0) {
            r1 = m[a];
            r2 = i + 1;
        }
        m[a] = i + 1;
    }

    vector<lint> comb(n + 2);
    comb[0] = 1;
    for (int i = 1; i <= n + 1; i++) {
        comb[i] = ((comb[i - 1]*(n + 1 - i + 1))%MOD*minv(i))%MOD;
    }

    int c = (r1 - 1) + (n + 1 - r2);
    vector<lint> comb_c(c + 1);
    comb_c[0] = 1;
    for (int i = 1; i <= c; i++) {
        comb_c[i] = ((comb_c[i - 1]*(c - i + 1))%MOD*minv(i))%MOD;
    }
    for (int i = 1; i <= n + 1; i++) {
        if (i - 1 <= c) {
            cout << (comb[i] - comb_c[i - 1] + MOD)%MOD << endl;
        } else {
            cout << comb[i] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 7424
import java.util.Scanner;
  class Main{
    public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    
     while(true){    

     int a = scan.nextInt();
     String op = scan.next();
     int b =scan.nextInt();

       if(op.equals("+")){
           System.out.println(a+b);
       }else if(op.equals("-")){
           System.out.println(a-b);
       }else if(op.equals("*")){
           System.out.println(a*b);
       }else if(op.equals("/")){
           System.out.println(a/b);
       }else if(op.equals("?")) {
           break;
       }   
     }
  }
}


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

#define int long long
using namespace std;

int32_t main() {

    int n, W;
    cin >> n >> W;

    vector<int> w(n + 1), val(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> w[i] >> val[i];
    }
    int dp[n + 1][W + 1] = {};
    for (int i = 1; i <= n; i++) {
        for (int wt = 1; wt <= W; wt++) {
            if (w[i] <= wt)
                dp[i][wt] = max(dp[i - 1][wt], dp[i - 1][wt - w[i]] + val[i]);
            else
                dp[i][wt] = dp[i - 1][wt];
        }
    }
    cout << dp[n][W];
}



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

int main()
{
	vector<int> sample = { 5, 5, 7 };
	vector<int> final = { 0, 0, 0 };
	for (int i = 3; i > 0; --i){
		int a = 0;
		cin >> a;
		for (auto &elem : sample){
			if (elem == a){
				elem = 0;
				break;
			}
		}
	}

	if (sample == final){ cout << "YES" << endl; }
	else{ cout << "NO" << endl; }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n;
    cin >> n;
    
    vector<int> a(n), b(n), c(n);
    REP(i, n) cin >> a[i] >> b[i] >> c[i];

    int dp[3][n];
    REP(i, 3) REP(j, n) dp[i][j] = 0;

    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];

    for(int i = 1; i < n; i++) {
        dp[0][i] = max(dp[1][i-1], dp[2][i-1]) + a[i];
        dp[1][i] = max(dp[0][i-1], dp[2][i-1]) + b[i];
        dp[2][i] = max(dp[0][i-1], dp[1][i-1]) + c[i];
    }

    cout << max(max(dp[0][n-1], dp[1][n-1]), dp[2][n-1]) << endl;

    return 0;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A[3][3];
    rep(i, 3) rep(j, 3) cin >> A[i][j];
    int N; cin >> N;
    bool B[3][3] = {};
    int C[11];
    rep(i, N) {
        cin >> C[i];
    }
    rep(i, 3) {
        rep(j, 3) {
            rep(k, N) {
                if (A[i][j] == C[k]) B[i][j] = true;
            }
        }
    }
    if (B[0][0] && B[1][1] && B[2][2]) {
        cout << "Yes" << endl;
        return 0;
    } else if (B[2][0] && B[1][1] && B[0][2]) {
        cout << "Yes" << endl;
        return 0;
    }
    rep(i, 3) {
        if (B[i][0] && B[i][1] && B[i][2]) {
            cout << "Yes" << endl;
            return 0;
        }
        if (B[0][i] && B[1][i] && B[2][i]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <bitset>
using namespace std;

const long long int INF = 1000000007;

int main(void)
{
    int N;
    cin >> N;
    vector<long long> l(N);
    for (int i = 0; i < N; i++)
    {
        cin >> l[i];
    }

    sort(l.begin(), l.end());
    
    int count = 0;
    for (int i = 0; i < N - 2; i++)
    {
        for (int j = i + 1; j < N - 1; j++)
        {
            for (int k = j + 1; k < N; k++)
            {
                if (l[i] == l[j] || l[j] == l[k] || l[i] == l[k])
                {
                    continue;
                }
                
                if (l[k] < l[i] + l[j])
                {
                    count++;
                }
                
            }
        }
    }
    
    cout << count << endl;
    return 0;
}

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

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

Measured memory_bytes: 256
import itertools

n, m = [int(_) for _ in input().split(' ')]
edges = set()
for _ in range(m):
    a, b = [int(_) for _ in input().split(' ')]
    edges.add((a, b))
    edges.add((b, a))

answer = 0
for vertices in itertools.permutations(range(2, n + 1)):
    steps = [1] + list(vertices)
    if all([(steps[i], steps[i + 1]) in edges for i in range(n - 1)]):
        answer += 1
print(answer)


Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

n = readline()
l = list(map(int, readline().split()))
print('Yes' if sum(l) > 2 * max(l) else 'No')

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);

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

    int alice=0, bob=0;
    rep(i,n){
        i % 2 == 0 ? alice += a.at(i) : bob += a.at(i);
    }

    cout << alice - bob << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int N;
string S, T;
string res;

int main(){
    cin >> N;
    cin >> S >> T;
    
    for (size_t i = 0; i < N; i++) {
      res += S[i];
      res += T[i];
    }
  
    
    cout << res; 
    return 0;
}


Measured memory_bytes: 256
// @author: arch_

#include <bits/stdc++.h>
using namespace std;

constexpr int Nmax = 100;
constexpr int Mmax = 100;
array<array<int, Mmax>, Nmax> a;
array<int, Mmax> b;
array<int, Nmax> c;

int main(void) {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) cin >> a[i][j];
    for (int i = 0; i < m; i++) cin >> b[i];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) c[i] += a[i][j] * b[j];
    for (int i = 0; i < n; i++) cout << c[i] << "\n";
    return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int n;
    string s;
    cin >> n >> s;
    for (int i = 0; i < s.length(); ++i) {
        s.at(i) = (s.at(i) - 'A' + n) % 26 + 'A';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/tenka1-2018-beginner/tasks/tenka1_2018_d

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    m=0
    k=0
    for i in range(int(((8*N+1)**0.5-1)/2)+1):
        if i*(i+1)==2*N:
            m=i
            k=i+1
            break
    if m==0:
        print("No")
        exit()
    elif N==1:
        print("Yes")
        print(2)
        print(1,1)
        print(1,1)
    else:
        ml=[[] for i in range(k)]
        for i in range(1,k+1):
            ml[i-1].append(str(i))
            ml[i-2].append(str(i))
        for i in range(k+1,N+1):
            ml[(i-k-1)%k].append(str(i))
            l=(i-k-1)//k
            ml[(i-k-1+2+l)%k].append(str(i))
        print("Yes")
        print(k)
        for i in range(k):
            print(m, " ".join(ml[i]))
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 76368
N=gets.chomp.to_i
l=gets.chomp.split(' ').map(&:to_i)
cnt=0
l2=l.sort
l2.each_with_index { |a,i|
  ((i+1)...N).each { |j|
    ab=a+l2[j]
    cnt += (l2.bsearch_index{|m| m >= ab } || N)-1-j
  }
}
puts cnt

Measured memory_bytes: 1912
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        mut s: [chars; 3]
    }
    for i in 0..3 {
        s[i].reverse();
    }

    let mut cur = 0u8;
    loop {
        if let Some(src) = s[cur as usize].pop() {
            cur = src as u8 - b'a';
        } else {
            break;
        }
    }
    println!("{}", (cur + b'A') as char);
}


Measured memory_bytes: 4352
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int a = in.nextInt();
        String o = in.next();
        int b = in.nextInt();
        if (o.charAt(0)=='+')
            System.out.println(a+b);
        else
            System.out.println(a-b);


    }
}

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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

//bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

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


int main() {
    map<char, queue<char>> cards;
    {
        string as, bs, cs;
        cin >> as >> bs >> cs;

        for (char k : as) cards['a'].push(k);
        for (char k : bs) cards['b'].push(k);
        for (char k : cs) cards['c'].push(k);

    }

    char now = 'a';
    while (!cards[now].empty()) {
        char top = cards[now].front();
        cards[now].pop();
        now = top;
    }
    char ans = now + ('A' - 'a');
    cout << ans << endl;

}



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N = input()
if N[-1] in '24579':
    print('hon')
elif N[-1] in '0168':
    print('pon')
else:
    print('bon')

Measured memory_bytes: 61876
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	int k;
	cin >> k;
	set<int>p;
	ll x = 7;
	ll cnt(1);
	while (p.count(x) == 0) {
		p.insert(x);
		x %= k;
		if (x  == 0) {
			cout << cnt;
			return 0;
		}
		cnt++;
		x = (x * 10 + 7);

	}
	cout << -1;
	return 0;
}

Measured memory_bytes: 50492
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var a, b, c, k int
	fmt.Scan(&a, &b, &c, &k)

	x := []int{a, b, c}
	sort.Ints(x)
	fmt.Println(int(math.Pow(2, float64(k)))*x[2] + x[0] + x[1])
}


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

int main(){
	int n; cin >> n;
	int a[n];
	int cont=0;
	
	for (int i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a, a+n);
	
	bool encontrado=false;
	
	while (cont<n && !encontrado){
		if (a[cont]==a[cont+1]){
			encontrado=true;
		}
		cont++;
	}
	
	if (encontrado){
		cout << "NO";
	}
	else {
		cout << "YES";
	}
	
	return 0;
}

Measured memory_bytes: 1024
a = input()
n = len(a)
cnt = 1
l = [0] * n

for x in range(n - 1):
    if a[x] != a[x + 1]:
        l[x] = cnt
        cnt = 1
    else:
        cnt += 1

l[-1] = cnt

cnt = 0
idx = 0

for x in range(n):
    if l[x] != 0:
        cnt = 1 - cnt
        if cnt == 1:
            idx = x + 1
        else:
            l[idx] = l[x]
            if idx != x:
                l[x] = 0

i = 0
while i < n - 1:
    if l[i] == 0:
        i += 1
        continue

    b = l[i] + l[i + 1]

    if b % 2 == 1:
        if l[i] % 2 == 0:
            idx = i + 1
        else:
            idx = i

    l[i] = l[i + 1] = b // 2

    if b % 2 == 1:
        l[idx] += 1
        
    i += 2

for x in l:
    print(x, end = ' ')

Measured memory_bytes: 4864