akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>

using namespace std;

int main()
{
    queue<long long> Q;
    int k;
    long long num = 0;
    long long ans;
    cin >> k;
    
    if (k <= 9){
        ans = k;
    }
    else {
        for (int i = 1;i <= 9;i++){
            Q.push(i);
            num++;
        }
        while (num < k){
            if (Q.front()%10 == 0){
                ans = Q.front()*10;
                if (num < k-1){
                    Q.push(ans);
                    Q.push(ans+1);
                    ans = ans+1;
                    num += 2;
                    Q.pop();
                }
                else {
                    break;
                }
            }
            else if (Q.front()%10 == 9){
                ans = Q.front()*10+8;
                if (num < k-1){
                    Q.push(ans);
                    Q.push(ans+1);
                    num += 2;
                    ans = ans+1;
                    Q.pop();
                }
                else {
                    break;
                }
            }
            else {
                ans = Q.front()*10+Q.front()%10-1;
                long long p = ans;
                for (int i = 0;i < 3 && num < k;i++){
                    ans = p+i;
                    Q.push(ans);
                    num++;
                }
                Q.pop();
            }
        }
    }
    cout << ans << endl;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

ll dp[222222][2];
ll add[222222];
vector<ll> v;
ll cou, n, ans;
string str;

void mod_add(ll &a, ll b){
	a += b;
	a %= MOD;
}

bool ti_ike(int now){
	string keymoon = str;
	REP(i, n){
		if((i / now) % 2){
			if(str[(i%now)] == '1')keymoon[i] = '0';
			else keymoon[i] = '1';
		}
		else {
			keymoon[i] = str[(i%now)];
		}
	}

	return keymoon <= str;
}

void seica() {
	dp[0][0] = 1;
	REP(i, n){
		if(str[i] == '1'){
			mod_add(dp[i+1][1], dp[i][0]);
			mod_add(dp[i+1][0], dp[i][0]);
		}
		else{
			mod_add(dp[i+1][0], dp[i][0]);
		}
		if(i != 0 && n % i == 0 && (n / i) % 2 == 1){
			v.PB(i);
			mod_add(add[i], dp[i][1]);
			if(ti_ike(i))mod_add(add[i], 1);
		}
		mod_add(dp[i+1][1], dp[i][1] * 2);
	}

	REP(i, v.size()){
		mod_add(cou, add[v[i]]);
		mod_add(ans, add[v[i]] * 2 * v[i]);
		REP(j, v.size()){
			if(i == j)continue;
			if(v[j] % v[i] == 0){
				add[v[j]] = (add[v[j]] + MOD - add[v[i]]) % MOD;
			}
		}
	}
}

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

	cin >> n;
	cin >> str;

	seica();

	ll sum = 0;
	REP(i, str.size()){
		sum = (sum * 2) % MOD;
		if(str[i] == '1'){
			sum = (sum + 1) % MOD;
		}
	}

	sum = (sum + 1) % MOD;
	sum = (sum - cou + MOD) % MOD;
	ans = (ans + sum * (2 * n) % MOD) % MOD;
	cout << ans << endl;

	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<long long int> A(N);
  long long int sum=0;
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    sum+=A.at(i);
  } 
  long long int tmp=0;
  long long int min =sum;
  for(int i=0;i<N-1;i++){
    tmp+=A.at(i);
    long long int c=sum-tmp;
    long long int B =c-tmp;
    if(B<0){
      B*=-1;
    }
    if(B<=min){
      min=B;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 1792
N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

items = sorted(A)[::-1][:M]
border = sum(A) * (1 / (4 * M))
is_selectable = True
for item in items:
    if item < border:
        is_selectable = False
        break

if is_selectable:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int a[508][508];
int n,m,i,j;
char ch; 
int main()
{
	scanf("%d %d\n",&n,&m);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			ch=getchar();
			if(ch=='#')a[i][j]=2; 
		}
		ch=getchar();
	}
	for(i=1;i<=m;i++)
	  printf(".");
	printf("\n");
	for(i=2;i<n;i++)
	{
	  for(j=1;j<=m;j++)
	  {
	  	if(j%2==1||a[i][j])printf("#");
	  	else printf(".");
	  }
	  printf("\n");
	}
	for(i=1;i<=m;i++)
	  printf("#");
	printf("\n");
	printf("\n");
	for(i=1;i<=m;i++)
	  printf("#");
	printf("\n");
	for(i=2;i<n;i++)
	{
	  for(j=1;j<=m;j++)
	  {
	  	if(j%2==0||a[i][j])printf("#");
	  	else printf(".");
	  }
	  printf("\n");
	}
	for(i=1;i<=m;i++)
	  printf(".");
	printf("\n");
	return 0;
} 
/*
5 5
.....
.#.#.
.....
.#.#.
.....
*/

Measured memory_bytes: 1664
#include <bits/stdc++.h>
constexpr int MOD = 1000000007;
constexpr int DEBUG = 0;
using ll = long long;
using namespace std;

ll f[100010];
void init() {
  f[0] = 1;
  for (int i = 1; i < 100010; i++)
    f[i] = (f[i - 1] * i) % MOD;
}
ll inv(ll x) {
  ll res = 1;
  ll k = MOD - 2;
  ll y = x;
  while (k) {
    if (k & 1) res = (res * y) % MOD;
    y = (y * y) % MOD;
    k /= 2;
  }
  return res;
}
ll C(int n, int k) {
  ll a = f[n];
  ll b = f[n-k];
  ll c = f[k];
  ll bc = (b * c) % MOD;
  return (a * inv(bc)) % MOD;
}
int main() {
  init();
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  
  sort(a.begin(), a.end());
  ll smin = 0, smax = 0;
  for (int i = 0; i < n - k + 1; i++) {
    smin += a[i] * C(n - i - 1, k - 1);
    smin %= MOD;
    if (DEBUG >= 1)
	    cout << a[i] << " * " << C(n - i - 1, k - 1) << " " << smin << endl;
  }
  for (int i = k - 1; i < n; i++) {
    smax += a[i] * C(i, k - 1);
    smax %= MOD;
    if (DEBUG >= 1)
	    cout << a[i] << " * " << C(i, k - 1) << " " << smax << endl;
  }
  cout << (smax - smin + MOD) % MOD << endl;
  return 0;
}

Measured memory_bytes: 1792
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std; 

inline void solve(){ 
    int  r, c ; 
    cin >> r >> c ; 
    vector <vector <int> > g(r+5,vector <int> (c+5)); 
    for (int i=1;i<=r;i++) { 
    	for (int j=1;j<=c;j++) { 
    		cin >> g[i][j] ; 
    		g[i][j] = ( (g[i][j] & 1)? 1 : 0 ) ; 
    	} 
    } 
    vector <pair<pii,pii>> res; 
    pair <pii,pii> p;
    for (int i=1;i<=r;i++){
    	for (int j=1;j<c;j++){
    		if (g[i][j]&1) {
    			g[i][j+1]++;
    			p.ff.ff=i; p.ff.ss=j;
    			p.ss.ff=i; p.ss.ss=j+1;
    			res.pb(p);
    		}
    	}
    }
    for (int i=1;i<r;i++){
    	if (g[i][c]&1){
    		g[i+1][c]++;
    		p.ff.ff=i; p.ff.ss=c;
    		p.ss.ff=i+1; p.ss.ss=c;
    		res.pb(p);
    	}
    }
    cout << sz(res) << endl;
    for (auto &it: res) {
    	printf("%lld %lld %lld %lld\n",it.ff.ff,it.ff.ss,it.ss.ff,it.ss.ss);
    }
} 

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}
/*
2 3
1 2 3
0 1 1


3 2
1 0
2 1
1 0

1 5
9 9 9 9 9

*/

Measured memory_bytes: 9468
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

bool prime(int n)
{
    int cnt=0;
    for(int i=1; i*i<=n; i++){
        if(i!=1 && n%i==0) cnt++;
    }
    if(cnt==0) return 1;
    else return 0;
}

int main()
{
    int N;
    cin >> N;
    vector<ll> v(N);
    rep(i, N){
        cin >> v[i];
    }
    ll ans=0;

    rep(i, N){
        int n = v[i];
        ans += prime(n);
    }

    cout << ans << endl;
}


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

int main(void) {
	int table[1001];
	int x;
	scanf("%d", &x);
	
	memset(table, 0, sizeof(int) * 1001);
	table[1] = 1;
	for (int i = 2; i <= 1000; i++) {
		if (table[i] == 0) {
			for (int j = i * i; j <= 1000; j *= i) {
				table[j] = 1;
			}
		}
	}

	for (int i = x; i >= 1; i--) {
		if (table[i] == 1) {
			printf("%d\n", i);
			return 0;
		}
	}

	return 0;
}


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


#define int         long long
#define fast        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
int mod = 1000000007;
int mod2 = 998244353;
/*
//int arr[100000]={};
int binarysearch(int a[],int n,int s)
{
    int l=0,h=n-1,mid,ans = -1;
    while(l<=h)
    {
        mid = l + (h-l)/2;
        if(a[mid]<=s)
        {
            ans = mid;
            l = mid + 1;
        }
        else h = mid - 1;
    }
    //ans = max(ans,k);
    return ans;
}
/*
bool isprime(int n)
{
    int x = sqrt(n),f=0;
    for(int i=2;i<=x;i++)
    {
        if(n%i==0)
        {
            f=1;
            break;
        }
    }
    if(f)
    return false;
    else return true;
}

int find1(int n)
{
    int mn = 9;
    int x = n,s;
    while(x>=1)
    {
        s = x%10;
        mn = min(mn,s);
        x /= 10;
    }
    return mn;
}

int find2(int n)
{
    int mn = 0;
    int x = n,s;
    while(x>=1)
    {
        s = x%10;
        mn = max(mn,s);
        x /= 10;
    }
    return mn;
}
int recurs(int n,int k)
{
    if(k==1)
        return n;
    if(find1(n)==0)
        return n;
    return recurs(n + (find1(n)*find2(n)) , --k);
}*/
signed main()
{
    fast;
    int t = 1;

   // cin>>t;

    while(t--)
    {
        int n=0,m=0,k=0,r=0,f=0,cnt=0,x=0,l=0,y=0,z=0,mx=0,sum=0,mini=INT_MAX,mn=INT_MAX;
        string s,str;
        cin>>n;
        if(n%10==3)
            s = "bon";
        else if(n%10==0||n%10==1||n%10==6||n%10==8)
            s = "pon";
            else s = "hon";
            cout<<s;
    }
	cerr << "\nTime elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
}


Measured memory_bytes: 3840
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
d=defaultdict(int)
x=[i+1+a[i] for i in range(n)]
y=[i+1-a[i] for i in range(n)]
for i in range(n):
    d[i+1-a[i]]+=1
ans=0
for i in range(n):
    ans+=d[i+1+a[i]]
print(sum(d[i+1+a[i]] for i in range(n)))

Measured memory_bytes: 142796
#include <iostream>
#include <stdio.h>
#include <string>
#include <complex>
using namespace std;
long n;
long ap[2][101], dp[2][101];
int main(void) {
  cin >> n;
  for(int i = 0; i < 2; i++) {
    for(int j = 0; j < n; j++) {
      cin >> ap[i][j];
    }
  }
  dp[0][0] = ap[0][0];
  dp[1][0] = ap[0][0] + ap[1][0];
  for(int i = 1; i < n; i++) {
    dp[0][i] = ap[0][i] + dp[0][i -1];
  }
  for(int i = 1; i < n; i++) {
    dp[1][i] += max(dp[1][i - 1], dp[0][i]) + ap[1][i];
  }
  cout << dp[1][n-1] << endl;
  return 0;
}

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

int main(){
    string S;
    cin >> S;
    int N;
    N=S.size();
    long long ans=0;

    for(int bit=0;bit<(1<<N-1);bit++){
        long long sum=0;//部分集合ごとに合計を初期化
        long long tmp=S[0]-'0';
        for(int i=0;i<N-1;i++){
            if(bit&(1<<i)){
                sum+=tmp;
                tmp=0;//+が挿入され桁が変わらないため0にする
            }
            tmp = tmp*10+S[i+1]-'0'; //bitが立っていなければ10倍
        }
        sum+=tmp;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
        ans+=sum;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/// In the name of ALLAH
/// I'm THEOVE46
#include<bits/stdc++.h>
using namespace std;

#define gap             " "
#define nn              "\n"
#define pi              2*acos(0.0)
#define db              double
#define ft              float
#define ll              long long int
#define ull             unsigned long long int
#define pf              printf
#define sf              scanf
#define ff              first
#define ss              second
#define sfi(n)          sf("%d",&n)
#define sfi2(n, m)      sf("%d%d",&n,&m)
#define sfl(n)          sf("%lld",&n)
#define sfl2(n, m)      sf("%lld%lld",&n,&m)
#define sff(n)          sf("%f",&n)
#define sfd(n)          sf("%lf",&n)
#define pfi(n)          pf("%d",n)
#define pfl(n)          pf("%lld",n)
#define pff(n)          pf("%f",f)
#define pfd(n)          pf("%lf",f)
#define bfi             cin.ignore()
#define bfs             cin.get()
#define bfc             getchar()
#define gl(s)           getline(cin, s)
#define loop(a,n)       for(i=a; i<n; i++)
#define mloop(i,a,n)    for(i=a; i<n; i++)
#define rloop(i,a,n)    for(i=a; i>=n; i--)
#define tloop(test)     for(ll tl=1; tl<=test; tl++)
#define case1(z)        cout<<"Case "<<z<<": "
#define case2(z)        printf("Case %d: ",z)
#define vi              vector<int>
#define vl              vector<ll>
#define vld(vc,rw)      vector<vector<ll> >vc(rw)
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define pis             pair<int,string>
#define psi             pair<string,int>
#define mls             map <ll,string>
#define msl             map <string,ll>
#define mll             map <ll,ll>
#define mp              make_pair
#define pb              push_back
#define itr             vector<int> :: iterator
#define atl(i, v)       for(auto i: v)
#define sz(s)           s.size()
#define sl(s)           s.length()
#define Sort(s)         sort(s.begin(), s.end())
#define SortR(s)        sort(s.rbegin(), s.rend())
#define all(x)          x.begin(),x.end()
#define rall(x)         x.end(), x.begin()
#define MEM(ar,val)     memset(ar, (val), sizeof(ar))
#define IN(A,B,C)       assert(B<=A && A<=C)
#define MOD             1000000007
#define EPS             1e-9
#define Max             1e9
#define Min             -1e9
#define bug1            "**1**"
#define bug2            "****2****"
#define artri(b,h)      0.5*b*h
#define artrap(b1,b2,h) (b1+b2)/2*h
#define arcrl(r)        pi*r*r
#define vlsyl(r,h)      pi*r*r*h
#define vlcone(r,h)     pi*r*r*(h/3)
#define vlsph(r)        (4/3)*pi*r*r*r
#define flush           fflush(stdout)
#define pcn(dg,val)     fixed << setprecision(dg) << val
#define ggl             pf("Case #%lld: ", tl)
#define FastIO          ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define showsort(n, a)  for(int i=0; i<n; i++) cout << a[i] << gap; cout << endl;

///THEOVE46

int main()
{
    //FastIO;
    ll n, i, x=0, a;
    cin >> n;
    loop(0, n)
    {
        cin >> a;
        if(a&1 && i%2==0) x++;
    }
    cout << x << endl;
    return 0;
}

///   check for integer overflow, array bounds
///   check for n=1
///   - - - The Ove 46



Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
const long long mod = 1e9+7;

int main() {
    char s[4];
    for (int i = 0; i < 4; i++)
    {
        cin >> s[i];
    }
    for (int i = 1; i < 4; i++)
    {
        if (s[i-1] == s[i])
        {
            cout << "Bad";
            return 0;
        }
    }
    cout << "Good";
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int,P>PP;

signed main() {
	int k, x; cin >> k >> x;
	if (k * 500 >= x)puts("Yes"); else puts("No");
}

Measured memory_bytes: 256
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		int D = sc.nextInt();
		int N = sc.nextInt();

		int q=(N-1)/99;

		int base=0;
		if(D==0) {
			base=1;
		}else if(D==1) {
			base=100;
		}else {
			base=100*100;
		}

		int ans=(N+q)*base;
		System.out.println(ans);
	}

	//以下テンプレート

	public static int[] extgcd(int a, int b) {

		int x0 = 1;
		int x1 = 0;

		int y0 = 0;
		int y1 = 1;

		while (b != 0) {
			int q = a / b;
			int r = a % b;

			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;

			a = b;
			b = r;

			x0 = x1;
			x1 = x2;

			y0 = y1;
			y1 = y2;
		}

		return new int[] { a, x0, y0 };

	}

	static int gcd(int a, int b) {

		if (b == 0)
			return a;

		if (a < b) {
			int t = a;
			a = b;
			b = t;
		}

		return gcd(b, a % b);

	}

	static int lcm(int a, int b) {
		return a * b / gcd(a, b);
	}

	static void swap(int[] a) {
		int t;

		t = a[0];
		a[0] = a[1];
		a[1] = t;

		return;
	}

	static <T> void output(List<T> list) {

		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i));

			if (i != list.size() - 1) {
				System.out.print(" ");
			} else {
				nl();
			}
		}

	}

	static void output(String[][] str) {

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				print(str[i][j]);
			}

			nl();
		}

	}

	static void output(boolean flg, String Yes, String No) {

		if (flg) {
			pln(Yes);
		} else {
			pln(No);
		}

	}

	static void output(String[][] str, int digit) {

		String dig = "%" + String.valueOf(digit) + "s";

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				System.out.printf(dig, str[i][j]);
			}
			nl();
		}

	}

	static void pln(String str) {
		System.out.println(str);
	}

	static void pln(int x) {
		System.out.println(x);
	}

	static void print(String str) {
		System.out.print(str);
	}

	static void print(int x) {
		System.out.print(x);
	}

	static void print(String str, int times) {
		for (int i = 0; i < times; i++) {
			print(str);
		}
	}

	static void print(int x, int times) {
		for (int i = 0; i < times; i++) {
			print(x);
		}
	}

	static void nl() {
		System.out.println();
	}

}


Measured memory_bytes: 21716
N,M=map(int,input().split())
X=list(map(int,input().split()))
if N>=M:
    print(0)
else:
    X.sort()
    Y = []
    for i in range(M - 1):
        Y.append(X[i + 1] - X[i])
    Y.sort()
    print(sum(Y[:M - N]))


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
    int n;cin>>n;
    V a(n);rep(i,n)cin>>a[i];
    sort(RALL(a));
    //rep(i,n)printf("%d ",a[i]);
    ll max=0;ll prev=0;
    int flag=0;
    for(int i=0;i<n-1;){
        if(prev!=0)break;
        int cnt=0;
        while(a[i]==a[i+1]){
            i++;
            cnt++;
        }if(flag==0){
            if(cnt>=3){max=a[i];prev=max;break;}
            else if(cnt>=1){
                flag=1;
                max=a[i];
            }
        }else{
            if(cnt>=1)prev=a[i];
        }
        i++;
    }
    cout<<prev*max<<endl;
}


Measured memory_bytes: 640
'use strict'
function Main(input) {
  // inputの文字列をとってきたもの
  let text = input.trim().split("");
  // ユニークになるように再セットしたもの
  let textSet = new Set(text);
  // 回答用の変数
  let ans = "";
  // 全てがユニークなら等しくなるので
  ans = +text.length == +textSet.size ? "yes" : "no";
  
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
    int X, A, B;
    cin >> X >> A >> B;
    int answer = (A * -1) + B;
    if (answer <= 0) {
        cout << "delicious" << endl;
    } else if (answer <= X) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

vector<string> hoge = { "a", "b", "c", "d", "e", "f", "g","h", "i", "j", "k", "l", "m", "n", "o", "p","q", "r", "s", "t", "u", "v", "w", "x","y", "z" };

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

	vector<string> saitan(26);

	REP(i, 26) {
		saitan[i]= hoge[i];
	}

	for (int i = S.size() - 1; i >= 0; --i) {
		int moji = S[i] - 'a';

		int min = 99999999;
		int mojimin = -1;
		REP(j, 26) {
			if (saitan[j].size() < min) {
				min = saitan[j].size();
				mojimin = j;
			}
		}

		saitan[moji] = hoge[moji] + saitan[mojimin];
	}

	int min = 99999999;
	int mojimin = -1;
	REP(j, 26) {
		if (saitan[j].size() < min) {
			min = saitan[j].size();
			mojimin = j;
		}
	}

	cout << saitan[mojimin] << endl;
}

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

int main() {

	int N, M;

	scanf("%d %d", &N, &M);

	int p = 1;

	p <<= M;

	int ac = N - M;

	int t = M * 1900 + ac * 100;

	printf("%d\n", t * p);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
ll a[100000];
ll dom[100001];

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

int main(){
  ll a,b;
  cin>>a>>b;
  ll gc=gcd(a,b);
  ll cnt=1;
  for(ll i=2; i*i<=gc; i++){
    if(gc%i==0){
      while(gc%i==0) gc/=i;
      cnt++;
    }
  }
  if(gc!=1) cnt++;
  cout<<cnt;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		int r = a- b*2;
		System.out.println(r<=0?0:r);
	}
}

Measured memory_bytes: 23508
#include <stdio.h>
int n, k, d, e, x;
int a[100];
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < k; i++) {
		scanf("%d", &d);
		for (int j = 0; j < d; j++) {
			scanf("%d", &e);
			a[e - 1]++;
		}
	}
	for (int i = 0; i < n; i++) {
		if (!a[i])x++;
	}
	printf("%d\n", x);
}

Measured memory_bytes: 1732
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

S = str(input())
count = {}
for i in range(len(S)):
    if S[i] in count.keys():
        count[S[i]] += 1
    else:
        count[S[i]] = 1

flag = True
for key in count.keys():
    if count[key] == 2:
        pass
    else:
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 6856
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author ilyakor
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    OutputWriter out = new OutputWriter(outputStream);
    TaskA solver = new TaskA();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskA {

    public void solve(int testNumber, InputReader in, OutputWriter out) {
      int n = in.nextInt();
      int[] a = new int[n];
      for (int i = 0; i < n; ++i) {
        a[i] = in.nextInt();
      }
      int res = 0;
      for (int i = 1; i < n; ++i) {
        if (a[i] == a[i - 1] && a[i - 1] != -1) {
          a[i] = -1;
          ++res;
        }
      }
      out.printLine(res);
    }

  }

  static class InputReader {

    private InputStream stream;
    private byte[] buffer = new byte[10000];
    private int cur;
    private int count;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public static boolean isSpace(int c) {
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public int read() {
      if (count == -1) {
        throw new InputMismatchException();
      }
      try {
        if (cur >= count) {
          cur = 0;
          count = stream.read(buffer);
          if (count <= 0) {
            return -1;
          }
        }
      } catch (IOException e) {
        throw new InputMismatchException();
      }
      return buffer[cur++];
    }

    public int readSkipSpace() {
      int c;
      do {
        c = read();
      } while (isSpace(c));
      return c;
    }

    public int nextInt() {
      int sgn = 1;
      int c = readSkipSpace();
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9') {
          throw new InputMismatchException();
        }
        res = res * 10 + c - '0';
        c = read();
      } while (!isSpace(c));
      res *= sgn;
      return res;
    }

  }

  static class OutputWriter {

    private final PrintWriter writer;

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

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

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

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

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

  }
}



Measured memory_bytes: 22740
l, r = map(int,input().split())
min_val = float('inf')
for i in range(l,r):
  for j in range(l+1, r+1):
    tmp = i*j%2019
    if min_val>tmp:
      min_val = tmp
    if min_val == 0:
      break
  if min_val == 0:
    break
print(min_val)

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var N int64
	fmt.Scan(&N)

	var ans int64
	if N == 1 {
		fmt.Println(0)
		return
	}

	// 2以上
	for i := int64(1); ; i++ {
		if N/i <= i {
			break
		}
		if N%i == 0 {
			if N/((N/i)-1) == N%(N/i-1) {
				ans += N/i - 1
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <bits/stdc++.h>
 
#define UNKO 1000000007
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
 

const int MAX = 5100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    // 前処理
    COMinit();
  
    ll X,Y;
  cin >> X >> Y;
  
  // たどり着けない条件をはじく。
  if( ((2*Y-X) <0 ) ||
      ((2*X-Y) <0 ) ||
      ((2*Y-X)%3 != 0 ) ||
      ((2*X-Y)%3 != 0 )  ){
    cout << 0;
    return 0;
  }
 
  ll a, b;
  a = (2*Y - X)/3;
  b = (2*X - Y)/3;
//  cout << "a="<<a<<",b="<<b<<endl;
  
  ll N;
  N = a+b;

  
  
    // 計算例
    cout << COM(N, a) << endl;
}

Measured memory_bytes: 119808
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    ll n;
    cin>>n;
    ll ans=n/2;
    if(n%2)
        ans++;
    cout<<ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
#define ll getchar();getchar();return 0;
	using namespace std;
	int a[90];
	signed main() {
		int n;
		cin >> n;
		a[0] = 2;
		a[1] = 1;
		for (int i = 2; i <= n; i++) {
			a[i] = a[i - 1] + a[i - 2];
		}
		cout << a[n] << endl;
		ll
	}

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

using namespace std;
int arr[10];

int main()
{
	int n,m,s,c;
	cin>>n>>m;
	while(m--){
		cin>>s>>c;
		if((arr[s]>0 and arr[s]!=c) or (s==1 and c==0 and n>1)){
			cout<<-1;
			return 0;
		}
		arr[s]=c;
	}
	if(!arr[1] and n>1) arr[1]++;
	for(int i=1;i<=n;i++) cout<<arr[i];
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <numeric>
#include <vector>
#include <math.h>

using namespace std;


int main()
{
	int n;
	double k;

	cin >> n >> k;

	double sum = 0;
	for (int i = 1; i <= n; i++)
	{
		int p = (int)(-floor(log2(i / k )));
		if (p < 0)
		{
			p = 0;
		}
		sum += pow(0.5, p);
	}
	sum /= n;

	printf("%0.12lf\n", sum);

	return 0;
}

Measured memory_bytes: 384
N = int(input())
W_list = [int(e) for e in input().split()]
right=0
min_diff=1000000

for i in range(N):
  right=right+W_list.pop(-1)
  diff=abs(right-sum(W_list))
  if diff<min_diff:
    min_diff=diff
    
print(min_diff)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    long long int N=1000000007;
    // Here your code !
    long long int monkey,clab;
    long long int kaijo[500000];
    kaijo[0]=1;
    for(int i=1;i<500000;i++){
        kaijo[i]=(kaijo[i-1]*i)%N;
    }
    cin>>monkey>>clab;
    
    if(monkey-clab>1||monkey-clab<-1){
        cout<<0;
    }
    if(monkey-clab==1||monkey-clab==-1){
        cout<<(kaijo[monkey]*kaijo[clab])%N;
    }
    if(monkey==clab){
        cout<<(((kaijo[monkey]*kaijo[monkey])%N)*2)%N;
    }
}


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


 
signed main() {
    int N;
    cin >> N;
    
    int ma=1, sum=0;
    for(;;ma++){
        sum+=ma;
//        cerr << ma;
        if(sum>=N)break;
    }
    cerr << ma << endl;
    
    while(N>0 && ma>=0){
        if(N>=ma){ N-=ma; cout << ma << " ";}
        ma--;
    }
    
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int N, A, B, C, D;
std::string S;

bool dfs(int x, int y){
   if(x==C && y==D) return true;

   if(x+1<N && x+1!=y && S[x+1]=='.'){
      if(dfs(x+1,y)) return true;
   }
   if(x+2<N && x+2!=y && S[x+2]=='.'){
      if(dfs(x+2,y)) return true;
   }
   if(y+1<N && y+1!=x && S[y+1]=='.'){
      if(dfs(x,y+1)) return true;
   }
   if(y+2<N && y+2!=x && S[y+2]=='.'){
      if(dfs(x,y+2)) return true;
   }

   return false;
}

bool dfs2(int x, int y){
   if(x>y) return true;

   if(x+1<N && x+1!=y && S[x+1]=='.'){
      if(dfs2(x+1,y)) return true;
   }
   if(x+2<N && x+2!=y && S[x+2]=='.'){
      if(dfs2(x+2,y)) return true;
   }
   return false;
}

int main(){
   std::cin >> N >> A >> B >> C >> D;
   std::cin >> S;
   --A; --B; --C; --D;

   for(int i=A+1; i<std::max(C,D)-1; ++i){
      if(S[i]=='#' && S[i+1]=='#'){
	 std::cout << "No" << std::endl;
	 return 0;
      }
   }
   if(C<D){
      std::cout << "Yes" << std::endl;
      return 0;
   }
   for(int i=B; i<=D; ++i){
      if(S[i]=='#') continue;
      if(i>0 && S[i-1]=='.'){
	 if(dfs2(i-1,i)){
	    std::cout << "Yes" << std::endl;
	    return 0;
	 }
      }
      if(i>1 && S[i-1]=='#' && S[i-2]=='.'){
	 if(dfs2(i-2,i)){
	    std::cout << "Yes" << std::endl;
	    return 0;
	 }
      }
   }

   std::cout << "No" << std::endl;
   return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <numeric>
#include <set>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  string left = s.substr(0, n);
  string right = s.substr(n, n+n);
  reverse(begin(right), end(right));
  vector<vector<int>> dp(n+1, vector<int>(n+1));
  int64_t res = 0;
  for (int mask = 0; mask < (1<<n); ++mask) {
    // clear
    for (auto &x : dp) fill(begin(x), end(x), 0);

    string a, b;
    for (int i = 0; i < n; ++i) ((mask >> i & 1) ? a : b) += left[i];
    dp[0][0] = 1;
    for (int i = 0; i <= a.size(); ++i) for (int j = 0; j <= b.size(); ++j) {
      if (i < a.size() && a[i] == right[i+j]) dp[i+1][j] += dp[i][j];
      if (j < b.size() && b[j] == right[i+j]) dp[i][j+1] += dp[i][j];
    }
    res += dp[a.size()][b.size()];
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long N;
int main(){
	cin>>N;
	long long total=0;
	for(long long i=1; i<=N; i++){
		if(i%3!=0&&i%5!=0){
			total+=i;
		}
	}
	cout<<total<<'\n';
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if((b+c)-a<0){
		printf("0\n");
	}
	else{
		printf("%d\n",(b+c)-a);
	}
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    var N = sc.nextInt

    val ans = new StringBuilder()
    while (N != 0) {
      if (N % 2 != 0) {
        N -= 1
        ans.append("1")
      } else {
        ans.append("0")
      }
      N /= -2
    }
    if (ans.isEmpty) "0"
    else ans.reverse.toString
  }
}


Measured memory_bytes: 27340
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i,a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
int n, m;
int q;
ll ans=0;
vector<int> v(10);
vector<int> a(50);
vector<int> b(50);
vector<int> c(50);
vector<int> d(50);
void func(int i,int x){
    for(int j=x;j<=m;j++){
        v[i]=j;
        if(i==n-1){
            ll tmp=0;
            for(int k=0;k!=q;k++){
                if(v[b[k]-1]-v[a[k]-1]==c[k]){
                    tmp+=d[k];
                }
            }
            ans=max(tmp,ans);
        }
        else{
            func(i + 1, j);
        }
    }
    return;
}

int main()
{
    cin >> n >> m >> q;
    REP(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    func(0,1);
    cout << ans << endl;
}

Measured memory_bytes: 3684
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
    unsigned int key;
    struct node *next;
    struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
    NodePointer n;
    for(n = nil->next; n != nil && n->key != key; n = n->next);
    return n;
}

void init(){
    nil = malloc(sizeof(struct node));
    nil->next = nil;
    nil->prev = nil;
}

void printList(){
    NodePointer cur;
    int isf = 1;
    for(cur = nil->next;cur != nil; cur = cur->next){
        if(isf == 0) printf(" ");
        printf("%d", cur->key);
        isf = 0;
    }
    printf("\n");
}

void deleteNode(NodePointer t){
    NodePointer delnode;
    delnode = t;
    delnode->prev->next = delnode->next;
    delnode->next->prev = delnode->prev;
    free(delnode);
}

void deleteFirst(){
    NodePointer t = nil->next;
    if(t == nil) return;
    deleteNode(t);
}

void deleteLast(){
    NodePointer t = nil->prev;
    if(t == nil) return;
    deleteNode(t);
}

void delete(int key){
    NodePointer t;
    t = listSearch(key);
    if(t == nil) return;
    deleteNode(t);
}

void insert(int key){
    NodePointer newnode;
    newnode = malloc(sizeof(struct node));
    newnode->key = key;
    newnode->next = nil->next;
    nil->next->prev = newnode;
    nil->next = newnode;
    newnode->prev = nil;
}

int main(){
    int key,n,i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d",&n);
    init();
    for(i = 0; i < n; i++){
        scanf("%s%d",com,&key);
        if(com[0] == 'i'){
            insert(key);
            np++;
            size++;
        }
        else if(com[0] == 'd'){
            if(strlen(com) > 6){
                if(com[6] == 'F') deleteFirst();
                else if(com[6] == 'L') deleteLast();
            }
            else{
                delete(key);
                nd++;
            }
            size--;
        }
    }

    printList();
    return 0;
}




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

int main() {
int flag,N,i,c,n;
  cin >> N;
n = N - 1;
int A[n];
  for(i = 0; i < N; i++)
  {
    cin >> n;
    A[i] = n;
  }
  
  flag = 0;
  c = 0;
  do
  {
    for(i = 0; i < N; i++)
    {
      n = A[i] % 2;
        if(n != 0){
          flag = 1;
          break;
        }
      A[i] = A[i] / 2.0;
    }
    if(flag == 0) c++;
    
  }
  while (flag == 0);
  cout << c << endl;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
#define INF 1000000000000000000
signed main(){
  init_io();
  ll v,e,d[110][110];
  cin >> v >> e;
  for(int i=0;i<v;i++){
    for(int j=0;j<v;j++){
      if(i==j) d[i][j] = 0;
      else d[i][j] = INF;
    }
  }
  ll s,t,di;
  for(int i=0;i<e;i++){
    cin >> s >> t >> di;
    d[s][t] = di;
  }
  for(int k=0;k<v;k++){
    for(int i=0;i<v;i++){
      for(int j=0;j<v;j++){
        if(d[i][k]==INF||d[k][j]==INF) continue;
        d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  for(int k=0;k<v;k++){
    for(int i=0;i<v;i++){
      for(int j=0;j<v;j++){
        if(d[i][k]==INF||d[k][j]==INF) continue;
        if(d[i][j]>d[i][k]+d[k][j]){
          cout <<"NEGATIVE CYCLE"<<endl;
          return 0;
        }
      }
    }
  }
  for(int i=0;i<v;i++){
    for(int j=0;j<v;j++){
      if(d[i][j] == INF) cout <<"INF";
      else cout << d[i][j];
      if(j==v-1) cout << endl;
      else cout << " ";
    }
  }
}



Measured memory_bytes: 3336
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String nString = scanner.next();
        int n = Integer.parseInt(nString);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int answer = 0;

        for (int i = 1 ; i <= n ; i++) {
            int digitSum = getDigitSum(String.valueOf(i));
            if (a <= digitSum && digitSum <= b) {
                answer += i;
            }
        }
        System.out.println(answer);
    }

    private static int getDigitSum(String input) {
        int result = 0;
        for (int i = 0; i < input.length(); i++) {
            result += Character.getNumericValue(input.charAt(i));
        }
        return result;
    }
}

Measured memory_bytes: 21844
import sys
import math
import functools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

c = ns()

print(chr(ord(c)+1))

Measured memory_bytes: 3828
w, h, n = gets.split.map(&:to_i)

x1 = 0; y1 = 0
x2 = w; y2 = h

n.times do
  x, y, a = gets.split.map(&:to_i)
  case a
  when 1
    x1 = x if x1 < x
  when 2
    x2 = x if x2 > x
  when 3
    y1 = y if y1 < y
  else
    y2 = y if y2 > y
  end
end

w = x2 - x1
w = 0 if w < 0
h = y2 - y1
h = 0 if h < 0
puts w * h


Measured memory_bytes: 1788
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>

#define LL long long int
#define pb push_back
#define mp make_pair
#define MAX 100005
#define MOD 1000000007

using namespace std;

int main() {
	int n, i, x;
	cin>>n;
	int a[n+1];
  memset(a, 0, sizeof a);
	for(i=1;i<n;i++) {
		cin>>x;
		a[x]++;
	}
	
  for(i=1;i<=n;i++) {
  	cout<<a[i]<<endl;
  }
    return 0;
}



Measured memory_bytes: 4416
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 100005
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

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

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	//  WF("output.txt");
	DF("err.txt");

	int N, M;
	scanf("%d %d", &N, &M);
	int A[MAX_N];
	for (int i = 0; i < N; i++) scanf("%d", A + i);
	vector <PII> BC(M);
	for (int k = 0; k < M; k++) {
		int B, C;
		scanf("%d %d", &B, &C);
		BC[k] = PII(C, B);
	}
	sort(A, A + N);
	sort(ALL(BC));
	int now = 0;
	for (int k = M - 1; k >= 0; k--) {
		while (now < N and BC[k].X > A[now] and BC[k].Y > 0) {
			A[now] = BC[k].X;
			BC[k].Y--;
			now++;
		}
	}
	int64 res = accumulate(A, A + N, 0LL);
	printf("%lld\n", res);
	return 0;
}

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

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

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
int main(){
  char c; cin >> c;
  c = c+1;
  cout << (char)c << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

X = int(input())

for x in range(X, X*2):
    if is_prime(x):
        print(x)
        exit()


Measured memory_bytes: 3064