akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <ctime>

using namespace std;

#define LOCAL 0
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define fore(i, a, b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= (_b); --i)
#define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1& arg1){
    cerr << name << ": " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1& arg1, Args&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " /";
    __f(comma + 1, args...);
}

template <class T> bool mini(T& a, T b) { return a > b ? (a = b, 0) : 1; }
template <class T> bool maxi(T& a, T b) { return a < b ? (a = b, 0) : 1; }

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const int INF = 1e9 + 7;

int main() {
#if LOCAL
    freopen("CP.inp", "r", stdin);
//    freopen("CP.out", "w", stdout);
#endif // LOCAL
    ios_base::sync_with_stdio(0); cin.tie(0);
    LL a, b; cin >> a >> b;
    LL gcd = __gcd(a, b);
    LL ans = 1;
    for (LL i = 2; i * i <= gcd; ++i) if (gcd % i == 0) {
        ++ans;
        while (gcd % i == 0) gcd /= i;
    }
    if (gcd > 1) ++ans;
    cout << ans << '\n';
    return 0;
}


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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    string s,t;
    cin2(s,t);
    lli n = s.length();

    map<char, char> m1;
    map<char, char> m2;

    REP(i,0,n) {
        auto it1 = m1.find(s[i]);
        if (it1 != m1.end() && it1->second != t[i]) {
            goto NO;
        }
        m1[s[i]] = t[i];

        auto it2 = m2.find(t[i]);
        if (it2 != m2.end() && it2->second != s[i]) {
            goto NO;
        }
        m2[t[i]] = s[i];
    }


    cout << "Yes" << endl;
    return 0;
NO:
    cout << "No" << endl;
}


Measured memory_bytes: 776
n = int(input())
xi = list(map(int, input().split()))

mi = min(xi)
ma = max(xi)
ans = 1000000

for i in range(mi, ma+1):
    num = 0
    for j in range(n):
        num += (xi[j]-i)**2
    ans = min(ans, num)

print(ans)

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

#define MAX_N 15

using namespace std;

int n;

int m[MAX_N + 1];
vector <pair<int, int>> g[MAX_N + 1];

int stk[MAX_N + 1];

bool verif()
{
    for(int i = 1; i <= n; i ++)
    {
        if(stk[i] == 1)
        {
            for(int j = 1; j <= m[i]; j ++)
            {
                if(stk[g[i][j - 1].first] != g[i][j - 1].second)
                    return 0;
            }
        }
    }

    return 1;
}

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i ++)
    {
        cin >> m[i];

        for(int j = 1; j <= m[i]; j ++)
        {
            int x, y;
            cin >> x >> y;
            g[i].push_back({x, y});
        }
    }

    int rez = 0;
    for(int i = 0; i < (1 << n); i ++)
    {
        int cati = 0;
        for(int j = 0; j < n; j ++)
        {
            stk[j + 1] = ((i & (1 << j)) != 0);
            cati += ((i & (1 << j)) != 0);
        }

        if(verif())
        {
            rez = max(rez, cati);
        }
    }

    cout << rez << "\n";

    return 0;
}


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

int main()
{
	string s;
	cin >> s;
	int kazu[128] = {};
	string now;
	for (int i = 1; i < s.size(); i += 2)
	{
		now = s;
		now.erase(s.size()-1-i);
		if(now.substr(0,now.size()/2) == now.substr(now.size()/2,now.size()/2))
		{
			cout << now.size() << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{
    int A,B,a,s,v;
    scanf("%d%d",&A,&B);
    a=A+B;
    s=A-B;
    v=A*B;
    if((a>=s)&&(a>=v))
        printf("%d\n",a);
    else if((s>=a)&&(s>=v))
        printf("%d\n",s);
    else
        printf("%d\n",v);
return 0 ;
}


Measured memory_bytes: 128
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

auto minBy(alias key, T)(T input) {
    return input.reduce!((a, b) => unaryFun!key(a) <= unaryFun!key(b) ? a : b);
}

void main() {
    int N, L; scan(N, L);

    // N 個のリングのおいしさは、L, L + 1, L + 2, ..., L + N - 1
//    int t = iota(L, L + N).reduce!((a, b) => abs(a) <= abs(b) ? a : b);
    int t = iota(L, L + N).minBy!(abs);
    int ans = iota(L, L + N).sum - t;
    writeln(ans);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(0, min(B, D) - max(A, C)) << endl;

    return 0;
}


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

int main(){
    int n,w1;
    cin >> n >> w1;
    int v[n],w[n];
    w1++;
    vector<int> now(w1,0);
    vector<int> last(w1,0);
    for(int i=0;i<n;i++){
        cin >> v[i] >> w[i];
        last[w[i]]=v[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<w1;j++){
            if(j-w[i]>=0){
                now[j]=max(last[j],now[j-w[i]]+v[i]);
            }
            else{
                now[j]=last[j];
            }
        }
        now.swap(last);
    }
    cout << last.back() << endl;
}

Measured memory_bytes: 3156
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
string buf;
int v;
bool perse(int a, int b) {
	switch (buf[a]) {
	case '-':
		return !perse(a + 1, b);
	case '(':
		{
			int c = a+1;
			int n = 0;
			for (;; c++) {
				if (buf[c] == '(')n++;
				else if (buf[c] == ')') {
					n--;
				}
				else {
					if (!n&&(buf[c]=='+'||buf[c]=='*'||buf[c]=='-'&&buf[c+1]=='>'))break;
				}
			}
			switch (buf[c]) {
			case '+':
				return perse(a + 1, c - 1) || perse(c + 1, b - 1);
			case '*':
				return perse(a + 1, c - 1) && perse(c + 1, b - 1);
			default:
				return !perse(a + 1, c - 1) || perse(c + 2, b - 1);
			}
		}
	case 'T':
		return 1;
	case 'F':
		return 0;
	}
	return v & 1 << (buf[a] - 'a');
}
int main() {
	while (cin>>buf,buf != "#") {
		int e = buf.find('=');
		bool yes = true;
		for (v = 0; v < 1 << 11; v++) {
			if (perse(0, e - 1) != perse(e + 1, buf.size() - 1)) {
				yes = 0;
				break;
			}
		}
		cout << (yes ? "YES" : "NO") << endl;
	}
}

Measured memory_bytes: 3220
#include <stdio.h>
#include <string.h>
int main(void){
    char a[100];
    scanf("%s",a);
    
    for(int i = 0;i < strlen(a); i++){
        a[i] = 'x';
        
    }
    printf("%s \n",a);
    return 0;
    
    

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long int lli;

using namespace std;

lli N;
lli x = 0;
lli ans = 0;

void dfs(lli x, bool A, bool B, bool C){
    if(x<=N && A && B && C) ans++;
    if(x<=N){
        dfs(10*x+3, true, B, C);
        dfs(10*x+5, A, true, C);
        dfs(10*x+7, A, B, true);
    }else return;
}

int main(void){
    cin>>N;
    dfs(x, false, false, false);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
/***************************************** 
****       Solution by SlavicG        ****
*****************************************/
 
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm> 
#include <set>
#include <utility>
#include <queue>
#include <map>
#include <assert.h>
#include <stack>
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;++i)
#define MX 10000000001
#define pow2(a) ((a)*(a))
#define pb push_back
#define vair <vector<pair<int,int>>
#define vi vector<int>
#define mp make_pair
#define pf push_front
#define all(v) v.begin(), v.end()
#define endl "\n"
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define PI   3.14159265
 int longestIncreasingSubsequenceLenghtDP(int a[],int n){
    int dp[n],ans=0;
    for(int k = 0;k<n;k++){
        dp[k] = 1;
        for(int i = 0;i<k;i++){
            if(a[i] <= a[k]){
                dp[k] = max(dp[k],dp[i] + 1);
                ans = max(dp[k],ans);
            }
        }
    }
    return ans;
 }
int result[1000] = {0};
int factDP(int n) 
{
   if (n >= 0) {
      result[0] = 1;
      for (int i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
      return result[n];
   }
}
bool checkPrime(int n)
{
    if(n<2) return false;
    for(int x = 2;x*x <=n;x++)
    {
        if(n%x == 0)return false;
    }
    return true;
}
vector<int> primeFactors(int n){
    vector<int> f;
    for(int x = 2;x*x<=n;x++){
        while(n%x==0){
            f.push_back(x);
            n/=x;
        }
    }
    if(n>1)f.push_back(n);
    return f;
}
int binary_Search_Classic(int n, int arr[],int target){
	int l,r,mid;
	l=0;
	r=n-1;
	while(l<=r){
		mid= l+(r-l)/2;
		if(arr[mid] == target){
			return mid;
		}
		if(arr[mid] < target){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return -1;
	
}
vector<int> Two_PointerSumOfTwo(vector<int> arr, int target)
{
	int l = 0, r = arr.size()-1;
	vector<int> ans;
	while(l<r){
		if(arr[l] + arr[r] == target)
		{
			ans.push_back(l);
			ans.push_back(r);
			break;
		}else if(arr[l] + arr[r] > target){
			r--;
		}else{
			l++;;
		}
	}
	return ans;
}
int countDistinctCharsString(string s) {
    unordered_map<char, int> m; 
    for (int i = 0; i <(int)s.length(); i++) { 
        m[s[i]]++; 
    }
    return m.size(); 
}
map<ll,ll> used;
int main()
{
	int a,b;
	cin >> a >> b;
	cout << a* b <<  endl;
	return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <stdbool.h>
 
void judge(int ye, int mo, int da)
{
    int sum = 10000 * ye + 100 * mo + da;
    if (sum < 18680908) {
        printf("pre-meiji\n");
    } else if (sum < 19120730) {
        printf("meiji %d %d %d\n", ye - 1867, mo, da);
    } else if (sum < 19261225) {
        printf("taisho %d %d %d\n", ye - 1911, mo, da);
    } else if (sum < 19890108) {
        printf("showa %d %d %d\n", ye - 1925, mo, da);
    } else {
        printf("heisei %d %d %d\n", ye - 1988, mo, da);
    }
}
    
    
int main(void)
{
    int ye, mo, da;
    while (scanf ("%d%d%d", &ye, &mo, &da) != EOF) {   
        judge(ye, mo, da);
    }
    return 0;
}

Measured memory_bytes: 1036
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#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 REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ld INF = 1e18;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll N;
    cin>>N;
    
    VEC(ll,sum,N);
    cin>>sum[0];
    REP1(i,N-1){
        ll t;
        cin>>t;
        sum[i]=sum[i-1]+t;
    }
    
    ll m=LLONG_MAX;
    REP(i,N-1){
        m=min(abs(sum[N-1]-sum[i]*2),m);
    }
    cout<<m;
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1792
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
	int n, ans = 0;
	vector<int> cnt(10001);
	for (int a = 1; a <= 100; ++a) {
		for (int b = 1; b <= 100; ++b) {
			for (int c = 1; c <= 100; ++c) {
				int d = a * a + b * b + c * c + a * b + b * c + c * a;
				if (d <= 10000) {
					cnt[d] += 1;
				}
			}
		}
	}
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cout << cnt[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3536
//Name: Cheese
//Level: 2
//Category: グラフ,Graph,最短経路,幅優先探索,BFS
//Note:

/*
 * 要するに1からNまでを順番に最短経路で廻ればよい．
 * 最短経路は幅優先探索で求めることができる．
 */
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>

using namespace std;

const int DR[] = {0, 0, 1, -1};
const int DC[] = {1, -1, 0, 0};
struct Tag {
    int r, c, distance;
    Tag() {}
    Tag(int r, int c, int d) : r(r), c(c), distance(d) {}
};
bool visited[1000][1000];

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

    int H, W, N;
    cin >> H >> W >> N;
    vector<string> field(H);
    pair<int,int> cur;
    for(int i = 0; i < H; ++i) {
        cin >> field[i];
        size_t spos = field[i].find('S');
        if(spos != string::npos) {
            cur = make_pair(i, spos);
        }
    }
    int ans = 0;
    for(int target = 1; target <= N; ++target) {
        for(int i = 0; i < H; ++i) {
            fill_n(visited[i], W, false);
        }
        Tag route;
        queue<Tag> q;
        q.push(Tag(cur.first, cur.second, 0));
        while(!q.empty()) {
            Tag t = q.front();
            q.pop();
            for(int i = 0; i < 4; ++i) {
                int nr = t.r + DR[i];
                int nc = t.c + DC[i];
                if(0 <= nr && nr < H && 0 <= nc && nc < W) {
                    if(field[nr][nc] != 'X' && !visited[nr][nc]) {
                        visited[nr][nc] = true;
                        if(field[nr][nc] == '0'+target) {
                            route = Tag(nr, nc, t.distance+1);
                            goto found;
                        }
                        q.push(Tag(nr, nc, t.distance+1));
                    }
                }
            }
        }
found:
        ans += route.distance;
        cur = make_pair(route.r, route.c);
    }

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

Measured memory_bytes: 2916
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a, b; cin >> a >> b;
	int arr[a + 50] = {0}, arr2[a + 50] = {0};
	int AC = 0, WA = 0;
	for(int i=0; i<b; i++)
	{
		int tmp; string str;
		cin >> tmp >> str;
		if(arr[tmp]) continue;
		if(str == "AC")
		{
			arr[tmp] = true;
		}
		else
		{
			arr2[tmp] ++;
		}
	}
	for(int i=0; i<=a; i++)
	{
		if(arr[i])
		{
			AC ++;
			WA += arr2[i];
		}
	}
	cout << AC << ' ' << WA << '\n';
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>
long long int MOD = 1e9+7;

long long int fast_power(long long int x, long long int n);


int main(){
  long long int X, Y;
  scanf("%lld%lld", &X, &Y);
  
  if((X+Y)%3 != 0){
    std::cout << 0 << std::endl;
    return 0;
  }
  
  long long int tmp = (X+Y)/3;
  X -= tmp;
  Y -= tmp;
  
  if(X <0 || Y < 0){
    std::cout << 0 << std::endl;
    return 0;
  }
  
  
  else{
    long long int Xf=1, Yf=1, XYf=1;
    for(long long int i = 1; i <= X; i++){
      Xf = Xf*i;
      Xf = (Xf+MOD)%MOD;
    }
    for(long long int i = 1; i <= Y; i++){
      Yf= Yf*i;
      Yf = (Yf+MOD)%MOD;
    }
    for(long long int i = 1; i <= X+Y; i++){
      XYf = XYf*i;
      XYf = (XYf+MOD)%MOD;
    }
   
    Xf = fast_power(Xf, MOD-2);
    Yf = fast_power(Yf, MOD-2);
    
    long long int ans = Xf;
    ans *= Yf;
    ans = (ans+MOD)%MOD;
    ans *= XYf;
    ans = (ans+MOD)%MOD;
    
    std::cerr << "Answer:" << std::endl;
    std::cout << ans << std::endl;
  }
  
  return 0;

}

long long int fast_power(long long int x, long long int n){
  long long int ans = 1;
  
  while(n > 0){
    if(n&1){
      ans = ans * x;
      ans = (ans+MOD)%MOD;
    }
    x = x*x;
    x = (x+MOD)%MOD;
    n = n>>1;
  }
  
  return ans;
}


Measured memory_bytes: 256
package main

import . "fmt"

// github.com/EndlessCheng/codeforces-go
func main() {
	const p = 1e9 + 7
	pow := func(x, n int) int {
		r := 1
		for ; n > 0; n >>= 1 {
			if n&1 == 1 {
				r = r * x % p
			}
			x = x * x % p
		}
		return r
	}
	c := func(n, k int) int {
		a, b := 1, 1
		for i := 1; i <= k; i++ {
			a = a * n % p
			n--
			b = b * i % p
		}
		return a * pow(b, p-2) % p
	}
	var n, m int
	Scan(&n, &m)
	ans := 1
	for i := 2; i*i <= m; i++ {
		e := 0
		for ; m%i == 0; m /= i {
			e++
		}
		ans = ans * c(e+n-1, e) % p
	}
	if m > 1 {
		ans = ans * n % p
	}
	Print(ans)
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    map<string, int> mp;
    rep (i, n) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
    
    return 0;
}



Measured memory_bytes: 3612
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

k,n = LI()
a = LI()
ans = a[-1] - a[0]
for i in range(1,n-1):
    ans = min(ans, a[i] + (k - a[i+1]))
print(ans)


Measured memory_bytes: 73164
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    int N,L;
    string S;
    string ans;
    int i;
    cin >> N >> L;
    vector<string> strlist;
    for(i=0;i<N;i++){
        cin >> S;
        strlist.push_back(S);
    }
    sort(strlist.begin(),strlist.end());
    for(i=0;i<N;i++) ans += strlist[i];
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++) cin >> H[i];
    for (int i = 1; i < N; i++) {
        if (H[i - 1] > H[i]) {
            cout << "No" << endl;
            return 0;
            break;
        } else {
            if (H[i] != H[i - 1]) {
                H[i]--;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3760
# -*- coding: utf-8 -*-

import sys
import os
import datetime

DAY_OF_WEEK = ['Thursday', 'Friday', 'Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday']
MONTH = [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

for s in sys.stdin:
    month, day = map(int, s.split())
    if month == day == 0:
        break

    past_day = sum(MONTH[:month]) + day - 1

    a = past_day % 7
    print(DAY_OF_WEEK[a])
    

Measured memory_bytes: 8120
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////
int n,m,a[110000];
priority_queue<P> que;
signed main(){
  cin>>n>>m;rep(i,n)cin>>a[i];sort(a,a+n);
  rep(i,m){
    int b,c;cin>>b>>c;
    que.push(P(c,b));
  }
  int ans = 0, i = 0;rep(i,n)ans += a[i];
  while(!que.empty() && i < n){
    P p = que.top();que.pop();
    if(p.first < a[i])break;
    ans += p.first;ans -= a[i];i++;
    if(p.second > 1)que.push(P(p.first, p.second-1));
  }
  cout << ans << endl;
}


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n;

	cout<<n/3<<endl;



}


Measured memory_bytes: 256
let twoDivideCount = (n) => {
  let lastI = 0
  for (i = 1; 2 ** i < n; i++) {
    var nn = n / 2 ** i
    if (nn !== Math.ceil(nn)) {
      return i - 1
    }
    lastI = i
  }
  return lastI + 1
}
let solve = (input) => {
  const [n, aline] = input.split("\n")
  let items = aline.split(" ")
  let r = items.map((i) => twoDivideCount(i))
  return Math.min(...r)
}
const input = require("fs").readFileSync("/dev/stdin", "utf8")
console.log(solve(input.trim()))


Measured memory_bytes: 7500
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int main() {
    int a, b, x;
    cin >> a >> b >> x;
    if(a <= x && a + b >= x){
        print("YES");
    }else{
        print("NO");
    }
    return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<string> a(N);
    rep(i,N) cin >> a[i];
    vector<int> col(N,0);
    int there=0,sum=0,ans=INF;
    rep(i,N) rep(j,N){
        col[j]|=(a[i][j]=='.');
        there|=(a[i][j]=='#');
    }
    if (!there){
        cout << -1 << endl;
        return 0;
    }
    rep(i,N) sum+=col[i];
    rep(i,N){
        int cnt=sum,ok=0;
        rep(j,N) ok|=(a[j][i]=='#');
        rep(j,N) cnt+=(a[i][j]=='.');
        ans=min(ans,cnt+1-ok);
    }
    cout << (ans!=INF?ans:-1) << endl;
}

Measured memory_bytes: 512
using System;
public class XYADG {
    public static void Main() {
        string read = Console.ReadLine();
        long x = long.Parse(read);
        long rotate = (x / 11)*2;
        if (x % 11 <= 6) {
            if (x%11 != 0) {
                rotate++;
            }
        } else {
            rotate += 2;
        }
        Console.WriteLine(rotate);

    }
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));
  int cnt = 0;
  REP(i,n){
    if(a[i] == a[i-1]) cnt++;
  }
  int ans;
  if(cnt % 2 == 0) ans = n - cnt;
  else ans = n - cnt - 1;
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>

int main() {
  int x,a = 1;
  //無限ループ => while (1)
  while (1) {
    std::cin >> x;
    if (x == 0) break;
    std::cout << "Case " << a << ": " << x << '\n';
    a++;
  }
  return 0;
}


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

#define ll long long
#define fr first
#define se second
#define pb push_back

using namespace std;

const long long N = 1e5 + 7;

long long res, n, m, cnt, ans , a , b , sum , mx , mn, c , d;
string s;
set<string>st;
int main()
{
    cin >> n;
    for( int i = 0;i < n;i ++ )
        cin >> s , st.insert(s);
    cout << st.size() << endl;
}


Measured memory_bytes: 19116
#include<bits/stdc++.h>
#define ll long long int 

using namespace std;

int main(){
    int n,W;
    cin>>n>>W;
    ll mat[n+1][100000+1];
    for(int i=0;i<=n;i++)mat[i][0]=0;
    for(int i=1;i<=100000;i++)mat[0][i]=100000000001;
    for(int i=1;i<=n;i++){
        ll w,v;
        cin >>w>>v;
        for(int j=1;j<=100000;j++){
            if(v>j){
                mat[i][j]=mat[i-1][j];
            }
            else{
                mat[i][j]=min(mat[i-1][j],mat[i-1][j-v]+w);
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
    for(int j=1;j<=100000;j++) {
        if(mat[i][j]<=W) {
            ans=max(ans,(ll)j);
        }
    }
        
    }
    cout <<ans<<endl;
    //cout <<mat[n][W]<<endl;
}



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

int main() {
    int n;
    cin >> n;
    int d[n];
    for (int i  = 0; i < n; i++) {
        cin >> d[i];
    }
    int m;
    cin >> m;
    int t[m];
    for (int i = 0; i < m; i++) {
        cin >> t[i];
    }

    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        mp[d[i]]++;
    }

    for (int i = 0; i < m; i++) {
        if (mp[t[i]] > 0) {
            mp[t[i]]--;
        }
        else {
            cout << "NO" << endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;
    return 0;
}

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

namespace AtCoder.Beginner162
{
    public class ABC162D
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            char[] S = Console.ReadLine().ToArray();

            List<int> Rs = new List<int>();
            List<int> Gs = new List<int>();
            List<int> Bs = new List<int>();

            for (int i = 0; i < N; i++)
            {
                if (S[i] == 'R') Rs.Add(i);
                if (S[i] == 'G') Gs.Add(i);
                if (S[i] == 'B') Bs.Add(i);
            }
            long cnt = (long)Rs.Count * (long)Gs.Count * (long)Bs.Count;

            for (int i = 0; i < N; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    var k = j + (j - i);
                    if (k >= N) { continue; }
                    if (S[i] != S[j] && S[j] != S[k] && S[i] != S[k]) { cnt--; }
                }
            }

            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 28200
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
typedef vector<bool> Array;
typedef vector<Array> Matrix;

//正方行列の掛け算 O(N^3)
Matrix operator*(const Matrix &a,const Matrix &b){
	const int N = a.size();
  //assert(V == a[0].size() && V == b.size() && V == b[0].size()); //正方行列
	Matrix res(N, Array(N, false));
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(res[i][j]) continue;
      for(int k = 0; k < N; k++){
        if(a[i][k] && b[k][j]){
          res[i][j] = true;
          break;
        }
      }
    }
  }
	return res;
}
//サイズNの単位行列
Matrix Mat_E(int N){
	Matrix res(N, Array(N, false));
  for(int i = 0; i < N; i++){
		res[i][i] = true;
	}
	return res;
}
//正方行列の累乗 O(M^3 * logn)
Matrix operator^(const Matrix &a, long long n){
  const int M = a.size();
	if(n == 0) return Mat_E(M);
	Matrix res = (a * a)^(n / 2);
	if(n & 1) res = res * a;
	return res;
}
typedef pair<int, int> P;

int main(){
  int N, M;
  long long Z;
  while(cin>>N>>M>>Z){
    if(N == 0) break;
    bool path[50][50] = {};
    vector<int> from[50];
    REP(i, M){
      int s, d;
      scanf("%d %d", &s, &d);
      s--; d--;
      path[s][d] = true;
      path[d][s] = true;
      from[d].push_back(s);
      from[s].push_back(d);
    }
    vector<P> state;
    state.push_back(P(-1, 0));
    REP(i, N){
      REP(j, from[i].size()){
        state.push_back(P(from[i][j], i));
      }
    }
    Matrix M(state.size(), Array(state.size(), false));
    for(int i = 0; i < state.size(); i++){
      for(int j = 0; j < state.size(); j++){
        if(state[i].second == state[j].first && state[i].first != state[j].second){
          M[i][j] = true;
        }
      }
    }
    M = M ^ Z;
    bool ans = false;
    REP(i, state.size()){
      if(state[i].second == N - 1 && M[0][i]){
        ans = true;
        break;
      }
    }
    if(ans) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1516
#include <iostream>
#include <iomanip>
#include <complex>
using namespace std;

int main() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;

  double a = (H + (M / 60)) / 12.0 * 2 * M_PI,
         b = M / 60.0 * 2 * M_PI;

  cout << fixed << setprecision(15) << abs(polar(A, a) - polar(B, b)) << endl;

  return 0;
}


Measured memory_bytes: 4140
n=int(input())
l=list(map(int,input().split()))
L=[]
c=0
for j in range(n):
  for i in range(len(l)-1,-1,-1):
    if l[i]==i+1:
      L.insert(0,l.pop(i))
      c+=1
      break
if c!=n:
  print(-1)
else:
  for k in range(len(L)):
    print(L[k])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define N 200005
using namespace std;
typedef long long LL;
int a[N],f[N],rk[N],n,m,ans;
LL g[N];
int A[N],B[N],C[N],cut[N];
struct edge{
	int x,y,z;
	int operator < (const edge &b)const{
		return z<b.z;
	}
}e[N];
int get(int u){for (;f[u]!=u;u=f[u]);return u;}
void Union(int tot,int u,int v){
	if (rk[u]<rk[v]) swap(u,v);
	A[tot]=u;B[tot]=v;C[tot]=rk[u]==rk[v];
	f[v]=u;rk[u]+=C[tot];g[u]+=g[v];
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for (int i=1;i<=m;i++)
		scanf("%d%d%d",&e[i].x,&e[i].y,&e[i].z);
	sort(e+1,e+m+1);
	for (int i=1;i<=n;i++) f[i]=i,g[i]=a[i],rk[i]=0;
	for (int i=1;i<=m;i++){
		int u=get(e[i].x),v=get(e[i].y);
		if (u==v) cut[i]=0;else cut[i]=1,Union(i,u,v);
	}
	for (int i=m;i;i--)
		if (cut[i]){
			if (g[get(e[i].x)]>=e[i].z) continue;
			int u=A[i],v=B[i],w=C[i];
			f[v]=v;rk[u]-=w;g[u]-=g[v];ans++;
			int t1=get(e[i].x),t2=get(e[i].y);
			//assert(t1==u&&t2==v||t1==v&&t2==u);
		}
		else
			ans+=g[get(e[i].x)]<e[i].z;
	printf("%d\n",ans);
}

Measured memory_bytes: 7936
fun make(candidate: List<Int>, perm: List<Int>): List<Int> {
    if (candidate.isEmpty()) {
        return listOf(perm.reduce { a, b ->
            a * 10 + b
        })
    }
    return candidate.indices.map { i ->
        val p = perm.toMutableList()
        val c = candidate.toMutableList()
        p.add(c[i])
        c.removeAt(i)
        make(c, p)
    }.flatten()
}

fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val p = readLine()?.replace(" ", "")?.toInt() ?: return
    val q = readLine()?.replace(" ", "")?.toInt() ?: return

    val data = 1.until(n + 1).map { it }
    val list = make(data, mutableListOf()).sortedDescending()
    val pi = list.indexOf(p)
    val qi = list.indexOf(q)
    val result = Math.abs(pi - qi)
    println(result)
}


Measured memory_bytes: 59488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  string t;
  cin >> t;
REP(i,t.size()){
  if(t.at(i)=='?')cout  << "D";
  else cout << t.at(i);
}
cout << "\n";
  return 0;
}


Measured memory_bytes: 3724
s = input()
t = input()

def f(k):
    c = 0
    for i in range(len(t)):
        if s[k + i] == t[i]:
            c += 1
    return c

maxi = f(0)
for i in range(len(s) - len(t) + 1):
    if f(i) > maxi:
        maxi = f(i)

print(len(t) - maxi)

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

bool judge(int x){
    //primeならtrueを返す.
    int mid = pow(x,0.5);
    bool flg = 0;
    while(mid>1){
        if(x%mid == 0){
            flg = 1;
            break;
        }
        mid--;
    }
    if(flg)return false;
    else return true;
}

int main(){
    int x;cin>>x;
    while(!judge(x)){
        x++;
    }
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
int p[100000];
int main(void)
{
	int n,res=0,i;
	scanf("%d",&n);
	FOR(i,0,n) scanf("%d",&p[i]);
	FOR(i,0,n-1){
		if(p[i]==i+1){
			res++;
			swap(int,p[i],p[i+1]);
		}
	}
	if(p[n-1]==n) res++;
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b&&b==c)
    {
        printf("No\n");
    }
    else if(a!=b&&a!=c&&b!=c)
    {
        printf("No\n");
    }
    else
    {
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 128
(let ((n (read))
      (a (make-array 0 :element-type 'integer
                       :adjustable t
                       :fill-pointer 0))
      (mx1 0)
      (mx2 0))
     (dotimes (i n)
       (vector-push-extend (read) a)
       (cond ((> (aref a i) mx1) (progn (setf mx2 mx1)
                                        (setf mx1 (aref a i))))
             ((> (aref a i) mx2) (setf mx2 (aref a i)))))
     (dotimes (i n)
       (format t "~A~%" (if (= mx1 (aref a i)) mx2 mx1))))

Measured memory_bytes: 61156
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#define N 2234
template<typename T> inline void read(T &x) {
	x = 0; char c = getchar();
	while (!isdigit(c)) c = getchar();
	while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
}
using namespace std;
inline void MIN(int &a, int b) {
	if (b < a)	a = b;
}
struct edge{
	int nxt, to;
}e[N << 1];
int head[N], ecnt;
inline void addedge(int from, int to) {
	e[++ecnt] = (edge){head[from], to};
	head[from] = ecnt;
}
int n;
char s[N];
int ans = 987654321, res;
int f[N], sum[N];
int siz[N];
void dfs(int cur, int faa, int nwd) {
	sum[cur] = siz[cur] = 0;
	int mx = 0, mxf = 0;
	for (int i = head[cur]; i; i = e[i].nxt) {
		int to = e[i].to; if (to == faa)	continue;
		dfs(to, cur, nwd + 1);
		sum[to] += siz[to];
		if (sum[to] > mx)	mx = sum[to], mxf = to;
		sum[cur] += sum[to];
		siz[cur] += siz[to];
	}
	if (sum[cur] - mx >= mx) {
		f[cur] = sum[cur] >> 1;
	} else {
		f[cur] = sum[cur] - mx + min(f[mxf], (mx - sum[cur] + mx) >> 1);
	}
	if (s[cur] == '1')	res += nwd, ++siz[cur];
}

inline void work(int rt) {
	res = 0;
	dfs(rt, 0, 0);
	if (f[rt] * 2 == res) MIN(ans, res / 2);
}
int main() {
	read(n);
	scanf("%s",s + 1);
	for (int i = 1; i < n; ++i) {
		int u, v; read(u), read(v);
		addedge(u, v), addedge(v, u);
	}
	for (int i = 1; i <= n; ++i)	work(i);
	if (ans == 987654321)	puts("-1");
	else	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3380
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a<b)
  {
    for(int i=0;i<b;i++)
      cout<<a;
  }
  else
  {
    for(int i=0;i<a;i++)
    {
      cout<<b;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <cctype>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(),i.end()
#define debug(i) std::cout << i << "\n"

const ll INF = 100000000;
const ll MOD = 1000000007;

void dfs(ll now, std::vector<std::vector<P>>& path,std::vector<ll>& ans){
    for(P a:path[now]){
        if(ans[a.first]==-1){
            ans[a.first]=(ans[now])^(a.second);
            dfs(a.first,path,ans);
        }
    }
}


int main()
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!

    ll n;
    std::cin>>n;
    std::vector<std::vector<P>> path(n,std::vector<P>());
    std::vector<ll> ans(n,-1);
    ans[0]=0;
    rep(i,0,n-1){
        ll u,v,w;
        std::cin>>u>>v>>w;
        u--;v--;
        path[u].push_back(P(v,w%2));
        path[v].push_back(P(u,w%2));
    }
    dfs(0,path,ans);
    rep(i,0,n){
        std::cout<<ans[i]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 9984
n = int(input())
lis = list(map(int, input().split()))
val = [0] * n

for i in range(n, 0, -1):
    if n // i == 1:
        val[i - 1] = lis[i - 1]
    else:
        a = sum(val[i - 1::i])
        if a % 2 == lis[i - 1]:
            val[i - 1] = 0
        else:
            val[i - 1] = 1

print(sum(val))
print(*[i + 1 for i in range(n) if val[i] == 1], sep=" ")


Measured memory_bytes: 13108
#include "bits/stdc++.h"
using namespace std;
// #define endl '\n'
// #define double long double
#define int long long
int MOD = 1000 * 1000 * 1000 + 7;

int n;
string s;
int d;

int dp[10001][2][101];

int place(int at, bool restrict, int md) {
	md %= d;
	if (at == n + 1) {
		return md == 0;
	}
	if (dp[at][restrict][md] != -1) return dp[at][restrict][md];
	int ans = 0;
	for (int here=0; here<10; here++) {
		if (!restrict) {
			ans += place(at+1, false, (md + here) % d);
		}
		else {
			if (here < (s[at-1] - '0')) {
				ans += place(at+1, false, (md+here) % d);
			}
			else if (here == (s[at-1] - '0')) {
				ans += place(at+1, true, (md + here) % d);
			}
			else {
				continue;
			}
		}
		ans %= MOD;
	}
	return dp[at][restrict][md] = ans % MOD;
}

signed main() {
	
	for (int i=0; i<10001; i++) for (int j=0; j<2; j++) for (int k=0; k<101; k++) dp[i][j][k] = -1;
	
	cin >> s;
	cin >> d;
	n = s.size();
	
	cout << (place(1, true, 0) - 1 + MOD) % MOD << endl;
	
}



Measured memory_bytes: 16896
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;

#define debug(s) cout << #s << " = " << s << endl
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define ff first
#define ss second
typedef long long ll;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

char s[110];

int main() {
  int k;
  scanf("%d", &k);
  scanf("%s", s);  
  int n = strlen(s);
  if (n > k) {
    for (int i = 0; i < k; ++i) printf("%c", s[i]);
    printf("...\n");
  }
  else printf("%s", s);
}


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


class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        long t=sc.nextInt();
        long[]h=new long[n];
        for(int i=0;i<n;++i)h[i]=sc.nextInt();
        long[]ans=new long[n];
        long m=0;
        long r=t;
        for(int i=0;i<n;++i){
            m=Math.max(m,h[i]);
            ans[i]=r>=0?r/m+1:1;
            if(r>=0&&r%m>=h[i])
                ans[i]++;
            r-=h[i];
        }
        for(long a:ans)out.println(a);
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 50272