akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=52e4,mo=998244353;

ll jc[N],ny[N];
int n,k;

inline ll ksm(ll o,ll t)
{
	ll y=1;
	for(;t;t>>=1,o=o*o%mo)
	if(t&1)y=y*o%mo;
	return y;
}

inline ll C(int a,int b)
{return (b<0||b>a)?(0):(jc[a]*ny[b]%mo*ny[a-b]%mo);}

int main()
{
	scanf("%d%d",&n,&k);
	jc[0]=ny[0]=1;
	fo(i,1,k)jc[i]=jc[i-1]*i%mo;
	ny[k]=ksm(jc[k],mo-2);
	fd(i,k-1,1)ny[i]=ksm(jc[i],mo-2);
	int R=k/2+(k%2);
	ll ans=0;
	for(;R<=k;++R){
		if(R<n)continue;
		int B=k-R;
		int t=R-n+1;
		if(R==B)ans=(ans+C(k-1,R)-C(k-1,R+t));
		else ans=(ans+C(k,R)-C(k,R+t)); 
	}
	ans=(ans%mo+mo)%mo;
	cout<<ans;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a>b){
    cout << "a > b" << endl;
  }
  else if(a<b){
    cout << "a < b" << endl;
  }
  else{
    cout << "a == b" << endl;
  }
}


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

int main()
{
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    if(x>=y){
        cout << "War" << endl;
        return 0;
    }
    int a = -200;
    int b = 200;
    while(n--){
        int t;
        cin >> t;
        a = max(a, t);
    }
    while(m--){
        int t;
        cin >> t;
        b = min(b, t);
    }
    string s = "War";
    for(int z = x+1; z<=y; z++){
        if(z > a && z <= b){
            s = "No War";
            break;
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI 3.14159265358979323846264338327950L

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define int long long
#define Graph vector<vector<int> >
#define PII pair<int,int>
#define VI vector<int>
#define VVI vecotor<vector<int> >
#define VPII vector<pair<int,int> >

template<typename A, size_t N, typename T>

void Fill(A (&array)[N], const T &val) {
	std::fill( (T*)array, (T*)(array + N), val );
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここにグローバル変数宣言
int H, W, sh, sw, gh, gw;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};//BFS関連







//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数宣言
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}


int gcd(int a, int b)
{
	if (a % b == 0)
	{
		return (b);
	}
	else
	{
		return (gcd(b, a % b));
	}
}



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main() {
	//入力の高速化用のコード
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	long long A, B, N;
	cin >> A >> B >> N;
	int x = min(B - 1, N);
	cout << (A * x) / B - A*(x / B) << endl;




}







Measured memory_bytes: 3540
#include <bits/stdc++.h>  
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define REP(i, a, n, op) for(int i=a; i<(int)(n); i ## op ## op)
#define cout(val) cout << val << endl

using namespace std;  

int main(){
    int n, first;
    long long k;
    cin >> n >> k;
    vector<int> town(n);
    rep(i, n) cin >> town.at(i);

    int nowTown = 1;
    int time = 1;
    vector<int> visit(n, 0);
    visit.at(0) = 1;
    while(true){
        time++;
        nowTown = town[nowTown - 1];
        if(visit[nowTown - 1] == 0) {
            visit[nowTown - 1] = time;
        }else{
            first = visit[nowTown - 1] - 1;
            time -= first + 1;
            break;
        }
    }
    nowTown = 1;
    int l = (k - first) % time + first;
    if(l > k) l = k;
    rep(i, l) nowTown = town[nowTown - 1];
    cout(nowTown);
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;
const ll INF = 10000000000000;
int E,V;
vector<vector<ll> > d;
vector<vector<bool> > is_pass;
int warshall(){
  REP(k,V){
    REP(i,V){
      REP(j,V){
	if(is_pass[k][j]&&is_pass[i][k]){
	  d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
	  is_pass[i][j] = true;}
      }
    }
  }
  REP(i,V){
    if(d[i][i] < 0){
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
  }
  REP(i,V){
    REP(j,V){
      if(d[i][j]!=INF)
	cout << d[i][j]; 
      else
	cout << "INF";
      if(j<V-1)cout << " ";
    }
    cout << "\n";
  }
  return 0;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> V >> E;
  d.resize(V,vector<ll>(V,INF));
  is_pass.resize(V,vector<bool>(V,false));
  REP(i,E){
    int s,t;
    cin >> s >> t;
    cin >> d[s][t];
    is_pass[s][t] = true;
  }
  REP(i,V)d[i][i] = 0;
  warshall();

  return 0;
}

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

using namespace std;

int main() {
	long long n, x;

	cin >> n >> x;
	long long a = x;
	long long b = n - x;
	long long ans = a + b;

	while (1) {
		if (a > b) {
			swap(b, a);
		}

		ans += a * (b / a * 2);

		if (b % a == 0) {
			ans -= a;
			break;
		}
		long long tmp = b;
		b = a;
		a = tmp % a;
	}

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


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

using namespace std;

struct Room {
	int sign = -1;
	vector<int> nextList;
};

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

	vector<Room> rooms(N + 1);
	for(int i = 0; i < M; i++) {
		int A, B;
		cin >> A >> B;

		rooms[A].nextList.push_back(B);
		rooms[B].nextList.push_back(A);
	}

	queue<int> que;
	que.push(1);
	while(!que.empty()) {
		int index = que.front();
		que.pop();

		for(int x : rooms[index].nextList) {
			if(rooms[x].sign == -1) {
				rooms[x].sign = index;
				que.push(x);
			}
		}
	}

	cout << "Yes" << endl;
	for(int i = 2; i <= N; i++) {
		cout << rooms[i].sign << endl;
	}

	return 0;
}


Measured memory_bytes: 10600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int H,N;
  int total =0;
 cin >> H >>N;
  int A[N];
  bool ans = false;
 for(int i=0;i < N;++i)
   cin >> A[i];
  for(int i=0;i < N;++i){
  total += A[i];
    if(total >= H)
  ans = true;
  }
  if(ans)
  cout << "Yes" << endl;
  else
    cout << "No" <<endl;
  
}

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

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

    rep(i,t.size()){
        if(t[i]=='?')t[i]='D';
    }

    cout<< t << endl;
    return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>>N;
    int a[N];
    rep(i,0,N) cin>>a[i];
    int ans=0;
    int l=0,r=0;
    while(l<N){
        while(r<N&&a[r]==a[l]){
            r++;
        }
        ans+=(r-l)/2;
        l=r;
    }
    cout <<ans<<"\n";
}

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

namespace ProblemN
{
    class Program
    {
        static void Main(string[] args)
        {

            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var N = read[0];
            var M = read[1];

            var xs = new int[M];
            var ys = new int[M];
            var connDict = new Dictionary<int, List<int>>();
            for (int i = 0; i < N; i++)
                connDict[i] = new List<int>() {};

            for (int i = 0; i < M; i++)
            {
                read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                xs[i] = read[0] - 1;
                ys[i] = read[1] - 1;
                connDict[xs[i]].Add(ys[i]);
                connDict[ys[i]].Add(xs[i]);
            }

            var searched = new bool[N];
            for (int i = 0; i < N; i++)
                searched[i] = false;

            var count = 0;
            DFS(connDict, searched, 0, ref count);

            Console.WriteLine(count);
        }

        static void DFS(Dictionary<int, List<int>> connDict, bool[] searched, int currentNode, ref int count)
        {
            var searchedTemp = new bool[searched.Length];
            searched.CopyTo(searchedTemp, 0);
            searchedTemp[currentNode] = true;
            if (searchedTemp.All(x => x))
            {
                count++;
                return;
            }

            foreach(var node in connDict[currentNode])
            {
                if (!searchedTemp[node])
                    DFS(connDict, searchedTemp, node, ref count);
            }
        }
    }
}


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

int main() {
    while (true) {
        int n; cin >> n;
        if (n == 0) return 0;

        P ans = make_pair(0, 0);
        int p[10000], d1[10000], d2[10000];
        rep(i, n) {
            cin >> p[i] >> d1[i] >> d2[i];
            if (ans.second < d1[i]+d2[i]) ans.first = p[i], ans.second = d1[i]+d2[i];
        }
        cout << ans.first << " " << ans.second << endl;
    }

    return 0;
}


Measured memory_bytes: 3128
#include<stdio.h>

int main(){
  long h,w;
  long res;
  
  scanf("%ld %ld", &h, &w);
  if(h == 1 || w == 1){
    printf("1");
  } else {
    res = (h * w)/2;
    if((h * w)% 2 == 1){
      res++;
    }
    printf("%lu", res);
  }
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		String line;
		List<Integer> input = new ArrayList<>();
		Scanner stdIn = new Scanner(System.in);
		for(int i = 0; i < 3; i++) {
			input.add(stdIn.nextInt());
		}
		Collections.sort(input);

		System.out.println(input.get(0) + " " + input.get(1) + " " + input.get(2));

	}

}

Measured memory_bytes: 26368
using System;
using System.IO;

class Solve
{
    static void Main(string[] args) {
        var S = Console.ReadLine();
        var len = S.Length;
        long answer = 0;
        for (int bit = 0; bit < 1 << len - 1; bit++) {
            long temp = S[0] - '0';
            for (int i = 0; i < len - 1; i++) {
                if ((bit & (1 << i)) > 0) {
                    answer += temp;
                    temp = 0;
                }
                temp = temp * 10 + S[i + 1] - '0';
            }
            answer += temp;
        }
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}

Measured memory_bytes: 25860
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}


int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}


int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}


int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}


int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


int main(){
  int p,q,r,Max,sum;
  cin>>p>>q>>r;
  Max=max(p,q);
  Max=max(Max,r);
  sum=p+q+r;
  cout<<sum-Max;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 2005;

template<typename T>
inline bool chmax(T &x, T y) {
  return x < y ? (x = y, 1) : 0;
}

int N, M;
int A[MAX_N][MAX_N], pos[MAX_N][MAX_N], head[MAX_N];
int nxt[MAX_N][MAX_N], pre[MAX_N][MAX_N], cnt[MAX_N];

inline void remove(int *p, int *n, int x) {
  n[p[x]] = n[x], p[n[x]] = p[x];
}

int res;

void work() {
  res = N;
  for (int i = 1; i <= M; ++i) {
    memset(cnt, 0, sizeof cnt);
    for (int j = 1; j <= N; ++j) cnt[A[j][head[j]]]++;
    
    int mx = 0, mxid;
    for (int j = 1; j <= M; ++j)
      if (chmax(mx, cnt[j])) mxid = j;
    
    res = min(res, mx);
    
    for (int j = 1; j <= N; ++j) {
      remove(pre[j], nxt[j], pos[j][mxid]);
      if (A[j][head[j]] == mxid) head[j] = nxt[j][head[j]];
    }
  }
}

int main() {
  scanf("%d%d", &N, &M);
  
  for (int i = 1; i <= N; ++i) {
    head[i] = 1;
    for (int j = 1; j <= M; ++j) {
      scanf("%d", &A[i][j]), pos[i][A[i][j]] = j;
      pre[i][j] = j - 1, nxt[i][j] = j + 1;
    }
  }

  work();

  printf("%d\n", res);
  
  return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const long double PI = (acos(-1));
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
int main(){
    ll x; scll(x);
    ll now = 100;
    int cnt = 0;
    while (now < x){
        now = now + (now/100);
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3760
#include<iostream>
#include<string>

using namespace std;

int main(){
	string S; cin >> S;
	int s1 = (S[0]-'0') * 10 + (S[1]-'0');
	int s2 = (S[2]-'0') * 10 + (S[3]-'0');

	// YYMM
	if(1 <= s2 && s2 <= 12){
		if(1 <= s1 && s1 <= 12) cout << "AMBIGUOUS" << endl;
		else cout << "YYMM" << endl;
	}else{
		if(1 <= s1 && s1 <= 12) cout << "MMYY" << endl;
		else cout << "NA" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <cstring>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <cassert>
#include <atcoder/scc>
#include <cstdio>

using namespace std;
using namespace atcoder;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m, a, b;
	cin >> n >> m;
	scc_graph graph(n);
	for (int i = 0; i < m; i++)
	{
		cin >> a >> b;
		graph.add_edge(a, b);
	}

	vector <vector<int>> res = graph.scc();
	cout << res.size() << '\n';
	for (int i = 0; i < res.size(); i++)
	{
		cout << res[i].size();
		for (auto it : res[i])
		{
			cout << ' ' << it;
		}
		cout << '\n';
	}

	return 0;
}

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

#define int long long
#define x first
#define y second
#define PII pair<int,int>
#define LL long long
#define pb push_back
#define pqp priority_queue<PII,vector<PII>,greater<PII>>
#define pqi priority_queue<int,vector<int>,greater<int>>
#define PSS pair<string,string>
#define in insert
#define line inline
#define sort(s) sort(s.begin(),s.end());
#define V vector<int>
#define VV vector<V>
#define IOS ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

using namespace std;

int dx[]=  {0,-1,0,1,0,0},dy[]= {-1,0,1,0,0,0},dz[] = {0,0,0,0,-1,1};
const int N = 1e5+7;
int sum[N];
int n , m, p;

inline int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9'){
        x = (x<<1) + (x<<3) + (ch^48);
        ch = getchar();
    }
    return x * f;
}

inline void solve()
{
    int h1,h2,m1,m2,k; cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << (h2 - h1) * 60 + (m2 - m1) - k << endl;
    
}
signed main()
{
    IOS
    //int _; cin >> _; while(_ --)
    solve();

    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  string str;
  cin >> str;
  int i,count=0;
  for(i=0;i<n-2;i++){
    if(str.at(i)=='A' && str.at(i+1)=='B' && str.at(i+2)=='C'){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
    int n,i,cnt,len;
    char s[11],y[201]={0};

    scanf("%s%d",s,&n);

    for(cnt=0;n-->0;){
        scanf("%s",y);
        len=strlen(y);
        for(i=0;s[i]!='\0';i++){
            y[len+i]=y[i];
        }
        //printf("%s",y);
        //strcat(y,y);
        if(strstr(y,s)!=NULL)cnt++;
    }
        printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 604
#include<algorithm>
#include<bitset>
#include<iostream>
#include<iomanip>
#include<set>
#include<string>
#include<math.h>

using namespace std;

class zahyo{
	public:
	int x;
	int y;
	zahyo(){
		x=0;
		y=0;
	}
	zahyo(int x_,int y_){
		x=x_;
		y=y_;
	}
	void print(){
		cout<<x<<" "<<y;
	}
	zahyo operator+(zahyo add){
		add.x=this->x+add.x;
		add.y=this->y+add.y;
		return add;
	}
	zahyo operator-(zahyo add){
		add.x=this->x-add.x;
		add.y=this->y-add.y;
		return add;
	}
	bool operator==(const zahyo add) const{
		if(add.x==this->x and add.y==this->y){return true;}
		else{return false;}
	}
	bool operator!=(const zahyo add) const{
		if(add.x==this->x or add.y==this->y){return false;}
		else{return true;}
	}
	bool operator<(const zahyo add) const{
		if(this->x<add.x){return true;}
		else if(this->x==add.x and this->y<add.y){return true;}
		else{return false;}
	}
	bool operator>(const zahyo add) const{
		if(this->x>add.x){return true;}
		else if(this->x==add.x and this->y>add.y){return true;}
		else{return false;}
	}
	void input(){
		cin>>x>>y;
	}
};


int main(){
	int n;
	cin>>n;
	int num[2][9];
	for(int k=0;k<2;k++){
		for(int i=0;i<n;i++){
			cin>>num[k][i];
		}
	}
	int array[9]={1,2,3,4,5,6,7,8,9};
	int counter=0;
	int numc[2]={};
	do{
		for(int i=0;i<2;i++){
			bool allsame=true;
			for(int j=0;j<n;j++){
				if(num[i][j]!=array[j]){
					allsame=false;
				}
			}
			if(allsame){
				numc[i]=counter;
			}
			for(int k=0;k<n;k++){
				//cout<<array[k];
			}
			//cout<<allsame<<endl;
		}
		counter++;
	}while(next_permutation(array,array+n));
	cout<<abs(numc[0]-numc[1])<<endl;
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main()
{
    int n, m;
    cin >> n >> m;
    lli a[305][305];
    rep(i, n) rep(j, m)
    {
        cin >> a[i][j];
        a[i][j]--;
    }
    set<int> un;
    int ans = 1e8;
    while (1) {
        int cnt[305] = {};
        rep(i, n)
        {
            rep(j, m)
            {
                if (un.find(a[i][j]) == un.end()) {
                    cnt[a[i][j]]++;
                    break;
                }
            }
        }
        int p = max_element(cnt, cnt + m) - cnt;
        ans = min(ans, *max_element(cnt, cnt + m));
        un.insert(p);
        if (un.size() == m)
            break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

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

    ll Bcount = 0;
    ll result = 0;
    for (int i = 0; i < S.length(); ++i) {
        if(S[i] =='B'){
            Bcount++;
        }
        if(S[i] == 'W'){
            result+=Bcount;
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9 + 7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int N;
string S;

inline vector<int> Z_algorithm(string S) {
	vector<int> Z(S.size());
	Z[0] = S.size();
	int i = 1, j = 0;
	while(i < S.size()){
		while(i + j < S.size() && S[j] == S[i + j]) j++;
		Z[i] = j;

		if(j == 0){
			i++;
			continue;
		}
		int k = 1;
		while(i + k < S.size() && k + Z[k] < j){
			Z[i + k] = Z[k];
			k++;
		}
		i += k;
		j -= k;
	}
	return Z;
}

signed main() {
	cin >> N >> S;
	ll ans = 0;
	rep(i, N) {
		string T = S.substr(i, N - i);
		vector<int> v = Z_algorithm(T);
		for (int j = 1; j < v.size(); j++) {
			if(v[j] <= j) ans = max(ans, (ll)v[j]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL INF=100000000000;
string u="abcdefghijklmnopqrstuvwxyz";


int main(){
    int sx,sy,gx,gy;
    cin >> sx >> sy >> gx >> gy;
    int dx,dy;
    dx=gx-sx;
    dy=gy-sy;
    string ans="";
    ans+="D";
    for(int i=0;i<dx+1;i++){
        ans+="R";
    }
    for(int i=0;i<dy+1;i++){
        ans+="U";
    }
    ans+="L";
    for(int i=0;i<dy;i++){
        ans+="D";
    }
    for(int i=0;i<dx+1;i++){
        ans+="L";
    }
    for(int i=0;i<dy+1;i++){
        ans+="U";
    }
    for(int i=0;i<dx+1;i++){
        ans+="R";
    }
    ans+="D";
    for(int i=0;i<dx;i++){
        ans+="L";
    }
    for(int i=0;i<dy;i++){
        ans+="D";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int L; cin >> L;
    Out(pow((double)L / 3.0, 3));

    return 0;
}


Measured memory_bytes: 256
s=input()
if int(s[:2])<=12 and int(s[:2])>0:
    if int(s[2:4])<=12 and int(s[2:4])>0:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif int(s[2:4])<=12 and int(s[2:4])>0:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 9112
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key

signed main() {
   tezz
   
   int n;
   cin >> n;
   int a[n][3];
   for(int i=0; i<n; i++){
       cin >> a[i][0] >> a[i][1] >> a[i][2];
   }
   int dp[n][3];
   dp[0][0]=a[0][0];
   dp[0][1]=a[0][1];
   dp[0][2]=a[0][2];
   for(int i=1; i<n; i++){
       dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
       dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
       dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]);
   }
   cout << max(  { dp[n-1][0]  , dp[n-1][1] , dp[n-1][2]  }  );
  
   return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
char s[10],ans[N],s1[10];
int main(){
	int n,a[3];
	scanf("%d%d%d%d%s",&n,a,a+1,a+2,s);
	if(a[s[0]-'A']+a[s[1]-'A']==0)return puts("No"),0;
	if(a[0]+a[1]+a[2]==1){
		ans[0]=a[s[0]-'A']==0?s[0]:s[1];
		swap(a[s[0]-'A'],a[s[1]-'A']);
		for(int i=1;i<n;i++){
			scanf("%s",s);
			if(a[s[0]-'A']+a[s[1]-'A']==0)return puts("No"),0;
			ans[i]=a[s[0]-'A']==0?s[0]:s[1];
			swap(a[s[0]-'A'],a[s[1]-'A']);
		}
		puts("Yes");
		for(int i=0;i<n;i++)printf("%c\n",ans[i]);
		return 0;
	}
	puts("Yes");
	for(int i=1;i<n;i++){
		int d;scanf("%s",s1);
		if(a[s[0]-'A']==a[s[1]-'A'])d=(s[1]==s1[0]||s[1]==s1[1]);
		else d=(a[s[0]-'A']>a[s[1]-'A']);
		a[s[d]-'A']++,a[s[!d]-'A']--;
		printf("%c\n",s[d]);
		s[0]=s1[0],s[1]=s1[1];
	}
	printf("%c\n",s[a[s[0]-'A']>0]);
	return 0;
} 

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 100100100100100;

int main() {
    int n; cin >> n;
    ll k; cin >> k;
    vector<int> a(n); rep(i,n) cin >> a[i];
    vector<int> f(n); rep(i,n) cin >> f[i];
    sort(all(a));
    sort(all(f),greater<>());
    ll ng = -1;
    ll ok = INF;
    ll mid;
    while (ok-ng > 1) {
        mid = (ok+ng)/2;
        ll cnt = 0;
        rep(i,n) {
            cnt += max(a[i]-mid/f[i], 0ll);
        }
        if (cnt <= k) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    //rep(i,n) {printf("%d ", a[i]);} printf("\n");
    //rep(i,n) {printf("%d ", f[i]);} printf("\n");
    return 0;
}

Measured memory_bytes: 4816
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		
		if (str.substring(2,3).equals(str.substring(3,4)) && str.substring(4, 5).equals(str.substring(5, 6))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");	
		}
	}
}

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


int main() {
   int A, B, C, X, k;
   cin >> A >> B >> C >> X;
   k = 0;
    for (int i = 0; i <=A; ++i) {
        for (int j = 0; j <= B; ++j) {
            for (int l = 0; l <= C; ++l) {
                int total = 500*i + 100*j + 50*l;
                if(total == X)
                    ++k;
            }
        }
    }
    cout << k << endl;
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  int SumPrice=0,MaxPrice=0;
  rep(i,n){
    int p;
    cin>>p;
    SumPrice+=p;
    MaxPrice=max(MaxPrice,p);
  }
  cout<<SumPrice-MaxPrice/2<<endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    N, X, M = map(int, input().split())

    n = [-1] * M
    n[X] = 0

    A = X
    history = [X]
    loop_start = -1
    loop_start_num = -1
    for i in range(1, M+2):
        Anext = A*A % M
        if n[Anext] != -1:
            loop_start = n[Anext]
            loop_start_num = Anext
            break
        history.append(Anext)
        n[Anext] = i
        A = Anext

    # print(n, loop_start,loop_start_num, history)
    ans = 0
    for i in range(min(loop_start, N)):
        ans += history[i]
        N -= 1
    
    loop = history[loop_start:]
    loop_len = len(loop)
    sum_loop = sum(loop)
    # print(sum_loop)

    n_loop = N // loop_len
    ans += sum_loop * n_loop
    N -= loop_len * n_loop

    for i in range(N):
        ans += loop[i]
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 13556
#include<stdio.h>
#include<string.h>
int main()
{
    char S[11],T[12],A[11];
    gets(S);
    gets(T);
    int lenS,lenT,i,d=0;
    lenS=strlen(S);
    lenT=strlen(T);
    lenT=lenT-1;
    for(i=0;i<lenT;i++)
    {
        A[i]=T[i];
    }
    for(i=0;i<lenS;i++)
    {
        if(S[i]==A[i])
        {
            d++;
        }
    }
    if(d==lenS) printf("Yes\n");
    else printf("No\n");

}


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

using namespace std ;

int main () {
	
	int n  , m ; 
	cin >> n  >> m ; 
	vector<int> vect(n) ; 
	float sum = 0 ; 
	for ( int i = 0 ; i < n ; i ++ ) {
		cin >> vect[i] ; 
		sum+= vect[i] ; 
	}
	sum = sum / (4*m); 
	int count = 0 ; 
	for (int i = 0 ; i < n ; i ++ ) {
		if ( vect[i] >= sum ) {
				count++ ; 
		}
	}
	//cout << count << endl ; 
	if ( count >= m ) 
		cout << "Yes" << endl ;
	else
		cout << "No" <<endl ; 

}


Measured memory_bytes: 256
#import sys
#input = sys.stdin.readline

import math
from collections import defaultdict,deque
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

def fast_expo(x,y,m):
    res=1
    while(y):
        if(y&1):
            res*=x
            res%=m
        x*=x
        x%=m
        y>>=1
    return res    

dp=defaultdict(int)
dp[1]=1
dp[2]=1
for i in range(3,200001):
    k=i
    cnt=0
    while(k):
        if(k%2): cnt+=1
        k>>=1
    dp[i]=dp[i%cnt]+1
n=ii()
a=ip()
a=a[::-1]
c=a.count('1')

min_1=0
max_1=0

for i in range(n):
    if(a[i]=='1'):
        if(c-1!=0):
            min_1+=fast_expo(2,i,c-1)
            min_1%=(c-1)
        max_1+=fast_expo(2,i,c+1)
        
        max_1%=(c+1)
    
ans=[]    

for i in range(n):
    if(a[i]=='1'):
        if(c-1==0):
            ans.append(0)
        else:    
            ans.append(dp[(min_1-fast_expo(2,i,c-1)+(c-1))%(c-1)]+1)
    else:
        ans.append(dp[(max_1+fast_expo(2,i,c+1))%(c+1)]+1)
ans=ans[::-1]
for i in ans:
    print(i)

Measured memory_bytes: 114580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int n;
  cin >> n;

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

  string ans = "APPROVED";
  for (int i = 0; i < n; i++) {
    if (a[i] % 2 == 0) {
      if (a[i] % 3 == 0 || a[i] % 5 == 0) {
        continue;
      } else {
        ans = "DENIED";
        break;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) {
 
		Scanner scan = new Scanner(System.in);
		int d = scan.nextInt();
		int n = scan.nextInt();
		
		if (n == 100) {
			n += 1;
		}
		
		if(d == 0) {
			System.out.println(n);
		} else {
			System.out.println((int)Math.pow(100, d) * n);
		}
	}
}

Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<n+1;i++)

using namespace std;
using std::swap;

vector<long long int> p;
vector<long long int> q;
int main() {
	long long int N,t=0;
	cin >> N;
	p.resize(N + 1);
	q.resize(N);
	rep(i, N + 1)cin >> p[i];
	rep(i, N)cin >> q[i];
	rep(i, N) {
		if (q[i] > p[i]) {
			t += p[i];
			q[i] -= p[i];
			p[i] = 0;
		}
		else {
			t += q[i];
			p[i] -= q[i];
			q[i] = 0;
			
		}

		if (q[i] > p[i+1]) {
			t += p[i+1];
			q[i] -= p[i+1];
			p[i+1] = 0;
		}
		else {
			t += q[i];
			p[i+1] -= q[i];
			q[i] = 0;
		}

		if (i == N - i - 1)break;

		if (q[N - i - 1] > p[N - i]) {
			t += p[N - i];
			q[N - i - 1] -= p[N - i];
			p[N-i] = 0;
		}
		else {
			t += q[N - i - 1];
			p[N - i] -= q[N - i - 1];
			q[N - i - 1] = 0;
		}

		if (q[N - i - 1] > p[N - i - 1]) {
			t += p[N - i - 1];
			q[N - i - 1] -= p[N - i - 1];
			p[N-i-1] = 0;
		}
		else {
			t += q[N - i - 1];
			p[N - i - 1] -= q[N - i - 1];
			q[N - i - 1] = 0;
		}

		if (i+1 == N - i - 1)break;
	}
	cout << t << "\n";
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  int count = 0;
  if(s[0] == '1') count += 1;
  if(s[1] == '1') count += 1;
  if(s[2] == '1') count += 1;

  cout << count;
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+5;
int main() {
    int n;cin>>n;
    int now=0;
    for(int i=1;i<=n;i++) {
    	int a,b;cin>>a>>b;
    	if(a==b) now++;
    	else now=0;
    	if(now==3) return cout<<"Yes",0;
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
  int d;
  d=a;a=b;b=d;
  d=c;c=a;a=d;
  
printf("%d %d %d",a,b,c); 
  return 0;}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
        String t = sc.next();
        char[] m1 = new char[s.length()];
        char[] m2 = new char[s.length()];
        int count = 0;
        for(int i = 0; i < s.length(); i++){
            m1[i] = s.charAt(i);
            m2[i] = t.charAt(i);
            if(!(m1[i] == m2[i]))
            count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 42164
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(int n){
    cout << "Yes" << endl;
}

void no (int n){
    cout << "No" << endl;
}

int main() {
    int n; cin >> n;
    vector<ll> ar(n);
    ll ans = 0;
    bool t = false;
    ll mi = inf;
    int m = 0;
    rep(i,n){
        cin >> ar[i];
        if (ar[i] == 0) t = true;
        ans += abs(ar[i]);
        if (ar[i] < 0) m++;
        mi = min(mi,abs(ar[i]));
    }
    if (t) cout << ans << endl;
    else if (m % 2 == 0) cout << ans << endl;
    else cout << ans - 2 * mi << endl;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll p(n);
    rep(i, n){
        cin >> p[i];
    }
    vi a(n, 0);
    rep(i, n){
        if(i+1 == p[i]) a[i] = 1;
    }
    ll ans = 0;
    rep(i, n-1){
        if(a[i] && a[i+1]){
            a[i] = a[i+1] = 0;
            ans++;
        }
    }
    rep(i, n){
        if(a[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    ll A, B, V, W, T;
    cin >> A >> V >> B >> W >> T;
    if ((V - W) * T >= abs(B - A))
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


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

#define MAX_N 200002
typedef long long ll;
typedef pair<ll, ll> P;

ll n, x[MAX_N], y[MAX_N], cum1, cum2, ans, T;

int main()
{
    cin>>n>>T;
    for(int i=0;i<n;i++)
        cin>>x[i];
    for(int i=1;i<n;i++)
        if(x[i] - x[i-1] <= T) ans += (x[i] - x[i-1]);
        else ans += T;
    cout << ans + T;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
int main() 
{
    ll a,b,n;
    cin>>a>>b>>n;
        if((b-1)>n)
        cout<<(floor((a*n)/b))-(a*floor(n/b));
        else
        cout<<(floor((a*(b-1))/b))-(a*floor((b-1)/b));

}

    

Measured memory_bytes: 3768
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


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

	vector<Pll> v( N );
	rep( i, N ) cin >> v[i].F >> v[i].S;

	map<pair<ll, ll>, ll> m;
	rep( i, N )
	{
		for ( int j = 0; j < N; ++j )
		{
			if ( i != j )
			{
				ll tx = v[i].F - v[j].F;
				ll ty = v[i].S - v[j].S;

				m[mp( tx, ty )]++;
			}
		}
	}

	ll ans = 0;
	arep( it, m )
	{
		chmax( ans, it.S );
	}

	cout << N - ans << endl;

	return ( 0 );
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
    long long x,y;
    cin>>x>>y;
    int a=0;
    while(x<=y){
        x=x*2;
        a++;
    }
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    public static final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    public static final PrintStream out = System.out;

    public static void main(String[] args) {
        int A = in.nextInt();
        int B = in.nextInt();
        int C = in.nextInt();

        out.println(Math.max(0, B + C - A));
    }
}


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

int main() {
  int N;
  int a[110];
  cin >> N;
  for(int i = 0; i < N; ++i) cin >> a[i];

  sort(a, a + N, greater<int>());
  int A = 0;
  int B = 0;
  for(int i = 0; i < N; ++i) {
    if (i % 2 == 0) A += a[i];
    else {
      B += a[i];
    }
  }
  int diff = A - B;
  cout << diff << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	string S; cin >> S;
	rep(i, 0, S.size()) {
		cout << (char)((S[i] - 'A' + N) % 26 + 'A');
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
//using Graph = vector<vector<int>>;
typedef long long ll;
using Graph = vector<vector<pair<ll,ll>>>;
const int mod =1e+9+7;

const int dy[4]={0,1,0,-1};
const int dx[4]={1,0,-1,0};
const ll INF=1e10;

int main(){
    ll s; cin>>s;
    vector<ll>dp(s+1);
    dp[0]=1;
    dp[1]=0;
    dp[2]=0;
    for(int i=3;i<=s;i++){
        dp[i]=dp[i-1]+dp[i-3];
        dp[i]%=mod;
    }
    cout<<dp[s]<<endl;
    }











Measured memory_bytes: 3604