akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

string s[3];
queue<char> q[3];

int win(int k) {
  if (q[k].empty()) {
    return k;
  }
  int l = q[k].front() - 'a';
  q[k].pop();
  win(l);
}

int main() {
  for (int i = 0; i < 3; i++) {
    cin >> s[i];         
  }
  
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < s[i].length(); j++) {
      q[i].push(s[i][j]);
    }
  }

  cout << char('A' + win(0)) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n;

int main() {
	cin >> n;
	switch (n % 10) {
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		cout << "hon" << endl;
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		cout << "pon" << endl;
		break;
	case 3:
		cout << "bon" << endl;
	}
	return 0;
}

Measured memory_bytes: 3604
/**
   * Sridip
   * RCCIIT, Kolkata
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
#define pw(b, p) pow(b, p) + 0.1
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void aag()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int32_t main()
{
	aag();
	
	int x, y, z;
	
	cin>>x>>y>>z;
	
	cout<<z<<" "<<x<<" "<<y<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028841971693993
#define MOD 998244353
#define sec setprecision
using namespace std;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	if (n == 0)
		return 1;
	else if (x == 1)return(1);
	else if (n % 2 == 0)
		return pow(x * x, (n / 2));
	else
		return x * pow(x, n - 1);
}
int ketasuu(ll h) {
	if (h < 0)return(-(ketasuu(-h)));
	else if (h < 10)return(1);
	else return(1 + ketasuu(h / 10));
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long com(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
long long n,k,ans=0;
long long q=0;
long long len[55];
map<int,long long> mp;
long long dfs(int step,long long num)
{
	if(num==1&&step==0) return 1;
	if(num==0||num==1) return 0;
	//cout<<"start "<<cc<<":"<<step<<" "<<num<<endl;
	long long sum=0;
	num--;
	long long mid=len[step-1];
	if(step==0) return 1;
	if(num<mid) return dfs(step-1,num);
	if(num>=mid) sum+=mp[step-1];
	num-=len[step-1];
	if(num==0) return sum;
	if(num!=0) sum++;
	num--;
	if(num==0) return sum;
	if(num<mid) return dfs(step-1,num)+sum;
	if(num>=mid) sum+=mp[step-1];
	return sum;
}
int main()
{
	len[0]=1;
	for(int i=1;i<=50;i++) len[i]=len[i-1]*2+3;
	mp[0]=1;
	for(int i=1;i<=50;i++) mp[i]=mp[i-1]*2+1;
	mp[0]=1;
	cin>>n>>k;
	cout<<dfs(n,k);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    for (size_t i = 0; i < 3; i++)
    {
        if (s[i] == s[i+1])
        {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}


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

int main() {
  char a,b,c;
  cin>>a>>b>>c;
  if(a==b and b==c){
    cout<<"No";
  }
  else{
    cout<<"Yes";
  }
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 300000
#define INC(X) \
  ( (X) % 7 == 1 ? (X) + 5 : (X) + 2 )

static int p[ N ];
static int pn;

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( i = 6; i < N; i = INC( i ) )
  {
    if ( p[ i ] ) continue ;

    for ( j = 6; i * j < N; j = INC( j ) )
    {
      p[ i * j ] = 1;
    }
  }
  for ( i = 6; i < N; i = INC( i ) )
  {
    if ( p[ i ] ) continue ;

    p[ pn++ ] = i;
  }

  for ( ; ; )
  {
    int n;

    scanf ( "%d", &n );
    if ( n == 1 ) break ;

    printf ( "%d:", n );
    for ( i = 0; i < pn; ++i )
    {
      if ( n % p[ i ] ) continue ;

      printf ( " %d", p[ i ] );
    }
    puts ( "" );
  }

  return ( 0 );
}

Measured memory_bytes: 1580
#include <bits/stdc++.h> 
using namespace std;
#define ll long long 
#define mod 998244353
#define MOD 998244353
ll fact[1000001];
void fast(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
inline ll mul(ll a,ll b){
  a=(a+MOD)%MOD;
  b=(b+MOD)%MOD;
  ll c=a*b;
  c=(c+MOD)%MOD;
  return c;
}
inline ll add(ll a,ll b){
  a=(a+MOD)%MOD;
  b=(b+MOD)%MOD;
  ll ans=(a+b);
  ans=(ans+MOD)%MOD;
  return ans;
}

ll power(ll a,ll b,ll c){
  ll ans=1;
  while(b){
    if(b&1){
      ans=mul(ans,a);
    }
    a=mul(a,a);
    b=b/2;
  }
  return ans;
}
ll ncr(ll n,ll r){
    if(r>n)return 0;
    if(r==n)return 1;
    ll xx=fact[n];
    xx=xx*power(fact[r],mod-2,mod)%mod;
    xx=xx*power(fact[n-r],mod-2,mod)%mod;
    return xx;
}
ll min(ll a,ll b){return a<b?a:b;}
ll cel(ll x){
    if(x%2==0)return x/2;
    else return x/2+1;
}
int main() 
{ 
    fast();
    ll n; cin>>n;
    n++;
    ll a[n];
    for(int i=0;i<n;++i)cin>>a[i];
    ll cnt=1;
    int flag=1;
    ll res=0;
    ll minm=a[n-1];
    ll maxm=a[n-1];
    ll z1[n];
    ll z2[n];
    z1[n-1]=z2[n-1]=a[n-1];
    for(int i=n-2;i>=0;i--){
        maxm+=a[i];
        minm=cel(minm);
        z1[i]=maxm;
        minm+=a[i];
        z2[i]=minm;
    }
    if(z2[0]>1||flag==0){
        cout<<-1<<endl;
        return 0;
    }
    for(int i=0;i<n;++i){
        ll f=min(cnt,z1[i]);
        res+=f;
        cnt-=a[i];
        cnt*=2;
        if(cnt>1e14)cnt=1e14;
    }
    cout<<res;
    return 0; 
} 


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

int main(){
  ll N,M;cin >> N >> M;
  vector<ll> A(N,0);
  vector<ll> B(N+1,0);
  for(int i=0;i<N;i++){
    cin >> A[i];
    B[i+1] = (A[i]+B[i])%M;
  }
  sort(B.begin(),B.end());
  ll sum = 0;
  ll i = 0;
  for(int j=0;j<=N;j++){
    if(j==N){
      ll x = j - i + 1;
      sum += x*(x-1)/2;
      cout << sum << endl;
      return 0;
    }
    if(B[j]!=B[j+1]){
      ll x = j - i + 1;
      sum += x*(x-1)/2;
      i = j + 1;
    }
  }
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <iomanip>
#include <map>
#include <climits>
#include <stack>
using namespace std;
#define ll long long int
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vi> vii;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<double> vf;
typedef priority_queue<double,vf,greater<double>> minHeap;

int main(){
	fastio();
	int MOD = 1000*1000*1000 + 7;
	int n,m;
	cin>>n>>m;
	vector<string> s(n);
	for(int i =0;i<n;i++){
		cin>>s[i];
	}
	vii dp(n,vi(m));
	dp[0][0] = 1;
	for(int i = 1;i<n;i++){
		if(s[i][0] == '#')
			break;
		dp[i][0]+=dp[i-1][0];
	}
	for(int i = 1;i<m;i++){
		if(s[0][i] == '#')
			break;
		dp[0][i]+=dp[0][i-1];
	}
	for(int i = 1;i<n;i++){
		for(int j =1;j<m;j++){
			if(s[i][j]!='#'){
				if(s[i][j-1]!='#')
					dp[i][j] = (dp[i][j] + dp[i][j-1])%MOD;
				if(s[i-1][j]!='#')
					dp[i][j] = (dp[i][j] + dp[i-1][j])%MOD;
			}
		}
	}
	cout<<dp[n-1][m-1];
	return 0;
 
}

Measured memory_bytes: 5248
import java.util.*;
class Main {
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        for(int i = 0; i < n; i++) {
            x[i] = stdIn.nextInt();
        }
        for(int i = 0; i < n; i++) {
            y[i] = stdIn.nextInt();
        }
        for(int p = 1; p <= 3; p++) {
            double dis = 0.0;
            for(int i = 0; i < n; i++) {
                dis += Math.pow(Math.abs(x[i] - y[i]),p);
            }
            System.out.println(Math.pow(dis, 1.0/p));
        }
        int max = 0;
        for(int i = 0; i < n; i++) {
            max = Math.max(max, Math.abs(x[i] - y[i]));
        }
        System.out.println(max);
         
    }
}


Measured memory_bytes: 26752
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        while(true) {
            int H = scn.nextInt(), W = scn.nextInt();
            if(H == 0 && W == 0) {
                break;
            }
            for(int i = 0; i < H; i++) {
                for(int j = 0; j < W; j++) {
                    System.out.print((i + j) % 2 > 0 ? "." : "#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 26884
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;
struct edge
{
	int to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
//int index(int x, int y, int w) { return w*x + y; }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int h, w, c;
vector<vi> fld;
int ans;

void paint(int col)
{
	int tmp = fld[0][0];
	if (tmp == col) return;
	fld[0][0] = col;
	queue<P> que;
	que.push(P(0, 0));
	while (que.size())
	{
		int x = que.front().first, y = que.front().second;
		que.pop();
		REP(j, 4)
		{
			int nx = x + dx[j], ny = y + dy[j];
			if (valid(nx, ny, h, w) && fld[nx][ny] == tmp)
			{
				que.push(P(nx, ny));
				fld[nx][ny] = col;
			}
		}
	}
}

void solve(int i)
{
	if (i == 4)
	{
		auto copy = fld;
		paint(c);
		int cnt = 0;
		queue<P> que;
		que.push(P(0, 0));
		fld[0][0] = -1;
		while (que.size())
		{
			int x = que.front().first, y = que.front().second;
			que.pop();
			cnt++;
			REP(j, 4)
			{
				int nx = x + dx[j], ny = y + dy[j];
				if (valid(nx, ny, h, w) && fld[nx][ny] == c)
				{
					que.push(P(nx, ny));
					fld[nx][ny] = -1;
				}
			}
		}
		chmax(ans, cnt);
		fld = copy;
		return;
	}
	else
	{
		REP(j, 6)
		{
			auto copy = fld;
			paint(j);
			solve(i + 1);
			fld = copy;
		}
	}
}

int main()
{
	while (cin >> h >> w >> c, h)
	{
		c--;
		ans = 0;
		fld.clear();
		fld.resize(h, vi(w));
		REP(i, h)REP(j, w)
		{
			cin >> fld[i][j];
			fld[i][j]--;
		}
		solve(0);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % 2019;
    } else {
        return modpow(m, n - 1) * m % 2019;
    }
}

signed main() {
    long long n, m;
    cin >> n >> m;
    vector<int> h(n);
    REP(i, n) { cin >> h[i]; }
    vector<long long> good(n, 1);
    for (long long i = 0; i < m; i++) {
        long long s, k;
        cin >> s >> k;
        int c = 0;
        if (h[s - 1] > h[k - 1]) {
            good[k - 1]--;
            ;
        } else if (h[k - 1] > h[s - 1]) {
            good[s - 1]--;
            ;
        } else {
            good[s - 1]--;
            good[k - 1]--;
        }
    }
    int ans = 0;
    REP(i, n) {
        if (good[i] == 1) {
            ans++;
        }
        //cout << good[i] << endl;
    }
    cout << ans << endl;
}

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

int main() {
  int A, B, H, M;
  double c, C;
  cin >> A >> B >> H >> M;
  
  c = H*30 + M*0.5-M*6;
  if (c <0){
    c = c*(-1);
  }
  if (c>180){
    c = 360-c;
  }
  C = cos(c*3.141592653589793238462643383279502884197169399375105820974944/180);
  
  std::cout << std::setprecision(30) << sqrt(A*A + B*B - 2*A*B*C) << endl;
  
  
 
}


Measured memory_bytes: 4164
#include<bits/stdc++.h>
using namespace std;
const int N=1e4+5;
int a[N],b[N];
int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i];
    long long s=0;
    for(int i=0; i<n; i++)
        cin>>b[i];
    for(int i=0; i<n; i++)
    {
        if(a[i]>b[i])
            s-=a[i]-b[i];
        else s+=(b[i]-a[i])/2;
    }
    if(s>=0)
        printf("Yes");
    else printf("No");
    return 0;
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    int N, M;
    cin >> N >> M;

    vector<string> A(N);
    rep(i, N) cin >> A[i];

    vector<string> B(M);
    rep(i, M) cin >> B[i];

    bool ok;
    rep(i, N) {
        rep(j, N) {
            if (i + M > N) continue;
            if (j + M > N) continue;

            ok = true;
            rep(y, M) {
                rep(x, M) {
                    if (A[i + y][j + x] != B[y][x]) {
                        ok = false;
                        break;
                    }
                }
                if (!ok) break;
            }
            if (ok) break;
        }
        if (ok) break;
    }

    if (ok) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>m;

    k = m-(m>>1);
    x = m>>1;

    for(int i=1;i<=x;i++){
        cout<<i<<" "<<(x*2+2-i)<<"\n";
    }

    for(int i=1;i<=k;i++){
        cout<<(i+x*2+1)<<" "<<(m*2+2-i)<<"\n";
    }

    return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
int m,a,b,c;
int main(){
    int n,k;
    string s,t;
    cin >> n;

    for (int i = 0; i < n; i++){
        cin >> s;
        if (s == "AC") m++;
        if (s == "WA") a++;
        if (s == "TLE") b++;
        if (s == "RE") c++;
    }

    cout << "AC x " << m << endl;
    cout << "WA x " << a << endl;
    cout << "TLE x " << b << endl;
    cout << "RE x " << c << endl;
}


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

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

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

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

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

fn main() {
    input!(n: i32, y: i32);

    for i in 0..n + 1 {
        for j in 0..(n - i + 1) {
            let k = n - (i + j);
            if i * 10000 + j * 5000 + k * 1000 == y {
                println!("{} {} {}", i, j, k);
                return;
            }
        }
    }
    println!("-1 -1 -1")
}


Measured memory_bytes: 4352
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if(abs(a - c) <= d){
        cout << "Yes" << endl;
    }else{
        if(abs(a - b) <= d && abs(b - c) <= d){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

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

int main() {
  int n, i, j, k;
  int *R;
  int max, min;

  scanf("%d", &n);
  R = malloc(n*sizeof(int));
  for(i = 0; i < n; i++) {
    scanf("%d", &R[i]);
  }
  max = R[1]-R[0];
  min = R[0];

  for(i = 0; i < n-1; i++) {
    if(R[i] < min || i == 0) {
      min = R[i];
      for(j = i+1; j < n; j++) {
	if(R[j]-R[i] > max) {
	  max = R[j]-R[i];
	}
      }
    }
  }
  printf("%d\n", max);

  return 0;
}

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

int main() {
  int w,n,a1,b1,change;
  int num[40];
  string str;
  cin >> w;
  for(int i=1;i<w+1;i++) {
    num[i] = i;
  }
  cin >> n;
  for(int i=1,from = 0,to;i<n+1;i++) {
    cin >> str;
    to = str.find(",");
    a1 = strtol(str.substr(0,to).c_str(),NULL,0);
    b1 = strtol(str.substr(to+1).c_str(),NULL,0);
    change = num[a1];
    num[a1] = num[b1];
    num[b1] = change;
  }
  for(int i=1;i<w+1;i++) {
    cout << num[i] << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b;
  int v[5];
  int res=0;
  cin >> a >> b;
  for (int i=a; i <= b; i++) {
    int tmp = i;
    for (int j=0; j < 5; j++) {
     v[j] = tmp%10;
     tmp /= 10;    
    }
    if (v[0] == v[4] && v[1] == v[3]) ++res;
  } 
  cout << res << endl;
}

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

bool isMonth(string str){
    string mm[12] = {
        "01","02","03","04","05","06","07","08","09","10","11","12"
    };
    for(int i = 0; i < 12; i++){
        if(str == mm[i]){
            return true;
        }
    }
    return false;
}

int main(){
    string str;
    cin >> str;
    string first = str.substr(0,2);
    string second = str.substr(2,2);
    string ans = "";
    if(isMonth(first) && !isMonth(second)){
        ans = "MMYY";
    } else if(!isMonth(first) && isMonth(second)){
        ans = "YYMM";
    } else if(isMonth(first) && isMonth(second)){
        ans = "AMBIGUOUS";
    } else {
        ans = "NA";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	int kkt = 1;
	while (kkt--) {
		ll S, T, D; scanf("%lld %lld %lld", &S, &T, &D); 
		vector<ll> w(D); for (int i = 0; i < D; i++) cin >> w[i];
		vector<ll> sum(D + 1); for (int i = 0; i < D; i++) sum[i + 1] = sum[i] + w[i];
		if (sum.back() >= 0) {
			for (int i = 0; i < D; i++) {
				S += w[i];
				if (S <= T) {
					cout << i + 1 << endl;
					return 0;
				}
			}
			puts("-1");
			return 0;
		}
		else {
			ll mn = *min_element(sum.begin(), sum.end());
			ll cnt = max(((S - T) + mn + sum.back()) / llabs(sum.back()), 0LL);
			S += sum.back() * cnt;
			ll res = cnt * D;
			for (int i = 0; i < D * 10; i++) {
				S += w[i % D];
				res++;
				if (S <= T) {
					cout << res << endl;
					return 0;
				}
			}
			//cout << S << endl;
		}
	}
	return 0;

}



Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int a,v,b,w,t;
	cin >> a >> v >> b >> w >> t;
	if(a < b){
		isYES(a + v * t >= b + w * t);
	}else{
		isYES(a - v * t <= b - w * t);
	}
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   int n,m;
   cin>>n>>m;
   ll ans=0;
   vector<  pair<ll,ll > > ar(m);
   ll a[n];
   for(int i=0;i<n;i++)
    cin>>a[i],ans+=a[i];
    sort(a,a+n);
   for(int i=0;i<m;i++)
   {
       cin>>ar[i].second>>ar[i].first;
   }
   sort(ar.begin(),ar.end());
   reverse(ar.begin(),ar.end());
   int p=0;
   for(int i=0;i<m;i++)
   {
       while(p<n&&ar[i].second&&(ar[i].first>a[p])){
        ans+=ar[i].first-a[p]; p++; ar[i].second--;
       }
   }
   cout<<ans;
      return 0;
}


Measured memory_bytes: 2560
def buble_sort(N,a_count):
  flag = 1
  while(flag):
    flag = 0
    for i in range(1,len(N)):
      if N[i] < N[i-1]:
        tmp = N[i-1]
        N[i-1] = N[i]
        N[i] = tmp
        flag = 1
        a_count += 1
  return a_count


x = 0
N = int(input())
a = list(map(int,input().split()))
w = buble_sort(a,x) 

for  i in range(len(a)):
  if i == len(a)- 1:
    print(a[i],end = "")
  else:
    print(a[i],end = " ")
  
print()
print(w)



Measured memory_bytes: 5608
#include<bits/stdc++.h>
#define lli long long int
#define pb push_back

using namespace std;


int main() {
    lli n,m,r,a,b,c;
    cin>>n>>m>>r;
    lli rs[r];
    lli dist[n+1][n+1];
    
    for(int i=0;i<=n;i++){
    	for(int j=0;j<=n;j++){
    		dist[i][j] = INT_MAX;
		}
		dist[i][i] = 0;
	}
    
    for(int i=0;i<r;i++){
    	cin>>rs[i];
	}
    
    for(int i=0;i<m;i++){
    	cin>>a>>b>>c;
    	dist[a][b] = c;
    	dist[b][a] = c;
	}
    
    for(int k=1;k<=n;k++){
    	for(int i=1;i<=n;i++){
	    	for(int j=1;j<=n;j++){
	    		if(dist[i][j]>dist[i][k]+dist[k][j]){
	    			dist[i][j] = dist[i][k]+dist[k][j];
				}
			}
		}
	}

    sort(rs,rs+r);
    
    lli current = 0;
    lli ans = INT_MAX;
    do{
    	
    	current = 0;
    	for(int i=0;i<=r-2;i++){
    		current+=dist[rs[i]][rs[i+1]];
		}
    	
		if(ans>current){
			ans = current;
		}
		
	}while(next_permutation(rs,rs+r));
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 512
def main():
    N = int(input())
    restaurants = {}
    for i in range(N):
        S, P = input().split()
        P = int(P)
        if not S in restaurants.keys():
            restaurants[S] = []
        restaurants[S].append([i, P])
    for s in sorted(restaurants.keys()):
        Ps = sorted(restaurants[s], key=lambda x:x[1], reverse=True)
        for p in Ps:
            print(p[0]+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))

x,y,z = 0,0,0
for i in a:
  if i%4 == 0: x += 1
  elif i%2 == 0: y += 1
  else: z += 1
    
if x >= z-1+y%2: print("Yes")
else: print("No")

Measured memory_bytes: 20016
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    string s;
    cin >> s;
    s.push_back('R');
    int n = s.size();
    vector<string> sections;
    string t;
    rep(i,n) {
        if (t.back() == 'L' && s[i] == 'R') {
            sections.push_back(t);
            t = "";
        }
        t.push_back(s[i]);
    }
    vector<int> ans;
    for (string sec : sections) {
        int sz = sec.size();
        int minians[sz];
        rep(i,sz) minians[i] = 0;
        int border;
        rep(i,sz-1) {
            if (sec[i] == 'R'&& sec[i+1] == 'L') border = i;
        }
        rep(i,sz) {
            if (abs(border-i)%2 == 0) {
                minians[border]++;
            }
            else {
                minians[border+1]++;
            }
        }
        rep(i,sz) {
            ans.push_back(minians[i]);
        }
    }
    rep(i,n-1) {
        cout << ans[i];
        if (i <= n-2) cout << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3832
n,m = map(int,input().split())

mod = 10**9+7

if abs(n-m) >= 2:
    print(0)
    exit()

tmp = 1

for i in range(n):
    tmp = tmp * (i+1) % mod
    
for i in range(m):
    tmp = tmp * (i+1) % mod
    
if n == m:
    print( tmp*2 % mod)
else:
    print(tmp)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
using namespace std;

int main() {
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];
  sort(a, a + n);
  int c = 1, cc = 0;
  REP(i, n) {
    if(a[i] < 3200 && a[i - 1] / 400 != a[i] / 400) {
      c++;
    } else if(a[i] >= 3200) {
      cc++;
    }
  }
  cout << c << " " << c + cc;
}

Measured memory_bytes: 256
from collections import deque

n = int(input())
graph = [list(map(int,input().split()))[2:] for _ in range(n)]

dist = [-1]*(n+1)
dist[0] = 0
dist[1] = 0
d = deque()
d.append(1)

while d:
    v = d.popleft()-1
    if len(graph[v]) >= 1:
        for i in graph[v]:
            if dist[i] == -1:
                dist[i] = dist[v+1]+1
                d.append(i)

for i in range(1,n+1):
    print(i,dist[i])


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

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

char f[50][50];
bool v[50][50];

int M,N;

int dfs(int x, int y)
{
	int ret=1;
	v[x][y]=1;

	for(int i=0; i<4; i++)
	{
		int tx=x+dx[i], ty=y+dy[i];
		if(tx<0||tx>=M||ty<0||ty>=N) continue;
		if(f[tx][ty]=='#') continue;
		if(v[tx][ty]) continue;

		ret+=dfs(tx,ty);
	}

	return ret;
}

int main()
{
	while(cin >> M >> N, (M||N))
	{
		int sx,sy;
		memset(v,0,sizeof(v));
		for(int i=0; i<N; i++)
		for(int j=0; j<M; j++)
		{
			cin >> f[j][i];
			if(f[j][i]=='@')
			{
				sx=j;
				sy=i;
			}
		}

		cout << dfs(sx,sy) << endl;
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

// author:Swastik Banerjee

using namespace std;

typedef long long ll;
#define MOD 1000000007

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


  ll n, k;
  cin >> n >> k;

  cout << min(n % k, abs(k - n % k));
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

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

  long long max = A * (long long)B;
  if (max < A - B) max = A - B;
  if (max < A + B) max = A + B;

  cout << max << endl;
}

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

const int maxn = 1e5+3,M=1e9+7;
long long cnt[maxn],a[maxn],d[maxn];
int n;

int main() {
    ios::sync_with_stdio(0);
    int T=1;
    int a,b,c;
    while(T--) {
        cin>>a>>b>>c;
        cout<<min(b/a,c)<<endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

const int MAX_N = 100005;
int par[MAX_N];
int rn[MAX_N];

void init(int n){
    for(int i=0; i<n; i++){
        par[i] = i;
        rn[i] = 0;
    }
}

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

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x==y) return;

    if(rn[x] < rn[y]){
        par[x] = y;
    } else{
        par[y] = x;
        if(rn[x] == rn[y]) rn[x]++;
    }
}

bool same(int x, int y) {
    return find(x) == find(y);
}


int main(){
    int N, M;
    cin >> N >> M;

    init(N);

    int p[N];
    for(int i=0; i<N; i++){
        cin >> p[i];
        p[i]--;
    }

    int x[M], y[M];
    for(int i=0; i<M; i++){
        cin >> x[i] >> y[i];
        x[i]--;y[i]--;
        unite(x[i], y[i]);
    }

    int ans = 0;
    for(int i=0; i<N; i++){
        if(same(i, p[i])) ans++;
    }

    cout << ans << endl;

    return 0;
}


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

int main()
{
    int n,i;
    
    struct restaurant {
        char s[11]; 
        int p;
        int num;
        struct restaurant *next;
    };
    struct restaurant r[1000];
    struct restaurant *start, *tmp, *pre;
    
    
    if(scanf("%d", &n) < 1){
        exit(1);
    }
    
    for (i = 0; i < n; i++){
        if(scanf("%s %d", r[i].s, &r[i].p) < 2){
            exit(1);
        }
        r[i].num = i+1;
    }
    
    start = &r[0];
    for (i = 1; i < n; i++){
        pre = NULL;
        tmp = start;
        while(1){
            if(strcmp(tmp->s, r[i].s) > 0){ 
                r[i].next = tmp;
                if (pre != NULL){
                    pre->next = &r[i];
                }
                if(tmp == start){
                    start = &r[i];
                }
                break;
                
            } else if (strcmp(tmp->s, r[i].s) < 0){
                if(tmp->next != NULL){
                    pre = tmp;
                    tmp = tmp->next;
                }else{
                    tmp->next = &r[i];
                    break;
                }
                
            }else{
                if(tmp->p < r[i].p){
                    r[i].next = tmp;
                    if (pre != NULL){
                        pre->next = &r[i];
                    }
                    if(tmp == start){
                        start = &r[i];
                    }
                    break;
                }else{
                    if(tmp->next != NULL){
                        pre = tmp;
                        tmp = tmp->next;
                    }else{
                        tmp->next = &r[i];
                        break;
                    }
                }
            }
        }
    }
    tmp = start;
    
    for (i = 0; i < n; i++){
        printf("%d\n", tmp->num);
        tmp = tmp->next;
    }
    
    
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int main(){
    int H,W;
    while(true){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2608
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e4, mod = 1e9 + 7, maxk = 400;
int n, k, m, ans;
int inv[maxn + 10], fac[maxn + 10], ifac[maxn + 10];
int a[maxn + 10], f[maxn + 10][maxk + 10];
int h[maxn + 10][maxk + 10];
int sf[maxk + 10], sh[maxk + 10];

inline int add(int x, int y) {
	x += y; return x < mod ? x : x - mod;
}
inline int dec(int x, int y) {
	x -= y; return x < 0 ? x + mod : x;
}
inline int mul(int x, int y) {
	return 1ll * x * y % mod;
}
inline int fpow(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		y >>= 1; x = mul(x, x);
	}
	return ans;
}

void init() {
	fac[0] = ifac[0] = 1;
	for (int i = 1; i <= maxn; ++i) {
		fac[i] = mul(fac[i - 1], i);
		inv[i] = i == 1 ? 1 : dec(0, mul(mod / i, inv[mod % i]));
		ifac[i] = mul(ifac[i - 1], inv[i]);
	}
}

bool alldiff() {
	static bool vis[500];
	for (int i = 1; i <= m; ++i) {
		if (vis[a[i]]) return 0;
		vis[a[i]] = 1;
	}
	return 1;
}

void dpit() {
	f[1][1] = k; h[1][1] = m == 1 ? k : 0;
	for (int i = 2; i <= n; ++i) {
		for (int j = 1; j < k; ++j) {
			sf[j] = add(sf[j - 1], f[i - 1][j]);
			sh[j] = add(sh[j - 1], h[i - 1][j]);
		}
		for (int j = 1; j < k; ++j) {
			f[i][j] = mul(f[i - 1][j - 1], k - j + 1);
			h[i][j] = mul(h[i - 1][j - 1], k - j + 1);
			f[i][j] = add(f[i][j], dec(sf[k - 1], sf[j - 1]));
			h[i][j] = add(h[i][j], dec(sh[k - 1], sh[j - 1]));
			if (j >= m) h[i][j] = add(h[i][j], f[i][j]);
		}
	}
}

void solve1() {
	for (int i = 1; i < k; ++i)
		ans = add(ans, h[n][i]);
	ans = dec(mul(mul(fac[k], ifac[k - m]), mul(n - m + 1, fpow(k, n - m))), ans);
	ans = mul(ans, mul(fac[k - m], ifac[k]));
	printf("%d", ans);
}

bool colorful() {
	static bool vis[maxk + 10];
	for (int i = k; i <= m; ++i) {
		memset(vis, 0, sizeof vis);
		bool fd = 1;
		for (int j = i - k + 1; j <= i; ++j) {
			if (vis[a[j]]) {
				fd = 0; break;
			}
			vis[a[j]] = 1;
		}
		if (fd) return 1;
	}
	return 0;
}

int getit() {
	static bool vis[maxk + 10];
	memset(vis, 0, sizeof vis);
	for (int i = 1; i <= m; ++i) {
		if (vis[a[i]]) return i - 1;
		vis[a[i]] = 1;
	}
	assert(0);
}

int work(int x, int y) {
	int ans = 0;
	for (int i = y; i < k; ++i)
		ans = add(ans, f[x + y][i]);
	return mul(ans, mul(fac[k - y], ifac[k]));
}

void solve2() {
	int all = mul(n - m + 1, fpow(k, n - m));
	if (colorful()) {
		printf("%d", all); return;
	}
	int pre = getit();
	reverse(a + 1, a + m + 1);
	int suf = getit();
	for (int i = 1; i <= n - m + 1; ++i) {
		ans = add(ans, mul(work(i - 1, pre), work(n - m - i + 1, suf)));
	}
	printf("%d", dec(all, ans));
}

int main() {
	init();
	scanf("%d%d%d", &n, &k, &m);
	for (int i = 1; i <= m; ++i) scanf("%d", &a[i]);
	dpit();
	if (alldiff()) solve1();
	else solve2();
}


Measured memory_bytes: 86656
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <deque>
using namespace std;

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

int main(){
  deque<ll> deq;
  int n;
  cin>>n;
  for(int i=n;i>0;i--){
    ll a;
    cin>>a;
    if(i%2)deq.push_front(a);
    else deq.push_back(a);
  }
  cout<<deq.front();deq.pop_front();
  while(!deq.empty()){
    cout<<" "<<deq.front();
    deq.pop_front();
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
int n;
struct Edge{
    int to,id;
};
vector<int> ans;
vector<vector<Edge>> g;
queue<int> que;
int main(void){
    // Your code here!
    cin>>n;
    ans.resize(n-1);
    g.resize(n);
    for(int i=0;i<n-1;i++){
        int x,y;cin>>x>>y;x--;y--;
        g[x].push_back((Edge){y,i});
        g[y].push_back((Edge){x,i});
    }
    int sz = 0;
    for(int i=0;i<n;i++){
        sz=max(sz,(int)g[i].size());
    }
    cout<<sz<<endl;
    bool used[n];
    fill(used,used+n,false);
    used[0]=true;
    que.push(0);
    while(que.size()){
        int v=que.front();que.pop();
        int k=1;
        int c = -1;
        for(int i=0;i<g[v].size();i++){
            int x=g[v][i].to;
            int y=g[v][i].id;
            if(used[x])c=ans[y];
        }
        for(int i=0;i<g[v].size();i++){
            int x=g[v][i].to;
            int y=g[v][i].id;
            if(used[x])continue;
            if(k==c)k++;
            ans[y]=k;k++;
            que.push(x);
            used[x]=true;
        }
    }
    for(int i=0;i<n-1;i++){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 7040
# import queue
from collections import deque
import sys

readline = sys.stdin.readline


def main():
    n_rooms, n_passages = map(int, input().split())
    passages = (map(int, readline().strip().split()) for _ in range(n_passages))

    connections = [set() for _ in range(n_rooms+1)]  # type: list
    for a, b in passages:
        connections[a].add(b)
        connections[b].add(a)

    que = deque()
    que.append((0, 1))  # parent, current

    signs = [-1] * (n_rooms + 1)

    while que:
        parent, current = que.popleft()

        if signs[current] != -1:
            continue

        signs[current] = parent

        for room in connections[current]:
            if signs[room] == -1:
                que.append((current, room))

    print('Yes')
    for sign in signs[2:]:
        print(sign)


if __name__ == "__main__":
    main()


Measured memory_bytes: 67812
#include <bits/stdc++.h>
using namespace std;
#define db(x) cout << #x << " = " << (x) << "\n";
using ll = long long;
using ld = long double;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll n, w;
    cin >> n >> w;
    ll vl_lmt = 1'000 * 101;
    vector<long long> dp(vl_lmt, INT_MAX);
    dp[0] = 0;
    ll wi, vi, ans = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> wi >> vi;
        for (int j = ans; j >= 0; j--)
        {
            if (wi + dp[j] <= w && dp[j + vi] > dp[j] + wi)
            {
                dp[j + vi] = dp[j] + wi;
                ans = max(ans, j + vi);
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;

public class Main{

  char[][] mojiss = {
    {'\0'},
    {'.', ',', '!', '?', ' '},
    {'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'}
  };

  Main(){
    //File f = new File("input1.txt");
    Scanner sin = new Scanner(System.in);
    //FileReader in = new FileReader(f);
    sin.nextInt();
    while(sin.hasNext()) {
      int i = -1;
      int buf = 9999;
      String str = sin.next();
      for (int j = 0; j < str.length(); j++) {
        char c = str.charAt(j);
        int n = Character.getNumericValue(c);
        if(n == 0) {
          if(i != -1) System.out.printf("%c", mojiss[buf][i]);
          i = -1;
        } else {
          i++;
          if (i >= mojiss[n].length)
            i = 0;
        }
        buf = n;
      }
      System.out.println();
    }
  }

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

}

Measured memory_bytes: 41456
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n];
    int left[n];
    int right[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    // r l 
    if(n % 2 == 0){
        for(int i = 0; i < n/2; i++){
            right[i] = a[2*i];
            left[i] = a[2*i+1];
        }
        for(int i = 0; i < n/2; i++){
            cout << left[n/2-1-i] << " ";
        }
        for(int i = 0; i < n/2; i++){
            cout << right[i];
            if(i != n/2-1){
                cout << " ";
            }
        }
    }else{
        left[0] = a[0];
        for(int i = 0; i < n/2; i++){
            right[i] = a[2*i+1];
            left[i+1] = a[2*i+2];
        }
        for(int i = 0; i < n/2+1; i++){
            cout << left[n/2-i] << " ";
        }
        for(int i = 0; i < n/2; i++){
            cout << right[i];
            if(i != n/2-1){
                cout << " ";
            }
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4480
#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, m;
  string s;
  map<string, int> mp;

  cin >> n;
  rep(i, n) {
    cin >> s;
    mp[s]++;
  }

  cin >> m;
  rep(i, m) {
    cin >> s;
    mp[s]--;
  }

  int ans = 0;
  for (auto x : mp) ans = max(ans, x.second);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
N = gets.to_i
S = Array.new N
N.times do |i|
  S[i] = gets.chomp
end

smap = {}
S.each do |s|
  smap[s] ||= 0
  smap[s] += 1
end

max = smap.values.max
smap.find_all{|k,v| v == max }.map{|k| k[0] }.sort.each do |k|
  puts k
end

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

int main ()
{
    int n;
    cin>>n;
    int a[n+10];
    int ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(i%2==0 && a[i]%2) ans++;
    }
    cout << ans<<endl;
	return 0;
}


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

int main () {
    
    char x[12];
    char y[12];
    scanf("%s%s", &x,&y);
    int a,b;
    scanf("%d%d", &a,&b);
    char z[12];
    scanf("%s",&z);
    
    if(strcmp(z,x)==0) {
        printf("%d %d\n",a-1,b);    
    }
    else if(strcmp(z,y)==0) {
        printf("%d %d\n",a,b-1);
    }

    return 0;
}

Measured memory_bytes: 1708
import math
def nyu():
    N = int(input())
    return N

def kansu(N):
    min = 9999999999

    tmp_n = int(math.sqrt(N))

    for n in range(1,tmp_n+1):
        if N % n == 0:
            n2  = str(int(N/n))
            n1 = str(n)
            

            if len(n2) > len(n1):
                tmp = int(len(n2))
            else:
                tmp = int(len(n1))
        
        if min>tmp:
            min  = tmp
    print(min)






N = nyu()
kansu(N)


Measured memory_bytes: 3060
#include<stdio.h>
#define N 1000

int main(void){
  int i,num;
  int number[N]={0};
  int frequent[N]={0};
  int mstFreCnt=0;

  for(i=0;(scanf("%d",&number[i])==1);i++){}
  num=i;
  for(i=0;i<num;i++){
    frequent[number[i]-1]++;
  }
  for(i=0;i<100;i++){
    if(frequent[i]>mstFreCnt) mstFreCnt=frequent[i];
  }
  for(i=0;i<100;i++){
    if(mstFreCnt==frequent[i]){
      printf("%d\n",i+1);
    }
  }
  return 0;
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

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

int h, w;
int ch, cw, dh, dw;
string f[1000];
int dp[1000][1000];

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

int main() {
    cin >> h >> w;
    cin >> ch >> cw; ch--; cw--;
    cin >> dh >> dw; dh--; dw--;
    for (int i = 0; i < h; ++i) {
        cin >> f[i];
    }
    
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
    q.emplace(0, ch * w + cw);
    fill(dp[0], dp[h], INF);
    dp[ch][cw] = 0;
    while (!q.empty()) {
        auto top = q.top();
        q.pop();
        int v = top.first;
        int y = top.second / w;
        int x = top.second % w;
        if (dp[y][x] > v)
            continue;
        for (int i = 0; i < 4; ++i) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if (ny < 0 || ny >= h || nx < 0 || nx >= w || f[ny][nx] == '#')
                continue;
            if (dp[ny][nx] > v) {
                dp[ny][nx] = v;
                q.emplace(v, ny * w + nx);
            }
        }
        for (int i = -2; i <= 2; ++i) {
            for (int j = -2; j <= 2; ++j) {
                int ny = y + i;
                int nx = x + j;
                if (ny < 0 || ny >= h || nx < 0 || nx >= w || f[ny][nx] == '#')
                    continue;
                if (dp[ny][nx] > v + 1) {
                    dp[ny][nx] = v + 1;
                    q.emplace(v + 1, ny * w + nx);
                }   
            }
        }
    }

    cout << (dp[dh][dw] == INF ? -1 : dp[dh][dw]) << endl;

    return 0;
}

Measured memory_bytes: 9428