akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

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

  int n, m;
  lol h[100005];
  cin >> n >> m;
  reps(i, n){
    cin >> h[i];
  }
  vit road[100005];
  int a, b;
  rep(i, m){
    cin >> a >> b;
    road[a].pu(b);
    road[b].pu(a);
  }
  bool out[100005] = {false};
  lol ans = 0;
  reps(i, n){
    if(out[i] == false){
      rep(j, road[i].size()){
	if(h[i] > h[road[i][j]]){
	  out[road[i][j]] = true;
	} else {
	  out[i] = true;
	}
      }
    }
  }
  int nasu = 0;
  reps(i, n){
    if(!out[i]){
      nasu ++;
    }
  }
  cout << nasu << '\n';
  return 0;
}


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

int main(){
  int N;
  int mx=0;
  string s;
  cin>>N;
  cin>>s;
  int x=0;
  for(int i=0;i<N;i++){
    if(s[i]=='I'){
      x+=1;
    }
    else{
      x-=1;
    }
    mx = max(mx,x);
  }
  cout<<mx<<endl;
}

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


//TEMPLATE
#define pb                push_back
#define mp                make_pair
#define ll                long long
#define ld                long double
#define pii               pair <ll, ll>
#define piii              pair <ll, pii>
#define F                 first
#define S                 second

#define newline           printf("\n")
#define minusone          printf("-1\n")
#define zeroo             printf("0\n")
#define scl1(a)           scanf("%lld", &a)
#define scl2(a, b)        scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)     scanf("%lld %lld %lld", &a, &b, &c)
#define prl1(a)           printf("%lld\n", a)
#define prl2(a, b)        printf("%lld %lld\n", a, b)
#define ssl1(s)           scanf(" %[^\n]", s)
#define scd1(a)           scanf("%lf", &a)
#define scd2(a, b)        scanf("%lf %lf", &a, &b)
#define prd(a)            printf("%lf\n", a)
#define prld(a)           printf("%Lf\n", a)
#define prcase(cs)        printf("Case %lld: ", cs)
#define cin1(a)           cin >> a
#define cin2(a, b)        cin >> a >> b
#define cin3(a, b, c)     cin >> a >> b >> c
#define cin4(a, b, c, d)  cin >> a >> b >> c >> d
#define cot1(a)           cout << a << "\n"
#define cot2(a, b)        cout << a << " " << b << "\n"
#define cot3(a, b, c)     cout << a << " " << b << " " << c << "\n"
#define cot4(a, b, c, d)  cout << a << " " << b << " " << c << " " << d << "\n"
#define cotline           cout << "\n"
#define cotminus          cout << "-1\n"
#define cot0              cout << "0\n"
#define cotyes            cout << "YES\n"
#define cotno             cout << "NO\n"
#define cotcase(cs)       cout << "Case " << cs << ": "

#define reversed(s)       reverse(s.begin(), s.end())
#define asort(s)          sort(s.begin(), s.end())
#define dsort(s)          sort(s.rbegin(), s.rend())
#define all(s)            s.begin(), s.end()
#define uniq(s)           s.resize(distance(s.begin(),unique(s.begin(), s.end())))
#define found(s, x)       (s.find(x) != s.end())

#define for0(i, n)        for (i = 0; i < n; i++)
#define for1(i, n)        for (i = 1; i <= n; i++)
#define fora(i, a, b)     for (i = a; i <= b; i++)
#define forb(i, b, a)     for (i = b; i >= a; i--)
#define fori(it, s)       for(auto it = s.begin(); it != s.end(); it++)

#define FR                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(a, x)          memset(a, x, sizeof a)
#define bitcount(n)       __builtin_popcountll(n)

//#define pi              3.1415926536
#define pi                acos(-1)

const ll INF = LLONG_MAX;
const ll SZ = 4e5+5;
const ll mod = 1e9+7;


string s, s1, s2;
ll n, k, ans = 0;
ll a[SZ];
//ll b[SZ];



int main() {
    FR;
    ll cs = 0, tc = 1, x, y, z, i, j, g, p, q, sum = 0, c = 0, t = 0;
//    ll a, b, d;
//    string s, s1, s2;

    cin1(c);
    while(c--) cout << "ACL";
    cotline;

    return 0;
}



Measured memory_bytes: 3508
# include<iostream>
using namespace std;
int a[100005];
int mp[100005];
int main ()
{
	 int N,M;
	 cin>>N>>M;
	 int win_num =0;
	 int wrong_num=0;
	 for(int i=0;i<M;i++)
	 {
	 	 int id;
	 	 cin>>id;
	 	 string s;
	 	 cin>>s;
	 	 if(s=="WA")
	 	 {
	 	 	a[id]++;
		  }
		 else if(mp[id]==0)
		 {
		 	 mp[id]=1;
		 	 win_num++;
		 	 wrong_num +=a[id];
		  }  
	 }
	 cout<<win_num<<" "<<wrong_num<<endl;
	 
	
}

Measured memory_bytes: 1024
N = int(input())
W = list(map(int, input().split()))
from itertools import accumulate

Wcumsum = list(accumulate(W))

ans = 1e10
for i in range(N-1):
  S1 = Wcumsum[i]
  S2 = Wcumsum[-1] - S1
  ans = min(ans, abs(S1-S2))
  
print(ans)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

int INF = INT_MAX / 2;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int dp[21][51][51];

bool check(char c, char d) {
	return c == d || (c != '`' && d == '?');
}

int main() {
	int n; cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		for (; s[i].size() < 20; s[i].push_back('`'));
	}
	for (int i = 0; i <= n; i++)
		dp[20][i][i] = 1;
	for (int i = 0; i + 1 <= n; i++)
		dp[20][i][i + 1] = 1;
	for (int k = 19; k >= 0; k--)
		for (int l = 0; l <= n; l++) {
			vector<int> a(n + 1);
			a[l] = 1;
			for (char c = '`'; c <= 'z'; c++)
				for (int i = n; i >= l; i--)
					for (int j = i + 1; j <= n; j++) {
						if (!check(c, s[j - 1][k])) break;
						a[j] = (a[j] + (ll)a[i] * dp[k + 1][i][j]) % MOD;
					}
			for (int r = l; r <= n; r++)
				dp[k][l][r] = a[r];
		}
	cout << dp[0][0][n] << endl;
}

Measured memory_bytes: 3404
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> seq(n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &seq[i]), --seq[i];

  vector<int> result;
  for (int rep = 0; rep < n; ++rep) {
    int chosen = -1;
    for (int i = 0; i < (int)seq.size(); ++i)
      if (seq[i] == i)
        chosen = i;
    if (chosen == -1) {
      printf("-1\n");
      exit(0);
    }

    result.push_back(chosen);
    seq.erase(seq.begin() + chosen);
  }
  reverse(result.begin(), result.end());
  for (int i = 0; i < (int)result.size(); ++i) {
    printf("%d\n", result[i] + 1);
  }

  return 0;
}


Measured memory_bytes: 256
def main():
	X, N = map(int, input().split(" "))
	if N == 0:
		print(X)
		return
	P = list(map(int, input().split(" ")))
	CONTINUE = True
	dif = 0
	while CONTINUE:
		temp_1 = X - dif
		temp_2 = X + dif
		if (temp_1 not in P):
			print(temp_1)
			CONTINUE = False
		elif (temp_2 not in P):
			print(temp_2)
			CONTINUE = False
		else:
			dif += 1
      
      
    
      
if __name__ == "__main__":
  main()

Measured memory_bytes: 61872
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int X=scan.nextInt();
		int Y=scan.nextInt();
		int Z=scan.nextInt();
		int temp=0;int s = 0;int n=0;
		n=X;
		s=Z;
		X=s;
		System.out.println(X);
		System.out.println(n);
		temp=Y;
		X=temp;
		System.out.println(X);
		}
}

Measured memory_bytes: 35544
#include<bits/stdc++.h>
using namespace std;
int m,d;
int x,y,ans;

int main(){
	cin>>m>>d;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=d;j++){
			x=j%10;
			y=j/10;
			if(x>=2&&y>=2&&x*y==i) ans++;
		}
	}
	cout<<ans;
	
	return 0;
}

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

int main(){
  string C1,C2;
  cin >> C1 >> C2;
  if (C1[0] == C2[2] && C1[1] == C2[1] && C1[2] == C2[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    ll n;
    cin>>n;

    string ans="";
    while(n>0){
        n--;
        ans.push_back((char)((n%26)+'a'));
        if(n)
        n/=26;
    }

    reverse(all(ans));

    cout<<ans<<"\n";

    return 0;

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define OUT(x) cout<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x
const int BA = 1000;
const int INFTY = (1<<21);
int main(){
  const int MAXN = 123456*2;
  int par[MAXN];
  int n,ans;
  memset(par,1,sizeof(par));
  for(int i=2;i<sqrt(MAXN);i++){
    if(par[i]){
      for(int j=0;i*(j+2)<MAXN;j++){
	par[i*(j+2)]=0;
      }
    }
  }
  while(cin >> n&&n){
    ans = 0;
    for(int i=n+1;i<=2*n;i++){
      if(par[i])ans++;
    }
    OUT(ans);
  }
}

Measured memory_bytes: 2128
#include <iostream>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    int q,m,b,e;
    cin>>q;
    while(q--){
            cin>>b>>m>>e;
            for(int i=0;i<m-b;i++) swap(v[b+i],v[e+i]);

    }
    for(int i=0;i<n;i++){
        if(i!=0)cout<<" ";
        cout<<v[i];
    }
    cout<<endl;

}


Measured memory_bytes: 3092
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();
    long a = 0;
    long b = 0;
    for(long i = -200; i <= 200; i++) {
      for(long j = -200; j <= 200; j++) {
        long t = ((((i * i) * i) * i) * i);
        long u = ((((j * j) * j) * j) * j);
        if((t - u) == x) {
          a = i;
          b = j;
        }
      }
    }
    System.out.println(a + " " + b);
  }
}

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

#define LL long long
#define hell 1000000007
#define PI acos(-1.0)



int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout << fixed << showpoint;
cout << setprecision(11);

int x, y;cin>>x>>y;
if(((4*x-y)%2==0 && (4*x-y)>=0) && ((y-2*x)%2==0 && (y-2*x)>=0))
{
    cout<<"Yes";
}
else
{
    cout<<"No";
}

return 0;
} 

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    private static Scanner sc;
    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            int[] hoge = new int[3];
            hoge[0] = sc.nextInt();
            hoge[1] = sc.nextInt();
            hoge[2] = sc.nextInt();

            Arrays.sort(hoge);

            System.out.println(hoge[0] + hoge[1]);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

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

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

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

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

#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define drng(i,a,b) for(int i=int(a);i>int(b);i--)
typedef long long LL;
#define PI 3.14159265


void test_case(){
	
}
int main() {
    fastio
    double a,h,v;
    cin>>a>>h>>v;
    
    double ind = v/(a*a);
    double res;
    double two = 2.00000000;
    if(ind<= h/two){
    	res = atan(two*a*ind/(h*h));
    	res = (res*180.00000000)/PI;
    	cout<<fixed << setprecision(8) <<90.00000000-res<<endl;
    }
    else{
    	ind = 2*(h-ind);
    	double temp = a / ind;
    	res = atan(temp);
    	res = (res*180)/PI;
    	cout<<fixed << setprecision(8) <<90.00000000-res<<endl;
    }
    
    return 0;
}

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



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

    int k=n/1.08;
    int j=k*1.08;
    int m= (k+1)*1.08;
    if(j ==  n){
        cout<<k<<endl;

    }else if(m==n){
        cout<<k+1<<endl;
    }else
    cout<<":("<<endl;



return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[12]:


N = int(input())
L = list(map(int, input().split()))


# In[13]:


ans = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                a = L[i] + L[j]
                b = L[j] + L[k]
                c = L[k] + L[i]
                if a>L[k] and b>L[i] and c>L[j]:
                    ans += 1
print(ans)


# In[ ]:






Measured memory_bytes: 9200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int N;
	cin >> N;
	vector<unsigned long long int> cnt(5);
	vector<string> S(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> S[i];
		if (S[i][0] == 'M')
		{
			cnt[0]++;
		}
		else if (S[i][0] == 'A')
		{
			cnt[1]++;
		}
		else if (S[i][0] == 'R')
		{
			cnt[2]++;
		}
		else if (S[i][0] == 'C')
		{
			cnt[3]++;
		}
		else if (S[i][0] == 'H')
		{
			cnt[4]++;
		}
	}
	unsigned long long int ans = 0;
	for (int i = 0; i < 3; ++i)
	{
		for (int j = i + 1; j < 4; ++j)
		{
			for (int k = j + 1; k < 5; ++k)
			{
				ans += cnt[i] * cnt[j] * cnt[k];
			}
		}
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 6144
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
const int INF = 10000;
int main() {
  vector<int> food(5);
  rep(i, 5) cin >> food[i];
  vector<int> idx = {0, 1, 2, 3, 4};
  int ans = INF;
  do {
    int et = 0;
    rep(i, 5) {
      et = et % 10 == 0 ? et : 10 * (et / 10 + 1);
      et += food[idx[i]];
    }
    ans = min(ans, et);
  } while(next_permutation(all(idx)));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
k = int(input())

lunlun = [[1, 2, 3, 4, 5, 6, 7, 8, 9]]
for i in range(11):
    last = lunlun[-1]
    add = []
    for x in last:
        c = x % 10
        add.append(x*10+c)
        if c != 0:
            add.append(x*10+c-1)
        if c != 9:
            add.append(x*10+c+1)
    lunlun.append(add)

all = []
for i in range(11):
    for x in lunlun[i]:
        all.append(x)
all.sort()
print(all[k-1])


Measured memory_bytes: 83160
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int base = sc.nextInt() / 2;
        HashSet<Integer> set = new HashSet<>();
        for (int i = 1; i < n; i++) {
            set.add(sc.nextInt() / 2);
        }
        set.remove(base);
        int count = getDev2Count(base);
        long lcm = base;
        for (int x : set) {
            if (count != getDev2Count(x)) {
                System.out.println(0);
                return;
            }
            lcm = lcm / gcd(lcm, x) * x;
            if (lcm > m) {
                System.out.println(0);
                return;
            }
        }
        System.out.println((m / lcm + 1) / 2);
    }
    
    static int getDev2Count(int x) {
        int count = 0;
        while (x % 2 == 0) {
            count++;
            x /= 2;
        }
        return count;
    }
    
    static long gcd(long x, long y) {
        if (x % y == 0) {
            return y;
        } else {
            return gcd(y, x % y);
        }
    }
}

Measured memory_bytes: 48292
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back;
#define IOS ios_base::sync_with_stdio(NULL);cin.tie(0);cout.tie(0)
using namespace std;
long long n,m,sum,arr[100005],cnt;
int main(){
    IOS;
    cin>>n>>m;
    for(int i =1;i<=n;i++){
        cin>>arr[i];
        sum+=arr[i];
    }
    for(int i =1;i<=n;i++){
        if(arr[i]*4*m>=sum)cnt++;
    }
    if(cnt>=m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class Task
    {
        static int N = 101;
        static int K;
        static int dp[][][] = new int[N][N][2];

        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            String number = in.next(); // n
            K = in.nextInt(); // number of non-0 digits in a number
            init_dp();
            int digits[] = getDigitsFrom(number);
            out.print(digitOcc(0, 0, true, digits));
        }

        static int digitOcc(int index, int count, boolean tight, int digits[])
        {
            if (count > K) return 0; // fails condition
            if (index == digits.length) return count == K ? 1 : 0; // out of boundary
            int answer = dp[index][count][boolToInt(tight)];
            if (answer >= 0) return answer;

            answer = 0;
            for (int i = 0; i < 10; ++i)
            {
                if (tight && (i > digits[index])) break; // forming too big number
                boolean nextTight = tight && (i == digits[index]);
                int nextCount = count + (i > 0 ? 1 : 0);
                answer += digitOcc(index + 1, nextCount, nextTight, digits);
            }
            dp[index][count][boolToInt(tight)] = answer;
            return answer;
        }

        private int[] getDigitsFrom(String number)
        {
            int[] digits = new int[number.length()];
            int i = 0;
            for (char digit : number.toCharArray())
            {
                digits[i] = digit - '0';
                i++;
            }
            return digits;
        }

        static int boolToInt(boolean b)
        {
            return b ? 1 : 0;
        }

        static void init_dp()
        {
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    for (int k = 0; k < 2; k++)
                    {
                        dp[i][j][k] = -1;
                    }
                }
            }
        }

    }
}



Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define U [1<<17]={}
#define G(a)((c=A[a]+A[P[a]]+C[a])%k?c:0)
typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;}L M(L i){return i?B[i]+M(i^i&-i):0;}L S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1e5;i+=i&-i)B[i]+=x;}L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f])-M(O[a])+G(a)+K(P[a]):abs(M(O[f])-M(O[b]));}main(){for(cin>>n>>k;--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(b=0);n<*Z;n++)if(!n|H[P[a=n]]-n)for(;!b|a;S(a=H[a],O[a]=b++))X[a]=n;for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a&&S(a,O[a]-1));}

Measured memory_bytes: 33488
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	/*
	xxxxaaayyyy
	yyyyYYYYaaa
	aaaaaayyyyY
	*/
	
	int n, k; cin >> n >> k;
	string s; cin >> s;
	
	string t = s, ans = s; reverse(all(t));
	t = s + t;
	rep(i, n + 1){
		string u = t.substr(i, n);
		if(k == 1){
			ans = min(ans, u);
			continue;
		}
		int len = 0;
		for(int j = n - 1; j >= 0 && u[j] == u[n - 1]; j--) len++;
		int len2 = min(n, len << min(k - 1, 13));
		string v = string(len2, u[n - 1]);
		rep(j, n - len2) v += u[n - len - 1 - j];
		
		ans = min(ans, v);
	}
	cout << ans << endl;
	
	return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

priority_queue<int> B[100001];

int main() {
  int n, m;
  cin >> n >> m;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    B[a].push(b);
  }

  ll ans = 0;
  priority_queue<pii> pq;
  for (int i = 1; i <= m; i++) {
    if (!B[i].empty()) {
      pq.push(mp(B[i].top(), i));
      B[i].pop();
    }
    if (pq.empty()) continue;

    pii p = pq.top();
    pq.pop();

    ans += p.F;
    if (!B[p.S].empty()) {
      pq.push(mp(B[p.S].top(), p.S));
      B[p.S].pop();
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 6400
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <cmath>

using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){

    int N, K;
    cin >> N >> K;
    
    int num = 1;
    for(int i = 0; i < N; i++){
        if(num * 2 < num + K){
            num = num * 2;
        }
        else{
            num = num + K;
        }
    }
    cout << num << endl;
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll n, ans=100000000;
  cin>>n;
  vector<ll> v(n);
  rep(i,0,n)
    cin>>v[i];
  rep(last,0,n-1) {
    ll p=0, q=0;
    rep(j,0,last+1) {
      p += v[j];
    }
    rep(j,last+1,n) {
      q += v[j];
    }
    ans = min(ans, abs(p-q));
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
 	int N;
  	cin >> N;
  	if(N%10==0 || N%10==1 || N%10==6 || N%10==8){
    	cout << "pon" << endl;
    }else{
 	if(N%10==3){
    	cout << "bon" << endl;
    }else{
     	cout << "hon" << endl;
    }
    }
}


Measured memory_bytes: 3524
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#define ll long long
#define Mod1(x) (x>=mod?x-mod:x)
#define mod 1000000007
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
int a[maxn],last[maxn];
int f[maxn];
int n;
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	f[0]=1;
	for(int i=1;i<=n;i++){
		if(last[a[i]]&&last[a[i]]!=i-1)f[i]=Mod1(f[i-1]+f[last[a[i]]]);
		else f[i]=f[i-1];
		last[a[i]]=i;
	}
	writeln(f[n]);
	// for(int i=1;i<=n;i++)
	// 	writesp(i),writeln(f[i]);
	return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

#define FILL(ptr, value) FILL_((ptr), sizeof(ptr) / sizeof(value), (value))

template <typename T>
void FILL_(void* ptr, size_t size, T value) {
  std::fill((T*)ptr, (T*)ptr + size, value);
}

inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

int main() {
  std::ios::sync_with_stdio(false);
  char  c;
  cin >> c;
  cout << (('a' <= c && c <= 'z') ? "a" : "A") << endl;
}

Measured memory_bytes: 3572
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10, A = 200, mod = 1e9 + 7;

int ctr[A];

int main() {
	fast_cin();
	int n; string s;
	cin >> n >> s;
	for (auto &i : s) {
		++ctr[i];
	}
	ll ans = 1;
	for (int i = 0; i < A; ++i) {
		ans *= (ctr[i] + 1);
		ans %= mod;
	}
	cout << (ans - 1 + mod) % mod << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

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

		String s=String.valueOf(a)+String.valueOf(b);
		int num=Integer.valueOf(s);
		int check=0;
		for(int i=1;i<=num;i++) {
			if(i*i==num) {
				check=1;
				break;
			}
		}
		System.out.println((check==1)? "Yes":"No");
	}

}

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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

int N, ans = 1;
str blobs;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> N >> blobs;
	FOR(i, 1, N) ans += (blobs[i] != blobs[i - 1]);
	cout << ans;
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <unordered_map>
#define maxn 100005
#define mod 1000000007
using namespace std;
typedef long long LL;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    if(n==m)
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)

using ll = long long;
using ull = unsigned long long;
constexpr ll mod = 1e9 + 7;
using namespace std;

int main() {

	int N; cin >> N;
	vector<int> B(N - 1); rep(i, N - 1)cin >> B[i];
	vector<int> A(N, 0);
	A[0] = B[0];
	for (int i = 1; i < N - 1; i++) {
		A[i] = min(B[i - 1], B[i]);
	}
	A[N - 1] = B[N - 2];

	ll ans = 0;
	rep(i, N) {
		ans += A[i];
	}
	cout << ans;

	return 0;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
using namespace std;
int main()
{
	int A,B,C;
	while( scanf(" %d %d %d",&A,&B,&C) != EOF ){
		int flag = 0;
		for( int i = 1 ; i <= B ; i++ ){
			if( A * i % B == C ){
				flag = 1;
				break;
			}
		}
		if( flag == 1 )
			printf("YES\n");
		else
			printf("NO\n");
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

  int len = S.size();
  int half = (len - 1) / 2;
  string s = S;
  reverse(s.begin(), s.end());

  bool can = true;

  if(S != s){
    can = false;
  }
  else if (S.substr(0, half) != s.substr(len - half, half)){
    can = false;
  }
  else if(S.substr(len - half, half) != s.substr(0, half)){
    can = false;
  }
  
  if(can) cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}


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

int main()
{
	int N,K;
	int ans=1;
	
	cin >> N >> K;
	
	N-=K;
	K--;
	for(;;)
	{
		if(N<=0)break;
		N-=K;
		ans++;
	}
	cout << ans << endl;
	return 0;
}



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


int main(){
    int a[1000010];
    cin>>a[1];
    
    if(a[1]%2==0){
        a[2]=a[1]/2;
    }
    else{
        a[2]=3*a[1]+1;
            }
    int i=2;
    while(a[i]!=a[i-1]&a[i]!=a[i-2]&a[i]!=a[i-3]){
        if(a[i]%2==0){
            a[i+1]=a[i]/2;
            i+=1;
        }
        else{
            a[i+1]=3*a[i]+1;
            i+=1;
        }
    }
    cout<<i<<endl;
    
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>	
#include<vector>
#include<queue>
#include<math.h>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;


int main() {
	int h, w;
	cin >> h >> w;
	int a[500][500];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}
	if (w > 1) {
		int i = 0, j = 0;
		int before_i = 0, before_j = 0;
		int flag = 1;
		int gi = h - 1, gj;
		if (h % 2 == 0) {
			gj = 0;
		}
		else {
			gj = w - 1;
		}
		bool downed = true;
		int ans = 0;
		vector<int>answers;
		while (i != gi || j != gj) {
			before_i = i;
			before_j = j;
			if (j == w - 1 || j == 0) {
				if (downed == false) {
					i++;
					downed = true;
					if (flag == 1) {
						flag = 0;
					}
					else {
						flag = 1;
					}
				}
				else {
					if (flag == 1) {
						j++;
					}
					else {
						j--;
					}
					downed = false;
				}
			}
			else {
				if (flag == 1) {
					j++;
				}
				else {
					j--;
				}
			}
			if (a[before_i][before_j] % 2 == 1) {
				ans++;
				a[before_i][before_j]--;
				a[i][j]++;
				answers.push_back(before_i);
				answers.push_back(before_j);
				answers.push_back(i);
				answers.push_back(j);
			}
		}
		cout << ans << endl;
		int cnt = 0;
		for (int i = 0; i < answers.size(); i++) {
			cnt++;
			cout << answers[i] + 1;
			if (cnt == 4) {
				cout << endl;
				cnt = 0;
			}
			else {
				cout << ' ';
			}
		}
	}
	else {
		vector<int>answer;
		int ans = 0;
		for (int i = 0; i < h-1; i++) {
			if (a[i][0] % 2 == 1) {
				ans++;
				a[i + 1][0]++;
				a[i][0]--;
				answer.push_back(i);
				answer.push_back(0);
				answer.push_back(i + 1);
				answer.push_back(0);
			}
		}
		cout << ans << endl;
		int cnt = 0;
		for (int i = 0; i < answer.size(); i++) {
			cnt++;
			cout << answer[i] + 1;
			if (cnt == 4) {
				cout << endl;
				cnt = 0;
			}
			else {
				cout << ' ';
			}
		}
	}
	return 0;
}

Measured memory_bytes: 5104
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define F first
#define S second
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
const int loose = 0;
const int tight = 1;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n, m;
	cin >> n >> m;
	Array s(n, 0), t(m, 0);
	REP(i, n) cin >> s[i];
	REP(i, m) cin >> t[i];

	Matrix dp(n + 1, Array(m + 1, 0));

	REP(i, n) {
		REP(j, m) {
			(dp[i + 1][j + 1] = ((dp[i][j + 1] + dp[i + 1][j]) % MOD + MOD - dp[i][j]) % MOD) %= MOD;
			if (s[i] == t[j]) (dp[i + 1][j + 1] += dp[i][j] + 1) %= MOD;
		}
	}

	cout << (dp[n][m] + 1) % MOD << endl;

	return 0;
}


Measured memory_bytes: 31616
if (s = gets.chomp).to_i < 100
    puts 0
    exit
end

ary = [3, 5, 7]
x = [[3, 5, 7]]
(s.size - 1).times {x << x[-1].product(ary)}
x.shift
x.map!{|e| e.map!{|f| f.join.to_i}}.flatten!.sort!

s = s.to_i
c = 0
x.each do |y|
    break if y > s
    c += 1 if y.to_s.chars.sort.join =~ /^3+5+7+$/
end

puts c

Measured memory_bytes: 4960
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;

class node {
  public:
  int p, l, r;
  node(int p = -1, int l = -1, int r = -1): p(p), l(l), r(r) {}
};

int main() {
  int n, id, k, c, si, d;
  cin >> n;
  node t[n];
  rep(i, n) {
    cin >> id >> k;
    rep(j, k) {
      cin >> c;
      t[c].p = id;
      if (j == 0) {
        t[id].l = c;
      }
      else {
        t[si].r = c;
      }
      si = c;
    }
  }

  rep(i, n) {
    cout << "node " << i << ": ";
    cout << "parent = " << t[i].p << ", ";
    id = t[i].p;
    d = 0;
    while (id != -1) {
      d++;
      id = t[id].p;
    }
    cout << "depth = " << d << ", ";
    if (t[i].p == -1) cout << "root, ";
    else if (t[i].l == -1) cout << "leaf, ";
    else cout << "internal node, ";
    cout << "[";
    for (int j = 0, id = t[i].l; id != -1; j++, id = t[id].r) {
      if (j) cout << ", ";
      cout << id;
    }
    cout << "]" << endl;
  }




  
  return 0;
}


Measured memory_bytes: 4268
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef pair <int, int> pii;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 1e5 + 5;
const int INF = INT_MAX;

int n, a[N], mn = INF, mx = 0;

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
		mn = min(mn, a[i]);
		mx = max(mx, a[i]);
	}
	if(mn == mx) {
		bool ok1 = 1, ok2 = 1;
		for(int i = 1; i <= n; ++i) {
			if(a[i] != n - 1) ok1 = 0;
			if(a[i] * 2 > n) ok2 = 0;
		}
		if(ok1 || ok2) 
			cout << "Yes\n";
		else 
			cout << "No\n";
	} else if(mn + 1 == mx) {
		int x = 0, y = 0;
		for(int i = 1; i <= n; ++i) {
			if(a[i] == mn) ++x;
			if(a[i] == mx) ++y;
		} 
		if(x + 1 <= mx && mx <= x + y / 2) {
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}	
	} else {
		cout << "No\n";
	}
	return 0;
}
/*
	If you only do what you can do, 
	You will never be more than you are now!
*/

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

int main() {
	int N;
	cin >> N;
	vector<int> L(N);
	for (int& e : L) cin >> e;
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = i+1; j < N; ++j) {
			for (int k = j+1; k < N; ++k) {
				if (L[k] >= L[i]+L[j]) continue;
				if (L[i] >= L[k]+L[j]) continue;
				if (L[j] >= L[k]+L[i]) continue;
				set<int> s = {L[i], L[j], L[k]};
				if (s.size() != 3) continue;
				++ans;
			}
		}
	}
	cout << ans << endl;
}

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

int main()
{
	int N,K,i;
	char s[15];
	char hold,asta = '*';
	cin >> N >> s >> K;
	hold = s[K-1];

	for( i = 0; i < N; i++ )
  {
		if( hold != s[i] )
		{
			cout << asta;
		}else{
			cout << s[i];
		}
  }
	cout << endl;
	return 0;
}


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

const int mod = 2019;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  reverse(s.begin(), s.end());
  int x = 1, tot = 0;
  vector<int> cnt(mod);
  ll ans = 0;
  rep(i, n) {
    cnt[tot]++;
    tot += (s[i] - '0') * x;
    tot %= mod;
    ans += cnt[tot];
    x = x * 10 % mod;
  }

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

Measured memory_bytes: 3684
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;
using pr  = pair<ll, ll>;

const ll MOD = 998244353;

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

	int mx = 0;
	int pre;
	cin >> pre;
	int f = pre;

	for (int i = 1; i < N; ++i)
	{
		int A; cin >> A;
		mx = max(mx, A - pre);
		pre = A;
	}

	mx = max(mx, K - pre + f);

	cout << K - mx << endl;

	return 0;
}

Measured memory_bytes: 256
module module_sort
    use iso_fortran_env
    implicit none

    interface quicksort
        module procedure :: int32_qsort
        module procedure :: int64_qsort
    end interface quicksort
contains

    recursive function int32_qsort(m) result(res)
        integer(int32), intent(in) :: m(:)
        integer(int32) :: res(size(m)) 

        if (size(m) <= 1) then; res = m
        else; res = [int32_qsort( pack(m(2:), m(2:) >= m(1)) ), m(1), int32_qsort( pack(m(2:), m(2:) < m(1)) )]
        end if

    end function int32_qsort

    recursive function int64_qsort(m) result(res)
        integer(int64), intent(in) :: m(:)
        integer(int64) :: res(size(m)) 

        if (size(m) <= 1) then; res = m
        else; res = [int64_qsort( pack(m(2:), m(2:) >= m(1)) ), m(1), int64_qsort( pack(m(2:), m(2:) < m(1)) )]
        end if

    end function int64_qsort

end module module_sort

program main
    use module_sort
    use iso_fortran_env
    implicit none
    integer(int64) :: n
    integer(int64), allocatable :: ai(:)
    integer(int64) :: i, ie
    integer(int64) :: ans

    read *, n
    allocate( ai(n) )
    read *, ai( 1:n )
!    ai = quicksort( ai )
!    print *, int32, int64, int128
!    call qsort( ai )
!    ai(n:1:-1) = ai(1:n)
    ai = intQsort( ai )
    ai(n:1:-1) = ai(1:n)

    if ( mod((n-1), 2) == 0 ) then
        ie = (n-1) / 2
        ans = ai(1) + ai(ie + 1)
    else
        ie = n / 2
        ans = ai(1)
    endif

    do i = 2, ie
        ans = ans + ai(i) * 2
    enddo

    print *, ans

contains

recursive subroutine qsort(a)
  implicit none
  integer(8),intent(inout) :: a(:)
  integer(8)::i,j,toobig,toosmall,pv,n

  n = size(a)
i = 1
j = n
pv = a((i+j)/2)
do
   do
     if (a(i) < pv) then
       i = i+1
     else
       exit
     end if
   end do
   do
     if(a(j) > pv) then
       j = j-1
     else
       exit
     end if
   end do
   if (i>=j) then
     exit
   else
     toobig = a(j)
     toosmall = a(i)
     a(i) = toobig
     a(j) = toosmall
     i = i+1
     j = j-1
   end if
 end do
 if (i > 2) then
   call qsort(a(1:i-1))
 end if
 if (j < n-1) then
   call qsort(a(j+1:n))
 end if
end subroutine qsort

pure recursive function intQsort( a ) result( r )
implicit none
integer(int64), intent(in) :: a(:)
integer(int64) :: r( size(a) )
integer(int64) :: sample(3), len, i,j

len = size( a(:) )
if( len<=1 )then
  r = a
else
  !select pivot
  sample(1:3) = [a(1), a(len/2), a(len)]
  do i = 1,2
    do j = 2,3
      if( sample(i)>sample(j) )then
        len = sample(i) !len is buffer
        sample(i) = sample(j)
        sample(j) = len
      end if
    end do
  end do
  
  r = [ intQsort( pack(a(:), a(:)< sample(2)) ), &
                  pack(a(:), a(:)==sample(2))  , &
        intQsort( pack(a(:), a(:)> sample(2)) ) ]
end if
end function intQsort

end program main

Measured memory_bytes: 11872
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
        }
        boolean ok = true;
        for(int i = 0; i < N; i++){
            if(A[i] % 2 == 0){
                if(A[i] % 3 != 0 && A[i] % 5 != 0) ok = false;
            }
        }
        if(ok){
            System.out.println("APPROVED");
        }else{
            System.out.println("DENIED");
        }
    }
}

Measured memory_bytes: 23892
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll a, b, c, x, y;

    cin >> a >> b >> c;

    x = c-a-b;
    y = pow(x,2);

    //if(4*a*b<y && x>0) cout << "Yes" << endl;
    if(x>0 && x*x>4*a*b) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256