akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ull mod = 1000000007;

int main(void)
{
	ll n, q;
	cin >> n >> q;
	vector<t3> events;
	rep(i, n) {
		ll s, t, x;
		cin >> s >> t >> x;
		events.emplace_back(s - x, -1, x);
		events.emplace_back(t - x, 0, x);
	}
	rep(i, q) {
		ll d;
		cin >> d;
		events.emplace_back(d, 1, i);
	}
	sort(events.begin(), events.end());
	auto s = events.size();
	multiset<ll> m;
	vector<ll> ans(q, 0);
	rep(i, s) {
		ll s, t, x;
		tie(s, t, x) = events[i];
		//cout << s << "," << t << "," << x << endl;
		if (t == -1) {
			m.insert(x);
		}
		else if (t == 0) {
			m.erase(m.find(x));
		}
		else
		{
			ans[x] = m.size() ? *m.begin() : -1;
			//cout << x << "," << ans[x] << endl;
		}
	}
	rep(i, q) {
		cout << ans[i] << endl;
	}

	return 0;
}


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

int main(void){
    
    int N;
    cin >> N;
    
    int A;
    map<int,int> mp;
    for(int i = 0; i < N;i++){
        cin >> A;
        if(mp[A]!=0){
            cout << "NO" <<endl;
            return 0;
        }
        mp[A]++;
    }
    cout <<"YES"<<endl;
    return 0;
    
}

Measured memory_bytes: 9600
#include <iostream>

using namespace std;

int main() {
  int n;
  char c;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> c;
    if (c == 'R')
      arr[i] = 0;
    else
      arr[i] = 1;
  }

  int i = 0, j = n-1, ans = 0;
  while (i < j) {
    while (i < n && arr[i] == 0)
      i++;
    while (j > 0 && arr[j] == 1)
      j--;
    if (i >= j)
      break;
    ans++;
    arr[i] = 0;
    arr[j] = 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3980
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pq = priority_queue<int>;
using q = queue<int>;



int main() {
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
  ll ans = 0;
if(k <= a) ans = k;
else if(c == 0 || a + b == k) ans = a; 
else{
 ans = a - (k-a-b);
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 3636
*a,=map(int,open(0).read().split())
b=[i%10 if i%10!=0 else 99 for i in a ]
c=a.pop(b.index(min(b)))
ans=0
#print(a)
for i in a:
    #print((i//10*10+(i%10>0)*10))
    ans+=(i//10*10+(i%10>0)*10)
print(ans+c)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>

using namespace std;


vector<int> ve;

int main()
{
	int num;
	string a, b, buff;
	
	int temp = 0;

	cin >> a >> b;

	buff = a + b;
	num = atoi(buff.c_str());
	

	for (int i = 0; i < 317; i++) {
		ve.push_back(i * i);
	}
		
	for (int i = 0; i < ve.size();  i++) {
		if (num == ve[i]) {
			cout << "Yes" << endl;
			return 0;
		}
		else if (num < ve[i]) {
			break;
		}
	}


	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
word = []
now = ""
for i in range(N):
  w = input()
  if i == 0:
    word.append(w)
    now = w[-1]
  else:
    if w[0] == now and w not in word:
      word.append(w)
      now = w[-1]
    else:
      break
if len(word) == N:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out, n) for(int i=0; i<n; i++) cout<<out[i]<<endl
int main(){
    int X; cin>>X;
    if(X>=30){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3536
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  [n,x] <- map (read::String->Int) . words <$> getLine
  ms <- map (read::String->Int) . lines <$> getContents
  print $ n + div (x - sum ms) (minimum ms)

Measured memory_bytes: 4304
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;

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

// value
int N, Q;
vector<vector<int>> G;
map<int, int> W;
ll ans[200020];

void dfs(int n, int w) {

	ans[n] = w + W[n];
	for (int i = 0; i < G[n].size(); i++) {
		if (ans[G[n][i]] == -1) {
			dfs(G[n][i], ans[n]);
		}
	}
	return;
}

void solve() {

	cin >> N >> Q;
	G.resize(N);
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	for (int i = 0; i < Q; i++) {
		int p, x;
		cin >> p >> x; p--;
		W[p] += x;
	}

	for (int i = 0; i < N; i++) {
		ans[i] = -1;
	}

	dfs(0, 0);

	for (int i = 0; i < N - 1; i++) {
		cout << ans[i] << " ";
	}
	cout << ans[N - 1] << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}


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

namespace AOJ.Codes
{
    //問題の名称... CGL_3_A: Polygon - Area 
    //問題文のURL... http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_A&lang=jp
    //所要時間... AAA
    //学んだこと... AAA
    //教室内の大まかな着席位置... 中央 x 中央

    class CGL_3_A_PolygonArea
    {
        static void Main(string[] args)
        {
            //読み込み
            var Ps = new List<P>();

            var N = int.Parse(Console.ReadLine());

            for (int i = 0; i < N; i++)
            {
                var x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                Ps.Add(new P(x[0], x[1]));
            }

            //計算
            var sum = 0d;
            var A = Ps[0];
            for (int i = 1; i < N - 1; i++)
            {
                //外積を求めて加算していく。
                var B = Ps[i];
                var C = Ps[i + 1];
                var AB = B - A;
                var AC = C - A;
                sum += P.GetCross(AB, AC) / 2; //三角形の面積なので外積を2で割る。
            }

            //出力
            Console.WriteLine(Math.Abs(sum).ToString("F1"));

            //Enterを押して終了
            Console.ReadLine();
        }

        private struct P
        {
            public int x { get; set; }
            public int y { get; set; }

            /// <summary>
            /// コンストラクタ
            /// </summary>
            /// <param name="x"></param>
            /// <param name="y"></param>
            public P(int x, int y)
            {
                this.x = x;
                this.y = y;
            }

            /// <summary>
            /// 差分を計算
            /// </summary>
            /// <param name="p1"></param>
            /// <param name="p2"></param>
            /// <returns></returns>
            public static double GetCross(P p1, P p2)
            {
                return p1.x * p2.y - p1.y * p2.x;
            }

            /// <summary>
            /// 外積を計算
            /// </summary>
            /// <param name="v1"></param>
            /// <param name="v2"></param>
            /// <returns></returns>
            public static P operator -(P v1, P v2)
            {
                return new P((v1.x - v2.x), (v1.y - v2.y));
            }
        }
    }

}




Measured memory_bytes: 18360
/*
link: 
tags: 
*/
#include<bits/stdc++.h>
#define to_l(a) ((a)<<1)
#define to_r(a) ((a)<<1|1)
#define lowbit(a) ((a)&(-a))
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
const int int_inf=0x3f3f3f3f;
const ll ll_inf=0x3f3f3f3f3f3f3f3f;
const int max_n=1e5+5;
const ll mod=1e9+7;
ll dp[2005];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int i,j;
	int s;
	cin>>s;
	dp[1]=dp[2]=0;
	dp[3]=dp[4]=dp[5]=1;
	for(i=6;i<=2000;i++){
		dp[i]=(dp[i-1]+dp[i-3])%mod;
	}
	cout<<dp[s]<<endl;
	return 0;
}


Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.IntStream;

public class Main {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        char[][] s = new char[3][];
        for (int i = 0; i < 3; i++) {
            s[i] = in.nextToken().toCharArray();
            if(i > 0 && s[i][0] != s[i - 1][s[i - 1].length - 1]) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}


class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}

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

using namespace std ;

const long long mod = 1e9 + 7ll ;
const int MAX = 2e5 + 10 ;

long long sz[MAX] , P[MAX] ;
int n ;

long long ans = 0ll ;

vector< vector<int> >adj(MAX) ;

long long powlog(long long base , long long power)
{
	if(power == 0)
		return 1ll ;
	long long x = powlog(base , power / 2ll) ;
	x = (x * x) % mod ;
	if(power & 1)
		x = (x * base) % mod ;
	x %= mod ;
	return x ;
}

void dfs(int node , int par)
{
	sz[node] = 1 ;
	for(auto &child : adj[node])
	{
		if(child == par)
			continue ;
		dfs(child , node) ;
		sz[node] += sz[child] ;
	}
	return ;
}

void dfs2(int node , int par)
{
	vector<long long>v ;
	long long sum = 0ll ;
	for(auto &child : adj[node])
	{
		if(child == par)
			continue ;
		dfs2(child , node) ;
		v.push_back(sz[child]) ;
		sum += sz[child] ;
	}
	long long x = (P[sz[node] - 1] - 1ll + mod) % mod ;
	long long y = (P[n - sz[node]] - 1ll + mod) % mod ;
	long long z = (x * y) % mod ;
	ans = (ans + z) % mod ;
	for(auto &i : v)
	{
		sum -= i ;
		x = (P[i] - 1ll + mod) % mod ;
		y = (P[sum] - 1ll + mod) % mod ;
		z = (x * y) % mod ;
		ans = (ans + z) % mod ;
	}
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	P[0] = 1ll ;
	for(int i = 1 ; i < MAX ; ++i)
		P[i] = (P[i-1] * 2ll) % mod ;
	cin>>n ;
	for(int i = 0 ; i < n-1 ; ++i)
	{
		int x , y ;
		cin>>x>>y; 
		adj[x].push_back(y) ;
		adj[y].push_back(x) ;
	}
	dfs(1 , -1) ;
	dfs2(1 , -1) ;
	ans = (ans * powlog(P[n] , mod-2)) % mod ;
	ans %= mod ;
	cout<<ans<<"\n" ;
	return 0 ;
}		

Measured memory_bytes: 27904
#include <stdio.h>//??????????????????????????¢???????????????????????°
#include <string.h>

int main(void)
{
	char c[1201];
	int al[52]={0};
	int i=0, l;

	for (;;)
	{
		
		if (scanf("%c", &c[i]) == -1)
		{
			break;
		}
		i+=1;
	}

	for (l=0;l<i;l++)
	{
		if(c[l] >= 'a' && c[l] <= 'z') {
			al[c[l]-'a']+=1;
		} else if (c[l] >= 'A' && c[l] <= 'Z') {
			al[c[l]-'A']+=1;
		}
	}

	for (i=0;i<='z'-'a';i++)
	{
		printf("%c : %d\n", i+'a', al[i]);
	}
	return 0;
}

Measured memory_bytes: 540
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

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

    static class Task {
    	int A, P;
        void solve(InputReader in, PrintWriter out) {
            // write your code here
        	A = in.nextInt();
        	P = in.nextInt();
        	out.println((A*3 + P) / 2);
        }
        
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}


Measured memory_bytes: 22996
// abc131b.cpp : Bite Eating
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define dw(i,s,e,d) for(int i=(s);i>(e);i-=(d))
#define in(x) cin>>(x)
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl

#define INF 1000000000+1

int main(){
  int N,L; cin>>N>>L;
  vi t(N+1);
  int s_taste = 0;
  up(i,1,N+1,1){
    t[i] = L + i - 1;
    s_taste += t[i];
  }

  int del_taste = 0;
  int diff_taste = INF;
  int taste = 0;
  int ans = 0;
  up(i,1,N+1,1){
    taste = abs(t[i]);
    if(diff_taste>taste){
      diff_taste = taste;
      ans = s_taste-t[i];;
    }
  }
  ote(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);

#define N 4e7
#define nl "\n"
#define f first
#define s second
#define pi acos(-1.0)
#define MOD 1000000007
#define pb push_back

typedef long long ll;
typedef double db;

using namespace std;

int main()
{
    io;
    //freopen("in.txt" , "r" , stdin);
    //freopen("out.txt" , "w" , stdout);

    ///Let the showdown begin

    string s;
    cin >> s;
    
    ll sum = 0;
    for(char ch : s)
    {
        sum += (ch - '0');
    }
    cout << ((sum % 9) == 0 ? "Yes" : "No") << nl;

    ///Happily DONE
    return 0;
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
#define loop(i,a,n) for(int i=a;i<n;i++)
int main(){
	long long int n;
  	scanf("%lld",&n);
    
    char s[4001];
    scanf("%s",s);
    long long int ans = 0; 
    
    vector<int>r,g,b;
    
    loop(i,0,n){
        if(s[i] == 'R')r.push_back(i);
        else if(s[i] == 'G')g.push_back(i);
        else if(s[i] == 'B')b.push_back(i);
    }
    
    loop(i,0,n){
        loop(j,i+1,n){
            if(s[i] != s[j]){
                int dist = j-i;
                if(s[i]!= 'R' and s[j]!= 'R'){
                    auto it = upper_bound(r.begin(),r.end(),j);
                    if(it != r.end()){
                        ans += (r.end() - it);
                        if(2*j-i < n and s[2*j-i] == 'R')ans --;
                    }
                        
                }
                else if(s[i]!= 'G' and s[j]!= 'G'){
                    auto it = upper_bound(g.begin(),g.end(),j);
                     if(it != g.end()){
                        ans += (g.end() - it);
                        if(2*j-i < n and s[2*j-i] == 'G')ans --;
                    }
                }
                else{
                    auto it = upper_bound(b.begin(),b.end(),j);
                    if(it != b.end()){
                        ans += (b.end() - it);
                        if(2*j-i < n and s[2*j-i] == 'B')ans --;
                    }
                }
            }
        }
    }
    
  	printf("%lld",ans);
  	puts("");
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n,m;
	cin>>n>>m;
	
	vi s;
	vi g;
	REP(i,m){
		int a,b;
		cin>>a>>b;
		if(a==1) s.push_back(b);
		if(b==n) g.push_back(a);
	}
	sort(ALL(g));
	
	for(auto elem:s){
		if(binary_search(ALL(g),elem)){
			cout<<"POSSIBLE"<<endl;
			return 0;
		}
	}
	
	cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e6+5;
int h,w,k,x1,Y1,x2,y2,dr[4][2]={{-1,0},{0,-1},{1,0},{0,1}};
LL dist[N*4];
char s[N];
inline int calc(int x,int y,int z){return (x*w+y)*4+z;}
priority_queue<pair<LL,int> >q;
inline LL ceil(LL x){
	return (x-1)/k*k+k;
}
void dijk(){
	memset(dist,0x3f,sizeof(dist));
	pair<LL,int>u;
	int v=calc(x1,Y1,0);LL w1;
	dist[v]=dist[v+1]=dist[v+2]=dist[v+3]=0;
	q.push({dist[v],v});q.push({dist[v],v+1});q.push({dist[v],v+2});q.push({dist[v],v+3});
	while(!q.empty()){
		u=q.top();q.pop();
		if(-u.first!=dist[u.second])continue;
		int x=u.second/4/w,y=(u.second/4)%w,d=u.second%4,x3,y3;
		for(int i=0;i<4;i++){
			x3=x+dr[i][0],y3=y+dr[i][1];
			if(x3<0||y3<0||x3>=h||y3>=w||s[calc(x3,y3,0)>>2]!='.')continue;
			if(d==i){
				if(dist[v=calc(x3,y3,i)]>dist[u.second]+1){
					dist[v]=dist[u.second]+1;
					q.push({-dist[v],v});
				}
			}
			else{
				if(dist[v=calc(x3,y3,i)]>ceil(dist[u.second])+1){
					dist[v]=ceil(dist[u.second])+1;
					q.push({-dist[v],v});
				}
			}
			
		}	
	}
}
int main(){
	scanf("%d%d%d",&h,&w,&k);
	scanf("%d%d%d%d",&x1,&Y1,&x2,&y2),x1--,Y1--,x2--,y2--;
	for(int i=0;i<h;i++)scanf("%s",s+i*w);
	dijk();
	LL ans=1e17;
	for(int i=0;i<4;i++)ans=min(ans,dist[calc(x2,y2,i)]);
	if(ans>1e15)printf("-1");
	else printf("%d",ceil(ans)/k);
	return 0;
} 

Measured memory_bytes: 39676
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll p=1e9+7;
struct aaa{
	ll x,y;
}a[200010];
ll n,ans,jc[100010],ny[100010],f[4010][4010];
ll ksm(ll x,ll y){
	ll xlh=1;
	while(y){
		if(y&1)xlh=xlh*x%p;
		x=x*x%p;
		y/=2;
	}
	return xlh;
}
ll C(ll x,ll y){
	return jc[x]*ny[y]%p*ny[x-y]%p;
}
int main(){
	ll i,j;
	jc[0]=ny[0]=1;
	for(i=1;i<=10000;i++)jc[i]=jc[i-1]*i%p,ny[i]=ksm(jc[i],p-2);
	scanf("%lld",&n);
	for(i=1;i<=n;i++){
		scanf("%lld%lld",&a[i].x,&a[i].y);
		f[-a[i].x+2000][-a[i].y+2000]++;
	}
	for(i=0;i<=4000;i++)
	 for(j=0;j<=4000;j++){
	 	if(i)f[i][j]=(f[i][j]+f[i-1][j])%p;
	 	if(j)f[i][j]=(f[i][j]+f[i][j-1])%p;
	 }
	for(i=1;i<=n;i++){
		ans=(ans+f[a[i].x+2000][a[i].y+2000])%p;
		ans=(ans-C(a[i].x*2+a[i].y*2,a[i].x*2)+p)%p;
	}
	printf("%lld",ans*ksm(2,p-2)%p);
}
/*
转化成从原点走到ai+aj,bi+bj的方案
再转化成从-ai,-bi走到aj,bj的方案 
*/

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

int main() {
  string c;
  cin >> c;
  
  if ( c == "a") {
    cout << "vowel" << endl;
  }
  else if ( c == "e") {
    cout << "vowel" << endl;
  }
  else if ( c == "i") {
    cout << "vowel" << endl;
  }
  else if ( c == "o") {
    cout << "vowel" << endl;
  }
  else if ( c == "u") {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
  
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

char c[26];

main()
{
        string s; cin>>s;
        int t=s.size();
        rep(i,t)c[s[i]-'a']=1;
        rep(i,26)
        {
                if(c[i]==0)
                {
                        char ans='a'+i;
                        cout<<ans<<endl;
                        return 0;
                }
        }
        cout<<"None"<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
int m,n,p3[12],dp[531441],inf=1e8;
string s[128];
int dfs(int x){
	if(dp[x]!=inf) return dp[x];
	rep(i,m){
		if(x/p3[i]%3==0){
			dp[x]=min(dp[x],1+max(dfs(x+p3[i]),dfs(x+2*p3[i])));
		}
	}
	return dp[x];
}
int main(){
	p3[0]=1;
	rep(i,11) p3[i+1]=p3[i]*3;
	while(true){
		cin>>m>>n;
		if(m==0) break;
		rep(i,n) cin>>s[i];
		rep(i,p3[m]){
			dp[i]=inf;
			int d[12]={};
			rep(j,m) d[j]=i/p3[j]%3;
			int cnt=0;
			rep(j,n){
				bool ok=true;
				rep(k,m) if(!(d[k]==0||d[k]-1==s[j][k]-'0')) ok=false;
				if(ok) cnt++;
			}
			if(cnt<=1) dp[i]=0;
		}
		cout<<dfs(0)<<endl;
	}
}

Measured memory_bytes: 1908
#include<bits/stdc++.h>
using namespace std;
char str[100];
inline int max(const int &a,const int &b){return a>b?a:b;}
inline int min(const int &a,const int &b){return a<b?a:b;}
inline void read(int &n)
{
	n=0;char c=getchar();bool b=0;
	while(c<'0'||c>'9'){if(c=='-')b=1;c=getchar();}
	while(c>='0'&&c<='9') n=(n<<3)+(n<<1)+c-48,c=getchar();
	if(b) n=-n;
}
set<int> s;
int n,x;
int main()
{
	read(n);
	for(int i=1;i<=n;i++)
	{
		read(x);
		if(s.find(x)!=s.end()) s.erase(x);
		else s.insert(x);
	}
	printf("%d",s.size());
}

Measured memory_bytes: 4864
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<int> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	string s,t ;
	cin >> s >> t ;
	vll a(26,0),b(26,0) ;
	for(int i=0;i<s.size();i++) a.at(s.at(i)-'a')++ ;
	for(int i=0;i<t.size();i++) b.at(t.at(i)-'a')++ ;
	sort(all(a)) ;
	sort(all(b)) ;
	yorn(a==b) ;
}


Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <bitset>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;

int main() {
    int n,m;
    cin >> n >> m;
    
    vector<double> L(n),a(n),b(n);
    rep(i,n) cin >> L[i] >> a[i] >> b[i];

    double ans = 0;
    rep(i,1<<n) {
        bitset<20> bit(i);
        if(bit.count() == m) {
            vector<int> res;
            rep(j,20) {
                if(bit[j]) res.push_back(j);
            }

            double sum = 0;
            rep(j,res.size()) {
                REP(k,j+1,res.size()) {
                    int s = res[j];
                    int t = res[k];
                    sum += (L[s]-L[t]) * (L[s]-L[t]);
                    sum += (a[s]-a[t]) * (a[s]-a[t]);
                    sum += (b[s]-b[t]) * (b[s]-b[t]);
                }
            }

            ans = max(ans,sum);
        }
    }
    
    cout << fixed;
    cout.precision(10);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1320
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        s: chars,
        t: chars
    }
    if s == t {
        println!("0");
        return;
    }
    let mut i = n;
    let mut j = n;
    let mut p = vec![];
    while j > 0 {
        j -= 1;
        let r = j;
        while j > 0 && t[j] == t[j - 1] {
            j -= 1;
        }
        i = min(i, j);
        while i > 0 && s[i] != t[j] {
            i -= 1;
        }
        if s[i] != t[j] {
            println!("-1");
            return;
        }
        if i < r {
            p.push((i, r));
        }
    }
    let mut ans = 0;
    let mut h: Vec<i64> = vec![0; n];
    let mut off = 0;
    let mut a = 0;
    let mut r = n;
    for &(i, j) in &p {
        for k in j + off..r {
            a += h[k];
        }
        r = j + off;
        off += 1;
        a += 1;
        h[j + off - 1] = 0;
        h[i + off - 1] -= 1;
        ans = max(ans, a as usize);
    }
    println!("{}", ans);
}


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os<<"("<<p.first<<","<<p.second<<")";
    return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os<<"{";
    rep(i, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}

int main() {
    int N; cin >> N;
    V<int> H(N); rep(i, N) cin >> H[i];
    V<int> a(N);
    for (int i = N-2; i >= 0; --i) {
        if (H[i] >= H[i+1]) {
            a[i] = a[i+1] + 1;
        }
    }
    cout << *max_element(ALL(a)) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define IL inline
#define _ 605
#define ll long long
using namespace std ;

IL int gi(){
    int data = 0 , m = 1; char ch = 0;
    while(ch!='-' && (ch<'0'||ch>'9')) ch = getchar();
    if(ch == '-'){m = 0 ; ch = getchar() ; }
    while(ch >= '0' && ch <= '9'){data = (data<<1) + (data<<3) + (ch^48) ; ch = getchar(); }
    return (m) ? data : -data ; 
}

#define mod 1000000007
int n,A[_],Ans,f[2][_][_] ; bool fix[_],del[_] ;
IL void add(int &x , int y) {x += y ; if(x >= mod) x -= mod ; }

int main() {
	n = gi() ;
	for(int i = 1; i <= 2 * n; i ++) A[i] = gi() ;
	for(int i = 1; i <= 2 * n; i ++) if(A[i] != -1) fix[A[i]] = true ;
	for(int i = 1; i <= 2 * n; i += 2) if(A[i]!=-1&&A[i+1]!=-1) del[A[i]] = del[A[i+1]] = true ;
	int op = 0 ;
	f[op][0][0] = 1 ;
	for(int i = 2 * n; i >= 1; i --) {
		if(del[i]) continue ;
		memset(f[op ^ 1] , 0 , sizeof(f[op ^ 1])) ;
		for(int j = 2 * n - i; j >= 0; j --)
			for(int k = 2 * n - i; k >= 0; k --)
				if(f[op][j][k]) {
					if(fix[i]) {
						add(f[op^1][j+1][k] , f[op][j][k]) ;
						if(k) add(f[op^1][j][k-1] , f[op][j][k]) ;
					}
					else {
						add(f[op^1][j][k+1] , f[op][j][k]) ;
						if(k) add(f[op^1][j][k-1] , f[op][j][k]) ;
						if(j) add(f[op^1][j-1][k] , 1ll * j * f[op][j][k] % mod) ;
					}
				}
		op ^= 1 ; 
	}
	Ans = f[op][0][0] ;
	int cnt = 0 ;
	for(int i = 1; i <= 2 * n; i += 2) if(A[i]==-1 && A[i+1]==-1) ++ cnt ;
	for(int i = 1; i <= cnt; i ++) Ans = 1ll * Ans * i % mod ;
	cout << Ans << endl ; return 0 ; 
}


Measured memory_bytes: 3072
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1e9 + 7;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, bool isFront) {
	if (first_itr < 0 || first_itr > str.size()) {
		return str;
	}
	else {
		if (isFront) {
			std::string tmp;
			for (size_t i = 0; i < first_itr; i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
		else {
			std::string tmp;
			for (size_t i = first_itr; i < str.size(); i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
	}
}


bool dfs(int depth, str s) {
	/*if (depth == n) {
		ans.push_back(s);
		return false;
	}
	for (int i = 0; i < n; i++) {
		if (dfs(depth + 1, s + dic.at(i))) {
			return true;
		}
	}*/
	return false;
}


P f(int x) {
	int a = x % 10;
	int b = 0;
	while (x) {
		b = x;
		x /= 10;
	}
	return make_pair(a, b);
}



int main() {
	int n; cin >> n;
	map<P, int> mp;
	REP(i, 1, n + 1) {
		P p = f(i);
		mp[p]++;
	}
	ll ans = 0;
	REP(i, 1, n + 1) {
		P p = f(i);
		P q(p.second, p.first);
		ans += mp[q];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int getMinimumCost(int arr[], int dp[], int size)
{
    for(int i = 2 ; i < size ; i++)
    {
        dp[i] = min(abs(arr[i] - arr[i-1]) + dp[i-1], abs(arr[i] - arr[i-2]) + dp[i-2]);
    }
    return dp[size-1];
}

int main(int argc, const char * argv[])
{
    int size;
    cin>>size;
    int arr[size];
    int dp[size];
    for(int i = 0 ; i < size ; i++)
    {
        cin>>arr[i];
        dp[i] = 0;
    }
    dp[0] = 0;
    dp[1] = abs(arr[1] - arr[0]);
    size > 0 ? cout<<getMinimumCost(arr, dp, size)<<endl : cout<<0<<endl;
    return 0;
}

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

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (c <= b)
    {
        cout << "delicious";
    }
    else
    {
        if (fabs(b - c) <= a)
        {
            cout << "safe";
        }
        else
        {
            cout << "dangerous";
        }
    }
}

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

N,K = map(int,readline().split())
A = list(map(int,readline().split()))

# 答えがXであると仮定する
# A_iの丸太をXにするためには、A_i / Xを切り上げた数 - 1回切る必要がある
# 15 を 4にするためには、15 / 4 = 3.x -> 3回切る
# 12 を 4にするためには、12 / 4 = 3 -> 2回切る
# (A_i + X - 1 // X) - 1 回でOK
# ((15 + 4 - 1) // 4) - 1 = 3
# ((12 + 4 - 1) // 4) - 1 = 2
# ((4 + 4 - 1) // 4) - 1 = 0
# Xの値を二分探索。切る回数の合計がK以下ならOK

ok = max(A)
ng = 0

def isOk(x):
  cut = 0
  for a in A:
    cut += ((a + x - 1) // x) - 1
  return cut <= K
  
while abs(ok - ng) > 1:
  mid = abs(ok + ng) // 2
  if isOk(mid):
    ok = mid
  else:
    ng = mid

print(ok)

Measured memory_bytes: 32160
#include<stdio.h>

int A,a[20];
 
int main(){
 
int M,m[200],k;
 
scanf("%d",&A);
for(k=0;k<A;k++)
scanf("%d",&a[k]);
 
scanf("%d",&M);
for(k=0;k<M;k++)
scanf("%d",&m[k]);

for(k=0;k<M;k++){
if(solve(0,m[k])==1) printf("yes\n");
else printf("no\n");
}

}
int solve(int x,int y){

int res;

if(y==0)
return 1;
if(x>=A)
return 0;

res=solve(x+1,y)||solve(x+1,y-a[x]);
return res;

}


Measured memory_bytes: 1996
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int n,a; cin>>n>>a;
    int m = n%500;
    if(a>=m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, M;
    cin >> N >> M;
    vec K(N);
    mat A(N);
    REP(i,0,N) {
        cin >> K[i];
        REP(j,0,K[i]) {
            ll a;
            cin >> a;
            A[i].pb(a-1);
        }
    }

    vec C(M, 0);
    REP(i,0,N) {
        REP(j,0,K[i]) ++C[A[i][j]];
    }

    ll cnt = 0;
    REP(i,0,M) {
        if(C[i] == N) ++cnt; 
    }
    PR(cnt);

    return 0;
}

/*



*/

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main() {
  int n, k, m, c = 0;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> m;
    if (m >= k) {
      ++c;
    }
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int i,n;
	scanf("%d",&n);
	int num[n];
	for(i=1;i<=n;i++)
		scanf("%d",&num[i]);
	for(i=0;i<n;i++){
		if(i==n-1)
			printf("%d",num[n-i]);
		else
			printf("%d ",num[n-i]);
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 600
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations
    #from itertools import accumulate, product, permutations
    from math import floor, ceil

    #mod = 1000000007

    n,q = map(int, input().split())
    s = input()
    l = [0]*(n+1)
    for i in range(n):
        if s[i]=='A':
          if s[i+1]=='C':
            l[i+1]=l[i] + 1
            continue
        l[i+1]=l[i]

    for _ in range(q):
        a, b = map(int, input().split())
        print(l[b-1]-l[a-1])


if __name__ == '__main__':
    main()

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a,b,k;
    cin>>a>>b>>k;

    for(int i=a;i<a+k&&i<=b;i++){
        cout<<i<<endl;
    }
    for(int i=b-k+1;i<=b;i++){
        if(i<a+k)continue;
        cout<<i<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import numpy as np
x = abs(int(input()))

# case of 98: (n-1)**2<n(n-1)<196<=n(n+1)<(n+1)**2, m=np.floor((2n)**1/2)-1,+1,+2  
# x - m(m-1)/2 until m-1, [x - m(m-1)/2] - m = wait, +add after wait (+1)

n = int(np.floor((2*x)**(1/2)))
m_cand = [n-1,n,n+1,n+2,n+3]


for i in m_cand:
    if (i*(i+1)<=2*x) & ((i+1)*(i+2)>2*x):
        m = i
        break
        
if m*(m+1)/2 == x:
    ans=m
else:
    ans = m+1
print(int(ans))


Measured memory_bytes: 12492
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int m = sc.nextInt();

    int l[] = new int[m];
    int r[] = new int[m];

    for (int i = 0; i < m; i++) {
      l[i] = sc.nextInt();
      r[i] = sc.nextInt();
    }

    int min = l[0];
    int max = r[0];

    for (int i = 1; i < m; i++) {
      min = Math.max(min, l[i]);
      max = Math.min(max, r[i]);
    }

    if (max - min < 0) {
      System.out.println(0);
    } else {
      System.out.println(max - min + 1);
    }
  }
}

Measured memory_bytes: 64748
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <unordered_set>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.begin(), v.end(), greater<int>);
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge{
    int to, cost;
};


int main(){
    int n, a, b;
    cin >> n >> a >> b;
    if(abs(a - b - 1) % 2 == 0){
        cout << "Borys" << endl;
    }else{
        cout << "Alice" << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long A,B,K;
  cin >> A >> B >> K;
  if(K>0){
  if(A>0){
    if(A>K){
      A-=K;
      K=0;
    }else{
      K=K-A;
      A=0;
      
    }
  }
  }
  
  if(K>0){
  if(B>0){
    if(B>K){
      B-=K;
      K=0;
    }else{
      K=K-B;
      B=0;
      
    }
  }
  }
  cout << A << " " << B << endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

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

vector<int> LeastPrimeFactor;
vector<int> primes;
bool isPrime(int x) { return LeastPrimeFactor[x] == x; }
void init(int N=2000000) {
    LeastPrimeFactor.resize(N);
    iota(all(LeastPrimeFactor), 0);
    for (int p = 2; p < N; ++p) {
        if (LeastPrimeFactor[p] != p) continue;
        primes.push_back(p);
        for (int np = 2*p; np < N; np += p) {
            if (LeastPrimeFactor[np] != np) continue;
            LeastPrimeFactor[np] = p;
        }
    }
}

int main() {
    int N;
    cin >> N;
    vl A(N);
    rep(i,N) cin >> A[i];

    int flag_pairwise = true;
    int g = A[0];
    init();
    map<int, int> usedPrimes;
    rep(i,N) {
        ll a = A[i];
        g = gcd(g, a);
        while (a > 1) {
            ll p = LeastPrimeFactor[a];
            if (usedPrimes[p]) flag_pairwise = false;
            usedPrimes[p] = 1;
            while (a % p == 0) a /= p;
        }
    }
    int flag_setwise = (g == 1);
    if (flag_pairwise) {
        cout << "pairwise coprime" << endl;
    } else if (flag_setwise) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }
    return 0;
}


Measured memory_bytes: 22848
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, M;
    cin >> N >> M;
    int K[31], A[31][31];
    int l[31] = {}, ans = 0;
    // N人の人
    for(int i=0;i<N;i++){
       cin >> K[i];
       // K[i]個の回答
       for(int j=0;j<K[i];j++){
           cin >> A[i][j];
           l[A[i][j]]++; 
       }
    }

    for(int i=1;i<=M;i++){
        if(l[i] == N)
            ans++;
    }

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

Measured memory_bytes: 256
n = int(input())
b = [int(i) for i in input().split()]
flag = True
for i in range(n):
    if b[i] > i+1:
        flag = False
        break

if not flag:
    print(-1)
else:
    ans = []
    while len(b) > 0:
        for m in range(max(b), 0, -1):
            if b[m-1] == m:
                ans.append(b[m-1])
                del b[m-1]
                break
    ans = ans[::-1]
    print(*ans, sep="\n")


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    char c;
    int i=0;
    while(~scanf("%c",&c)&&c!='\n')
    {
        if(i%2==0)
        cout<<c;
        i++;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
(let ((k (parse-integer (format nil "~A~A" (read) (read)))))
  (defun lp (n)
    (cond ((< (* n n) k) (lp (1+ n)))
          ((= (* n n) k) (princ "Yes"))
          ((> (* n n) k) (princ "No"))))
  (lp 1))

Measured memory_bytes: 12772
#include <stdio.h>
int main(void)


{
	int a, b, i, max, min;
	long sum;
	sum = 0;
	scanf("%d", &a);
	for (i = 0;i < a;i++)
	{
		scanf("%d", &b);
		sum = sum + b;
		if (i == 0)
		{
			min = b;
			max = b;
		}
		if (b < min)
		{
			min = b;
		}
		if (b > max)
		{	
			max = b;
		}
	}
	printf("%d %d %ld\n",min, max, sum);
	return 0;
}

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

int main(){
  
 //入力
  string S;
  cin >> S;
  
 //処理
  string T="ATCG";
  
  int ans = 0;
  for(int i = 0; i < S.size() ; i++){
    
    //iは開始地点
    int now = 0;
    for(int j = i; j < S.size() ; j++){
      
      //j文字目まではATCGであるかチェック
       bool ok = false;
       for(int k = 0; k < T.size() ; k++){
         
         if(S[j] == T[k]) ok = true;
       }
      
       if(ok){
         //j文字目がATCG文字なら,i文字目からj文字目がATCG文字列である。
         now++;
         ans = max(ans,now);
       }
      
      else{
        //j文字目がATCG文字列でないならこれ以上i文字目から始まるATCG文字列は作れない
        break;
      }
      
    }
  }
  
  cout << ans << endl;
      
      
      
  
}

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

int main() {
	int64_t n;
	cin >> n;
	vector<int64_t> b(n+1),d(n+1),e(n+1);
	vector<int64_t> c(n+1,-1);
	vector<int64_t> a(n);
	for(auto &i:a) cin >> i;
	for(auto i:a) b.at(i)++;
	for(auto i:a) c.at(i)++;
	int64_t sum{};
	for(int64_t i=1; i<=n; i++){
		d.at(i)= b.at(i)*(b.at(i)-1)/2;
		sum += d.at(i);
		e.at(i) = c.at(i)*(c.at(i)-1)/2;
	}
	for(int64_t i=0; i<n; i++){
		if(b.at(a.at(i))<2) cout << sum << endl;
		else cout << sum - d.at(a.at(i)) + e.at(a.at(i)) << endl;
		
	}
}

Measured memory_bytes: 10368