akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    int a[n];
    REP(i,n){
        int b; cin >> b; --b;
        a[b] = i;
    }
    ll res  = 0;
    set<int> st;
    st.insert(-1);
    st.insert(n);
    REP(i,n){
        int ri = *st.upper_bound(a[i]);
        auto itr = st.lower_bound(a[i]);
        itr--;
        int le = *itr;
        res += (i + 1) * (ri -a[i]) * (a[i] - le);
        st.insert(a[i]);
    }
    cout << res << '\n';
}

Measured memory_bytes: 13696
#include <stdio.h>
 
int main () {
	char num[4];
	scanf("%s", &num);
	
	if (num[0] == '7' || num[1] == '7' || num[2] == '7') {
		printf("Yes");
	}
	else {
		printf("No");
	}
	
	
	return 0;
}

Measured memory_bytes: 1708
#include<stdio.h>

int main(void)
{
  int flag[11],cnt=0,score=0;
  char S[11];

  scanf("%s",S);
  for (int i = 0; i < 11; i++)
    flag[i] = 0;

  for (int i = 0; i < 11; i++) {
    if(S[i]=='A')
      flag[i]=1;
    else if(S[i]=='T')
      flag[i]=1;
    else if(S[i]=='C')
      flag[i]=1;
    else if(S[i]=='G')
      flag[i]=1;
  }
  for (int i = 0; i < 11; i++){
    if(flag[i]==1)
      cnt++;
    else
    {
      if(cnt>score)
      score=cnt;
      cnt=0;
    }
  }

  printf("%d\n",score);

  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int>A(n);
    vector<ll>a;
    rep(i,n){
        cin >> A[i];
    }
    rep(i,n){
        ll sum = 0;
        for(int j = i; j< n; j++){
            sum += A[j];
            a.push_back(sum);
        }
    }
    assert((int)(a.size()) == n*(n+1)/2);
    //for(auto x:a)cout << x << endl;
    ll ans = 0;
    for(int i = 60; i>=0; i--){
        int c = 0;
        vector<ll>b;
        vector<ll>d;
        rep(j,a.size()){
            if((a[j]&(1LL<<i))){
                c++;
                b.push_back(a[j]);
            }else{
                d.push_back(a[j]);
            }
        }
        if(c>=k){
            ans += (1LL<<i);
            a = b;
        }else{
            //a = d;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 13164
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
using namespace std;

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

int main(){
   ll N;
   cin>>N;
   ll MOD = 1000000007;
   ll ans = 0;
   vector<ll> A(N);
   for (ll i=0;i<N;i++) cin >> A[i];
    
   for(ll i = 0;i<60;i++){
       ll ones = 0;
       for(ll j=0;j<N;j++){
           if (A[j]&1) ones += 1;
           A[j] = A[j]>>1;
       }
       ll zeros = (N - ones)%MOD;
       unsigned long long tmp = ll(pow(2,i))%MOD*ones%MOD*zeros%MOD;
       ans += tmp;
       ans %= MOD;
   }
   cout << ans << endl;
   
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>

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

using namespace std;

int main()
{
	int N, C = 1, map[10][10];
	for(;cin>>N,N;)
	{
		cout << "Case " << C++ << ":" << endl;

		int index = 1;
		rep(i,2*N-1)
		{
			int x = min(i, N - 1), y = max(0, i - N + 1), n = x - y + 1;
			rep(j,n)
			{
				map[y][x] = index + (i % 2 != 0 ? j : n - j  - 1);
				x--;
				y++;
			}
			index += n;
		}

		rep(y,N)
		{
			rep(x,N)
			{
				cout.width(3);
				cout << map[y][x];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	ans := 0
	for i := a; i <= b; i++ {
		if c%i == 0 {
			ans++
		}
	}
	fmt.Println(ans)
}



Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define int long long int
#define vi vector<int>
#define vvi vector < vi >
#define pii pair<int,int>
#define mod 1000000007
#define inf 1000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define tr(k,st,en) for(int k = st; k <= en ; ++k)
#define trb(k,en,st) for(int k = en; k >= st ; --k)
using namespace std;

int32_t main()
{
    std::ios::sync_with_stdio(false);
    int n,w;
    cin>>n>>w;
    int val_max =n*1000;
    vi dp(n*1000 + 1, inf); // 0... valmax; // dp[val] -> min wt : val of sack exactly val;
    dp[0] = 0;
    tr(i,1,n){
        int wt,val;
        cin>>wt>>val;
        trb(val_already,val_max, val){
            dp[val_already] = min( dp[val_already], dp[val_already - val]  + wt);
        }
    }
    int ans = 0;
    tr(i,0,val_max){
        if (dp[i] <= w) {
            ans = i;
        }
    }
    std::cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4052
s = input()
ans = 'keyence'
cnt = 0

for i in range(7):
    if s[i] != ans[i]:
        break
    cnt += 1

for i in range(7):
    if s[len(s) - i - 1] != ans[6 - i]:
        break
    cnt += 1

if cnt >= 7:
    ans = 'YES'
else:
    ans = 'NO'
print(ans)


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

int main() {
  int N;
  cin >> N;
  vector<string> result(N);
  
  for (int i=0; i<N; i++){
    cin >> result.at(i);
  }
  
  int countAC = 0;
  int countWA = 0;
  int countTLE = 0;
  int countRE = 0;
  
  for (int i=0; i<N; i++){
    if (result.at(i)=="AC")
      countAC++;
    if (result.at(i)=="WA")
      countWA++;
    if (result.at(i)=="TLE")
      countTLE++;
    if (result.at(i)=="RE")
      countRE++;
  }
  cout << "AC x " << countAC << endl;
  cout << "WA x " << countWA << endl;
  cout << "TLE x " << countTLE << endl;
  cout << "RE x " << countRE << endl;
    
}


Measured memory_bytes: 6424
#include <cstdio>

int main()
{
	int a, b;

	while (1){
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0) break;

		for(int i = 0; i < a; i++){

			for(int j = 0; j < b; j++){
				if(i == 0 || i == a - 1) printf("#");
				else if(j == 0 || j == b - 1) printf("#");
				else printf(".");
 			}

 			printf("\n");
		}

		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1000
import sys
input=sys.stdin.buffer.readline
n,a,b=map(int,input().split())
if n==1:
    if a==b:print(1)
    if a!=b:print(0)
if n>1:
    if a>b:print(0)
    if a<=b:print((n-2)*(b-a)+1)

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

int main(){
    int N, H[21], tmp, cnt;
    cin >> N;
    tmp = 0;
    cnt = 0;
    for(int i = 0; i < N; i++){
        cin >> H[i];
        if(tmp <= H[i]){
            cnt++;
            tmp = H[i];
        }
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

int main(){
    int N,now=0,out=0;
    cin >> N;
    string S,ans;
    cin >> S;
    stack<char> st;
    ans = S;
    for(int i=0;i<N;i++){
        if(S[i]=='('){
            st.push('(');
        }else{
            if(st.empty()){
                ans.insert(now,"(");
            }else{
                st.pop();
            }
        }
    }

    for(int i=0;i<st.size();i++){
        ans += ')';
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<16,INF=1<<30;
ll dp[MAX][103];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        vector<int> S(N);
        vector<ll> T(N);
        for(int i=0;i<N;i++){
            int M;cin>>M>>T[i];
            for(int j=0;j<M;j++){
                int a,b;cin>>a>>b;
                for(int k=a;k<b;k++){
                    S[i]+=(1<<(k-6));
                }
            }
        }
        
        memset(dp,0,sizeof(dp));
        
        for(int i=0;i<N;i++){
            for(int bit=0;bit<(1<<16);bit++){
                if((bit|S[i])==bit+S[i]) dp[bit|S[i]][i+1]=max(dp[bit|S[i]][i+1],dp[bit][i]+T[i]);
                dp[bit][i+1]=max(dp[bit][i+1],dp[bit][i]);
            }
        }
        
        ll ans=0;
        
        for(int bit=0;bit<(1<<16);bit++) ans=max(ans,dp[bit][N]);
        
        cout<<ans<<endl;
    }
}





Measured memory_bytes: 55880
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define sc3(a,b,c)  cin>>a>>b>>c
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"Yes"<<endl
#define prN         cout<<"No"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];
ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	sc(n);
	f1(i,n){
		string s=toString(i);
		y=s[le(s)-1]-'0';
		x=s[0]-'0';
		if(!y)continue;
		A[x*20+y]++;
	}
	f1(i,n){
		
		string s=toString(i);
		y=s[le(s)-1]-'0';
		x=s[0]-'0';
		ans+=A[y*20+x];	
		//if(x==y)ans--;
	}
	pr(ans);
	
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	} 		
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a < b) swap(a,b);
    if(a < c) swap(a,c);
    if(b < c) swap(b,c);

    cout << a - c << endl;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a+b > c+d) {
    cout << "Left" << endl;
  }
  else if (a+b == c+d) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    vector<int> v[100001];

    ll dp[100001][2];   //0=white,1=black


    void dfs(int i,int p)
    {
        //cout<<i<<endl;
        int flag=0;
        dp[i][0]=dp[i][1]=1;
        for(int j=0;j<v[i].size();++j)
        {
            if(v[i][j]!=p)
            {
                flag=1;
                dfs(v[i][j],i);
                dp[i][0]=(dp[i][0]*(dp[v[i][j]][0]+dp[v[i][j]][1]))%mod;
                dp[i][1]=(dp[i][1]*(dp[v[i][j]][0]))%mod;
            }
        }
        
    }

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j,a,b;
            cin>>n;
            for(i=1;i<=n-1;++i)
            {
                cin>>a>>b;
                v[a].pb(b);
                v[b].pb(a);
            }
            dfs(1,-1);
            ll ans=(dp[1][0]+dp[1][1])%mod;
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 14208
W, H ,N = list(map(int, input().split()))
S = [[1]*W] * H

for i in range(N):
    x, y, a =  list(map(int, input().split()))
    if a == 3:
        for j in range(y):
            S[j] = [0] * W
    elif a == 4:
        for j in range(y, H):
            S[j] = [0] * W
    elif a == 1:
        for j in range(H):
            for k in range(x):
                S[j][k] = 0
    elif a == 2:
        for j in range(H):
            for k in range(x, W):
                S[j][k] = 0

re = 0
for i in range(H):
    re += sum(S[i])

print(re)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

int main(){
    ll N, X, T; cin >> N >> X >> T;
    ll num = ceil((float)N / (float)X);
    cout << num * T << endl;
}

Measured memory_bytes: 3608
import java.util.*;
public class Main{
	static int[] list1 = new int[180];
	static int[] list2 = new int[45];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		makeList();
		int[] dp1 = new int[1000000];
		int[] dp2 = new int[1000000]; 
		

		Arrays.fill(dp1, 2 << 27);
		Arrays.fill(dp2, 2 << 27);

		dp1[0] = dp2[0] =  0;

		for(int i = 0; i < 180; i++) {
			for(int j = 0; j < 1000000; j++) {
				if(dp1[j] == 2 << 27) continue;
				if(j + list1[i]  >= 1000000) break;
				dp1[j + list1[i]] = Math.min(dp1[j+list1[i]], dp1[j] + 1);
			}
		}

		for(int i = 0; i < 45; i++) {
			for(int j = 0; j < 1000001; j++) {
				if(dp2[j] == 2 << 27) continue;
				if(j + list2[i] >= 1000000) break;
				dp2[j + list2[i]] = Math.min(dp2[j+list2[i]], dp2[j] + 1);
			}
		}
		
		while(true) {
			int a = sc.nextInt();
			if(a == 0) break;
			System.out.println(dp1[a] + " " + dp2[a]);
		}
	}
	
	static void makeList() {
		int count1 = 0;
		int count2 = 0;
		for(int i = 1; i < 1000001; i++) {
			int sum = i*(i+1)*(i+2)/6;
			if(sum > 1000001) break;
			if(sum % 2 == 1) {
				list1[count1++] = sum;
				list2[count2++] = sum;
			}
			else {
				list1[count1++] = sum;
			}
		}
	}
	

	
}

Measured memory_bytes: 29360
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		if(n % 2 ==1) {
			System.out.println("No");
			return;
		}
		if(s.substring(0,n/2).equals(s.substring(n/2))){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}


	}
}

Measured memory_bytes: 23636
from math import pow

n, k = map(int, input().split())
ans = 0
if k == 1:
    print(1)
else:
    for i in range(1, n+1):
        times = 0
        point = i
        while point < k:
            point *= 2
            times += 1
        else:
            ans += (1/n) * pow(0.5, times)

    print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  long long n; cin >> n;
  cout << (n%2==0? n : n*2) << '\n';
  return 0;
}


Measured memory_bytes: 256
N = int(input())
p = list(map(float, input().split()))
dp = [[0.0 for i in range(N+1)] for _ in range(N+1)]
dp[0][0] = 1.0
for i in range(N):
    for j in range(i+1):
        # 表が出る
        dp[i+1][j+1] += dp[i][j] * p[i]
        # 裏が出る
        dp[i+1][j] += dp[i][j] * (1 - p[i])
temp = (N+1)//2
print(sum(dp[-1][temp:]))

Measured memory_bytes: 153312
#include <stdio.h>

int main()
{
  int ret, i, N, ng_flag;
  char S[101];
  
  ret = scanf("%d", &N);
  ret = scanf("%s", S);
  if ( (N % 2) != 0 ) {
    printf("No\n");
    return 0;
  }
  
  ret = N/2;
  ng_flag = 0;
  for ( i=0; i<ret;i++ ) {
    if ( S[i] != S[ret+i] ) {
      i = ret;
      ng_flag = 1;
    }
  }
  if ( ng_flag )
    printf( "No\n" );
  else
    printf( "Yes\n" );
}


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

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

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    let n = s.len();
    let mut ans = "AC";
    if s[0] != 'A'
        || s[2..n - 1].iter().filter(|&&c| c == 'C').count() != 1
        || s.iter().filter(|&c| c.is_lowercase()).count() != n - 2
    {
        ans = "WA";
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
S = input()
Q = int(input())
pre, suf = '', ''
rev = False
for _ in range(Q):
    query = input().split()
    if query[0] == '1':
        rev ^= 1
    else:
        f, c = query[1:]
        if (f == '1' and not rev) or (f == '2' and rev): pre = c + pre
        else: suf = suf + c
print(pre + S + suf if not rev else (pre + S + suf)[::-1])

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

using pii = pair<int, int>;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    cout<<std::fixed<<std::setprecision(15);

    int N, W;
    cin >> N >> W;

    vector<pii> vw(N);
    rep(i, N) cin >> vw[i].first >> vw[i].second;
    sort(all(vw), [](pii a, pii b) {return (double)a.first/a.second>(double)b.first/b.second;});

    int room = W;
    long double v = 0.0;
    for (int i = 0; i < N && room > 0; i++) {
        int w_prime = min(room, vw[i].second);
        v += (long double)vw[i].first * w_prime / vw[i].second;
        room -= w_prime;
    }

    cout << v << endl;
}




Measured memory_bytes: 3532
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define int long long

using namespace std;


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


const int MOD = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}



int K;
int A[100010];
signed main() {
	cin >> K;
	REP(i, K) {
		cin >> A[i];
	}
	int ma = 3, mi = 2;
	if (A[K - 1] != 2) {
		cout << -1 << endl;
		return 0;
	}
	FORR(i, K - 2, 0) {
		if (A[i] > ma) {
			cout << -1 << endl;
			return 0;
		}
		ma = ma / A[i] * A[i] + A[i] - 1;
		if (ma/A[i]*A[i]< mi) {
			cout << -1 << endl;
			return 0;
		}
		mi = (mi + A[i] - 1) / A[i] * A[i];
	}
	cout << mi << " " <<ma<< endl;
}




Measured memory_bytes: 1024
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    ll  q,h,s,d;
    cin>>q>>h>>s>>d;
    ll n;
    cin>>n;
    ll ne[4] = {25,50,100,200};
    vector<ll> v = {q,h,s,d};
    if(q*2<h){
        v[1]=q*2;
    }
    if(v[1]*2<s){
        v[2]=v[1]*2;
    }
    if(v[2]*2<d){
        v[3]=v[2]*2;
    }

    n = n*100;
    ll ans = 0;

    for(int i=3;i>=0;i--){
        ans += n/(ne[i])*v[i];
        n%=ne[i];

    }

    cout<<ans<<endl;




    
return 0;
}


Measured memory_bytes: 256
import sys

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

root = None

def insert(key):
    global root
    x, y = root, None
    while x is not None: x, y = x.left if key < x.key else x.right, x
    if y is None: root = Node(key)
    elif key < y.key: y.left = Node(key)
    else: y.right = Node(key)

def find(target):
    result = root
    while result and target != result.key:
        result = result.left if target < result.key else result.right
    return result is None

def delete(target):
    def remove_node(p, c, a):
        if p.left == c: p.left = a
        else: p.right = a
    p, c = None, root
    while c.key != target: p, c = c, c.left if target < c.key else c.right
    if c.left is None:
        remove_node(p, c, c.right)
    elif c.right is None:
        remove_node(p, c, c.left)
    elif c.right.left is None:
        c.right.left = c.left
        remove_node(p, c, c.right)
    else:
        g = c.right
        while g.left.left is not None: g = g.left
        c.key = g.left.key
        g.left = g.left.right

def inorder(node):
    return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
def preorder(node):
    return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''

input()
for e in sys.stdin:
    if e[0] == 'i': insert(int(e[7:]))
    elif e[0] == 'd': delete(int(e[7:]))
    elif e[0] == 'f': print(['yes','no'][find(int(e[5:]))])
    else: print(inorder(root)); print(preorder(root))


Measured memory_bytes: 56176
#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<ll, ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int q;
  cin >> q;
  for(int i = 0; i < q; i++) {
    string X, Y;
    cin >> X >> Y;
    vector<vector<int>> dp(X.size() + 1, vector<int>(Y.size() + 1));
    for(int i = 0; i < X.size(); i++) {
      dp[i][0] = 0;
    }
    for(int i = 0; i < Y.size(); i++) {
      dp[0][i] = 0;
    }
    for(int i = 0; i < X.size(); i++) {
      for(int j = 0; j < Y.size(); j++) {
        if(X[i] == Y[j]) {
          dp[i + 1][j + 1] = dp[i][j] + 1;
        } else {
          dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
        }
      }
    }
    cout << dp[X.size()][Y.size()] << endl;
  }

  return 0;
}


Measured memory_bytes: 6864
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int N;
    cin >> N;
    map<string, long long> dict;
    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        if (dict.count(s) == 0) {
            dict.insert(make_pair(s, 0LL));
        }
        dict[s] += 1LL;
    }
    long long ans = 0;
    for (auto e : dict) {
        if (e.second > 1) {
            ans += e.second * (e.second - 1) / 2;
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 11136
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
ans=0
a.sort()
for i in range(n):
    if x>=a[i]:
        if i == n-1:
            if a[i]==x:
                ans+=1
        else:
            x-=a[i]
            ans+=1
    else:
        break
print(ans)

Measured memory_bytes: 3060
#coding:UTF-8

while True:
    h,w = map(int,raw_input().split())
    if h == 0 and w == 0:
        break
    for i in range(h):
        if i == 0 or i == h - 1: 
            print "#" * w
            if i == h -1:
                print ""
        else:
            print "#"+"." * (w - 2)+"#"

Measured memory_bytes: 4204
# 優先度付きキュー
from sys import exit
from heapq import heappush, heappop

N, M = map(int, input().split())

jobs = {}
for _ in range(N):
    A, B = map(int, input().split())
    if A > M:
        exit
    if A in jobs:
        jobs[A].append(B)
    else:
        jobs[A] = [B]

result = 0
candidates = []
for a in range(1, M + 1):
    if a in jobs:
        for b in jobs[a]:
            heappush(candidates, -b)
    else:
        if len(candidates) == 0:
            continue
    result += -heappop(candidates)
print(result)


Measured memory_bytes: 26072
INF = 1e20

A, B, Q = [int(i) for i in input().split()]
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]
X = [int(input()) for _ in range(Q)]

from bisect import bisect_left

mins = []
for x in X:
    s = bisect_left(S, x)
    t = bisect_left(T, x)
    mi = INF
    for ss in [S[s], S[s - 1]]:
        for tt in [T[t], T[t - 1]]:
            mi = min(mi, abs(ss - x) + abs(tt - ss), abs(tt - x) + abs(ss - tt))
    mins.append(str(mi))
print("\n".join(mins))


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

    long long a,b,n;
    string ss,l[100][100];
    int main(){
        cin>>a>>b;
        if (a*500>=b){
            cout<<"Yes"<<endl;
            return 0;
        }
        cout<<"No"<<endl;
    }


Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int x,y,wk;
	while(1)	{
		scanf("%d %d",&x,&y);
		if(x==0 && y==0)	break;
		if(x>y)	{
			wk=x;
			x=y;
			y=wk;
		}
		printf("%d %d\n",x,y);
	}
	return 0;
}


Measured memory_bytes: 2048
#include <vector>
#include <cassert>
#include <functional>

/*
last-updated: 2020/08/15

SegmentTree(size_type n_, const F & f, const_reference id_elem) : 要素数 n_, 二項演算 f, 単位元 id_elem
void set(size_type i, const_reference x) : Θ(log n) i 番目の要素に x を代入
void add(size_type i, const_reference x) : Θ(lon n) i 番目の要素に x を演算する
value_type fold(size_type l, size_type r) const : Θ(log n) [l, r) を fold した結果を返す
size_type lower_bound(const_reference x) const : Θ(log n) 単調増加を仮定し、fold(0, idx) >= x となるような最小の idx を返す
size_type upper_bound(const_reference x) const : Θ(log n) 単調増加を仮定し、fold(0, idx) > x となるような最小の idx を返す

参考 :

*/

template<typename T>
struct BinaryIndexedTree {
	using value_type = T;
	using const_reference = const value_type &;
	using F = std::function<value_type(const_reference, const_reference)>;
	using size_type = std::size_t;
	
	BinaryIndexedTree(size_type n_, const F & f, const_reference id_elem) : n(n_), f(f), id_elem(id_elem) {
		node.resize(n + 1, id_elem);
	}
	
	size_type size() const noexcept {
		return n;
	}
	void add(size_type i, const_reference x) {
		assert(i < size());
		++i;
		for (; i <= n; i += i & -i) node[i] = f(node[i], x);
	}
	
	// [0, i)
	value_type sum(size_type i) {
		assert(i <= size());
		value_type res = id_elem;
		for (; i > 0; i -= i & -i) res = f(res, node[i]);
		return res;
	}
	
private:
	size_type n;
	F f;
	value_type id_elem;
	std::vector<value_type> node;
	
};

#include <cstdio>
int main() {
	int n, q;
	scanf("%d %d", &n, &q);
	BinaryIndexedTree<int> bit(n, [](auto &&x, auto &&y) {
		return x + y;
	}, 0);
	
	while (q--) {
		int com, x, y;
		scanf("%d %d %d", &com, &x, &y);
		if (com == 0) bit.add(x - 1, y);
		else printf("%d\n", bit.sum(y) - bit.sum(x - 1));
	}
}


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

using namespace std;

int main() {
    unsigned int n, q;
    cin >> n >> q;

    vector<list<int>> lst(n);
    while (q--) {
        int op, t;
        cin >> op >> t;
        if (op == 0) {
            int x;
            cin >> x;
            lst[t].insert(lst[t].end(), x);
        } else if (op == 1) {
            for (auto it = lst[t].begin(); it != lst[t].end(); it++) {
                if (it != lst[t].begin()) {
                    cout << " ";
                }
                cout << *it;
            }
            cout << endl;
        } else if (op == 2) {
            int s;
            cin >> s;
            lst[s].splice(lst[s].end(), move(lst[t]));
            lst[t].clear();
        }
    }
    return 0;
}


Measured memory_bytes: 18756
N, X = map(int, input().split())
x = list(map(int, input().split()))
for i in range(N):
    x[i] = abs(x[i] - X)


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


ans = x[0]
if N != 1:
    for j in range(1, N):
        ans = gcd(ans, x[j])
print(ans)

Measured memory_bytes: 14224
n, k = gets.chomp.split(" ").map {|c| c.to_i}

d = []
a = []

k.times do |ki|
    d.push(gets.chomp.to_i)
    a.push(gets.chomp.split(" ").map {|c| c.to_i})
end

all = []
a.each do |ai|
    all.concat(ai)
end

uniq = all.uniq

puts n - uniq.length

Measured memory_bytes: 14568
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define _               ios_base::sync_with_stdio(0);cin.tie(0)
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define ll              long long
#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 mk(arr,n,type)  type *arr=new type[n];
#define vpii            vector<pair<int,int> >
#define umii            unordered_map<int,int>
#define lli             list<int>
#define gcd(m,n)        __gcd(m,n)
#define mib             map<int,bool>


int main(){
  string s,t;
  cin >> s;
  cin >> t;
  int dp[s.length() + 1][t.length() + 1];

  for(int i = 0;i <= s.length();i++){ dp[i][0] = 0; }
  for(int i = 0;i <= t.length();i++){ dp[0][i] = 0; }

  for(int i = 1;i <= s.length();i++){
    for(int j = 1;j <= t.length();j++){
      if(s[i - 1] == t[j - 1]){
        dp[i][j] = dp[i - 1][j - 1] + 1;
      }else{
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }
  string result;
  result.resize(dp[s.length()][t.length()]);
  int z = dp[s.length()][t.length()] - 1;
  int i = s.length();
  int j = t.length();
  while(i >= 0 && j >= 0){
    if(dp[i][j] == dp[i][j - 1]){
      j--;
    }else if(dp[i][j] == dp[i - 1][j]){
      i--;
    }else{
      result[z] = s[i - 1];
      i--,j--,z--;
    }
  }
  cout << result << endl;
}

/*
  a b y x b
a 1 1 1 1 1
x 1 1 1 2 2
y 1 1 2 2 2
b 1 2 2 2 3
*/

Measured memory_bytes: 35456
#----------------for input------------------------
numberAndQuontum=input().split()
number=int(numberAndQuontum[0])
Quontum=int(numberAndQuontum[1])
allProcessList=[]

index=0
while index<number:
    nameAndTime=input().split()
    nameTimeList=[]
    nameTimeList.append(nameAndTime[0])
    nameTimeList.append(int(nameAndTime[1]))
    allProcessList.append(nameTimeList)
    index+=1
#----------------for input------------------------

def schedule(Quontum,allProcessList):
    time=0
    listForReturn=[]
    while True:
        index=0
        if allProcessList==[]:
            break
        length=len(allProcessList)
        while index<length:
            if allProcessList[index][1]<=Quontum:
                time+=allProcessList[index][1]
                listForReturn.append(allProcessList[index][0]+" "+str(time))
                allProcessList[index]=[]
                index+=1
            else:
                time+=Quontum
                listForAppend=[allProcessList[index][0],allProcessList[index][1]-Quontum]
                allProcessList.append(listForAppend)
                allProcessList[index]=[]
                index+=1
        while [] in allProcessList:
            allProcessList.remove([])
    for printPair in listForReturn:
        print(printPair)

#-------------------for main---------------------------
schedule(Quontum,allProcessList)

            



Measured memory_bytes: 15780
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(){
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    int i = (n - k >= 0) ? n - k : 0;
    int ans = 0;
    if(i != 0) ans = (k * x) + (i * y);
    else ans = n * x;

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
  static void Main(string[] args)
  {
    string[] ns = new string[110];
    string[] ms = new string[110];
    bool[] count = new bool[110];
    // スペース区切りの整数の入力
    int N = int.Parse(Console.ReadLine());
    for (int i = 0; i < N; i++) {
      ns[i] = "";
      ns[i] = Console.ReadLine();
    }
    int M = int.Parse(Console.ReadLine());
    for (int i = 0; i < M; i++) {
      ms[i]="";
      ms[i] = Console.ReadLine();
    }


    int lastvalue = 0;
    for (int i = 0; i < N; i++) {
      int wcount = 0;
      if (count[i] == false) {
        for (int j = i; j < N; j++) {
          if (ns[j] == ns[i]) {
            wcount++;
            count[j]=true;
          }
        }
        for (int j = 0; j < M; j++) {
          if (ms[j] == ns[i]) {
            wcount--;
          }
        }
        if (wcount>0){
          if (lastvalue<wcount)
          lastvalue=wcount;
        }
      }

    }

    Console.WriteLine(lastvalue);


  }
}

Measured memory_bytes: 11092
n,m = map(int,input().split())
s = []
c = []
for i in range(m):
    ss,cc = map(int,input().split())
    s.append(ss)
    c.append(cc)
for i in range(10**(n-1) if n!=1 else 0,10**n):
    ans = str(i)
    for j in range(m):
        if ans[s[j]-1] != str(c[j]):
            break
    else:
        print(ans)
        break
else:        
    print(-1)

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

ll f(ll a){
	if((a & 3) == 0) return a;
	else if((a & 3) == 1) return 1;
	else if((a & 3) == 2) return a + 1;
	else return 0; 
}

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

	ll a, b;
	cin >> a >> b;
	ll res = f(b);
	res ^= f(a - 1);
	cout << res;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[]) {
  string s;
  cin>>s;
  bool flag=1;
  int countC=0;
  if(s[0]!='A') flag=0;
  if(s[1]<'a')  flag=0;
  for(int i=2;i<s.size()-1;i++){
    if(s[i]<'a'&&s[i]!='C')  flag=0;
    if(s[i]=='C') countC++;
  }
  if(s[s.size()-1]<'a') flag=0;
  if(flag==1&&countC==1){
    cout<<"AC"<<endl;
  }else{
    cout<<"WA"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <string.h>
#include <string>
#include <cmath>

using namespace std;

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

int main() {
	vector<char> a;
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			char c;
			cin >> c;
			if (i == j)
				a.push_back(c);
		}
	}
	for (int i = 0; i < 3; ++i)
		cout << a[i];
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true) {
      int cnt = 0;
      int n = sc.nextInt();
      int x = sc.nextInt();
      if (n == 0 && x == 0) break;
      for (int i = 1; i <= n - 2; i++) {
        if (i >= x) break;
        for (int j = i + 1; j <= n - 1; j++) {
          if (i + j >= x) break;
          for (int k = j + 1; k <= n; k++) {
            if (i + j + k == x) cnt++;
            if (i + j + k >= x) break;
          }
        }
      }
      System.out.println(cnt);
    }
  }
}



Measured memory_bytes: 26504
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
int main()
{
    char c;
    cin >> c;
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')cout << "vowel\n";
    else cout << "consonant\n";
}

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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  for(int i=0;i<n;i++){
	cin >> l.at(i);
  }
  sort(l.begin(),l.end());
  /*for(int i=0;i<n;i++){
    cout << l.at(i) <<endl;
  }*/
  int sum=0;
  for(int i=0;i<n-1;i++){
    sum += l.at(i);
  }
  if( l.at(n-1) < sum){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  

  return 0;
  
}

Measured memory_bytes: 256
def factorize(n):
    b = 2
    fct = [(1,1)]
    while b * b <= n:
        cnt =0
        while n % b == 0:
            n //= b
            cnt +=1
        if cnt >=1:
            fct.append((b,cnt))
        b = b + 1
    if n > 1:
        fct.append((n,1))
    return fct

nmax = 10**6
mod = 10**9+7
fac = [1]*nmax
finv = [1]*nmax
inv = [1]*nmax
def ncr_pre():
    for i in range(2,nmax):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) %mod
        finv[i] = finv[i-1] * inv[i] %mod

def ncr(n,r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fac[n]* (finv[r] * finv[n-r] %mod) %mod

ncr_pre()
n,m = map(int,input().split())
ls = factorize(m)
tmp = 1
for num,cnt in ls:
    if num==1:continue

    tmp=tmp*ncr(n+cnt-1,cnt) %mod
print(tmp)


Measured memory_bytes: 88180
from itertools import combinations

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

count = 0
for C in combinations(L, 3):
    l_list = list(C)
    l_list.sort()

    if l_list[2] > l_list[1] and l_list[1] > l_list[0]:
        if l_list[2] < l_list[1] + l_list[0]:
            count += 1

print(count)

Measured memory_bytes: 9100
from math import gcd

n = int(input())
A = list(map(int, input().split()))
maxA = 10**6+5

def furui(x):
    memo = [0]*(x+1)
    primes = []
    for i in range(2, x+1):
        if memo[i]: continue
        primes.append(i)
        memo[i] = i
        for j in range(i*i, x+1, i):
            if memo[j]: continue
            memo[j] = i
    return primes

primes = furui(maxA)

c = [0]*maxA
for a in A: c[a] += 1

for p in primes:
    cnt = 0
    for i in range(p, maxA, p):
        cnt += c[i]
    if cnt >= 2:
        break
else:
    print('pairwise coprime')
    exit()

g = 0
for a in A:
    g = gcd(g, a)
if g == 1:
    print('setwise coprime')
else:
    print('not coprime')

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || '9' < c) break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

int main()
{
    const int MAX_OPE = 200000 + 1;
    int N;

    gc(N);

    map<int, int> m;
    REP (i, N)
    {
        int P;

        gc(P);

        m[P] = i;
    }

    int pre = -1;

    int minVal = 1;
    int maxVal = 1;

    int minOpe = MAX_OPE;

    // 1-indexed
    FOR (i, 1, N + 1)
    {
        if (m[i] < pre)
        {
            // 先頭へ minVal - 1
            // 末尾へ N - maxVal
            if (N + minVal - maxVal - 1 < minOpe)
            {
                minOpe = N + minVal - maxVal - 1;
            }

            minVal = i;
            maxVal = i;
        }
        else maxVal = i;

        pre = m[i];
    }

    if (minOpe == MAX_OPE) minOpe = 0;

    cout << minOpe << endl;
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;

int N;
ll A[100010];

int main() {

    cin >> N;
    for (int i = 0 ; i < N; i++) {
        cin >> A[i];
    }
    sort(A, A + N);
    for (int i = 0; i <= N - 2; i+=2) {
        if (A[i] < 0 and A[i+1] < 0) {
            A[i] *= -1;
            A[i+1] *= -1;
        }
        else if (A[i] < 0 and A[i+1] >= 0) {
         if (abs(A[i]) > abs(A[i+1])) {
             A[i] *=-1;
             A[i+1] *= -1;
         }
        }
    }

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += A[i];
    }
    cout << ans << '\n';

}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace Atcoder.Abc
{
    //https://atcoder.jp/contests/abc176/tasks/abc176_a
    public class Abc176_A
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var intN= Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

            var N = intN[0];
            var X = intN[1];
            var T = intN[2];

            var ans = (N + X - 1) / X;

            WriteLine(ans * T);


            //for (int i = 1; i <= 1000; i++)
            //{
            //    if ( X * i >= N)
            //    {
            //        WriteLine(T * i);
            //        break;
            //    }
            //}

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 17640
#include <iostream>

using namespace std;


int main(){
	long long n, m;
	cin >> n >> m;

	if(n == 1 && m == 1){
		cout << 1 << endl;
	}
	else if(n == 1 || m == 1){
		cout << n*m-2 << endl;
	}
	else{
		cout << (n-2)*(m-2) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
a.sort()
n = a[-1]
flg = 0
ans = 0
for i in range(N):
  if flg < min(a[i],n-a[i]):
    flg = min(a[i],n-a[i])
    ans = a[i]
print(n,ans)

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

int main() {
    string n;
    cin >> n;
    int sum = 0;
    for (char c : n) {
        sum += (c-'0');
    }
    if(sum%9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define sc second
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll ans, bit[65];

int main()
{
	ll n; scanf("%lld", &n);
	
	for(ll i = 1; i <= n; i++){
		ll inp; scanf("%lld", &inp);
		
		for(ll j = 0; j < 60; j++){
			if((1LL << j) & inp) bit[j]++;
		}
	}
	for(ll i = 0; i < 60; i++){
		ans = (ans + ( ( ((1LL << i) % mod) * bit[i]) % mod * (n - bit[i])) % mod) % mod;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 3792
#include<stdio.h>
#define maxn 100010
int cnt;
int p[maxn], np[maxn];

void init() {
	int i, j;
	for (i = 2; i < maxn; ++i) {
		if (!np[i]) {
			p[++cnt] = i;
			for (j = i + i; j < maxn; j += i)
				np[j] = 1;
		}
	}
}
void solve() {
	int n, i;
	scanf("%d", &n);
	for (i = 1; i <= cnt; ++i) {
		if (n <= p[i]) {
			printf("%d", p[i]);
			break;
		}
	}
}
int main() {
	init();
	solve();
	return 0;
}

Measured memory_bytes: 768