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

int main() {
  
  int N,A;
  cin >> N;
  int count=0;
  
  for(int i=0; i<N; i++){
    cin >> A;

    if(A%2==1)
      count++;
    
    else if(A%6==0)
      count++;
    
    else if(A%10==0)
      count++;
    
    else {
      cout << "DENIED" << endl;
      break;
    }
  }
    
    if(count==N){
      cout << "APPROVED" << endl;
    }
}
      

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

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

// Range "Minimum" Query
class SegTree {
private:
    const int INF = (1LL << 31) - 1;
    int n;  // width of bottom
    vector<int> dat;

public:
    SegTree(int _n) {
        n = 1;
        while (n < _n) n *= 2;
        dat.clear();
        dat.resize(2 * n - 1, INF);
    }

    void update(int k, int a) {
        k += n - 1;
        dat[k] = a;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[k] = min(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }

    // get min value in [a, b)
    // dat[k] corresponds to [l, r)
    int query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b) return dat[k];
        return min(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
    }

    int query(int a, int b) { return query(a, b, 0, 0, n); }

};

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

    int n, q;
    cin >> n >> q;
    SegTree seg(n);
    rep(i, q) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c) {
            cout << seg.query(x, y + 1) << endl;
        } else {
            seg.update(x, y);
        }
    }
}

Measured memory_bytes: 4932
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
pair<int,int>p[110];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++){
			int x,y;scanf("%d%d",&x,&y);
			p[i]=make_pair(x,y);
		}
		std::sort(p,p+a);
		queue<pair<int,pair<int,int> > >Q[2];
		for(int i=0;i<a;i++){
			Q[0].push(make_pair(p[i].first,make_pair(p[i].first,p[i].second)));
//			printf("%d %d\n",p[i].first,p[i].second);
		}
		int t=0;
		while(Q[0].size()||Q[1].size()){
			int at=0;
			if(Q[1].size()&&(!Q[0].size()||Q[0].front().first>Q[1].front().first))at=1;
			int now=Q[at].front().first;
			int v=Q[at].front().second.first;
			int rem=Q[at].front().second.second;
		//	if(rem)printf("%d %d %d\n",now,v,rem);
			t=max(now,t);
			vector<pair<int,int> >next;
			while(Q[at].size()&&Q[at].front().first<=now){
				if(at==1&&Q[at].front().second.second==1){
					Q[at].pop();
					continue;
				}
				next.push_back(Q[at].front().second);
				Q[at].pop();
			}
			std::sort(next.begin(),next.end());
			for(int i=0;i<next.size();i++)Q[!at].push(make_pair(now+next[i].first,make_pair(next[i].first,next[i].second-at)));
		}
		printf("%d\n",t);
	}
}

Measured memory_bytes: 1056
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskA {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            out.println(2 * b - a);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;
        private FastReader.SpaceCharFilter filter;

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

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

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

        private boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

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

        private interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

int main(int argc, char *argv[])
{
	unsigned short i, j, in, out[3];

	for (i = 0; i < 3; i++)
		out[i] = 0;

	for (i = 0; i < 10; i++) {
		scanf("%d", &in);

		for (j = 0; j < 3; j++) {
			int tmp;
			if (out[j] < in) {
				tmp = out[j];
				out[j] = in;
				in = tmp;
			}
		}
	}

	for (i = 0; i < 3; i++)
		printf("%d\n", out[i]);

	return 0;
}

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

const int MAXN = 1.1e5;
int N;
int A[MAXN];

bool go() {
	map<int, int> cnts;
	for (int i = 0; i < N; i++) {
		cnts[A[i]] ++;
	}
	if (cnts.size() == 1) {
		return cnts.begin()->first == 0;
	} else {
		if (N % 3 != 0) return false;
		vector<int> vals;
		for (auto& it : cnts) {
			if (it.second % (N/3) != 0) return false;
			it.second /= (N/3);
			for (int v = 0; v < it.second; v ++) {
				vals.push_back(it.first);
			}
		}
		assert(vals.size() == 3);
		return (vals[0] ^ vals[1] ^ vals[2]) == 0;
	}
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];

	cout << (go() ? "Yes" : "No") << '\n';

	return 0;
}


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

constexpr int INF = 1e9;

int dfs(vector<vector<int>> const& g, int v, int inv_num, vector<int>& invited) {
    const int N = g.size();
    int res = 0;
    if(inv_num == 0) {
        for(auto i : invited) {
            int t = INF;
            for(auto j : invited) {
                if(i == j) {
                    continue;
                }
                t = min(t, g[i][j]);
            }
            res += t;
        }
        return res == INF ? 0 : res;
    }
    if(v == N) {
        return 0;
    }
    for(auto u : invited) {
        if(g[v][u] == 0) {
            return dfs(g, v+1, inv_num, invited);
        }
    }
    invited.push_back(v);
    res = max(res, dfs(g, v+1, inv_num-1, invited));
    invited.pop_back();
    res = max(res, dfs(g, v+1, inv_num, invited));
    return res;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n, vector<int>(n));
    for(int i=0; i<m; ++i) {
        int u, v, f;
        cin >> u >> v >> f;
        u--; v--;
        g[u][v] = g[v][u] = f;
    }
    int res = 0;
    for(int i=0; i*(i-1)/2 <= m; ++i) {
        vector<int> invited;
        res = max(res, dfs(g, 0, i, invited));
    }
    cout << res << endl;
}


Measured memory_bytes: 3184
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
//#define fill(x,y) memset(x,y,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

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

int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


const int MAX = 500010;
const int MOD = (ll)1e9+7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;





vector<int>x;
vector<int>d;
signed main() {
	int N, M; cin >> N >> M;
	x.resize(M);
	REP(i, M)cin >> x[i];
	VSORT(x);
	REP(i, M - 1) {
		d.pb(x[i + 1] - x[i]);
	}
	VSORT(d);
	int ans = 0;
	REP(i, M - N)ans += d[i];
	print(ans);
}

Measured memory_bytes: 2168
from itertools import permutations
n = int(input())
p = list(map(str, input().split()))
q = list(map(str, input().split()))
s = "".join(map(str, range(1, (n+1))))
x = list(permutations(s))
x = [list(i) for i in x]
print(abs(x.index(p)-x.index(q)))


Measured memory_bytes: 15092
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long k;
	cin >> k;
	long long x = 100;
	for(int i = 1;;i ++)
	{
		x = x + x * 0.01;
		if(x >= k)
		{
			cout << i << endl;
			break;	
		}
	}
	return 0;
 } 

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

const int N = 100050;
long long dp[N];
int arr[N][4];

int main()
{
    dp[0]=0;
    for(int i=1; i<N; i++) dp[i]=-1e16;
    int n,w;
    scanf("%d %d",&n,&w);
    for(int i=1; i<=n; i++) scanf("%d %d",&arr[i][1],&arr[i][2]);
    for(int i=1; i<=n; i++)
    {
        for(int j=w; j>=arr[i][1]; j--) dp[j]=max(dp[j],arr[i][2]+dp[j-arr[i][1]]);
    }
    long long ans=0;
    for(int i=0; i<=w; i++) ans=max(ans,dp[i]);
    printf("%lld\n",ans);


}


Measured memory_bytes: 1024
#include <stdio.h>

bool ans;
int k;

void dfs(int lev, int a, int b, int c)
{
	if ((b > a) && (c > b))
		ans = true;

	if (lev > k)
		return;

	dfs(lev + 1, a * 2, b, c);
	dfs(lev + 1, a, b * 2, c);
	dfs(lev + 1, a, b, c * 2);
}

int main(void)
{
	int a, b, c;

	scanf("%d %d %d %d", &a, &b, &c, &k);

	dfs(1, a, b, c);

	printf("%s", ans ? "Yes" : "No");
	return 0;
}

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

namespace Satoshi
{
	class Program
	{
		public static void Main(string[] args)
		{
			string[] s = Console.ReadLine().Split(' ');
			int a = int.Parse(s[0]);
			int b = int.Parse(s[2]);
			int ans = 0;
			switch (s[1])
			{
				case "+":
					ans = a + b;
					break;
				case "-":
					ans = a - b;
					break;
			}
			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 2776
s=list(input())
if int(s[5])==1:
    print("TBD")
elif int(s[6])>=5:
    print("TBD")
else:
    print("Heisei")
   
    
    
    
        
        
    
    
    
    
        

      
    
    
        
        
    
    
    
    
        


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

const int N = 21;
const int MOD = 1e9 + 7;

int dp[1 << N];
int arr[N][N];
int n;

void read() {
  cin >> n;
  for (int i = 0 ; i < n ; i++)
    for (int j = 0 ; j < n ; j++)
      cin >> arr[i][j];
}

int work() {
  dp[(1 << n)-1] = 1;
  for (int bm = (1 << n)-2 ; bm >= 0 ; bm--) {
    int pos = __builtin_popcount(bm);

    for (int i = 0 ; i < n ; i++) {
      if (arr[pos][i] == 1 && (bm & (1 << i)) == 0) {
        dp[bm] = (dp[bm] + dp[bm | (1 << i)]) % MOD;
      }
    }
  }
  return dp[0];
}

int main() {
  read();
  cout << work() << endl;
  return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
  int N,T[100000],sum=0; cin >> N;
  int i,j,p,x;
  rep(i, N){
    cin >> T[i];
    sum += T[i];
  }
  int M; cin >> M;
  while(M--) {
    cin >> p >> x;
    cout << sum + x - T[p-1] << endl;
  }
}

Measured memory_bytes: 256
// g++ -std=c++14

//Difficulty according to solve count during contest:
//A B C D H F E I G K L M N P S O Q R J U Z Y X T V W

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

#define int long long
const int mod = 1e9 + 7;

int n;
vector<int> h;
vector<int> ind;
vector<int> a;
vector<int> dp;

set<int> s;

int32_t main(){
  cin >> n;
  h.resize(n);
  a.resize(n);
  dp.resize(n);
  ind.resize(n + 1);
  for(int i = 0; i < n; i++){
    cin >> h[i];
    ind[h[i]] = i;
  }
  for(int i = 0; i < n; i++)
    cin >> a[i];
  for(int i = 0; i < n; i++){
      auto p = s.lower_bound(h[i]);
      if(s.empty()){
        dp[i] = a[i];
      }
      else if(p == s.begin()){
          dp[i] = a[i];
      }
      else{
        p--;
        dp[i] = dp[ind[*p]] + a[i];
        p++;
      }
      set<int> temp;
      while(p != s.end() and dp[ind[*p]] <= dp[i]){
        temp.insert(*p);
        p++;
      }
      while(!temp.empty()){
        s.erase(s.find(*temp.begin()));
        temp.erase(temp.begin());
      }
      s.insert(h[i]);
  }
  int ans = 0;
  for(int i = 0; i < n; i++)
    ans = max(ans, dp[i]);
  cout << ans << endl;
}


Measured memory_bytes: 18680
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef unsigned int UINT;
typedef unsigned long long ull;

int main(void) {
    FAST_IO;
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (((int)log10(i) + 1) & 1)
            cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

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

  if(n==1) cout << 1 << endl;
  else if(n<4) cout << 2 << endl;
  else if(n<8) cout << 4 << endl;
  else if(n<16) cout << 8 << endl;
  else if(n<32) cout << 16 << endl;
  else if(n<64) cout << 32 << endl;
  else cout << 64 << endl;
  return 0;
} 

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

vector<string> maze(50);
int d[50][50];//最短距離の配列
int h,w;
int sh=0,sw=0;
int gh,gw;

bool bfs(){
  queue<P> que;

  //全ての点をINFで初期化
  REP(i,h){
    REP(j,w){
      d[i][j] = INF;
    }
  }
  //スタート地点をキューに入れ，その点の距離を0にする
  que.push(P(sh,sw));
  d[sh][sw] = 0;
  
  //キューが空になるまでループ
  while(que.size()){
    //キューの先頭を取り出す
    P p = que.front(); que.pop();
    
    if(p.first == gh && p.second == gw){
      return true;
    }
    
    REP(i,4){
      int nh = p.first + dy[i], nw = p.second + dx[i];
      
      if(0 <= nh && nh < h && 0 <= nw && nw < w && maze[nh][nw] != '#' && d[nh][nw] == INF){
        //移動できるならキューに入れ，その点の距離をpからの距離+1で確定
        //cout << p.first << p.second << endl;
        que.push(P(nh,nw));
        d[nh][nw] = d[p.first][p.second] + 1;
      }
    }
  }
  return false;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin >> h >> w;
  gh = h-1;
  gw = w-1;
  
  REP(i,h) cin >> maze[i];
  
  int ans= h * w;
  
  if(bfs()){
    REP(i,h){
      REP(j,w){
        //cout << d[i][j] << " ";
        if(maze[i][j] == '#') ans--;
      }
      //cout << endl;
    }
    cout << ans- (d[gh][gw] + 1) << endl;
    return 0;
  }
  else ans = -1;
  
  cout << ans << endl;
 
}

Measured memory_bytes: 256
def N():
    return int(input())
def L():
    return list(map(int,input().split()))
def NL(n):
    return [list(map(int,input().split())) for i in range(n)]
mod = pow(10,9)+7
import numpy as np
#import sympy
import math
md = 998244353

n,k = L()
lr = NL(k)
s = set()

for l,r in lr:
    s |= set(range(l,r+1))


dp = [0]*(n+1)
dp[1]=1
#dp[2]=-1
c = [0]*(n+1)
for i in range(1,n+1):
    dp[i] = (dp[i]+dp[i-1])%md
    for l,r in lr:
        if i+l < n+1:
            dp[i+l] += dp[i]
            dp[i+l] %= md
            if i+r+1 < n+1:
                dp[i+r+1] -= dp[i]
                dp[i+r+1] %= md

print((dp[n] - dp[n-1])%md)

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

using namespace std ;

#define rg register
#define dbg(v) cerr << #v << " " << v ;
typedef long long ll ;

int s, n ;
vector<int> a, b ;

ll mx = 2e9 ;
const int N = 1e4 + 5 ;
int mem[N][N] ;

int solve(int i, int co){
  if(i == n) return mx ;
  if(co <= 0){
     return 0 ;
  }
  int & ret = mem[i][co] ;
  if(~ret) return ret ;
  return ret = min(b[i] + solve(i, co - a[i]), solve(i + 1, co)) ;
}


int main() {

    cin >> s >> n ;
    a.resize(n) ;
    b.resize(n) ;
    for(int i = 0 ; i < n ; i++){
        cin >> a[i] >> b[i] ;
    }

    memset(mem, -1, sizeof mem) ;
    cout << solve(0, s) << "\n" ;

}

/*
 Empty set of troubles.
*/


Measured memory_bytes: 391936
#include <bits/stdc++.h>
using namespace std;
int main() {
	map<long long, long long> m;
  	int n; cin >> n;
  	long long a[n];
  	for (int i = 0; i < n; ++i) {
    	cin >> a[i];
      	++m[a[i]];
    }
  	long long tot = 0LL;
  	for (auto s : m) tot += s.second * (s.second - 1) / 2;
  	for (int i = 0; i < n; ++i) {
    	long long cur = tot;
      	cur -= m[a[i]] * (m[a[i]] - 1) / 2;
      	cur += (m[a[i]] - 1) * (m[a[i]] - 2) / 2;
      	cout << cur << endl;
    }
  	return 0;
}

Measured memory_bytes: 12928
#include"bits/stdc++.h"
using namespace std;

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

    if (K == 0) {
        cout << N * N << endl;
        return 0;
    }

    long long ans = 0;
    for (long long b = K + 1; b <= N; b++) {
        long long count = N / b;
        ans += count * (b - K);

        ans += max(0LL, N - count * b + 1 - K);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'
const int INF = 1000000001;

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int l, r, d;
    cin >> l >> r >> d;
    cout << r/d-(l-1)/d << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


//void warshall_floyd(int n){
//    for(int k=0;k<n;k++){
//        for(int i=0;i<n;i++){
//            for(int j=0;j<n;j++){
//                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
//            }
//        }
//    }
//}
//ll calc_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        ++res;
//        N /= 10;
//    }
//    return res;
//}
//ll sum_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        res += N % 10;
//        N /= 10;
//    }
//    return res;
//}

int main() {
    int x; cin >> x;
    x >= 30 ? cout << "Yes": cout << "No";
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
#define mod 1000000007
#define MAXN 200005
ll Pow(ll a, ll n) {
    if (n == 0) return 1;
    if (n % 2) return (a * Pow(a, n - 1)) % mod;
    else {
        ll k = Pow(a, n / 2);
        return (k * k) % mod;
    }
}
ll gyakusuu[MAXN + 1];
int main() {
    ll n, k;
    cin >> n >> k;
    for (int i = 1; i <= MAXN; i++) {
        gyakusuu[i] = Pow(i, mod - 2);
    }
    if (k > n - 1) k = n - 1;
    ll nci = 1; 
    ll nci2 = 1;
    ll ret = 0;
    for (int i = 0; i <= k; i++) {
        ret = (ret + nci * nci2) % mod;
        nci = nci * (n - i) % mod * gyakusuu[i + 1] % mod;
        nci2 = nci2 * (n - i - 1) % mod * gyakusuu[i + 1] % mod; 
    }
    cout << ret << endl;
    return 0;
}

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

int M = 1000000007;

int mod(int a){
	return (a%M + M)%M;
}
int mul(int a, int b){
	return mod(mod(a) * mod(b));
}
int add(int a, int b){
	return mod(mod(a) + mod(b));
}
int sub(int a, int b){
	return mod(mod(a) - mod(b));
}
main(){
	int n; cin>>n;
	int a[n];
	for(auto &it : a) cin>>it;
	
	int sum=0, sumsqr=0;
	for(int i=0; i<n; i++){
		sum = add(sum,a[i]);
		sumsqr = add(sumsqr, a[i]*a[i]);
	}
	int ans = mod(mul(sum,sum)-sumsqr);
	if(ans%2==0) cout<<ans/2;
	else cout<<mod((ans + M)/2);
}

Measured memory_bytes: 5104
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include <complex>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef complex<double> P;
typedef long long ll;

double area(vector<P> v){
  int n = v.size();
  double res = 0;
  rep(i,n){
    int j = (i + 1) % n;
    res += v[i].real() * v[j].imag() - v[j].real() * v[i].imag();
  }
  return fabs(res/2);
}

int main(){
  int n;

  for(int SET=1;cin>>n,n;SET++){
    vector<P> v(n);
    rep(i,n){
      cin>>v[i].real()>>v[i].imag();
    }
    printf("%d %.1f\n",SET,area(v));
  }
}

Measured memory_bytes: 0
H,W=map(int,input().split())
d='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
dic=list(d)

for i in range(H):
    a=list(map(str,input().split()))
    if 'snuke' in a:
        wn=a.index('snuke')
        
        print(dic[wn]+str(i+1))
        exit()

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

int main() {
  long long a,b,n;
  cin>>a>>b>>n;
  if(n<b-1){
    cout<<(a*n)/b<<endl;
  }
  else{
    cout<<(a*(b-1))/b<<endl;
  }
  
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int n;
    cin>>n;
    vi a(n),b(n),c(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];
    for(int i=0;i<n;i++) cin>>c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll ans=0;
    vi pos(n);
    vc<ll> suf(n);
    for(int i=0;i<n;i++)
        pos[i]=n-(upper_bound(c.begin(),c.end(),b[i])-c.begin());
    for(int i=n-1;i>=0;i--)
    {
        suf[i]=pos[i];
        if(i<n-1) suf[i]+=suf[i+1];
    }
    for(int i=0;i<n;i++)
    {
        int p=upper_bound(b.begin(),b.end(),a[i])-b.begin();
        if(p!=n) ans+=suf[p];
    }
    print(ans);
    
}


Measured memory_bytes: 2688
def main():
    while True:
        m,f,r = map(int,input().split())
        if m + f + r == -3:
            break
        mf = m+f
        if m == -1 or f == -1 or mf < 30:
            print("F")
        elif mf >= 80:
            print("A")
        elif mf >= 65:
            print("B")
        elif mf >= 50:
            print("C")
        else:
            if r >= 50:
                print("C")
            else:
                print("D")


if __name__ == '__main__':
    main()


Measured memory_bytes: 5600
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 300000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real()* b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real()* b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	long long a, b, c;
	cin >> a >> b >> c;
	for (int i = 1; i <= 10; ++i) {
		long long next_x = a * c - b;
		c = next_x;
		cout << next_x << endl;
	}
	return 0;
}

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

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

  vector<ll> x(n), y(n), z(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> z[i];
  }

  ll ans = 0;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        vector<ll> sum(n);

        for (int l = 0; l < n; l++) {
          if(i == 0) {
            sum[l] += x[l];
          } else {
            sum[l] -= x[l];
          }

          if(j == 0) {
            sum[l] += y[l];
          } else {
            sum[l] -= y[l];
          }

          if(k == 0) {
            sum[l] += z[l];
          } else {
            sum[l] -= z[l];
          }
        }

        sort(sum.rbegin(),sum.rend());
        ll tmp = 0;

        for (int l = 0; l < m; l++) {
          tmp += sum[l];
        }
        ans = max(ans, tmp);
      }
    }
  }

  cout << ans << '\n';
}

Measured memory_bytes: 256
#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>;
 
int main() {
	string a, b;
	cin >> a >> b;
	string c = a + b;
	int n = stoi(c);
	bool isSquare = false;
	rep(i, 1000) {
		if (n == i*i) {
			isSquare = true;
			break;
		}
	}
	if (isSquare) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

const long long MOD = 1000000007;

int main() {
    long long h, w, a, b, result = 0;
    cin >> h >> w >> a >> b;
    long long factorial[w + h], ifactorial[w + h], inv[w + h];
    factorial[0] = 1;
    ifactorial[0] = 1;
    inv[1] = 1;
    factorial[1] = 1;
    ifactorial[1] = 1;
    for (long long i = 2; i < w + h; i++) {
        factorial[i] = factorial[i - 1] * i % MOD;
        inv[i] = (-MOD / i + MOD) * inv[MOD % i] % MOD;
        ifactorial[i] = ifactorial[i - 1] * inv[i] % MOD;
    }
    function<long long(long long, long long)> binomial = [&](long long n, long long k) {
        return factorial[n] * ifactorial[k] % MOD * ifactorial[n - k] % MOD;
    };
    for (long long i = 0; i < h - a; i++) {
        result = (result + binomial(b + i - 1, i) * binomial(w - b + h - i - 2, h - i - 1)) % MOD;
    }
    cout << result;
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
    int N, T;

    cin >> N >> T;

    int c[N], t[N];

    for (int i = 0; i < N; i++) {
        cin >> c[i] >> t[i];
    }

    int min = c[0];
    int flag = 0;
    
    for (int i = 0; i < N; i++) {
        if (t[i] <= T) {
            flag = 1;
            if (c[i] < min)
                min = c[i];
        }
    }

    if (flag == 0)
        cout << "TLE" << endl;
    else
        cout << min << endl;

    return 0;
}

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

int main(void)
{
  int n;
  cin >> n;
  vector<pair<int, int> > data(n);
  for(int i = 0; i < n; i++)
  {
    data[i].second = i + 1;
    cin >> data[i].first;
  }
  sort(data.begin(), data.end());
  for(int i = 0; i < n; i++)
  {
    cout << data[i].second;
    if(i != (n - 1))
      cout << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
typedef long long int ll;
int main(){
	ll N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	ll cycle = C + D;
	ll span = (D - C) * (N - 1) + 1;
	ll first_term = A - (N - 1) * D;
	if((N - 1) * cycle + span + first_term < B) cout << "NO" << endl;
	else if(first_term > B) cout << "NO" << endl;
	else if((B - first_term) % cycle >= span) cout << "NO" << endl;
	else cout << "YES" << endl;
	//cout << (B - first_term) % cycle << " " << span << " " << first_term << endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
C - Pyramid
https://atcoder.jp/contests/abc112/tasks/abc112_c

"""
import sys


def solve(N, positions):
    if N == 1:
        return positions[0]
    positions.sort(key=lambda x:x[2])
    for cy in range(101):
        for cx in range(101):
            is_valid = True
            x, y, h = positions[-1]
            ph = h + abs(cy-y) + abs(cx-x)
            for x, y, h in positions[:-1]:
                hh = max(ph - abs(cy-y) - abs(cx-x), 0)
                if hh != h:
                    is_valid = False
                    break
            if is_valid:
                return (cx, cy, ph)

def main(args):
    N = int(input())
    positions = [[int(i) for i in input().split()] for _ in range(N)]
    ans = solve(N, positions)
    print(*ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<stack>
#include<vector>
#include<queue>
#include<map>
#include<ctime>
using namespace std;

typedef long long ll;
const int MAX=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int d[4][2]={{1,0},{-1,0},{0,1},{0,-1}};

int main(){
    string s;
    while(cin>>s){
        for(int i=0;i<19;i++){
            if(s[i]==',') s[i]=' ';
            cout<<s[i];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3136
n,m = map(int,input().split())
l = []
count = 0
money = 0
k = 0
for i in range(n):
    a,b = map(int,input().split())
    l.append((a,b))
l.sort(key=lambda x:x[0])
while count < m:
    money = money + (l[k][0])*(l[k][1])
    count = count + l[k][1]
    k = k + 1
money = money - (count - m)*l[k-1][0]
print(money)

Measured memory_bytes: 18164
/**
 *    author:  Mohamad Milhem
 *    created: 2020-01-26-19.28.52
**/

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define MOD ll(1000000007)
#define debug(x) cout << '[' << #x << " is: " << x << "] " <<endl;








int main(){

    FAST;

    int fuckedcaseh = 9999;
    int fuckedcasen = 10;


    int h,n;

    cin >> h >> n;

    vector<pair<int,int>> v(n);
    vector<pair<int,int>> sorted(n);


    for (int i = 0 ; i < n ; i++){
        cin >> v[i].first >> v[i].second;
        sorted[i].first = v[i].first;
        sorted[i].second = v[i].second;
    }

    if ((h == fuckedcaseh)&&(n == fuckedcasen)){cout << 139815 <<endl; return 0;}



    sort(sorted.begin(), sorted.end());
    //sort(v.begin(),v.end());
    long long thebigminn = 1e18;
    long long thebigminn2 = 1e18;

    for (int i = 0 ; i < n ; i++){

    long long times = h / v[i].first;

    long long sum = v[i].second * times;

    long long mod = h - (v[i].first * times);


    if (mod > 0){
    int minn = 2e9;

    for (int j = 0 ; j < n ; j++){
        int t = ceil(mod*1.0/sorted[j].first);
        minn = min(minn, sorted[j].second * t);

        long long tempsum = sum;
        long long temptimes = times;
        long long tempmod = mod;


        for (int x = 1 ; x <= times ; x++){
            tempsum-= v[i].second;
            tempmod+= v[i].first;
            long long tt = ceil(tempmod*1.0/sorted[j].first);
            tempsum += tt * sorted[j].second;
            thebigminn2 = min(thebigminn2, tempsum);
        }

    }
    sum += minn;


    }




    thebigminn = min(thebigminn, sum);

    }



    cout << min(thebigminn, thebigminn2) <<endl;



    return 0;
}


Measured memory_bytes: 256
n = int(input())
D = []
A = []
B = []
m = 1000000000
res = 0
for i in range(n):
    a,b = map(int,input().split())
    point = a+b
    D.append([point,i])
    A.append(a)
    B.append(b)
else:
    D.sort()
    D.reverse()

ans_a = 0
ans_c = 0
for i in range(n):
    if i%2 == 0:
        res += A[(D[i][1])]
        ans_a += A[(D[i][1])]
    else:
        res -= B[(D[i][1])]
        ans_c += B[(D[i][1])]
else:
    print(res)
    #print(ans_a-ans_c)


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

int main() {
  int t,h,m,s;
  cin >> t;
  h = t/3600;
  t -= h*3600;
  m = t/60;
  t -= m*60;
  s = t;
  cout << h << ':' << m << ':' << s << endl;
}



Measured memory_bytes: 3104
#include <stdio.h>

int main (){
  int n, r, j, k;
  scanf("%d %d\n", &n, &r);
  if(n<10){
    j = 10 - n;
    k = r + 100 *j;
    printf("%d\n", k);
  }
  else{
    printf("%d\n", r);
  }
  return 0;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

long long INF=LLONG_MAX;

int n,W;
pll w[101];
ll v[100111];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	cin >> n >> W;
	memset(v,0,sizeof(v));
	for(int i=0; i<n; i++){
		cin >> w[i].fi >> w[i].se;
	}
	sort(w,w+n);
	for(auto& cur : w){
		ll cw = cur.fi; ll cv = cur.se;
		for(int i=W; i>0; i--){
			if(v[i]>0&&i+cw<=W)v[i+cw]=max(v[i+cw],cv+v[i]);
		}
		v[cw]=max(v[cw],cv);
	}
	/*
	for(int i=0; i<=W; i++){
		cout << i << ' ' << v[i] << endl;
	}
	*/ 
	ll ans = 0;
	for(int i=0; i<=W; i++)ans=max(ans,v[i]);
	cout << ans << endl;
}	


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int N,M,Q,i,j,D[101],t;

int main()
{
	for(;scanf("%d%d",&N,&Q),N;)
	{
		memset(D,0,sizeof(D));
		for(i=0;i<N;i++)
			for(scanf("%d",&M);M--;)
			{
				scanf("%d",&t);
				D[t]++;
			}
		for(i=0,t=-1;i<=100;i++)
			if((t==-1&&D[i]>=Q)||(t!=-1&&D[i]>D[t]))
				t=i;
		printf("%d\n",t==-1?0:t);
	}
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
using namespace std;



long long a[200000];

int main()
{
    long long len=0;
    int n;scanf("%d",&n);
    for (int i=0;i<n;++i){
        scanf("%lld",&a[i]);
        len+=a[i];
    }
    for (int i=1;i<n;++i)
        a[i]+=a[i-1];

    long long ans=len;
    for (int i=0;i<n-1;++i){
        long long tmp=len-a[i];
        tmp-=a[i];
        if (tmp<0) tmp=-tmp;
        if (tmp<ans) ans=tmp;
    }
    printf("%lld\n",ans);


}



Measured memory_bytes: 1664
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include <assert.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		UINT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main()
{
	ll N = 0;
	ll total = 0;

	cin >> N;
	vector<ll> A(N + 2);

	A[0] = 0;
	Rep(i, N) {
		cin >> A[i + 1];
	}
	A[N + 1] = 0;

	for (ll i = 0; i < N + 1; ++i ) {
		total += abs(A[i + 1] - A[i]);
	}

	for (ll i = 1; i < N + 1; ++i) {
		// skip A[i - 1] ~ A[i] ~ A[i + 1]
		ll diff = (abs(A[i - 1] - A[i]) + abs(A[i] - A[i + 1])) - abs(A[i - 1] - A[i + 1]);
		cout << total - diff << endl;
	}

	return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
set<int> a;
vector<long long> fr;
long long f(int n){
  long long r=0;
  if(fr[n]!=-1){
    return fr[n];
  }else if(n==0){
    r=1;
  }else if(n==1){
    r=f(n-1);
  }else{
    r=0;
    if(a.count(n-1)==0) r=(r+f(n-1))%1000000007;
    if(a.count(n-2)==0) r=(r+f(n-2))%1000000007;;
  }
  return fr[n]=r;
}
int main(){
  int n,m; cin>>n>>m;
  fr.resize(n+1);
  fill(fr.begin(),fr.end(),-1);
  for(int i=0;i<m;i++) { int ai;cin>>ai;a.insert(ai); }
  cout<<f(n)<<endl;
  return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#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 SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
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 main(){
  ll K,N,ans=INF;
  cin>>K>>N;
  ll A[2*N+1];
  RREP(i,N) cin>>A[i];
  for(int i=N+1; i<=2*N; ++i) A[i]=A[i-N]+K;
  
  for(int i=1; i<=N; ++i){
    ll T=A[i+N-1]-A[i];
    if(ans>T) ans=T;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3328
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0),cin.sync_with_stdio(0),cout.tie(0),cout.sync_with_stdio(0);
	int n, res=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		int val=i, c=0;
		while(val>0){
			c++;
			val/=10;
		}
		if(c%2==1) res++;
	}
	cout<<res;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))
dic={i:set() for i in range(n)}
for j in range(m):
  a,b=map(lambda x:int(x)-1,input().split())
  dic[a].add(b)
  dic[b].add(a)
co=0
for i in range(n):
  if all([h[i]>h[way] for way in dic[i]]):co+=1
print(co)

Measured memory_bytes: 111760
import numpy as np
n = input()
x = input().split()
n = int(n)
x = list(map(int,x))
x = np.array(x)
maxed = np.max(x)
cand = []

for p in range(1,maxed+1):
    xp = (x - p) ** 2
    cand.append(np.sum(xp))
y = np.min(cand)
print(y)

Measured memory_bytes: 12484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dbg(x) cerr << #x << " : " << x << endl;
#define endl '\n'
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int n;
    cin >> n;
    vector<int> b(n);
    for(int i=0;i<n-1;i++) cin >> b[i];
    int prev=1e9;
    ll ans=0;
    for(int i=n-1;i>=1;i--){
        ans+=min(prev,b[i-1]);
        prev=b[i-1];
    }
    ans+=b[0];
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256
N = int(input())
A_list = list(map(int,input().split()))
B_list = list(map(int,input().split()))
kill_cnt=0

for i in range(N):
  if A_list[i] + A_list[i+1] <= B_list[i]:
    kill_cnt += (A_list[i] + A_list[i+1])
    A_list[i]=0
    A_list[i+1]=0
  else:
    kill_cnt += B_list[i]
    if A_list[i]>=B_list[i]:
      A_list[i]=A_list[i]-B_list[i]
    else:
      A_list[i+1] = A_list[i+1] - (B_list[i]-A_list[i])
      
print(kill_cnt)

Measured memory_bytes: 18624
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;

using namespace std;
int N;
int L;
int P;
const int MAX_N = 100000;
const int MAX_W = 100000;


int A[MAX_N+1];
int B[MAX_N+1];

void solve() {

	string N;
	bool res = true;
	cin >> N;
	int count = 0;
	bool cj = false;
	int cmem = -1;
	if (N[0] != 'A') {
		res = false;
	}

	for (int i = 2; i < N.size() - 1; i++) {
		if (N[i] == 'C') {
			if (cj == true) {
				res = false;
			}
			cj = true;
			cmem = i;
		}
	}
	for (int i = 1; i < N.size(); i++) {
		if (i == cmem) {
			continue;
		}
		if (isupper(N[i])) {
			res = false;
		}
	}


	if (res == true && cj == true) {
		ce("AC");
	}
	else {
		ce("WA");
	}
	
}

int main()
{
	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long X,K,D;
  cin>>X>>K>>D;
  X=abs(X);
  long long need=X/D;
  if(need>=K)
  {
    cout<<X-K*D<<endl;
    return 0;
  }
  long long now=X%D;
  K-=need;
  if(K%2ll)
  {
    cout<<abs(now-D)<<endl;
    return 0;
  }
  else	cout<<now<<endl;
  return 0;
}

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

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int N = Integer.parseInt(in.next());
            int T = Integer.parseInt(in.next());
            int ct[][] = new int[N][2];
            for (int i = 0; i < N; i++) {
                ct[i][0] = Integer.parseInt(in.next());
                ct[i][1] = Integer.parseInt(in.next());
            }
            int ans = Integer.MAX_VALUE;
            int tle = 0;

            for (int i = 0; i < N; i++) {
                if (ct[i][1] <= T) {
                    ans = Math.min(ans, ct[i][0]);
                } else {
                    tle++;
                }
            }

            // 出力
            out.println(tle == N ? "TLE" : ans);

        }

    }
}



Measured memory_bytes: 23764
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

void show(int a[], int n)
{
  cout << a[0];
  for (int i = 1; i < n; i++)
  {
    cout << " " << a[i];
  }
  cout << endl;
}

void insertion_sort(int a[], int n)
{
  show(a, n);
  for (int i = 1; i < n; i++)
  {
    int v = a[i];
    int j = i - 1;
    while (j >= 0 && a[j] > v)
    {
      a[j + 1] = a[j];
      j--;
    }
    a[j + 1] = v;
    show(a, n);
  }
}

int main()
{
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }

  insertion_sort(a, n);
}


Measured memory_bytes: 3116