akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;

namespace cswork
{
    class Program
    {
        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);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

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

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

        public Program() { }

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

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        public static List<long> GeneratePrime(long max)
        {
            long prime;
            double sqrtMax = Math.Sqrt(max);
            var primeList = new List<long>();

            List<long> searchList = new List<long>();
            for (long i = 2; i <= max - 1; i++)
            {
                searchList.Add(i);
            }

            do
            {
                prime = searchList.First();
                primeList.Add(prime);
                searchList.RemoveAll(n => n % prime == 0);
            } while (prime < sqrtMax);

            primeList.AddRange(searchList);

            return primeList;
        }

        void Omame()
        {
            cin = new Scanner();
            long X = cin.nextLong();

            List<long> list = new List<long>();

            list.Add(1);
            for (int i = 2; i <= Math.Pow(1000, 0.5); i++)
            {
                for (int j = 2; (long)Math.Pow(i, j) <= X; j++)
                {
                    list.Add((long)Math.Pow(i, j));
                }
            }

            Console.WriteLine(list.Max());

        }
    }
}


Measured memory_bytes: 13396
def solve():
    max_density = -1
    ans = [-1, -1]
    A, B, C, D, E, F = map(int, input().split())
    for a in range(0, F + 1, A * 100):
        for b in range(0, F - a + 1, B * 100):
            w = a + b
            if w == 0:
                continue
            max_s = min(F - w, w // 100 * E)
            for c in range(0, max_s + 1, C):
                for d in range(0, max_s - c + 1, D):
                    s = c + d
                    density = 100 * s / (w + s)
                    if density > max_density:
                        ans = [w + s, s]
                        max_density = density
    return ans


print(*solve())


Measured memory_bytes: 9116
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	long long min,n,k,a;
	scanf("%lld%lld",&n,&k);
	if(k==1) {printf("0");return 0;}
	n=n%k;
	if(abs(n-k)<n) n=abs(n-k);
	printf("%lld",n);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll unsigned long long int
#define max 2147483647
using namespace std;

int dp[100005], n;
int a[100005];

ll f(int i)
{
	if (i == (n - 1))
	{
		return 0;
	}
	if (i >= n)
	{
		return max;
	}
	if (a[i] != -1)
	{
		return a[i];
	}

	int r = max;

	return a[i] = min(
			   f(i + 2) + abs(dp[i + 2] - dp[i]),
			   f(i + 1) + abs(dp[i + 1] - dp[i]));
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	memset(a, -1, sizeof a);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> dp[i];
	}
	cout << f(0) << "\n";
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PI (acos(-1))
#define ct cout<<
#define cn cin>>
#define spc <<" "<<
#define nl puts("")
#define _fl(x) puts("FLAG " #x);
#define  _(x)  cout<< #x <<" is "<< x <<endl;
#define fs first
#define sc second
#define pb push_back
#define all(v)  (v).begin(), (v).end()
#define _109 (1000000000)
#define _0(arr) memset(arr,0,sizeof ( arr ) )
#define _1(arr) memset(arr,-1,sizeof ( arr ) )
#define _ninp(n,arr) for(int i=0; i<n;i++)cin>>arr[i];
#define _nout(n,arr) for(int i=0; i<n;i++)cout<<arr[i]<<" \n"[i==n-1];
double _eps=1e-6;
long long gcd(long long a, long long b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main() {

    ll n,k;
    cn n>>k;

    if(n>=k){
     
       ll d=n/k;

       ll x=(n-d*k);
       ll p=abs(n-(d+1)*k);


       ct min(x,p);
    }
    else {

        ll x=abs(n-k);

    	ct min(x,abs(x-k));
    }



   nl;



    return 0;
}


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

#define endl '\n'

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

    int n;
    cin >> n;
    vector <int> A(n);
    for(int i = 0; i < n; i++) {
        cin >> A[i];
    }
    int cnt = 1;
    int res = 0;
    for(int i = 1; i < n; i++) {
        if(A[i - 1] == A[i]) {
            cnt++;
        }
        else {
            res += cnt / 2;
            cnt = 1;
        }
    }
    res += cnt / 2;
    cout << res;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
 
int main() {
	ll a,b,c;
	cin>>a>>b;
	c=__gcd(a,b);
	a*=b;
	a/=c;
	cout<<a;
	return 0;
}

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

template<typename T>
struct BIT {
    BIT(int n) : n(n), bit(n + 1, 0) { }
    // i is 0-indexed.
    void add(int i, T x) {
        for (++i; i <= n + 1; i += i & -i) bit[i] += x;
    }
    // [0, i), i is 0-indexed.
    T sum(int i) {
        T res = 0;
        for (; i > 0; i -= i & -i) res += bit[i];
        return res;
    }
    // [l, r), l and r is 0-indexed.
    T sum(int l, int r) {
        return sum(r) - sum(l);
    }
private:
    int n;
    vector<T> bit;
};

/*
    verified http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B&lang=jp
*/
int main() {
    int n, q; cin >> n >> q;
    BIT<int> bit(n);
    for (int i = 0; i < q; ++i) {
        int com, x, y; cin >> com >> x >> y;
        if (com == 0) bit.add(--x, y);
        else cout << bit.sum(--x, y) << endl;
    }
}



Measured memory_bytes: 3136
#include <iostream>
#include <iomanip>
#include <stdio.h>
using namespace std;

double recurse(int N, int ones, int twos, int threes);
static double dp[301][301][301];

int main()
{
    /*
    for (int i = 0; i < 903; i++) {
        for (int j = 0; j < 903; j++) {
            for (int k = 0; k < 903; k++) {
                dp[i][j][k] = -1.0;
            }
        }
    }

    printf("Done filling array\n");
    */
    int N;

    cin >> N;

    int ones = 0;
    int twos = 0;
    int threes = 0;

    for (int i = 0; i < N; i++)
    {
        int tmp;

        cin >> tmp;

        if (tmp == 1)
        {
            ones++;
        }
        else if (tmp == 2)
        {
            twos++;
        }
        else
        {
            threes++;
        }
    }

    cout << setprecision(15);
    cout << ones + twos * 2 + threes * 3 + recurse(N, ones, twos, threes) << endl;
}

double recurse(int N, int ones, int twos, int threes)
{
    //Base case:
    if (ones == 0 && twos == 0 && threes == 0)
    {
        return 0.0;
    }

    if (dp[ones][twos][threes] != 0.0)
    {
        //printf("Used value here!\n");
        return dp[ones][twos][threes];
    }
    //Find probability of wasting a move
    int nonEmptyPlates = ones + twos + threes;
    double p_wasted = 1.0 - (double)nonEmptyPlates / N;

    double p1 = 0.0;
    double p2 = 0.0;
    double p3 = 0.0;

    //printf("State: ones = %d, twos = %d, threes = %d, p_wasted = %f\n", ones, twos, threes, p_wasted);

    if (ones > 0)
    {
        p1 = (double)ones / nonEmptyPlates * recurse(N, ones - 1, twos, threes);
    }

    if (twos > 0)
    {
        p2 = (double)twos / nonEmptyPlates * recurse(N, ones + 1, twos - 1, threes);
    }

    if (threes > 0)
    {
        p3 = (double)threes / nonEmptyPlates * recurse(N, ones, twos + 1, threes - 1);
    }

    dp[ones][twos][threes] = p1 + p2 + p3 + p_wasted / (1 - p_wasted);
    return dp[ones][twos][threes];
    //return p1 + p2 + p3 + p_wasted / ((1 - p_wasted) * (1 - p_wasted)) * prob;
}

Measured memory_bytes: 111188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int go(int x){
	int cont=0;
	for(int m=2;m*m<=(2*(x-2));m++){
		for(int n=2;n*n<=(2*(x-2));n++){
			int t=(2*x)-(m*m)-(n*n);
			if(t>=4){
				int y=sqrt(t);
				if(t==y*y){
					int a=(m+y-n)/2;
					int b=(m+n-y)/2;
					int c=(n+y-m)/2;
					int l=(a*a)+(b*b)+(c*c)+(a*b)+(a*c)+(b*c);
				    if(l==x){
						if(a>=1 && b>=1 && c>=1) cont++;
					}
				}
			}
		}
	}
	return cont;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n; cin>>n; 
	for(int i=1;i<=n;i++){
		cout<<go(i)<<"\n";
	}
    return 0;
}	



Measured memory_bytes: 3548
from fractions import gcd
N, K = map(int, input().split())
A = list(map(int, input().split()))

g = A[0]
mx = A[0]
for i in range(N-1):
    g = gcd(g, A[i+1])
    mx = max(mx, A[i+1])

if K%g == 0 and K <= mx:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 16208
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()

int main() {
	int H,W;
	cin>>H>>W;
	vector<string> S(H);
	rep(i,H){
		cin>>S[i];
	}
	string ans = "Yes";
	rep1(i,H-1)rep1(j,W-1)
	if(S[i][j] == '#')
	if(S[i+1][j]!='#'&&S[i][j+1]!='#'&&S[i-1][j]!='#'&&S[i][j-1]!='#')
	ans = "No";

	cout<<ans<<endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

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

    if(X == 3 || X == 5 || X == 7) {
        cout << "YES";
    }
    else {
        cout << "NO";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
//A	Don't be late

#include <iostream>
#include <string>
using namespace std;

int main() {
    double D,T,S;
    double A;
    cin >> D >> T >> S;
    A = D / S;
    //cout << A << endl;

    
      if (A <= T) cout << "Yes" << endl;
      else cout << "No" << endl;
}


Measured memory_bytes: 3712
import java.util.*;
import java.lang.Math.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		if(s.charAt(2)==s.charAt(3)&&s.charAt(4)==s.charAt(5))System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 22740
from heapq import heapify, heappop, heappush

N = int(input())
A = list(map(int, input().split()))
A = [-a for a in A]

L = [[a, i] for i, a in enumerate(A[:2*N])]
Sl = 0
heapify(L)
used = set()
for i in range(N):
  a, i = heappop(L)
  used.add(i)
  Sl -= a

R = A[2*N:].copy()
Sr = -sum(R)
heapify(R)

ans = Sl - Sr
for i in range(2*N-1, N-1, -1):
  a = - A[i]
  r =  - heappop(R)
  if a > r:
    heappush(R, -r)
  else:
    Sr += a - r
    heappush(R, -a)
  if i in used:
    while L:
      l, j = heappop(L)
      l *= -1
      if j < i:
        Sl += l - a
        used.add(j)
        break
  ans = max(ans, Sl - Sr)

print(ans)

Measured memory_bytes: 54736
#include<string>
#include<map>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<ctime>
#include<iostream>
#define ps puts("")
#define fi first
#define nd second
#define mset(x) memset((x), 0, sizeof (x))
#define mk make_pair
#define sqr(x) ((x)*(x))
#define pii pair<ll,int>
using namespace std;
typedef long long ll;
inline ll read() {
    ll x = 0; char f = 1, 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;
}
void write(ll x) { if (x < 0) x = -x, putchar('-'); if (x > 9) write(x / 10); putchar(x % 10 + '0'); }
inline void writeln(ll x) { write(x); puts(""); }
const int N = 1234456; 
int n, a[N], b[N], ans = 1e9, c1[N], c2[N]; 
int check(int x, int y) {
	int res = 0;
	for(int i = 1; i <= n / 2; ++i)
		res += a[i] != x;
	for(int i = 1; i <= n / 2; ++i)
		res += b[i] != y;	
	return res;
}
int main() {
	n = read();
	for(int i = 1; i <= n / 2; ++i)
		a[i] = read(), b[i] = read(), c1[a[i]]++, c2[b[i]]++;
	int p1 = 0, p2 = 0, p3 = 0, p4 = 0;
	for(int i = 1; i <= 100000; ++i) {
		if(c1[i] > c1[p1]) p2 = p1, p1 = i;
		else if(c1[i] > c1[p2]) p2 = i;
		if(c2[i] > c2[p3]) p4 = p3, p3 = i;
		else if(c2[i] > c2[p4]) p4 = i; 
	}
	if(p1 != p3) ans = min(ans, check(p1, p3));
	if(p1 != p4) ans = min(ans, check(p1, p4));
	if(p2 != p3) ans = min(ans, check(p2, p3));
	if(p2 != p4) ans = min(ans, check(p2, p4));
	writeln(ans);
	return 0;
}

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

int main () {
  int a, b, c;
  cin >> a >> b >> c;
  int counter = 0;
  for(int i = a; i <= b; i++) {
    // 自身を含める。
    // cout << i << endl;
    if (c % i == 0) counter++;
  }
  cout << counter << endl;
  return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define int long long
using namespace std;
pair<int, int> pref[1000010];
int kek[1000010];
signed main(){
    int n;
    string s;
    cin >> n >> s;
    pref[0] = {0, 0};
    kek[0]=0;
    int S = 0;
    for (int i=0; i < n; i++){
        pref[i+1] = pref[i];
        if (s[i] == 'M') S++;
        if (s[i] == 'C'){
            pref[i+1].first++;
            pref[i+1].second += S;
        }
        kek[i+1] = S;
    }
    int q;
    cin >> q;
    for (int i=0;i<q;i++){
        int k;
        cin >> k;
        int ans=0;
        for (int j=0;j<n;j++){
            if (s[j] == 'D'){
                int right = min(n-1, j+k-1);
                int number = pref[right+1].first - pref[j].first;
                int sm = pref[right+1].second - pref[j].second - number*kek[j];
               // cout << pref[right+1].second << " " << pref[j].second << endl;
                ans+=sm;
            }
        }
        cout << ans << endl;
    }


}


Measured memory_bytes: 24836
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int tc = 1;
    //cin >> t;
    while(tc--)
    {
        int a, b, c, k, ans = 0;
        cin >> a >> b >> c >> k;

        int x = min(k , a);
        k -= x;
        ans += x;
        if(k > 0){
            x = min(k , b);
            k -= x;
            if(k > 0){
                x = min(k , c);
                ans -= x;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3660
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Hamza Hasbi
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        A_restricted solver = new A_restricted();
        solver.solve(1, in, out);
        out.close();
    }

    static class A_restricted {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            out.printLine(a + b >= 10 ? "error" : a + b);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer st;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

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

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

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <math.h>
#include <cmath>
#include <ctime>
#include <stdlib.h>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define m_t make_tuple
#define rep(i,n)  for(int i=0; i<(int) (n); i++)


const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 1000000021;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	return lower_bound(all(vec), xx) - vec.begin();
}
template<typename T>void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>void vecin(vector<TT>& vec) {
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}
template<class tt> struct counter {
	map<tt, int>mp;
	bool add(tt t, int xx) {
		if (!mp.count(t)) {
			mp[t] = xx;
			return true;
		}
		mp[t] += xx;
		if (!mp[t]) {
			mp.erase(t);
		}
		return false;
	}
};

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
long long modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

bool chmax(int& xx, int yy) {
	if (xx < yy) {
		xx = yy;
		return true;
	}
	return false;
}
bool chmin(int& xx, int yy) {
	if (xx > yy) {
		xx = yy;
		return true;
	}
	return false;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx <= 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int n, d,a,b,ans=0;
	cin >> n >> d;
	d *= d;
	rep(i, n) {
		cin >> a >> b;
		if (a * a + b * b <= d) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r,s=0;
    cin>>n;
    ll a[n+2];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    cin>>m;
    for(i=0;i<m;i++)
    {
        cin>>l>>r;
        s=0;
        for(j=0;j<n;j++)
        {
            if(j+1ll==l)
            {
                s+=r;
            }
            else
            {
                s+=a[j];
            }
        }
        cout<<s<<"\n";
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};

int main(void){
    int N,K;
    cin >> N >> K;
    cout << N - K + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  int c = a + b, d = a - b, e = a * b;
  cout << max({c, d, e}) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

set<lint> divisors(lint N)
{
    set<lint> divset;
    lint N2 = N;
    divset.insert(1LL);
    divset.insert(N);
    FOR(d, 2LL, min(1000001LL, N + 1)) {
        if (N % d == 0) {
            while (N2 % d == 0)
                N2 /= d;
            divset.insert(d);
            divset.insert(N / d);
        }
    }

    divset.insert(N2);
    return divset;
};

lint f(lint N, lint K)
{
    if (K == 1)
        return -1;

    while (N % K == 0)
        N /= K;
    return N % K;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    lint N;
    cin >> N;

    int ret = 0;
    for (lint K : divisors(N - 1))
        if (f(N, K) == 1)
            ret++;

    for (lint K : divisors(N))
        if (f(N, K) == 1)
            ret++;

    cout << ret << endl;
    return 0;
};

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,m,r;

template<class T> 
class DK{
public:
    struct edge{
        ll to;
        T cost;
        edge(ll _to,T _cost):to(_to),cost(_cost){}
    };

    vector<T> d;
    vector<vector<edge>> G;

    DK(ll _n){
        d.resize(_n);
        G.resize(_n);
    }

    //無向辺
    void add_edge(ll from,ll to,T cost){
        G[from].push_back(edge(to,cost));
        // G[to].push_back(edge(from,cost));
    }

    void dijkstra(ll start){
        fill(ALL(d),INF);
        d[start] = 0;

        typedef pair<T,ll> PP;
        priority_queue<PP, vector<PP>, greater<PP>> que;
        que.push(PP(0,start));

        while (!que.empty()){
            PP p = que.top();
            que.pop();
            ll v = p.second;
            T cost = p.first;
            if(cost > d[v])continue;
            rep(i,G[v].size()){
                edge e = G[v][i];
                ll to = e.to;
                T ncost = cost + e.cost;
                if (d[e.to] > ncost){
                    d[e.to] = ncost;
                    que.push(PP(d[e.to],to));
                }
            }
        }
    }
};

int main(){
    cin >> n >> m >> r;
    DK<ll> dk(n);
    rep(i,m){
        ll x,y; 
        ll z;
        cin >> x >> y >> z;
        dk.add_edge(x,y,z);
    }
    dk.dijkstra(r);
    rep(i,n){
        if(dk.d[i] == INF)cout << "INF" << endl;
        else cout << dk.d[i] << endl;
    }
}


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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve()
{
    int n, k;
    cin >> n >> k;
    int ans = INT32_MAX;
    for(int i = 0; i <= n; i++){
        int subAns = (1 << i) + (k*(n-i));
        ans = min(ans, subAns);
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	n <- readInt
	ps <- readInts
	print $ solve n ps

solve _ [] = 0
solve m (p:ps) = d + solve ( min m p ) ps
	where
		d = if p <= m then 1 else 0

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

#define    ll     long long int

int main( )
{
    int n, m;
    map<string, int> mp1, mp2;
    int i, j, k, l;
    string s;
    vector<string> v;
    cin >> n;
    for (i = 0; i < n; i++) {
        cin >> s;
        v.push_back(s);
        mp1[s]++;
    }
    cin >> m;
    for (i = 0; i < m; i++) {
        cin >> s;
        mp2[s]++;
    }
    int mx = 0;
    for (i = 0; i < n; i++) {
        int x = mp1[v[i]];
        int y = mp2[v[i]];
        mx = max(mx, x - y);
    }
    cout << mx << '\n';
    return 0;
}

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

void Main(){
    
}

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

  if(a > b) swap(a, b);
  if(b > c) swap(b, c);
  if(a > b) swap(a, b);
  
  cout<<a<<" "<<b<<" "<<c<<endl;
}


Measured memory_bytes: 3068
#include <iostream>
using namespace std;
int S[32];
int main() {
  ios::sync_with_stdio(false);
  int N, M, K, A;
  cin >> N >> M;
  for (int i=0; i<N; i++) {
    cin >> K;
    for (int j=0; j<K; j++) {
      cin >> A;
      S[A]++;
    }
  }
  int ret = 0;
  for (int i=1; i<=M; i++) {
    if (S[i] == N) ret++;
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
S = input()

N = len(S)
import sys

for i in range(1,N-1):
    if i%2 == 0:
#         print(S[:(N+1-i)//2],S[(N+1-i)//2:N-i])
        if S[:(N+1-i)//2] == S[(N+1-i)//2:N-i]:
            print(N-i)
            sys.exit()

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

bool dfs(int i, vector<int> &s, vector<vector<int>> &g) {
  s[i] = 1;
  for (auto j : g[i]) {
    if (s[j] == 1) return false;
    if (s[j] == 0) {
      if (!dfs(j, s, g)) return false;
    }
  }
  s[i] = -1;
  return true;
}

int main() {

  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    g[a].emplace_back(b);
  }

  vector<int> s(n);
  bool is_a = true;
  rep(i, n) {
    if (s[i] == 0) {
      if (!dfs(i, s, g)) is_a = false;
    }
  }

  cout << (is_a ? 0 : 1) << endl;
  return 0;
}



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

int main()
{
    int k;
    string s;
    cin>>k>>s;
    if(s.length() <= k){
        cout<<s;
    }else{
        for(int i=0;i<k;i++){
            cout<<s[i];
        }
        cout<<"...";
    }
}


Measured memory_bytes: 3628
from itertools import accumulate


def get_dist(cur, nxt):
    return abs(cur[0] - nxt[0]) + abs(cur[1] - nxt[1])


H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

pos = {}
for i in range(H):
    for j in range(W):
        pos[A[i][j] - 1] = (i, j)

acc = []
for i in range(D):
    res = [0]
    now = i
    while now + D < H * W:
        nxt = now + D
        res.append(get_dist(pos[now], pos[nxt]))
        now = nxt
    acc.append(list(accumulate(res)))

Q = int(input())
for _ in range(Q):
    ans = 0
    L, R = map(int, input().split())
    L -= 1
    R -= 1
    path = acc[L % D]
    print(path[R // D] - path[L // D])


Measured memory_bytes: 36256
#include <iostream>
using namespace std;
 
int main()
{
    int a,b,c,x,y;
    int ans = 0;
    cin >> a >> b >> c >> x >> y;
    if(a+b < 2*c)
    {
        ans = a*x+b*y;
    }
    else
    {
        int minNum = min(x,y);
        int maxNum = max(x,y);
        if(x < y)
        {
            ans += b*(y-x);
        }
        else
        {
            ans += a*(x-y);
        }
        
        ans += minNum*2*c;
        ans = min(maxNum*2*c, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a=list(input())
c=[chr(i) for i in range(97, 97+26)]
ct=[0 for i in range(26)]
n=len(a)
for i in range(n):
  ct[c.index(a[i])]+=1
ans=0
for i in range(26):
  ans+=(n-ct[i])*ct[i]
print(ans//2+1)

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

int main()
{
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s == "Sunny")
    {
        cout << "Cloudy";
    }
    else if(s == "Cloudy")
    {
        cout << "Rainy";
    }
    else
    {
        cout << "Sunny";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a,sum=0;
	for(int i=1;i<=n;i++){
		cin>>a;
		while(a%2==0){
			a/=2;
			sum++;
		}
	}
	cout<<sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INT(a) scanf("%d",&a)
#define STR(a) scanf("%s",a)
#define DBL(a) scanf("%lf",&a)
#define LNG(a) scanf("%lld",&a)
#define PI acos(-1)

int main(){
	string s;
	cin>>s;
	int year=(s[5]-'0')*10+(s[6]-'0');
	
	if(year>4) cout<<"TBD\n";
	else cout<<"Heisei\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll) 1000000007
#define P pair<ll, ll>

ll now, ans;
string s;
int main() {
	cin >> s;
	REP(i, s.size()) {
		if (s[i] == 'A')now++;
		else if (i != s.size() - 1) {
			if (s[i] == 'B' and s[i + 1] == 'C') {
				ans += now;
				i++;
			}
			else now = 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
	int a, b;
	char op;
	scanf("%d %c %d",&a ,&op ,&b);
	while(op != '?'){
		if(op == '+')
			printf("%d\n", a+b);
		if(op == '-')
			printf("%d\n", a-b);
		if(op == '*')
			printf("%d\n", a*b);
		if(op == '/')
			printf("%d\n", a/b);
		scanf("%d %c %d",&a ,&op ,&b);
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
typedef long long ll;
const int N=250005,mo1=998244853,mo2=993244853;
struct pii{
	int x,y;
	inline void operator+=(const pii&rhs){x+=rhs.x-mo1;y+=rhs.y-mo2;x+=x>>31&mo1;y+=y>>31&mo2;}
	inline void operator-=(const pii&rhs){x-=rhs.x;y-=rhs.y;x+=x>>31&mo1;y+=y>>31&mo2;}
	inline pii operator*(const pii&rhs)const{return (pii){int(1ll*x*rhs.x%mo1),int(1ll*y*rhs.y%mo2)};}
	inline operator ll(){return (ll(x)<<30)|y;}
}f[N],mi[N*2],t,nw;
int n,i,p,pp[N];
char c[N];
std::unordered_map<ll,int>mp;
ll ans;
int main(){
	mi[0]=(pii){487619673,250267803};for(i=1;i<N*2;++i)mi[i]=mi[i-1]*(pii){789322,989432};
	scanf("%d%s",&n,c+1);
	for(i=1;i<=n;++i){
		if(c[i]=='+')nw+=mi[p+N];
		if(c[i]=='-')nw-=mi[p+N];
		if(c[i]=='>')++p;
		if(c[i]=='<')--p;f[i]=nw;pp[i]=p;
	}
	++mp[f[n]];
	for(i=1;i<=n;++i)ans+=mp[t=f[i]],t+=f[n]*mi[pp[i]+N],++mp[t];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 26996
import bisect
A, B, Q = map(int, input().split())
s = [-10**11] + [int(input()) for i in range(A)] + [10**11]
t = [-10**11] + [int(input()) for i in range(B)] + [10**11]

'''
def nibutans(x, l, r):
	if r - l <= 1:
		return max(r, l)
	nibu = (r + l) // 2
	return nibutans(x, nibu, r) if x > s[nibu] else nibutans(x, l, nibu)

def nibutant(x, l, r):
	if r - l <= 1:
		return max(r, l)
	nibu = (r + l) // 2
	return nibutant(x, nibu, r) if x > t[nibu] else nibutant(x, l, nibu)

for i in range(Q):
	x = int(input())
	sr, tr = nibutans(x, 0, A + 1), nibutant(x, 0, B + 1)
	ans = 10**17
	for S in [s[sr - 1], s[sr]]:
		for T in [t[tr - 1], t[tr]]:
			d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
#			print(str(ans) + ' ' + str(d1) + ' ' + str(d2))
			ans = min(ans, d1, d2)
	print(ans)
'''
for q in range(Q):
	x = int(input())
	b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
	res = 10**13
	for S in [s[b - 1], s[b]]:
		for T in [t[d - 1], t[d]]:
			d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
			res = min(res, d1, d2)
	print(res)

Measured memory_bytes: 12816
require 'prime'
h = Hash.new(0)
n = gets.chomp.to_i
1.upto(n) do |i|
  Prime.prime_division(i).each do |a, b|
    h[a] += b
  end
end
ret = 1
h.each do |k, v|
  ret *= (k ** v) % (10**9 + 7)
end
puts ret % (10**9 + 7)

Measured memory_bytes: 76668
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 aa, bb, kk;
	cin >> aa >> bb >> kk;
	if(kk <= aa)
	{
		cout << aa - kk << ' ' << bb << endl;
	}
	else if(kk <= aa + bb)
	{
		cout << "0 " << bb + aa - kk << endl;
	}
	else
	{
		cout << "0 0" << endl;
	}
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
 
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;}

int main() {
    int n, r; cin >> n >> r;
    int ans;
    if(n < 10) {
        r = r + (100 * (10-n));
    }
    cout << r << endl;
}


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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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;}

int N;
bool issq[1000005];
int ans;

bool check(int x,int y,int n){
    //cout<<n<<endl;
    int d=(x+y)*(x+y)-4*(x*x+y*y+x*y-n);
    //cout<<d<<endl;
    if(d<0)return false;
    if(!issq[d])return false;
    int s=-(x+y)+sqrt(d);
    if(s%2!=0)return false;
    //cout<<s<<endl;
    int z=s/2;
    if(z>=1)return true;
    else return false;
}

signed main(){
    cin>>N;
    for(int i=0;i<=1000;++i)issq[i*i]=true;
    for(int i=1;i<=N;++i){
        int res=0;
        for(int x=1;x<=100;++x){
            for(int y=1;y<=100;++y){
                if(check(x,y,i))res++;
            }
        }
        cout<<res<<endl;
    }
    //check(1,1,6);
}

Measured memory_bytes: 4592
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 6000 + 20 ;
int n ;
string s ;

int match[N] ;
string res[N] , mx[N] ;

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

	cin >> n ;
	cin >> s ;

	n *= 2 ;
	queue <int> que ;
	for (int i = 0 ; i < n ; i ++) {
		if (!que.size() || s[que.front()] == s[i]) que.push(i) ;
		else match[i] = que.front() , match[que.front()] = i , que.pop() ;
	}

	for (int i = n - 1 ; i >= 0 ; i --) {
		if (match[i] > i) {
			if (s[i] == 'a') res[i] = "ab" + mx[match[i] + 1] ;
			else {
				string tmp = "" ;
				int l = i , r = match[i] ;

				for (int j = l ; j <= r ; j ++) {
					if (s[j] == 'b') tmp += "b" , r = match[j] ;
					else if (match[j] >= l) tmp += "a" ;
				}

				tmp += mx[r + 1] ;

				res[i] = tmp ;
			}
		}
	
		mx[i] = max(mx[i + 1] , res[i]) ;
	}

	cout << mx[0] << '\n' ;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;
string s[3];

inline li calc(char a, char b, char c) {
    if (a == b) {
        if (b == c) {
            return 0;
        } else {
            return 1;
        }
    } else if (a == c) {
        return 1;
    } else if (b == c) {
        return 1;
    }
    return 2;
}

int main() {
    cin >> n;
    rep(i, 3)cin >> s[i];
    li res = 0;
    rin{
        res += calc(s[0][i], s[1][i], s[2][i]);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

/*
  Code
*/

double eauclidDistance(pair<double, double>& x1, pair<double, double>& x2) {
  return sqrt((x1.first - x2.first) * (x1.first - x2.first) + (x1.second - x2.second) * (x1.second - x2.second));
}

void swap(int& a, int& b) {
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

int main(int argc, char const *argv[])
{
  int N;
  cin >> N;

  vector<int> p(N);
  REP(N) cin >> p[i];

  int ans = 0;
  REP(N) {
    if((i+1) == p[i]) {
      if(i+1 == N) {
        ans++;
        break;
      }
      swap(p[i], p[i+1]);
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
//make sure to make new file!
import java.io.*;
import java.util.*;

public class Main{
   
   public static void main(String[] args)throws IOException{
      BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      PrintWriter out = new PrintWriter(System.out);
      
      double n = Double.parseDouble(f.readLine());
      
      out.println(n*2.0*Math.PI);
      
      
      
      
      
      
      
      
      out.close();
   }
   
      
}

Measured memory_bytes: 33172
import sys
from collections import Counter

sys.setrecursionlimit(10**7)
 
inf = 1<<100
 
def solve():
    N, M = map(int, input().split())
    edges = [None]*M
    Adj = [[] for i in range(N)]
 
    for i in range(M):
        ui, vi, ci = map(int, sys.stdin.readline().split())
        ui, vi = ui - 1, vi - 1
        edges[i] = (ui, vi, -ci)
        Adj[ui].append(vi)

    visitable = [False]*N

    dfs(N, M, Adj, visitable, 0)

    reachable = [False]*N
    reachable[0] = True
    reachable[N - 1] = True

    for u in range(1, N - 1):
        visited = [False]*N

        dfs(N, M, Adj, visited, u)

        if visited[N - 1]:
            reachable[u] = True
 
    ans = Bellmanford(N, M, edges, visitable, reachable)
 
    if ans is not None:
        print(-ans)
    else:
        print('inf')

def dfs(N, M, Adj, visitable, u):
    visitable[u] = True

    for v in Adj[u]:
        if not visitable[v]:
            dfs(N, M, Adj, visitable, v)

def Bellmanford(N, M, edges, visitable, reachable):
    dist = [inf]*N
    dist[0] = 0
    flag = True

    cnt = 0
 
    for i in range(N):
        flag = False

        for (u, v, c) in edges:
            if dist[u] != inf and dist[v] > dist[u] + c:
                dist[v] = dist[u] + c

                if visitable[v] and reachable[v]:
                    flag = True

        # print(dist)

        if not flag:
            break

        if flag and i == N - 1:
            return None

    return dist[N - 1]
 
if __name__ == '__main__':
    solve()

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

using namespace std;
const int maxn = 1e5 + 5, mod = 1e9 + 7;

string s;
int d, n, f[maxn][100][2];

int dp(int i, int j, int less)
{
    if (i == n+1) return (j == 0);
    if (f[i][j][less] != -1) return f[i][j][less];
    int &res = f[i][j][less]; res = 0;
    int x = 9;
    if (!less) x = s[i] - '0';
    for(int k=0; k<=x; ++k) 
        res = (res + dp(i + 1, (j + k) % d, (k < x) || less)) % mod;
    return res;
}

int main()
{
    #ifdef NTMA 
        freopen("abc.inp", "r", stdin);
    #endif
    memset(f, 255, sizeof(f));
    cin >> s >> d;
    n = s.size();
    s = ' ' + s;
    cout << (dp(1, 0, 0) - 1 + mod) % mod;
    return 0;
}

Measured memory_bytes: 79232
p=*0..gets.to_i
s=0
f=->a{a!=p[a]?p[a]=f[p[a]]:a}
a,b=$<.map(&:split).transpose.map{|a|a.map.with_index{[_1.to_i,_2]}.sort.each_cons(2).map{[_2[0]-_1[0],_1[1],_2[1]]}}
(a+b).sort.map{|c,*a|a,b=a.map &f
a!=b&&(s+=c
p[b]=a)}
p s

Measured memory_bytes: 60672