akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
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;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j]
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能

int main(){
    int n,k; cin >> n >> k;
    int r,s,p; cin >> r >> s >> p;
    string t; cin >> t;
    ll ans=0;
    rep(i,n){
        if(t[i]=='r'){
            if(i-k<0) ans+=p;
            else if(t[i-k]!=t[i]) ans+=p;
            else t[i]='m';
        }
        else if(t[i]=='s'){
            if(i-k<0) ans+=r;
            else if(t[i-k]!=t[i]) ans+=r;
            else t[i]='m';
        }
        else if(t[i]=='p'){
            if(i-k<0) ans+=s;
            else if(t[i-k]!=t[i]) ans+=s;
            else t[i]='m';
        }
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 512
def op1 (p) :
    return (
        p[ 0],p[ 1],p[ 2],p[ 3],p[ 4],p[ 5],p[21],p[22],p[23],p[11],p[10],p[ 9],p[17],p[13],p[14],
        p[15],p[16],p[12],p[18],p[19],p[20],p[ 6],p[ 7],p[ 8],p[24],p[25],p[26],p[27],p[28],p[29]
    )

def op2 (p) :
    return (
        p[27],p[28],p[29],p[ 3],p[ 4],p[ 5],p[ 6],p[ 7],p[ 8],p[ 9],p[10],p[11],p[12],p[13],p[15],
        p[14],p[16],p[17],p[20],p[19],p[18],p[21],p[22],p[23],p[24],p[25],p[26],p[ 0],p[ 1],p [2]
    )

def op3 (p) :
    return (
        p[23],p[ 1],p[ 2],p[26],p[ 4],p[ 5],p[29],p[ 7],p[ 8],p[20],p[10],p[11],p[12],p[13],p[14],
        p[17],p[16],p[15],p[18],p[19],p[ 9],p[21],p[22],p[ 0],p[24],p[25],p[ 3],p[27],p[28],p[ 6]
    )

def op4 (p) :
    return (
        p[ 0],p[ 1],p[21],p[ 3],p[ 4],p[24],p[ 6],p[ 7],p[27],p[ 9],p[10],p[18],p[14],p[13],p[12],
        p[15],p[16],p[17],p[11],p[19],p[20],p[ 2],p[22],p[23],p[ 5],p[25],p[26],p[ 8],p[28],p[29]
    )

def op (p, i) :
    if (i == 1) :
        return op1(p)
    elif (i == 2) :
        return op2(p)
    elif (i == 3) :
        return op3(p)
    elif (i == 4) :
        return op4(p)

def valid (p) :
    for i in range(1, 9) :
        if (p[0] != p[i]) :
            return False

    for i in range(22, 30) :
        if (p[21] != p[i]) :
            return False

    for i in range(10, 12) :
        if (p[9] != p[i]) :
            return False

    for i in range(13, 15) :
        if (p[12] != p[i]) :
            return False

    for i in range(16, 18) :
        if (p[15] != p[i]) :
            return False

    for i in range(19, 21) :
        if (p[18] != p[i]) :
            return False

    q = (p[0], p[9], p[12], p[15], p[18], p[21])

    if (q == (0, 1, 3, 5, 4, 2)) :
        return True
    if (q == (0, 3, 5, 4, 1, 2)) :
        return True
    if (q == (0, 5, 4, 1, 3, 2)) :
        return True
    if (q == (0, 4, 1, 3, 5, 2)) :
        return True

    if (q == (2, 1, 5, 3, 4, 0)) :
        return True
    if (q == (2, 5, 3, 4, 1, 0)) :
        return True
    if (q == (2, 3, 4, 1, 5, 0)) :
        return True
    if (q == (2, 4, 1, 5, 3, 0)) :
        return True

    return False

def solve (n, p, i) :
    global minimum
    if (n > 9) :
        return

    if (n >= minimum) :
        return

    if (valid(p)) :
        minimum = min(minimum, n)
        return

    for j in range(1, 5) :
        if (i != j) :
            solve(n + 1, op(p, j), j)
    return

minimum = 100
N = int(input())
for kk in range(0, N) :
    minimum = 100
    p = tuple([int(term) - 1 for term in input().split()])
    if (valid(p)) :
        print(0)
        continue
    for i in range(1, 5) :
        solve(1, op(p, i), i)
    print(minimum)

Measured memory_bytes: 7908
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


class UnionFindWeighted:
    # Reference: https://note.nkmk.me/python-union-find/
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        self.weight = [0] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            root = self.find(self.parents[x])
            self.weight[x] += self.weight[self.parents[x]]
            self.parents[x] = root
            return root

    def union(self, x, y, w):
        w += -self.weight[x] + self.weight[y]

        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y, w = y, x, -w

        self.parents[x] += self.parents[y]
        self.parents[y] = x
        self.weight[y] = -w

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def diff(self, x, y):
        return self.weight[x] - self.weight[y]


def main():
    N, M, *LRD = map(int, read().split())

    uf = UnionFindWeighted(N)
    for l, r, d in zip(*[iter(LRD)] * 3):
        l -= 1
        r -= 1
        if uf.same(l, r) and uf.diff(l, r) != d:
            print('No')
            return
        else:
            uf.union(l, r, d)

    print('Yes')
    return


if __name__ == '__main__':
    main()


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

#define ll long long
#define ld long double
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define ppb pop_back
#define vll vector<ll>
#define vi vector<int>
#define endl "\n"

const ll INF = 1000000007;

/*
const int max_size = 100001;
int parent[max_size];
int Size[max_size];

int root(int x){
	while(x!=parent[x]){
		parent[x] = parent[parent[x]];
		x = parent[x];
	}
	return x;
}

void sunion(int x,int y){
	int rx = root(x);
	int ry = root(y);
	if(rx != ry){
		if(Size[rx] > Size[ry]){
			parent[ry] = parent[rx];
			Size[rx] += Size[ry];
		}
		else{
			parent[rx] = parent[ry];
			Size[ry] += Size[rx];
		}
	}
}
*/

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--){
		int x,ans=1;
		for (int i=0;i<5;i++) {
			cin >> x;
			if (x == 0) ans = i+1;
		}
		cout << ans;
	}
	return 0;
}


Measured memory_bytes: 3608
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        for(int i = 1; i < 10; i++){
           for(int j = 1; j < 10; j++){
                if(i*j == num){
                    System.out.println("Yes");
                    return;
                }
            } 
        }
        System.out.println("No");
    }
}


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

int main(){
  int i,j,n,c=0;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>j;
    if(j!=i+1) c++;
  }
  if(c<=2) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int find(int a,int b){
	si s; s.insert(0); s.insert(1); s.insert(2);
	s.erase(s.find(a));
	s.erase(s.find(b));
	return(*s.begin());
}

int32_t main(){
    IOS;
    int n;
    cin>>n;
    string s;
    cin>>s;
    int suf[n+1][3];
    map<char,int> m;
    m.insert({'R',0});
    m.insert({'G',1});
    m.insert({'B',2});
    memset(suf,0,sizeof(suf));
    for(int j=s.size()-1;j>=0;j--){
    	for(int i=0;i<3;i++){suf[j][i]=suf[j+1][i];}
    	suf[j][m[s[j]]]++;
    }
    int ans=0;
    for(int i=0;i<s.size();i++){
    	for(int j=i+1;j<s.size();j++){
    		int a=m[s[i]];
    		int b=m[s[j]];
    		if(a==b) continue;
    		else{
    			int c=find(a,b);
    			ans+=suf[j+1][c];
    			int diff=j-i;
    			if(j+diff<(int)s.size()&&m[s[j+diff]]==c) ans--;
    		}
    	}
    }
    cout<<ans<<endl;
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        String s = sc.next();

        Map<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (!map.containsKey(ch)) {
                map.put(ch, 0);
            }
            map.put(ch, map.get(ch) + 1);
        }
        int cnt = 0;
        for (char key : map.keySet()) {
            cnt++;
        }
        if (cnt == 2) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

int main() {
    int a, b, c, d;
    cin >> a;
    b = a % 10;
    a = a - b;
    c = a % 100 / 10;
    a = a - c;
    d = a % 1000 / 100;
    cout << b + c + d <<endl;
      
}

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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define REP(i,N) for(int i=0;i<N;i++)

int main()
{
    int n; cin>>n;
    vector<int> p(n,0);
    REP(i,n){
        cin>>p[i];
    }
    int ans = 0;
    for(int i=1;i<n-1;i++){
        ans += (p[i-1]<p[i]&&p[i]<p[i+1]) || (p[i-1]>p[i]&&p[i]>p[i+1]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007LL
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  150
#define tmod             998244353LL
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<pair< ll ,ll > > &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
//bool P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n,ll m);

ll nCr(ll n,ll r,vector<ll> &Fc,vector<ll> &IF)
{
    return (((Fc[n]*IF[r])%tmod)*IF[n-r])%tmod;
}

int main()
{
fast;
ll q=1,t;
//cin >> q; t = q;
while(q--)
{
    ll i,j,n,m,k,l,r,a,b,c=0,d=0,e,g=0,p,u,v,w,x,y,flag=1;
    //n=m=k=i=j=l=r=a=b=c=d=u=v=w=p=x=y=0;
    cin >> n >> m >> k;
    vector<ll> Fac(n+1,1),IF(n+1,1);
    for(i=2;i<=n;i++) {Fac[i] = (Fac[i-1]*i)%tmod;  IF[i] = (IF[i-1]*MI(i,tmod))%tmod;}
    ll ans = 0;
    for(i=0;i<=k;i++)
    {
        ans = (ans + (((nCr(n-1,i,Fac,IF)*m)%tmod)*Powb(m-1,n-i-1,tmod))%tmod )%tmod;
    }
    cout << ans;


}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n,ll m)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2,m);
    if(n%2==0){return (temp*temp)%m;}
    else{return (b*((temp*temp)%m))%m;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<pair<ll,ll> > &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid].F==ser)
    {
        return mid;
    }
    else if(PS[mid].F > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    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;
}
/*
void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                P[j]=false;
            }
        }
    }

}

*/


Measured memory_bytes: 6368
N = int(raw_input())
health = map(int, raw_input().strip().split())

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

if len(health) == 1:
	print health[0]
else:
	g = gcd(health[0], health[1])
	for i in range(2, len(health)):
		g = gcd(g, health[i])
print g

Measured memory_bytes: 11296
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  cout << a*b << "\n";

  return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    set<ll> ans{1, 2, 3};
    ll A, B;
    cin >> A >> B;
    ans.erase(A);
    ans.erase(B);
    cout << *ans.begin() << endl;
    return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MAX 2000005
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define tr(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
 
 
ll n, m, i, j, k, t,r, a, b, c, d, l, w, tmp, g, ans, sum, cnt, neg1, flag, mn, mx, neg2;
ll arr[MAX], sz[MAX], crr[MAX];
vector<ll> v[MAX];
vector<ll> centroid;

int main()
{
    
    ios_base::sync_with_stdio(false);cin.tie(NULL);
   
        cin>>n;
        cout<<!n;
    

    return 0;   
}

Measured memory_bytes: 50520
#include <stdio.h>
 
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
 
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}
 
void skip(int k) { while (k--) gc(); }
 
void out(int n)
{
	int i;
	char ob[20];
 
	if (!n) { pc('0'); return; }
	i = 0; while (n) ob[i++] = n%10 + '0', n/=10;
	while (i--) pc(ob[i]); 
}
 
int que[1500005]; int top, end;
 
int main()
{
	int n, i, t;
	char op;
 
	n = in(); top = 0, end = 1;
	while (n--) {
		if (gc() == 'i') {
			skip(6);
			que[end++] = in();
		} else {
			skip(5);
			op = gc();
			if (op == 'L') {
				skip(4);
				top++;
			} else if (op == 'F') {
				skip(5);
				end--;
			} else {
				que[top] = t = in();
				i = end; while (que[--i] != t);
				if (i > top) {
					if (end - i < i - top) {
						while (++i < end) que[i-1] = que[i];
						end--;
					} else {
						while (--i > top) que[i+1] = que[i];
						top++;
					}
				}
			}
		}
	}
	i = end-1; out(que[i--]);
	while (i > top) pc(' '), out(que[i--]);
	pc('\n');
	return 0;
}


Measured memory_bytes: 5340
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 4e4 + 10;
int getsum(int n)
{
	int sum = 0;
	while (n)
	{
		sum += n % 10;
		n /= 10;
	}
	return sum;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, a, b;
	cin >> n >> a >> b;
	LL ans = 0;
	for (int i = 1; i <= n; i++)
	{
		int sum = getsum(i);
		if (sum >= a && sum <= b) ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//Uneven Numbers
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int count=0;

    for (int i=1;i<=n;i++) {
      String s=String.valueOf(i);
      if (s.length()%2==1) {
        count++;
      }
    }

    System.out.println(count);

  }
}


Measured memory_bytes: 28244
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n=0, sum=0;
        int othe = 0;
        int count=0;
        
        while(true){
            n = Integer.parseInt(sc.next());
            sum = Integer.parseInt(sc.next());
            if(n==0) break;
            
            count=0;
            for(int i=1; i<n; i++){
                for(int j=i+1; j<n; j++){
                    othe=(sum-i-j);
                    if((othe > j) && (othe <= n)) count++;
                }
            }
            System.out.println(count);
        }
    }
}


Measured memory_bytes: 26108
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
#include <cmath>
using namespace std;


int main()
{
    int n, m;
    cin >> n >> m;
    vector< vector <int> > s(m);
    for (int i = 0; i < m; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int tmp;
            cin >> tmp;
            s[i].push_back(--tmp);
        }
    }
    vector<int> p;
    for (int i = 0; i < m; i++) {
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
    }

    int okCount = 0;
    for (int state = 0; state < pow(2, n); state++) {
        // 各電球について，条件を満たすかを確認する 
        bool ngFlag = true;
        for (int denki = 0; denki < m; denki++) {
            int count = 0;
            for (int sw = 0; sw < s[denki].size(); sw++) {
                if (state & (1 << (s[denki][sw]))) {
                    count++;
                }
            }
            if (p[denki] != count % 2) {
                ngFlag = false;
                break;
            }
        }
        if (ngFlag) {
            okCount++;
        }
    }
    cout << okCount << endl;
}

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s, t = list(map(str, readline().rstrip().decode('utf-8').split()))
    ls = []
    for i in range(n):
        ls.append(s[i])
        ls.append(t[i])
    print("".join(ls))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38256
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=10005;
int n,k;
bool no[maxn];

bool check(int x){
	while(x){
		if(no[x%10])return false;
		x/=10;
	}
	return true;
}

int main(){
	scanf("%d%d",&n,&k);
	rep(i,k){
		int x;
		scanf("%d",&x);
		no[x]=true;
	}
	while(true){
		if(check(n)){
			printf("%d",n);
			return 0;
		}
		n++;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];





int main(){
	long long a;
    cin>>a;
    long long cou=0;
    int p=0;
    if(a%2!=0){
        cout<<0<<endl;
    }
    else{
        p=5;
        a=a/2;
        for(long long i=5;i<=a;i*=5){
            cou+=a/i;
        }
        cout<<cou<<endl;
    }
}



Measured memory_bytes: 256
#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 RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	ll n;
	cin >> n;

	string s;
	s = to_string(n);

	bool flg = false;
	rep(i,s.size()-1){
		if(s[i+1] != '9') {
			flg = true;
			break;
		}
	}

	int ans = 0;
	if(flg){
		ans = (s[0] -'0') - 1; 
		rep(i,s.size()-1) ans += 9;
	}else{
		rep(i,s.size()) ans += (s[i] - '0');
	}

	cout << ans << endl;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int h,w;
  cin >> h >> w;
  for (int i=0;i<w+2;i++) cout <<'#';
  cout << endl;
  
  for (int i=0;i<h;i++){
    cout <<'#';
    for(int j=0;j<w;j++){
      char a;
      cin >> a;
      cout << a;
    }
    cout <<'#' << endl;
  }
  for (int i=0;i<w+2;i++) cout <<'#';
  cout << endl;
  
}


Measured memory_bytes: 256
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    long int x,y;
    scanf("%ld %ld", &x, &y);
    long int n = y / x;
    int nCount = 1;
    while(n >= 2){
        n /= 2;
        nCount++;
    }
    printf("%d", nCount);
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    static double Median(long[] x)
    {
        x = x.OrderBy(xx => xx).ToArray();
        var n = x.Length;
        if (n % 2 == 0)
        {
            return (x[n / 2 - 1] + (double)x[n / 2]) / 2;
        }
        else
        {
            return x[n / 2];
        }
    }

    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var min = new long[N];
        var max = new long[N];
        for (int i = 0; i < N; i++)
        {
            var vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            min[i] = vals[0];
            max[i] = vals[1];
        }
        var left = Median(min);
        var right = Median(max);

        var answer = right - left;
        if (N % 2 == 0)
        {
            answer *= 2;
        }
        answer++;

        Console.WriteLine(answer);
    }
}

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

int main()
{
    long long int h,w,dia,p1,p2;
    scanf("%lld%lld",&h,&w);
    if(h%2==0)
        p1=h/2;
    else
        p1=h/2+1;
    if(w%2==0)
            p2=w/2;
    else
        p2=w/2+1;
    dia=p1*p2+(h/2)*(w/2);
    if(h==1||w==1)
        printf("1\n");
    else
    printf("%lld\n",dia);

}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL inf = 112345678901234567;
int main()
{
	LL A, B, Q;
	in >> A >> B >> Q;
	std::vector<LL>s(A), t(B), x(Q);
	rep(i, A) in >> s[i];
	rep(i, B) in >> t[i];
	rep(i, Q) in >> x[i];

	rep(i, Q)
	{
		auto s1 = std::lower_bound(s.begin(), s.end(), x[i]);
		auto s2 = std::upper_bound(s.begin(), s.end(), x[i]);
		auto t1 = std::lower_bound(t.begin(), t.end(), x[i]);
		auto t2 = std::upper_bound(t.begin(), t.end(), x[i]);
		LL disSL = inf, disSR = inf, disTL = inf, disTR = inf;
		if (s1 != s.end()) disSR = *s1 - x[i];
		if (s2 != s.begin()) disSL = x[i] - *(s2 - 1);
		if (t1 != t.end()) disTR = *t1 - x[i];
		if (t2 != t.begin()) disTL = x[i] - *(t2 - 1);
		LL res1 = std::max(disSL, disTL);
		LL res2 = disSL + disTR + std::min(disSL, disTR);
		LL res3 = disSR + disTL + std::min(disSR, disTL);
		LL res4 = std::max(disSR, disTR);
		out << std::min({ res1,res2,res3,res4 }) << std::endl;
	}
}


Measured memory_bytes: 3712
#include <iostream>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if(a >= b) {
		for(int i = 0; i < a; i++) {
			cout << b;
		}
	} else {
		for(int i = 0; i < b; i++) {
			cout << a;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll t,n,i,j,x,y,k;

int main() {
	vector<ll>a(4);
	for(i=0;i<4;i++)
	cin>>a[i];
	ll p=LLONG_MIN;
	for(i=0;i<2;i++)
	{
	    for(j=2;j<4;j++)
	    {
	        p=max(p,a[i]*a[j]);
	    }
	}
	cout<<p;

	    
	
	return 0;
}



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


int main(){
    int a, b;
    string s;
    cin >> a >> b >> s;
    bool ans = true;
    rep(i,a){
        if(s.at(i) == '-'){
            ans = false;
            break;
        }
    }
    if(s.at(a) != '-'){
        ans = false;
    }
    for(int i=a+1; i<a+b; i++){
        if(s.at(i) == '-'){
            ans = false;
            break;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
using namespace std;
typedef long long int ll;

int main() {
	string s;
	cin >> s;
	int n = s.length();
	ll ans = 0;
	for(int i = 0; i < 1 << n; i++){
		ll sum = 0;
		ll num = 0;
		for(int j = 0; j < n; j++){
			if(i & (1 << j)){
				num *= 10;
				num += s[j] - '0';
			}else{
				sum += num;
				num = 0;
			}
		}
		sum += num;
		ans += sum;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define EPS 1e-14
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define PI 2*acos(0.0)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(x) cout<<#x <<": "<< x << "\n"
#define DEBUG_ARR(a) REP(i, size(a)){ cout << #a << "[" << i << "]: " << a[i] << "\n"; }
const int VX[] = { 0, 1, 0, -1 };
const int VY[] = { 1, 0, -1, 0 };
const long MOD = 1000000007;

int main()
{
	//	--- I/O 高速化 ---
	cin.tie(0);
	ios::sync_with_stdio(false);
	// --- ここまで ---

	string s;
	cin >> s;

	int len = s.length();
	cout << s[0] << len - 2 << s[len - 1] << endl;

	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf  = 1 << 61;
    static int[] x4 = {-1, 0, 0, 1};
    static int[] y4 = {0, -1, 1, 0};

    static int n, m;
    static P[] conditions;

    public static void main(String[] args) {
        input();
        solve();
    }

    static void solve() {
        Arrays.sort(conditions, (P a, P b) -> a.y - b.y);
        int cleared = 0;
        int ans = 1;
        int cut = conditions[cleared].y-1;
        while(cleared < m-1) {
            if(cut >= conditions[cleared+1].x) {
                cleared++;
                continue;
            }else{
                cleared++;
                cut = conditions[cleared].y-1;
                ans++;
            }
        }

        print(ans);
    }

    static void input() {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        m = in.nextInt();
        conditions = new P[m];
        for(int i = 0; i < m; i++) {
            conditions[i] = new P(in.nextInt(), in.nextInt());
        }
    }

    static void print(String s) {
        System.out.println(s);
    }

    static void print(char c) {
        System.out.println(c);
    }

    static void print(int i) {
        System.out.println(i);
    }

    static void print(long i) {
        System.out.println(i);
    }

    static void print(float i) {
        System.out.println(i);
    }

    static void printArray2D(int[][] array, char del) {
        int r = array.length;
        int c = array[0].length;
        for(int i = 0; i < r; i++) {
            for(int j = 0; j < c; j++) {
                System.out.format("%3d", array[i][j]);
                if(j != c-1) System.out.print(del);
                else System.out.print('\n');
            }
        }
    }
}

class P {
    int x, y;
    P(int x, int y) {
        this.x = x;
        this.y = y;
    }
}

Measured memory_bytes: 90916
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    long T1 = scanner.nextLong();
    long T2 = scanner.nextLong();
    long A1 = scanner.nextLong();
    long A2 = scanner.nextLong();
    long B1 = scanner.nextLong();
    long B2 = scanner.nextLong();
    long c1 = A1 * T1 - B1 * T1;
    long c2 = A2 * T2 - B2 * T2;
    if (c1 + c2 == 0) {
      System.out.println("infinity");
      return;
    }
    if ((c1 > 0 && c1 + c2 > 0) || (c1 < 0 && c1 + c2 < 0)) {
      System.out.println(0);
      return;
    }
    long d1 = Math.abs(c1);
    long d2 = Math.abs(c1 + c2);
    long r = d1 / d2 * 2 + 1;
    if (d1 % d2 == 0) r--;
    System.out.println(r);
  }
}


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

using pii = pair<int, int>;

struct edge {
    int to, cost;
};

using edges = vector<edge>;
using graph = vector<edges>;

constexpr int INF = 1e9;

// leaf, far
pair<int, int> dfs(int v, int prev, graph const& g, int sum) {
    pii res = make_pair(0, 0);
    if(g[v].size() == 1 && prev != -1) {
        res.first = g[v][0].cost;
        res.second = sum - g[v][0].cost;
        return res;
    }
    for(auto& e : g[v]) {
        if(e.to == prev) {
            continue;
        }
        pii p2 = dfs(e.to, v, g, sum+e.cost);
        res.first += p2.first;
        res.second = max(res.second, p2.second);
    }
    return res;
}

int main() {
    int n;
    while(cin >> n, n) {
        vector<int> p(n-1), d(n-1);
        for(int i=0; i<n-1; ++i) {
            cin >> p[i];
            p[i]--;
        }
        int sum = 0;
        for(int i=0; i<n-1; ++i) {
            cin >> d[i];
            sum += d[i];
        }
        graph g(n);
        for(int i=0; i<n-1; ++i) {
            g[i+1].push_back(edge{p[i], d[i]});
            g[p[i]].push_back(edge{i+1, d[i]});
        }
        int res = INF;
        for(int i=0; i<n; ++i) {
            pii t = dfs(i, -1, g, 0);
            res = min(res, (sum-t.first)*3 + t.first - t.second);
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3264
import numpy as np
N,K,Q = map(int,input().split())
ans = [K-Q]*N
for i in range(Q):
  seikai = int(input())-1 #0~N-1
  ans[seikai] += 1
for i in range(N):
  if ans[i] > 0:
    print('Yes')
  else:
    print('No')

  

Measured memory_bytes: 20512
#include <stdio.h>
#include <iostream>
using namespace std;
int main(void){
  int s;
  int a[1000000];
  int ans;
  bool flag = false;
  cin >> s;
  a[0] = s;
  for(int i = 1;i < 1000000;i++){
    if(a[i-1]%2 ==  0){
      a[i] = a[i-1]/2;
    } else {
      a[i] = 3*a[i-1] + 1;
    }
    for(int j = 0;j < i;j++){
      if(a[i] == a[j]){
        ans = i + 1;
        flag = true;
        break;
      }
    }
    if(flag){
      break;
    }
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;
const string YES = "Yes";
const string NO = "No";
template <typename T>
void vecin(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
}
template <typename T>
void vecout(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n - 1; ++i)
    {
        cout << v[i] << " ";
    }
    cout << v[n - 1] << endl;
}

void solve(std::string S, std::string T){
    REP(i, S.size()){
        if (S[i] != T[i]){
            cout<<NO<<endl;
            return;
        }
    }
    cout<<YES<<endl;
}

int main(){
    std::string S;
				std::cin >> S;
				std::string T;
				std::cin >> T;
    solve(S, T);
}


Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
char a[5][5] ={{0,0,0,0,0},
	       {0,'A','B','C',0},
	       {0,'D','E','F',0},
	       {0,'G','H','I',0},
	       {0,0,0,0,0}};
char t,b;
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
double dp[22][5][5];
double solve(int e,int x,int y){
  if(!e) return (a[x][y] == t)?1:0;
  if(dp[e][x][y] >= 0) return dp[e][x][y];

  double g = 0;
  int c = 0;
  for(int i = 0; i < 4; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    c++;
    if(a[nx][ny]){
      if(a[nx][ny] == b){
	g += solve(e-1,x,y);
      }else{
	g += solve(e-1,nx,ny);
      }
    }else{
      g += solve(e-1,x,y);
    }
  }
  //printf("%f\n",g);
  return dp[e][x][y] = g / c;
}
int main(void){
  while(1){
    int n;
    scanf("%d",&n); if(!n) break;
    memset(dp,-1,sizeof(dp));
    char s;
    scanf(" %c %c %c",&s,&t,&b);
    s -= 'A';
    printf("%.10f\n",solve(n,s/3+1,s%3+1));
  }
}

Measured memory_bytes: 1072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

const ll Mod = int(1e9) + 7;
ll Pow(ll b, ll e){
	if(e<0) e=(-e)*(Mod-2)%(Mod-1);
	ll ret=1;
	while(e){
		if(e&1) (ret*=b)%=Mod;
		(b*=b)%=Mod; e>>=1;
	}
	return ret;
}

int n, m, k;
ll f[51];

ll tot[51];
void Build(){
	for(int i=1; i<=50; ++i) tot[i]=i;
	for(int i=2; i<=50; ++i){
		if(tot[i] == i) for(int j=i; j<=50; j+=i) tot[j]=tot[j]/i*(i-1);
	}
}
ll necklace(ll color, ll length){
	ll s = 0;
	for(ll d=1; d<=length; ++d) if(length%d == 0){
		(s += tot[d] * Pow(color, length/d)) %= Mod;
	}
	return s*Pow(length, -1) % Mod;
}
ll Comb(ll n, ll r){
	ll ja=1, mo=1;
	for(;r;){
		(mo *= r) %= Mod;
		(ja *= n) %= Mod;
		--n; --r;
	}
	return ja*Pow(mo, -1) % Mod;
}
ll H(ll n, ll r){ return Comb(n+r-1, r); }

vector<int> E[101];
int el[110];
int er[110];

bool vis[110];
int ind[110];
int low[110];
int par[110];
int nt;

void DFS(int x, int p){
	par[x]=p;
	ind[x] = low[x] = ++nt;
	for(int ei:E[x]){ int y=el[ei]+er[ei]-x;
		if(!ind[y]){
			DFS(y, x);
			low[x]=min(low[x], low[y]);
		} else if(y != p){
			low[x]=min(low[x], ind[y]);
		}
	}
}

vector<int> pc[101];
int cc;
bool os[101];
void Color(int x, int c){
	vis[x]=1; os[x]=1;
	for(int ei:E[x]){ int y=el[ei]+er[ei]-x;
		if(os[y] && y!=par[x]){
			pc[c].pb(ei);
			continue;
		}
		if(vis[y]) continue;
		if(ind[x] <= low[y]){
			pc[++cc].pb(ei);
			Color(y, cc);
		} else {
			pc[c].pb(ei);
			Color(y, c);
		}
	}
	os[x]=0;
}

int main()
{
	Build();
	
	read(n, m, k);
	for(int i=1; i<=m; ++i){
		int a, b; read(a, b);
		el[i] = a; er[i] = b;
		E[a].pb(i); E[b].pb(i);
	}
	
	vector<int> dr;
	for(int i=1; i<=n; ++i) if(!ind[i]) dr.pb(i), DFS(i, -1);
	for(int r:dr) Color(r, cc);
	
	ll ans = 1;
	for(int i=1; i<=cc; ++i){
		set<int> Vs;
		for(int ei:pc[i]){
			int a=el[ei], b=er[ei];
			Vs.insert(a);
			Vs.insert(b);
		}
		int V = Vs.size();
		int E = pc[i].size();
		
		//printf("V %d E %d\n", V,E);
		
		if(E == V-1){
			/// tree, in fact V=2 && E=1
			(ans *= k) %= Mod;
		} else if(V == E){
			(ans *= necklace(k, V)) %= Mod;
		} else {
			(ans *= H(k, E)) %= Mod;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  vector<int> x(n), a(n);
  
  
  rep(i,n) {
    cin>>x[i];
    a[i] = x[i];
  }
  
  sort(all(a));
  
  rep(i,n) {
    if(x[i]<=a[n/2-1]) cout<<a[n/2]<<endl;
    else cout<<a[n/2-1]<<endl;
  }
}

Measured memory_bytes: 3840
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    	int line = sc.nextInt();
    	int line2 = sc.nextInt();
      
    	if(line == 1 && line2 == 2){
      		System.out.print(3);
    	}else if(line == 1 && line2 == 3){
      		System.out.print(2);
    	}else if(line == 2 && line2 == 1){
      		System.out.print(3);
    	}else if(line == 2 && line2 == 3){
      		System.out.print(1);
    	}else if(line == 3 && line2 == 1){
      		System.out.print(2);
    	}else if(line == 3 && line2 == 2){
      		System.out.print(1);
    	}
    }
}

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

int main(){
    int n;
  cin>>n;
    vector<int> A(n);
    vector<int> B(n);
    rep(i,n){
        cin >> A.at(i) >> B.at(i);
    }
    sort (A.begin(),A.end());
    sort (B.begin(),B.end());
    int ans =0;
    if(n%2 == 1){
        ans = B.at((n+1)/2-1) - A.at((n+1)/2-1);
    }
    else{
        ans = B.at(n/2-1)+B.at(n/2)-A.at(n/2-1)-A.at(n/2);
    }
      cout << ans+1 << endl;}
    

Measured memory_bytes: 4764
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
//操作の順番
//0:2倍する,1:+1する
vint O;
//操作の順番を決める
void ope(int L){
	if(L==3){
		O.pb(1);
		return;
	}
	if(L==2)
		return;
	ope(L/2);
	if(L&1){
		O.pb(0);
		O.pb(1);
	}
	else{
		O.pb(0);
	}
}
int main(){
	int L;
	cin>>L;
	//辺集合
	vector<tint> E;
	E.eb(1,2,0);
	E.eb(1,2,1);
	//現在の頂点の数
	int node=2;
	//操作を構築する
	ope(L);
	//やる
	int l=2;
	for(int o:O){
		if(o){
			E.eb(1,node,l);
			l++;
		}
		else{
			for(int i=0;i<E.size();i++)
				get<2>(E[i])*=2;
			E.eb(node,node+1,0);
			E.eb(node,node+1,1);
			node++;
			l*=2;
		}
	}
	cout<<node<<" "<<E.size()<<endl;
	for(tint T:E){
		int a,b,c;
		tie(a,b,c)=T;
		cout<<a<<" "<<b<<" "<<c<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int K = scanner.nextInt();
        String S = scanner.next();
        if(S.length() > K) {
            S = S.substring(0,K) + "...";

        }
        System.out.println(S);
    }
}

Measured memory_bytes: 38616
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
#define pb push_back
#define pll pair<ll, ll>
#define mll map<ll, ll>
#define ff first
#define oo 1000000000000000005
#define ss second
#define el "\n"
#define maxS 200005
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    // ll t;cin>>t;while(t--)
    {
        ll n, k;
        cin>>n>>k;
        
        ll a[n+1];
        for(ll i=1 ; i<n+1 ; i++)
            cin>>a[i];
        
        vector<ll> cycle, vis(n+1, 0), tmp;
        // vis[1] = 1;
        ll pos = 1;
        // cycle.pb(1);
        
        while(!vis[pos])
        {
            vis[pos] = 1;
            tmp.pb(pos);
            pos = a[pos];
        }
        
        // pos = a[pos];
        
        ll sz = tmp.size();
        for(ll i=0 ; i<sz ; i++)
        {
            if(tmp[i] != pos)
                continue;
            else
                while(i<sz)
                    cycle.pb(tmp[i++]);
        }
        
        // for(auto it : cycle)
        //     cout<<it<<" ";
        // cout<<el;
        
        if(k <= sz-1)
            cout<<tmp[k];
        else
        {
            if(cycle[0] != 1)
            {
                k -= sz-1;
                k %= cycle.size();
                if(k != 0)
                    cout<<cycle[k-1];
                else
                    cout<<cycle[cycle.size()-1];
            }
            else
            {
                k %= cycle.size();
                cout<<cycle[k];
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 10732
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 114514
int N;
int A[MAX_N];
int B[MAX_N];
int main()
{
	while(true){
		scanf("%d",&N);
		if(N==0)return 0;
		for(int i=0;i<N;i++){
			scanf("%d",&A[i]);
		}
		for(int i=0;i<N;i++){
			scanf("%d",&B[i]);
		}
		sort(A,A+N);reverse(A,A+N);
		sort(B,B+N);reverse(B,B+N);
		int ina=0,inb=0;
		bool F=true;
		while(ina<N-1&&inb<N){
			if(A[ina]<=B[inb])inb++;
			else ina++;
			if(ina>2*inb){
				printf("%d\n",ina);
				F=false;
				break;
			}
		}
		if(F)printf("NA\n");
	}
}

Measured memory_bytes: 3544