akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;
	string s;
	cin>>s;
	bool flag = false;
	if(s[0] == 'A'){
		rep(i, s.length()){
			if(i == 0 )continue;
			if(s[i] == 'C'&&2<=i&&i<=s.length()-2){
				if(flag){
					cout << "WA" << endl;
					return 0;
				}
				flag = true;
			}else if('A' <= s[i] && s[i] <= 'Z'){
					cout << "WA" << endl;
					return 0;
			}
		}
	}
	if(flag){cout << "AC"<<endl;}else{cout << "WA"<<endl;}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	if (abs(x - a) < abs(x - b)) {
		cout << "A" << endl;
	}
	else {
		cout << "B" << endl;
	}

	

	
}


Measured memory_bytes: 3596
import java.util.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun main() {
	abc000X()
}

fun triangle(n:Int) = n*(n+1)/2

fun abc000X() {
	val days = int()
	val types = 0..25

	val penalty = list().toIntArray()
	val advantage = Array(days) {list().toIntArray()}

	val last = Array(26) {TreeSet<Int>()}
	last.forEach {it.add(-1)}

	var r = 0L
	val t = IntArray(days) {0}

	fun calcPenalty(d:Int,type:Int) = penalty[type]*triangle(d-last[type].floor(d))

	for(d in 0 until days) {
		val ct = types.maxBy {
			advantage[d][it]+calcPenalty(d,it)
		}!!
		t[d] = ct
		last[ct].add(d)
		r += advantage[d][ct]-calcPenalty(d,ct)
	}

	for(t in types)
		r += -calcPenalty(365,t)

	System.err.println(r)
	t.forEach {println(it+1)}
}


Measured memory_bytes: 40656
#include<iostream>
using namespace std;
int main()
{
  int tate,yoko,goukeiyoko,goukeitate,zentai=0;
  int hairetu[100][100];
  int i,j;

  cin >> tate >> yoko;

  for(i = 0;i < tate;i++){
    for(j = 0;j < yoko;j++){

      cin >> hairetu[i][j];

    }
  }

  for(i = 0;i < tate;i++){
    goukeiyoko = 0;
    for(j = 0;j < yoko;j++){

      goukeiyoko += hairetu[i][j];
      zentai += hairetu[i][j];

      cout << hairetu[i][j] << " ";

    }
    cout << goukeiyoko << "\n";
  }

  for(i = 0;i < yoko;i++){
    goukeitate = 0;
    for(j = 0;j < tate;j++){

      goukeitate += hairetu[j][i];

    }
    cout << goukeitate << " ";
  }

  cout << zentai << "\n";
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

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

  int n;
  cin >> n;
  vint a(n);
  rep(i, n) cin >> a[i];
  vector<Pi> vec;
  rep(i, n) vec.emplace_back(a[i], i);
  vec.emplace_back(0, -1);
  sort(all(vec));
  reverse(all(vec));
  vint ans(n);
  int idx = inf;
  rep(i, n) {
    //cout<<vec[i].first<<" "<<vec[i].second<<" "<<vec[i+1].first<<" "<<vec[i+1].second<<endl;
    if(vec[i].first != vec[i+1].first) {
      chmin(idx, vec[i].second);
      ans[idx] += (i+1)*(vec[i].first-vec[i+1].first);
    }
  }
  rep(i, n) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 4208
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
static class Program{
	const int mod=1000000007;
	const long o=1;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		int[] a=sc.Ia;
		long[] dp=new long[s[0]+1];
		string[] dp2=new string[s[0]+1];
		bool[] b=new bool[10];
		int[] h=new int[]{0,2,5,5,4,5,6,3,7,6};
		for(int i=0;i<s[1];i++){b[a[i]]=true;}
		dp[0]=1;
		for(int i=2;i<=s[0];i++){
			for(int j=1;j<10;j++){
				if(b[j]&&h[j]<=i&&dp[i-h[j]]>0){
					if(dp[i]<dp[i-h[j]]+1){
						dp[i]=dp[i-h[j]]+1;
						dp2[i]=dp2[i-h[j]]+j.ToString();
					}
					else if(dp[i]==dp[i-h[j]]+1&&string.Compare(dp2[i-h[j]]+j.ToString(),dp2[i])==1){
						dp2[i]=dp2[i-h[j]]+j.ToString();
					}
				}
			}
		}
		Console.WriteLine(dp2[s[0]]);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

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

using namespace std;

#define int64 long long 
const int mod = (int) 1e9 + 7;

const int nax = 2e5 + 5;
vector<int> par(nax), siz(nax);

int find(int u){
	if(par[u] == u)return u;
	return par[u] = find(par[u]);	
}

void union_set(int a, int b){
	a = find(a), b = find(b);
	if(a == b)return ;
	if(siz[a] > siz[b])swap(a, b);
	par[a] = b;
	siz[b] += siz[a];
}

int main(){
	int n, m;
	cin>>n>>m;
	for(int i=0; i<n; i++){
		par[i] = i, siz[i] = 1;
	}
	for(int i=0; i<m; i++){
		int u, v;
		cin>>u>>v;
		--u, --v;
		union_set(u, v);
	}
	int ans = 0;
	for(int i=0; i<n; i++){
		if(i == par[i]){
			ans = max(ans, siz[i]);	
		}
	}
	cout<<ans;
	
}


Measured memory_bytes: 4696
#include <iostream>
using namespace std;
int main(void){
    int ans;
    int x;
    ans = 0;
    
    for (int i=0;i < 5;i++) {
        
        cin >> x;
        
        if (x == 0 && i == 0) 
            ans += 1;
        
        
        if (x == 0 && i == 1) 
            ans += 2;
        
    
        if (x == 0 && i == 2) 
            ans += 3;
        
    
        if (x == 0 && i == 3) 
            ans += 4;
        

        if (x == 0 && i == 4) 
            ans += 5;
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 3468
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1},N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
struct str{
	int num[100]={},len=1;
};
string s;
bool t[200005],okb,okw;
int len,sum[200005],cntb,cntw;
vector<int> b,w;
str ans;
void pr(str x)
{
	for(int i=x.len;i>=1;i--)
		cout<<x.num[i];
}
str mul(str a,str b)
{
	int now[100]={},l=a.len+b.len;
	if(a.num[a.len]*b.num[b.len]<10)
		l--;
	for(int i=1;i<=a.len;i++)
		for(int j=1;j<=b.len;j++)
		{
			int pro=a.num[i]*b.num[j];
			now[i+j-1]+=pro%10,now[i+j]+=pro/10;
		}
	str res;
	for(int i=1;i<100;i++)
		res.num[i]=now[i];
	res.len=l;
	return res;
}
str plu(str a,str b)
{
	str res;
	int l=max(a.len,b.len),t=0;
	for(int i=1;i<=l;i++)
	{
		int now=a.num[i]+b.num[i]+t;
		t=now/10;
		res.num[i]=now%10;
	}
	if(t>0)
		res.num[l+1]=t,l++;
	res.len=l;
	return res;
}
str calc(str x,int a,int b)
{
	str res=x;
	str aa,bb;
	int pos1,pos2,aaa=a,bbb=b;
	pos1=pos2=0;
	while(aaa>0)
	{
		int r=aaa%10;
		aa.num[++pos1]=r;
		aaa/=10;
	}
	aa.len=pos1;
	while(bbb>0)
	{
		int r=bbb%10;
		bb.num[++pos2]=r;
		bbb/=10;
	}
	bb.len=pos2;
	res=plu(res,mul(aa,bb));
	return res;
}
int main(){
	cin>>s;
	len=s.size();
	if(len==1)
	{
		cout<<0;
		return 0;
	}
	int ii;
	for(ii=0;ii<s.size();ii++)
		if(s[ii]=='B')
			break;
	for(;ii<s.size();ii++)
		if(s[ii]!='B')
			break;
	if(ii==s.size())
	{
		cout<<0;
		return 0;
	}
	for(int i=s.size()-1;i>=0;i--)
		if(s[i]=='W')
		{
			s=s.substr(0,i+1);
			break; 
		}
	for(int i=0;i<s.size();i++)
		if(s[i]=='B')
		{
			s=s.substr(i,s.size()-i);
			break;
		}
	for(int i=0;i<s.size();)
	{
		cntb=0;
		while(s[i]=='B')
			cntb++,i++;
		if(cntb!=0)
			b.push_back(cntb);
		cntw=0;
		while(s[i]=='W')
			cntw++,i++;
		if(cntw!=0)
			w.push_back(cntw);
	}
	sum[0]=b[0];
	for(int i=1;i<b.size();i++)
		sum[i]=sum[i-1]+b[i];
	for(int i=0;i<b.size();i++)
		ans=calc(ans,sum[i],w[i]);
	pr(ans);
	return 0;
}

Measured memory_bytes: 1148
// ------------------------------------
// Date:2018/ 3/23
// Problem:Trained? _ _ b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

static const int MOD = 1e9 + 7;
static const int MAX_N = 1e5 + 1;

bool btn[MAX_N];
int N;

int main()
{
  scanf("%d", &N);
  vector< int > a(N);
  REP(i, N) {
    scanf("%d", &a[i]);
  }

  int ans = 0;
  memset(btn, false, sizeof(btn));
  btn[0] = true;
  int last = 0;
  REP(i, N) {
    if (btn[last]) {
      // debug(last);
      btn[last] = false;
      last = a[last] - 1;
      btn[last] = true;
      ans++;
      if (last == 1) break;
    } else {
      ans = -1;
      break;
    }
    if (i == N - 1) ans = -1;
  }
  cout << ans << endl;
 
  return 0;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
#define MAXX 100005
 
#define PI   3.14159265358979323846264338327950

#define PB push_back 
#define F first
#define S second
 
#define ll 	 long long int

#define mod  1000000007




int main()
{
	FAST;
	ll a, b;
	cin >> a >> b;
	ll c = b;
	ll x = 0;
	while(c ){
		c/= 10;
		x ++;
	}
	x = pow(10, x);
	a *= x;
	a += b;
	if(floor(sqrt(a)) == ceil(sqrt(a))){
		cout << "Yes";
		return 0;
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 3936
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 2e5 + 10;
const ll inf = 1e18 + 42;

ll a[N];

int main() {
	fast_cin();
	int n; cin >> n;
	ll sum = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	ll ans = inf, cur = 0;
	for (int i = 1; i < n; ++i) {
		cur += a[i];
		ans = min(ans, abs(cur - (sum - cur)));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
// Shift-JIS（シフトジス）

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

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


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

using namespace std;

//int→string
//string→int
//------------------------------------------
inline int toInt(string s) {
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}

template<class T>
inline string toString(T x) {
    ostringstream sout;
    sout << x;
    return sout.str();
}

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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;



int main() {

    int N;
    cin >> N;
    
    VI a(N);
    REP(i, N){
        cin >> a[i];
    }

    int min = 1<<20;
    
    for(int i=-100;i<=100;i++){
        int cost = 0;
        for(int j=0;j<N;j++){
            cost += (a[j]-i)*(a[j]-i);
        }
        
        if(min>cost){
            min = cost;
        }
        
    }
    
    cout << min << endl;

    return 0;
}











































Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i;
  long long a,b;
  scanf("%d%lld%lld",&n,&a,&b);
  long long x[n+1];
  for(i=0;i<n;i++)
    scanf("%lld",&x[i]);
  long long count=0;
  for(i=1;i<n;i++){
    if((x[i]-x[i-1])*a>b)
      count+=b;
    else
      count+=a*(x[i]-x[i-1]);
  }
  printf("%lld\n",count);
  return 0;
}

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




int main(){
	int n, m; cin >> n >> m;
	vector<vector<int>> uv(n);
	
	for (int i = 0; i < m; i++) {
		int u, v; cin >> u >> v;
		uv[u - 1].push_back(v - 1);
	}

	int s, t; cin >> s >> t;

	vector<int> dp[3];
	for(int i = 0; i < 3; i++)
		dp[i].assign(n, -1);
	queue<pair<int, int>> q;
	q.push(make_pair(s - 1, 0));
	while (!q.empty()) {
		pair<int, int> e = q.front();
		q.pop();

		int p = e.second % 3;

		if (dp[p][e.first] != -1)
			continue;

		dp[p][e.first] = e.second;
		for (auto i : uv[e.first]) {
			q.push(make_pair(i, e.second + 1));
		}
	}

	cout <<
		(dp[0][t - 1] == -1 ?
			-1 : dp[0][t - 1] / 3) << endl;

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  int ac = 0, wa = 0, tle = 0, re = 0;

  while ( n-- > 0 ) {
    string s;
    cin >> s;
    if ( s == "AC" ) { ac++; }
    if ( s == "WA" ) { wa++; }
    if ( s == "TLE" ) { tle++; }
    if ( s == "RE" ) { re++; }
  }

  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	string c;
	cin>>c;


	if(c=="A") {
		cout<<"T"<<endl;
	}
	if(c=="T") {
		cout<<"A"<<endl;
	}
	if(c=="C") {
		cout<<"G"<<endl;
	}

	if(c=="G") {
		cout<<"C"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int ele1,ele2;
int s[1000][1000];
int s_pointer[1000];

void func_print(int s[][1000],int s_size,int s_num)
{
    printf("%d\n",s_num);
    for (int i=0; i<s_num; ++i)
    {
        printf("%d ",s_size);
        for (int j=0; j<s_size; ++j)
            printf("%d ",s[i][j]);
        printf("\n");
    }
}
void func_cal(int n,int s_size,int s_num)
{
    int tail=1;
    for (int i=0; i<s_num; ++i)
    {
        int size_tmp=0;
        for (int j=0; j<i; ++j)
        {
            s[i][size_tmp++]=s[j][s_pointer[j]++];
        }
        while (size_tmp<s_size)
            s[i][size_tmp++]=tail++;
        s_pointer[i]=(i==0)?0:s_pointer[i-1];
    }
}

int main()
{
    cin>>n;
    ele1=int(trunc(sqrt(2*n)));
    ele2=2*n/ele1;
    if (ele1*ele2!=2*n || (ele2-ele1!=1)) {cout<<"No"<<endl; return 0;} else cout<<"Yes"<<endl;
    func_cal(n,ele1,ele2);
    func_print(s,ele1,ele2);
    return 0;
}
    


Measured memory_bytes: 3200
def swap(a, b):
    tmp = a
    a = b
    b = tmp;
    return a, b

n = int(input())
p = list(map(int, input().split()))
g = p.copy()
q = sorted(p)
flag = 0
for i in range(n):
    for j in range(n):
        p[i], p[j] = swap(p[i], p[j])
        if (p == q):
            flag = 1
        p = g.copy()
if flag == 1:
    print("YES")
else:
    print("NO")


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



Measured memory_bytes: 3116
n = int(input())
A = list(map(int,input().split()))

from collections import deque

d = deque()

for i,a in enumerate(A):
    if i % 2 == 0:
        d.append(a)
    else:
        d.appendleft(a)

if n % 2 != 0:
    d.reverse()

for i in d:
    print(i,end=" ")
print()

Measured memory_bytes: 30840
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void solve(){
  #ifndef ONLINE_JUDGE    
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf   
    ll n,m;
    cin>>n>>m; 
    ll h[n];
    for(ll i=0;i<n;i++) 
    cin>>h[i];
    ll a2[100000];
    fill(a2,0);
    for(ll i=0;i<m;i++){
      ll a,b;
      cin>>a>>b; 
      a2[a-1]=max(a2[a-1],h[b-1]);
      a2[b-1]=max(a2[b-1],h[a-1]);
    }
    ll ans=0;
    for(ll i=0;i<n;i++){
      ans+=(h[i]>a2[i]);
    }
    cout<<ans<<endl; 
    
    return 0;
}
    

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

int main() {
   int n,k;
cin>>n>>k;
vector<int> l(n);
for(int i=0;i<n;i++){
cin>>l[i];
}
sort(l.begin(),l.end());
int ans=0;
for(int i=0;i<k;i++){
ans+=l[n-1-i];
}
cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
 	int n, z = 1;
	cin >> n;
	for (int i = 2 ; i <= n ; i++) {
		int x = i * i;
		while (x <= n) {
			z = max(z, x);
			x *= i;
		}
	}
	cout << z;
}

Measured memory_bytes: 3552
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String[] a = new String[h];
        for(int i = 0; i < h; i++){
            a[i] = sc.next();
        }
        int p = 0;
        for(int i = 0; i < h+2; i++){
            if(i == 0 || i == h+1){
                for(int j = 0; j < w+2; j++){
                    if(j == w+1){
                        System.out.println('#');
                    } else {
                        System.out.print('#');
                    }
                }
            } else {
                System.out.println('#' + a[p] + '#');
                p++;
            }
        }
    }
}

Measured memory_bytes: 21204
#include<iostream>
using namespace std;
static const int N=100;

int main(){
    int M[N][N];
    int n,u,k,v;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            M[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        cin>>u>>k;
        u--;
        for(int j=0;j<k;j++){
            cin>>v;
            v--;
            M[u][v]=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j==n-1){
                cout<<M[i][j];
            }
            else{
                cout<<M[i][j];
                cout<<" ";
            }
        }
        cout<<endl;
    }
    return 0;
}


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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> vn(n+2,0);
  for(int i=0; i<n; ++i) cin >> vn[i+1];
  int ans = 0;
  for(int i=0; i<=m && i<=n; ++i){
    vector<int> minusv(0);
    int nans1 = 0;
    for(int j=0; j<=i; ++j){
      //cout << "取得回数:" << i << " 左から:" << j << endl;
      if(vn[j] >=0) nans1 += vn[j];
      else minusv.push_back(vn[j]);;
      int nans2 = nans1;
      vector<int> minusv2 = minusv;
      for(int k=0; k+j<=i; ++k){
        //cout << "右から:" << k;
        int x = n +1 -k;
        if(vn[x] >=0) nans2 += vn[x];
        else minusv2.push_back(vn[x]);
        sort(minusv2.begin(),minusv2.end());
        reverse(minusv2.begin(),minusv2.end());
        int minx = minusv2.size() -(m -j -k);
        int nans3 = nans2;
        for(int l=0; l<minx; ++l) nans3 += minusv2[l];
        //cout << " スコア:" << nans3 << endl;
        ans = max(ans, nans3);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
def b_minesweeper(H, W, S):
    # 書き換え後のフィールド
    field = [[''] * W for _ in range(H)]
    # あるマス目の右、下、左、上、右下、左下、左上、右上
    neighbouring_square = ((0, 1), (1, 0), (0, -1), (-1, 0), (1, 1), (1, -1), (-1, -1), (-1, 1))

    def is_in_field(row, col):  # 調べるマスがフィールド内か？
        return (0 <= row < H) and (0 <= col < W)

    for row in range(H):
        for col in range(W):
            if S[row][col] == '#':
                field[row][col] = '#'
                continue

            num = 0  # 周囲8マスの#の数
            for dr, dc in neighbouring_square:
                nr, nc = row + dr, col + dc
                if is_in_field(nr, nc) and S[nr][nc] == '#':
                    num += 1
            field[row][col] = str(num)
    return '\n'.join(''.join(row) for row in field)


H, W = [int(i) for i in input().split()]
S = [input() for _ in range(H)]
print(b_minesweeper(H, W, S))

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000007;




int main() {
	
	int h, w;
	cin >> h >> w;

	VVC a(h, VC(w));

	VVC b = a;
	REP(i, h)REP(j, w) {
		cin >> a[i][j];
		b[i][j] = a[i][j];
	}

	VVI c(h, VI(w,0));
	VVI d(h, VI(w,0));

	REP(i, h) {
		REP(j, w) {
			if (a[i][j] == '#')continue;
			int cnt = 1;
			int k = j;
			while (true) {
				if (j + 1 == w) {
					FOR(l, k, k + cnt)c[i][l] = cnt;
					break;
				}
				else if (a[i][j + 1] == '.') {
					j++;
					cnt++;
				}
				else {
					FOR(l, k, k + cnt)c[i][l] = cnt;
					break;
				}
			}
		}
	}

	REP(i, w) {
		REP(j, h) {
			if (a[j][i] == '#')continue;
			int cnt = 1;
			int k = j;
			while (true) {
				if (j + 1 == h) {
					FOR(l, k, k + cnt)d[l][i] = cnt;
					break;
				}
				else if (a[j+1][i] == '.') {
					j++;
					cnt++;
				}
				else {
					FOR(l, k, k + cnt)d[l][i] = cnt;
					break;
				}
			}
		}
	}

	int ans = 0;

	REP(i, h)REP(j, w) {
		ans = max(ans, c[i][j] + d[i][j]-1);
	}

	cout << ans << endl;

}


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

int N;
int beki3[11] = {1},beki2[11] = {1};
int num[3] = {3,5,7};
string S;


int main(){
	cin >> N;
	if(N/100==0){
		cout << 0 << endl;
		return 0;
	}
	for(int i=1;i<=10;i++){
		beki2[i] = beki2[i-1]*2;
		beki3[i] = beki3[i-1]*3;
	}
	S = to_string(N);
	int n = S.size();
	int ans = 0;
	for(int i=3;i<=n;i++) ans += beki3[i-1]-3*beki2[i-1]+3;
	int len[n+1] = {0};
	for(int i=0;i<pow(3,n);i++){
		int t = i;
		bool judge[3] = {0};
		for(int j=0;j<n;j++){
			len[j] = t%3;
			judge[len[j]] = true;
			t /= 3;
		}
		if(!judge[0] || !judge[1] || !judge[2]) continue;
		bool ok = true;
		for(int j=0;j<n;j++){
			char c = S[j];
			if(num[len[j]]>atoi(&c)) ok = false;
			if(num[len[j]]<atoi(&c)) break;
		}
		if(ok){
			ans++;
//			cout << num[len[0]] << " " << num[len[1]] << " " << num[len[2]] << endl;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
from collections import defaultdict as de
s=de(int)
n=int(input())
a=sorted([list(map(int,input().split()))for i in range(n)])
for i in range(n):
    for j in range(i):
        s[(a[i][0]-a[j][0],a[i][1]-a[j][1])]+=1
print(n-max(s.values(),default=0))


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define int long long


using namespace std ;
const int N  = 1e5 +5;
int dp[N] ;
bool vis[N+1] ;

int dfs(const vector<int> (g)[] ,int u)
{
    vis[u] = true;
    for(auto i :g[u])
    {
        if(vis[i] == 0)
        {
            dfs(g , i) ;
        }
        dp[u] = max(dp[u] , 1+ dp[i]) ;

    }
    return dp[u] ;


}


signed main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;

    int n , m ;

    cin >> n >> m ;
    int u , v ;
    vector<int> g[n+1] ;

    for(int i = 0 ; i < m ; ++i )
    {
        cin >> u >> v ;
        g[u].push_back(v) ;
    }

    for(int i = 1 ; i <= n  ; ++i)
    {
        if(vis[i] == 0 )
        {
            dfs(g , i) ;
        }

    }
    int ans = *max_element(dp ,dp+n+1 ) ;
    cout << ans << endl ;
}


Measured memory_bytes: 13232
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;
const int MM = 18;

long long k, dp[MM][10], sum[MM][10];

string go(int i, int j){
//    print(i, j, k);
    if(i == 0)
        return to_string(j);
    for(int l = max(0, j-1); l <= min(9, j+1); l++){
        if(dp[i-1][l] <= k){
            k -= dp[i-1][l];
        }
        else return to_string(j) + go(i-1, l);
    }
    //idk
    return to_string(j)+go(i-1, min(9, j+1));
}

int main(){
    for(int i = 0; i <= 9; i++)
        dp[0][i] = 1, sum[0][i] = i;
    for(int i = 1; i < MM; i++){
        for(int j = 0; j <= 9; j++){
            for(int l = max(j-1, 0); l <= min(j+1, 9); l++){
                dp[i][j] += dp[i-1][l];
            }
            sum[i][j] = dp[i][j];
            if(j) sum[i][j] += sum[i][j-1];
            else sum[i][j] += sum[i-1][9];
//            printf("%lld ", dp[i][j]);
        }
//        pc(10);
    }
//    for(int i = 1; i < MM; i++){
//        for(int j = 0; j <= 9; j++){
//            printf("%lld ", sum[i][j]);
//        }
//        pc(10);
//    }
    
    scan(k);
//    k = 15;
    k--;
    
    int si = 0, sj = 0;
    string res;
    for(int i = 0; i < MM; i++){
        for(int j = 1; j <= 9; j++){
            if(dp[i][j] <= k){
                k -= dp[i][j];
            }
            else{
                si = i, sj = j;
                goto out;
            }
        }
    }
    out:;
    
    res = go(si, sj);
    
//    cout<<"f "<<res<<endl;
    reverse(all(res));
    while(res.size() and res.back() == '0')
        res.pop_back();
    reverse(all(res));
    cout<<res;
    
    return 0;
}

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

using namespace std;
typedef long long ll;

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


int main(int argc, char* argv[])
{
  int a, b;
  cin >> a >> b;
  if (a % 2 == 0 || b % 2 == 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long int li;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    ll ans=0;
    char n;
    cin >> n;
    if(n=='A')cout << 'T' << endl;
    if(n=='T')cout << 'A' << endl;
    if(n=='G')cout << 'C' << endl;
    if(n=='C')cout << 'G' << endl;
    return 0;
}



Measured memory_bytes: 256
<?php
// B
fscanf(STDIN, '%d', $n);
fscanf(STDIN, '%s', $s);
$ans = 0;
for ($i = 1; $i < $n; $i++) {
    $cnt = 0;
    $x = count_chars(substr($s, 0, $i), 1);
    $y = count_chars(substr($s, $i, $n - $i), 1);
    foreach ($x as $idx => $v) {
        if (isset($y[$idx])) $cnt++;
    }
    $ans = max($ans, $cnt);
}
echo $ans;

Measured memory_bytes: 4728
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, M, p, wa_cnt;
bool AC[100003];
int WA[100003];
string s;
set<int> S;

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

  cin >> N >> M; 
  rep(i, M) {
    cin >> p >> s;
    p--;
    if (s == "AC") {
      S.insert(p);
      if (!AC[p]) wa_cnt+=WA[p];
      AC[p] = true;
    }
    else {
      WA[p]++;
    }
  }
  cout << S.size() << ' ' << wa_cnt << "\n";
  return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define ll long long int
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define pb(v, a) v.push_back(a)
#define Sort(v) sort(v.begin(), v.end())
#define For(m) for (auto it = m.begin(); it != m.end(); it++)
#define mod 1000000007
#define PI 3.14159265358979323846
using namespace std;

int main()
{
  ll n;
  cin >> n;
  ll arr[n];
  
  fr(i,0,n)cin >> arr[i];
  ll ans =arr[0];
  fr(i,0,n)ans=min(ans,arr[i]);
  bool x =true;
  fr(i,0,n)
  {
      if(ans==arr[i]&&x)
      {
          x=false;
      }
      else
      {
          arr[i]%=ans;
      }
  }
   priority_queue <ll, vector<ll>, greater<ll> > pq;
   fr(i,0,n)
   {
       if(arr[i]!=0)
       {
           pq.push(arr[i]);
       }
   } 
   while(pq.size()!=1)
   {
       ll x = pq.top();
       pq.pop();
       vector<ll>x1;
       while(!pq.empty())
       {
           pb(x1,pq.top()%x);
           pq.pop();
       }
       pq.push(x);
       fr(i,0,x1.size())
       {
           if(x1[i]!=0)
           pq.push(x1[i]);
       }
   }
   cout << pq.top();
  return 0;
}


Measured memory_bytes: 3316
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
 
#define endl '\n'
#define loop(i, m, n) for (ll i = m; i < n; i++)
#define loope(i, m, n) for (ll i = m; i <= n; i++)
#define epool(i, m, n) for (ll i = m; i >= n; i--)
#define mod 1000000007
#define mod2 998244353
#define vi vector<ll>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x,0;
#define all(v) v.begin(),v.end()
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll>,greater<ll>>
const ll INF=1e18;
const double PI=4*atan(1);

#define SpeedForce                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;

ll mpow(ll base,ll exp,ll M);
ll POW(ll base,ll exp);
ll gcd(ll a,ll b);
ll lcm(ll a,ll b);
ll modInverse(ll n);
ll nCr(ll n, ll r);

void solve(){
     ll a,b,c,k;
    cin >> a >> b >> c >> k;

    ll cn=0;
    while(b<=a){
        b=b*2;
        cn++;
    }

    while(c<=b){
        c=2*c;
        cn++;
    }

    if(cn<=k) cout << "Yes";
    else cout << "No";
    cout << endl;

}

int32_t main(){
    SpeedForce
    ll i = 0,j = 0;

    int t;
    t=1;
    //cin >> t;
    //ll cnt=1;
    while (t--){
        //cout << "Case #" << cnt << ": ";
        //cout << fixed << setprecision(10);
        solve();
        //cout << endl;
        //cnt++;
    }
}

ll POW(ll base,ll exp){
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base);
        base = ((ll)base * base);
        exp >>= 1;
    }
    return result;
}

ll mpow(ll base, ll exp,ll M){
    base %= M;
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base) % M;
        base = ((ll)base * base) % M;
        exp >>= 1;
    }
    return result%M;
}

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

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

ll modInverse(ll n) { 
    return mpow(n, mod-2,mod); 
}
 
ll nCr(ll n, ll r){ 
   if (r==0) 
      return 1; 
    ll fac[n+1]; 
    fac[0] = 1; 
    for (int i=1 ; i<=n; i++) 
        fac[i] = (fac[i-1]*i)%mod; 
    return ((fac[n]* modInverse(fac[r]) % mod * 
            modInverse(fac[n-r]) % mod)%mod)%mod; 
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
//#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 998244353
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    int res = 1;

    x = x;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);

        y = y>>1;
        x = (x*x);
    }
    return res;
}
bool isprime(int x)
{
      if(x<2)
        return false;
    for(int i=2;i*i<=x;i++)
     {
        if (x%i==0)
            return false;
    }
    return true;
}
vector<int>primeFactors(int n)
{
    vector<int>v;
    while (n % 2 == 0)
    {
        v.pb(2);
        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            v.pb(i);
            n = n/i;
        }
    }
    if (n > 2)
        v.pb(n);
    return v;
}

void solve()
{
int a,b,c,k;
cin>>a>>b>>c>>k;
if(k<=a)
{
    cout<<k<<endl;
    return ;
}
else
{
    int ans=0;
    ans+=a;
    k-=a;
    if(k<=b)
    {
        cout<<ans<<endl;
        return ;
    }
    else
        k-=b;
    ans-=k;
    cout<<ans<<endl;
}
}
signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
//cin>>t;
t=1;
while(t--)
{
solve();
}
}


Measured memory_bytes: 3636
use std::io;
use std::cmp::Ordering;
use std::str::FromStr;

fn get_line() -> String {
    let mut line = String::new();
    io::stdin().read_line(&mut line).ok();
    line
}

fn get_vector() -> Vec<i32> {
    let line = get_line();
    let vec : Vec<i32> = line.split_whitespace().map(|x| i32::from_str(x).unwrap()).collect();
    return vec;
}

fn main() {
    loop {
        let mut vec = get_vector();
        if vec[0] == 0 && vec[1] == 0{
            break;
        }
        vec.sort();
        println!("{} {}", vec[0], vec[1]);
    }
}



Measured memory_bytes: 5036
package main

import "fmt"

func main(){
	var x, y int
	fmt.Scanf("%d %d", &x, &y)
	for x != 0 || y != 0{
		if x < y{
			fmt.Println(x, y)
		}else{
			fmt.Println(y, x)
		}
		fmt.Scanf("%d %d", &x, &y)
	}
}



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

int z[5001];
int res = 0;
int n;
string s;

void solve(){
	for(int i = 0; i < n;i++) z[i]=0;
	int l = 0,r = 0;
	for(int i = 1; i < n; i++){
		if(i<=r){
			z[i] = min(r-i+1,z[i-l]);
		}
		while(i+z[i]<n && s[z[i]] == s[i+z[i]]) z[i]++;
		if(i+z[i]-1>r)
			l = i,r = i+z[i]-1;
	}

	for(int i = 1; i < n; i++){
		res = max(res, min(i,z[i]));
	}

}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	 cin>>n;
	 cin>>s;
	 while(n>0){
	 	solve();
	 n--;
	 for(int i = 0; i < n; i++)
	 	s[i] = s[i+1];
	 }
	 cout<<res;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int w,h,n; cin>>w>>h>>n;
    bool board[w][h]={};
    rep(i,n){
        int x,y,a; cin>>x>>y>>a;
        if(a==1){
            rep(xx,x)rep(yy,h) board[xx][yy]=1;
        }
        if(a==2){
            rep(xx,w-x)rep(yy,h) board[w-1-xx][yy]=1;
        }
        if(a==3){
            rep(xx,w)rep(yy,y) board[xx][yy]=1;
        }
        if(a==4){
            rep(xx,w)rep(yy,h-y) board[xx][h-1-yy]=1;
        }
    }
    int cnt=0;
    rep(i,w)rep(j,h){
        if(board[i][j]) cnt++;
    }
    cout<<w*h-cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483648
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#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--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

int main() {
	string s;
	cin >> s;
	bool turn = 1;
	int ans = 0;
	Loop(i, s.length()) {
		if (turn) {
			if (s[i] == 'p') ans--;
			turn = !turn;
		}
		else {
			if (s[i] == 'g') ans++;
			turn = !turn;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=1;i<=n;i++)
signed main(){
  int n,m;
  int x;
  int mod=1e9+7;
  cin>>n>>m;
  int sx=0,sy=0;
  rep(i,n)cin>>x,sx+=(i-1)*x-(n-i)*x,sx%=mod;
  rep(i,m)cin>>x,sy+=(i-1)*x-(m-i)*x,sy%=mod;
  cout<<(sx*sy)%mod<<endl;
  return 0;
}


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

using namespace std;

#define rep(i, a) for (int i = 0; i < a; i++)
#define reps(i, b, a) for (int i = b; i < a; i++)

int culc(int x, int g)
{
  if (x >= g) return x - g;
  if ((g - x) % 2 == 0) return (g - x) / 2;
  return (g - x) / 2 + 2;
}

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  int mi = 1000000;
  reps(i, -10, 60) {
    int t = culc(A, i) + culc(B, i) + culc(C, i);
    mi = min(mi, t);
  }
  cout << mi << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstring>

const int N = 15;

int n, m;
char s[N][N];

int p[N][2], cnt;

bool vis[N];

bool check() {
  int t = n / 2, ss = 0;
  memset(vis, 0, sizeof vis);
  for (int i = 0; i < m; ++i) if (!vis[i]) {
    bool ok;
    for (int j = i + 1; j < m; ++j) if (!vis[j]) {
      ok = true;
      for (int k = 0; k < t; ++k)
        if (s[p[k][0]][i] != s[p[k][1]][j] || s[p[k][0]][j] != s[p[k][1]][i]) {
          ok = false;
          break;
        }
      if (ok) {
        vis[j] = true;
        break;
      }
    }
    if (!ok) {
      for (int k = 0; k < t; ++k)
        if (s[p[k][0]][i] != s[p[k][1]][i])
          return false;
      ++ss;
    }
  }
  return ss <= m % 2;
}

bool dfs(int S, bool t) {
  if (S == 0) return check();
  if (t && dfs(S & (S - 1), false)) return true;
  if (S != (S & -S)) {
    int x = 0;
    while ((~S >> x) & 1) ++x;
    for (int y = x + 1; y < n; ++y) if ((S >> y) & 1) {
      p[cnt][0] = x; p[cnt][1] = y;
      ++cnt;
      if (dfs(S & ~(1 << x) & ~(1 << y), t)) return true;
      --cnt;
    }
  }
  return false;
}

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i)
    scanf("%s", s[i]);
  puts(dfs((1 << n) - 1, n % 2 == 1) ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    int n;
    string a,b;
    cin>>n>>a>>b;
    for(int i=0;i<n;i++){
        cout<<a[i]<<b[i];
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int R=1,C=1,H[1000010]={0};
int N[1000010]={-1000};
//??????????????\??????
void hin(int a){
  int i=C++;
  for(N[R]=a;a<N[H[i/2]];i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//???????????????????°???????????????????
int hout(){
  int rt=H[1],nt=1,i=0,k=H[--C];
  while(nt-i){
    H[i=nt]=k;
    if(i*2  <C&&N[  k  ]>N[H[i*2  ]])H[i]=H[nt=i*2  ];
    if(i*2+1<C&&N[H[nt]]>N[H[i*2+1]])H[i]=H[nt=i*2+1];
  }
  return rt;
}
int main(){
  int n,m,k,i,j,d[100010],t,a,b;
  scanf("%d",&m);
  while(m--){
    scanf("%d %d %d",&n,&k,&b);
    for(i=0;i<n-1;i++){
      scanf("%d",&a);
      hin(a-b);
      b=a;
    }
    for(i=t=0;i<n-k;i++)t+=N[hout()];
    printf("%d\n",t);
    C=R=1;
  }
  return 0;
}
       

Measured memory_bytes: 3228
import sys
import math
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(20000000)


def main():
    N = int(input())
    nums = [int(input()) for _ in range(N)]
    a = deepcopy(nums)
    a.sort(reverse=True)

    for i in range(len(nums)):
        if a[0] == nums[i]:
            print(a[1])
        else:
            print(a[0])


if __name__ == '__main__':
    main()



Measured memory_bytes: 14628
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int count=0,flag=0,c;
  string s;
  string p;
  cin >> s >> p;

  for(int i=0;i<s.size();i++){
    count=0;
    for(int j=0;j<p.size();j++){
      c = i+j;
      c%=s.size();
      if(s[c]==p[j])count++;       
      else break;
    }
    if(count==p.size()){
      cout<<"Yes"<<endl;
      flag=1;
      break;
    }
    
    
  }
  if(flag==0){
    cout<<"No"<<endl;}
  return 0;
}
    
  

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

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	string ans = "";
	rep(i, S.size()) {
		char c = S[i];
		int count = 0;
		rep(j, 26) {
			if (c == alphabet[j]) {
				count = j;
				break;
			}
		}
		count += N;
		count %= 26;
		ans += alphabet[count];
	}
	
	cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int a, b, c;
    cin >> a >> b >> c;
    printf("%lld\n", (a + b + c) - max({a, b, c}));
    return 0;
}


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

using namespace std;

typedef long long ll;

template<typename T> ostream& operator << (ostream& os, vector<T> v) {
  for (auto& i : v) os << i << " "; return os; 
}
template<typename T> istream& operator >> (istream& is, vector<T>& v) {
  for (auto& i : v) is >> i; return is;
}
template<typename K, typename V> ostream& operator << (ostream& os, unordered_map<K, V> m) {
  for (auto& i : m) os << i.first << ":" << i.second << endl; return os;
}
template<typename T> inline bool chmin(T& x, T y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}
template<typename T> inline bool chmax(T& x, T y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  cin >> a;

  // second-acted player wins
  vector<bool> dp(k+1, false);
  for (int i=1; i<=k; i++) {
    for (int j=0; j<n; j++) {
      if (i - a[j] >= 0) {
        // switch the winner
        // e.g. x = 2, k = 6
        // dp[0] = False
        // dp[2] = dp[2] | !dp[0] => True
        // dp[4] = dp[4] | !dp[2] => False
        // dp[6] = dp[6] | !dp[4] => True
        dp[i] = dp[i] | !dp[i-a[j]];
      }
    }
  }
  if (dp[k]) cout << "First" << endl;
  else cout << "Second" << endl;
  return 0;
}


Measured memory_bytes: 256