akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
class Program
    {
        static void Main(string[] args)
        {
            var Array = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int N = Array[0];
            int M = Array[1];
            List<City> lstCity = new List<City>();
            for (long i = 0; i < M; i++)
            {
                Array = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
                lstCity.Add(new City(Array[1], i, Array[0]));
            }
            var dumy = lstCity.OrderBy(x => x.Div).ThenBy(x => x.BuildYear).ToArray();
            var tmp = dumy[0].Div;
            long Num = 1;
            dumy[0].BirthOrder = Num;
            for (var i = 1; i < M; i++)
            {
                if (tmp == dumy[i].Div)
                {
                    Num++;
                    dumy[i].BirthOrder = Num;
                }
                else
                {
                    Num = 1;
                    dumy[i].BirthOrder = Num;
                    tmp = dumy[i].Div;

                }
            }

            foreach (var i in dumy.OrderBy(x => x.OrderNo))
            {
                Console.WriteLine($"{i.Div:D6}{i.BirthOrder:D6}");
            }
        }
    }


    class City
    {
        public int BuildYear;
        public long OrderNo;
        public long BirthOrder;
        public int Div;
        public City(int B, long O, int D)
        {
            this.BuildYear = B;
            this.OrderNo = O;
            this.Div = D;
        }
    }

Measured memory_bytes: 34052
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>


using namespace std;
map<string,int>mp;



int n,m;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        string s;
        cin>>s;
        mp[s]++;
    }
    cin>>m;
    for(int i=1;i<=m;i++)
    {
        string s;
        cin>>s;
        mp[s]--;
    }
    int ans=0;
    for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++)
    ans=max(ans,it->second);
    cout<<ans;
    //system("pause");
    return 0;
}      
    

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (){

    bool cards[4][14];

    for(int i=0; i<4; i++){
        for(int j=1; j<=13; j++){
            cards[i][j] = 0;
        }
    }

    int n; cin >> n;
    char c; int b;

    for(int i=0; i<n; i++){
        cin >> c >> b;
        if(c=='S') cards[0][b]=1;
        if(c=='H') cards[1][b]=1;
        if(c=='C') cards[2][b]=1;
        if(c=='D') cards[3][b]=1;
    }

    for(int i=0; i<4; i++){
        for(int j=1; j<14; j++){
            if(cards[i][j]) continue;
            if(i==0) c='S';
            if(i==1) c='H';
            if(i==2) c='C';
            if(i==3) c='D';
            cout << c << " " << j << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3100
use io::*;
use std::*;

const YES: &'static str = "Yes";
const NO: &'static str = "No";
fn solve(X: i64, Y: i64) {
    for i in 0..X + 1 {
        let kame = i;
        let turu = X - i;
        if kame * 4 + turu * 2 == Y {
            println!("{}", YES);
            return;
        }
    }
    println!("{}", NO)

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut X: i64;
    X = scanner.next();
    let mut Y: i64;
    Y = scanner.next();
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(X, Y)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 2256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
    int a;
    char str[20];
    scanf("%d/%s",&a,str);
    printf("2018/%s",str);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            List<string> lstS = System.Console.ReadLine().Trim().Split(' ').ToList();
            List<long> lstA = new List<long>();
            for (int i = 0; i < lstS.Count; i++) { lstA.Add(long.Parse(lstS[i])); }
            lstA.Sort();
            List<int> lstL = new List<int>();
            for (int i = 0; i < lstA.Count; i++) { lstL.Add(lstA[i].ToString().Length); }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            decimal iOut = 0M;
            if (lstA.Contains(0L)) { iOut = 0L; }                                                       // 数列に0があれば0
            else
            {
                if (lstL.Contains(19))                                                                  // 数列に19桁以上あって
                {
                    for (int i = 0; i < lstA.Count; i++)
                    {
                        if (lstA[i] > 1L && lstL[i] != 19)                                              // 2以上が1個でも存在すれば -1
                        {
                            iOut = -1M;
                            break;
                        }
                    }
                    if (iOut == 0M) { iOut = 1000000000000000000M; }                                    // 2以上がなければ入力の最大値
                }
                else
                {
                    iOut = 1M;
                    for (int i = 0; i < lstA.Count; i++)                                                // 小さい値から乗算
                    {
                        if (iOut.ToString().Length + lstL[i] > 20)                                      // 次に掛ける値で20桁超えたら抜ける
                        {
                            iOut = -1M;
                            break;
                        }
                        iOut *= lstA[i];                                                                // 乗算
                        if (iOut > 1000000000000000000M)                                                // 1000000000000000000超えたら抜ける
                        {
                            iOut = -1L;
                            break;
                        }
                    }
                }
            }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 51568
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  string s;
  while(cin>>s,s!="0000"){
    int co=0;
    if(s[0]==s[1]&&s[1]==s[2]&&s[2]==s[3]){cout<<"NA"<<endl;continue;}
    while(s!="6174"){
      vector<int>tmp;
      rep(i,4)tmp.pb(s[i]-'0');
      sort(all(tmp));
      int a=0,b=0;
      rep(i,4){
	a+=pow(10,3-i)*tmp[i];
	b+=pow(10,i)*tmp[i];
      }
      a=b-a;
      co++;
      s="";
      while(a){
	s=(char)(a%10+'0')+s;
	a/=10;
      }
      while(s.size()!=4)s='0'+s;
    }
    cout<<co<<endl;
  }
}

Measured memory_bytes: 1260
#include <stdio.h>
int main()
{
	int n,i;
	int ans=100000;

	scanf("%d",&n);

	for(i=0;i<n;i++){
		ans *= 1.05;
		ans = ((ans+999)/1000)*1000;
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 592
import java.util.*;

public class Main {
    public static void main(String[] args) {	
	Main main = new Main();
    	main.solveA();
    }
    
    private void solveA() {
	Scanner sc = new Scanner(System.in);
    	int A = sc.nextInt();
    	int B = sc.nextInt();
    	System.out.println(A <= B ? A: A-1);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define ll long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second
    
    using namespace std;
    void add_self(ll &a,ll b)
    {
        a+=b;
        if(a>=mod)
            a-=mod;
        return;
    }
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T=1;
        //cin>>T;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n;
            cin>>n;
            ll a[n+1][n+1];
            for(ll i=1;i<=n;i++)
            {
                for(ll j=1;j<=n;j++)
                    cin>>a[i-1][j-1];
            }
            ll dp[1<<n]={0};
            dp[0]=1;
            for(ll mask=0;mask<(1<<n)-1;mask++)
            {
                ll c= __builtin_popcount(mask);
                for(ll b=0;b<n;b++)
                {
                    if(a[c][b] && !(mask&(1<<b)))
                    {
                        ll ab=mask^(1<<b);
                        add_self(dp[ab],dp[mask]);
                    }
                }
            }
            printf("%d",dp[(1<<n)-1]);
        }
        return 0;
    }


Measured memory_bytes: 16640
N=int(input())
S=list(input())
#print(S)
SETF=[set() for i in range(N)]
SETE=[0 for i in range(N)]
ANSSET=set()
SETF[0]=set()
SETF[0].add(S[0])
#print(SETF)
#print(type(SETF[1]))
import copy
for i in range(1,N):
    SETF[i]=copy.deepcopy(SETF[i-1])
    SETF[i].add(S[i])
#print(SETF)

SETE[0]=set()
SETE[0].add(S[-1])
#print(SETE)
for i in range(1,N):
    SETE[i]=copy.deepcopy(SETE[i-1])
    SETE[i].add(S[N-1-i])
SETE=SETE[::-1]

for i in range(1,N-1):
    for f in SETF[i-1]:
        for e in SETE[i+1]:
            ANSSET.add(f+S[i]+e)
print(len(ANSSET))
#print(SETE)

Measured memory_bytes: 98720
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
using ll = long long;
using P = pair<int, int>;

const int mod = 1000000007;
struct mint {
  ll x; 
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

mint f(int n){ 
  if(n == 0)return 1;
  mint x = f(n / 2); 
  x *= x; 
  if(n % 2 == 1)x *= 2;
  return x;
}

mint choose(int n, int a){
  mint x = 1, y = 1;
  for(int i = 0; i < a; ++i){
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

vector<vector<int>> calcNext(const string &s){
	int n = s.size();
	vector<vector<int>> res(n + 1, vector<int>(26, n)); 
	for(int i = n - 1; i >= 0; --i){
		for(int c = 0; c < 26; ++c){
			res[i][c] = res[i + 1][c]; 
			res[i][s[i] - 'a'] = i; 
		}
	}

	return res;
}

vector<vector<mint>> dp;

int main(){
  string s;
  cin >> s;

  int n = s.size();
  string t = s;
  reverse(t.begin(), t.end());

  auto next_s = calcNext(s);
  auto next_t = calcNext(t);
  dp = vector<vector<mint>>(n + 1, vector<mint>(n + 1, 0));
  dp[0][0] = 1; 
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      for(int c = 0; c < 26; ++c){
        int ni = next_s[i][c];
        int nj = next_t[j][c];
        if(ni + nj <= n - 2)dp[ni + 1][nj + 1] += dp[i][j];
      }
    }
  }

  mint ans = 0;
  for(int i = 0; i <= n; ++i){
  	for(int j = 0; j <= n - i; ++j){
      mint num = 1;
      for(int c = 0; c < 26; ++c){
        if(next_s[i][c] + 1 + j <= n)num += 1;
      }
      ans += dp[i][j] * num;
    }
  }

  cout << ans.x - 1 << endl;

  return 0;
}



Measured memory_bytes: 34920
#include <iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
using ll = long long;

using namespace std;



int main() {
    int n;
    cin>>n;
    vector<double> v(n);
    rep(i,n) cin>>v[i];
    sort(v.begin(),v.end());
    double ans = v[0];
    for(int i = 1; i < n; i++) {
        ans = (ans+v[i])/2;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 n;
    const i64 mod = 998244353;
    std::string str;
    std::cin >> n >> str;
    std::bitset<4010> x(str);
    std::vector<std::bitset<4010>> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> str;
        a[i] = std::bitset<4010>(str);
    }

    std::vector<i64> pow2(4010);
    pow2[0] = 1;
    for (int i = 1; i < 4010; i++) pow2[i] = pow2[i - 1] * 2 % mod;

    auto gcd(a[0]);
    for (int i = 1; i < n; i++) {
        auto curr = a[i];
        while (1) {
            int d1 = 4000, d2 = 4000;
            while (!gcd[d1] && d1 > 0) d1--;
            while (!curr[d2] && d2 > 0) d2--;
            if (d2 > d1) {
                std::swap(d1, d2);
                std::swap(gcd, curr);
            }
            if (!d2 && !curr[d2]) break;
            if (gcd == curr) break;

            gcd = gcd ^ (curr << (d1 - d2));
        }
    }

    i64 d = 4000, ret = 0, dx = 4000;
    while (!gcd[d]) d--;
    while (!x[dx]) dx--;
    auto y = x >> d;
    for (int i = 0; i < 4000; i++) if (y[i]) ret = (ret + pow2[i]) % mod;
    auto q = y << d;
    for (int i = 0; i <= dx - d; i++) {
        if (q[dx - i]) q ^= gcd << (dx - i - d);
    }
    q |= y << d;
    if (x.to_string() >= q.to_string()) ret++;

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
 int n;
 cin >> n;
 long double sum = 0.0;
 for (int i = 0; i < n; i++) {
  long double d;
  cin >> d;
  sum += 1.0 / d;
 }
 cout << 1.0 / sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> ivec;
const ll N = 1e9+7;

const int nmax = 8,m = 100;
vector<int> ab[nmax];
// int V = 0,E = 0;
// int moved[n];
int dfs(int x, int n, bool moved[nmax]){
    // rep(i,n) cout << moved[i] << ' ' ;
    // cout <<endl;
    bool allmoved = true;
    rep(i,n){
        if(moved[i] == false) allmoved = false;
    }
    if(allmoved) {
        // cout << "test" << endl;
        return 1;
    }
    // moved[x] = 1;
    int ans = 0;
    rep(i,ab[x].size()){
        int v = ab[x][i];
        // if() continue;
        if(moved[v] == 0){
            moved[v] = 1;
            ans += dfs(v,n,moved);
            moved[v] = 0;
        }
    }
    // cout << "ans"  << ' ' << ans << endl;
    return ans;
}
// dfsでの実装
// int main(){
//     int n,m; cin >> n >> m;
//     // vector<int> ab[n];
//     rep(i,m){
//         int a,b; cin >> a >> b;
//         ab[a-1].pb(b-1);
//         ab[b-1].pb(a-1);
//     }
//     bool moved[n] = {};
//     moved[0] = true;
//     cout << dfs(0,n,moved) << endl;
//     return 0;
// }

// next_parmutationを用いた実装（全探索）
int main(){
    int n,m; cin >> n >> m;
    bool ab[n][n] = {};
    rep(i,m){
        int a,b; cin >> a >> b;
        a--;b--;
        ab[a][b] = true;
        ab[b][a] = true; 
    }
    vector<int> v(n-1);
    iota(v.begin(),v.end(),1);
    int ans = 0;
    do{
        bool ok = true;
        rep(i,n-1){
            if(i == 0){
                if(ab[0][v[i]] == false) ok = false;
            }
            else{
                if(ab[v[i-1]][v[i]] == false) ok = false;
            }
        }
        if(ok) {
            ans++;
            // rep(i,n-1)cout << v[i] << " ";cout << endl;
        }
    }while(next_permutation(v.begin(),v.end()));
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define int ll
//#define endl '\n'

int32_t main()
{
    IOS
    int a,b;
    cin>>a>>b;
    cout<<max(max(a+a-1,b+b-1),a+b)<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template< class T > void prArray(T a,char ch = ' '){
  for(int i=0;i<(int)a.size();i++,cout<<ch){
    if(i) cout<<ch;
    cout<<a[i];
  }
  cout<<endl;
}
typedef pair<int,int> P;
int n;
vector<int> A;
vector<P> ans;
void add(int x,int y){ans.push_back(P(x+1,y+1));}
void pr(){
    cout<<ans.size()<<endl;
    for(P p:ans) cout<<p.first<<" "<<p.second<<endl;
}

bool Plus(){
  ans.clear();
  int mx = 0;
  for(int i=0;i<n;i++) if(A[i]>A[mx]) mx = i;
  for(int i=0;i<n;i++) add(mx,i), A[i] += A[mx];
  for(int i=0;i<n-1;i++) add(i,i+1), A[i+1] += A[i];
  for(int i=1;i<n;i++) if(A[i-1] > A[i]) return 0;
  return 1;
}

bool Minus(){
  ans.clear();
  int mn = 0;
  for(int i=0;i<n;i++) if(A[i]<A[mn]) mn = i;
  for(int i=0;i<n;i++) add(mn,i), A[i] += A[mn];
  for(int i=n-1;i>0;i--) add(i,i-1), A[i-1] += A[i];
  for(int i=1;i<n;i++) if(A[i-1] > A[i]) return 0;
  return 1;
}


signed main(){
  cin>>n;
  A.resize(n);
  //for(int i=0;i<n;i++) A[i] = rand()%100  - 50;
  for(int i=0;i<n;i++) cin>>A[i];
  
  vector<int> tmp = A;
  if(Plus()){pr();return 0;}
  A = tmp;
  if(Minus()){pr();return 0;}
  assert(0);
}



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

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> ans(n,0);
  for(int i=0; i<m; i++){
    int a,b;
    cin>>a>>b;
    ans.at(a-1)++;
    ans.at(b-1)++;
  }

  for(int i=0; i<n; i++)cout<<ans.at(i)<<endl;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


int main() {
    string s; cin >> s;
    string t; cin >> t;

    int ans = 1001;
    int n = t.size();
    for(int i = 0; i < (int)s.size(); i++){
        string tmp = s.substr(i, n);
        if((int)tmp.size() != n) continue;
        int cnt = 0;
        for(int j = 0; j < n; j++){
            if(t[j] != tmp[j]) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int A = 0;
  vector<int> v(N);
  for (int i = 0; i < N; i++){
    cin >> v.at(i);
  }
  for (int i = 0; i < N; i++){
     if (v.at(i) == -1){
       continue;
    }
    for (int j = i + 1; j < N; j++){
      if (v.at(i) == v.at(j)){
        v.at(j) = -1;
        A++;
      }
    }
  }
  cout << N - A<< endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;
ll memo[1ll << 21][21];
ll a[30][30];
//Best never rest
//Always use top down dp for bitmask dp problems

ll rec(ll mask,ll j,ll n)
{
    if(mask == ((1ll << n) - 1))//All done right
     return 0;
   // else if((mask == 0) and (j != (n-1))) return 0;//No way left
    else if(j == (n-1))//ek jon e baki
    {
        //tar pochondo r kyeu ache naki dekhte hobe to
        bool f = false;
        for(ll i = 0;i < n;i++)
        {
            if((!(mask & (1ll << i))) and a[i][j])
            {
              f = true;
              break;
            }
        }
        if(f) return memo[mask][j] = 1;
        else return memo[mask][j] = 0;
    }
    else if(memo[mask][j] != -1)
     return memo[mask][j];//Return the memoized solution
    else
    {
        //Well before coming to the generalised solution it is important that we think about the base cases a little bit more

        ll val = 0;
        for(ll k = 0;k < n;k++)
        {
            if((a[k][j] == 1) and ((mask & (1ll << k)) == 0))
            {
                val = ((val % mod) + (rec((mask | (1ll << k)),j + 1,n)) % mod)%mod;
            }
        }
        return memo[mask][j] = val % mod;
    }
    
}
void Compute(ll n)
{
    KAKA
    //ll a[n+1][n+1];
    pragi(0,n)
    {
        pragj(0,n)
        {
            cin>>a[i][j];//Compatibility of ith man and jth woman
        }
    }
 
ll no_of_matchings = rec(0,0,n);
cout<<no_of_matchings<<"\n";
}
int main()
{
    KAKA
    memset(memo,-1,sizeof(memo));
    ll n;
    cin>>n;
    Compute(n);
}

Measured memory_bytes: 344448
from collections import Counter


def prime_factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n //=2
    f=3
    while f**2<=n:
        if n%f==0:
            a.append(f)
            n //=f
        else:f +=2
    if n!=1:a.append(n)
    return a


n,p=map(int,input().split())
A=Counter(prime_factorize(p)).items()
cnt=1
for i,j in A:
    cnt *=pow(i,j//n)
print(cnt)

Measured memory_bytes: 3316
while 1:
 m, f, r = map(int, input().split())
 tsum = m + f
 if m == -1 and f == -1 and r == -1:
  break
 elif m == -1 or f == -1:
  print('F')
 elif tsum >= 80:
  print('A')
 elif tsum >= 65:
  print('B')
 elif tsum >= 50:
  print('C')
 elif tsum >= 30:
  if r >= 50:
   print('C')
  else:
   print('D')
 else:
  print('F')

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

ll gcd(ll a, ll b) { return (b?gcd(b, a%b):a); }

const int M = 1000000007;
ll mul(ll a, ll b) { return (a*b)%M; }
ll mod_pow(ll a, ll b) {
  ll r = 1;
  while (b) {
    if (b&1) r = mul(r, a);
    b >>= 1;
    a = mul(a, a);
  }
  return r;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, zero = 0;
  cin >> n;
  map<pair<ll, ll>, P> mp;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    if (x == 0 && y == 0) {
      ++zero;
      continue;
    }
    ll g = gcd(x, y);
    x /= g;
    y /= g;
    if (y < 0) { x = -x, y = -y; }
    if (x == 0) y = 1;
    if (y == 0) x = 1;
    if (x > 0) mp[{x, y}].first++;
    else mp[{y, -x}].second++;
  }
  ll ans = 1;
  for (auto k : mp) {
    ll now1 = mod_pow(2, k.second.first);
    ll now2 = mod_pow(2, k.second.second);
    ans = mul(ans, (now1+now2-1)%M);
  }
  ans += zero-1;
  ans = (ans+M)%M;
  cout << ans << endl;
}

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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	cout<<((a+b)%3==0||a%3==0||b%3==0?"Possible":"Impossible")<<endl;
	return 0;
}


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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

int main(){
  int K;
  int a,b;
  cin>>K>>a>>b;
  for(int i(a);i<=b;i++){
    if(i%K==0){
      cout << "OK" << endl;
      return 0;
    } 
  }
  cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int A[] = new int[n];
		for(int i = 0; i < n; i++) {
			A[i] = sc.nextInt();
		}
		for(int z = 0; z < n; z++) {
			System.out.print(A[z]);
			if(z < n-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
		for (int j = 1; j < A.length; j++) {
			int key = A[j];
			int i = j - 1;
			while(i >= 0 && A[i] > key) {
				A[i + 1] = A[i];
				i--;
			}
			A[i + 1] = key;
			for(int z = 0; z < n; z++) {
				System.out.print(A[z]);
				if(z < n-1) {
					System.out.print(" ");
				}
			}
			System.out.println("");
		}
	}
}



Measured memory_bytes: 33936
#include<iostream>
int main(){
  int n;
  std::cin >> n;
  int i, A[n];
  for(i=n-1; i>=0; i--) std::cin >> A[i];
  for(i=0; i<n; i++) std::cout << A[i] << (n - 1 == i ? "\n" : " ");
  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    int mx = -1;
    int v;
    rep(i,n) {
        int a, b; cin >> a >> b;
        if (chmax(mx,a)) v = b;
    }
    int ans = mx + v;
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int getCnt2(int num){
    long long ans = 0;
    int temp = 2;
    while(temp <= num){
        ans += (num / temp);
        temp *= 2;
    }
    return ans;
}

int main(){

    int N;
    cin >> N;

    string a;
    cin >> a;

    vector<int> b(N - 1);
    bool containOne = false;
    for(int i = 0; i < N - 1; i++){
        int l = a[i] - '0';
        int r = a[i + 1] - '0';
        b[i] = abs(l - r);
        if(b[i] == 1){
            containOne = true;
        }
    }

    if(containOne){
        for(int i = 0; i < N - 1; i++){
            if(b[i] == 2){
                b[i] = 0;
            }
        }
    }
    else{
        for(int i = 0; i < N - 1; i++){
            if(b[i] == 2){
                b[i] = 1;
            }
        }
    }

    int bit = 0;
    for(int i = 0; i < N - 1; i++){
        int n = N - 2;
        int r = i;
        int cnt = (getCnt2(n) - getCnt2(n - r)) - getCnt2(r);
        if(cnt > 0){    // Even
            continue;
        }
        else{   // Odd
            bit ^= b[i];
        }
    }

    if(containOne){
        if(bit == 0){
            cout << 0 << endl;
        }
        else{
            cout << 1 << endl;
        }
    }
    else{
        if(bit == 0){
            cout << 0 << endl;
        }
        else{
            cout << 2 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 5252
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{	
		boolean not[] = new boolean[1000000];
		
		not[0] = true;
		not[1] = true;
		
		for (int i = 2; i * i < 1000000; i++)
		{
			if (not[i]) continue;
			for (int x = (i << 1); x < 1000000; x += i)
			{
				if (not[x]) continue;
				not[x] = true;
			}
		}
		
		Scanner sc = new Scanner(System.in);
		while(true)
		{
			int count = 0;
			int n;
			try
			{
				n = sc.nextInt();
			}
			catch(Exception e)
			{
				break;
			}
			for (int i = 2; i <= n; i++)
			{
				if (not[i] == false) count++;
			}
			System.out.println(Integer.toString(count));
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For(i, 0, n)
#define rrep(i, n) rFor(i, n, 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int n, m, s[MAX];

int check(int mid){
    int cur = 1, cnt = 0;
    while(s[n - 1] >= cur + mid){
        int lv = -1;
        auto itr = lower_bound(s, s + n, cur);
        if(itr - s > 0) chmax(lv, max(1, mid - abs(cur - *prev(itr))));
        if(*itr < cur + mid) chmax(lv, max(1, mid - abs(cur - *itr)));
        if(lv < 0) return mod;
        cur += lv;
        ++cnt;
    }
    return cnt + 1;
}

void solve(){
    rep(i, n) scanf("%d", &s[i]);
    int low = 1, high = s[n - 1];
    if(check(1) < m){
        printf("%d\n", -1);
        return;
    }
    while(high - low > 1){
        int mid = (high + low) / 2;
        (check(mid) >= m ? low : high) = mid;
    }
    printf("%d\n", (check(low) < mod ? low : -1));
}

int main(){
    while(scanf("%d%d", &n, &m) && n){
        solve();
    }
}


Measured memory_bytes: 3588
#include <iostream>

using namespace std;

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

    int x1, x2, y1, y2, t1, t2;
    x1 = x2 = y1 = y2 = t1 = t2 = 0;
    bool flag = true;
    int dist;
    for (int i = 0; i < N; i++) {
        cin >> t2 >> x2 >> y2;
        dist = abs(x2-x1)+abs(y2-y1);
        if ((dist > (t2-t1)) || ((dist-t2+t1)&1)) {
            flag = false;
        }
    }

    cout << (flag ? "Yes":"No") << endl;
}

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

#define MOD 1000000007

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<vector<T>>&obj) {
    o << "[" << endl; for (int i = 0; i < (int)obj.size(); ++i) o << "  " << obj[i] << endl; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const multiset<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}

#define INF 1000000001

int main(int argc, char const *argv[]) {
    int N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N), B(M);
    vector<ll> A_sum(N+1, 0), B_sum(M+1, 0);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        A_sum[i+1] = A[i] + A_sum[i];
    }
    for (int i = 0; i < M; ++i) {
        cin >> B[i];
        B_sum[i+1] = B[i] + B_sum[i];
    }

    // print(A_sum);
    // print(B_sum);

    int ans = 0;
    for (int i = 0; i <= N; ++i) {
        ll res = K - A_sum[i];
        if (res < 0) continue;
        int n = i + distance(B_sum.begin(), prev(upper_bound(B_sum.begin(), B_sum.end(), res)));
        ans = max(ans, n);
        // print(i, res, distance(B_sum.begin(), prev(upper_bound(B_sum.begin(), B_sum.end(), res))), n);
    }
    print(ans);
    
    return 0;
}


Measured memory_bytes: 9592
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        char[] s = scanner.next().toCharArray();
        int c1 = 0, c2 = 0;
        for (char c : s) {
            if (c == '0') c1++;
            else c2++;
        }

        System.out.println(Math.min(c1, c2) * 2);
    }
}

Measured memory_bytes: 26576
#include<bits/stdc++.h>
#define fi first
#define f first
#define se second
#define s second
#define vi_a vector<int>a;
#define p_b push_back
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define pw(x) (1ll << x)
#define sz(x) (int)x.size()
#define endl "\n"
#define rall(x) x.rbegin(),x.rend()
#define len(a) (ll)a.size()
#define rep(x,l,r) for(ll x=l;x<r;x++)
using namespace std;
ld eps = (ld)1 / 1e15;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const ll to[5]={0,4,6,7,9};
const ll N=1e3+1e2;
const ll R=1e4;
//ll columns[N][26];
//ll str[N][26];
//pll cool[N][N];
signed main(){
    fast_io;
    ll l;
    cin>>l;
    ld mx=0;
    cout<<fixed<<setprecision(6)<<(ld)l/3.*l/3.*l/3.;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		char result = 'a';
		char[] c = s.toCharArray();
		Arrays.sort(c);
		for(int i = 0; i < s.length(); i++){
		    if(result < c[i]){
		        System.out.println(result);
		        return;
		    }
		    result = (char)(c[i] + 1);
		}
		if(result == 'z'){
		    System.out.println("z");
		}else{
		    System.out.println("None");
		}
		
		// 出力
		//System.out.println(result);
	}
}




Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
long long n;
void print(long long x)
{
  	if(x==0){return;}
  	--x;
  	print(x/26);
    char chr=x%26+'a';
  	cout<<chr;
}
int main(void)
{
  	cin>>n;
  	print(n);
}

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

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int n = cin.nextInt();
        string s = cin.next();

        char[] s_ = s.ToCharArray();

        int ans = 0;

        for (int i = 0; i < n - 2; ++i)
        {
            if (s_[i] == 'A' && s_[i + 1] == 'B' && s_[i + 2] == 'C')
                ans++;
        }

        WriteLine(ans);
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
int main (){

    int a,b,s,m,g;
    scanf("%d%d",&a,&b);
    s=a+b;
    m=a-b;
    g=a*b;
    if(s>=m&&s>=g){
        printf("%d\n",s);
    }
    else if(m>=s&&m>=g){
        printf("%d\n",m);
    }
    else{
        printf("%d\n",g);
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main() {
  int N, A;
  cin >> N;
  int S[N];
  for(int i = 0; i < N; i++) {
    S[i] = 0;
  }
  for(int i = 0; i < N - 1; i++) {
    cin >> A;
    S[A - 1]++;
  }
  for(int i = 0; i < N; i++) {
    cout << S[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 4364
package main

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

func main() {
	log.SetFlags(log.Lshortfile)
	N := nextInt()
	M := nextInt()
	X := nextInt()
	Y := nextInt()
	x := nextInts(N)
	y := nextInts(M)
	x = append(x, X)
	y = append(y, Y)
	sort.Ints(x)
	sort.Ints(y)
	if x[len(x)-1] < y[0] {
		fmt.Println("No War")
	} else {
		fmt.Println("War")
	}
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	return p[i].b < p[i].b
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 640
#include<stdio.h>

#define N 101

int main(){
  int i,j,id,k,n,d;
  int a[N][N];

  scanf("%d",&n);

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

  for(i=1;i<=n;i++){
    scanf("%d%d",&id,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&d);
      a[i][d]=1;
    }
  }

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      printf("%d",a[i][j]);
      if(j!=n){
	printf(" ");
      }
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2148
#include <stdio.h>
#include <string.h>
int main(void){
  char s[3];
  scanf("%s", s);
  int len=strlen(s);
  if(len==2)
    printf("%s\n", s);
  else
    printf("%c%c%c\n", s[2], s[1], s[0]);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x;
    int y;
    cin >>x;
    cin >>y;
    //足がやたらと多い
    if (4*x<y){
        //おかしい
        cout << "No";
    }
        //足がやたらと少ない
    else if (2*x>y){
        //おかしい
         cout << "No";
    }
    //足がなぜか奇数
    else if (y%2==1){
        //okasii
         cout << "No";
    }
    else{
        //ok
         cout << "Yes";
    }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=100005;
const ll mod=1e9+7,inv2=5e8+4;
inline int read()
{
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n;
char s[N];
int main()
{
	scanf("%d%s",&n,s+1);
	if(n&1){
		puts("No"); return 0;
	}
	for(int i=1;i<=n/2;i++){
		if(s[i]!=s[i+n/2]){
			puts("No"); return 0;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

/*
  UnionFind Tree
*/
class UnionFind {
    private: 
        vector<int> par;
        vector<int> rank;
        vector<int> cnt;
    
    public:
        UnionFind(int n);
        int find(int x);
        void unite(int x, int y);
        bool same(int x, int y);
        int count(int x);
        void printStatus();
};

UnionFind::UnionFind(int n) {
    for (int i = 0; i < n; i++) {
        par.push_back(i);
        rank.push_back(0);
        cnt.push_back(1);
    }
}
int UnionFind::find(int x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
}
void UnionFind::unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) {
        cnt[y] += cnt[x];
        par[x] = y;
    } else {
        cnt[x] += cnt[y];
        par[y] = x;
        if (rank[x] == rank[y]) rank[x]++;
    }
}
bool UnionFind::same(int x, int y) {
    return find(x) == find(y);
}
int UnionFind::count(int x) {
    return cnt[find(x)];
}
void UnionFind::printStatus() {
    printf("----------------\n");
    for (int i = 0; i < par.size(); i++) {
        printf("[node %d]: parent = %d, rank = %d, count = %d\n", i, par[i], rank[i], cnt[i]);
    }
}

int main() {

    int N, M;
    cin >> N >> M;
    vector<int> p(N);
    rep(i,N) {
        cin >> p[i];
        p[i]--;
    }
    vector<P> e(M);
    rep(i,M) {
        cin >> e[i].first >> e[i].second;
        e[i].first--;
        e[i].second--;
    }
    UnionFind tree(N);
    rep(i,M) tree.unite(e[i].first, e[i].second);

    int ans = 0;
    rep(i,N) {
        if (tree.same(p[i], i)) ans++;
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 2796
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <functional>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(x) begin(x), end(x)
using namespace std;

int solve(int n, vector<int> const & a, vector<int> const & b) {
    int sum_a = accumulate(whole(a), 0, bit_xor<int>());
    {
        map<int, int> cnt;
        for (int a_i : a) {
            cnt[a_i] += 1;
        }
        cnt[sum_a] += 1;
        for (int b_i : b) {
            if (cnt.count(b_i)) {
                cnt[b_i] -= 1;
                if (cnt[b_i] == 0) {
                    cnt.erase(b_i);
                }
            }
        }
        assert (not cnt.empty());
        if (cnt.size() >= 2 or cnt.begin()->second >= 2) {
            return -1;  // impossible
        }
    }
    int mismatch = 0;
    int component = 0; {
        map<int, set<int> > g;
        repeat (i, n) {
            if (a[i] != b[i]) {
                mismatch += 1;
                g[b[i]].insert(a[i]);
            }
        }
        set<int> used;
        function<void (int)> go = [&](int a_i) {
            used.insert(a_i);
            for (int a_j : g[a_i]) if (not used.count(a_j)) {
                go(a_j);
            }
        };
        component += 1;
        if (g.count(sum_a)) {
            go(sum_a);
        }
        repeat (i, n) if (not used.count(a[i])) {
            if (g.count(a[i])) {
                component += 1;
                go(a[i]);
            }
        }
    }
    return mismatch + (component - 1);
}

int main() {
    int n; scanf("%d", &n);
    vector<int> a(n); repeat (i, n) scanf("%d", &a[i]);
    vector<int> b(n); repeat (i, n) scanf("%d", &b[i]);
    int result = solve(n, a, b);
    printf("%d\n", result);
    return 0;
}

Measured memory_bytes: 25984