akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

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

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

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

fn main() {
    input! {
        x: i64,
    }
    if x >= 30 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2108
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(a[k-1])

Measured memory_bytes: 39856
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;

bool check(string now){
  string p = now;
  reverse(now.begin(),now.end());
  if(p == now) return true;
  else return false;
}

string now;

int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>now;
  
  string a1 = now.substr(0,(now.size())/2);
  string a2 = now.substr((now.size()+1)/2,now.size()/2);
  if(check(a1) && check(a2) && check(now)) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<map>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
int n;
ll a[100010];
int main(){
  scan(n);
  rep(i,n){
    scan(a[i]);
  }
  sort(a,a+n);
  vector<ll> vi;
  rep(i,n-1){
    if(a[i]==a[i+1]){
      vi.push_back(a[i]);
      i++;
    }
  }
  ll j=vi.size(),res;
  if(j>=2){
    res=vi[j-1]*vi[j-2];
  }
  else{
    res=0;
  }
  prin(res);

  

  

  

  return 0;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
#define ll long long
const int N=1e7+10,mod=998244353;
int n,mul,sum,fc[N],fi[N];
int main(){
	std::cin>>n;
	fc[0]=fc[1]=fi[0]=fi[1]=mul=1;
	for(int i=2;i<=n;i++)fc[i]=(ll)fc[i-1]*i%mod;
	for(int i=2;i<=n;i++)fi[i]=(ll)(mod-mod/i)*fi[mod%i]%mod;
	for(int i=2;i<=n;i++)fi[i]=(ll)fi[i-1]*fi[i]%mod;
	for(int i=1;i<=n;i++)mul=3ll*mul%mod;
	for(int i=n,s=1;i>=(n>>1)+1;i--,s=(s<<=1)>=mod?s-mod:s){
		sum=(sum+(ll)fc[n]*fi[i]%mod*fi[n-i]%mod*s)%mod;
		// std::cerr<<"> "<<i<<" "<<s<<" "<<std::endl;
	}
	// std::cerr<<mul<<" "<<sum<<std::endl;
	std::cout<<((ll)mul+(mod-sum<<1))%mod<<std::endl;
}

Measured memory_bytes: 78336
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#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 SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) REV(SORT(V)) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) for(int i = 0; i < (V).size(); i++) {cout << (V).at(i) << endl;}

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,x,y,z;
double d,e,f;
string s,t;
//

signed main() {
  RAPID;
  IN2(a,b);
  OUT(max({(a+b),(a-b),(a*b)}));
}

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

#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;

using Cint = cpp_int;

int main() {
	Cint m; cin >> m; Cint n; cin >> n; Cint max = 1000000007;
	Cint ans = powm(m, n, max);	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3284
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

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

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int result = 0;
        while (true) {
            String line = reader.readLine();
            if (line == null) {
                break;
            }
            for (int i = 0; i < line.length(); i++) {
                char ch = line.charAt(i);
                if (Character.isDigit(ch)) {
                    int m = ch - '0';
                    for (i = i + 1; i < line.length(); i++) {
                        ch = line.charAt(i);
                        if (!Character.isDigit(ch)) {
                            break;
                        }
                        m *= 10;
                        m += ch - '0';
                    }
                    result += m;
                }
            }
        }
        out.println(result);
    }
}

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

int main() {
	string s; cin >> s;
	map<char, int> res;

	for (int i = 0; i < s.length(); i++) {
		res[s[i]]++;
		if (res[s[i]] == 2) {
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
const int w=5e5+5;
const ll mod=1e9+7;
int a[w];
int main()
{
    int i,j;
    int n;
    cin>>n;
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    int ans=1e9;
    for(i=a[1];i<=a[n];i++)
    {
        int u=0;
        for(j=1;j<=n;j++)
            u+=(a[j]-i)*(a[j]-i);
        ans=min(ans,u);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

//divCeil
long divCeil(long a, long b){
    return (a-1)/b+1;
}

long n;
long x, y;

int main(){
    scanf("%ld", &n);
    x = y = 1;
    for(int i = 0; i < n; i++){
        long a, b;
        scanf("%ld%ld", &a, &b);
        long r = std::max(divCeil(x, a), divCeil(y, b));
        x = a * r;
        y = b * r;
    }
    printf("%ld\n", x+y);
}


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

const int ac = 100;
const int tle = 1900;
int main(void)
{
	int n, m, ans;
	cin >> n >> m;

	ans = 0;
	ans = ((n - m) * ac + m * tle) * pow(2, m);
	cout << ans << endl;
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h,w;
    while(cin>>h>>w,h!=0 && w!=0){
	reps(i,w){
	    cout<<'#';
	}
	cout<<'\n';
	reps(i,h-2){
	    cout<<'#';
	    reps(j,w-2){
		cout<<'.';
	    }
	    cout<<'#'<<'\n';
	}
	reps(i,w){
	    cout<<'#';
	}
	cout<<'\n'<<'\n';;
    }
    return 0;
}



Measured memory_bytes: 3136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication12
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var hw = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int h = hw[0];
                int w = hw[1];
                if (h == 0 && w == 0)
                    break;
                for (int a = 0; a < w; ++a)
                {
                    Console.Write("#");
                }
                Console.WriteLine();

                for (int b = 2; b < h; ++b)
                {
                    Console.Write("#");
                    for (int a = 2; a < w; ++a)
                    {
                        Console.Write(".");
                    }
                    Console.WriteLine("#");
                   
                }
                    for (int a = 0; a < w; ++a)
                    {
                        Console.Write("#");
                    }
                    
                Console.WriteLine();
                Console.WriteLine();
                }


            }
        }
    }

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

using ll = long long int;
using P = pair<ll, ll>;
using P3 = pair<double,P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9+7);
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-9;

void rec(int n, int k, string &s){
    if(n == 0){
        cout << s << endl;
        return;
    }
    int m = s.size();
    for(int i=0;i<=min(k+1,m);i++){
        s.push_back('a'+i);
        rec(n-1,max(k,i),s);
        s.pop_back();
    }
}

int main(){
    int n;
    cin >> n;
    string s;
    rec(n,0,s);
    return 0;
}

Measured memory_bytes: 1536
def hw(a,b):
  w = 0
  for i,j in zip(a,b):
    #print(i,j)
    if i == j:
      w+=1
  return w

s = input()
t = input()
ans = len(t)
tl = len(t)
for i in range(len(s)-tl+1):
  #print(s[i:i+tl])
  tmp = tl - hw(s[i:i+tl], t)
  ans = min(tmp, ans)
print(ans)
  

Measured memory_bytes: 9116
#include <iostream>
using namespace std;
int main(){
	int x,y;
	while(x,y>=0,x,y<=10000){
		cin>>x>>y;
		if(x == 0 && y == 0){
			break;
		}
		if(x<=y){
		cout<<x<<" "<<y<<endl;
		}
		else if(y<x){
		cout<<y<<" "<<x<<endl;
		}
	}
return 0;
}


Measured memory_bytes: 3024
/*
    キレそう
 */

#include <cstdio>
#include <cstring>
#include <vector>
#include <utility>
using namespace std;

typedef pair<char, int> Pair;

char buf[1000001];
vector<Pair> v;

int main() {
    char prev;
    int len;
    int count;
    int size;
    int ans;

    scanf("%s", buf);
    len = strlen(buf);
    prev = buf[0];
    count = 1;
    for (int i=1; i<len+1; i++) {
        if (prev == buf[i]) count++;
        else {
            v.push_back(Pair(prev, count));
            count = 1;
        }
        prev = buf[i];
    }

    ans = 0;
    size = v.size();
    for (int i=0; i<size-2; i++) {
        if (v[i].first == 'J' && v[i+1].first == 'O' && v[i+2].first == 'I') {
            if (v[i+1].second <= min(v[i].second, v[i+2].second)) {
                ans = max(ans, v[i+1].second);
            }
        }
    }

    printf("%d\n", ans);
}

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

typedef struct _TREE {
	vector <int> connect;
	long long startCnt;
	long long totalCnt;
} TREE;

TREE trees[200001];



void addCounters(int beforeTree, int thisTree, long long addCounter) {
	trees[thisTree].totalCnt = trees[thisTree].startCnt + addCounter;
	for (unsigned int i = 0; i < trees[thisTree].connect.size(); i++) {
		int connectedTree = trees[thisTree].connect[i];
		if (connectedTree == beforeTree) continue;

		addCounters(thisTree, connectedTree, trees[thisTree].totalCnt);
	}
}


int main(void) {
	int N, Q;
	cin >> N >> Q;

	// initialization
	for (int i = 1; i <= N; i++) {
		trees[i].connect.clear();
		trees[i].startCnt = 0;
		trees[i].totalCnt = 0;
	}
	// edge
	for (int i = 1; i <= N-1; i++) {
		int a, b;
		cin >> a >> b;
		trees[a].connect.push_back(b);
		trees[b].connect.push_back(a);
	}
	// counter
	for (int i = 1; i <= Q; i++) {
		int p, x;
		cin >> p >> x;
		trees[p].startCnt += x;
	}
	// calc
	addCounters(0, 1, 0);

	// answer
	for (int i = 1; i < N; i++) {
		cout << trees[i].totalCnt << " ";
	}
	cout << trees[N].totalCnt << endl;

	return 0;
}


Measured memory_bytes: 25856
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

ll GCD (ll x, ll y) {
  if (y == 0) return x;
  return GCD(y, x%y);
}
int main() {
    ll a,b; cin >> a >> b;
    ll ans = 1;
    ll gcd = GCD(a,b);
    for (ll i = 2; i <= ceil(sqrtl(gcd)); i++)
    {
        if (gcd % i == 0) {
            ans++;
            while (gcd % i == 0) {
                gcd /= i;
            }
        }
    }
    if (gcd != 1) ans++;
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
 
#define ll long long 
#define mkp make_pair 
#define fi first 
#define se second
#define pb push_back 
#define pf push_front 
#define ppb pop_back 
#define ppf pop_front 

using namespace std ;
 
int z , o , ans ;
 
int main(){
 
	int n ;

	cin >> n ;

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

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

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

				ans += __gcd(  __gcd( i , j ), u ) ;

			}

		}

	}

	cout << ans ;
 
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(void){
  int n,cnt=1;
  char s[100001];
  scanf("%d",&n);
  scanf("%s",s);
  for(int i=0;i<n-1;i++){
    if(s[i]!=s[i+1])cnt++;
  }
  printf("%d\n",cnt);
  return(0);
}

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

ll power(ll a, ll b){
    if(a == 1 || b == 0)
        return 1;
    ll so = power(a, b / 2);
    so = (so * so) % mod;
    if(b % 2 == 1)
        so = (so * a) % mod;
    return so;
    
}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == '1')
            ans++;
    }
    ans = power(2, ans);
    for(int i = 0, left = 0; i < n; i++){
        if(s[i] == '1'){
            ans = (ans + (power(2, left) * power(3, n - i - 1)) % mod) % mod;
            left++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=1e5+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
}
int n;
typedef pair<int,int> pii;
#define mk make_pair
#define fir first
#define sec second
vector<pii>E[N];

#define pb push_back
void input()
{	
	int x,y,z;
	n=read<int>();
	For(i,2,n)
	{
		x=read<int>(),y=read<int>(),z=read<int>();
		E[x].pb(mk(y,z)),E[y].pb(mk(x,z));
	}
}
int rt,rt_sz;
int size[N];
void dfs1(int u,int pre)
{
	size[u]=1;
	int mx=0;
	for(pii t:E[u])if(t.fir^pre)
	{
		dfs1(t.fir,u);
		size[u]+=size[t.fir];
		cmax(mx,size[t.fir]);
	}
	cmax(mx,n-size[u]);
	if(cmin(rt_sz,mx))rt=u;
}
ll dep[N];
void dfs2(int u,int pre)
{
	size[u]=1;
	for(pii t:E[u])if(t.fir^pre)
	{
		dep[t.fir]=dep[u]+t.sec;
		dfs2(t.fir,u);
		size[u]+=size[t.fir];
	}
}
ll ans;
const int inf=0x3f3f3f3f;
void work()
{
	rt=0,rt_sz=n;
	dfs1(1,0);
	dfs2(rt,0);
	For(i,1,n)ans+=dep[i];
	ans<<=1;
	int Min=inf;
	for(pii t:E[rt])
	{
		cmin(Min,t.sec);
		if(size[t.fir]==(n+1)/2)
		{
			ans-=t.sec,Min=0;
		}
	}
	write(ans-Min,'\n');
}
int main()
{
//	file();
	input();
	work();
	return 0;
}



Measured memory_bytes: 13568
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        String A = sc.next();
        String B = sc.next();
        if (A.length() > B.length()) {
            System.out.println("GREATER");
            return;
        } else if (A.length() < B.length()) {
            System.out.println("LESS");
            return;
        }
        for (int i = 0; i < A.length(); i++) {
            if (A.charAt(i) > B.charAt(i)) {
                System.out.println("GREATER");
                return;
            } else if (A.charAt(i) < B.charAt(i)) {
                System.out.println("LESS");
                return;
            }
        }
        System.out.println("EQUAL");
    }
}


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

int main() {
    std::string n;
    std::cin >> n;

    bool flag = false;
    for(int i = 1; i <= 2; i++) {
        if(n[i - 1] == n[i] && n[i] == n[i + 1]) {
            flag = true;
        }
    }

    if(flag) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int N, act[100010][3], dp[100010][3];
signed main() {
    cin >> N;
    for(int i=0; i<N; i++) {
        for(int k=0; k<3; k++) {
            cin >> act[i][k];
        }
    }

    fill(dp[0], dp[N+1], -1);
    for(int k=0; k<3; k++) dp[1][k] = act[0][k];
    for(int i=1; i<N; i++) {
        for(int k=0; k<3; k++) {
            if(dp[i][k] < 0) continue;
            for(int m=0; m<3; m++) {
                if(k == m) continue;
                chmax(dp[i+1][m], dp[i][k] + act[i][m]);
            }
        }
    }

    int ans = max({dp[N][0], dp[N][1], dp[N][2]});
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
a = int(s[:2])
b = int(s[2:])
if a > 0 and a <= 12:
    if b > 0 and b <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if b > 0 and b <= 12:
        print('YYMM')
    else:
        print('NA')


Measured memory_bytes: 39532
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const int MX = 1000005;


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    sort(whole(a));
    vector<int> cnt(MX);
    rep(i, n) {
        if (cnt[a[i]]!=0) {
            cnt[a[i]]++;
            continue;
        }
        for (int j=a[i]; j<MX; j+=a[i]) {
            cnt[j]++;
        }
    }

    rep(i, n) {
        if (cnt[a[i]]==1) ans++;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8012
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define ini 0
using namespace std;

int rlay[100001];

int main (){

while (1){

memset(rlay ,0 ,sizeof(rlay));
int n,k,input,ansmax=0;
cin>>n>>k;
if (n==0 && k==0)break;

rlay[0]=ini;
for (int i=1;i<=n;i++){
        cin>>input;
        rlay[i]=input+rlay[i-1];
}

for (int i=n;i-k>0;i--){
        ansmax = max ( rlay[i]-rlay[i-k] ,ansmax );
}

cout<<ansmax<<endl;
}

return 0;
}



Measured memory_bytes: 3488
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;

typedef long long ll;

int used[100003];

int main() {
	int N, K; cin >> N >> K;
	vector<pair<ll, int>> a(N);
	for (int i = 0; i < N; i++) cin >> a[i].second >> a[i].first;
	sort(a.rbegin(), a.rend());
	ll x = 0, sum = 0;
	for (int i = 0; i < K; i++) {
		int t = a[i].second;
		ll d = a[i].first;
		if (!used[t]) x++;
		used[t]++;
		sum += d;
	}
	vector<pair<ll, int>> b;
	for (int i = K - 1; i >= 0; i--) {
		int t = a[i].second;
		ll d = a[i].first;
		if (used[t] <= 1) continue;
		b.push_back({ d, i });
		used[t]--;
	}
	if (b.empty()) {
		cout << sum + x*x << endl;
		return 0;
	}
	ll ans = sum + x*x;
	reverse(b.begin(), b.end());
	for (int i = K; i < N; i++) {
		if (b.empty()) break;
		int t = a[i].second;
		ll d = a[i].first;
		if (used[t]) continue;
		sum -= b.back().first;
		b.pop_back();
		sum += d;
		used[t]++;
		x++;
		ans = max(ans, sum + x*x);
	}
	cout << ans << endl;
	return 0;
}

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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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! {
        n: usize,
        k: usize,
        d: [usize; k],
    }

    let mut n = n;
    let mut usable = vec!(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);

    for e in d {
        let idx = usable.binary_search(&e).unwrap();

        usable.remove(idx);
    }

    loop {
        if matches(&usable, n) {
            break;
        }

        n += 1;
    }

    println!("{}", n);
}

fn matches(v: &Vec<usize>, n: usize) -> bool {
    let n_str = n.to_string();

    for e in n_str.chars() {
        let e = e.to_digit(10).unwrap() as usize;

        if v.binary_search(&e).is_err() {
            return false;
        }
    }

    true
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>
#include <math.h>
using namespace std;

#define ll long long

int main() {
	int n;
	cin >> n;
	int a, b, c, hoge;
	for (int i = n;; i++) {
		hoge = i;
		a = hoge % 10;
		hoge /= 10;
		b = hoge % 10;
		hoge /= 10;
		c = hoge % 10;
		if (a == b && b == c) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#define PII pair<int,int>
#define MIS map<int,set<int>,greater<int> >
#define MII map<int,int>
using namespace std;
int main()
{
  int n,c;
  MIS m;
  for(;;){
    scanf("%d,%d", &n, &c);
    if(n == 0 && c == 0) break;
    m[c].insert(n);
  }
  MII l;
  n = 1;
  for(MIS::iterator it = m.begin(); it != m.end(); it++, n++){
    set<int>::iterator p = (*it).second.begin();
    while(p != (*it).second.end()){
      l[(*p)] = n;
      p++;
    }
  }
  while(cin >> n){
    cout << l[n] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	
	static int minusCnt(int[] a){
		int count = 0;
		for(int i=0; i<a.length; i++)
			if(a[i] < 0) count++;
		return count;
	}
	
	static int[] minusIdx(int[] a,int cnt){
		int[] idx = new int[cnt];
		int j=0;
		for(int i=0; i<a.length; i++)
			if(a[i] < 0) idx[j++] = i;
		return idx;
	}
	
	//最大値
	static int maxOf(int[] a){
		int max = a[0];
		for(int i:a)
			if(max < i) max = i;
		return max;		
	}
	
	//最小値
	static int minOf(int[] a){
		int min = a[0];
		for(int i:a)
			if(min > i) min = i;
		return min;		
	}
	
	//[配列]を表示して改行.
	static void aryPrint(int[] a){
		for(int i : a) System.out.print(i + " ");
		System.out.println();
	}
	
	static int LsumUp(int[] a,int idx){
		int x=0;
		for(int i=0; i<=idx; i++) x +=a[i];
		return x ;
	}
	
	static int RsumUp(int[] a,int idx){
		int y=0;
		for(int i=idx; i<a.length; i++) y +=a[i];
		return y ;
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n;
		do{
			n = stdIn.nextInt();
			if(n==0) break;
			int[] a = new int[n];
			int sum = 0;
			for(int i=0; i<n; i++){
				a[i] = stdIn.nextInt();
				sum += a[i];
			}
			int cnt = minusCnt(a);
			if(cnt==0){ System.out.println(sum); continue; }
			if(cnt==a.length || cnt == a.length-1){System.out.println(maxOf(a)); continue; }
			
			int[] minusIdx = minusIdx(a,cnt); //負の要素の番号を
			
			int[] Lbest = new int[minusIdx.length];
			int[] Rbest = new int[minusIdx.length];
			
			for(int i=0; i < minusIdx.length; i++){
				 Lbest[i] = LsumUp(a,minusIdx[i]);
				 Rbest[i] = RsumUp(a,minusIdx[i]);
			}
			int best=0;
			if(best > minOf(Lbest)) best = minOf(Lbest);
			if(best > minOf(Rbest)) best = minOf(Rbest);
			for(int i=0; i<minusIdx.length-1; i++){
				for(int j=i+1; j<minusIdx.length; j++) if(best > (Lbest[i]+Rbest[j])) best = Lbest[i]+Rbest[j];
			}
			System.out.println(sum-best);
		} while(true);
	}
}

Measured memory_bytes: 13000
<?php
$N = (int)fgets(STDIN);

if ($N === 2) {
    echo 1;
    return;
}

$ans = 2;
for ($K = 2; $K <= (int)sqrt($N) ;$K++) {
    if (($N - 1) % $K === 0) {
        $ans += 1;
        if ($K * $K !== $N - 1) {
            $ans += 1;
        }
        continue;
    }
    $n = $N;
    while ($n % $K === 0) {
        $n = $n / $K;
    }
    if ($n % $K === 1) {
        $ans += 1;
    }
}

echo $ans;

Measured memory_bytes: 16220
function main(arg) {
	arg = Number(arg.split("\n")[0])

	var master = [0, 3,5,7]
	var counter = 0;

	for (var i = 0;;i++) {
		var tmp = String(i.toString(4))
		var _tmp = "";

		if (tmp.length < 3) {
			continue;
		}

		if (tmp.indexOf('0') !== -1) {
			continue;
		}

		var b = tmp.split("").filter(function (x, i, self) {
            return self.indexOf(x) === i;
        });

		if (b.length < 3) {
			continue;
		}


		for (var j = 0; j < tmp.length; j++) {
			_tmp += master[tmp[j]]
		}

		if (_tmp > arg) {
			break;
		}
		counter++
	}
	console.log(counter)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 10480
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

int main()
{
    int n;  cin >> n;
    int ans;
    int max = 0;


    for (int i = n; i >= 1; i--){
        int a = i;
        int cnt = 0;
        while(a % 2 == 0){
            if (a >= 1){
                cnt++;
                a /= 2;
            }
        }

        if (max <= cnt){
            max = cnt;
            ans = i;
        }
    }
    cout << ans << endl;
}

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

int a[20];
int q[20][20];
int p[20];

int N,M;
int main () {
    cin >> N >> M;
    for(int i=0; i<M; i++) {
        int k;
        cin >> k;
        a[i] = k;
        for(int j=0; j<k; j++) {
            int x;
            cin >> x;
            x--;
            q[i][j] = x;
        }
    }
    for(int j=0; j<M; j++) cin >> p[j];

    int ans = 0;
    for(int i=0; i<(1<<N); i++) {
        bool ok = true;

        for(int j=0; j<M; j++) {
            int cnt = 0;

            for(int k=0; k<a[j]; k++) {
                if( i & (1<<q[j][k]) ) cnt++;
            }
            if(cnt % 2 != p[j]) ok = false;
        }
        if(ok) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

const int N=(int)1e7+7;
ll prm[N];

void seive(){
    for(int i=2;i<N;i++){
        if(prm[i]==0){
            for(int j=i;j<N;j+=i)
                prm[j]=i;
        }
    }
}

int main(){
    nimble
    seive();
    ll n;
    cin>>n;
    ll as=1;
    for(ll i=2;i<=n;i++){
        ll x=i;
        ll tmp=1;
        while(x>1){
            ll f=0;
            ll y=prm[x];
            while(x%y==0){
                x/=y;
                f++;
            }
            tmp*=(f+1);
        }
        as+=i*tmp;
    }
    cout<<as<<nl;
    return 0;
}


Measured memory_bytes: 81780
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <numeric>
#include <cstdlib>

#define rep(i, n) for (int i = 0; i < n; ++i)
typedef unsigned long long ll;

using namespace std;

int main()
{
    ll n, k;
    cin >> n >> k;
    ll divide = n/k;
    n -= divide * k;
    while (true)
    {
        if ( labs(n-k)>= n)
            break;
        n = labs(n - k);
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    System.out.print("A");
    System.out.print(S[1].charAt(0));
    System.out.println("C");
  }
}

Measured memory_bytes: 23252
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

N,L = na()
a=[]
b = 10000000000

for i in range(L,L+N):
    a.append(i)
    b = i if min(abs(b),abs(i)) == abs(i) else b

print(sum(a)-b)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
 
int cnt[100000 + 10];
 
int main()
{
	int n; scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		int x; scanf("%d", &x);
		cnt[x]++;
	}
	int odd = 0, even = 0;
	for(int i = 1; i <= 100000; i++) if(cnt[i]) {
		if(cnt[i] & 1) odd++;
		else even++;
	}

	int ans = odd + even;
	if(even & 1) ans--;
	printf("%d\n", ans);
 
	return 0;
}

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

#define MAX 201

int main(){
  int m,h,i,j,k;
  char x[MAX],y[MAX],z[MAX];

  int cnt;
  int cnt_max;
  char ans[10][MAX];

  cnt = 0;
  while(1)
  { 
    if (cnt >= 10) break;

    scanf("%s",x);    // シャッフルされる文字列

    if (x[0]=='-') break;

    scanf("%d",&m);   // シャッフル回数

    // シャッフル回数分ループ
    for(k=0;k<m;k++)
    {
      scanf("%d",&h); // シャッフル位置

      // シャッフルされる文字列を代入
      for(i=0;i<h;i++)
      {
	      y[i]=x[i];
      }
      y[i]='\0';

      // シャッフルしない文字列を代入
      for(i=h,j=0;i<strlen(x);i++)
      {
        z[j]=x[i];
        j++;
      }
      z[j]='\0';

      // シャッフルしない文字列にシャッフルする文字列を連結
      strcat(z,y);

      // zの文字列をxに移し替え
      for(i=0;i<=strlen(x);i++)
      {
        x[i]=z[i];
      }
      // zの最後を\0に変える
      memset(z, '\0', sizeof(z));
    }
    // // x表示
    // printf("%s\n",x);
      memcpy(ans[cnt], x, sizeof(x));
      cnt++;
      cnt_max = cnt;
  }

  for (cnt = 0; cnt < cnt_max; cnt++)
  {
    // 表示
    printf("%s\n",ans[cnt]);
  }
  
  return 0; 
}


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

using namespace std;

vector< vector< int64_t > > get_combination(int N, int M) {
  vector< vector< int64_t > > mat(N + 1, vector< int64_t >(N + 1));
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if(j == 0 || j == i) mat[i][j] = 1;
      else mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
      mat[i][j] %= M;
    }
  }
  return (mat);
}

int main() {
  int N, K, M;
  cin >> N >> K >> M;
  auto C = get_combination(N, M);
  int dp[302][302] = {{}};
  for(int i = 0; i <= K; i++) {
    dp[1][i] = 1;
  }
  for(int i = 2; i <= N + 1; i++) {
    int sub[302] = {};
    for(int j = K - 1; j >= 0; j--) { // 目標
      for(int k = 0; k < i; k++) {
        sub[k] += dp[k][j + 1];
        sub[k] %= M;
      }
      for(int k = 1; k <= i; k++) { // 個数
        dp[i][j] += 1LL * dp[i - k][j] * C[i - 2][k - 1] % M * sub[k] % M;
        dp[i][j] %= M;
      }
    }
  }
  cout << dp[N + 1][0] << endl;
}

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

using namespace std;

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

    std::vector<int64_t> Val2Idx(N+1);
    for (int64_t i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        Val2Idx[t] = i;
    }

    int64_t result = 0;
    std::set<int64_t> smallerIdxes;
    smallerIdxes.emplace(-1);
    smallerIdxes.emplace(N);
    for (int64_t a = 1; a <= N; ++a) {
        const auto idx = Val2Idx[a];
        auto itr = smallerIdxes.upper_bound(idx);
        auto r = *itr;
        auto l = *(--itr);

        result += a * (idx-l)*(r-idx);

        smallerIdxes.emplace(idx);
    }

    std::cout << result << std::endl;

#if 0
    int64_t result = 0;
    for (int64_t i = 0; i < N; ++i) {
        int64_t l = 0;
        for (int64_t j = i-1; j >= 0; --j) {
            if (A[j] < A[i]) {
                l = j + 1;
                break;
            }
        }

        int64_t r = N-1;
        for (int64_t j = i + 1; j < N; ++j) {
            if (A[j] < A[i]) {
                r = j - 1;
                break;
            }
        }
        result += A[i] * (i-l+1)*(r-i+1);
    }
    std::cout << result << std::endl;
#endif

#if 0
    int64_t result = 0;
    for (int64_t l = 0; l < N; ++l) {
        int64_t m = A[l];
        for (int64_t r = l; r < N; ++r) {
            result += std::min(m, A[r]);
            m = std::min(m, A[r]);
        }
    }

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


Measured memory_bytes: 11136
def main():
  N, M = list(map(int, input().split()))
  C = list(map(int, input().split()))
  C = sorted(C)
  AB = [list(map(int, input().split())) for i in range(M)]
  AB = sorted(AB, key=lambda x: x[1], reverse=True)
  
  result = 0
  i, j = 0, 0
  while i < N:
    A, B = AB[j] if j < M else (0, 0)
    j += 1
    if i+A < N and B >= C[i+A]:
      i += A
      result += A * B
    else:
      break
    
  while i < N:
    if C[i] > B:
      result += sum(C[i:])
      break
    else:
      result += B
      A -= 1      
      if j < M and A == 0:
        A, B = AB[j] if j < M else (0, 0)
        j += 1
    
    i += 1
  
  print(result)

if __name__ == "__main__":
  main()

Measured memory_bytes: 33640
S = input()
T = input()
alp = "abcdefghijklmnopqrstuvwxyz"
d = {s: None for s in alp}
e = {s: None for s in alp}
for s, t in zip(S, T):
    if d[t] is None:
        d[t] = s
    elif d[t] != s:
        print("No")
        exit()
    if e[s] is None:
        e[s] = t
    elif e[s] != t:
        print("No")
        exit()
print("Yes")

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

unordered_map<char, int> s2map(string s){
	unordered_map<char, int> m_tmp;
	for(int i=0; i<s.size(); i++){
		m_tmp[s[i]]++;
	}
	return m_tmp;
}

void min_map(unordered_map<char, int> m_tmp, unordered_map<char, int> &m_min){
	for(char c = 'a'; c <= 'z'; c++){
		if(m_tmp[c] < m_min[c]) m_min[c] = m_tmp[c];
	}
}

int main(){
	int n;
	cin >> n;
	string s;
	unordered_map<char, int> m_tmp;
	unordered_map<char, int> m_min;
	cin >> s;
	m_tmp = s2map(s);
	m_min = m_tmp;
	for(int i=1; i < n; i++){
		cin >> s;
		m_tmp = s2map(s);
		min_map(m_tmp, m_min);
	}
	for (char c = 'a'; c <= 'z'; c++) {
		for(int i=0; i < m_min[c]; i++) cout << c;
	}
	return 0;
}



Measured memory_bytes: 256
L=[]
for i in range(3):
    a,b,c=map(int,input().split())
    L+=[a,b,c]
N=int(input())
l= [int(input()) for i in range(N)]
a=[0]*9
for i in l:
    for j in range(9):
        if i==L[j]:
            a[j]=1
if a[0]*a[1]*a[2] or a[3]*a[4]*a[5] or a[6]*a[7]*a[8] or a[0]*a[3]*a[6] or a[1]*a[4]*a[7] or a[2]*a[5]*a[8] or a[0]*a[4]*a[8] or a[6]*a[4]*a[2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main(){
    let sum: u32 = (0..3).map(|_| read::<u32>()).sum();
    println!("{}", if sum >= 22 {"bust"} else {"win"});
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0);\
cin.tie(0);\
cout.tie(0);
#define ll long long   
#define endl '\n'  
using namespace std;
const int N = 100+ 5;
int  n, m, k,r = 0, b = 0;
int main()
{
	IO
		cin >> n >> m >> k; 
	char  arr[N][N]; 
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> arr[i][j];
		}
		
		
	}
	int  way1 = (1 << n);
	int  way2 =  (1 << m);
	int  ans = 0; 

	for(int  mask = 0 ;mask < way1 ;mask++)
	{
		for (int mask2 = 0; mask2 < way2; mask2++)
		{
			int  cur = 0;
			for (int i = 0; i < n; i++)
			{
				for (int j = 0; j < m; j++)
				{
					if ((mask & (1 << i)) && (mask2 & (1 << j)))
					{
						if(arr[i][j]!='.')
						cur++;
					}
				}
			}
			if (cur == k)
				ans++; 

		}
		
    }
	cout << ans << "\n"; 

}

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

int main() {
    int n; string s;
    cin>>n>>s;
    if(s.size()<=n) {
        cout<<s<<endl;
        return 0;
    }
    string s2=s.substr(0,n);
    s2+="...";
    cout<<s2<<endl;
	return 0;
}


Measured memory_bytes: 3132
import math
n = int(input())
m = math.ceil(math.sqrt(n))

min_f = float('inf')

for i in range(1, m+1):
  x = n/i
  if x.is_integer():
    x = int(x)
    i = int(i)
    f = max(len(str(i)), len(str(x)))
    if min_f > f:
      min_f = f
print(min_f)


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

int main(){
    int n;
    cin >> n;
    int count = 0;
    bool flag = false;
    rep(i,n){
        int d1,d2;
        cin >> d1 >> d2;
        if(d1 == d2 ){
            count++;
        }
        else{
            count = 0;
        }

        if(count == 3){
            flag = true;
        }
    }

    if(flag == true)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  int a,b;
  cin>>a>>b;
  cout<<((a*b)%2 ? "Odd" : "Even");
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
(* O(n log n) *)
let n = read_int () in
let rec count c m =
  if m mod 2 = 1 then c
  else count (c + 1) (m / 2) in
let ans, ma = ref 1, ref 0 in
for i = 1 to n do
  let c = count 0 i in
  if !ma < c then (ma := c; ans := i)
done;
Printf.printf "%d\n" !ans

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

int main() {
  long long n;
  cin >> n;
  long long a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  long long minMove = min({a,b,c,d,e});

  long long ans = ((n + minMove - 1) / minMove) + 4;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;


int main()
{
    string S, T;
    cin >> S >> T;


    if(S.size() < 1 || S.size() > 10 || S.size() + 1 != T.size())
    {
        cout << "No" << endl;
        return 0;
    }

    for(int i = 0; i < S.size(); ++i)
    {
        if(!islower(S[i]) || S[i] != T[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    if(islower(T[S.size()]))
    cout << "Yes" << endl;
    else
       cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for (int i=0;i<(n);i++)

int main()
{
    ll N;
    cin >> N;
    vector<ll> P(N);
    rep (i,N) {
        cin >> P[i];
    }

    ll ans = 0;
    rep (i,N) {
        if ((i+1 < N) && (P[i] == i+1) && (P[i+1] == i+2)) {
            ans += 1;
            i += 1;
        }
        else if (P[i] == i+1) {
            ans += 1;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(){
	int r,g,b;
	scanf("%d%d%d",&r,&g,&b);
		int ans;
		ans=r*100+g*10+b;
		if(ans%4==0)
			printf("YES\n");
		else
			printf("NO\n");
	return 0;
} 

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

typedef long long ll;


char str[104];

int main(){
    while(1){
        stack<int> st;
        bool judge = true;

        fgets(str, 104, stdin); 
        if(str[0]=='.')break;
    
        int i=0;
        while(str[i] != '.'){
            if(str[i]=='(' || str[i]=='['){
                st.push(str[i]);
            }else if(!st.empty()){
                if(str[i]==')'){
                    if(st.top() == '('){
                        st.pop();
                    }else{
                        judge = false;
                    }
                }else if(str[i]==']'){
                    if(st.top() == '['){
                        st.pop();
                    }else{
                        judge = false;
                    }
                }
            }else if(st.empty()){
                if(str[i]==')' || str[i]==']') judge = false;
            }
            if(judge==false){
                break;
            }
            i++;
        }
        if(!st.empty()){
            judge = false;
        }
        if(judge){
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }

}


Measured memory_bytes: 3068