akhauriyash/Code-Regression huggingface dataset:
#include <bits//stdc++.h>
#define rep(i,n) for(int i = 0;i < n;i++)
using namespace std;
typedef long long ll;

int main(){
    int k;
    cin >> k;
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[k-1];
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second


void solve(){
	
	int n;
	cin>>n;
	int points[n][3];
	rep(i,0,n){
		cin>>points[i][0]>>points[i][1]>>points[i][2];
	}

	int dp[n][3];
	dp[0][0] = points[0][0];
	dp[0][1] = points[0][1];
	dp[0][2] = points[0][2];

	rep(i,1,n){
		dp[i][0] = points[i][0] + max(dp[i-1][1] , dp[i-1][2]);
		dp[i][1] = points[i][1] + max(dp[i-1][0] , dp[i-1][2]);
		dp[i][2] = points[i][2] + max(dp[i-1][1] , dp[i-1][0]);
	}
	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;



}
signed main(){
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand (static_cast <unsigned> (time(0)));
    int t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using namespace std;
const int mod=1e9+7;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,ans=0; cin >> n;
    rep(i,0,n) {
        int l;int r;
        cin >> l >> r;
        ans+=r-l+1;
    }
    cout << ans << endl;
 }    


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
#define sz(x) int(x.size())
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

// アンバランスな文字列には同じ文字が過半数以上なければならない

int main() {
    string s;
    cin >> s;
    int n = s.size();
    repeat(i, n - 1) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }
    repeat(i, n - 2) {
        if (s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 3688
#include<cstdio>
#include<map>
#include<algorithm>
using namespace std;
typedef long long int ll;

int N;
ll A[222222];
map<ll, int> mpa;

int main(){
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%lld", &A[i]);
		mpa[A[i]]++;
	}
	sort(A, A + N);
	reverse(A, A + N);
	int res = 0;
	for(int i = 0; i < N; i++){
		if(mpa[A[i]] == 0) continue;
		ll base = 1LL;
		while(base <= A[i]) base *= 2LL;
		if(mpa[base - A[i]] > 0){
			if(base == 2 * A[i] && mpa[base - A[i]] == 1) continue;
			res++;
			mpa[base - A[i]]--;
		}
		mpa[A[i]]--;
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 26752
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int t;
string s, ds[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
int main(){
	cin >> s;
	for(;t<7 && s != ds[t]; t++);
	cout << 7 - t << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <cctype>
#include <stack>
#include <list>
#include <queue>
#include <map>
#include <sstream>
#include <cmath>
#include <limits>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

#define lli long long int
#define ulli unsigned long long int

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define SZ(a) (int)(a.size())

#define loop(i,a,b) for(int i=a; i<b; i++)

int gcd(int a, int b) {return b==0?a:gcd(b,a%b);}
int lcm(int a, int b) {return a*(b/gcd(a,b));}

#define INF 1000000000  //(10^9)
#define MOD 1000000007  //(10^9+7)

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);

vi arr(100010,0);

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s;
	cin>> s;
	for(int i= s.length()-2; i>=0; i--)
	{
		arr[i]= arr[i+1];
		if(s[i+1]=='g')
			arr[i]+=1;
	}
	int rock=0, paper=0, lose=0, win=0;
	if(s[0]=='p')
		lose++;
	rock++;
	loop(i,1,s.length())
	{
		if(s[i]=='g')
		{
			if(paper<rock)
			{
				int x;
				x= rock+1-paper;
				if(arr[i] >= x)
					rock+=1;
				else
				{
					paper+=1;
					win++;
				}
			}
			else
				rock+=1;
		}
		if(s[i]=='p')
		{
			if(paper<rock)
				paper+=1;
			else
			{
				rock+=1;
				lose++;
			}
		}
	}
	cout<< (win-lose)<< "\n";


	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int n, i, j;
    cin >> n;
    string s;
    cin >> s;

    string ans = "";
    
    for (i=0; i<n; i++){
        if (i == 0){
            ans = ans + s[i];
        } else if (s[i] != ans.back()){
            ans = ans + s[i];
        }
    }

    cout << ans.size() << endl;
	return 0;
}

Measured memory_bytes: 844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    ll y=min(k,x/d);
    k=k-y;
    x=x-y*d;
    if(k%2==0)
        cout<<x;
    else
        cout<<d-x;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

char str[105];

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    scanf("%s", str);
    if(n%2) {
        printf("No\n"); return 0;
    }
    int m=n/2;
    if(strncmp(str+0, str+m, m)==0) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }


    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include<map>
#include<set>
using namespace std;

int main() {
    long long n, k;
    cin >> n >> k;
    long long ans;
    if (k % 2 == 1) ans= pow(n/k,3);
    else ans=pow(n / (k / 2)-n/k , 3)+pow(n/k,3);
    cout << ans << endl;
}
    

Measured memory_bytes: 384
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);
        ABC098_A solver = new ABC098_A();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC098_A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();

            int ans = Math.max(Math.max(a + b, a - b), a * b);
            out.print(ans);

        }

    }
}



Measured memory_bytes: 23764
package main

import (
	"fmt"
	"sort"
)

type restaurant struct {
	no, point int
}

type rests []restaurant

func (r rests) Len() int {
	return len(r)
}
func (r rests) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func (r rests) Less(i, j int) bool {
	return r[i].point > r[j].point
}

func main() {
	var n int
	fmt.Scan(&n)
	restaurants := make(map[string][]restaurant, 0)
	var s string
	var p int
	var r restaurant
	for i := 0; i < n; i++ {
		fmt.Scan(&s, &p)
		r.no = i + 1
		r.point = p
		restaurants[s] = append(restaurants[s], r)
	}
	cities := make([]string, 0) // 市の名前の配列
	for city := range restaurants {
		cities = append(cities, city)
	}
	sort.Strings(cities) // 市の名前をソート
	for _, c := range cities {
		for k, v := range restaurants { //c市内のレストラン情報のスライスを取得
			if k == c {
				sort.Sort(rests(v)) // ポイントで降順にソート(Less()の実装に注意)
				for _, w := range v {
					fmt.Println(w.no) // レストラン番号を出力
				}
			}
		}
	}
}


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

int main(){
    std::string s;
    cin >> s;
    s[5] = ' ';
    s[13] = ' ';
    s[19] = ' ';
    cout << s << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int ans[][] = new int[1000][1000]; //????°?????????????????????\?????????????????????
		
		//??\?????????????¨????
		int time;
		for(int i = 0; i < h; i++){
			char[] hw = sc.next().toCharArray();
			time = -1;//1???????????£???????????????????????????
			for(int j = 0; j < w; j++){
				if(hw[j] == 'c'){ //??????????°????????????????????????´???????????????0????????????
					time = 0;
				}
				ans[i][j] = time;
				if(time != -1){ //?????????????°?????????\??????????????????1???????¶????????????????
					time++;
				}
			}
		}
		
		//??????
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(j == w - 1){
					System.out.println(ans[i][j]);
				}else{
					System.out.print(ans[i][j]);
					System.out.print(" ");
				}
			}
		}
	}
}

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

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	int left = N / K;
	int right = (double)N / K + 0.5;
	int ans = left * left * left;
	if (K % 2 == 0) ans += right * right * right;
	cout << ans << endl;


    return 0;
}


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

# AtCoder Beginner Contest
# Problem A

if __name__ == '__main__':
    candies = list(map(int, input().split()))
    candies = sorted(candies)

    first = sum(candies[:2])
    second = candies[2]

    if first == second:
        print('Yes')
    else:
        print('No')


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

  int ans; 
  string s; 
  int main(){ 
    cin >> s; 
    if(s[0]=='1') ans++; 
    if(s[1]=='1') ans++; 
    if(s[2]=='1') ans++; 
    cout << ans << endl; 
    
  }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <iomanip>
#include <map>
#include <sstream>
#define ll long long
using namespace std;
// ver..(1.1)
string ent="\n";
string space=" ";
int main(){
   ios_base::sync_with_stdio(false);
   ll a,b,c;
   cin >> a >> b >> c;

   ((a+b+c)>=22) ? cout << "bust\n":cout << "win\n";
}
/*



*/

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
using namespace std;
int a[200001],b[200001];
int n,m;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	scanf("%d",&b[i]);
	if(m>n){
		printf("NO\n");
		return 0;
	}
	sort(a+1,a+n+1);
	sort(b+1,b+m+1);
	int i=1,j=1;
	while(i<=n&&j<=m)
	{
		if(b[j]<a[i])
		{
			printf("NO\n");
			return 0;
		}
		if(b[j]==a[i])
		{
			j++;i++;
		}
		if(b[j]>a[i])
		i++;
	}
	if(j!=m+1) {
		printf("NO\n");
		return 0;
	}
	if(j==m+1&&a[i-1]==b[m])
	printf("YES\n");
	
	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>

int main()
{
	int i, j, k, N, ans = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		for (j = 1; N - i * j >= 1; j++) ans++;
	}
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int main(){
    while(1){
        int n,m;
        cin >> n >> m;
        if(n == 0) break;
        
        vector<int> s(n);
        for(int i=0; i<n; i++){
            cin >> s[i];
        }
        vector<int> d(m);
        for(int i=0; i<m; i++){
            cin >> d[i];
        }
        sort(d.begin(), d.end());
        
        vector<int> dp(1<<n, inf);
        vector<int> sum(1<<n, 0);
        dp[0] = 0;
        for(int i=0; i<(1<<n); i++){
            for(int j=0; j<n; j++){
                if(i>>j & 1) continue;
                int k = i|(1<<j);
                sum[k] = sum[i]+s[j];
                auto itr=lower_bound(d.begin(), d.end(), sum[i]);
                int cost=dp[i];
                for(; itr!=d.end() and *itr<sum[k]; itr++){
                    cost += min(*itr-sum[i], sum[k]-*itr);
                }
                dp[k] = min(dp[k], cost);
            }
        }
        int ans = dp[(1<<n)-1];
        auto itr=lower_bound(d.begin(), d.end(), sum[(1<<n)-1]);
        for(; itr!=d.end(); itr++){
            ans += *itr-sum[(1<<n)-1];
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
using namespace std;

////////// 最大公約数 ///////////

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

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

int main(){
  int N,ans=0;
  cin>>N;
  
  for(int i=1; i<=N; ++i){
    for(int j=1; j<=N; ++j){
      for(int k=1; k<=N; ++k){
        ans+=gcd(i,gcd(j,k));
      }
    }
  }
  
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (abs(a - c) <= d) cout << "Yes" << endl;
    else if (abs(a - b) <= d && abs(b - c) <= d) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m,i,j,ans=0,temp=0;
  cin >>n;
  vector<string> s(n),t(m);
  for(i=0;i<n;i++)
    cin>>s.at(i);
  cin >>m;
  for(i=0;i<m;i++)
    cin >>t.at(i);
  
  for(i=0;i<n;i++){
    temp=0;
    for(j=0;j<n;j++)
     if(s.at(i)==s.at(j))
       temp+=1;
    for(j=0;j<m;j++)
      if(s.at(i)==t.at(j))
        temp-=1;
    if(ans<=temp)
      ans=temp;
  }
  cout<<ans;
  
}

Measured memory_bytes: 512
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#include<stdio.h>
#include <string.h>
#include<algorithm>
#include <queue>
typedef long long ll;
const int mod=998244353;
const int maxn=1e6+5;
const ll INF=100000000000000005;
const double eps=1e-11;
using namespace std;
ll n,m,p;
struct node{
    int w,v;
    bool friend operator<(node a,node b)
    {
        return a.w<b.w;
    }
}save[3005];
ll dp[3005][6005];
int main()
{
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%lld%lld",&save[i].w,&save[i].v);
    sort(save+1,save+1+n);
    for(int i=1;i<=n;i++)
    {
        for(int k=0;k<save[i].w+m;k++)
        {
            if(k>=save[i].w) dp[i][k]=max(dp[i-1][k],dp[i-1][k-save[i].w]+save[i].v);
            else dp[i][k]=dp[i-1][k];
        }
    }
    ll res=0;
    for(int i=1;i<=n;i++) res=max(dp[n][m+save[i].w-1],res);
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 144468
n = int(input())
a = list(map(int, input().split()))

ipa = {}
ima = {}
for i in range(n):
    p = i + a[i]
    if p in ipa:
        ipa[p] += 1
    else:
        ipa[p] = 1
    m = i - a[i]
    if m in ima:
        ima[m] += 1
    else:
        ima[m] = 1

ans = 0
for k in ipa:
    if k in ima:
        ans += ipa[k] * ima[k]
print(ans)

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

int ans[10000000];

int main(){
    string s;
    cin >> s;
    
    rep(i,s.size()){
        int j = i;
        int num = 0;
        while(1){
            if(s[i] == 'R'){
                if(s[i]!=s[j+1]){
                    break;
                }
                else{
                    j++;
                    num++;
                }
            }
            else{
                if(s[i]!=s[j+1]){
                    break;
                }
                else{
                    j++;
                    num++;
                }
            }
        }
        int n = num;
        if(s[i] == 'R'){
            while(n>=0){
                if((n%2)==0){
                    ans[j] +=1;
                }
                else{
                    ans[j+1] += 1;
                }
                n--;
            }
        }
        else{
          	while(n>=0){
                if((n%2)==0){
                    ans[i] +=1;
                }
                else{
                    ans[i-1] += 1;
                }
                n--;
            }
        }
          i +=num;
    }
    rep(i,s.size()){
        cout << ans[i] << " " ;
    }
    
    return 0;
    
}










Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
void READ() {
#define R READ();
#define INFI 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MEMX(x,num) memset(x,num,sizeof(x))
#define prln(x) cout<<#x<<"="<<x<<endl
#define prt(x) cout<<x<<endl
#define prk(x) x<<" "
#define sz(x) int(x.size())
#define PB(x) push_back(x)
#define LINK(x,y) G[x].PB(y),G[y].PB(x)
#ifndef ONLINE_JUDGE
    freopen("A.in", "r", stdin);
#endif
    std::ios::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(3);
}
///////////////////////////
const int N=5 +2e5;


int n;
int a[N];
int main() {
    
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int ma=a[n-1],ans;
    int mi=INFI;
    for(int i=0;i<n-1;i++)
    {
        if(abs(2*a[i]-ma)<mi)mi=abs(2*a[i]-ma),ans=a[i];
    }
    cout<<ma<<" "<<ans;


    return 0;
}


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

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans;
int N;
vi A;
bool flag = false;

void solve(){
    rep(i, N){
        if(A[i] % 2 == 1) {
            flag = true;
            break;
        }
    }

    if(flag) cout << "first" << endl;
    else cout << "second" << endl;
}

int main(){
    cin >> N;
    A.resize(N);

    rep(i, N) cin >> A[i];

    solve();
}


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


#define M 1000000007
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define mod 998244353
#define sz(v) (int)(v).size()

#define pii pair<int, int>
#define vi vector<int>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)

ll add(ll a,ll b)
{
	a%=M;
	b%=M;
	ll p = (a+b)%M;
	return (p+M)%M;
}

ll mul(ll a,ll b)
{
	a%=M;
	b%=M;
	ll p = (a*b)%M;
	return (p+M)%M;
}


int main()
{
	fastio;
	ll i,n,m,a[100010];
	cin>>n>>m;
	ll sum=0;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	ll val = sum/(4*m) + (sum%(4*m)>0);
	ll cnt=0;
	for(i=0;i<n;i++)
	{
		// cin>>a[i];
		if(a[i]>=val)
			cnt++;
	}
	if(cnt>=m)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

    return 0;
}





Measured memory_bytes: 3628
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    final Scanner s = new Scanner(System.in);
    final int N = Integer.parseInt(s.next());
    final int M = Integer.parseInt(s.next());
    final int[] array = new int[N];
    Arrays.fill(array, 1);
    final boolean[] flg = new boolean[N];
    flg[0] = true;

    for (int i = 0; i < M; i++) {
      final int x = Integer.parseInt(s.next()) - 1;
      final int y = Integer.parseInt(s.next()) - 1;
      array[x]--;
      array[y]++;
      if (flg[x]) {
        if (array[x] <= 0) flg[x] = false;
        flg[y] = true;
      }
    }
    int count = 0;
    for (int i = 0; i < N; i++) {
      if (flg[i]) count++;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 52040
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long ll;
typedef vector<long long int> vi;
typedef vector<long long int>::iterator vit;

int main(){
	int h = 0, v = 0;
	int a[5], b[5];
	while (cin  >>a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
		REP(i,4){
			REP(j, 4){
				if (b[i] == a[j]){
					v++;
					if (i == j){
						v--;
						h++;
					}
				}
			}
		}
		cout << h << " " << v << endl;
		h = v = 0;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N, M;
  cin >> N >> M;
  if (N == M) {
    cout << "Yes"
         << "\n";
  } else
    cout << "No"
         << "\n";
}

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

int main() {
	long A, B, C, K;
  
	cin >> A >> B >> C >> K;
  
    if (A >= K)	{
      cout << K << endl;
    } else if ((A+B) >= K) {
      cout << A << endl;
    } else {
      C = K-(A+B);
      cout << A-C << endl;
    }
}

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

// auto MOD int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


// combination MOD prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < MOD);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(int n, int k) {
    return fact[n]*ifact[n-k];
  }
} comb(1000005);

int modPow(long long a, long long n) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  long long t = modPow(a, n / 2);
  return (t * t) % MOD;
}

int main() {
    ll N,K;
    cin >> N >> K;
    mint ans = 0;
    int A[N];
    rep(i,N) {
        cin >> A[i];
    }
    mint tmp = 0;
    rep(i,N) {
        tmp = ans;
        rep(j,N-1) {
            if (A[i]>A[(i+j+1)%N]) {
                if (K==1 && i+j+1<N) {
                    ans+=1;
                }
                else if (K>1 && i+j+1<N) {
                    ans+=K*(K+1)/2;
                }
                else if (K>1 && i+j+1>=N) {
                    ans+=K*(K-1)/2;
                }
            }
        }
        //cout << ans-tmp << endl;
    }
    cout << ans << endl;
}


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

int N, M;  //駒の数と地点の数
int cost = 0;  //駒移動回数
int X[100010];  //各地点の座標
int DX[100010];  //隣り合う地点の距離

int main(){
  cin >> N >> M;
  for(int i = 0; i < M; i++) cin >> X[i]; sort(X, X+M);
  for(int i = 0; i < M-1; i++) DX[i] = X[i+1] - X[i]; sort(DX, DX+M-1); reverse(DX, DX+M-1);

  /*駒の数-1個分の地点間距離を削除可能: i < (M-1)-(N-1) = M-N*/
  for(int i = N-1; i < M-1; i++) cost += DX[i];
  cout << cost << endl;
  return 0;
}


  
 
  

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

int main() {
    int n, ans = 1e9, i;
    vector <pair<int, int> > v,w;
    map <int, int> mp1, mp2;
    map <int, int>::iterator it;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        int x;
        
        scanf("%d", &x);
        
        if (i % 2 == 0) {
            mp1[x]++;
        } else {
            mp2[x]++;
        }
    }
    
    mp1[1e9] = 0;
    mp2[1e9] = 0;
    
    for (it = mp1.begin(); it != mp1.end(); it++) v.push_back(make_pair(it->second, it->first));
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    
    for (it = mp2.begin(); it != mp2.end(); it++) w.push_back(make_pair(it->second, it->first));
    sort(w.begin(), w.end());
    reverse(w.begin(), w.end());
    
    for (i = 0; i < v.size(); i++) {
        int p = 0;
        
        if (v[i].second == w[0].second) p = 1;
        
        ans = min(ans, n - (v[i].first + w[p].first));
    }
    
    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 6136
#include <bits/stdc++.h>
//#pragma GCC diagnostic error "-Wconversion"
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
ll digits(ll x){
  ll length = 0;
  while (x > 0){
    x /= 10;
    length++;
  }
  return length;
  if (x == 0) return 0;
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
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 main(){
  cout << fixed << setprecision(15);
  int ans = 0;
  //string ans = "No";

  int x; cin >> x;
  ans = 8 - (x - 400) / 200;

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

Measured memory_bytes: 3564
// Clockwork is still ticking.

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

namespace fastIO
{
	const UI BUFFER_SIZE = (UI) 1 << 15;
	char buffer[BUFFER_SIZE], *cur, *ed;

	inline char getc() { return *(cur == ed ? ed = buffer + fread(buffer, 1, BUFFER_SIZE, stdin), cur = buffer : cur)++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

template<typename T> inline T sqr(const T &val) { return val * val; }
template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }

// END tpl.

const int MAXN = (int) 3e5;

int n, L;

int a[MAXN + 5];

int t[MAXN + 5];

inline void input()
{
	n = read<int>(), L = read<int>();
	for(int i = 1; i <= n; ++i) a[i] = read<int>();
	for(int i = 1; i <= n; ++i) t[i] = read<int>();
}

inline void solve()
{
	static int l[MAXN + 5], r[MAXN + 5];

	LL ans = 0;
	for(int i = 1; i <= n; ++i)
		if(t[i] % (2 * L) == 0) ans += t[i] / (2 * L);
		else
		{
			ans += t[i] / (2 * L) + 1, t[i] %= 2 * L;
			l[i] = t[i] <= 2 * a[i];
			r[i] = t[i] <= 2 * (L - a[i]);
		}

	for(int i = 1, cntl = 0, cntlr = 0; i < n; ++i)
		if(cntl > 0 && r[i])
		{
			cntlr += l[i];
			--cntl, --ans;
		}
		else if(!l[i] && r[i]) { if(cntlr > 0) --cntlr, ++cntl; }
		else cntl += l[i];
	if(!r[n]) ++ans;
	printf("%lld\n", ans * 2 * L);
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 4992
import java.util.*;

public class Main {
    public static void main(String[] args){
        final Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if (N == 1) {
            System.out.println("Hello World");
        }
        else {
            int A = sc.nextInt();
            int B = sc.nextInt();
            System.out.println((A + B));
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>
using namespace std;
const int MAX = 10000+5;
int a[MAX] = {0};
int n,q,cnt = 0;
void Search(int num){
	for(int i = 0;i < n;i++){
		if(num == a[i]){
			cnt++;
			break;
		}
	}
}
int main(int argc, char const *argv[])
{
	cin >> n;
	for(int i = 0;i < n;i++)
		cin >> a[i];
	cin >> q;
	int num;
	for(int i = 0;i < q;i++){
		cin >> num;
		Search(num);
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

int main() {
  int x,y;

  cin >> x >> y;
  cout << x - y + 1 << endl;
}


Measured memory_bytes: 256
def check(i,j,h):
    return i!=j and j!=h and h!=i and i+j>h and j+h>i and i+h>j

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

ans = 0
for i in range(N):
    for j in range(i,N):
        for h in range(j,N):
            ans += check(L[i],L[j],L[h])

print(ans)


Measured memory_bytes: 9192
L = int(input())
N = L.bit_length()
res = L - (1 << (N - 1))
start = 1 << (N - 1)

ans = []
for i in range(N - 1):
    ans.append((i + 1, i + 2, 0))
    ans.append((i + 1, i + 2, 1 << (N - i - 2)))

for i in reversed(range(N)):
    if res >= (1 << i):
        ans.append((1, N - i, start))
        start += (1 << i)
        res -= 1 << i

print(N, len(ans))
for edge in ans:
    print(*edge)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;


int a[2000000];
map<int, int> mp;

int Pow(int x, int y){
  int res = 1;
  rep(i,inf){
    if(y == 0)break;
    if(y&1)res *= x;
    y >>= 1;
    x *= x;
  }
  return res;
}

signed main(){
  int n, p;
  scanf("%lld%lld", &n, &p);
  if(n == 1){
    printf("%lld\n", p);
    return 0;
  }
  int pp = p;
  repi(i,2,2000000){
    if(pp == 1)break;
    while(pp%i == 0){
      // printf("*%lld %lld*\n", i, pp);
      mp[i]++;
      pp /= i;
    }
  }
  
  for(auto it = mp.begin();it != mp.end();it++){
    // printf("%lld %lld\n", it->fi, it->se);
  }
  
  int ans = 1;
  for(auto it = mp.begin();it != mp.end();it++){
    ans *= Pow(it->fi, (it->se/n));
  }
  printf("%lld\n", ans);
  return 0;
}






Measured memory_bytes: 256
/*         
               JAI SHREE RAM    */
 
 
 
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define int             long long
#define mp              make_pair
#define pr              pair<long long,long long>
#define vr              vector<long long>
#define mod            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
const int N = 1000001;
 
int power(int x, unsigned int y) 
{ 
    int res = 1;     
   
    while (y > 0) 
    { 
        
        if (y & 1) 
            res = res*x; 
        y = y>>1; // y = y/2 
        x = x*x;  // Change x to x^2 
    } 
    return res; 
}
 
long long maxSubArray(long long a[], int sze)
{
   long long max_so_far = 0, max_ending = 0;
   for (int i = 0; i < sze; i++)
   {
       max_ending = max_ending + a[i];
       if (max_ending < 0)
           max_ending = 0;
       else if (max_so_far < max_ending)
           max_so_far = max_ending;
   }
   return max_so_far;
}
 
 
 
ll factorialNumInverse[N + 1]; 
ll naturalNumInverse[N + 1]; 
ll fact[N + 1]; 
  
 
void InverseofNumber(ll p) 
{ 
    naturalNumInverse[0] = naturalNumInverse[1] = 1; 
    for (int i = 2; i <= N; i++) 
        naturalNumInverse[i] = naturalNumInverse[p % i] * (p - p / i) % p; 
} 
void InverseofFactorial(ll p) 
{ 
    factorialNumInverse[0] = factorialNumInverse[1] = 1; 
  
    
    for (int i = 2; i <= N; i++) 
        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % p; 
} 
void factorial(ll p) 
{ 
    fact[0] = 1; 
  
    // precompute factorials 
    for (int i = 1; i <= N; i++) { 
        fact[i] = (fact[i - 1] * i) % p; 
    } 
} 
  
ll Binomial(ll N, ll R, ll p) 
{ 
    // n C r = n!*inverse(r!)*inverse((n-r)!) 
    ll ans = ((fact[N] * factorialNumInverse[R]) 
              % p * factorialNumInverse[N - R]) 
             % p; 
    return ans; 
} 
 
 
void solve()
{
  string s;
  cin>>s;
  
  int sum=0;
  for(int i=0;i<s.length();i++)
  {
      sum=sum+(s[i]-'0');
  }
   if(sum%9==0)
   cout<<"Yes\n";
   else
   cout<<"No\n";
}
 
int32_t main()
{ 
      
      
      int test;
      test=1;
      //cin>>test;
      while(test--)
      {
          solve();
      }
       
    
    return 0;
	}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
int main() 
{
    int n,k,i,j;
    cin>>n>>k;
    int m=1e9+7;
    int a[n+1],s[k+1];
    for(i=1;i<=n;i++)
    cin>>a[i];
    int dp[n+1][k+1];
    dp[0][0]=1;
    for(i=1;i<=k;i++)
    dp[0][i]=0;
    for(i=1;i<=n;i++)
    {
        s[0]=dp[i-1][0];
        for(j=1;j<=k;j++)
        s[j]=(s[j-1]+dp[i-1][j])%m;
        
        for(j=0;j<=k;j++)
        {
            int x=s[j];
            int y=j-a[i]-1;
            if(y>=0)
            x=(x-s[y]+m)%m;
            dp[i][j]=x;
        }
    }
    cout<<dp[n][k];
  
}

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

using namespace std;

typedef long long ll;
#define fori(i,n) for(int i=0; i<n; i++)
#define itn int 
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vll vector <ll>
#define be(a) (a).begin(), (a).end()
#define size(a) (int)a.size()
#define get(a) cin >> a
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	while (n>1000) {
		n-=1000;
	}
	cout << 1000-n;
	return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
using ll = long long;

int h,w;
vector<vector<int>> bw,nm;

void area_make(int x,int y,int gr) {
    nm[x][y] = gr;
    int tmp = bw[x][y];
    if (x-1>=0)   {if (nm[x-1][y]==0 and bw[x-1][y]==tmp) area_make(x-1,y,gr);}
    if (x+1<=h-1) {if (nm[x+1][y]==0 and bw[x+1][y]==tmp) area_make(x+1,y,gr);}
    if (y-1>=0)   {if (nm[x][y-1]==0 and bw[x][y-1]==tmp) area_make(x,y-1,gr);}
    if (y+1<=w-1) {if (nm[x][y+1]==0 and bw[x][y+1]==tmp) area_make(x,y+1,gr);}
}

int main() {
    cin >> h >> w;
    bw = vector<vector<int>>(h,vector<int>(w));
    nm = vector<vector<int>>(h,vector<int>(w,0));
    string s;
    vector<string> origin;

    for (int i=0;i<h;i++) {
        cin >> s;
        origin.push_back(s);
        for (int j=0;j<w;j++) {
            if ((i+j)%2==0) {
                if (s[j]=='.') bw[i][j]=1;  
                else bw[i][j]=2;
            }
            else {
                if (s[j]=='.') bw[i][j]=2;  
                else bw[i][j]=1;
            }
        }        
    }
    int area_code=1;
    for (int i=0;i<h;i++) {
        for (int j=0;j<w;j++) {
            if (nm[i][j]==0) {
                area_make(i,j,area_code);
                area_code+=1;
            }
        }
    }
    vector<map<char,ll>> cn(area_code+1);
    for (int i=1;i<area_code+1;i++) {
        cn[i]['w'] = 0;
        cn[i]['b'] = 0; 
    }
    
    for (int i=h-1;i>=0;i--) {
        for (int j=w-1;j>=0;j--) {
            int tmp = nm[i][j];            
            if (origin[i][j]=='.') cn[tmp]['w'] += 1;
            else cn[tmp]['b'] += 1;            
        }
    }
    
    ll g = 0;
    for (int i=1;i<area_code;i++) {
        g += cn[i]['w'] * cn[i]['b'];
    }
    cout << g << endl;
    return 0;
}

Measured memory_bytes: 25472
from collections import deque
N,K=map(int,input().split())
l=list(map(int,input().split()))
num=[1]*10
nums=[]
d=deque()
ans=[]
for i in range(len(l)):
    num[l[i]]=0
for i in range(10):
    if num[i]==1:
        nums.append(i)
        d.append(i)
#print(nums)
for i in range(10000):
    v=d.popleft()
    ans.append(v)
    for j in nums:
        if v!=0:
            d.append(v*10+j)
    #print(ans)
    #print(d)
    #input()
#print(len(ans),len(set(ans)),ans[len(ans)-1])
for i in range(len(ans)):
    if ans[i]>=N:
        print(ans[i])
        break



Measured memory_bytes: 57692
# -*- coding: utf-8 -*-
from math import ceil, sqrt, atan, degrees

def solve():
    a,b,x = map(int, input().split())
    if a*a*b == x:
        return '0'
    elif 1/2*a*a*b >= x:
        t = atan(2*x/a/b/b)
    else:
        t = atan(a*a*a/2/(a*a*b-x))

    return str(90-degrees(t))
        
if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 3188
i = gets.to_i
arr = []
 
i.times do |i|
  arr.push(gets.chomp)
end

puts ('AC x ' + arr.count('AC').to_s)
puts ('WA x ' + arr.count('WA').to_s)
puts ('TLE x ' + arr.count('TLE').to_s)
puts ('RE x ' + arr.count('RE').to_s)

Measured memory_bytes: 20644
#include<bits/stdc++.h>
    using namespace std;
    # define ll long long int
    vector<int>graph[200005];
    

    int main(){
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
        ios::sync_with_stdio(false);
        cin.tie(0);

        int a;
        cin>>a;
        cout<<a+a*a+a*a*a<<endl;

    }

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

using namespace std;
using ll = long long;
using pl = pair<ll,ll>;
#define inf numeric_limits<ll>::max()

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll nn(vector<ll> &v, ll x) {
  auto it = lower_bound(v.begin(), v.end(), x);
  ll w, e;
  if(it == v.begin())
    w = inf;
  else
    w = abs(*prev(it)-x);
  if(it == v.end())
    e = inf;
  else
    e = abs(*it-x);
  return min(w, e);
}

void solve(long long A, long long B, long long Q, std::vector<long long> s, std::vector<long long> t, std::vector<long long> x){
  vector<pair<ll,char>> v;
  for(auto xx : s) {
    v.push_back(make_pair(xx, 's'));
  }
  for(auto xx : t) {
    v.push_back(make_pair(xx, 't'));
  }
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  sort(v.begin(), v.end());
  
  for(auto val: x) {
    auto it = lower_bound(v.begin(), v.end(), make_pair(val, 'a'));
    ll w, e;
    //first west
    if(it == v.begin()) {
      w = inf;
    } else {
      w = abs(val - prev(it)->first);
      if(prev(it)->second == 's')
	w += nn(t, prev(it)->first);
      else
	w += nn(s, prev(it)->first);
    }
    //first east
    if(it == v.end())
      e = inf;
    else {
      e = abs(val - it->first);
      if(it->second == 's')
	e += nn(t, it->first);
      else
	e += nn(s, it->first);
    }

    std::cout << min(w, e) << std::endl;
  }
}

int main(){
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  long long Q;
  scanf("%lld",&Q);
  std::vector<long long> s(A);
  for(int i = 0 ; i < A ; i++){
    scanf("%lld",&s[i]);
  }
  std::vector<long long> t(B);
  for(int i = 0 ; i < B ; i++){
    scanf("%lld",&t[i]);
  }
  std::vector<long long> x(Q);
  for(int i = 0 ; i < Q ; i++){
    scanf("%lld",&x[i]);
  }
  solve(A, B, Q, std::move(s), std::move(t), std::move(x));
  return 0;
}


Measured memory_bytes: 8560
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n []byte
	fmt.Scan(&n)
	var sum int
	for i := range n {
		a, _ := strconv.Atoi(string([]byte{n[i]}))
		sum += a
	}
	if sum%9 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


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

int main(){
    string x, y;

    cin >> x >> y;
    reverse(y.begin(), y.end());

    if(x == y){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2019-12-16 20:54:58
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int N;
    cin >> N;
    vector<pair<pair<string, int>, int>> book(N);
    for (int i = 0; i < N; i++) {
        cin >> book[i].first.first >> book[i].first.second;
        book[i].first.second *= -1;
        book[i].second = i+1;
    }

    sort(all(book));

    for (int i = 0; i < N; i++) {
        cout << book[i].second << endl;
    }

    return 0;
}


Measured memory_bytes: 256