akhauriyash/Code-Regression huggingface dataset:
from operator import mul
from functools import reduce

def cmb(n,r):
    #n<10^4で最速s
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n,m=map(int,input().split())
if n>=2 and m>=2:print(cmb(n,2)+cmb(m,2))
elif n>=2:print(cmb(n,2))
elif m>=2:print(cmb(m,2))
else:print(0)

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
using PP = pair<P,P>;

const int N = 8005;
map<int,bool> dpx[N], dpy[N];
int main() {
  string s; int x,y;
  cin >> s >> x >> y;
  int n = s.size();

  vector<int> v = {0};
  rep(i,n){
    if(s[i]=='F') v[v.size()-1]++;
    else v.push_back(0);
  }
  n = v.size();

  dpx[0][0] = dpy[0][0] = true;
  dpx[1][v[0]] = dpy[1][0] = true;
  rep(j,n-1){
    int i=j+1;
    if(i%2==0){
      for(auto p:dpx[i-1]){
        dpx[i+1][p.first+v[i]] = true;
        dpx[i+1][p.first-v[i]] = true;
      }
    }else{
      for(auto p:dpy[i-1]){
        dpy[i+1][p.first+v[i]] = true;
        dpy[i+1][p.first-v[i]] = true;
      }
    }
  }
  bool ans = (dpx[n][x]||dpx[n-1][x]) && (dpy[n][y]||dpy[n-1][y]);
  cout << (ans?"Yes":"No") << endl;
}

Measured memory_bytes: 232832
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ');
  buildMaxHeap(arr);
  console.log(' ' + arr.join(' '));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest = i;
    left = 2 * i + 1;
    right = 2 * i + 2;
    if (left < n && Number(arr[left]) > Number(arr[i])) largest = left;
    if (right < n && Number(arr[right]) > Number(arr[largest])) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(n / 2 - 1); i >= 0; i--) maxHeapify(i);
}



Measured memory_bytes: 88308
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	if sc.Scan() {
		x, err := strconv.Atoi(sc.Text())
		if err != nil {
			panic(err)
		}
		fmt.Println(x*x*x)
	}
}



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

#define forn(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
const long double pi=2*acos(0.0);

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	vector<vector<int>>v(n+1);
	forn(i,m){
	    int x,y;
	    cin>>x>>y;
	    v[x].push_back(y);
	    v[y].push_back(x);
	}
	vector<bool>visited(n+1,false);
	vector<int>res(n+1);
	list<int>que;
	visited[1]=true;
	que.push_back(1);
	while(!que.empty()){
        int s=que.front();
        que.pop_front();
        for (auto i = v[s].begin(); i != v[s].end(); ++i)
        {
            if (!visited[*i])
            {
                visited[*i] = true;
                res[*i]=s;
                que.push_back(*i);
            }
        }
	}
	bool flag=true;
	for(int i=1;i<n+1;i++){
        if(!visited[i]){
            flag=false;
            break;
        }
	}
	if(!flag)cout<<"No"<<endl;
	else{
        cout<<"Yes"<<endl;
        for(int i=2;i<n+1;i++)cout<<res[i]<<endl;
	}
}


Measured memory_bytes: 12816
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int dis[2001][2001];

int main()
{
	cout << fixed << setprecision(10);
	int n, x, y;
	cin >> n >> x >> y;
	x--;
	y--;

	vector<int> cnt(n);

	REP(i, n)
	{
		for (int j = i + 1; j < n; j++)
		{
			int len = j - i;
			chmin(len, abs(x - i) + 1 + abs(y - j));
			cnt[len]++;
		}
	}
	for (int i = 1; i < n; i++)
	{
		cout << cnt[i] << " ";
	}

	return 0;
}

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

using namespace std;

int main(void)
{
	int k,t;
	cin >> k >> t;
	int a[105];
	for(int i=1;i<=t;i++)
		cin >> a[i-1];
	
	sort(a,a+t);

	int x=a[t-1];
	
	cout << (x<(k+1)/2 ? 0:k-(k-x)*2-1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}



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

  Int N, M;
  cin>>N>>M;
  string S, T;
  cin>>S>>T;

  Int gcd = __gcd(N, M);
  Int lcm =  (N / gcd) * M;

  Int x = lcm/N;
  Int y = lcm/M;
  Int ans = 1;
  for(Int i=0;i<N;i++){
    if(x * i % y) continue;
    ans &= S[i] == T[x * i / y];
  }

  if(!ans){
    cout<<-1<<endl;
    return 0;
  }
  else{
    cout<<lcm<<endl;
  }
  return 0;
}


Measured memory_bytes: 640
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def main():
  n, m = map(int, input().split())
  flags = numpy.zeros((n, m))
  for i in range(n):
    for a in list(map(int, input().split()))[1:]:
      a -= 1
      flags[i, a] = 1
  
  count = 0
  for j in range(flags.shape[1]):
    if sum(flags[:, j]) == n:
      count += 1
  print(count)

if __name__=='__main__':
  main()



Measured memory_bytes: 12396
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int A,B,T;
        String[] s = str.split(" ");
        A = Integer.parseInt(s[0]);
        B = Integer.parseInt(s[1]);
        T = Integer.parseInt(s[2]);
        System.out.println((T/A)*B);
    }
}

Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


// http://tsutaj.hatenablog.com/entry/2018/03/09/225829

int board[2010][2010];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    int n, k;
    cin >> n >> k;
    
    int sum = 0, white = 0;
    rep(i, n) {
        int x, y;
        char ch;
        cin >> x >> y >> ch;
        x %= 2 * k; y %= 2 * k;
        if (ch == 'B') {
            board[x + 1][y + 1]++;
            sum++;
        } else {
            board[x + 1][y + 1]--;
            sum--;
            white++;
        }
    }
    
    // 横に流す
    rep3(i, 1, 2 * k + 1) rep3(j, 1, 2 * k + 1) board[i][j] += board[i][j - 1];
    // 縦に流す
    rep3(i, 1, 2 * k + 1) rep3(j, 1, 2 * k + 1) board[i][j] += board[i - 1][j];
    
    int ma = -(1 << 25);
    // aの右下
    // リンクの図の, 左上が原点
    rep(i, k + 1) rep(j, k + 1) {
        int a = board[i][j]; // aが左上に完全消失してるときはi = k, j = kに同じ
        int b = board[i + k][j + k] - board[i + k][j] - board[i][j + k] + board[i][j];
        int c = board[2 * k][j] - board[i + k][j]; // cの縦は振り切ってる
        int d = board[i][2 * k] - board[i][j + k];
        int e = board[2 * k][2 * k] - board[2 * k][j + k] - board[i + k][2 * k] + board[i + k][j + k];
        int tmp = a + b + c + d + e;
        chmax(ma, max(tmp, sum - tmp));
    }
    ma += white;
    cout << ma << endl;
}

/*
 
 黒と白の領域がある
 黒で塗りたい領域だけ見る
 だから, 白があったら-1
 (理解に時間かかった, よく読もう)
 
 tmp + white
 (黒の領域の黒 - 黒の領域の白) + (白) = (黒の領域の黒 + 白の領域の白)
 
 sum - tmp + white
 (黒 - 白) - (黒の領域の黒 - 黒の領域の白) + (白)
 = (白の領域の黒 - 白の領域の白) + (白)
 = (白の領域の黒 + 黒の領域の白)
 = -(黒の領域の黒 + 白の領域の白)
 白を+1, 黒を-1とした場合に相当する
 tmpの計算で負になったとき正
 
 */


Measured memory_bytes: 16000
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    string str;
    cin >> str;
    int ans = 753;
    for(int i = 0; i + 3 <= str.size(); i++){
        ans = min(ans, abs(753 - stoi(str.substr(i, 3))));
    }
    cout << ans << "\n";
}

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

int main(){
   char s[11],t[11];
   int a,b;
   char u[11];
   scanf("%s %s",s,t);
   scanf("%d %d",&a,&b);
   scanf("%s",u);

   if(!(strcmp(u,s))){
      printf("%d %d",--a,b);
   }else {
      printf("%d %d",a,--b);
   }
}

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

using namespace std;
typedef long long ll;

const ll INF = 1e18L;

vector <ll> dp;
vector <ll> pref;

void rec(int i,vector <int>& not_taken,ll score,int mask,int group)
{
    if (i == not_taken.size())
    {
        dp[mask]=max(dp[mask],score+pref[group]);
        return;
    }

    rec(i+1, not_taken, score, mask, group);
    rec(i+1, not_taken, score, mask ^ (1 << not_taken[i]), group ^ (1 << not_taken[i]));
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector <vector <ll> > in (n,vector <ll> (n));
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++)
        cin >> in[i][j];

    pref.resize(1 << n);
    for (int mask=0;mask < (1 << n);mask++)
    {
        for (int i=0;i<n;i++)
            if (mask & (1 << i))
            for (int j=i+1;j<n;j++)
            if (mask & (1 << j))
            pref[mask]+=in[i][j];
    }

    dp.resize(1 << n, -INF);
    dp[0]=0;
    for (int mask=0;mask<(1 << n);mask++)
    {
        vector <int> not_taken;
        for (int i=0;i<n;i++)
            if (!(mask & (1 << i)))
            not_taken.push_back(i);
        rec(0,not_taken,dp[mask],mask,0);

    }

    cout << dp[(1 << n) - 1];

}



Measured memory_bytes: 1280
/*
       This sky
       Is lonely and grey
       But every night I feel your gravity waves
       And the world is cold
       But it's beautiful
       I wish you were here now
       I miss your soul
       But you lost your light
       When the darkness called
       I still stand here waiting
       The last to fall
       The last to fall
       The last to fall
       The last to fall
                            */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const unordered_map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define dbg(x) cout<<#x<<" = "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 4e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time"<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//_______________________________________________________________________________________
int main()
{
       int x,y;
       cin>>x>>y;
       fri(i,0,101){
              fri(j,0,101){
                     if((4*i+2*j)==y){
                            if((i+j)==x){
                                   cout<<"Yes"<<endl;
                                   return 0;
                            }
                     }
              }
       }
       cout<<"No";
}


Measured memory_bytes: 3636
import java.util.Scanner;

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

		int cb = (c + b - 1) / b;
		int ad = (a + d - 1) / d;
		if (cb <= ad) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35720
#include <bits/stdc++.h>
#define N 1000000007
using namespace std;

long long n, ans = 0;
// bit,  nowover? less?
long long dp[70][2][2] = {0};
string num;

void solve();

int main() {
  cin >> n;
  while(n > 0) {
    num += (n % 2) + '0';
    n /= 2;
  }
  reverse(num.begin(), num.end());
  solve();
  cout << ans << endl;
  return 0;
}

void solve() {
  long long size = num.size();
  //(1,0),(0,0),(0,0)(over)
  dp[0][0][0] = dp[0][0][1] = dp[0][1][0] = 1;
  for(long long i = 1; i < size; ++i) {
    if(num[i] == '1') {
      //(0,0)
      dp[i][0][1] +=
          (dp[i - 1][0][0] + dp[i - 1][0][1]) % N;
      //(1,1)
      dp[i][0][1] +=
          (dp[i - 1][1][0] + dp[i - 1][1][1]) % N;
      dp[i][0][1] %= N;
      //(0,1)
      dp[i][0][1] += dp[i - 1][0][1];
      dp[i][0][1] %= N;
      dp[i][0][0] += dp[i - 1][0][0];

      //(0,0)
      dp[i][1][0] += dp[i - 1][0][0];
      dp[i][1][1] += dp[i - 1][0][1];
      //(0,1)
      dp[i][1][1] +=
          (dp[i - 1][1][0] + dp[i - 1][1][1]) % N;
      dp[i][1][1] %= N;
      //(1,1)
      dp[i][1][0] += dp[i - 1][1][0];
      dp[i][1][0] %= N;
      dp[i][1][1] += dp[i - 1][1][1];
      dp[i - 1][1][1] %= N;
    }
    else {
      //(0,0)
      dp[i][0][1] += dp[i - 1][0][1];
      dp[i][0][0] += dp[i - 1][0][0];
      //(1,1)
      dp[i][0][1] += dp[i - 1][1][1];
      dp[i][0][1] %= N;
      dp[i][0][0] += dp[i - 1][1][0];
      dp[i][0][0] %= N;
      //(0,1)
      dp[i][0][1] += dp[i - 1][0][1];
      dp[i][0][1] %= N;

      //(0,0)
      dp[i][1][1] += dp[i - 1][0][1];
      //(0,1)
      dp[i][1][0] += dp[i - 1][1][0];
      dp[i][1][1] += dp[i - 1][1][1];
      dp[i][1][1] %= N;
      //(1,1)
      dp[i][1][1] += dp[i - 1][1][1];
      dp[i][1][1] %= N;
    }
  }
  for(int i = 0; i < 2; ++i) {
    ans += dp[size - 1][0][i];
    ans %= N;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int W, a, b;
	cin >> W >> a >> b;
	if(a < b) {
		if(b - a > W)
		   cout << (b - a) - W << endl;
		else
		   cout << 0 << endl;
	} else {
		if(a - b > W)
		   cout << (a - b) - W << endl;
		else
		   cout << 0 << endl;
	} 
	return 0;
}


Measured memory_bytes: 256
def dfs(i,e,s):
    if i==n-1:
        if s==7:
            print(e+'=7')
            exit()
    
    else:
        dfs(i+1,e+'+'+a[i+1],s+int(a[i+1]))
        dfs(i+1,e+'-'+a[i+1],s-int(a[i+1]))
    
a=input()
n=len(a)
dfs(0,a[0],int(a[0]))

Measured memory_bytes: 3064
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans += b[a[i]-1]
    if i >= 1:
        if a[i] - a[i-1] == 1:
            ans += c[a[i]-2]
print(ans)

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

using namespace std;

int main(void)
{
    long long int N, D, x, y;
    cin >> N >> D;
    int count = 0;
    for(int i = 0; i < N; i++){
        cin >> x >> y;
        if((x * x + y * y) <= (D * D)){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll a, b, c; cin >> a >> b >> c;
  if(a==b&&b==c) fin("Yes")
  else fin("No")
  return;
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
w = int(input())
n = int(input())
amida = [i+1 for i in range(w)]
for i in range(n):
    a,b = map(int,input().split(","))
    v = amida[a-1]
    amida[a-1] = amida[b-1]
    amida[b-1] = v
for i in amida:
    print(i)


Measured memory_bytes: 5596
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<sstream>
using namespace std;
int inf = 1e9;
int main(){
  int n; cin >> n;
  int cnt = inf;
  for(int i=0; i<n; i++){
    int a; cin >> a;

    int tmp = 0;
    while(a % 2 == 0) {
      a /= 2;
      tmp++;
    }
    cnt = min(cnt, tmp);

  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
program train;
var 
    n, i : longint;
    sum : Int64;
begin
    read(n);
    sum := 0;
    for i := 1 to n do 
        if not ((i mod 3) = 0) and not ((i mod 5) = 0)
            then sum := sum + i;
    write(sum);
end.    

Measured memory_bytes: 1336
#include<bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
int a[30][30],dp[(1<<21)+10];
int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch&15),ch=getchar();
	return x*f;
}
void add(int &x,int y){x+=y;if (x>=MOD) x-=MOD;}
int main()
{
	int n=read();
	for (register int i=1;i<=n;++i)
	  for (register int j=1;j<=n;++j)
	    a[i][j]=read();
	int S=(1<<n)-1;dp[0]=1;
	for (register int s=0;s<=S;++s)
	{
		int i=0,t=s;
		while (t) i+=(t&1),t>>=1;
		for (register int j=1;j<=n;++j) if (a[i+1][j]&&(!((s>>(j-1))&1))) add(dp[s|(1<<(j-1))],dp[s]);
	}
	printf("%d\n",dp[S]);
	return 0;
}

Measured memory_bytes: 8448
#include <iostream>
using namespace std;
void swap(int *p, int *q) {
    int tmp;
    tmp = *p;
    *p = *q;
    *q = tmp;
}

int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b) {
        swap(&a, &b);
    }
    if (b > c) {
        swap(&b, &c);
    }
    if (a > b) {
        swap(&a, &b);
    }
    cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 3104
#include <stdio.h>
int main(void){
  long long int  x;
  long long int a=100;

  scanf("%lld",&x);
  int y=0;
  
  while(a<x){
    a=a+a/100;
    y++;
  }
  printf("%d",y);
 
  return 0;
  }

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
#define N	55
void solve(){
	char a, b;
	cin>>a>>b;
	if(a=='H')
		cout<<b<<endl;
	else{
		if(b=='H') cout<<a<<endl;
		else cout<<'H'<<endl;
	}
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
     t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


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

int main() {
  int n, c = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b = 0;
    cin >> a;
    while (true) {
      if (a % 2 == 0) {
        a /= 2;
        b++;
      }
      else break;
    }
    if (i == 0) c = b;
    else if (c > b) c = b;
  }  
  cout << c << endl;
}


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

using namespace std;
int main ()
{   
    int N,M,X,Y;
    vector<int> x,y;
    cin >> N >> M >> X >> Y;
    x.push_back(X);
    y.push_back(Y);
    int tmp;
    for(int i=0;i<N;i++){
        cin >> tmp;
        x.push_back(tmp);
    }
    for(int i=0;i<M;i++){
        cin >> tmp;
        y.push_back(tmp);
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    if(x.back()<y.front())cout << "No War" << endl;
    else cout << "War" << endl;
    
    
    return 0;
}












Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <sstream>

using namespace std;

int main() {
    int a,b,c;

    cin >> a >> b >> c;

    if(c >= a && c <= b){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;++i)
#define per(i,r,l) for (int i=r;i>=l;--i)
#define rep0(i,r) for (int i=0;i<r;++i)
#define pr pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define ll long long
using namespace std;
const int N=1e6+6;
int main(){
    string s; cin>>s;
    cout<<s[0]<<s[1]<<s[2];
}

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

int main(){
    int n;
    cin>>n;
    vector<int> a(n-1);
    for(int i=0;i<n-1;i++)cin>>a[i];
    map<int,int> d;
    for(auto it:a)d[it]++;
    for(int i=1;i<=n;i++){
        cout<<d[i]<<endl;;
    }
}

Measured memory_bytes: 13560
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cassert>
#include<climits>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define EPS (1e-10)
#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1 
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define MAX 31
#define pow2(a) ((a)*(a))

using namespace std;

class Point
{
  public:
  double x,y,z;

  Point(double x = -IINF,double y = -IINF,double z=-IINF): x(x),y(y),z(z){}

  Point operator + (Point p){return Point(x+p.x,y+p.y,z+p.z);}
  Point operator - (Point p){return Point(x-p.x,y-p.y,z-p.z);}
  Point operator * (double a){return Point(a*x,a*y,a*z);}
  Point operator / (double a){return Point(x/a,y/a,z/a);}

  bool operator == (const Point& p)const
  {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS && fabs(z-p.z) < EPS;
  }

};

typedef Point Vector;

int V;
Point ps[MAX];

inline double dist(Point a,Point b)
{
  return sqrt(pow2(a.x-b.x)+pow2(a.y-b.y)+pow2(a.z-b.z));
}

inline void compute()
{
  Point mp = Point(50,50,50);
  double rate = 1;
  int max_pos;
  while(rate > EPS)
    {
      rep(_,100)
	{
	  max_pos = 0;
	  REP(j,1,V)
	    {
	      if(dist(mp,ps[max_pos]) < dist(mp,ps[j]))
		{
		  max_pos = j;
		}
	    }
	  mp.x += (ps[max_pos].x-mp.x) * rate;
	  mp.y += (ps[max_pos].y-mp.y) * rate;
	  mp.z += (ps[max_pos].z-mp.z) * rate;
	}
      rate = rate * 0.5;
    }
  printf("%.5lf\n",dist(mp,ps[max_pos]));
}

int main()
{
  while(scanf("%d",&V),V)
    {
      rep(i,V)
	{
	  scanf("%lf %lf %lf",&ps[i].x,&ps[i].y,&ps[i].z);
	}

      compute();

    }
  return 0;
}

Measured memory_bytes: 1256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <bitset>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = Mint(2).pow(n);
  Mint pow(long long n) const {
    if (n==0) return Mint(1);
    Mint y = pow(n>>1); // pow(n/2)を計算する
    y *= y;
    if (n%2==1) y *= *this;
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return a.pow(mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    Mint one = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= (i + one);
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};


int main() {
  int N, K;
  std::cin >> N >> K;
  std::vector<int > A(N);
  mod = K;
  for (int i=0; i<N; i++) {
    std::cin >> A[i];
  }
  std::vector<Mint > S(N+4);
  S[0] = 0;
  for (int i=0; i<N; i++) {
    S[i+1] = Mint(S[i]);
    S[i+1] += Mint(A[i]);
  }
  for (int i=0; i<=N; i++) {
    S[i] -= Mint(i);
  }
  std::map<long long, long long> mp;
  long long ans = 0;
  for (int i=0; i<=N; i++) {
    if (i>=K) mp[S[i-K].x]--; 
    ans += mp[S[i].x];
    //printf("ans+=mp[%d]=%lld\n", S[i], mp[S[i]]);
    mp[S[i].x]++;
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 17568
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include "iomanip"

using namespace std;

#include <cstdio>
#include <cstring>


int main() {
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    for (int i = 0; i < n; ++i) {
        cout << (i == m - 1 ? (char)tolower(s[i]) : (char)s[i]);
    }

}

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

int main() {
  int an[3];rep(i,3)cin>>an[i];
  sort(an,an+3);
  if (an[0]==5 && an[1]==5 && an[2]==7) cout<<"YES";
  else cout << "NO";
  
}


Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

main :: IO ()
main = do
	r <- readLn :: IO Double
	print $ 3.141592654 * 2 * r 

Measured memory_bytes: 4056
#include <iostream>
#include<bits/stdc++.h>
const int N=1e5+5;
const int M=1e7;
using namespace std;
int a[N];
int n,k,r,s,p,i,q;
int ps(char c)
{
    if(c=='r') return p;
    else if(c=='s') return r;
         else if(c=='p') return s;
}
int main()
{
    string t;
    cin>>n>>k;
    cin>>r>>s>>p;
    cin>>t;
    for(i=0;i<k;i++){
        a[i]=ps(t[i]);
    }
    for(i=k;i<2*k;i++){
        if(i==n) break;
        if(t[i]==t[i-k]) a[i]=a[i-k];
        else a[i]=a[i-k]+ps(t[i]);
    }
    for(i=2*k;i<n;i++){
        if(t[i]==t[i-k]&&a[i-k]!=a[i-2*k]) a[i]=a[i-k];
        else a[i]=a[i-k]+ps(t[i]);
    }
    q=0;
    for(i=n-k;i<n;i++)
        q=q+a[i];
    cout<<q;
    return 0;
}


Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static long solve[][] = new long[3002][3002];
    public static char direction[][] = new char[3002][3002];
    public static void main(String args[])throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s=br.readLine();
        String t=br.readLine();
        int SL=s.length();
        int TL=t.length();
        solve[0][0]=0;
        for(int i=0;i<s.length();i++)
            solve[0][i+1]=0;
        for(int i=0;i<t.length();i++)
            solve[i+1][0]=0;
        //System.out.println(DP(0,0));
        for(int i=1;i<=SL;i++)
        {
            for(int j=1;j<=TL;j++)
            {
                if(s.charAt(i-1)==t.charAt(j-1))
                {
                    solve[i][j]=solve[i-1][j-1]+1;
                    direction[i][j]='d';
                }
                else
                {
                    if(solve[i-1][j]>solve[i][j-1])
                    {
                        solve[i][j]=solve[i-1][j];
                        direction[i][j]='u';
                    }
                    else
                    {
                        solve[i][j]=solve[i][j-1];
                        direction[i][j]='l';
                    }
                }
            }
        }
        //System.out.println(solve[SL][TL]);
        int i=SL,j=TL;
        StringBuilder sb = new StringBuilder("");
        while(i!=0&&j!=0)
        {
            if(direction[i][j]=='d')
            {
                sb.append(s.charAt(i-1));
                i--;
                j--;
            }
            else if(direction[i][j]=='u')
                i--;
            else
                j--;
        }
        System.out.println(sb.reverse().toString());
        /*for(int i=1;i<=SL;i++)
        {
            for(int j=1;j<=TL;j++)
                System.out.print(direction[i][j]+" ");
            System.out.println();
        }*/
    }
}

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

#define pb push_back
#define int long long
#define mkpr make_pair
#define rep(i,a,b) for (i = a; i <= b;++i)
#define rrep(i,a,b) for (int i = a; i >= b; i--)

typedef pair<int, int> pii;
typedef map<int, int> mpii;
typedef unordered_map<int, int> umpii;
typedef vector<int> vi;
typedef vector<pii> vpii;
#define ff first
#define ss second
#define setbits(x)  __builtin_popcountll(x)
#define zrobits(x)  __builtin_ctzll(x)
#define mod 1000000007
#define MAX 500002
#define INF (long long) 4e18
#define endl "\n"

void in() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
//Problem-A
int solveA() {
	int n, i;
	cin >> n;
	int arr[n + 1];
	rep(i, 1, n)
	cin >> arr[i];
	int dp[n + 1];
	arr[0] = arr[1];
	dp[0] = 0;
	dp[1] = 0;
	rep(i, 2, n) {
		dp[i] = min(dp[i - 2] + abs(arr[i] - arr[i - 2]), dp[i - 1] + abs(arr[i] - arr[i - 1]));
	}
	return dp[n];
}
int32_t main() {
	in();
	cout << solveA() << endl;
}

Measured memory_bytes: 5204
MOD = 1000000007;

s = [int(x) if x!="?" else -1 for x in input()]

n=len(s)

r=[0]*13

c=s[0]
if (c!=-1):
	r[c]=1
else:
	for i in range(10):r[i]=1

for i in range(1,n):
	dp=[0]*26
	for j in range(13):dp[j*10%13]+=(r[j]%MOD)
	dp[13:26]=dp[0:13]
	c=s[i]
	r=[0]*13
	if (c==-1):
		w=sum(dp[4:14])
		for j in range(13):
				r[j]+=w
				w=w+dp[j+1]-dp[4+j]
	else:
		for j in range(13):
			r[j]+=dp[13-c+j]
print (r[5]%MOD)


Measured memory_bytes: 4092
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int N;
    cin >> N;
    int p[N];
    rep(i,N) cin >> p[i];
    rep(i,N) p[i]--;
    int ans=0;
    rep(i,N){
        if(p[i]==i) ans++;
        if(i<N-1)if(p[i]==i && p[i+1]==i+1) i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
class Dice():
    def __init__(self, numbers):
        self.top = numbers[0]
        self.s = numbers[1]
        self.e = numbers[2]
        self.w = numbers[3]
        self.n = numbers[4]
        self.bot = numbers[5]
    def rot(self, dir):
        top, s, e, w, n, bot = (self.top, self.s, self.e, self.w, self.n, self.bot)
        if dir == 'N':
            self.top = s
            self.s = bot
            self.e = e
            self.w = w
            self.n = top
            self.bot = n
        elif dir == 'S':
            self.top = n
            self.s = top
            self.e = e
            self.w = w
            self.n = bot
            self.bot = s
        elif dir == 'E':
            self.top = w
            self.s = s
            self.e = top
            self.w = bot
            self.n = n
            self.bot = e
        elif dir == 'W':
            self.top = e
            self.s = s
            self.e = bot
            self.w = top
            self.n = n
            self.bot = w
    def getTop(self):
        return self.top
    def rotMany(self, command):
        for dir in command:
            self.rot(dir)



li = list(map(int, input().split()))
D = Dice(li)
n = int(input())
for _ in range(n):
    t, s = map(int, input().split())
    for cmd in ["N","N","N","E","EE",""]:
        if D.top == t:
            break
        else:
            D.rotMany(cmd)
    for cmd in ["SEN", "SEN", "SEN", ""]:
        if D.s == s:
            break
        else:
            D.rotMany(cmd)
    print(D.e)



Measured memory_bytes: 5604
card=[[0 for i in range(13)] for j in range(4)]
n=int(input())
for k in range(0,n):
  x,y=map(str,input().split())
  
  if x == 'S':
    n=0
  elif x == 'H':
    n=1
  elif x == 'C':
    n=2
  elif x == 'D':
    n=3
  
  y=int(y)-1
  card[n][y]=1

for k in range(0,13):
  if card[0][k] == 0:
    print('S',k+1)

for k in range(0,13):
  if card[1][k] == 0:
    print('H',k+1)

for k in range(0,13):
  if card[2][k] == 0:
    print('C',k+1)
    
for k in range(0,13):
  if card[3][k] == 0:
    print('D',k+1)


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
signed main(void){
	char c;
	int a[25][25];
	memset(a,0,sizeof(a));
	int x,y,m;
	while(cin>>x>>c>>y>>c>>m){
		x+=5;
		y+=5;
		a[x][y]++;
		a[x-1][y]++;
		a[x+1][y]++;
		a[x][y-1]++;
		a[x][y+1]++;
		if(m==1)
			continue;
		a[x-1][y-1]++;
		a[x-1][y+1]++;
		a[x+1][y-1]++;
		a[x+1][y+1]++;
		if(m==2)
			continue;
		a[x-2][y]++;
		a[x+2][y]++;
		a[x][y-2]++;
		a[x][y+2]++;
	}
	int ans1=0,ans2=0;
	for(int i=5;i<15;i++)
		for(int j=5;j<15;j++){
			if(a[i][j]==0)
				ans1++;
			else if(a[i][j]>ans2)
				ans2=a[i][j];
		}
	cout<<ans1<<endl
		<<ans2<<endl;
}

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

#define MOD 1000000007

string k;
int d;

int dp[10002][2][101];


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

	cin >> k >> d;

	dp[0][0][0] = 1;
	rep(i, k.size()) rep(f, 2)rep(m, d + 1) {
		rep(di, 10) {
			if (f == 0 && k[i] - '0' < di)break;
			(dp[i + 1][f || k[i] - '0' > di][(m + di) % d] += dp[i][f][m]) %= MOD;
		}
	}
	cout << (dp[k.size()][0][0] + dp[k.size()][1][0] - 1 + MOD) % MOD << endl;


	return 0;
}


Measured memory_bytes: 8192
import * as fs from 'fs';
// main
function main(input: string[]) {
    // param
    let s;
    let ans;
    // init
    s = input.shift();
    // solve
    if (s.substring(s.length-1) != "s") {
        ans = s + "s";
    } else {
        ans = s + "es";
    }
    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        let input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            let input = lines;
            main(input);
        });
    }
}
entrypoint();


Measured memory_bytes: 29660
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for(int i = 0; i < n; i++)
void Yn(bool flg){cout<<(flg?"Yes":"No")<<endl;}
void YN(bool flg){cout<<(flg?"YES":"NO")<<endl;}
void yn(bool flg){cout<<(flg?"yes":"no")<<endl;}

signed main(){
  string S;
  cin >> S;
  int a;
  if(S == "SUN") {
    a = 7;}
  else if(S == "SAT") {
    a = 1;}
  else if(S == "FRI") {
    a = 2;}
  else if(S == "THU") {
    a = 3;}
  else if(S == "WED") {
    a = 4;}
  else if(S == "TUE") {
    a = 5;}
  else if(S == "MON") {
    a = 6;}
cout << a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <typeinfo>
using namespace std;
int N, M;
int main()
{
    cin >> N;
    map<int, int> mp;
    for(int i=0; i<N; ++i){
        int a; cin >> a;
        mp[a]++;
    }
    bool ok = true;
    cin >> M;
    for(int i=0; i<M; ++i){
        int a; cin >> a;
        if(mp[a]>0){
            mp[a]--;
        }else{
            ok = false;
        }
        if(!ok) break;
    }
    if(!ok) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 9600
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;
typedef long long ll;

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> m(n);
    int sum=0;
    for (int i = 0; i < n; i++)
    {
        cin >> m[i];
        sum+=m[i];
    }
    sort(m.begin(), m.end());
    cout << n+(x-sum)/m[0] << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"strconv"
	"strings"
	"os"
)

func nextInt(sc *bufio.Reader) int {
	line, _ := sc.ReadString('\n')
	i, _ := strconv.Atoi(strings.Trim(line, "\n"))
	return i
}

func nextLine(sc *bufio.Reader) string {
	line, _ := sc.ReadString('\n')
	return strings.Trim(line, "\n")
}

func readInts(sc *bufio.Reader, n int) []int {
	line, _ := sc.ReadString('\n')
	result := make([]int, n)
	for i, s := range strings.Split(strings.Trim(line, "\n"), " ") {
		x, _ := strconv.Atoi(s)
		result[i] = x
	}
	return result
}

func main() {
	var n int
	fmt.Scanln(&n)

	reader := bufio.NewReader(os.Stdin)

	ts := readInts(reader, n)

	m := nextInt(reader)

	ps := make([]int, m)
	xs := make([]int, m)
	for i := 0; i < m; i++ {
		ns := readInts(reader, 2)
		ps[i] = ns[0]
		xs[i] = ns[1]
	}

	for i := 0; i < m; i++ {
		var sum int

		q := ps[i] - 1
		for j, x := range ts {
			if j == q {
				sum += xs[i]
			} else {
				sum += x
			}
		}

		fmt.Println(sum)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
 
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x first
#define y second
 
const int MOD = 1e9 + 7;
 
void setIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
//    freopen((s+".in").c_str(),"r",stdin);
//    freopen((s+".text").c_str(),"w",stdout);
}

//ctrl q is comment
//ctrl b is run
//ctrl s is compile
//alt r is search & replace
//alt d is delete a line

int main(){
    setIO();
    int a, b, c, K; cin >> a >> b >> c >> K;
    int k2 = K;
    bool ok = false;
    int p2[10];
    int p = 0, m = 1;
    p2[0] = 1;
    while(p < 9){
        ++p; m *= 2;
        p2[p] = m;
    }
    K = k2;
    for(int i = 0; i < 7; ++i){
        for(int j = 0; j < 7; ++j){
            for(int k = 0; k < 7; ++k){
                if(i + j + k > K) continue;
                int ra = a * p2[i];
                int rb = b * p2[j];
                int rc = c * p2[k];
                if(rb > ra && rc > rb) {
                    ok = true;
                }
            }
        }
    }
    cout << (ok ? "Yes\n": "No\n");
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
const int MAX = 501;

int n, cnt[MAX], res[MAX*MAX];
pair<int,int> x[MAX];
set<int> pos;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n*n; i++) pos.insert(i);
	for(int i = 1; i <= n; i++) cnt[i] = n;
	for(int i = 1; i <= n; i++) {
		cin >> x[i].first;
		x[i].second = i;
	}
	sort(x+1, x+n+1);
	for(int i = 1; i <= n; i++) {
		if(x[i].first == x[i-1].first) cout << "No", exit(0);
		for(int j = 0; j < x[i].second-1; j++) {
			if(pos.empty() || *pos.begin() >= x[i].first) cout << "No", exit(0);
			res[*pos.begin()] = x[i].second;
			--cnt[x[i].second];
			pos.erase(pos.begin());
		}
		res[x[i].first] = x[i].second;
		--cnt[x[i].second];
		pos.erase(x[i].first);
	}
	for(int i = 1, j = 1; i <= n*n; i++) if(!res[i]) {
		while(j <= n && !cnt[x[j].second]) ++j;
		if(i <= x[j].first) cout << "No", exit(0);
		res[i] = x[j].second;
		--cnt[x[j].second];
	}
	cout << "Yes\n";
	for(int i = 1; i <= n*n; i++) cout << res[i] << ' ';
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X,Y,Z;
  cin>>X>>Y>>Z;
  int count = 0;
  X-=Z;
  while(X>=Y+Z){
    count++;
    X -= Y;
    X -= Z;
    
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = "";
		int result = 100000;
		try {
			while((str = br.readLine()) != "") {
				int num = Integer.parseInt(str);
				for(int i=0; i<num; i++) {
					result += result / 100 * 5;
					if(result % 1000 != 0) {
						result = (result / 1000 + 1) * 1000;
					}
				}
				System.out.println(result);
			}
		} catch(Exception e) {
			e.getMessage();
		}
	}
}

Measured memory_bytes: 24348