akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	const int M=1000000007;
	int n;
	cin>>n;
	n<<=1;
	string s;
	cin>>s;
	ll res=1,o=0;
	for(int i=0;i<n;++i){
		if(i<n/2)
			res=res*(i+1)%M;
		int x=(s[i]=='B')^(o&1);
		if(x)
			++o;
		else{
			res=(res*o)%M;
			--o;
		}
	}
	if(o)
		res=0;
	cout<<res<<endl;
	return 0;
}

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

int n,k,val[100005];

int main()
{
    cin>>n>>k;
    int koi;
    for(int i=1;i<=n;i++)
    {
        cin>>val[i];
        if(val[i]==1) koi=i;
    }
    cout<<(n-1+k-2)/(k-1)<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 100005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int dp[N];
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,m;
   cin>>n>>m;
   map<int,int>mp;
   for(int i=0;i<m;i++)
   {
       int x;
       cin>>x;
       mp[x]=1;
   }
   dp[0]=1;
   for(int i=1;i<=n;i++)
   {
       if(i>=1 && !mp[i])
       {
           dp[i]+=dp[i-1];
           dp[i]%=M;
       }
       if(i>=2 && !mp[i])
       {
           dp[i]+=dp[i-2];
           dp[i]%=M;
       }
   }
   cout<<dp[n]%M<<endl;

}



Measured memory_bytes: 7296
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int n;
    string s;
    cin >> n >> s;

    int ans = 0;
    int tem = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'I') {
            tem++;
        } else {
            tem--;
        }

        ans = max(ans, tem);
    }

    cout << ans << endl;

    return 0;
}


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

const int INF = 1 << 29;        // 十分大きい値にする

string S, T;

// DP テーブル
int dp[3010][3010];

int main() {
	cin >> S >> T;

	memset(dp, 0, sizeof(dp));    // 初期化
	for (int i = 0; i < S.size(); ++i) {
		for (int j = 0; j < T.size(); ++j) {
			if (S[i] == T[j]) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
			dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]);
			dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]);
		}
	}

	string res = "";
	int i=(int)S.size(), j=(int)T.size();
	while (i > 0 && j > 0) {
		if(dp[i][j] == dp[i-1][j]) i--;
		else if(dp[i][j] == dp[i][j-1]) j--;
		else {
			res = S[i-1] + res;
			i--; j--;
		}
	}

	cout << res << endl;
}


Measured memory_bytes: 35712
n = int(input())
dic = {}
for i in range(n):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

cnt = 0
for i, j in dic.items():
    cnt = max(cnt, j)
ans = []
for i, j in dic.items():
    if cnt == j:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 92376
#include <bits/stdc++.h>
using namespace std;
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<pii>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define mod 998244353
#define MAX 1000000001

int main(){
	fast;
	int test=1;
	//cin >> test;
	while(test--){
	    int k;
	    cin >> k;
	    for(int i=0 ; i<k ; i++){
	        cout << "ACL";
	    }
	}
	return 0;
}

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

int main(){
  int n; cin >>n;
  if(n%1000==0) cout << 0 << endl;
  else cout << 1000-(n%1000) << endl;
  return 0; 
}

Measured memory_bytes: 3632
main =do
    n <- getLine
    ai <- map read . words <$> getLine :: IO [Int]
    bi <- map read . words <$> getLine :: IO [Int]
    ci <- map read . words <$> getLine :: IO [Int]
    let ai_init = init ai
    let ai_tail = tail ai
    print $  (sum [bi!!(x-1) | x <- ai]) + (sum [ci!!((ai_init!!x)-1) | x<-[0..((length ai)-2)], (ai_tail!!x) - (ai_init!!x) == 1])


Measured memory_bytes: 3976
import math
d,g = map(int,input().split())
p = [0 for i in range(d)]
c = [0 for i in range(d)]
for i in range(d):
    p[i],c[i] = [int(j) for j in input().split()]

mn = 10**18
for i in range(2**d):
    ii = i
    ni = 0
    mh = -1
    pi = 0
    for j in range(d):
        if ii&1 == 1:
            pi += p[j]*(j+1)*100+c[j]
            ni += p[j]
        else:
            mh = j
        ii >>= 1
    res = g-pi
    if res > (p[mh]-1)*(mh+1)*100:
        continue
    elif 0 < res:
        ni += math.ceil(res/((mh+1)*100))
    if mn > ni:
        mn = ni

print(mn)


Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int c[][] = new int[3][3];
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) {
				c[i][j] = sc.nextInt();
			}
		}
		
		for(int a1 = 0; a1 <= 100; a1++) {
			int b1 = c[0][0] - a1;
			int b2 = c[0][1] - a1;
			int b3 = c[0][2] - a1;
			int a2 = c[1][0] - b1;
			int a3 = c[2][0] - b1;
			if(a2 + b2 == c[1][1] && a2 + b3 == c[1][2] && a3 + b2 == c[2][1] && a3 + b3 == c[2][2]) {
				System.out.println("Yes");
				return;
			}
		}
		
		System.out.println("No");
	}
}


Measured memory_bytes: 25172
#include <iostream>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    int k, food[m], cnt = 0;
    for(int i = 0; i < m; i++) food[i] = 0;
    for(int i = 0; i < n; i++) {
        cin >> k;
        int a;
        for(int j = 0; j < k; j++) {
            cin >> a;
            food[a-1]++;
        }
        cnt++;
    }
    int ans = 0;
    for(int i = 0; i < m; i++) 
        if(food[i] == cnt) ans++;
    cout << ans << endl;
    return 0;
}

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

int main(void){
  int sx, sy, tx, ty;

  cin >> sx >> sy >> tx >> ty;

  int height = ty - sy;
  int width  = tx - sx;

  for(int i = 0; i < height; i ++)
    cout << "U";
  for(int i = 0; i < width; i ++)
    cout << "R";
  for(int i = 0; i < height; i ++)
    cout << "D";
  for(int i = 0; i < width+1; i ++)
    cout << "L";
  for(int i = 0; i < height+1; i ++)
    cout << "U";
  for(int i = 0; i < width+1; i ++)
    cout << "R";

  cout << "D";
  cout << "R";

  for(int i = 0; i < height+1; i ++)
    cout << "D";
  for(int i = 0; i < width+1; i ++)
    cout << "L";

  cout << "U";
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.*
import java.util.*

const val A = 0
const val B = 1
const val C = 2
fun solve(N: Int, a: IntArray, b: IntArray, c: IntArray) {
    val dp = Array(3) { LongArray(N) }
    dp[A][0] = a[0].toLong()
    dp[B][0] = b[0].toLong()
    dp[C][0] = c[0].toLong()
    for (i in 1 until N) {
        dp[A][i] = a[i] + Math.max(dp[B][i - 1], dp[C][i - 1])
        dp[B][i] = b[i] + Math.max(dp[C][i - 1], dp[A][i - 1])
        dp[C][i] = c[i] + Math.max(dp[A][i - 1], dp[B][i - 1])
    }
    // for (i in 0 until N){
    //     println("${dp[A][i]} ${dp[B][i]} ${dp[C][i]}")
    // }
    val ans = setOf(dp[A][N - 1], dp[B][N - 1], dp[C][N - 1]).max()!!
    println(ans)
    return
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val a = IntArray(N)
    val b = IntArray(N)
    val c = IntArray(N)
    for (i in 0 until N) {
        a[i] = sc.next().toInt()
        b[i] = sc.next().toInt()
        c[i] = sc.next().toInt()
    }
    solve(N, a, b, c)
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

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

    if (A > 8 or B > 8) {
        cout << ":(" << endl;
    }
    else {
        cout << "Yay!" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# coding: utf-8

# In[ ]:

# oj d [URL] -d test/A
# oj d [URL] -d test/B
# oj d [URL] -d test/C
# oj d [URL] -d test/D
# oj d [URL] -d test/E
# oj d [URL] -d test/F

# oj t -c "python A.py" -d test/A
# oj t -c "python A.py" -d test/B
# oj t -c "python A.py" -d test/C
# oj t -c "python A.py" -d test/D
# oj t -c "python A.py" -d test/E
# oj t -c "python A.py" -d test/F

S = input()
jdg = False
for i in range(1,6):
    if S == "hi"*i:
        jdg = True
if jdg:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

string change_to_s(int n){
    stringstream ss; ss<<n;
    return ss.str();
}

signed main(){
    int n;
    cin >> n;
    int MIN = 1e9;
    for(int i = 1; i * i <= n; i++){
        if(n % i == 0){
            int d = n / i;
            string s = change_to_s(i);
            string t = change_to_s(d);
            MIN = min(MIN, max((int)s.size(), (int)t.size()));
        }
    }
    cout << MIN << endl;
}

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


int main() {
    ll a; cin>>a;
    double b; cin>>b;
    ll ib=b*100+0.1;
    a*=ib;
    a/=100;
    cout<<a<<endl;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define pri 1000000007
using namespace std;
ll q,n;
bool chec(ll cur,char qu[][2],ll op,string a){
	ll j=0;
//	cout<<cur<<"ss"<<endl;
	while(j<q){
	//	cout<<j<<cur<<a[cur]<<qu[j][0]<<endl;
	if(a[cur]==qu[j][0]){
	//if(cur==3)	cout<<cur<<j<<endl;
		if(qu[j][1]=='L'){cur--;}
		else {cur++;}
	}
	j++;
		
	if(cur==n){
		if(op==1)return 1;
		else return 0;
	}	
	if(cur==-1){
		if(op==0)return 1;
		else return 0;
		
	}
	}
	return 0;
}
void run(){
	cin>>n>>q;
    string a;
    cin>>a;
    char ta[q][2];
    for(ll i=0;i<q;i++){
    	
    	cin>>ta[i][0]>>ta[i][1];
    	}
    ll init=0,fin=n-1;
    ll vs=n;
    while(fin>=init){
    	ll mid=(init+fin)/2;
    	//cout<<mid<<" "<<chec(mid,ta,1,a);

    	if(chec(mid,ta,1,a)){
    	
    		vs=min(vs,mid);
    			fin=mid-1;
    	}
    	else{
    		init=mid+1;
    	}
    }
   
    ll ans=0;
  for(ll j=vs-1;j>=max(vs-2,ans);j--){
  	if(chec(j,ta,1,a)==1){vs=j;}
  }
  
 //cout<<vs;
     ans+=n-(vs);
     
  
      init=0,fin=n-1;
       vs=-1;
       
    while(fin>=init){
         ll mid=(init+fin)/2;
    //if(fin==0||mid==n)break;
    		//cout<<mid<<" "<<chec(mid,ta,0,a);
    	
    	if(chec(mid,ta,0,a)){
    		vs=max(vs,mid);
    		init=mid+1;
    	}
    	else{
    		fin=mid-1;
    	}
    }
   for(ll j=vs+1;j<min(vs+3,n);j++){
  	if(chec(j,ta,0,a)==1)vs=j;
  }
    ans+=(vs+1);
   // cout<<vs<<endl;
	cout<<n-ans<<endl;
	
}
int main() {
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)run();
	// your code goes here
	return 0;
}

Measured memory_bytes: 1156
n=int(input())
a,b=map(int,input().split())
p =list(map(int,input().split()))
e=f=g=0
for i in p:
    if i<=a:
        e+=1
    elif i>=a and i<=b:
        f+=1
    else:
        g+=1
print(min(e,f,g))

Measured memory_bytes: 3064
#include <stdio.h>

int main() {
	int a, b, c, d;
	scanf("%d %d", &a, &b);
	
	if(a < 10) {
		c = 100 * (10 - a);
		d = b + c;
		printf("%d", d);
	} else {
		printf("%d", b);
	}
	
	return 0;
}

Measured memory_bytes: 3216
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int d[55];

int solve() {
    map<int, int> m;
    for (int i = 0; i < n; i++) {
        m[d[i]]++;
        if (d[i] == 0 || (d[i] == 12 && m[d[i]] >= 2) || m[d[i]] >= 3) {
            return 0;
        }
    }

    vector<int> s;
    vector<int> b;
    b.push_back(0);
    b.push_back(24);
    for (auto v : m) {
        if (v.first != 12 && v.second == 1) {
            s.push_back(v.first);
        } else if (v.first == 12) {
            b.push_back(12);
        } else {
            b.push_back(v.first);
            b.push_back(24-v.first);
        }
    }
    const int l = (int)s.size();
    int res = 0;
    for (int i = 0; i < (1<<l); i++) {
        vector<int> c = b;
        for (int j = 0; j < l; j++) {
            if ((i>>j)&1) {
                c.push_back(s[j]);
            } else {
                c.push_back(24-s[j]);
            }
        }
        sort(ALL(c));
        int g = inf;
        for (int j = 0; j < (int)c.size()-1; j++) {
            g = min(g, c[j+1]-c[j]);
        }
        res = max(res, g);
    }
    return res;
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> d[i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3612
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 200000
#define mod 998244353
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

const int g=3;
ll wn[30][2];
int r[maxn+5],n2,len;
ll inv[maxn+5],fac[maxn+5],ifac[maxn+5];

ll C(int n,int m)
{
    if(m<0 || n-m<0) return 0;
    return fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

ll qp(ll a,int k)
{
    ll ans=1;
    while(k)
    {
        if(k&1) ans=ans*a%mod;
        a=a*a%mod;
        k>>=1;
    }
    return ans;
}
void init()
{
    rep(i,0,20)
    {
        wn[i][0]=qp(g,(mod-1)/(1<<i));
        wn[i][1]=qp(wn[i][0],mod-2);
    }
}

void NTT(vector<ll> &a,int opt)
{
    rep(i,1,n2-1) if(r[i]>i) swap(a[i],a[r[i]]);
    rep(t,0,len-1)
    {
        int step=1<<t,step2=1<<t+1;
        ll w=wn[t+1][opt];
        for(int i=0;i<n2;i+=step2)
        {
            ll wj=1;
            rep(j,0,step-1)
            {
                ll tmp=wj*a[i+j+step]%mod;
                a[i+j+step]=(a[i+j]-tmp+mod)%mod;
                a[i+j]=(a[i+j]+tmp)%mod;
                wj=wj*w%mod;
            }
        }
    }
}

void conv(vector<ll> &A,vector<ll> &B)
{
    int n=A.size()+B.size()-1;
    len=0;
    for(n2=1;n2<n;n2<<=1) len++;
    rep(i,0,n2-1) r[i]=(r[i>>1]>>1)|((i&1)<<len-1);
    A.resize(n2,0);
    B.resize(n2,0);
    NTT(A,0);
    NTT(B,0);
    rep(i,0,n2-1) A[i]=A[i]*B[i]%mod;
    NTT(A,1);
    rep(i,0,n2-1) A[i]=A[i]*inv[n2]%mod;
    A.resize(n);
}

int cnt[maxn+5];
ll f[maxn+5];

vector<ll> dfs(int L,int R)
{
    if(L==R)
    {
        vector<ll> res;
        res.pb(1);
        for(int i=1;i*2<=cnt[L];i++) res.pb(C(cnt[L],i*2)*f[i]%mod);
        return res;
    }
    int mid=(L+R)>>1;
    auto A=dfs(L,mid);
    auto B=dfs(mid+1,R);
    conv(A,B);
    return A;
} 


int main()
{
    inv[1]=fac[0]=ifac[0]=1;
    rep(i,2,maxn) inv[i]=inv[mod%i]*(mod-mod/i)%mod;
    rep(i,1,maxn) fac[i]=fac[i-1]*i%mod;
    rep(i,1,maxn) ifac[i]=ifac[i-1]*inv[i]%mod;
    init();

    f[0]=1;
    rep(i,1,maxn) f[i]=f[i-1]*(2*i-1)%mod;
    
    int n; scanf("%d",&n);
    rep(i,1,n*2)
    {
        int x; scanf("%d",&x); cnt[x]++;
    } 
    auto res=dfs(1,100000);
    int N=res.size();
    ll ans=0;
    rep(i,0,N-1)
    {
        //printf("? %d: %lld\n",i,res[i]);
        if(i&1) ans=(ans+mod-res[i]*f[n-i]%mod)%mod;
        else ans=(ans+res[i]*f[n-i])%mod;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 12020
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
typedef long long ll;

int main(){
	string s;
	cin >> s;
	
	vector<char> ans;
	for(int i=0; i<s.size(); i+=2){
		ans.push_back(s[i]);
	}
	REP(i,ans.size()) cout << ans[i];
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 3664
N, K = map(int, input().split())
s = [0] * (N + 2)
for i in range(1, N + 1):
    s[i + 1] = s[i] + i
#s
s_rev = [0] * (N + 2)
for i in range(N, -1, -1):
    s_rev[N - i + 1] = s_rev[N - i] + i
#s_rev
ans = 0
mod = 10 ** 9 + 7
for i in range(K, N + 2):
    #print(s_rev[i] - (s[i] - 1))
    ans += (s_rev[i] - (s[i] - 1)) % mod
print(ans % mod)

Measured memory_bytes: 30228
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct frep {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr frep(int l_, int r_): l(std::min(l_, r_)), r(r_) {}
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct brep {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr brep(int r_, int l_): r(std::max(l_, r_) - 1), l(l_ - 1) {}
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
inline T scan() {
  T res;
  std::cin >> res;
  return res;
}

int main() {
  int N, M;
  std::cin >> N >> M;
  std::cout << (N == M ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    String input = sc.next();
    char in[] = new char[3];
    for (int i = 0; i < 3; i++) {
      in[i] = input.charAt(i);
      if (in[i] == '1') {
        in[i] = 9;
      } else if (in[i] == '9') {
        in[i] = 1;
      }
    }

    int ans = in[0] * 100 + in[1] * 10 + in[2];
    System.out.println(ans);
  }
}

Measured memory_bytes: 22736
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#include <iomanip>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 5;
const int Mod = 1e9 + 7;
LL f(LL x){
    if(x == -1) return 0;
    switch (x % 4)
    {
    case 0:
        return x;
    case 1 :
        return 1;
    case 2:
        return x + 1;
    case  3 :
        return 0;
    }
}
int main()
{
    LL A, B;
    cin >> A >> B;
    cout << (f(B)^f(A-1)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll sum = 0;
	rep(i, n) sum ^= a[i];
	rep(i, n) {
		sum ^= a[i];
		cout << sum << (i == n - 1 ? "\n" : " ");
		sum ^= a[i];
	}
	return 0;
}


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

int main(){
    int N;cin >> N;
    vector<pair< ll, ll> > pairs(N);
    for(int i = 0; i < N; i++){
        ll x,y; cin >> x >> y;
        pairs[i] = make_pair(x,y);
    }
    sort(pairs.begin(), pairs.end());
    ll min = 1LL <<50;
    if(N >= 2){
        for(int i = 0; i < N; i++){
            for(int j = i + 1; j < N; j++){
                ll p = pairs[j].first - pairs[i].first;
                ll q = pairs[j].second - pairs[i].second;
                //cout << p << " " << q << endl;
                vector<pair <ll, ll> > listpair;
                listpair.push_back(pairs[j]);
                int cost = 1;
                for(int k = 0; k < N; k++){
                    if(k != i && k != j){
                        bool flag = 1;
                        for(int l = 0; l < listpair.size(); l++){
                            if(listpair[l].first + p == pairs[k].first && listpair[l].second + q == pairs[k].second ){
                                listpair[l] = pairs[k];
                                flag = 0;
                                break;
                            }
                        }
                        if(flag){
                            listpair.push_back(pairs[k]);
                            cost++;
                        }
                    }
                }
                if(cost < min) min = cost;
                //cout << i << " " << j << " " << min << endl;
            }
        }
        cout << min << endl;
    }
    else{
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int len; cin>>len;
    string  s; cin >> s;
    int  f=0,se=0;
    for (int i=0;i<len;i++){
        if (s[i]==')') {
            if (f) f--;
            else se++;
        }
        else f++;
    } 
    for (int i=0;i<se;i++) cout << "(";
    cout << s;
    for (int i=0;i<f;i++) cout << ")";
    cout << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3580
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>
#include <atcoder/dsu>

using namespace std;
using namespace atcoder;

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

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 998244353;

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 int n,q,t,u,v;
 cin>>n>>q;
 dsu d(n);
 while (q--) {
   cin>>t>>u>>v;
   if(t == 0) d.merge(u,v);
   else cout<<d.same(u,v)<<endl;
 }


 return 0;
}


Measured memory_bytes: 3872
#include <iostream>
#include <vector>
#include <algorithm>

int main(){

    int N,M;
    std::cin>>N>>M;

    std::vector<int> x(M);
    for (auto i = x.begin(); i != x.end(); i++ ){
      std::cin>>*i;
    }

    if(N>=M){
      std::cout<<0<<std::endl;
    }else{
      std::sort(x.begin(),x.end());
      int sum = *(x.end()-1) - *(x.begin());
      for (auto i = x.begin(); i != x.end();i++ ){
        if(i != x.end()-1){
          *i = *(i+1) - *i;
        }else{
          *i = 0;
        }
      }
      std::sort(x.begin(),x.end());
      int minus = 0;
      for (auto i = x.crbegin(); i - x.crbegin() != N-1; i++){
        minus += *i;
      }
      std::cout<<sum - minus<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 640
<?php
  
  $n = intval(fgets(STDIN));

  $a = explode(" ", trim(fgets(STDIN)));
  $result = [];

  for($i=0; $i<$n; $i++){
    $jun = $a[$i];
    $result[$jun] = $i+1;
  }

  $str = "";
  for($i=0; $i<$n; $i++){
    $str .= $result[$i+1]." ";
  }

  echo substr($str, 0, -1);

Measured memory_bytes: 19188
#include <iostream>
#include <string>
//#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
//#include <unordered_map>
#include <stack>

using namespace std;

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

int H,W;
char S[25][25];
int Number[25][25];

int d[410][410];

int main() {	

	cin >> H >> W;

	rep(i, 25) {
		rep(j, 25) {
			Number[i][j] = -1;
			S[i][j] = '#';
		}
	}

	rep(i, 410) {
		rep(j, 410) {
			d[i][j] = INF+5;
			if (i == j)d[i][j] = 0;
		}
	}

	int N = 0;
	rep(i, H) {
		rep(j, W) {
			cin >> S[i][j];
			if (S[i][j] == '.'){ Number[i][j] = N; N++; }
		}
	}

	int V = N;
	rep(i, H) {
		rep(j, W) {
			if (Number[i][j] >= 0) {
				if (Number[i][j + 1] >= 0) {
					d[Number[i][j]][Number[i][j + 1]] = 1;
					d[Number[i][j + 1]][Number[i][j]] = 1;
				}
				if (Number[i+1][j] >= 0) {
					d[Number[i][j]][Number[i + 1][j]] = 1;
					d[Number[i + 1][j]][Number[i][j]] = 1;
				}
			}
		}
	}
	
	for (int k = 0; k < V; k++)
		for (int i = 0; i < V; i++)
			for (int j = 0; j < V; j++)
			{
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				//d[j][i] = d[i][j];
			}

	int max = 0;
	rep(i, V) {
		rep(j, V) {
			if (d[i][j] < INF && d[i][j] > max)max = d[i][j];
		}
	}
	
	cout << max << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
//-----------------------------------------

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

  vector<int> a;
  int q;
  cin >> q;
  REP(i,q){
    int com;
    cin >> com;
    if(com == 2) a.pop_back();
    else{
      int x;
      cin >> x;
      if(com == 0) a.push_back(x);
      else cout << a[x] <<endl;
    }
  }


  return 0;
}




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

int main()
{
    int n, m, l;

    cin >> n >> m >> l;

    int a[128][128] = {0};
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }

    int b[128][128] = {0};
    for (int i = 0; i < m; i++){
        for (int j = 0; j < l; j++){
            cin >> b[i][j];
        }
    }

    for (int i = 0; i < n; i++){
        for (int j = 0; j < l; j++){
            long long c = 0;
            for (int k = 0; k < m; k++){
                c += a[i][k] * b[k][j];
            }
            cout << c << "\n "[j < l - 1];
        }
    }

    return 0;
}

Measured memory_bytes: 1292
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int n, m;
  readf("%s %s\n", &n, &m);
  auto a = new char[][](n, n);
  auto b = new char[][](m, m);
  foreach (i; 0..n) {
    a[i] = readln.chomp.to!(char[]);
  }
  foreach (i; 0..m) {
    b[i] = readln.chomp.to!(char[]);
  }

  bool f;
  foreach (i; 0..n-m+1) {
    a:foreach (j; 0..n-m+1) {
      foreach (x; 0..m) {
        foreach (y; 0..m) {
          if (a[i+x][j+y] != b[x][y]) {
            continue a;
          }
        }
      }
      f = true;
    }
  }

  if (f) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;

#define INX(x) (cin >> x)
#define OUTX(x) (cout << x << endl)

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>


int main()
{
    ll N;
    INX(N);

    vll L(N);
    for (ll i = 0; i < N; i++)
    {
        INX(L[i]);
    }

    ll result = 0;
    for (ll i = 0; i < N; i++)
    {
        ll a = L[i];
        for (ll j = i + 1; j < N; j++)
        {
            ll b = L[j];
            if(a == b)
            {
                continue;
            }

            for (ll k = j + 1; k < N; k++)
            {
                ll c = L[k];
                if(a == c || b == c)
                {
                    continue;
                }

                if(a + b > c && b + c > a && c + a > b)
                {
                    result++;
                }
            }
        }
    }
    OUTX(result);
    




    return 0;
}


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

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

int main() {
    int n; cin >> n;
    int sum = 0, m = 100;
    for(int i = 0; i < n; i++){
        int s; cin >> s;
        sum += s;
        if(s % 10 != 0){
            m = min(m, s);
        }
    }
    if(sum % 10 == 0 && m != 100) cout << sum - m << endl;
    else if(sum % 10 != 0) cout << sum << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,i;
  cin >> n;
  string s1,s2;
  int t=0,h=0;
   
  for(i=0;i<n;i++){
    cin >> s1 >> s2;
    if(s1.compare(s2)==0) {
      t++;h++;
    }else if(s1.compare(s2)>0) t+=3;
    else h+=3;
  }
  cout << t << " " << h << endl;
}


Measured memory_bytes: 3160
n = int(input())
sn = sorted([int(input()) for _ in range(n)])
sum_sn = sum(sn)
answer = sum_sn
i = 0
while i < n and sn[i] % 10 == 0:
    i += 1
if i == n:
    print(0)
else:
    print(answer-sn[i] if answer % 10 == 0 else answer)


Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
    int n=0,i;
    long long int a[10001]={0},s=1000000,b=-1000000,g=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    for(i=0;i<n;i++){
        if(s>=a[i]){
            s=a[i];
        }
        }

    for(i=0;i<n;i++){
        if(b<a[i]){
            b=a[i];
        }
    }
    for(i=0;i<n;i++){
        g=g+a[i];
    }
    printf("%lld %lld %lld\n",s,b,g);
return 0;
}

Measured memory_bytes: 688
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define inf INT_MAX
#define MOD 1000000007
#define MEM(a,b) memset(a,(b),sizeof(a))
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;

const int N = 10;
int H, W, temp, s = 1;
int a[N+2][N+2];

void floydWarshall(){
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(a[i][j] > a[i][k]+a[k][j]){
                    //cout << i << "," << j << " => " << a[i][j] << " => ";
                    a[i][j] = a[i][k]+a[k][j];
                    //cout << a[i][j] << "\n";
                }
            }
        }
    }
}

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

    cin >> H >> W;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cin >> a[i][j];
        }
    }
    floydWarshall();
    int MP = 0;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin >> temp;
            //cout << temp << " ";
            if(temp == -1 || temp == 1){continue;}else{
                MP += a[temp][1];
            }
        }//cout << "\n";
    }
    cout << MP << "\n";
    return 0;
}

Measured memory_bytes: 256
n = input()
li = [n[0],n[1],n[2],n[3]]
pm = [[1,1,1],[1,1,0],[1,0,1],[1,0,0],[0,1,1],[0,1,0],[0,0,1],[0,0,0]]
s = ""

for i in range(8):
    for j in range(3):
        if pm[i][j]==1:
            pm[i][j]="+"
        elif pm[i][j]==0:
            pm[i][j]="-"

for j in range(8):
    s = li[0]+pm[j][0]+li[1]+pm[j][1]+li[2]+pm[j][2]+li[3]
    if eval(s)==7:
        break
print(s+"=7")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

template <class T, class F>
T UpperBound(T i0, T i1, F f) {
    while (i0 < i1) {
        T i = (i0 + i1) / 2;
        if (f(i)) i0 = i + 1; else i1 = i;
    }
    return i0;
}

int main() {
    int n, m, v, p;
    cin >> n >> m >> v >> p;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<>());

    auto i = UpperBound<int>(p, n, [&](auto i) {
        int d = a[p - 1] - a[i];//これだけ増やす必要がある
        if (d > m) return false;
        if (d == 0) return true;

        ll r = (ll)m * v;
        r -= (p - 1) * (ll)m + (ll)m + (n - 1 - i) * (ll)m;
        if (r <= 0) return true;

        for (int j = p - 1; j < i; j++) {
            r -= (a[i] + m) - a[j];
        }
        if (r <= 0) return true;

        return false;
    });

    cout << i << endl;

    //上位P問と同じやつは採用される
    //ある問題を採用させたいとき、ライバルは無投票で採用される可能性のあるやつを除いた自分より真に上位のやつら
    // [9 8 8] 8 7 7 7 6 5
    //自分には必ず投票させるので自分以下のやつらに追い越されることはない 上位のやつらにも投票していい
    //Mが小さいときは自分以下に投票し続ければいいが、分散させるという手もあるので ライバルにも余裕があるので余裕ぶんは
    //Mが小さいと分散させづらい VはN未満 半分以下だと何か嬉しいか？
    //そういえば二分探索できるね
    //配り方としては、合計がM*VでmaxがM以下なら何でもできる？

    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <regex>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;

const int MOD = 1e9+7;

int main(void){
  ll n;
  cin >> n;
  ll ans = 1;
  ll a;
  vector<ll> s(n, 0);
  for(ll i = 0;i < n;  i++){
    cin >> a;
    s[a]++;
  }
  if (n % 2 == 1){
    if(s[0] != 1){
      cout << "0" << endl;
      return 0;
    }
    for(ll i = 2;i < n; i += 2){
      if(s[i] != 2){
        cout << "0" << endl;
        return 0;
      }else{
        (ans *= 2) %= MOD;
      }
    }
  }else{
    for(ll i = 1;i < n; i += 2){
      if(s[i] != 2){
        cout << "0" << endl;
        return 0;
      }else{
        (ans *= 2) %= MOD;
      }
    }
  }
  cout << ans << endl;
  return 0;
 }

Measured memory_bytes: 1024
#!/usr/bin/python
# -*- coding: UTF-8 -*-
i = input()
n = map(int, raw_input().split())
cnt=0

#リストの一番手前からみる。
for i in xrange(len(n)):
#いま見てる番目を記憶
    min=i
#フラグ判定を0で初期化
    flag=0
#リストの二番目から最後は一つ手前まで
    for j in xrange(i,len(n)):
        if n[j]<n[min]:
#より小さい値の順番目を記憶する。
#このifの中に入っていると入れ替え処理候補が有ったことになるのでフラグを立てる。
            min=j
            flag=1
#当初の比較のために取り出してきた値と発見した最小の値を入れ替える。
    n[i],n[min]=n[min],n[i]
    cnt+=flag
print ' '.join(map(str,n))
print cnt

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
ll test[1234][1234];
signed main() {
	ll n = 0, mae = 0, ato = 0; string maes = "", atos = "";
	cin >> n; ato = n;
	cout << 0 << endl << flush; cin >> maes;
	if (maes == "Vacant") { return 0; }
	for (int h = 0; h < 20; h++) {
		string s; ll naka = (mae + ato) / 2;
		cout << naka << endl << flush; cin >> s;
		if (s == "Vacant") { return 0; }
		if ((naka - mae) % 2 == 1) {
			if (maes == s) {
				atos = s; ato = naka;
			}
			else {
				maes = s; mae = naka;
			}
		}
		else {
			if (maes == s) {
				maes = s; mae = naka;
			}
			else {
				atos = s; ato = naka;
			}
		}
	}
	cin >> n; return 0;
}

Measured memory_bytes: 852
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc160_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (s[2]==s[3] && s[4] ==s[5])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.Read();
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template<typename T>
struct BinaryIndexedTree{
    vector<T> data;
    int sz;

    BinaryIndexedTree(int n){
        sz = n + 2;
        data.assign(sz, 0);
    }

    void add(int i, T x){
        ++i;
        while(i < sz){
            data[i] += x;
            i += i & -i;
        }
    }

    // [0, i] の区間和
    T sum(int i){
        T res = 0;
        ++i;
        while(i > 0){
            res += data[i];
            i -= i & -i;
        }
        return res;
    }

    // [l, r) の区間和
    T sum(int l, int r){
        return sum(r - 1) - sum(l - 1);
    }

    // val 以上を満たす 0-indexed の位置を返す
    int lower_bound(T val){
        // if(val <= 0)    return -1;
        int res = 0;
        int n = 1;
        while(n < sz)   n <<= 1;
        for(int k = n >> 1; k > 0; k >>= 1){
            if(res + k < sz && data[res + k] < val){
                val -= data[res + k];
                res += k;
            }
        }
        return res;     // 1-indexed であれば、res + 1 を返す
    }
};

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

    int N, Q, a;
    cin >> N >> Q;
    BinaryIndexedTree<ll> bit(N);
    for(int i = 0; i < N; ++i){
        cin >> a;
        bit.add(i, a);
    }
    for(int i = 0; i < Q; ++i){
        int t;
        cin >> t;
        if(t){
            int l, r;
            cin >> l >> r;
            cout << bit.sum(l, r) << '\n';
        }
        else{
            int p, x;
            cin >> p >> x;
            bit.add(p, x);
        }
    }
}

Measured memory_bytes: 8256
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    string st;
    cin >> st;
    if(st=="ABC")
    	cout << "ARC";
    else cout << "ABC";
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define int long long
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const int MOD = 998244353;

int N, S;
int A[3010];
int dp[3010][3010];

signed main() {
    //cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> S;
    rep(i, N) cin >> A[i];
    dp[0][0] = 1;
    rep(i, N+1) rep(j, S) {
        dp[i+1][j] += dp[i][j];
        dp[i+1][j] %= MOD;
        if (j+A[i]<=S) {
            if (j==0) dp[i+1][A[i]] = i+1;
            else {
                dp[i+1][j+A[i]] += dp[i][j];
                dp[i+1][j+A[i]] %= MOD;
            }
        }
    }
    int ans = 0;
    rep(i, N+1) {
        ans += dp[i][S]*(N-i+1);
        ans %= MOD;
    }
    cout << ans << endl;
}

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


int n, m;
int unitree[300010];

int init(){
  for(int i = 0;i < 300010;i++){
    unitree[i] = i;
  }
}

int root(int i){
  if(unitree[i] == i) return i;
  return unitree[i] = root(unitree[i]);
}

int unite(int i, int j){
  i = root(i);
  j = root(j);
  if(i != j){
    unitree[max(i, j)] = min(i, j);
  }
}

bool find(int i, int j){
  return root(i) == root(j);
}

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

  int k;
  init();
  for(int i = 0;i < n;i++){
    cin >> k;
    for(int j = 0;j < k;j++){
      int x;
      cin >> x;
      unite(i, n+x);
    }
  }

  for(int i = 1;i < n;i++){
    if(!find(0, i)){
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;

  return 0;
}


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

// output
#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
// utility
#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 T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#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;


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

  vector<int> r(R);
  REP(i, R){
    cin >> r[i];
    r[i]--;
  }
  sort(ALL(r));

  vector<vector<int>> dist(N, vector<int>(N, INF));
  REP(i, N) dist[i][i] = 0;
  REP(i, M){
    int u, v, d;
    cin >> u >> v >> d;
    u--; v--;
    dist[u][v] = d;
    dist[v][u] = d;
  }

  REP(k, N) REP(i, N) REP(j, N){
    chmin(dist[i][j], dist[i][k]+dist[k][j]);
  }

  int ans = INF;
  do{
    int ret = 0;
    REP(i, R-1){
      ret += dist[r[i]][r[i+1]];
    }
    chmin(ans, ret);
  }while(next_permutation(ALL(r)));

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n;
    cin >> n;
    vector<int> d(n);

    for(int i=0; i<n; i++) cin >> d[i];
    sort(d.rbegin(), d.rend());
    debug(d);
    
    int ans = 0;
    int beforenum = 0;
    for(int i=0; i<n; i++) {
        if (beforenum == d[i]) continue;
        ans++;
        beforenum = d[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3168