akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,d,abs_ab,abs_bc,abs_ac;
    cin>>a>>b>>c>>d;
    abs_ab=abs(a-b);
    abs_bc=abs(b-c);
    abs_ac=abs(a-c);
    if(abs_ab<=d&&abs_bc<=d)
    {
        cout<<"Yes";
    }
    else if(abs_ac<=d)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}

Measured memory_bytes: 3608
while 1:
      qua,bag = input().split()
      qua = int(qua)
      bag = int(bag)
      if qua == 0:
            break
      price = list(map(int,input().split()))
      price.sort(reverse=True)
      for i in range(qua):
            if (i+1)%bag == 0:
                  price[i]=-1
      for i in range(qua//bag):
            price.remove(-1)
      pay = sum(price)
      print(pay)


Measured memory_bytes: 5712
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  int a, b;
  cin >> a >> b;
  int ans, res = 0;
  res = max(a+a-1, a+b);
  ans = max(res, b+b-1);
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    import time
    input = sys.stdin.buffer.readline
    start = time.time()
    N = int(input())
    A = [tuple(map(int, input().split())) for i in range(N)]

    id = [0]*N
    Lock = [-1]*N
    ans = 0
    min_id = 0
    M = (N*(N-1)) // 2

    while(min_id < N-1):
        now = time.time()
        if now - start > 1.9:
            ans = M
            break
        ans += 1
        if ans > M:
            break
        tmp = set()
        for i in range(N):
            if id[i] >= N-1:
                continue
            else:
                if Lock[i] >= 0:
                    continue
                else:
                    a = A[i][id[i]]
                    if Lock[a-1] == i and i not in tmp:
                        Lock[a-1] = -1
                        id[a-1] += 1
                        tmp.add(a-1)
                        id[i] += 1
                    else:
                        if i not in tmp:
                            Lock[i] = A[i][id[i]]-1
        min_id = min(id)
    if ans > M:
        print(-1)
    else:
        print(ans)


main()


Measured memory_bytes: 98732
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const int MOD = 1e9+7;
//}}}

int a[55];
int primes[55555 * 5];
int main(){
	int N;
	cin >> N;
	int primeCount = 0;
	primes[primeCount++] = 2;
	int count = 0;
	rep(n, 3, 55555 * 5){
		bool f = true;
		rep(j, primeCount){
			if(n % primes[j] == 0){
				f = false;
				break;
			}
		}
		if(f){
			primes[primeCount++] = n;
			if(n % 10 == 1){
				count++;
				printf("%d", n);
				if(count == N){
					return 0;
				}
				printf(" ");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;


public class Main {

    public static void main(String args[]){
        Scanner scan =new Scanner(System.in);
        int s =scan.nextInt();
        int w=scan.nextInt();
        if(w>=s){
            System.out.println("unsafe");
        }
        else{
            System.out.println("safe");
        }
    }

}

Measured memory_bytes: 35768
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>

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

using namespace std;

const int M=1000000007;

int main(){
	int na,nt,ng,nc,m; cin>>na>>nt>>ng>>nc>>m;
	string name[50];
	vector<string> elem[50];
	string dummy; getline(cin,dummy);
	rep(i,m){
		string s; getline(cin,s);
		int n=s.length();
		for(int j=0,p=0;j<=n;j++){
			if(j==n || s[j]==' '){
				if(p<j){
					if(p==0){
						name[i]=s.substr(0,j-1);
					}
					else{
						elem[i].push_back(s.substr(p,j-p));
					}
				}
				p=j+1;
			}
		}
	}

	int len[50]={}; // ループがないので各記号の長さは一意に決まる
	for(int i=m-1;i>=0;i--){
		rep(j,elem[i].size()){
			if(elem[i][j][0]=='['){ // 終端記号
				len[i]++;
			}
			else{ // 非終端記号
				len[i]+=len[find(name,name+m,elem[i][j])-name];
			}
			len[i]=min(len[i],201);
		}
	}
	if(len[0]!=na+nt+ng+nc){ cout<<0<<endl; return 0; }

	// 構文規則を展開して終端記号だけで書く
	for(int i=m-1;i>=0;i--){
		if(len[i]>200) continue;

		vector<string> elem2;
		rep(j,elem[i].size()){
			if(elem[i][j][0]=='['){ // 終端記号
				elem2.push_back(elem[i][j]);
			}
			else{ // 非終端記号
				int id=find(name,name+m,elem[i][j])-name;
				elem2.insert(elem2.end(),elem[id].begin(),elem[id].end());
			}
		}
		elem[i]=elem2;
	}

	static int dp[2][51][51][51];
	dp[0][0][0][0]=1;
	rep(i,elem[0].size()){
		int i1=i%2,i2=1-i1;
		memset(dp[i2],0,sizeof dp[i2]);

		bool ba=(elem[0][i].find('A')!=-1);
		bool bt=(elem[0][i].find('T')!=-1);
		bool bg=(elem[0][i].find('G')!=-1);
		bool bc=(elem[0][i].find('C')!=-1);

		rep(a,na+1) rep(g,ng+1) rep(t,nt+1) {
			int c=i-a-g-t;
			if(ba && a+1<=na){ dp[i2][a+1][t][g]+=dp[i1][a][t][g]; if(dp[i2][a+1][t][g]>=M) dp[i2][a+1][t][g]-=M; }
			if(bt && t+1<=nt){ dp[i2][a][t+1][g]+=dp[i1][a][t][g]; if(dp[i2][a][t+1][g]>=M) dp[i2][a][t+1][g]-=M; }
			if(bg && g+1<=ng){ dp[i2][a][t][g+1]+=dp[i1][a][t][g]; if(dp[i2][a][t][g+1]>=M) dp[i2][a][t][g+1]-=M; }
			if(bc && c+1<=nc){ dp[i2][a][t][g]  +=dp[i1][a][t][g]; if(dp[i2][a][t][g]  >=M) dp[i2][a][t][g]  -=M; }
		}
	}

	cout<<dp[elem[0].size()%2][na][nt][ng]<<endl;

	return 0;
}

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

ll N,cnt[300000][63],A[300000],sum[63];

int main(void){
    cin >> N;
    rep(i,N){
        cin >> A[i];
        ll x = A[i];
        ll m=0;
        while(x > 0){
            if(x&1==1)cnt[i][m]++;
            x = x>>1;
            m++;
        }
        rep(j,63)sum[j] += cnt[i][j];
        //rep(j,3)cout << sum[j];
        //cout << endl;
    }
    
    ll ans=0;
    rep(i,N){
        ll p=1;
        rep(j,63){
            sum[j]-=cnt[i][j];
            if(cnt[i][j]==0)ans = (ans + (sum[j] *p)%MOD)%MOD;
            else ans = (ans + ( (N -1 - i - sum[j])*p)%MOD)%MOD;
            p = (2 * p)%MOD;
        }
    }
    ans = ans%MOD;
    cout << ans <<endl;
    
}


Measured memory_bytes: 150272
#include <cstdio>
#include <string>

using namespace std;

int main(void){
  int a1,a2,a3,b1,b2,b3,c1=0,c2=0,c3=0,c4=0;

  scanf("%d%d", &a1,&b1);
  scanf("%d%d", &a2,&b2);
  scanf("%d%d", &a3,&b3);
  
  if(a1%4==0) c4++;
  else if(a1%3==0) c3++;
  else if(a1%2==0&&a1!=4) c2++;
  else c1++;
  if(a2%4==0) c4++;
  else if(a2%3==0) c3++;
  else if(a2%2==0&&a2!=4) c2++;
  else c1++;
  if(a3%4==0) c4++;
  else if(a3%3==0) c3++;
  else if(a3%2==0&&a3!=4) c2++;
  else c1++;
  if(b1%4==0) c4++;
  else if(b1%3==0) c3++;
  else if(b1%2==0&&b1!=4) c2++;
  else c1++;
  if(b2%4==0) c4++;
  else if(b2%3==0) c3++;
  else if(b2%2==0&&b2!=4) c2++;
  else c1++;
  if(b3%4==0) c4++;
  else if(b3%3==0) c3++;
  else if(b3%2==0&&b3!=4) c2++;
  else c1++;
  
  if(c1>=3||c2>=3||c3>=3||c4>=3){
    printf("NO\n");
    return 0;
  }else if(c1==0||c2==0||c3==0||c4==0){
    printf("NO\n");
    return 0;
  }else printf("YES\n");
  return 0;
}

Measured memory_bytes: 128
using System;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int a = sc.NextInt() * 500;
        Console.WriteLine(a >= sc.NextInt() ? "Yes" : "No");
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 11092
import java.util.*;

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

        int k = sc.nextInt();
        for(int i = 0; i < k; i++) {
            if(i % 2 == 0) {
                if(a % 2 == 1) a--;
                int tmp1 = a / 2;

                a -= tmp1;
                b += tmp1;

            } else {
                if(b % 2 == 1) b--;
                int tmp2 = b / 2;
                b -= tmp2;

            a += tmp2;

            }
            

        }
        System.out.println(a + " " + b);
    } 
}

Measured memory_bytes: 21844
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define debug cout<<"****************"<<endl
using namespace std;
typedef long long ll;
inline void ju() {
	freopen("***.in","r",stdin);
	freopen("***.out","w",stdout);
}
inline ll rd() {
	ll x=0,f=1; char c=getchar();
	while((c<'0'||c>'9')&&(c!='-')) c=getchar();
	if(c=='-') f=-1,c=getchar();
	while(c>='0'&&c<='9') {
		x=(x<<3)+(x<<1)+c-'0';
		c=getchar();
	}
	return x*f;
}
int main() {
	int n=rd();
	printf("%d\n",n/2*((n+1)/2)); 
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int a[3];
  scanf("%d%d%d",&a[0],&a[1],&a[2]);
  int i = 0;
  if ((a[0] == 7 && a[1] == 5 && a[2] == 5) || (a[0] == 5 && a[1] == 7 && a[2] == 5) || (a[0] == 5 && a[1] == 5 && a[2] == 7))
  {
    printf("YES");
  }
  else
    printf("NO");
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

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

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 (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  int c=0,min=1e9;
  ll sum=0;
  rep(i,n)
  {
    if(a[i]>0);
    else c--;
    chmin(min,abs(a[i]));
    sum+=abs(a[i]);
  }
  if(abs(c)%2==1)cout<<sum-2*min<<endl;
  else cout<<sum<<endl;

  return 0;

}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n); i >= 0; i--)
#define revrepr(i, a, b) for (int i = (a); i >= b; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    int max_count = 0;
    rep(i, n) {
        string str;
        cin >> str;
        mp[str]++;
        chmax(max_count, mp[str]);
    }

    vector<string> strs;
    for (auto p: mp) if (p.second == max_count) strs.push_back(p.first);
    sort(strs.begin(), strs.end());
    for (auto str: strs) cout << str << endl;
}

Measured memory_bytes: 26868
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
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;}
 
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

int P,Q,R;

signed main(){
	IOS();
	cin>>P>>Q>>R;
	cout<<P+Q+R-max({P,Q,R})<<endl;
}

Measured memory_bytes: 764
def gcd(x,y):
	if y==0: return x
	return gcd(y, x%y)

N=int(input())
A=list(map(int, input().split()))
l=[0];r=[0]

for i in range(N):
	l.append(gcd(l[i],A[i]))
	r.append(gcd(r[i],A[N-1-i]))
r = r[::-1]
ans=0
for i in range(N):
	temp=gcd(l[i],r[i+1])
	ans=max(ans,temp)
print(ans)

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

typedef pair<int, int> result;
#define value first
#define p second

result equation(const string &s, int p = 0);
result factor(const string &s, int p = 0);
result term(const string &s, int p = 0);

result equation(const string &s, int p) {
	result r = factor(s, p);
	while( s[r.p] == '+' || s[r.p] == '-' ){
		result r_ = factor(s, r.p+1);
		if( s[r.p] == '+' )
			r.value += r_.value;
		else
			r.value -= r_.value;
		r.p = r_.p;
	}
	return r;
}

result factor(const string &s, int p) {
	result r = term(s, p);
	while( s[r.p] == '*' || s[r.p] == '/' ) {
		result r_ = term(s, r.p+1);
		if( s[r.p] == '*' )
			r.value *= r_.value;
		else
			r.value /= r_.value;
		r.p = r_.p;
	}
	return r;
}

result term(const string &s, int p) {
	if( s[p] == '(' ) {
		result r = equation(s, p+1);
		r.p += 1; // skip ')'
		return r;
	}else{
		int value = 0;
		while ( isdigit(s[p]) )
			value = value * 10 + (s[p++] - '0');
		return result(value, p);
	}
}

int main() {
	string s;
	int n;
	cin >> n;
	for(int i=0 ; i < n ; i++ ){
		cin >> s;
		result r = equation( s );
		cout << r.value << endl;
	}
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	static int n;
	static int[] ps;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (true) {
			n = sc.nextInt();
			if (n == 0)
				break;
			ps = new int[n];
			for (int i = 0; i < n; i++) {
				ps[i] = sc.nextInt();
			}
			System.out.println(solve(0, 0, 0));
		}
	}

	public static int solve(int k, int a, int b) {
		if (k == n) {
			return Math.abs(a - b);
		}
		return Math.min(solve(k + 1, a, b + ps[k]), solve(k + 1, a + ps[k], b));
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // メインプログラムここから
    ll a, b, c, ans;
    
    cin >> a >> b >> c;
    
    ll x = max(a, b);
    ll y = max(x, c);
    
    ll z = min(a, b);
    ll w = min(x, c);
    
    ll d = y/2 + 1;
    
    if(y%2==0){
        ans = 0;
    }else{
        ans = z*w;
    }
    
    cout << ans << endl;
    // ここまで
}


Measured memory_bytes: 256
//In The Name of Allah
#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
#define mp make_pair

typedef pair < int , int > pii;

const int N = 1e5 + 10;
const int inf = 1e9 + 10;

int d[N];
priority_queue < pii , vector < pii > , greater < pii > > pq;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    fill(d, d + N, inf);
    for (int i = 1; i <= 9; i ++){
        d[i % n] = min(d[i % n], i);
        pq.push(mp(i, i % n));
    }
    while (!pq.empty()){
        int x = pq.top().Y, c = pq.top().X;
        pq.pop();
        if (c != d[x])
            continue;
        for (int i = 0; i <= 9; i ++){
            int y = (10 * x + i) % n;
            if (c + i < d[y]){
                d[y] = c + i;
                pq.push(mp(d[y], y));
            }
        }
    }
    cout << d[0];
    return 0;
}


Measured memory_bytes: 5636
T=gets.strip
S=T.gsub(/BC/,"X")
ans=0
i=0
x=0
S.chars do |s|
  if s=="X"
    ans+=i-x
    x+=1
  elsif s=="B"||s=="C"
    i=0
    x=0
    next
  end
  i+=1
end
puts ans

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

int h[3];
void trans(int a){
	h[0] = a/3600;
	h[1] = (a%3600)/60;
	h[2] = a%60;
}

void disp(){
	for(int i = 0;i < 3;i++){
		if(i)cout << ":";
		if(h[i] < 10)cout << "0";
		cout << h[i];
	}
	cout << endl;
}

int main(){
	while(cin >> h[0] >> h[1] >> h[2]){
		if(h[0] == -1)break;
		int a = 7200 - (h[0]*3600 + h[1]*60 + h[2]);
		trans(a);
		disp();
		trans(3*a);
		disp();
	}
	
	return 0;
}

Measured memory_bytes: 3092
from collections import deque
import sys
N, M = map(int, input().split())

graph = [deque([]) for _ in range(N + 1)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

d = [0]*(N+1)

def bfs(v):
    stack = deque([v])
    while stack:
        v = stack[0]
        if graph[v]:
            w = graph[v].popleft()
            if d[w] == 0:
                d[w] = v
                stack.append(w) 
        else:
            stack.popleft()        

bfs(1)

for i in range(2, N+1):
    if d[i] == 0:
        print("No")
        sys.exit()

print("Yes")
for i in range(2, N+1):
    print(d[i])

Measured memory_bytes: 86228
# coding : utf-8
class Dice:
	def __init__(self, label):
		self.d = label

	def north(self):
		d = self.d
		self.d = [d[1],d[5],d[2],d[3],d[0],d[4]]
	
	def east(self):
		d = self.d
		self.d = [d[3],d[1],d[0],d[5],d[4],d[2]]
	
	def west(self):
		d = self.d
		self.d = [d[2],d[1],d[5],d[0],d[4],d[3]]
	
	def south(self):
		d = self.d
		self.d = [d[4],d[0],d[2],d[3],d[5],d[1]]

	def output(self):
		d = self.d
		print(self.d[0])

label = list(map(int, input().split()))
op_list = list(input())
d0 = Dice(label)
for op in op_list:
	if op =='N':
		d0.north()
	if op =='E':
		d0.east()
	if op =='W':
		d0.west()
	if op =='S':
		d0.south()
d0.output()

Measured memory_bytes: 7768
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define PUTS(x) cout << (x) << endl;

vector<pair<Int, Int>> primeFactors(Int n) {
    vector<pair<Int, Int>> result;
    Int factor = 0;
    Int factorCount = 0;
    Int q = n;
    if (n >= 2) {
        for (Int i = 2; i * i <= n;) {
            if (q % i == 0) {
                if (i != factor) {
                    factor = i;
                    factorCount = 1;
                } else {
                    factorCount++;
                }
                q /= i;
            } else {
                if (factor > 0) {
                    result.push_back(make_pair(factor, factorCount));
                    factor = 0;
                }
                i++;
            }
        }
    }
    if (q > 1) {
        result.push_back(make_pair(q, 1));
    }

    return result;
}

int main() {
    Int n;
    cin >> n;
    auto v = primeFactors(n);
    auto ans = 0LL;
    for (auto const &[k, e] : v) {
        auto i = 1;
        auto x = e;
        while (x > 0) {
            x -= i;
            if (x < 0) break;
            ans++;
            i++;
        }
    }
    PUTS(ans)
}


Measured memory_bytes: 3624
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    k = I()
    l = len(s)
    t = set()
    for i in range(1,k+1):
        for j in range(l-i+1):
            t.add(s[j:j+i])

    return sorted(list(t))[k-1]



print(main())



Measured memory_bytes: 7116
#include <stdio.h>

int main(void)
{
	int a, b, c, i, x;
	scanf("%d %d %d", &a, &b, &c);
	i=0;
	x=0;
	for(i=a; i<=b; i++)
	{
		if(c%i==0)
			{
				x++;
			}
	}
	printf("%d\n", x);
	
	return 0;
}


Measured memory_bytes: 2728
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

const long long INF = (long long) 1e11+1;
const long long mod = (long long) 100000000 ;
const long long hell = (long long) 1000000007;


ll power(ll x,ll y)
{
  ll res=1;
  while(y>0){
    if(y%2) res=(x%mod*res%mod)%mod;
    x=(x%mod*x%mod)%mod;    
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,mod-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;
   
   while(test--)
   solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/
// gcd of strings
/*
string getgcd(string s1,string s2){
    
    while(true){
        if(s1.length()<s2.length()){
            swap(s1,s2);
            continue;
        }
        if(s2.empty())
        return s1;
        
        if(s1.substr(0,s2.length())!=s2)
        return "";
        
        s1=s1.substr(s2.length());
    }
}
*/
/*
// for user defined DS hashmap and set
 
struct hash_pair{
      size_t operator()(const pair<int,pair<int,int>>& p) const{
          auto hash1=hash<int>()(p.F) ;
          auto hash2=hash<int>()(p.S.F) ;
          auto hash3=hash<int>()(p.S.S) ;
          return (hash1^hash2)^hash3;
      }  
};
struct pair_hash
{
	template <class T1, class T2>
	std::size_t operator () (std::pair<T1, T2> const &pair) const
	{
		std::size_t h1 = std::hash<T1>()(pair.first);
		std::size_t h2 = std::hash<T2>()(pair.second);

		return h1 ^ h2;
	}
};
*/

void solve(){
    ll n;
    cin>>n;
    double l1=n/3.0;
    double l2=n/3.0;
    double l3=n-(l1+l2);
    double ans=l1*l2*l3;
    cout<<fixed<<setprecision(10)<<ans;
}    


///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll a,ll b)
{
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main( )
{
    int x;
    cin>>x;
    vector<int>v(x);
    for(int i=0; i<x; i++)
        cin>>v[i];
    long long sum=0;

    for(int i=1; i<x; i++)
    {
        if (v[i-1]>v[i])
        {
            sum+=(v[i-1]-v[i]);
            v[i]=v[i-1];
        }
    }
   
    cout<<sum<<endl;

}


Measured memory_bytes: 4044
import scala.math._

// longでrangeの作り方

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val a, b, c, d = sc.nextInt
//  val list = List.fill(3)(sc.next)

  val s1 = a * b
  val s2 = c * d

  val ans = if (s1 <= s2) s2 else s1

  println(ans)


  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 25664
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,x,y,e,f,n;
    cin>>n>>a>>b>>c>>d;
    x=0;
    y=0;
    if(n%a==0){
        x=n/a;
    }
    else if(n%a>0){
        x=n/a+1;
    }
    if(n%c==0){
        y=n/c;
    }
    else if(n%c>0){
        y=n/c+1;
    }
    e=x*b;
    f=y*d;
    if(e<f){
        cout<<e<<endl;
    }
    else if(e==f){
        cout<<e<<endl;
    }
    else{
        cout<<f<<endl;
    }
}


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

int read()
{
	int ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10+ch-'0';
	if(flag)ans=-ans;
	return ans;
}

long long rell()
{
	long long ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10ll+(long long)(ch-'0');
	if(flag)ans=-ans;
	return ans;
}

void writ(int n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}

void wrll(long long n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10ll)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}
const int N=1<<18;
char a[N];
int b[N];

int main()
{
	scanf("%s",a);
	long long ans=1;
	for(int i=0;a[i];i++)
	{
		ans+=(long long)(i-b[(int)a[i]]);
		b[(int)a[i]]++;
	}
	wrll(ans);
	puts("");
	return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
    
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i,n) {
        int a;
        cin >> a;
        mp[a-1]++;
        mp[a]++;
        mp[a+1]++;
    }
    int ans = 0;
    for(P p : mp) {
        chmax(ans, p.se);
    }
    cout << ans << endl;
}

Measured memory_bytes: 7884
#include <cstdint>
#include <cstdlib>
#include <iostream>
#include <string>

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

  intmax_t res = 0;
  for (int i = 0; i < (1 << (S.length()-1)); ++i) {
    intmax_t cur = S[0]-'0';
    for (size_t j = 1; j < S.length(); ++j) {
      if (i >> (j-1) & 1) {
        res += cur;
        cur = 0;
      }
      cur = cur*10 + S[j]-'0';
    }
    res += cur;
  }
  std::cout << res << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int A, B, C;
    cin >> A >> B >> C;
    cout << min(C, B / A) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

A, B, Q = MAP()
s = [INT() for _ in range(A)]
t = [INT() for _ in range(B)]

for _ in range(Q):
	x = INT()
	idx_s = bisect(s, x)
	idx_t = bisect(t, x)

	S = []
	T = []
	if 0 < idx_s:
		S.append(s[idx_s-1])
	if idx_s < A:
		S.append(s[idx_s])

	if 0 < idx_t:
		T.append(t[idx_t-1])
	if idx_t < B:
		T.append(t[idx_t])

	ans = INF
	for shrine, temple in product(S, T):
		if min(shrine, temple) <= x <= max(shrine, temple):
			tmp = abs(shrine-temple) + min(abs(x-shrine), abs(x-temple))
		else:
			tmp = max(abs(x-shrine), abs(x-temple))
		ans = min(ans, tmp)

	print(ans)



Measured memory_bytes: 18440
/**
 *    author:  tourist
 *    created: 04.05.2019 15:40:34       
**/
#include <bits/stdc++.h>

using namespace std;

template <typename T>
class graph {
 public:
  struct edge {
    int from;
    int to;
    T cost;
  };

  vector<edge> edges;
  vector<vector<int>> g;
  int n;

  graph(int _n) : n(_n) {
    g.resize(n);
  }

  virtual int add(int from, int to, T cost) = 0;
};

template <typename T>
class forest : public graph<T> {
 public:
  using graph<T>::edges;
  using graph<T>::g;
  using graph<T>::n;

  forest(int _n) : graph<T>(_n) {
  }

  int add(int from, int to, T cost = 1) {
    assert(0 <= from && from < n && 0 <= to && to < n);
    int id = (int) edges.size();
    assert(id < n - 1);
    g[from].push_back(id);
    g[to].push_back(id);
    edges.push_back({from, to, cost});
    return id;
  }
};

template <typename T>
class dfs_forest : public forest<T> {
 public:
  using forest<T>::edges;
  using forest<T>::g;
  using forest<T>::n;

  vector<int> pv;
  vector<int> pe;
  vector<int> order;
  vector<int> pos;
  vector<int> end;
  vector<int> sz;
  vector<int> root;
  vector<int> depth;
  vector<T> dist;

  dfs_forest(int _n) : forest<T>(_n) {
  }

  void init() {
    pv = vector<int>(n, -1);
    pe = vector<int>(n, -1);
    order.clear();
    pos = vector<int>(n, -1);
    end = vector<int>(n, -1);
    sz = vector<int>(n, 0);
    root = vector<int>(n, -1);
    depth = vector<int>(n, -1);
    dist = vector<T>(n);
  }

  void clear() {
    pv.clear();
    pe.clear();
    order.clear();
    pos.clear();
    end.clear();
    sz.clear();
    root.clear();
    depth.clear();
    dist.clear();
  }

 private:
  void do_dfs(int v) {
    pos[v] = (int) order.size();
    order.push_back(v);
    sz[v] = 1;
    for (int id : g[v]) {
      if (id == pe[v]) {
        continue;
      }
      auto &e = edges[id];
      int to = e.from ^ e.to ^ v;
      depth[to] = depth[v] + 1;
      dist[to] = dist[v] + e.cost;
      pv[to] = v;
      pe[to] = id;
      root[to] = (root[v] != -1 ? root[v] : to);
      do_dfs(to);
      sz[v] += sz[to];
    }
    end[v] = (int) order.size() - 1;
  }

  void do_dfs_from(int v) {
    depth[v] = 0;
    dist[v] = T{};
    root[v] = v;
    pv[v] = pe[v] = -1;
    do_dfs(v);
  }

 public:
  void dfs(int v, bool clear_order = true) {
    if (pv.empty()) {
      init();
    } else {
      if (clear_order) {
        order.clear();
      }
    }
    do_dfs_from(v);
  }

  void dfs_all() {
    init();
    for (int v = 0; v < n; v++) {
      if (depth[v] == -1) {
        do_dfs_from(v);
      }
    }
    assert((int) order.size() == n);
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  dfs_forest<int> g(n);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    g.add(x, y);
  }
  g.dfs(0);
  int root = 0;
  for (int i = 1; i < n; i++) {
    if (g.depth[i] > g.depth[root]) {
      root = i;
    }
  }
  g.dfs(root);
  int diam = 0;
  for (int i = 0; i < n; i++) {
    diam = max(diam, g.depth[i]);
  }
  cout << (diam % 3 == 1 ? "Second" : "First") << '\n';
  return 0;
}


Measured memory_bytes: 29360
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int N=100 ;
ll a[N],b[N],c[N],d[N];
ll n,h;
int main()
{
    scanf("%lld%lld",&n,&h);
    for(int i=0;i<n;i++){
        scanf("%lld%lld",&a[i],&b[i]);
        c[i]=a[i];
        d[i]=b[i];
    }
    sort(c,c+n);
    sort(d,d+n);
    ll area=3999999999000000001;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=0;k<n;k++){
                for(int l=k+1;l<n;l++){
                    int cnt=0;
                    for(int q=0;q<n;q++){
                        if(a[q]<=c[j]&&a[q]>=c[i]&&b[q]>=d[k]&&b[q]<=d[l])
                            cnt++;
                    }
                    if(cnt>=h)
                        area=min(area,(c[j]-c[i])*(d[l]-d[k]));
                }
            }
        }
    }
    printf("%lld\n",area);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,i;
    cin>>n;
    float total=0,a[n];
    for(i=0;i<n;i++)
    {
        float k;
        cin>>k;
        a[i]=k;
        total+=k;
    }
    float ave;
    ave=total/n;
    float min=200,h;int flag;
    for(i=0;i<n;i++)
    {
        h=a[i]-ave;
        if(h<0)
        h=h+h*(-2);
        if(min>h){
        flag=i;min=h;
        }
    }
    cout<<flag<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program {
    static void Main( string[] args )
    {
        List<string> spades = CreateSuit( "S " );
        List<string> hearts = CreateSuit( "H " );
        List<string> clubs = CreateSuit( "C " );
        List<string> diamonds = CreateSuit( "D " );

        int n = int.Parse( Console.ReadLine() );

        for ( int i = 0; i < n; ++i ) {
            string card = Console.ReadLine();

            switch ( card[ 0 ] ) {
                case 'S': { spades.Remove( card ); break; }
                case 'H': { hearts.Remove( card ); break; }
                case 'C': { clubs.Remove( card ); break; }
                case 'D': { diamonds.Remove( card ); break; }

                default: { break; }
            }
        }

        Print( ref spades );
        Print( ref hearts );
        Print( ref clubs );
        Print( ref diamonds );
    }

    public static List<string> CreateSuit( string prefix )
    {
        List<string> suit = new List<string>( 13 );

        for ( int i = 1; i < 14; ++i ) {
            suit.Add( prefix + i );
        }

        return suit;
    }

    public static void Print( ref List<string> suit )
    {
        for ( int i = 0; i < suit.Count; ++i ) {
            Console.WriteLine( suit[ i ] );
        }
    }
}

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

int main(){
    stack<int> s;
    string op = "+-*";
    string word;
   // long long number;

    while(cin>>word){//読み込みがある場合（ただし数値も文字列型として処理される）
        if(op.find(word)!=string::npos){
            int r=s.top(); s.pop();
            int l=s.top(); s.pop();
            if(word=="+") s.push(l+r);
            if(word=="-") s.push(l-r);
            if(word=="*") s.push(l*r);
        }
        else{
            s.push(stoi(word));
        }
    }
    int ans=s.top();
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <list>
#include <stack>
#include <queue>
#include <cstdlib>
#include <tuple>
#define INF 1e9
#define EPS 1e-9
using namespace std;

typedef list<int> L;
typedef pair <int,int> P;
typedef vector<int> V;
typedef queue<int> Q;
typedef stack<int> S;
typedef map<string,int> M;

int main()
{
    int year;
    vector<bool> v(3000001, true);
    v[0] = v[1] = false;
    for (int i = 0; i < v.size(); i++) {
        if (v[i] == true) {
            if ((i - 6) % 7 == 0 || (i - 1) % 7 == 0) {
                for (int j = 2; j * i <= v.size(); j++) {
                    v[i * j] = false;
                }
            } else {
                v[i] = false;
            }
        }
    }
    while (cin >> year , year > 1) {
        L res;
        for (int i = 0; i <= year; i++) {
            if (v[i])
                if (year % i == 0)
                    res.push_back(i);
        }
        cout << year << ":";
        for (auto ite = res.begin(); ite != res.end(); ite++) {
            cout << " " << *ite;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1528
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

const int INF = 1e9;
const long long LINF = 1e18;

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

    set<pair<int, int>> edges;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        edges.insert(pair<int, int>(a, b));
    }

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

    long long cnt = 0;
    do {
        bool pass = true;
        int s = 1, e;
        for (int i = 0; i < p.size(); i++) {
            e = p[i];
            // cout << "s: " << s << ", e: " << e << endl;
            int minp = min(s, e);
            int maxp = max(s, e);
            if (edges.end() == edges.find(pair<int, int>(minp, maxp))) {
                pass = false;
                break;
            }
            s = e;
        }

        if (pass) {
            cnt++;
        }
        // cout << endl;
    } while (next_permutation(p.begin(), p.end()));

    cout << cnt << endl;

    return 0;
}


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

int main()
{
	int N, L;
	cin >> N >> L;
	vector<string> S(N);
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	sort(S.begin(), S.end());
	string res;
	for (int i = 0; i < N;i++) {
		res += S[i];
	}
	cout << res << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int N;
vector<int> to[500 * 999];
int h[500 * 999];

int get_id(int a, int b) {
    if (a > b) swap(a, b);
    return (N - 1) * (a - 1) - max(0, (a - 2) * (a - 1) / 2) + b - a - 1;
}

int main() {
    cin >> N;
    REP(i, N) {
        int A, Ab, Ai, Abi;
        cin >> Ab;
        Abi = get_id(i + 1, Ab);
        REP(j, N - 2) {
            cin >> A;
            Ai = get_id(i + 1, A);
            to[Abi].push_back(Ai);
            h[Ai]++;

            Ab = A;
            Abi = Ai;
        }
    }

    int V = N * (N - 1) / 2;
    queue<int> que;
    REP(i, V) if (h[i] == 0) que.push(i);

    vector<int> sorted;
    while (!que.empty()) {
        int i = que.front(); que.pop();
        sorted.push_back(i);
        for (int t : to[i]) {
            h[t]--;
            if (h[t] == 0) que.push(t);
        }
    }

    if (sorted.size() < V){
        cout << -1 << endl;
        return 0;
    }

    int dp[500 * 999];
    REP(i, V) dp[i] = 1;
    REP(i, V) {
        int s = sorted[i];
        for (int t : to[s]) dp[t] = max(dp[t], dp[s] + 1);
    }

    int ans = 0;
    REP(i, V) ans = max(ans, dp[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 33524
import java.util.Scanner;
class Main{
    public static void main(String[] args){
      Scanner stdIn = new Scanner(System.in);
      int a=stdIn.nextInt();
      int b=stdIn.nextInt();
      int c=stdIn.nextInt();
      int t=0;
      t=a;
      a=b;
      b=t;
      int tem;
      tem=a;
      a=c;
      c=tem;
      System.out.println(a+" "+b+" "+c);
    }
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using u128 = __uint128_t;

#define int long long
#define index_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIndex find_by_order
#define indexOf order_of_key
#define MOD 1000000007
#define MAX 200005

int dp[MAX];

void solve() {
    int h , w;
    cin>>h>>w;
    char x[101][101];
    for(int i = 0 ; i< h ; i++){
        cin>>x[i];
    }
    // by row....
    vector<int> row;
    for(int i = 0 ; i< h ; i++){
        bool there = false;
        for(int j = 0 ; j < w ; j++){
            if(x[i][j] == '#'){
                there = true;
                break;
            }
        }
        if(there){
            row.push_back(i);
        }
    }
    vector<int> column;
    for(int j = 0 ; j < w ; j++){
        bool there = false;
        for(int i = 0 ; i < h ; i++){
            if(x[i][j] == '#'){
                there = true;
                break;
            }
        }
        if(there){
            column.push_back(j);
        }
    }
    for(auto i : row){
        for(auto j : column){
            cout<<x[i][j];
        }
        cout<<endl;
    }
    cout<<endl;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 2000

int solve(int,int);
  
int A[N],M[N];
int n;

int main(){
  
  int i,q;
  
  scanf("%d",&n);
  for( i=0 ; i<n ; i++ ){
    scanf("%d",&A[i]);
  }
  
  scanf("%d",&q);
  for( i=0 ; i<q ; i++ ){
    scanf("%d",&M[i]);
  }

  for( i=0 ; i<q ; i++ ){
    if((solve(0,M[i])) == 1) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

int solve(int i,int m){

  if(m == A[i])
    return 1;

  if(i+1 >= n)
    return 0;

  if(solve(i + 1, m) || solve(i + 1, m - A[i]) == 1)
  return 1;

  return 0;

}

Measured memory_bytes: 584
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int n, c;
    cin >> n >> c;

    const int T = (int)1e5 + 1;

    vector<int> a[30];
    for (int k = 0; k < c; k++) {
        a[k] = vector<int>(T);
    }
    for (int i = 0; i < n; i++) {
        int s, t, c;
        cin >> s >> t >> c;
        c--;

        for (int j = s; j < t; j++) {
            a[c][j] = 1;
        }
    }
    for (int k = 0; k < c; k++) {
        for (int j = 1; j < T; j++) {
            if (a[k][j] == 1 && a[k][j - 1] == 0) a[k][j - 1] = 1;
        }
    }
    int r = 0;
    for (int j = 0; j < T; j++) {
        int s = 0;
        for (int k = 0; k < c; k++) {
            s += a[k][j];
        }
        r = max(r, s);
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 12160
#include <iostream>
#define rep(i,n) for(int i=0;i<(n);++i)

using namespace std;
int main(){
    int a[5];
    int ans;
    rep(i,5){
        cin >> a[i];
    }
    rep(i,5){
        if(a[i] == 0){ans=i;break;}
    }
    ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
int n;
char s[60][105];
int t[60];
char x[105];
int flag=0;
int sum=0;
scanf("%d",&n);
for(int count=0;count<n;count++){
    scanf("%s",s[count]);
    scanf("%d",&t[count]);
}
scanf("%s",x);

for(int count=0;count<n;count++){
    if(strcmp(s[count],x)==0){flag++;}
    else if(flag==1){sum=sum+t[count];}
}
printf("%d",sum);
}

Measured memory_bytes: 128