akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string words[] = {"dream", "dreamer", "erase", "eraser"};
  string S;
  cin >> S;
  REV(S);
  REP(i,4){
      REV(words[i]);
  }
  int p = 0;
  while(p<S.size()){
    bool success = false;
    REP(i,4){
        string word = words[i];
            if (S.substr(p,word.size()) == word){
                success = true;
                p+=word.size();
                break;
            }

        }
    if (!success){
            cout << "NO" << endl;
            return 0;
        }  
    }
  cout << "YES" << endl;
}

Measured memory_bytes: 512
K,S = map(int,input().split())
t = 0
#c = 0
for x in range(max(0,S-2*K),min(S//3+1,K+1)):
    if S-x > 2 * K:
        pass
    else:
        for y in range(max(x,S-x-K),min((S-x)//2+1,K+1)):
            #c += 1
            z = S - x - y
            if z < y:
                #print('pass')
                pass
            else:
                #print(x,y,z)
                if x == y == z:
                    t += 1
                elif x == y or y == z:
                    t += 3
                else:
                    t += 6
print(t)

Measured memory_bytes: 3060
# compare function
def comp(items):
    return (items[0]**2 + items[1]**2 == items[2]**2)


# main function
def main():
    n = int(input())

    items = [0] * 3
    for tm in range(n):
        str = (input()).split()
        for i in range(3):
            items[i] = int(str[i])

        items.sort()

        if(comp(items)):
            print("YES")
        else:
            print("NO")


if __name__ == '__main__':
    main()

Measured memory_bytes: 6720
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def PL(L) : print(*L, sep="\n")

X, Y, A, B, C = LI()
P = LI()
Q = LI()
R = LI()

P.sort(reverse=True)
Q.sort(reverse=True)
P = P[0 : X]
Q = Q[0 : Y]

aps = P + Q + R
aps.sort(reverse=True)

print(sum(aps[0 : X+Y]))


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


void solve(long long N, long long Y){
  long long max_a = min(Y/10000, N); //1万円札

  for(long long a = 0; a <= max_a; a++){
    long long max_b = min((Y-10000*a)/5000, N); //5千円札
    if(max_b < 0) break;
    for(long long b = 0; b <= min((Y-10000*a)/5000,N); b++){
        long long c = N - a - b;
        if(c < 0) break;
        if(10000 * a + 5000 * b + 1000 * c == Y){
          cout << a << ' ' << b << ' ' << c << endl;
          return;
        }
    }
  }
  cout << "-1 -1 -1" << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long Y;
    scanf("%lld",&Y);
    solve(N, Y);
    return 0;
}


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

int main() {
	int m, n;
	cin >> n >> m;
	int A[100][100];
	int B[100],C[100];

	for (int s = 0; s < 100; s++) {
		for (int r = 0; r < 100; r++) {
			A[s][r] = 0;
		}
		B[s] = 0;
		C[s] = 0;
	}

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

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

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			C[i] += B[j] * A[i][j];
		}
		cout << C[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3148
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();

        List<Integer> divsA = new ArrayList<>();
        List<Integer> divsB = new ArrayList<>();
        for (int i = 1; i <= a; ++i) {
            if (a % i == 0) divsA.add(i);
        }
        for (int i = 1; i <= b; ++i) {
            if (b % i == 0) divsB.add(i);
        }

        List<Integer> divs = new ArrayList<>();
        for (int i = 0; i < divsA.size(); ++i) {
            for (int j = 0; j < divsB.size(); ++j) {
                if (divsA.get(i) == divsB.get(j)) {
                    divs.add(divsA.get(i));
                }
            }
        }

        System.out.println(divs.get(divs.size() - k));
    }
}

Measured memory_bytes: 22868
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
using namespace std;
// #define int long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

/////////////////////////////////////////////////////////////////////

const int N = 110, K = 1e5+10, M = 1e9+7;
ll add(ll x, ll y) {return (x+y)%M;}
ll sub(ll x, ll y) {return (x+M-y)%M;}

int n, k, a[N];
ll dp[N][K], p[N][K];

void calc_pre(int idx) {
	p[idx][0] = dp[idx][0];
	FOR(i, 1, k) p[idx][i] = add(p[idx][i-1], dp[idx][i]);
}

ll range_sum(int idx, int lo, int hi) {
	return sub(p[idx][hi], lo > 0 ? p[idx][lo-1] : 0);
}

signed main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    cin >> n >> k;
    FOR(i, 1, n) cin >> a[i];

    dp[0][0] = 1;
    calc_pre(0);
    FOR(i, 1, n) {
    	FOR(j, 0, k) dp[i][j] = range_sum(i-1, j-a[i], j);
    	calc_pre(i);
    }
    cout << dp[n][k] << endl;

    return 0;
}

// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE)
// - .size()-k underflow (WA, RTE, TLE)
// - small n edge cases (WA)

// Rare mistakes made in the past:
// - division by 0 (WA)
// - integer division (WA)
// - setprecision (WA)
// - INF not big enough using ll (WA)
// - setting min to 0 instead of -INF (WA)
// - outputting debug (WA)
// - allocating too much memory (locRTE, MLE)
// - stack size (locRTE)


Measured memory_bytes: 162048
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
b = 0
for i in a:
    x -= i
    if x >= 0:
        b += 1
        N -= 1
    else:
        break
if x == 0:
    print(b)
else:
    if N == 0:
        print(b-1)
    else:
        print(b)

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

class B
{
	static void Main()
	{
		Console.ReadLine();
		var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
		var d = a.Where((pi, i) => pi != i + 1).Count();
		Console.WriteLine(d == 0 || d == 2 ? "YES" : "NO");
	}
}


Measured memory_bytes: 13396
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    N = int(input())
    S = input()

    ans = 0
    for i in range(1000):
        s = str(i).zfill(3)
        i0 = S.find(s[0])
        if i0 != -1:
            i1 = S[i0+1:].find(s[1])
            if i1 != -1:
                i2 = S[i0+i1+2:].find(s[2])
                if i2 != -1:
                    ans += 1

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=2e5+5;
const int mod=1e9+7;
int n,m;
ll x;
ll c[20];
ll a[20][20];
ll f[20];
ll min1=1e18;
void dfs(ll cost,int cnt)
{
    int flag=0;
    for(int i=1;i<=m;i++)
    {
        if(f[i]<x)
        {
            flag=1;
            break;
        }
    }
    if(!flag)
    {
        min1=min(min1,cost);
        return;
    }
    if(cnt>n)
        return;
    for(int i=1;i<=m;i++)
    {
        f[i]+=a[cnt][i];
    }
    dfs(cost+a[cnt][0],cnt+1);
    for(int i=1;i<=m;i++)
    {
        f[i]-=a[cnt][i];
    }
    dfs(cost,cnt+1);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m>>x;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            cin>>a[i][j];
        }
    }
    dfs(0,1);
    if(min1==1e18)
        cout<<-1<<'\n';
    else
    cout<<min1<<'\n';

}

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

int main(){
  int N;
  cin >> N;
  int V[N],C[N];
  for(int i=0;i<N;i++){
    cin >> V[i];
  }
  for(int i=0;i<N;i++){
    cin >> C[i];
  }
  int a[N];
  for(int i=0;i<N;i++){
    a[i] = V[i]-C[i];
  }
  int sum=0;
  for(int i=0;i<N;i++){
    if(a[i]>0){
      sum+=a[i];
    }
  }
  cout << sum << '\n';
}


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

const ll MOD = 1e9 + 7;

int main(){
  ll N; cin >> N;
  vector<ll> bits(61, 0);
  
  for(ll i=0; i<N; i++){
    ll a; cin>>a;
    ll sft=0;
    while(a>0){
      if(a%2){
        bits[sft]++;
      }
      a/=2;
      sft++;
    }
  }
  
  ll ans = 0, ad = 1;
  for(ll b: bits){
    ans += (((ad * b) % MOD) * (N - b)) % MOD;
    ans %= MOD;
    ad *= 2;
    ad %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define MAXN 3005

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

	long long n, i, j, k, s, ans, MOD = 998244353;
	cin >> n >> s;
	vector<long long> a(n), ct(MAXN, 0), sum(MAXN, 0);
	for (i = 0; i < n; i++) cin >> a[i];

	ans = 0;
	for (i = 0; i < n; i++) {
		for (j = s - a[i]; j >= 1; j--) {
			ct[j + a[i]] = (ct[j + a[i]] + ct[j]) % MOD;
			sum[j + a[i]] = (sum[j + a[i]] + sum[j]) % MOD;
		}

		// add self (standalone)
		ct[a[i]] = (ct[a[i]] + 1) % MOD;
		sum[a[i]] = (sum[a[i]] + i) % MOD;

		// add all occurrence without current one
		ans = (ans + sum[s] + ct[s]) % MOD;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void){
  int i, n, r, t, cr, ct, cs;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d%d", &r, &t);
    cr = r % 100;
    ct = t % 30;
    cs = t/30*5+r/100;
    if(cr == 0 && ct == 0){
      printf("%d\n", cs);
    }else if(cr != 0 && ct == 0){
      printf("%d %d\n", cs, cs+1);
    }else if(cr == 0 && ct != 0){
      printf("%d %d\n", cs, cs+5);
    }else{
      printf("%d %d %d %d\n", cs, cs+1, cs+5, cs+6);
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdlib.h>
#include<set>

using namespace std;

int main(void)
{
    long int W,H,x,y;
    cin>>W>>H>>x>>y;
    
    
    if((W%2==0 && x==W/2) && (H%2==0 && y==H/2)){
       cout<<(double)W*H/2<<" "<<1<<endl;
    }
    else{
        cout<<(double)W*H/2<<" "<<0<<endl;
    }
  
}



Measured memory_bytes: 256
h, w = map(int, input().split())
aa = [
    list(map(int, input().split()))
    for _ in range(h)
]

ans = []
for y in range(h):
    for x in range(w - 1):
        if aa[y][x] & 1 == 1:
            ans.append((y, x, y, x + 1))
            aa[y][x] -= 1
            aa[y][x + 1] += 1
for y in range(h - 1):
    if aa[y][w - 1] & 1 == 1:
        ans.append((y, w - 1, y + 1, w - 1))
        aa[y][w - 1] -= 1
        aa[y + 1][w - 1] += 1

print(len(ans))
for a in ans:
    print(' '.join(map(lambda x: str(x + 1), a)))

Measured memory_bytes: 26600
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

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

   bool flg = 0;
   if(a>x) flg = 0;
   else if(a+b>=x) flg = 1;
   else if(a==x) flg =1;
   
   if(flg) cout << "YES" << endl;
   else cout << "NO" << endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	ll n,k;
	cin>>n>>k;
	vector<ll> a(n);
	for(int i = 0; i < n; i++){
		cin >>a[i];
	}
	ll ans = -1;
	vector<ll> cnt(42);
	for(int i = 41; i >=0; i--){
		ll mask = 1LL<<i;
		for(int j = 0; j < n; j++){
			if(mask & a[j]) cnt[i]++;
		}
	}

	// for(int i = 0; i <= 41; i++){
	// 	cout << cnt[i] << endl;
	// }

	ll now = 0;
	for(int i = 41; i >=0; i--){
		ll mask = 1LL<<i;
		if(k & mask){
			now += (mask);
			ll res = now - (mask);
				for(int j = i-1; j >= 0 ; j--){
					if(cnt[j]<n-cnt[j]) res += 1LL<<j;
				}
				ll res_ans = 0;
				for(int j = 0; j < n; j++){
					res_ans += (a[j]^res);
				}
				ans = max(res_ans,ans);

				// cout << "now = " << now << endl;
				res_ans = 0;
				for(int j = 0; j < n; j++){
					res_ans += (a[j]^now);
					// cout << (a[j]^now) << " ";
				}
				// printf("\n");
				ans = max(res_ans,ans);
		}

		// cout << now << "  " << ans << endl;
	}

	if(k==0) ans = accumulate(all(a),(ll)0);
	cout << ans << endl;

	return 0;
}

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

int a;

int main(){
  cin >> a;
  if(a<1200) cout << "ABC" <<endl;
  else if(a<2800) cout << "ARC" <<endl;
  else cout << "AGC" <<endl;
}


Measured memory_bytes: 256
fn main() {
    let s = next_line();
    let mut v = vec![false; 4];
    for c in s.chars() {
        
        match c {
            'N' => v[0] = true,
            'E' => v[1] = true,
            'W' => v[2] = true,
            'S' => v[3] = true,
            _ => continue,
        }
    }
    let mut ok = true;
    for x in 0..4 {
        if v[x] && v[3 - x] == false {ok = false;}
       // println!("{}", v[x]);
    }
    println!("{}", if ok {"Yes"} else {"No"});
}



fn next_line() -> String {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input
}

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

using namespace std;

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

  int n, k, r, s, p;
  cin >> n >> k;
  cin >> r >> s >> p;
  string t;
  cin >> t;

  int count = 0;
  for (int i = 0; i < k; i ++) {
    for (int j = i; j < n; j += k) {
      if (j == i || t[j] != t[j - k]) {
        if (t[j] == 'r') {
          count += p;
        } else if (t[j] == 's') {
          count += r;
        } else if (t[j] == 'p') {
          count += s;
        }
      } else {
        t[j] = ' ';
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 512
#include <algorithm>
        #include <bitset>
        #include <cassert>
        #include <chrono>
        #include <cmath>
        #include <complex>
        #include <cstdio>
        #include <cstdlib>
        #include <cstring>
        #include <ctime>
        #include <deque>
        #include <functional>
        #include <iomanip>
        #include <iostream>
        #include <iterator>
        #include <limits>
        #include <climits>
        #include <list>
        #include <map>
        #include <numeric>
        #include <queue>
        #include <random>
        #include <ratio>
        #include <set>
        #include <sstream>
        #include <stack>
        #include <string>
        #include <unordered_map>
        #include <unordered_set>
        #include <utility>
        #include <vector>
        using namespace std;
         
        typedef long long ll;
        typedef long double LD;
        #define int ll
        #define double LD
        #define pb push_back
        #define mp make_pair
        #define REP(i,n) for (int i = 0; i < n; i++)
        #define loop(i,n) for (int i = 0; i < n; i++)
        #define FOR(i,a,b) for (int i = a; i < b; i++)
        #define REPD(i,n) for (int i = n-1; i >= 0; i--)
        #define FORD(i,a,b) for (int i = a; i >= b; i--)
        #define remax(a,b) a = max(a,b)
        #define remin(a,b) a = min(a,b)
        #define mem(a, b) memset(a, b, sizeof a)
        #define append push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define print(x) cout << (x) << endl
        #define PRECISION(x) cout << fixed << setprecision(x)
        #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
        #define Test(){int t;cin >> t;for(int i=1;i<=t;i++){cout << "Case #" << i << ": ";solve();}}
        #define test(){int t; cin>>t; for(int i=1;i<=t;i++){solve();}}
        #define vi vector<int>
        #define vii vector<pair<int,int> > 
        #define vci vector<pair<char,int> >
        #define vic vector<pair<int,char> > 
        #define N 20005
        #define pb push_back
        const double PI=acos(-1);
        const int MOD = 1000000007;
        const int FMOD = 998244353;
		
	
		void solve()
		{
			string s,t;
			cin>>s>>t;
			
			int n=s.size();
			int n1=t.size();
			int cnt=0,ans=INT_MAX;
			
			for(int i=0;i<=n-n1;i++)
			{
			    int cnt=0;
			    string p=s.substr(i,n1);
			    for(int j=0;j<n1;j++)
			    {
			        if(p[j]!=t[j])
			        cnt++;
			    }
			    ans=min(ans,cnt);
			}
			cout<<ans<<endl;
		}
		signed main()
		{
		//	test();
		solve();
		}

Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>

int cmp(const void* a,const void* b)
{
    return *(int *)a - *(int *)b;
}


int main()
{
	int n,k,i,j;
    int max=0;
    int x[110],y[110];

    for(i=0;i<110;i++)
    {
        y[i] = 0;
    }

	scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&x[i]);
        if(max<x[i])
        {
            max = x[i];
        }
    }

for(i=0;i<max;i++)
{
    for(j=0;j<n;j++)
    {
        y[i] = y[i] + (x[j] - i-1)*(x[j] - i-1);
    }
}
	qsort(y,max,sizeof(y[0]),cmp);

    printf("%d",y[0]);
	return 0;
}

Measured memory_bytes: 128
#coding:utf-8

if __name__ == "__main__":
    A, B, K = map(int, input().split())
    L = []
    for n in range(1, min(A, B)+1):
        if A % n == 0 and B % n == 0:
            L.append(n)

    print(L[len(L)-K])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;
typedef pair<ll,ll> pairs;
typedef vector<pairs> p;


ll gcd(ll A,ll B){
    if (A%B==0)return(B);
    else return(gcd(B,A%B));
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}

bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    cin.tie(0);

    ll r, g, b, n;
    cin>>r>>g>>b>>n;
    ll ans = 0;
    for(ll i=0;i<=n;++i){
        for(ll j=0;j<=n;++j){
            ll flag = n-(r*i+g*j);
            if(flag%b == 0 and flag >=0){
                ans++;
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn main() {
    let mut n = input!(i64);
    let mut i: u32 = 0;
    let mut zero_or_one: Vec<i32> = Vec::with_capacity(64);

    if n == 0 {
        println!("0");
        return;
    }

    while n != 0 {
        if n % (-2i64).pow(i+1) != 0 {
            zero_or_one.push(1);
            n -= (-2i64).pow(i);
        } else {
            zero_or_one.push(0);
        }
        i += 1;
    }

    zero_or_one.reverse();
    // zero_or_one.iter().for_each(move |x| print!("{}", x));
    for bit in zero_or_one.iter() {
        print!("{}", bit);
    }
    println!("");
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll A[int(2e5+5)];

int main(){
  cin >> N;
  ll sum = 0;
  for (int i = 0; i < N; i++){
    cin >> A[i];
    sum = sum ^ A[i];
  }

  cout << (sum ^ A[0]);
  for (int i = 1; i < N; i++){
    cout << " " << (sum ^ A[i]);
  }
  cout << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

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

    int st, en;

    rep(i, s.size())
    {
        if (s[i] == 'A')
        {
            st = i;
            break;
        }
    }
    for (int i = s.size() - 1; i >= 0; i--)
    {
        if (s[i] == 'Z')
        {
            en = i;
            break;
        }
    }
    cout << en - st + 1 << endl;
    return (0);
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int N;
string S[1000010];
vector<int> rv;
vector<P> rl;
map<int, deque<int>> idx;

struct segtree {
    int size;
    vector<int> node;
    
    segtree(int n) {
        size = 1;
        while (size<n) size *= 2;
        node.resize(2*size-1);
        fill(node.begin(), node.end(), -1000000);
    }
    
    void update(int k, int a) {
        k += size-1;
        node[k] = a;
        while (k>0) {
            k = (k-1)/2;
            node[k] = max(node[2*k+1], node[2*k+2]);
        }
    }
    
    int query(int a, int b, int k, int l, int r) {
        if (r<=a || b<=l) return -1000000;
        if (a<=l && r<=b) return node[k];
        else {
            int vl = query(a, b, 2*k+1, l, (l+r)/2);
            int vr = query(a, b, 2*k+2, (l+r)/2, r);
            return max(vl, vr);
        }
    }
    
    int get(int a, int b) {
        return query(a, b, 0, 0, size);
    }
};

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    rep(i, N) cin >> S[i];
    rep(i, N) {
        int l = 0;
        int r = 0;
        rep(j, S[i].size()) {
            if (S[i][j]=='(') l++;
            else {
                if (l>0) l--;
                else r++;
            }
        }
        //cout << r << " " << l << endl;
        rl.pb(P(r, l));
    }
    sort(rl.begin(), rl.end());
    segtree st(N);
    rep(i, N) st.update(i, rl[i].second);
    rep(i, N) idx[rl[i].second].pb(i);
    rep(i, N) rv.pb(rl[i].first);
    
    int bal = 0;
    rep(i, N) {
        int j = upper_bound(rv.begin(), rv.end(), bal)-rv.begin();
        int M = st.get(0, j);
        if (M==-1000000) {
            cout << "No" << endl;
            exit(0);
        }
        int k = idx[M].front();
        //cout << j << endl;
        idx[M].pop_front();
        st.update(k, -1000000);
        bal -= rl[k].first;
        bal += rl[k].second;
        //cout << bal << endl;
    }
    
    if (bal==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 62604
// Believe in yourself
#include<bits/stdc++.h>

using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Pair vector<pair<ll,ll>>
#define vec vector <ll> 
#define all(a) a.begin(),a.end()
#define mo 1000000007
#define decimal(i,n) fixed << setprecision(i) << n
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define show_nl(a) for(auto xyz:a)cout<<xyz<<endl;


void eea(ll a,ll b,ll &x,ll &y)
{
    if (a == 1)
    {
        x = 1; y = 0;
        return;
    }
    ll x1, y1;
    eea(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
}
ll mi(ll a,ll m)
{
    ll x,y;
    eea(a,m,x,y);
    x= (x%m+m)%m;
    return x;
}

/*
Enter the test case


Some helpful points
1.) Calm yourself
2.) check for semicolon or data type mismatch
*/

ll binarysearch(ll *a,ll n,ll k,ll r)
{
    ll l=1,mid;
    ll p=k;
    while(l<r)
    {   
        ll x=0;
        k=p;
        mid=(l+r)/2;
        for(ll i=n-1;i>=0;i--)
        {   
            ll c=((*(a+i))+mid-1)/mid;
            
            if(c==1)
            break;
            k=k-c+1;
            if(k<0)
            {
                x=1;
                break;
            }    
        }
        if(x==1)
        l=mid+1;
        else
        r=mid;
    }
    return l;
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);    
    ll t=1;
    // cin>>t;
    while(t--)
    {
      int n,m;
      cin>>n>>m;
      int a=(n+m-1)/m;
      cout<<a<<"\n";
      
    }
}



Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int l , r;
  int len = 0;
  for(int i=0;i<n;i++){
    cin >> l >> r;
    len+=r-l+1;
  }
  cout << len << endl;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    def comb(n, k):
        a = n * (n - 1)
        return a // 2
    n = int(input())
    a = list(map(int, input().split()))

    count = {}
    # 10 ** 5
    for i in a:
        count[i] = count.get(i, 0) + 1

    all_sum = 0
    # 10 ** 5
    for i in count.values():
        all_sum += comb(i, 2)

    # 10 ** 5
    for i in a:
        ans = all_sum - comb(count[i], 2) + comb(count[i] - 1, 2)
        print(ans)



Measured memory_bytes: 26140
n=int(input())
S=[list(input()) for i in range(n)]
co=set(S[0])
for x in S:
	co=co&set(x)
if len(co)==0:
	print('')
	exit(0)
dic={x:50 for x in co}
for s in S:
	for x in co:
		dic[x]=min(dic[x],s.count(x))
ans=[]
c=sorted(co)
for x in c:
	for i in range(dic[x]):
		ans.append(x)
print(''.join(ans))

	



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int in_n; cin>>in_n;
  int a[in_n]={0};
  for(int n=1;n<=in_n;n++){
    for(int i=1;i*i<n;i++){
      for(int j=i;j*j<n;j++){
        for(int k=j;k*k<n;k++){
          int s=i*i+j*j+k*k+i*j+j*k+k*i;
          if(s>n) break;
          if(s==n){
            if(i==j&&j==k) a[n-1]+=1;
            else if(i==j||j==k||k==i) a[n-1]+=3;
            else a[n-1]+=6;
          }
        }
      }
    }
  }
  for(int i:a) cout<<i<<endl;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

typedef struct {
    bool L, R;
} p_t;

Int n, q;
vector<Int> G[100001];
bool marked[100001];

Int dfs(Int x) {
    if (marked[x]) return x;
    for (Int i = 0; i < (Int)G[x].size(); i++) {
        //cout << x << " to " << G[x][i] << endl;
        return dfs(G[x][i]);
    }
}

int main() {
    vector<Int> res;
    Int cnt = 0;
    while (cin >> n >> q and n) {
        // if (cnt == 0) {
        //     cnt++;
        //     continue;
        // }
        for (Int i = 0; i <= 100000; i++) {
            while (not G[i].empty()) G[i].pop_back();
            marked[i] = false;
        }
        for (Int i = 2; i <= n; i++) {
            Int x;
            cin >> x;
            G[i].push_back(x);
        }
        marked[1] = true;
        Int sum = 0;
        for (Int i = 0; i < q; i++) {
            char com;
            Int x;
            cin >> com >> x;
            if (com == 'Q') {
                sum += dfs(x);
            }
            if (com == 'M') {
                marked[x] = true;
            }
        }
        //dump(sum);
        res.push_back(sum);
    }
    for (int i = 0; i < (int)res.size(); i++) {
        dump(res[i]);
    }
    return 0;
}



Measured memory_bytes: 8620
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int mod=1e9+7;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
const int N=5005;
int n,k=0,inv;
int a[N],fa[N];
int getf(int x){
	return fa[x]==x?x:fa[x]=getf(fa[x]);
}
int sz[N],tp[N];
int Fac[N],Inv[N];
int v[N],m=0;
int dp[N][N];
int main(){
	n=read(),inv=Pow(n-1,mod-2);
	For(i,1,n)
		fa[i]=i;
	For(i,1,n){
		a[i]=read();
		k+=a[i]==-1;
		if (a[i]!=-1)
			fa[getf(i)]=getf(a[i]);
	}
	For(i,1,n){
		int f=getf(i);
//		outval(f);
		sz[f]++;
		tp[f]+=a[i]==-1;
	}
//	outarr(tp,1,n);outarr(sz,1,n);
	Fac[0]=1;
	For(i,1,n)
		Fac[i]=(LL)Fac[i-1]*i%mod;
	Inv[n]=Pow(Fac[n],mod-2);
	Fod(i,n,1)
		Inv[i-1]=(LL)Inv[i]*i%mod;
	int ans=0,cnt=0;
	For(i,1,n)
		if (getf(i)==i){
			assert(tp[i]<=1);
			if (tp[i]==1)
				v[++m]=sz[i];
			else
				cnt++;
		}
//	outarr(v,1,m);
	assert(k==m);
	dp[0][0]=1;
	For(i,1,m)
		For(j,0,i){
			int val=dp[i-1][j];
			if (!val)
				continue;
			Add(dp[i][j],val);
			Add(dp[i][j+1],(LL)val*inv%mod*v[i]%mod);
		}
	For(i,2,m)
		Add(ans,(LL)dp[m][i]*Fac[i-1]%mod);
	For(i,1,m)
		Add(ans,(LL)(v[i]-1)*inv%mod);
	ans=(LL)ans*Pow(n-1,k)%mod;
	ans=Add((LL)cnt*Pow(n-1,k)%mod+ans);
	ans=Del((LL)n*Pow(n-1,k)%mod-ans);
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i < n; i++) cin >> v[i];
  for(int i=0; i < n; i++) {
    if(v[i]%2 ==0) {
      if(v[i]%3 != 0 && v[i]%5 !=0){cout << "DENIED" << endl; return 0;}
    }
  }
  cout << "APPROVED" << endl;
}


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

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

	string t; cin >> t;
	int n = t.size();
	for (int i = 0; i < n; ) {
		if (t[i] != '?') {++i; continue;}
		char cur = 'P';
		if (i and t[i-1] == 'P') cur = 'D';
		int j = i;
		while (j < n and t[j] == '?') {
			t[j] = cur;
			if (cur == 'D') cur = 'P';
			else cur = 'D';
			++j;
		}
		if (j == n or (j < n and t[j] == 'P')) t[j-1] = 'D';
		i = j;
	}
	cout << t << '\n';
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  string S;
  cin>>S;
  ll a=S.size(), b=a/2;
  //回文かどうか
  for(int i=0; i<b; i++){
    if(S[i]!=S[a-1-i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  //強いかどうか
  //akasaka 奇数7文字なら0-2,4-6 7/2=3
  ll c=b/2;
  for(int i=0; i<c; i++){
    if(S[i]!=S[b-1-i]){
      cout<<"No"<<endl;
      return 0;
    }      
  }
  //かみのく
  for(int i=0; i<c; i++){
    if(S[b+1+i]!=S[a-1-i]){
      cout<<"No"<<endl;
      return 0;
    }      
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define For(i,a,b) for(long long i=a;i<b;i++)
#define pb push_back
using namespace std;
typedef long long ll;
ll power(ll x,ll y,ll p){
ll res = 1;x = x % p;
while (y > 0){
if (y & 1){res = (res*x) % p;}
y = y>>1;
x = (x*x) % p;}
return res;}
ll mcd(ll a,ll b){
    if(b>a)swap(a,b);
    if(b==0)return a;
    else return mcd(b,a%b);
}
ll t,n,m,k;
bool esprimo(ll n){
ll s=0;
for(ll i=1;i*i<=n;i++){
    if(n%i==0){s++;}}
if(s>=2){return false;}
return true;
}
int main(){
    //    cout<<fixed<<setprecision(2);
//cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
string s;
cin>>n;
pair<ll,ll> a[n];
for(int i=0;i<n;i++){cin>>a[i].fi>>a[i].se;}
for(int i=0;i+2<n;i++){
    if(a[i].fi==a[i].se&&a[i+1].fi==a[i+1].se&&a[i+2].fi==a[i+2].se){
        cout<<"Yes"<<endl;
        return 0;
    }
}
cout<<"No"<<endl;
}



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

const int MAXN = 400002;
int a[MAXN], b[MAXN];

int main() {
#ifdef PAUNSVOKNO
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20); cout.tie(nullptr); cin.tie(nullptr);
    int n;
    cin >> n;
    
    if (n == 3) {
        cout << "2 5 63\n";
        return 0;
    }

    int s = 0;
    int p = 0;

    for (int i = 2; p < n; ++i) {
        int r = -1;
        if (p == n - 2) {
            r = (s % 2) ^ 1;
        }
        
        if (((i % 3 == 0) || i % 2 == 0) && (i % 2 != r) && ((p != n - 1) || (s + i) % 6 == 0)) {
            cout << i << " ";
            s += i;
            ++p;
        }
    }
}

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

int main(void)
{
  int n;
  char s[114514], tmp[114514], res[114514];
  int i, j;
  int cnt, len;

  while (scanf("%d", &n), n){
    scanf("%s", s);
    for (i = 0; i < n; i++){
      cnt = 1;
      *res = '\0';
      len = strlen(s);
      for (j = 0; j < len; j++){
        if (s[j] == s[j + 1]){
          cnt++;
        }
        else {
          sprintf(tmp, "%d%c", cnt, s[j]);
          strcat(res, tmp);
          cnt = 1;
        }
      }
      strcpy(s, res);
    }
    printf("%s\n", s);
  }

  return (0);
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define prvsort(v) sort(v.begin(), v.end(), greater<pair<ll, ll>>())
#define ll long long
#define ld long double
#define fixset(val) fixed << setprecision(10) << val 
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define mod 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll N, sum = 0; cin >> N;
  vector<ll> a(N);
  rep(i, 0, N) {
  	cin >> a[i];
    sum ^= a[i];
  }
  rep(i, 0, N) {
  	cout << (sum ^ a[i]) << " ";
  }
}

Measured memory_bytes: 4760
/*
    ////////        //        ////////////          //            /////////
    //            //  //      //                  //  //          //     //
    ///////     /////////     //   ///////      /////////         /////////
        ///   //       //     //   //   //     //       //        /////
    /////// //          //    ///////   //    //         //       //   /////
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define endd "\n"
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define test int t;cin>>t;while(t--)
#define input freopen("inp.txt","r",stdin)
#define output freopen("out1.txt","w",stdout)
#define loop(i,n) for(int i=0;i<n;i++)
#define rloop(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,n) for(int i=1;i<=n;i++)
#define RFOR(i,n) for(int i=n;i>0;i--)
#define cloop(i,x,y) for(int i=(x);i<=(y);++i)
#define bug(a) cout << #a << " = " << a << endl;
#define fbug(a, x, y) {cout<<#a<<":";cloop(i, x, y)cout<<a[i]<<' ';cout<<endl;}
#define sz size()
#define pii pair<int,int>
#define pint pair<int,int>
#define ff first
#define ss second
#define aint(x) x.begin(),x.end()
#define setp(x) fixed<<setprecision(x)
#define pi 3.14159265358979323846264338
#define mset(x) memset(x,0,sizeof x);
#define spa cout<<endd
#define com(x)#x
#define inf 2000
int power(int a , int b,int modi){
    int res=1;
    while(b){if(b%2)res=(res*a)%modi;b/=2;a=(a*a)%modi;}
    return res ;
}/*
int dirx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int diry[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
int dx[]= {-1,1,0,0};
int dy[]= {0,0,-1,1};
//-------------------------------------------------------------------//
#define N 1
int k,sum=0,ans=0,cur=0,x,y,cnt=0;
int n,m,r,c;
ll a[N];*/
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
  
int main()
{
    //    memset(str, 't' , sizeof(str)); 

    fast;
   ll n;
  cin>>n;
 // int b[n];
  vector <int> v;
  vector<int>::iterator it; 
  
  //  it = v.begin(); 
  //  v.erase(it); 
  
  loop(i,n){
      int x;
      cin>>x;
      if(x>(i+1))
      {
          cout<<"-1\n";
          return 0;
      }
      v.push_back(x);
  }

  vector <int> v1;
  ll nn=n;
  while(n--)
  {
    /*  int i=n-1;
       it=v.end();
       it--;
      for(int i=n-1;i>=0;i--)
      {
                        it--;
        

          if(v[i]==(i+1))
          {
              cout<< "\n v[i] and i are  "<<v[i]<<" "<<i<<endl;
              cout<<v[i]<<endl;
              v.erase(it);
             break;
          }
         // it--;*/
         it=v.begin();
         int in=0;
         for(int i=0;i<=n;i++)
         {  
             //it++;
             if(v[i]==(i+1))
             {
              //   cout<<"v[i] and i are "<<v[i]<<" "<<i<<endl;
             in=i;
             }
             
         }
         v1.push_back(v[in]);
        //  cout<<v[in]<<endl;
         v.erase(v.begin()+in);
      
    // cout<<"loop after \n";

  }
  reverse(v1.begin(),v1.end());
  loop(i,nn)
  {
     cout<<v1[i]<<endl;
  }
  
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int l = s.length();
    for(int i=0; i<l; i++){
     System.out.print("x");
    }
    System.out.print("\n");
  }
}

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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

const int N = 1e5 + 7;

int height[N];

vector<int> G[N];
bool vis[N];
bool good[N];

void dfs(int v) {
  vis[v] = true;
  bool ok = true;
  for (auto &u : G[v]) {
    if (!vis[u]) {
      dfs(u);
    }
    if (height[u] >= height[v]) {
      ok = false;
    }
  }
  good[v] = ok;
}

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

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

  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      dfs(i);
    }
  }

  int res = 0;
  for (int i = 1; i <= n; i++) {
    res += good[i];
  }

  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 11008
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
int main(){
  ll a,b,k;cin>>a>>b>>k;
  if(a>=k)
  {
    cout<<a-k<<" "<<b;
  }
  else if(a<k && a+b>=k)
  {
    cout<<0<<" "<<a+b-k;
  }
  else
    cout<<0<<" "<<0;
}
  

  


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 2005
#define MOD 1000000007
using namespace std;
using LL = long long;

int n,m,s[M],t[M];
LL sum[M][M],dp[M][M];
int low(int x) {
    return x&-x;
}
void add(int x,int y,int v) {
    for (int i=x; i<=n; i+=low(i))
        for (int j=y; j<=m; j+=low(j))
            sum[i][j] = (sum[i][j] + v) % MOD;
}
LL ask(int x,int y) {
    LL res = 0;
    for (int i=x; i>0; i-=low(i))
        for (int j=y; j>0; j-=low(j))
            res = (res + sum[i][j]) % MOD;
    return res;
}
int main()
{
    while (~scanf("%d %d", &n,&m)) {
        REP(i,1,n) scanf("%d", &s[i]);
        REP(i,1,m) scanf("%d", &t[i]);

        LL ans = 0;
        MSET(sum, 0);
        MSET(dp, 0);
        dp[0][0]=1;
        
        REP(i,1,n)REP(j,1,m) if(s[i]==t[j]) {
            dp[i][j] = (ask(i-1, j-1) + 1) % MOD;
            ans += dp[i][j];
            add(i,j,dp[i][j]);
        }
        printf("%lld\n", (ans+1)%MOD);
    }
    return 0;
}


Measured memory_bytes: 63104
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse = True)
d = dd(int)
sd = dd(int)
res = 1
nCr = {}
def cmb(n, r):
  global nCr
  if r == 0 or r == n: return 1
  if r == 1: return n
  if (n,r) in nCr: return nCr[(n,r)]
  nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
  return nCr[(n,r)]

for i in range(N):
  d[v[i]] += 1
r = sum(v[: A])
s = v[: A]
sdsum = 0
for t in s:
  sd[t] += 1
  sdsum += 1
kss = sorted(sd.keys())
#print(d, sd)
f = 0
j = -1
for k in range(A, B + 1):
  j += 1
  t = 1
  for i in range(len(kss)):
    a = kss[i]
    if d[a] < sd[a] + j:
      f = 1
      break
    t *= cmb(d[a], sd[a] + j)
    #print(d[a], sd[a] + j)
  if f:
    break
  res += t
print(r / A)
print(res - 1)

Measured memory_bytes: 40304
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String a = scanner.next();
		String s = scanner.next();
		String c = scanner.next();
		System.out.println("A" + String.valueOf(s.charAt(0)) + "C");
	}

}


Measured memory_bytes: 20820
#include "bits/stdc++.h"

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);

int n, q;

int get_ordered_golem_position(int pos, string s, string items, string orders) {
    char code = s[pos]; 
    for(int i=0; i<items.size(); i++) {
        if(code == items[i]) {
            if(orders[i] == 'L')
                pos--;
            else
                pos++; 
            code = s[pos];
        }
    } 
    return pos;
}

int get_drop_position(int left, int right, 
                        string s, string t, string d, char direction) {
    int position = left + (right-left)/2;
    int moved_position = get_ordered_golem_position(position, s, t, d); 
    if(direction == 'L') {
        if(right-left<=1) return position;
        else if(moved_position == -1) return get_drop_position(position, right, s, t, d, direction);
        else return get_drop_position(left, position, s, t, d, direction);
    } else {
        if(right-left<=1) return position;
        else if(moved_position == n) return get_drop_position(left, position, s, t, d, direction);
        else return get_drop_position(position, right, s, t, d, direction);
    }

    return 0;
}

int main() {
    //int n, q;
    string s;
    cin >> n >> q;
    cin >> s;
    string t(q, 'a'), d(q, 'a');
    for(int i=0; i<q; i++) {
        cin >> t[i] >> d[i];
    }

    //for(int i=0; i<n; i++) {
    //    cout << i << " :" << get_ordered_golem_position(i, s, t, d) << endl;
    //}
    // 落ちないギリギリのラインを攻める
    int left_pos = get_drop_position(-1, n, s, t, d, 'L');
    int right_pos = get_drop_position(-1, n, s, t, d, 'R');
   
    //cout << "LEFT_POS: " << left_pos << endl;
    //cout << "RIGHT_POS: " << right_pos << endl;

    int ans = right_pos - left_pos;
    if(ans < 0) cout << 0 << endl;
    else cout << ans << endl;
    
    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

// integerの各桁を足す
int sum_digits(int num) {
    int rtn = 0;
    string num_str = to_string(num);
    for(int i=0; i<num_str.size(); i++) {
        rtn += num_str[i] - '0';
    }   
    return rtn;
}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}



Measured memory_bytes: 1924