akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int r = sc.nextInt();
		int w = sc.nextInt();
		long x=(long) 1e9+7;
		long[][] dp = new long[r][w];
		for (int i = 0; i < r; i++) {
			String z = sc.next();
			for (int j = 0; j < w; j++) {
				if (z.charAt(j) == '.') {
					if (i == 0 && j == 0) {
						dp[i][j] = 1;
					} else if (i == 0) {
						dp[i][j] = dp[i][j - 1];
					} else if (j == 0) {
						dp[i][j] = dp[i - 1][j];
					} else {
						dp[i][j] = (dp[i][j - 1] + dp[i - 1][j])%x;
					}
				} else {
					dp[i][j] = 0;
				}
			}
		}
		
		long y=dp[r - 1][w - 1];
		System.out.println(y>x?y%x:y);
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

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

		public int[] nextIntArr(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = Integer.parseInt(next());
			}
			return arr;
		}
	}
}


Measured memory_bytes: 38864
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    bool OK = false;
    int tmp;
    for( int i=0; i<=N/4; i++){
        for( int j=0; j<=N/7; j++){
            tmp = 4*i+7*j;
            if(tmp == N) OK = true;
        }
    }
    if(OK==false) cout << "No" << endl;
    else cout << "Yes" << endl;
}




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

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

	A *= (-1);

	if (A + B <= 0) {
		cout << "delicious";
	}
	else {
		if (A + B <= X)
			cout << "safe";
		else
			cout << "dangerous";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  static final int WHITE = 0;
  static final int GRAY = 1;
  static final int BLACK = 2;
  static int v;
  static Map<Integer, List<Integer>> adjList = new HashMap<Integer, List<Integer>>();
  static int color[];
  static boolean judge = false;

  public static void main(String[] args){

    Scanner scan = new Scanner(System.in);
    v = scan.nextInt();
    int e = scan.nextInt();

    int start,end = 0;
    for(int i = 0 ; i < e ; i++) {
      start = scan.nextInt();
      end = scan.nextInt();
      if(!adjList.containsKey(start)) {
        adjList.put(start, new ArrayList<Integer>());
      }
      adjList.get(start).add(end);
    }

    color = new int[v];
    for(int i : adjList.keySet()){
      dfs(i);
    }

    if(judge) {
      System.out.println(1);
    } else System.out.println(0);
  }

  static void dfs(int u) {
    color[u] = GRAY;
    if(adjList.containsKey(u)) {
      for(int ne : adjList.get(u)) {
        if(color[ne] == GRAY) {
          judge = true;
          break;
        }
        if(color[ne] == WHITE) dfs(ne);
      }
    }
    color[u] = BLACK;
  }
}


Measured memory_bytes: 31832
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		long n = sc.nextLong(), k = sc.nextLong();
		long[] end = new long[(int)n];
		for(int i = 0; i < n; i++) {
			end[i] = sc.nextLong();
		}
		Map<Long, Long> map = new HashMap<>();
		boolean check = false;
		long next = 1l;
		long count = 0l;
		long st = 0l;
		long en = 0l;
		List<Long> list = new ArrayList<>();
		List<Long> listn = new ArrayList<>();
		while(!check) {
			if(map.containsKey(next)) {
				st = (long)map.get(next);//count
				en = (long)map.size();//count
				List<Long> lista = new ArrayList<>(map.keySet());
				List<Long> listb = new ArrayList<>(map.values());
				list = lista;
				listn = listb;
				break;
			}else {
				map.put(next, count);
				next = end[(int)next -1];
				count++;
			}
		}
		long t = 0l;
		if(st != 0) {
			t = k- st + 1;
		}else {
			t = k+1;
		}
		long an = t%(en-st);
		int index = 0;
		if(st > k) {
			index = listn.indexOf(k);
		}else if(an == 0) {
			index = listn.indexOf(en -1);
		}else {
			index = listn.indexOf(st + an -1);
		}
		System.out.println(list.get(index));

	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

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

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 66156
N=int(input())
dp=[10**7]*3000000
dp[0]=0

pow6=[6**j for j in range(10) if 6**j <= N]
pow9=[9**j for j in range(10) if 9**j <= N]

for i in range(N):
    for p6 in pow6:
        dp[i+p6]=min(dp[i+p6], dp[i]+1)
    for p9 in pow9:
        dp[i+p9]=min(dp[i+p9], dp[i]+1)

print(dp[N])

Measured memory_bytes: 26612
#include <iostream>
const int INF = 1001001001;
typedef long long ll;
using namespace std;
ll f(int n, ll x) {
  if (n == 0) return 1;
  ll len = (1LL<<(n+1)) - 3;
  ll num = (1LL<<n) - 1;
  if (x == 1) return 0;
  else if (x <= len + 1) return f(n-1, x-1);
  else if (x == len + 2) return num + 1;
  else if (x <= 2*(len+1)) return num + 1 + f(n-1, x-len-2);
  else return 2*num + 1;
}
 
int main() {
  int n; ll x;
  cin >> n >> x;
  cout << f(n, x) << endl;
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			string line;
			while ((line = Console.ReadLine()) != null)
			{
				double[] l = line.Split(' ').Select(i => double.Parse(i)).ToArray();

				if (l[0] < 35.5 && l[1] < 71.0)
					Console.WriteLine("AAA");
				else if (l[0] < 37.5 && l[1] < 77.0)
					Console.WriteLine("AA");
				else if (l[0] < 40.0 && l[1] < 83.0)
					Console.WriteLine("A");
				else if (l[0] < 43.0 && l[1] < 89.0)
					Console.WriteLine("B");
				else if (l[0] < 50.0 && l[1] < 105.0)
					Console.WriteLine("C");
				else if (l[0] < 55.0 && l[1] < 116.0)
					Console.WriteLine("D");
				else if (l[0] < 70.0 && l[1] < 148.0)
					Console.WriteLine("E");
				else
					Console.WriteLine("NA");
			}
		}
	}
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	string s;
	cin >> s;
	cout << s.substr(0,4) << " " << s.substr(4,8) << endl;
}


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

int main() {
  string s;
  cin >> s;
  rep(i, 7) {
    if (s.substr(0, i) + s.substr(s.size() - 7 + i) == "keyence") {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> s(n);
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    int q;
    cin >> q;
    vector<int> t(q);
    for(int i = 0; i < q; i++){
        cin >> t[i];
    }
    int cnt = 0;
    for(int i = 0; i < q; i++){
        for(int j = 0; j < n; j++){
            if(t[i] == s[j]){
                cnt++;
                break;
            }
        }
    }
    cout << cnt << endl;

}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef vector<int> vi;

double dist(vi &v, int p) {
    int i;
    double d = 0;
    if (p == -1) {
        for (i = 0; i < v.size(); i++)
            d = max(d, (double)v[i]);
    } else {
        for (i = 0; i < v.size(); i++)
            d += pow(v[i], p);
        d = pow(d, 1.0 / p);
    }
    return d;
}

int main() {FIN
    
    int n, i, e;
    cin >> n;
    vi df(n);
    for (i = 0; i < n; i++) cin >> df[i];
    for (i = 0; i < n; i++) {
        cin >> e;
        df[i] = abs(df[i] - e);
    }
    
    cout << fixed << setprecision(8) << dist(df, 1) << "\n";
    cout << fixed << setprecision(8) << dist(df, 2) << "\n";
    cout << fixed << setprecision(8) << dist(df, 3) << "\n";
    cout << fixed << setprecision(8) << dist(df, -1) << "\n";
    
    return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin>>n;
  ll ans=0;
  ll x=n;
  for(ll i=2; i*i<=n; i++){
    ll cnt=0;
    while(x%i==0){
      x/=i;
      cnt++;
    }

    ll maxk=0;
    for(ll k=1; k<=40; k++){
      if(k*(k+1)/2<=cnt)
        maxk=k;
    }
    ans+=maxk;
  }
  if(x!=1)
    ans++;

  cout<<ans<<endl;
}



Measured memory_bytes: 3652
class AtCoder {
  // 入力系
  input=[];
  input_i=-1;
  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n){
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n){
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }

  // コンソール
  o(...a:any){
    console.log(...a);
  }

  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }

  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }

  // 自作
  gcd(...arr):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  isPrime(n:number):boolean{
    if(n < 2) return false;
    const suq=Math.sqrt(n);
    for(let i=2;i<=suq;i++){
      if(n%i==0){
        return false;
      }
    }return true;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
}
const o = new AtCoder()
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line',(line)=> {
  o.input.push(...line.split(/[\s]/));
});

process.stdin.on('end', ()=> {
  o.o(o.ceil(o.n()/o.n()))
});

Measured memory_bytes: 7628
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n;
    cin >> n;

    V v;

    REP(i, 110)
    v.push_back(0);

    for (int i = 2; i <= n; i++)
    {
        int i_ = i;
        int j = 2;
        while (i_ > 1)
        {
            if (i_ % j == 0)
            {
                v[j]++;
                i_ /= j;
            }
            else
                j++;
        }
    }

    int res = 0;

    for (int i = 2; i < 100; i++)
    {
        if (v[i] >= 2)
            for (int j = 2; j < 100; j++)
            {
                if (v[j] >= 4 && j != i)
                    for (int k = j + 1; k < 100; k++)
                    {
                        if (v[k] >= 4 && k != i)
                        {
                            res++;
                            //cout << i << " " << j << " " << k << endl;
                        }
                    }
            }
    }

    for (int i = 2; i < 100; i++)
    {
        if (v[i] >= 2)
            for (int j = 2; j < 100; j++)
            {
                if (v[j] >= 24 && j != i)
                    res++;
            }
    }

    for (int i = 2; i < 100; i++)
    {
        if (v[i] >= 4)
            for (int j = 2; j < 100; j++)
            {
                if (v[j] >= 14 && j != i)
                    res++;
            }
    }

    for (int i = 2; i < 100; i++)
    {
        if (v[i] >= 74)
            res++;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx")
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define PA pair<LL,LL>
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define EB emplace_back
#define TS to_string
#define TU to_ullong
#define BPL __builtin_popcountll
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORR(i,a,n) for(i=n-1;i>=a;i--)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
//#define ERR 0.00000000000001
#define NUM 200010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL LBn(VL &v,LL a){LL mx=v.size(),mn=-1,md;while(mx-mn>1){md=(mx+mn)/2;if(v[md]<a)mn=md;else mx=md;}return mx;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a%m<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}
template<typename T>bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  FAST;
  LL i,ans=0,K,A,B;
  cin>>K>>A>>B;
  if(((A+K-1)/K)*K<=B)cout<<"OK"<<endl;
  else cout<<"NG"<<endl;

  //cout<<ans<<endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
 
const int MAXN = 105;
int n, len;
string s[MAXN];
 
int main() {
  cin >> n >> len;  
  string s[MAXN]; 
  for(int i = 0; i < n; ++i){
    cin >> s[i];
  }
  sort(s, s+n);
  for (int i=0; i<n; i++) {
    cout << s[i];
  }
  cout << endl;
  return 0;
}


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

int main() {
    int N, count, result=0;
    cin >> N;
    for (int i = 1; i < N + 1; i++)
    {
        count = 0;
        if (i % 2 == 0) continue;
        else {
            for (int j=1; j < i + 1; j++) {
                if (i % j == 0) count++; 
            }
            if (count == 8) result++;
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3644
using System;
using System.Linq;

namespace ABC158
{
    class A
    {
        static void Main(string[] args)
        {
            //var a = Console.ReadLine().Split().Select().ToArray();
            var s = Console.ReadLine();

            int a = 0;
            int b = 0;
            for (int i = 0; i < 3; i++)
            {
                if (s[i] == 'B') b = 1;
                if (s[i] == 'A') a = 1;
            }

            if (a == 0 || b == 0) Console.WriteLine("No");
            else Console.WriteLine("Yes");
        }
    }
}


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

int SelectionSort(vector<int> &a) {
  int n = a.size(), min_j, swap_times = 0;
  for (int i = 0; i < n - 1; ++i) {
    min_j = i;
    for (int j = i + 1; j < n; ++j) { 
      if (a[j] < a[min_j]) {
        min_j = j;
      }
    }
    if (i != min_j) {
      swap(a[i], a[min_j]);
      ++swap_times;
    }
  }
  return swap_times;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int res = SelectionSort(a);
  cout << a[0];
  for (int i = 1; i < n; ++i) {
    cout << ' ' << a[i];
  }
  cout << endl;
  cout << res << endl;
}


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

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

    double val1=(double)b*10;
    double val2;
    int sub_val;

    for(double i=0;i<10;++i){
        val2=(val1+i)*0.08;
        sub_val=val2;
        if(sub_val==a){
            cout << val1+i <<endl;
            return 0;
        }
    }

    cout << -1 <<endl;
    
    return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
ans = float('inf')
for i in [1, -1]:
    for j in [1, -1]:
        if b * i >= a * j:
            tmp = b * i - a * j
            if i == -1:
                tmp += 1
            if j == -1:
                tmp += 1
            ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int x[n],y[n];
  double p1=0,p2=0,p3=0,p4=0;
  for(int i=0;i<2*n;i++){
    if(i<n)cin>>x[i];
    else {cin>>y[i-n];
          p1+=fabs(x[i-n]-y[i-n]);
          p2+=pow((x[i-n]-y[i-n]),2);
          p3+=pow(fabs((x[i-n]-y[i-n])),3);
          p4=max(p4,fabs(x[i-n]-y[i-n]));}
           
  }
  p2=fabs(sqrt(p2));
  p3=cbrt(p3);
    
  printf("%f\n%f\n%f\n%f\n",p1,p2,p3,p4);
      
  return 0;
}


Measured memory_bytes: 3344
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

void ng(){
  cout << -1 << endl;
  exit(0);
}
int main(){
  int n;
  cin >> n;
  vector<int> ans(n);
  vector<int> b(n), a(n);
  for(int i = 0;i < n;i++){
    cin >> b[i];
    a[i] = b[i];
  }
  for(int i = n-1;i >= 0;i--){
    int nxt = -1;
    for(int j = a.size() - 1;j >= 0;j--){
      if(a[j] == j + 1){
	nxt = j;
	break;
      }
    }
    if(nxt == -1)ng();
    a.erase(a.begin() + nxt);
    ans[i] = nxt;
  }

  for(int i = 0;i < n;i++)cout << ans[i]+1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
 
int main() {
    int d;
    while (cin >> d, d) {
        int n, m;
        cin>>n>>m;
        int shop[114514];
        shop[0] = 0;
        for (int i = 1;i < n;i++)cin >> shop[i];
        shop[n] = d;
        
        sort(shop,shop+n);
        int ans = 0;
         
        for (int i = 0;i < m;i++) {
            int k;
            cin >> k;
            int lb = -1;
            int ub = n + 2;
            int dif = 1.7e9;
            while (ub - lb > 1) {
                int mid = (lb + ub) / 2;
                if (shop[mid] <= k) {
                    lb = mid;
                    dif = min(dif, abs(k - shop[mid]));
                }
                else {
                    ub = mid;
                    dif = min(dif, abs(k - shop[mid]));
                }
            }
            ans += dif;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3524
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var D = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        var ans = 0;

        for (int i = 0; i < N; i++)
        {
            for (int j = i + 1; j < N; j++)
            {
                ans += D[i] * D[j];
            }
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 28164
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << ", "
template <typename T> ostream& operator<<(ostream& _o_, const vector<T>& _v_){ \
 if(!_v_.empty()){_o_<<'[';copy(_v_.begin(),_v_.end(),ostream_iterator<T>(_o_,", "));_o_<<"\b\b]";}return _o_;}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
typedef unsigned int uint;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unsigned char uchar;
struct secure_hash {
 static uint64_t splitmix64(uint64_t x) {
  x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); }
 size_t operator()(uint64_t x) const {
  static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } };
template<typename T> using V = vector<T>;
template<typename T, typename U> using umap = unordered_map<T,U,secure_hash>;
template<typename T> using uset = unordered_set<T,secure_hash>;
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using max_heap = priority_queue<T>;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    V<V<int>> dp(n+1, V<int>(m+1, 0));
    rep(i,0,n+1) dp[i][0] = 0;
    rep(j,0,m+1) dp[0][j] = 0;
    rep(i,1,n+1) rep(j,1,m+1) {
        if (s[i-1] == t[j-1]) {
            dp[i][j] = max(dp[i][j], dp[i-1][j-1]+1);
        }
        else {
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
            dp[i][j] = max(dp[i][j], dp[i][j-1]);
        }
    }
    int i = n;
    int j = m;
    string ans = "";
    while (i > 0 and j > 0) {
        if (s[i-1] == t[j-1]) {
            ans += s[i-1];
            --i;
            --j;
        }
        else if (dp[i][j] == dp[i-1][j]) {
            --i;
        }
        else {
            --j;
        }
    }
    rep(i,ans.size(),0) cout << ans[i];
    cout << endl;
}


Measured memory_bytes: 35584
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <utility>
#include <algorithm>
#include <set>
#include <queue>
#include <climits>
#include <limits>
#define inf 1000000000000000000

#define ll long long
#define max(A, B) ((A) > (B) ? (A) : (B))
#define min(A, B) ((A) < (B) ? (A) : (B))
#define pair(A, B) make_pair(A, B)

using namespace std;

typedef pair<int, int> pi;
typedef pair<pair<int, int>, int> pii;

void perform() {
  int n, x, y; cin >> n >> x >> y;
  vector<int> adj[n];
  int ans[n];
  for (int i = 1; i < n; i++) {
    ans[i] = 0;
    adj[i].push_back(i-1);
    adj[i-1].push_back(i);
  }
  adj[x-1].push_back(y-1);
  adj[y-1].push_back(x-1);
  bool global[n];
  for (int i = 0; i < n; i++) global[i] = false;
  for (int i = 0; i < n; i++) {
    priority_queue<pi, vector<pi>, greater<pi>> q;
    bool marked[n];
    for (int j = 0; j < n; j++) marked[j] = false;
    global[i] = marked[i] = true;
    q.push(pair(0, i));
    while (!q.empty()) {
      pi v = q.top();
      q.pop();
      for (int k = 0; k < adj[v.second].size(); k++) {
        if (!marked[adj[v.second][k]]) {
          if (!global[adj[v.second][k]]) ans[v.first+1]++;
          q.push(pair(v.first+1, adj[v.second][k]));
          marked[adj[v.second][k]] = true;
        }
      }
    }
  }
  for (int i = 1; i < n; i++) cout << ans[i] << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll t = 1; //cin >> t;
  while (t--) {perform();}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<int> x(n);
	for(int i=0; i<n; ++i){
		cin >> x[i];
	}

	int ans=1e9;
	for(int i=1; i<=100; ++i){
		int d=0;
		for(int j=0; j<n; ++j){
			d += (x[j]-i)*(x[j]-i);
		}
		ans = min(ans,d);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
					  cerr << "\n\n" << "Time elapsed: " << \
					  (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
					  return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<db , db>
#define pll pair<ll , ll>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define inf 100000000000000007
#define eps 0.000001
#define stp fixed<<setprecision(20)
#define endl '\n'

ll dp[100005];

int main()
{
	start_routine();
	fastio;


    ll n;cin>>n;
    ll k=2;
    //cin>>k;
    ll h[n+1]={0};

    for(ll i=1;i<=n;i++)
    {
    	dp[i]=inf;
    	cin>>h[i];
    }

    dp[1]=0;
    for(ll i=2;i<=n;i++)
    {
    	ll mn=inf;
    	for(ll j=i-1;j>=max(i-k,1ll);j--)
    		mn=min(mn,dp[j]+abs(h[j]-h[i]));
    	dp[i]=mn;
    }

    cout<<dp[n];
	end_routine();
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	int a[n];
	rep(i, n) cin >> a[i];
	ll ans = 0;
	rep(i, n) {
		ans += a[i] / 2;
		if (i != n - 1) {
			if (a[i] % 2 and a[i + 1] != 0) a[i + 1] += a[i] % 2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4012
nm = list(map(int, input().split()))
a = list(map(int, input().split()))

treshold = sum(a)/(4*nm[1])
judge = 'Yes'
for i in range(nm[1]):
    a_max = max(a)
    a[a.index(a_max)] = 0
    if a_max < treshold:
        judge = 'No'
        break

print(judge)


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

class Solution
{
    static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        long n = vals[0];
        long m = vals[1];

        long time = m * 1900 + (n - m) * 100;

        double sum = 0;
        double okRate = 1 / Math.Pow(2, m);
        double curRate = 1;
        for (int i = 1; true; i++)
        {
            var curTime = time * i * curRate * okRate;

            if (curTime < 0.01)
            {
                break;
            }
            sum += curTime;
            curRate = curRate * (1 - okRate);
        }

        Console.WriteLine(Math.Round(sum));
    }
}

Measured memory_bytes: 13396
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	ans := "No"
	for i := 0; 7*i <= n; i++ {
		if (n-7*i)%4 == 0 {
			ans = "Yes"
		}
	}
	fmt.Println(ans)
}


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

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll N;
  cin >> N;
  vector<ll> A(N);
  ll sum = 0;
  map<ll,ll> cnt; // { value => count }
  rep(i,N) {
    cin >> A[i];
    ++cnt[A[i]];
    sum += A[i];
  }
  // Here, cnt has value => count
  // printmap(cnt);
  // cout << "sum:" << sum << endl;

  ll Q;
  cin >> Q;
  vector<ll> B(Q), C(Q);
  rep(i,Q) {
    cin >> B[i] >> C[i];
  }

  rep(i,Q) { // for (int i = 0; i < q; ++i) {
    ll diff = (C[i]-B[i])*cnt[B[i]];
    cnt[C[i]] += cnt[B[i]];
    cnt[B[i]] = 0;
    sum += diff;
    cout << sum << endl;
  }
}


Measured memory_bytes: 11556
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long LL;

LL powmod(LL a, LL n){
	if(n == 0) return 1;
	if(n % 2) return (a*powmod(a,n-1)) % MOD;
	LL c = powmod(a,n/2);
	return (c*c) % MOD;
}
LL inv(LL a){
	return powmod(a,MOD-2) % MOD;
}


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

	/*LL dp[310][310]; // how many left to visit;
	for(LL i = 0; i <= n; i++) dp[0][i] = 0;
	dp[0][n] = 1;
	for(LL j = 0; j < m; j++){
		for(LL i = 0; i <= n; i++) dp[j+1][i] = 0;
		for(LL i = 0; i <= n; i++){
			dp[j+1][i] += (n-i) * dp[j][i];
			dp[j+1][i] %= MOD;
			if(i > 0){
				dp[j+1][i-1] += (i) * dp[j][i];
				dp[j+1][i-1] %= MOD;
			}
		}
	}*/
	LL dp[2][310][310]; // home, unvis;
	for(LL i = 0; i < 310; i++) for(int j = 0; j < 310; j++) dp[0][i][j] = dp[1][i][j] = 0;
	dp[0][1][n-1] = 1;
	for(LL c = 0; c < m; c++){
		for(LL i = 0; i < 310; i++) for(int j = 0; j < 310; j++) dp[1-c%2][i][j] = 0;
		for(LL j = 0; j <= n; j++){
			for(LL k = 0; k + j <= n; k++){
				dp[1-c%2][n-k][k] += j*dp[c%2][j][k];
				dp[1-c%2][n-k][k] %= MOD;

				if(k > 0) dp[1-c%2][j][k-1] += k*dp[c%2][j][k];
				if(k > 0) dp[1-c%2][j][k-1] %= MOD;

				if(n-j-k > 0) dp[1-c%2][j][k] += (n-j-k)*dp[c%2][j][k];
				if(n-j-k > 0) dp[1-c%2][j][k] %= MOD;

			}
		}
	}
	cout << dp[m%2][n][0] << endl;
}


Measured memory_bytes: 1792
N, K = map(int, input().split())

dic = {}
for i in range(N):
    a, b = map(int, input().split())
    if a in dic:
        dic[a] += b
    else:
        dic[a] = b
keys = list(dic.keys())
keys.sort()

cur_pos = 0
for key in keys:
    b = dic[key]
    cur_pos += b
    if cur_pos >= K:
        print(key)
        break

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
        b.at(i) = a.at(i);
    }
    sort(b.begin(),b.end(),greater<int>());
    int max1=b.at(0),max2=min(b.at(0),b.at(1));

    //cout << max1 << " " << max2 << endl;

    for(int i=0;i<n;i++){
        if(a.at(i)==max1){
            cout << max2 << endl;
        }else{
            cout << max1 << endl;
        }
    }    
}


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

int main() {
  string s; cin >> s;
  int len = 0;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
      len += 1;
      ans = max(ans, len);
    } else {
      len = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
use std::collections::HashSet;
use std::io;

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

const SPLIT_DELIMITER: char = ' ';
#[allow(dead_code)]
fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

fn main() {
    let s = str2vec(&input_line_str());
    let mut set = HashSet::new();
    for z in s {
        set.insert(z);
    }
    if set.contains(&'a') && set.contains(&'b') && set.contains(&'c') {
        println!("Yes");
    } else {
        println!("No");
    }
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (300006)
int main(){
	FAST
	string b[3];
	cin>>b[0]>>b[1]>>b[2];
	ll ans = siz(b[0]) + siz(b[1]) + siz(b[2]);
	ll p[]={0,1,2};
	string a[3];
	do {
		a[0]=b[p[0]], a[1]=b[p[1]], a[2]=b[p[2]];
		vector<int>zero(siz(a[2])+1,0),one(siz(a[2])+1,0);
		FOR(i,0,siz(a[2])){
			zero[i]=1;
			DEC(j,siz(a[0])-1,max(0ll,siz(a[0])-i))if(a[0][j]!='?'&&a[2][i-(siz(a[0])-j)]!='?'
				&&
					a[0][j]!=a[2][i-(siz(a[0])-j)])zero[i]=0;
		}
		FOR(i,0,siz(a[2])){
			one[i]=1;
			DEC(j,siz(a[1])-1,max(0ll,siz(a[1])-i))if(a[1][j]!='?'&&a[2][i-(siz(a[1])-j)]!='?'
				&&
					a[1][j]!=a[2][i-(siz(a[1])-j)])one[i]=0;
		}
		FOR(i,0,siz(a[1])){
			bool can=1;
			DEC(j,siz(a[0])-1,max(0ll,siz(a[0])-i))if(a[0][j]!='?'&&a[1][i-(siz(a[0])-j)]!='?'
				&&
					a[0][j]!=a[1][i-(siz(a[0])-j)])can=0;
			if(!can)continue;
			FOR(k,0,siz(a[2])){
				if(one[k] && zero[max(0ll,k-(siz(a[1])-i))]){
					ans=min(ans,siz(a[0])+siz(a[1])+siz(a[2])-min(siz(a[0]),i)-min(siz(a[0])+siz(a[1])-min(siz(a[0]),i), k));
				}
			}
		}
	} while(next_permutation(p,p+3));
	cout<<ans<<'\n';
}


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

int main(){
	string str;
	cin >> str;
	
	for(int i=1; i<(int)str.length(); i++){
		if(str[i-1]==str[i]){
			cout << i << " " << i+1 << endl;
			return 0;
		}
	}
	
	for(int i=2; i<(int)str.length(); i++){
		if(str[i-2]==str[i]){
			cout << i-1 << " " << i+1 << endl;
			return 0;
		}
	}
	
	cout << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

int n, A, B, C;
vector<int> l(10);

int dfs(int now, int a, int b, int c) {
  // すべての竹を使い切ったとき
  if(now==n) {
    // 長さ 0 の竹は存在しない
    if(a==0 || b==0 || c==0) return 1e9;
    else return abs(A-a)+abs(B-b)+abs(C-c);
  }
  // res := 消費MP
  int res = 1e9;
  res = min(res, dfs(now+1, a, b, c));            // l[now]を使わない
  res = min(res, dfs(now+1, a+l[now], b, c)+10);  // a の材料に l[now] を使う
  res = min(res, dfs(now+1, a, b+l[now], c)+10);
  res = min(res, dfs(now+1, a, b, c+l[now])+10);

  return res;
}

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

  cin >> n >> A >> B >> C;
  rep(i, n) cin >> l[i];

  // 竹 a, b, c について, 初めに余分な合成魔法(0 + l[now])をそれぞれ 1 回ずつ使った誤差を引く
  cout << dfs(0, 0, 0, 0)-30 << '\n';
  return 0;
}


Measured memory_bytes: 256
w, h, x, y = map(int, input().split())

s = w * h / 2

if 2 * x == w or 2 * y == h:
    if 2 * x == w and 2 * y == h:
        judge = '1'
    else:
        judge = '0'
else:
    judge = '0'

print(s, judge)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion
#pragma region chminmax
template <typename T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

const ll INF = 1e18;

int main()
{
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];

    // if odd, you can have 2 spaces somewhere
    // if even you can have 1 space
    int k = 1 + n % 2;
    vvll dp(n + 1, vll(4, -INF));
    dp[0][0] = 0;

    rep(i, n) rep(j, k + 1)
    {
        // don't choose
        chmax(dp[i + 1][j + 1], dp[i][j]);

        // you need to choose one if
        // i odd, j odd:
        // e.g. i=3 j=1 then oxxo or xoxo are the possible states
        // in either case, you need to select a[i].
        // i even, j even:
        // e.g. i=2 j=0 then oxo
        // i=4 j=0 then oxoxo(x...)
        // i=4 j=2 then oxxxo
        // there are 3 selected from 5 in i=4 j=0
        // however, the final value is for dp[n][k] so it's ok
        // if k is 1 for even n, then dp[5][1] will be dp[4][0] or dp[4][1]

        if ((i + j) % 2 == 0)
            chmax(dp[i + 1][j], dp[i][j] + a[i]);
        else
            chmax(dp[i + 1][j], dp[i][j]);
    }
    cout << dp[n][k] << endl;

    return 0;
}

Measured memory_bytes: 18044
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner as = new Scanner(System.in);
		String n = as.next();

		String[] strArray = n.split("");

		int pcount = 0;
		int m = Integer.parseInt(n);



		for(int i=0;i<strArray.length;i++) {
			int tmp = Integer.parseInt(strArray[i]);

			pcount += tmp;
		}

		if(m%pcount == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 24148
#include <cstdio>
#include <cstring>
#include <iostream>
#include <set>
#include <vector>

#include <algorithm>

using namespace std;
#define DEBUG(X) cerr<<__LINE__<<" "<<#X<<": "<<X<<endl;
#define sci(x) int x;scanf("%d",&x);
#define scii(x, y) int x,y;scanf("%d%d",&x,&y);
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
vector<int> vec;

int main() {
  scii(N,M)
  REP(_,M) {
    scii(a,b);
    vec.push_back(a);
    vec.push_back(b);
  }
  REPP(i,N) {
    cout << count(vec.begin(), vec.end(), i) << endl;
  }
}

Measured memory_bytes: 256
//Resting_Prince
#include<bits/stdc++.h>
#define mod 1000000007
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef vector<ll> V;

int main()
{
    ios;
    ll n,i,j,a[4][4],b[11],c[4][4]={0};
    rep(i,0,2)rep(j,0,2)cin>>a[i][j];
    cin>>n;
    rep(i,0,n-1)cin>>b[i];
    rep(i,0,n-1)
    {
        rep(i1,0,2)
        {
            rep(i2,0,2)
            {
                if(a[i1][i2]==b[i])
                    c[i1][i2]=1ll;
            }
        }
    }
    ll ans=0;
    rep(i,0,2)
    {
        ll chck=0;
        rep(j,0,2)
        {
            chck+=(c[i][j]==1);
        }ans+=(chck==3);
    }
    rep(i,0,2)
    {
        ll chck=0;
        rep(j,0,2)
        {
            chck+=(c[j][i]==1);
        }ans+=(chck==3);
    }
    ll chck=0;
    rep(j,0,2)
    {
        chck+=(c[j][j]==1);
    }ans+=(chck==3);
    chck=0;i=2;
    rep(j,0,2)
    {
        chck+=(c[j][i]==1);
        i--;
    }ans+=(chck==3);
    if(!ans)cout<<"No";
    else cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
graph = [[] for i in range(N)]

for i in range(M):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  graph[a].append(b)
  graph[b].append(a) 
    
def dfs(x,g):
    if vis[x]:return
    vis[x]=1
    for i in g[x]:
     dfs(i,g)
    return

ans=0
for i in range(len(graph)):
    for j in range(len(graph[i])):
        t=graph[i]
        gn=graph[0:i]+[t[0:j]+t[j+1:]]+graph[i+1:]
        vis=[0]*N
        dfs(0,gn)
        if not(all(vis)):
            # print(i+1, graph[i][j]+1,gn,vis)
            ans+=1
print(ans)

Measured memory_bytes: 9240