akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
int in(){int a;scanf("%d",&a);return a;}
ll lin(){ll a;scanf("%lld",&a);return a;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

vi G[100010];
int ind[100010];

int main()
{
    int n = in();
    int m = in();

    rep(i, m) {
        int a = in() - 1, b = in() - 1;
        G[a].PB(b);
        ind[b]++;
    }

    bool f = false;

    vi ans;

    queue<int> q;
    rep(i, n) if (ind[i] == 0) {
        ans.PB(i);
        q.push(i);
    }

    if (q.size() > 1) f = true;

    while (q.size()) {
        int v = q.front(); q.pop();

        int cnt = 0;

        for (int u : G[v]) {
            ind[u]--;

            if (ind[u] == 0) {
                if (cnt > 0) f = true;
                q.push(u);
                ans.PB(u);
                cnt++;
            }
        }
    }

    for (int v : ans) printf("%d\n", v+1);
    printf("%d\n", f);
}

Measured memory_bytes: 6104
#include<stdio.h>
int main(){
   int m,f,r;
   int seiseki[50]={};
   int i=0;
   int count=0;
   

   while(1){
    scanf("%d %d %d",&m,&f,&r);
    
     if(m==-1 && f==-1 && r==-1) break;
     else if(m+f>=30 &&m+f<50 && r>=50) seiseki[i]=50;
     else  if(m==-1 || f==-1) seiseki[i]= 0;
     else seiseki[i]=m+f;
     i++;
     count +=1;
   }

   for(i=0;i<count;i++){
     if(seiseki[i]>=80) printf("A\n");
if(seiseki[i]<80 && seiseki[i]>=65) printf("B\n");
 if(seiseki[i]<65 && seiseki[i]>=50) printf("C\n");
 if(seiseki[i]<50 && seiseki[i]>=30) printf("D\n");
  if(seiseki[i]<30) printf("F\n");
   }

   return 0;
}



Measured memory_bytes: 2040
#include<stdio.h>
#include<stdlib.h>

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

int lcm( int a, int b ){
 // a*b が大きくなりすぎる場合に配慮
 return a * ( b / gcd(a, b) );
}


int main(void){
  int n;
  scanf("%d\n",&n);
  int a[n];
  int i;
  for(i=0;i<n;++i){
    scanf("%d",&a[i]);
  }
  int ans;
  for(i=0;i<n;++i){
    if( i == 0 ) ans = a[i];
    else ans = gcd(ans,a[i]);
  }
  printf("%d\n",ans);
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
  int A, B, M;
  std::cin >> A >> B >> M;
  std::vector<int> a(A), b(B), x(M), y(M), c(M);
  rep(i, A) std::cin >> a[i];
  rep(i, B) std::cin >> b[i];
  rep(i, M) {
    std::cin >> x[i] >> y[i] >> c[i];
  }

  int minv = 1000000;
  rep(i, M) {
    minv = min(minv, a[x[i]-1] + b[y[i]-1] - c[i]);
  }

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

  minv = min(minv, a[0] + b[0]);

  std::cout << minv << std::endl;

  return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int x = in.nextInt();
		int y = in.nextInt();
		int z = in.nextInt();
		int k = in.nextInt();
		long[] a = new long[x];
		for(int i=0;i<x;i++) {
			a[i] = in.nextLong();
		}
		long[] b = new long[y];
		for(int i=0;i<y;i++) {
			b[i] = in.nextLong();
		}
		long[] c = new long[z];
		for(int i=0;i<z;i++) {
			c[i] = in.nextLong();
		}
		long[] bc = new long[y*z];
		for(int i=0;i<y;i++) {
			for(int j=0;j<z;j++) {
				bc[i*z+j] = b[i] + c[j];
			}
		}
		Arrays.sort(bc);
		int min_k_yz = Math.min(k, y*z);
		long[] bc_higher = new long[min_k_yz];
		for(int i=0;i<min_k_yz;i++) {
			bc_higher[i] = bc[bc.length-1-i];
		}
		long[] abc = new long[x*min_k_yz];
		for(int i=0;i<x;i++) {
			for(int j=0;j<min_k_yz;j++) {
				abc[i*min_k_yz+j] = a[i] + bc_higher[j];
			}
		}
		Arrays.sort(abc);
		for(int i=0;i<k;i++) {
			System.out.println(abc[abc.length-1-i]);
		}
		in.close();
	}

}


Measured memory_bytes: 61828
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
 cin >>N;
  
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A.at(i);
  }
int count=0;
for (int i = 0; i < N; i++) {
  bool flag=true;
for (int j = 0; j < i; j++) {
 
if(A[i]<A[j]){
  flag =false;
}
}
  if(flag){count++;}
}
cout <<count<<endl;
}

Measured memory_bytes: 256
from collections import Counter
def resolve():
    N = int(input())
    A = list(map(int,input().split()))
    Q = int(input())
    tbl = [0] * 1000000
    for i in A:
        tbl[i] +=1
    sm = sum(A)
    for i in range(Q):
        B,C = map(int,input().split())
        tmp = tbl[B]
        sm -= B * tmp
        sm += C * tmp
        tbl[C] += tmp        
        tbl[B]=0
        print(sm)


resolve()

Measured memory_bytes: 84772
#include <stdio.h>

int main(void) {
  int i, j, h, w, k;
  while( 1 ) {
    scanf("%d%d", &h, &w);
    if(!h && !w) break;
    for(j = 0; j < h; ++j) {
      for(k = 0; k < w; ++k) printf("#");
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2616
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
const int mod = 1e9 + 7;

int main()
{
	int a, b;
	int ans;
	scanf("%d %d", &a, &b);
	ans = a + b;
	if(ans >= 10)
		printf("error\n");
		else
			printf("%d\n", a + b);
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    p = [I() for _ in range(N)]

    ans = sum(p) - max(p) // 2
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10012
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g,ko;
    ll x,y,w;
    char hoge,fuga;
    cin>>n;
    for(ll i=n;i>=0;i--){
        a=sqrt(i);
        if(a*a==i){
            cout<<i<<endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>                          
using namespace std;
int n,a[5][5],b[15],f[5][5];          
int main(){
    for(int i=1;i<=3;i++)
        for(int j=1;j<=3;j++)
            cin>>a[i][j];
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>b[i];
    	for(int j=1;j<=3;j++)
    	    for(int k=1;k<=3;k++)
    	        if(b[i]==a[j][k]) f[j][k]=1;
	}
	if(f[1][1]==1&&f[1][2]==1&&f[1][3]==1) cout<<"Yes";
	else if(f[2][1]==1&&f[2][2]==1&&f[2][3]==1) cout<<"Yes";
	else if(f[3][1]==1&&f[3][2]==1&&f[3][3]==1) cout<<"Yes";
	else if(f[1][1]==1&&f[2][2]==1&&f[3][3]==1) cout<<"Yes";
	else if(f[1][3]==1&&f[2][2]==1&&f[3][1]==1) cout<<"Yes";
	else if(f[1][1]==1&&f[2][1]==1&&f[3][1]==1) cout<<"Yes";
	else if(f[1][2]==1&&f[2][2]==1&&f[3][2]==1) cout<<"Yes";
	else if(f[1][3]==1&&f[2][3]==1&&f[3][3]==1) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)(n); i++)
#define Loop1(i, n) for(int i = 1; i <= (int)(n); i++)
#define Loopr(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)(n); i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
bool nearlyeq(double x, double y) { return abs(x - y) < 1e-9; }
bool inrange(int x, int t) { return x >= 0 && x < t; }
bool inrange(vi xs, int t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

/*******************************************************/

int main() {
	quickio();
	int n; cin >> n;
	ll l; cin >> l;
	vll a(n); Loop(i, n) cin >> a[i];
	int id = -1;
	Loop(i, n - 1) {
		if (a[i] + a[i + 1] >= l) {
			id = i;
			break;
		}
	}
	if (id == -1) {
		cout << "Impossible" << endl;
	}
	else {
		vi ans = { id };
		Loopr(i, id) {
			ans.push_back(i);
		}
		Loop(i, n - 1) {
			if (i <= id) continue;
			ans.push_back(i);
		}
		reverse(ans.begin(), ans.end());
		cout << "Possible" << endl;
		Loop(i, ans.size()) {
			cout << ans[i] + 1 << endl;
		}
	}
}

Measured memory_bytes: 2168
fun main() {
    val builder = StringBuilder()

    val (h1, m1, h2, m2, k) = readInputLine().split(" ").map { it.toInt() }

    val tim1 = h1 * 60 + m1
    val tim2 = h2 * 60 + m2

    builder.appendln(tim2 - tim1 - k)

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 36404
# get n  list_n
n = int(input())
list_n = [int(x) for x in input().split(' ')]

# get q list_q
q = int(input())
list_q = [int(x) for x in input().split(' ')]

#define recursion find_partial_sum
#input: integer list and M
#output boolean

def find_partial_sum(idx, M):
    if 0 > M or idx >= n:
        return False
    i = list_n[idx]
    if M == i:
        return True
    if find_partial_sum(idx+1, M-i) or find_partial_sum(idx+1, M):
        return True
    return False
#iterate q and check find_åparcial_sum(list_n, q_i) and print
for q_i in list_q:
    if sum(list_n) < q_i:
        print("no")
    elif find_partial_sum(0, q_i):
        print('yes')
    else:
        print('no')


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int[] a = new int[3];
		int sum = 0;

		for (int i = 0; i < 3; i++) {
			a[i] = sc.nextInt();
		}
		
		Arrays.sort(a);
		
		sum = (a[1] - a[0]) + (a[2] - a[1]);
		
		System.out.println(sum);
		
		sc.close();
	}
}


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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    int k = 0;
    for(int i = 0; i < n; i++){
        if(p[i] != i + 1) k++;
    }
    if(k <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

using namespace std;

int main(){
	string str;
	cin >> str;
	for(int i = 0; i < str.size(); i++){
		if(str[i] == 'A' && str[i+1] == 'C'){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}



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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(b <= c || d <= a)cout << 0 << endl;
  else if(a <= c && b <= d)cout << b-c << endl;
  else if(c <= a && b <= d)cout << b-a << endl;
  else if(c <= a && d <= b)cout << d-a << endl;
  else if(a <= c && d <= b)cout << d-c << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	m := make(map[byte]int)
	for i := 0; i < len(s); i++ {
		m[s[i]]++
		if m[s[i]] > 1 {
			fmt.Println("no")
			return
		}
	}
	fmt.Println("yes")
}


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

char A[200055];

ll Ans;

int main() {
	scanf(" %s", A);
	for(int i = 0, s = 0; A[i]; i++) {
		if('W' == A[i]) Ans += s;
		else s++;
	}
	cout << Ans << endl;
	return 0;
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	string ans = "NO";
	rep(i, b) {
		int now = a + i*a;
		if(now%b == c) ans = "YES";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
#map(int,input().split())
s = list(input())
alpha = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
for i in range(len(s)):
  index = alpha.index(s[i])
  index += n
  if index > 25:
    index -= 26
    s[i] = alpha[index]
  else:
    s[i] = alpha[index]
print("".join(s))

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

#define fr(i, a, b) for (long long i = a; i < b; ++i)
#define fr2(i, b, a) for (long long i = b; i >= a; --i)
#define pb push_back

#define set0(a) memset(a, 0, sizeof(a))
#define setneg(a) memset(a, -1, sizeof(a))
#define setinf(a) memset(a, 126, sizeof(a))
#define trace(a) cerr << #a << ": " << a << endl

#define PI acos(-1.0)

typedef vector<long long> vll;
typedef vector<pair<long long, long long>> vllp;
typedef pair<long long, long long> llp;
typedef long long int ll;
typedef unsigned long long ull;
ll N = 1000000007;

template <typename T>
void show(T *a, int size)
{
	int i;
	cout << endl
		 << "The array is ";
	fr(i, 0, size)
	{
		cout << a[i] << " ";
	}
	cout << endl;
}

template <typename T>
void show_vector(vector<T> v)
{
	cout << endl
		 << "The vector is ";
	int i;
	fr(i, 0, v.size())
	{
		cout << v[i] << " ";
	}
	cout << endl;
}

ll Npow(ll x, ll n, ll M = N)
{
	if (n == 0)
		return 1;
	else if (n % 2 == 0)
		return Npow((x * x) % M, n / 2, M);
	return (x * Npow((x * x) % M, (n - 1) / 2, M)) % M;
}
//GLOBAL
#define M 100005

ll add()
{
	return 0;
}
template <typename T, typename... Types>
T add(T var1, Types... var2)
{
	return ((((ll(var1)) % N + ll(add(var2...))) % N) + N) % N;
}

ll mul()
{
	return 1;
}
template <typename T, typename... Types>
T mul(T var1, Types... var2)
{
	return ((ll(var1)) % N * ll(mul(var2...))) % N;
}

vll adj[M];
ll dp[M], dp2[M];
ll n, m;
ll ans[M];
ll phi_;

ll phi(ll x)
{
	ll rv = x;
	for (ll i = 2; i * i <= x; i++)
	{
		if (x % i == 0)
		{
			while (x % i == 0)
			{
				x /= i;
			}
			rv -= (rv / i);
		}
	}
	if (x > 1)
	{
		rv -= rv / x;
	}
	return rv;
}

//FUNCTIONS
ll dfs(ll parent, ll child)
{
	ll rv = 1;
	fr(i, 0, adj[child].size())
	{
		if (adj[child][i] != parent)
		{
			rv = mul(dfs(child, adj[child][i]) + 1, rv);
		}
	}
	dp[child] = rv;
	return rv;
}
void dfs2(ll parent, ll child)
{
	ll product = 1;
	vll suffix;
	vll prefix;
	fr(i, 0, adj[child].size())
	{
		if (adj[child][i] != parent)
		{
			prefix.pb(product);
			product = mul(product, dp[adj[child][i]] + 1);
		}
		else
		{
			prefix.pb(product);
		}
	}

	product = 1;
	fr2(i, adj[child].size() - 1, 0)
	{
		if (adj[child][i] != parent)
		{
			suffix.pb(product);
			product = mul(product, dp[adj[child][i]] + 1);
		}
		else
		{
			suffix.pb(product);
		}
	}
	reverse(suffix.begin(), suffix.end());

	fr(i, 0, adj[child].size())
	{
		if (adj[child][i] != parent)
		{
			dp2[adj[child][i]] = mul(prefix[i], suffix[i]);
			dp2[adj[child][i]] = mul(dp2[adj[child][i]], (1 + dp2[child]));
			dfs2(child, adj[child][i]);
		}
	}
}

void dfs3(ll parent, ll child)
{
	fr(i, 0, adj[child].size())
	{
		if (adj[child][i] != parent)
		{
			dfs3(child, adj[child][i]);
		}
	}
	ans[child] = mul(dp[child], 1 + dp2[child]);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	ll x, y;
	fr(i, 0, n - 1)
	{
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	N = m;
	phi_ = phi(N);
	dfs(1, 1);
	dp2[1] = 0;
	dfs2(1, 1);
	dfs3(1, 1);
	// show(dp + 1, 12);
	// show(dp2 + 1, 12);

	fr(i, 1, n + 1)
	{
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 24064
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_121(void) {
	string a, b;
	cin >> a >> b;
	string ab = a + b;
	int ab_int=0;
	int ab_size = ab.size()-1;

	for (int i = 0; i < ab.size(); i++) {
		//cout << ab[ab_size-i] << endl;
		ab_int += (int(ab[ab_size-i]-'0') * int(pow(10.0,i)));
		//cout << ab_int << endl;
	}

	//cout << ab_int << endl;
	
	double sqr = sqrt(ab_int);

	//cout << sqr << endl;

	if (sqr - int(sqr) == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


}

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

Measured memory_bytes: 3976
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int a,b;
	int o=0,k=0;

	cin>>a>>b;

	o=a*b;
	k=1*a+1*(b-1);

	cout<<o-k<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    int i = 0;
    bool same = false;
    string s_1 = s;
    while(i < s.size() + 5){
        char g = s[0];
        s[0] = s[s.size() - 1];
        int j = 0;
        while(j <= s.size() - 2){
            s[j + 1] = s_1[j];
            j ++;
        }
        //s[s.size() - 1] = g;
        s_1 = s;
        //cout << s << endl;
        if(s == t) {
            same = true;
            break;
        }
        i ++;
    }
    if(same)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
using System;

namespace atcorder
{
    class Program
    {
        static void Main()
        {
            var nk = Console.ReadLine().Split(' ');
            var n = int.Parse(nk[0]);
            var k = int.Parse(nk[1]);
            int[] a = new int[n];

            for (var i = 0; i < k; i++)
            {
                var d = int.Parse(Console.ReadLine());
                var ad = Console.ReadLine().Split(' ');


                foreach(var j in ad) 
                {
                    var intj = int.Parse(j);
                    a[intj - 1] += 1;
                }
            }
            int ans = 0;
            for (var l = 0; l< a.Length; l++)
            {
                if (a[l] == 0)
                {
                    ans += 1;
                }
            }

            Console.WriteLine(ans);

        }
    }
}


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


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int res = 0;
	vector<int> b(n);
	b = a;
	sort(b.begin(), b.end());
	rep(i, n) {
		if (a[i] == b[n - 1]) cout << b[n - 2] << endl;
		else cout << b[n - 1] << endl;
	}
}

Measured memory_bytes: 3200
import re

a = ">'(=+)#(=+)~$"
b = ">\^(Q=)+~~$"
n = int(input())

for _ in range(n):
    s = input()
    r = re.match(a, s)
    if r and r.group(1) == r.group(2):
        print('A')
    elif re.match(b, s):
        print('B')
    else:
        print('NA')


Measured memory_bytes: 6572
#include<stdio.h>

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main() {
  int K;
  cin>>K;
  int sum=0;
  for(int i=1;i<=K;i++){
    for(int j=1;j<=K;j++){
      for(int k=1;k<=K;k++){
        int a=__gcd(i,j);
        sum+=__gcd(a,k);
      }
    }
  }
  cout<<sum<<endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

#define MOD 998244353
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);


vl arr[1005];
bool vis[1005];
ll dis[1005];

int timer=0;

ll in[1005],out[1005];
//ll sz[1001];

void dfs(ll node)
{
  vis[node]=1;
  in[node]=timer++;
 // if(arr[node.size()==1])temp.pb()
for(int i=0;i<arr[node].size();i++)
{
  ll x=arr[node][i];
  if(!vis[x])
  {
   // dis[x]=dis[node]+1;
    dfs(x);
  }
}
out[node]=timer++;
}



ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}

ll pow(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }

return ans;
}


/*const int N=200000;

ll fac[N+1];
ll inv[N+1];
ll p=998244353;

ll c(ll a, ll b,ll m)
{
  if(a<b)return 0;
  return (fac[a]*inv[b]%m)*(inv[a-b])%m;
}

void fill()
{
inv[0]=1;
fac[0]=1;

for(int i=1;i<=N;i++)
{
  fac[i]=fac[i-1]*i%p;
  inv[i]=powM(fac[i],p-2,p);
}

}
*/
//ld dp[2001][2001];

ll dp[3001][3001];  // dp[i][j] ways to make sum i using j numbers.


int main()
{  fast

ll n,s;
cin>>n>>s;



vl a(n+1);



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

sort(all(a));

dp[0][0]=powM(2,n,MOD);

for(int i=1;i<=n;i++)
{
  for(int j=0;j<=3000;j++)
  {
     dp[i][j]+=dp[i-1][j];
    if(j>=a[i]) dp[i][j]+=dp[i-1][j-a[i]]*powM(2,MOD-2,MOD)%(MOD);
    dp[i][j]%=(MOD);
  }
}


cout<<dp[n][s]<<"\n";

 return 0;

}


Measured memory_bytes: 74016
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n; string s;
    cin >> n >> s;
    int ok = 0, ng = n;
    while(ng - ok > 1){
        int mid = (ok+ng)/2;
        map<string, int> v;
        int good = 0;
        for (int i = 0; i+mid-1 < n; ++i) {
            string t = s.substr(i, mid);
            if(v.count(t)){
                if(v[t]+mid-1 < i) good = 1;
            }else {
                v[t] = i;
            }
        }
        if(good) ok = mid;
        else ng = mid;
    }
    cout << ok << "\n";
    return 0;
}

Measured memory_bytes: 6660
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

int main() {
    vector<ll> cnt_matches_vec = {2, 5, 5, 4, 5, 6, 3, 7, 6};
    unordered_map<ll, ll> cnt_matches;
    rep(i, 0, 9) {
        cnt_matches[i+1] = cnt_matches_vec[i];
    }
    ll N, M;
    cin >> N >> M;
    vector<ll> Ais(M);
    rep(i, 0, M) {
        cin >> Ais[i];
    }
    {
        unordered_map<ll, ll> map;
        rep(i, 0, Ais.size()) {
            if (map.find(cnt_matches[Ais[i]]) == map.end()) {
                map[cnt_matches[Ais[i]]] = Ais[i];
            } else {
                map[cnt_matches[Ais[i]]] = max(map[cnt_matches[Ais[i]]], Ais[i]);
            }
        }
        Ais.clear();
        for (const auto& kv : map) {
            Ais.push_back(kv.second);
        }
    }
    sort(Ais.begin(), Ais.end());
    auto dp = make_vec_nd(numeric_limits<ll>::min(), Ais.size()+1, N+1);
    dp[0][0] = 0;
    rep(number_cnt, 1, Ais.size()+1) {
        ll cost = cnt_matches[Ais[number_cnt-1]];
        rep(n, 0, N+1) {
            dp[number_cnt][n] = dp[number_cnt-1][n];
            if (n >= cost) {
                dp[number_cnt][n] = max(dp[number_cnt][n],
                                        dp[number_cnt][n-cost] + 1);
            }
        }
    }
    vector<ll> digits;
    ll N_loc = N;
    rrep(number_cnt,Ais.size()+1,1) {
        ll cost = cnt_matches[Ais[number_cnt-1]];;
        while(N_loc-cost >= 0 &&
              dp[number_cnt][N_loc] == dp[number_cnt][N_loc-cost]+1) {
            digits.push_back(Ais[number_cnt-1]);
            N_loc -= cost;
        }
    }
    sort(digits.rbegin(), digits.rend());
    rep(i,0,digits.size()) {
        cout << digits[i];
    }
    cout << endl;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define M 110
#define N 100
#define rep(i, x, y) for(int i = (x); i <= (y); ++ i)
int d[M][M], f[M][M];
int main() {
	cin.tie(0);
	int n, m; cin >> n >> m;
	rep(i, 1, n) rep(j, 1, m) {
		cin >> d[i][j];
	}
	rep(i, 0, N) rep(j, 0, N) {
		f[i][j] = 0;
		rep(k, 1, n) rep(w, 1, m) {
			f[i][j] = max(f[i][j], d[k][w] - i * k - j * w);
		}
	}
	rep(i, 1, n) rep(j, 1, m) {
		int t = 1000;
		rep(k, 0, N) rep(w, 0, N) {
			t = min(t, f[k][w] + i * k + j * w);
		}
		if(t != d[i][j]) {
			puts("Impossible");
			return 0;
		}
	}
	puts("Possible");
	printf("%d %d\n", N + N + 2, N + N + (N + 1) * (N + 1));
	rep(i, 1, N) {
		printf("%d %d X\n", i, i + 1);
		printf("%d %d Y\n", i + 101, i + 102);
	}
	rep(i, 0, N) rep(j, 0, N) {
		printf("%d %d %d\n", i + 1, N + N + 2 - j, f[i][j]);
	}
	printf("1 %d\n", N + N + 2);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

template<class T>
struct Vec2
{
	Vec2(){}
	Vec2(T _x, T _y) : x(_x), y(_y) {}

	Vec2 operator+(const Vec2& rhs) const { return Vec2(x + rhs.x, y + rhs.y); }
	Vec2 operator-(const Vec2& rhs) const { return Vec2(x - rhs.x, y - rhs.y); }
	Vec2 operator*(T s) const { return Vec2(x*s, y*s); }
	Vec2 operator/(T s) const { return Vec2(x/s, y/s); }
	T dot(const Vec2& rhs) const { return x*rhs.x + y*rhs.y; }
	T cross(const Vec2& rhs) const { return x*rhs.y - y*rhs.x; }
	T sqlength() const { return x*x + y*y; }
	double length() const { return sqrt(sqlength()); }
	bool operator<(const Vec2& rhs) const
	{
		if (x != rhs.x) return x < rhs.x;
		return y < rhs.y;
	}

	T x;
	T y;
};

template<class T>
T cross(const Vec2<T> &O, const Vec2<T> &A, const Vec2<T> &B)
{
	return (A - O).cross(B - O);
}

template<class T>
bool IsIntSegments(const Vec2<T>& A1, const Vec2<T>& A2, const Vec2<T>& B1, const Vec2<T>& B2)
{
	return (cross(A1, A2, B1)*cross(A1, A2, B2) < 0 && cross(B1, B2, A1)*cross(B1, B2, A2) < 0);
}

template<class T>
bool IsPointOnSegment(const Vec2<T>& P, const Vec2<T>& S, const Vec2<T>& E)
{
	Vec2<T> dir = E - S;
	if ((P - S).cross(dir) != 0) {
		return false;
	}
	T prd = (P - S).dot(dir);
	if (prd < 0) {
		return false;
	}
	return prd <= dir.dot(dir);
}

int main()
{
	typedef Vec2<long long> Vec;

	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		Vec P[4];
		for (int j = 0; j < 4; j++) {
			cin >> P[j].x >> P[j].y;
		}

		Vec d1 = P[0] - P[1];
		Vec d2 = P[2] - P[3];
		if (d1.cross(d2) == 0) {
			puts("2");
		}
		else if (d1.dot(d2) == 0) {
			puts("1");
		}
		else {
			puts("0");
		}
	}
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, const char *argv[]) {
  int N, tmp;
  vector<int> dis(100);
  cin >> N;
  vector<int> X(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }

  for (int i = 0; i < 100; i++) {
    dis[i] = 0;
    for (int j = 0; j < N; j++) {
      tmp = X[j] - i + 1;
      dis[i] += tmp * tmp;
    }
  }
  vector<int>::iterator iter = min_element(dis.begin(), dis.end());
  size_t index = distance(dis.begin(), iter);

  cout << dis[index] << endl;
  return 0;
}


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

int main(){
    int N,K;
    cin >> N >> K;
    long long res = 0;
    while(N){
        N /= K;
        res++;
    }
    cout << res << endl;

    return 0;
}

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

int dx[4] = {-1,0,1,0};
int dy[4] = {0,1,0,-1};

int main(){
	int N,n,d;
	int map[500][500];

	while(1){
		//ÏÌú»
		for(int y=0 ; y<500 ; y++){
			for(int x=0 ; x<500 ; x++){
				map[y][x] = -1;
			}
		}
		map[250][250] = 0;//0Ì^Cð(x,y)=(250,250)ÌÀWÉu­

		//f[^ZbgNÌüÍ
		cin >> N;
		if(N==0) break;//0ðüÍÅI¹
		
		for(int i=0 ; i<N-1 ; i++){
			//N-1ñ¾¯n dÌüÍ
			cin >> n >> d;

			for(int y=0 ; y<500 ; y++){
				for(int x=0 ; x<500 ; x++){
					if(map[y][x]==n){//^CÔn¾Á½ç

						//^CnÔ©ç1}XÆÈèÉ(i+1)ÔÌ^Cðu­
						//(i+1)ÈÌÍiª0©çnÜÁÄ¢é©ç
						//d: 0:¶  1:º  2:E  3:ã
						int mx = x + dx[d];
						int my = y + dy[d];
						map[my][mx] = i+1;
					}
				}
			}
		}

		//(^CÌ éXÀWÌÅål)-(^CÌ éXÀWÌÅ¬l)+1 ªßéÅ·
		//(^CÌ éYÀWÌÅål)-(^CÌ éYÀWÌÅ¬l)+1 ªßé³Å·
		int minX = 500 , minY = 500;
		int maxX =   0 , maxY =   0;
		//^CÌ éX,YÀWÌÅålÆÅ¬lðßé
		for(int y=0 ; y<500 ; y++){
			for(int x=0 ; x<500 ; x++){
				if(map[y][x]>=0){
					if(x<minX) minX = x;
					if(x>maxX) maxX = x;
					if(y<minY) minY = y;
					if(y>maxY) maxY = y;
				}
			}
		}
		//ðÌoÍ
		cout << (maxX-minX)+1 << " " << (maxY-minY)+1 << endl;
	}
}

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

const int m = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    int x, y;
    int maxsum = -m, minsum = m, maxdiff = -m, mindiff = m;
    for(int i = 0; i < n; i++) {
        cin >> x >> y;
        maxsum = max(maxsum, x + y);
        maxdiff = max(maxdiff, x - y);
        minsum = min(minsum, x + y);
        mindiff = min(mindiff, x - y);
    }
    if(maxsum - minsum > maxdiff - mindiff)
        cout << maxsum - minsum;
    else
        cout << maxdiff - mindiff;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX + 1];

void maxHeapify(int i){
	int l = 2*i;
	int r = 2*i + 1;
	int largest, tmp;
	
	if(l <= H && A[l] > A[i]) largest = l;
	else largest = i;
	
	if(r <= H && A[r] > A[largest]) largest = r;
	
	if(largest != i)
	{
		tmp = A[i];
		A[i] = A[largest];
		A[largest] = tmp;
		maxHeapify(largest);
	}
}

int extract()
{
	int maxv;
	if(H < 1) return -INFTY;
	maxv = A[1];
	A[1] = A[H--];
	maxHeapify(1);
	return maxv;
}

void increaseKey(int i, int key)
{
	int tmp;
	
	if(key < A[i])	return;
	A[i] = key;
	while(i > 1 && A[i / 2] < A[i]){
	tmp = A[i];
	A[i] = A[i / 2];
	A[i / 2] = tmp;
	i = i / 2;
	}
}

void insert(int key)
{
	H++;
	A[H] = -INFTY;
	increaseKey(H, key);
}

int main(void){
	int key;
	char com[20];
	
	while(1){
		scanf("%s", com);
		if(com[0] == 'e' && com[1] == 'n') break;
		if(com[0] == 'i')
		{
		  scanf("%d", &key);
		  insert(key);
		}
		else
		{
			printf("%d\n", extract());
		}
	}
	return 0;
}



Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, k;
	cin >> n >> k;
	vector<int> a(n), b(n);
	rep(i, n) cin >> a[i] >> b[i];
	priority_queue<P, vector<P>, greater<P>> pq;
	rep(i, n) {
		pq.emplace(a[i], b[i]);
	}
	ll cnt = 0;
	while (1) {
		int num = pq.top().first;
		int tmp = pq.top().second;
		pq.pop();
		if (cnt + tmp >= k) {
			cout << num << endl;
			return 0;
		}
		cnt += tmp;
	}
	return 0;
}


Measured memory_bytes: 2168
from itertools import *
from collections import *

N = int(input())
An = list(map(int, input().split()))

An_pos, An_neg = deque(), deque()
for a in An:
    if a >= 0:
        An_pos.append(a)
    else:
        An_neg.append(-a)
        pass
    pass

ans = sum(chain(An_pos, An_neg))

if len(An_neg) % 2 == 1:
    ans -= 2 * min(chain(An_pos, An_neg))
    pass

print(ans)


Measured memory_bytes: 14660
#include <cstdio>
#include <queue>
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 1e5 + 1;
typedef unsigned long long ull;
const ll INF = 1ll<<60;
int m,n,t;
int main()
{
    string a, b, c;
    cin >> a >> b;
    int aa, bb;
    cin >> aa >> bb;
    map<string,int>mp;
    mp[a] = aa;
    mp[b] = bb;
    cin >> c;
    if (mp[c])
    {
        mp[c]--;
    }
    cout << mp[a] << " " << mp[b] << endl;
    return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

array<int, 26> ans;

array<int, 26> f(string s) {
	array<int, 26> rt;
	rt.fill(0);
	for (char c : s) rt[c - 'a']++;
	return rt;
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	ans.fill(0x3f3f3f3f);
	int n; read(n);
	rep(i, 0, n) {
		string s; read(s);
		array<int, 26> r = f(s);
		rep(j, 0, 26) chmin(ans[j], r[j]);
	}
	//rep(i, 0, 26) printf("%c: %d\n", 'a'+i, ans[i]);
	rep(i, 0, 26) rep(j, 0, ans[i]) cout << char('a' + i);
	cout << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

ll dfs(string S) {
  int N = S.size();
  if (S[1] != '[') {
    ll k = stoll(S.substr(1,N-2));
    return k / 2 + 1;
  }
  int count = 0;
  vector<ll> A;
  string t = "";
  for (int i = 1; i < N-1; i++) {
    if (S[i] == '[') count++;
    if (S[i] == ']') count--;
    t.push_back(S[i]);
    if (count == 0) {
      A.emplace_back(dfs(t));
      t = "";
    }
  }
  sort(all(A));
  ll y = 0;
  rep(i,A.size() / 2 + 1) y += A[i];
  return y;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
  while (true) {
    int N; cin >> N;
    if (N == 0) break;
    vector<vector<int>> t(N, vector<int>(N+1));
    rep(i,N) {
      rep(j,N+1) cin >> t[i][j];
    }
    vector<vector<int>> A(N, vector<int>(1 << N));
    for (int tmp = 0; tmp < (1 << N); tmp++) { //00…0～11…1までの状態sでのi番目の最短クリアタイム
      bitset<16> s(tmp);

      rep(i,N) {
        A[i][tmp] = t[i][0];
        rep(j,N) {
          if (s.test(j)) chmin(A[i][tmp],t[i][j+1]); 
        }
      }
    }

    vector<int> dp(1 << N,INF);
    dp[0] = 0;
    queue<int> que;
    que.emplace(0);
    while(!que.empty()) {
      int tmp = que.front();
      bitset<16> s(tmp); que.pop();
      rep(i,N) {
        if (!s.test(i)) {
          if (dp[tmp | (1 << i)] == INF) que.emplace(tmp | (1 << i));
          chmin(dp[tmp | (1 << i)], dp[tmp] + A[i][tmp]);
        }
      }
    }

    cout << dp[(1 << N) - 1] << endl;
  }
}


Measured memory_bytes: 7412
import java.lang.*;
import java.util.*;

public class Main{
  public static void main(String[] args){
    HashMap<String,Integer> map = new HashMap<>();
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    
    while(scan.hasNextLine()){
      String val = scan.nextLine();
      if(map.get(val) == null) map.put(val, 1);
      else map.put(val, map.get(val)+1);
    }
    
    System.out.println("AC x " + ((map.get("AC") == null)? 0 : map.get("AC")));
    System.out.println("WA x " + ((map.get("WA") == null)? 0 : map.get("WA")));
    System.out.println("TLE x " + ((map.get("TLE") == null)? 0 : map.get("TLE")));
    System.out.println("RE x " + ((map.get("RE") == null)? 0 : map.get("RE")));
  }
}

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

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = "";
			var v = new List<double[]>();
			while ((s = Console.ReadLine()) != null)
			{
				var xy = s.Split(',');
				v.Add(xy.Select(d => double.Parse(d)).ToArray());
			}

			var n = v.Count;
			var S = 0.0;
			for (int i = 0; i < n; i++)
			{
				S += (v[i][0] * v[(i + 1) % n][1]) - (v[(i + 1) % n][0] * v[i][1]);
			}

			Console.WriteLine("{0}", Math.Abs(S / 2));
		}
	}
}

Measured memory_bytes: 6148
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	string s;
	cin>>s;
	
	cout<<((s=="ABC")?"ARC":"ABC")<<endl;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
        int sum=0;
        for(int i = 0; i < 4; i++){
                int tmp;
                cin >> tmp;
                sum += tmp;
        }
        printf("%d\n%d\n",sum/60,sum-60*(sum/60));
        return 0;
}

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

using namespace std;

int a[100050];
int dp[100050];


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

    for(int i = 0 ; i < n; i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+n);

    for(int i = 1 ; i <= k ; i++){
        for(int j = 0 ; j < n  ; j++){
            int num = a[j];
            if(num > i)    break;

            if(!dp[i - num]){
                dp[i] = 1;
                break;
            }
        }
    }

    if(dp[k]){
        cout << "First";
    }
    else cout << "Second";

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	string s; cin>>s;
  int n=s.size();
  string a,b;
  rep(i,1,n+1){
    if(i%2==0){
      a.push_back('0');
      b.push_back('1');
    }
    else{
      a.push_back('1');
      b.push_back('0');
    }
  }
  int ans=0;
  int ans2=0;
  rep(i,0,n){
    if(s[i]!=a[i])ans++;
    if(s[i]!=b[i])ans2++;
  }
  cout<<min(ans,ans2)<<endl;

  
	
	
	return 0;
}

Measured memory_bytes: 3972
import Data.Char

lowerCase [] = []
lowerCase (ch:ss) = toLower ch : lowerCase ss

main = do
  w <- return . lowerCase =<< getLine
  t <- return . filter (/= "END_OF_TEXT") . concat . map words . lines =<< getContents
  print $ length $ filter (== w) $ map lowerCase t

Measured memory_bytes: 3744
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

int a,b,c,d;

int main(){
	cin>>a>>b>>c>>d;
	cout<<(a+b+c+d)/60<<endl<<(a+b+c+d)%60<<endl;
}

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

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vvint(v, w, n) vector<int> v(n); vector<int> w(n); REP(i,n) cin >> v[i] >> w[i];
#define vlint(v, n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v, n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v, n1, n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v, n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()
#define len(v) (v).length()

static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long int MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);

static const int dy4[]={0, 0, 1, -1};
static const int dx4[]={1, -1, 0, 0};
static const int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
static const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};

int Knapsack_01(int N,int W,vector<int> v,vector<int> w) {

  int dp[N+1][W+1];
//std::vector<std::vector<int> > dp(N + 1, std::vector<int>(W + 1, 0));
  for (int i = 0; i <= N; i++) dp[i][0] = 0;
  for (int j = 0; j <= W; j++) dp[0][j] = 0;

  REP(i, N) REPS(j, 1, W+1){
      if (j < w[i]) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
  }
  return dp[N][W];
}

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

  int N, W;
  cin >> N >> W;
  vvint(v, w, N);

  cout << Knapsack_01(N, W, v, w) << endl;

}

Measured memory_bytes: 7096
from itertools import product


def main():
    N, K = list(map(int, input().split()))
    a = list(map(int, input().split()))
    find = 0
    for i in range(1, N):
        if a[i-1] < a[i]:
            find += 1
    if find >= K:
        print(0)
        return

    first = a.pop(0)

    ans = float('inf')

    for bits in product((0, 1), repeat=N-1):
        build = a.copy()
        changeBuild = bits
        find = 1
        score = 0
        if sum(changeBuild) == 0:
            continue
        for i, v in enumerate(changeBuild):
            if i == 0:
                nowmax = first
            else:
                maxbuild = max(build[:i])
                nowmax = max(first, maxbuild)

            if v == 1 and nowmax >= build[i]:
                score += nowmax-build[i]+1
                build[i] = nowmax+1
            if i == 0 and first < build[i]:
                find += 1
            if i >= 1 and nowmax < build[i]:
                find += 1
        if find >= K:
            ans = min(ans, score)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188