akhauriyash/Code-Regression huggingface dataset:
//全然分からなかったから見返すとき用
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())

ll choose(ll a) { //aC2
	return (a - 1) * a / 2;//組み合わせを求める式
  							//3つ同じなら3-1*3/2で4組になるので
}
int main() {
	ll n;// 32 bit 整数型に収まらない可能性がある
  	cin>>n;
  
  	vector<string> s(n);
 	rep (i,n)cin>>s[i];
  	rep (i,n)SORT(s[i]);//sortで辞書順並び替えできる
  	SORT(s);
  
  	vector <ll> cnt(n,1);
	ll sum=0;//最後の答えのやつ
  	ll j=0;//
  
  	rep(i,n-1){
    	if(s[i]==s[i+1])
          cnt[j]++;//一致した数
      	else j++;
    }
	j++;
  	rep(i,j)sum+=choose(cnt[i]);//一致した数から組み合わせ数を求める
  	cout<<sum<<endl;
  
}

Measured memory_bytes: 7168
#include<stdio.h>
int main()
{
	char r[5]={'A','B','C','D','E'};
	int s1[5],i,s2[5],m=0,l;
	while(1){
		for(i=0;i<5;i++){
			scanf("%d%d",&s1[i],&s2[i]);
			if(s1[i]==0&&s2[i]==0){
				return 0;
			}
		}
		for(i=0;i<5;i++){
			if(m<s1[i]+s2[i]){
				m=s1[i]+s2[i];
				l=i;
			}
		}
		printf("%c %d\n",r[l],m);
		m=0;
	}
	return 0;
}

Measured memory_bytes: 2576
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
double EPS=1e-8;
int cnt[1000][1000][3];
int main(){
	int m,n,t;char c;
	cin>>n>>m>>t;
	REP(i,n)REP(j,m){
		cin>>c;
		if(c=='J')cnt[j][i][0]++;
		else if(c=='O')cnt[j][i][1]++;
		else cnt[j][i][2]++;
	}
	REP(i,n)REP(j,m)REP(k,3){
		if(i!=0)cnt[j][i][k]+=cnt[j][i-1][k];
		if(j!=0)cnt[j][i][k]+=cnt[j-1][i][k];
		if(j!=0&&j!=0)cnt[j][i][k]-=cnt[j-1][i-1][k];
	}
	while(t--){
		int u,x,y,z;
		cin>>u>>x>>y>>z;u--;x--;y--;z--;
		int ans[3];
		REP(i,3){
			ans[i]=cnt[z][y][i];
			if(u!=0)ans[i]-=cnt[z][u-1][i];
			if(x!=0)ans[i]-=cnt[x-1][y][i];
			if(u!=0&&x!=0)ans[i]+=cnt[x-1][u-1][i];
		}
		cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2]<<endl;
	}	
}

Measured memory_bytes: 12880
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){
    
    string S,T,U;
    int A,B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if(S==U){
        A-=1;
    }else if(T==U){
        B-=1;
    }
    
    cout << A << " " << B << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
#include<math.h>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const int mod=10007;
#define ll long long

ll f[51]={1};
ll p[51]={1};
ll patty(int n,ll x){
	if(x>=f[n]-1)return p[n];
	if(x<=1)return 0;
	if(x<=f[n-1]+1)return patty(n-1,x-1);
	if(x<=f[n-1]+2)return p[n-1]+1;
	if(x<=f[n]-1)return p[n-1]+1+patty(n-1,x-f[n-1]-2);
}

int main(){
	int n;
	ll x;
	cin>>n>>x;
	for(int i=1;i<51;i++){
		f[i]=2*f[i-1]+3;
		p[i]=2*p[i-1]+1;
	}
	cout<<patty(n,x);
	return 0;
}


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

using namespace std;

int main()
{
    int a,x,y;
    cin>>a;
    x=a/100;
    y=a%100;
    if(x<=12&&y<=12&&x>0&&y>0)
        cout<<"AMBIGUOUS"<<"\n";
    else if(y<=12&&y>0)
        cout<<"YYMM"<<"\n";
    else if(x<=12&&x>0)
        cout<<"MMYY"<<"\n";
    else if((x>12&&y>12)||(x>12&&y==0)||(x==0&&y>12)||(x==0&&y==0))
        cout<<"NA"<<"\n";
    return 0;
}

Measured memory_bytes: 256
// すごろく 2018/12/27

#include <iostream>
using namespace std;

int main() {
    int N, S[100], val;
    bool previous = false; // 1個前が1かどうか
    int length = 0;
    int maxi = 0;

    cin >> N;
    for (int i=0; i<N; i++) {
        cin >> val;
        if (val) { // 1がでた
            length++;
        } else {
            maxi = max(maxi, length);
            length = 0;
        }
    }
    maxi = max(maxi, length); // これを忘れた？

    cout << maxi + 1 << '\n';
    return 0;
}


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

int main(void)
{
	int mem[4][3][10] = {0};
	int n;

	cin >> n;

	for(int i = 0; i < n; i++) {
		int b, f, r, v;
		cin >> b >> f >> r >> v;

		mem[--b][--f][--r] += v;
	}

	for(int i = 0; i < 4; i++) {
		for(int j = 0; j < 3; j++) {
			for(int k = 0; k < 10; k++)
				cout << " " << mem[i][j][k];
			cout << endl;
		}
		if(i != 3) {
			for(int k = 0; k < 20; k++)
				cout << '#';
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    int res=0;
    char c;
    bool zf=0;
    while(((c=getchar())<'0'||c>'9')&&c!= '-');
    if(c=='-')zf=1;
    else res=c-'0';
    while((c=getchar())>='0'&&c<='9')res=(res<<3)+(res<<1)+c-'0';
    if(zf)return -res;
    return res;
}
int d[2005],a[2005][2005];
signed main(){
	int n=read(),m=read(),ans=2e16;
	for(register int i=1;i<=n;i++){
		d[i]=read();
	}
	for(register int i=1;i<=n;i++){
		a[i][i]=d[i];
		for(register int j=i+1;j<=n;j++){
			a[i][j]=min(a[i][j-1],d[j]);
		}
	}
	for(register int i=0;i<n;i++){
		int tmp=m*i;
		for(register int j=1;j<=n;j++){
			int k=j-i;
			if(k<=0)tmp+=min(a[1][j],a[k+n][n]);
			else tmp+=a[k][j];
		}
		ans=min(ans,tmp);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 26332
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
using ll = long long;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
}

void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}

graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}

void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}

ll memo[100100];
graph G(0);

void init(){
    for (int i = 0; i < 100100; ++i) {
        memo[i] = -1;
    }
}

ll solve(ll i){
    if(memo[i] != -1){
        return memo[i];
    }
    ll res = 0;
    for (int j = 0; j < G[i].size(); ++j) {
        res = max(res,solve(G[i][j]) + 1);
    }
    return memo[i] = res;
}

int main() {
    ll N,M;
    init();
    cin >> N >> M;
    G = InputDGraph(N,M);
    //OutputGraph(G);
    ll res = 0;
    for (int i = 0; i < N; ++i) {
        res = max(solve(i),res);
    }
    cout << res << endl;


}


Measured memory_bytes: 8576
#include <iostream>

int main(void){
    int n, i; scanf("%d", &n);
    int A[n]; for(i = 0; i < n; ++i) scanf("%d", A+i);
    for(i = 0; i < n - i - 1; i++) std::swap(A[i], A[n - i - 1]);
    for(i = 0; i < n; ++i){printf("%d", A[i]); putchar(i == n - 1 ? '\n' : ' ');}
    return 0;
}


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

int main() {
    int N;cin >> N;
    vector<ll> A(N);
    int count = 0;ll absmin;ll ans = 0;
    cin >> A[0];ans += abs(A[0]);absmin = abs(A[0]);if (A[0] < 0) count++;
    for (int i = 1;i < N;i++){
        cin >> A[i];
        if (A[i] < 0) count++;
        absmin = min(absmin,abs(A[i]));
        ans += abs(A[i]);
    }
    if (count % 2 != 0) ans -= absmin * 2;
    cout << ans << endl;
}

Measured memory_bytes: 1024
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

setrecursionlimit(10**6)

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

A, B = reads()
if A * B == 15:
  print("*")
elif A + B == 15:
  print("+")
else:
  print("x")


Measured memory_bytes: 4196
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;
#define mp make_pair
#define pb push_back
void solve();
void read_input(){

}
void solve(){

}
int main(){
	int a,b,c,x;
	cin>>a>>b>>c>>x;
	int res = 0;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k =0;k<=c;k++){
				if (500 *i +100 *j + 50 *k == x)
					res++;
			}
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
 
using namespace std;
int K;
int S;
int main(){
  int count = 0;
  cin >> K >> S;
  for(int x=0; x<=K; x++){
    for(int y=0; y<=K; y++){
      int z = S - x - y;
      int total = x + y + z;
      if(0<=z and z<=K){
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

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

    if (a%2 != b%2) {
        cout << "IMPOSSIBLE" << endl;
        return (0);
    }
    cout << (a+b) / 2 << endl;
}


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

int main(){

    int N, M, p[1011];

    while(cin >> N >> M, N){
        vector <int> sum;
        p[0] = 0;
        for(int i = 1; i <= N; i++) cin >> p[i];
    
        for(int i = 0; i <= N; i++){
            for(int j  = 0; j <= N; j++){
                if(p[i] + p[j] > M) continue;
                sum.push_back(p[i] + p[j]);
            }
        }
    
        sort(sum.begin(), sum.end());
        int res = 0;
        for(int i = 0; i  < sum.size(); i++){
            vector <int>::iterator it = lower_bound(sum.begin(), sum.end(), M - sum[i]);
            res = max(res, sum[i] + *(it - 1));
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 9332
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	ll n, k, sum;
	ll ans = 0;

	cin >> n >> k;

	vector<ll> v(n, 0);
	vector<ll> vv(40, 0);

	REP(i, n) {
		cin >> v[i];
	}

	REP(i, n) {
		bitset<40> bi(v[i]);
		REP(j, 40) {
			if (bi[j]) {
				vv[j]++;
			}
		}
	}

	bitset<40> bi1(k + 1);

	RREP(i, 40) {
		sum = 0;
		if (bi1[i]) {
			bitset<40> bi2(k + 1);
			bi2.reset(i);
			REP(j, i) {
				if (vv[j] > n - vv[j]) {
					bi2.reset(j);
				}
				else {
					bi2.set(j);
				}
			}
			REP(j, n) {
				sum += (bi2.to_ullong() ^ v[j]);
			}
			ans = max(ans, sum);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
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;
}

#ifdef DEBUG
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
#else
template <class T, class... Args>
void debug(const T &x, const Args &... args) {}
template <class T> void debugVector(const vector<T> &v) {}
#endif

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> p(N * N);
    for(int i = 0; i < N * N; i++) {
        cin >> p[i];
        p[i]--;
    }
    vector<int> dist(N * N);
    vector<bool> exists(N * N, true);
    for(int i = 0; i < N * N; i++) {
        int r = i / N;
        int c = i % N;
        dist[i] = min({r, c, N - 1 - r, N - 1 - c});
    }
    int ans = 0;
    for(int s : p) {
        int i = s / N;
        int j = s % N;
        ans += dist[s];
        queue<int> que;
        for(int k = 0; k < 4; k++) {
            int ni = i + dy[k];
            int nj = j + dx[k];
            if(0 <= ni && ni < N && 0 <= nj && nj < N &&
               dist[ni * N + nj] > dist[s]) {
                dist[ni * N + nj] = dist[s];
                que.emplace(ni * N + nj);
            }
        }
        while(que.size()) {
            int now = que.front();
            que.pop();
            for(int k = 0; k < 4; k++) {
                int ni = now / N + dy[k];
                int nj = now % N + dx[k];
                if(0 <= ni && ni < N && 0 <= nj && nj < N &&
                   dist[ni * N + nj] > dist[now] + exists[now]) {
                    dist[ni * N + nj] = dist[now] + exists[now];
                    que.emplace(ni * N + nj);
                }
            }
        }
        exists[s] = false;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 5256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var x = sc.nextLong();
		var k = sc.nextLong();
		var d = sc.nextLong();
		sc.close();

		var result = 0L;
		x = Math.abs(x);
		if (k < x / d) {
			result = x - k * d;
		} else if ((k - (x / d)) % 2 == 0) {
			result = Math.abs(x - d * (x / d));
		} else {
			result = Math.abs(x - d * ((x / d) + 1));
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 35712
n=int(input())
A=list(map(int,input().split()))
INF=float('inf')

dp=[[0 for _ in range(n)] for _ in range(2)]
dp[0][0]=A[0]
dp[1][0]=-INF
for i in range(1,n):
  dp[0][i]=max(dp[0][i-1],dp[1][i-1])+A[i]
  dp[1][i]=max(dp[0][i-1]-2*A[i-1]-A[i],dp[1][i-1]+2*A[i-1]-A[i])

print(max(dp[0][n-1],dp[1][n-1]))

Measured memory_bytes: 93384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, K, S;
ll dp[25][25][160];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> N >> K >> S, N) {
    fill_n((ll*)dp, 25*15*160, 0);
    for (int i = 1; i <= N; i++) {
      dp[1][i][i] = 1;
    }
    for (int i = 1; i < K; i++) {
      for (int j = 1; j <= N; j++) {
        for (int k = i; k <= S; k++) {
          for (int l = j+1; l <= N && k+l <= S; l++) {
            dp[i+1][l][k+l] += dp[i][j][k];
          }
        }
      }
    }
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
      ans += dp[K][i][S];
    }
    cout << ans << endl;
  }

  return 0;
}


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

using namespace std;

#define INF 1<<30
#define LINF 1ll<<60ll
#define pb(a) push_back(a)
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)

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

#define fil0(i,n) cout<<swet(n)<<setfill('0')<<i<<resetiosflags(ios_base::floatfield)


int main(){
    int n;
    cin>>n;
    vi a(n);
    REP(i,n){
        cin>>a[i];
    }
    int ans=0;
    REP3(i,1,n){
        if(a[i-1]==a[i]){
            a[i]=-1;
            ++ans;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
///in the name of ALLAH
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll d,t,s;
    cin>>d>>t>>s;
    double a=d/(double)s;
    if(a<=t)cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    int n,k,x,y,s=0;
    cin>>n>>k>>x>>y;
    if(n>k)
        cout<<k*x+(n-k)*y;
    else
        cout<<n*x;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>

std::vector<int> x(30);
int w, n;
int a, b;
int main() {
	std::cin >> w;
	for(int i=0; i<w; ++i) {
		x[i] = i + 1;
	}
	std::cin >> n;
	
	int a, b;
	for(int i=0; i<n; ++i) {
		scanf("%d,%d", &a, &b);
		int tmp = x[a-1];
		x[a-1]  = x[b-1];
		x[b-1]  = tmp;
	}
	
	for(int i=0; i<w; ++i) {
		std::cout << x[i] << std::endl;
	}
	
	return 0;
}


Measured memory_bytes: 3052
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:continue
        for j in range(i * 2, n + 1, i):is_prime[j] = False
    return is_prime

def main():
    q=int(input())
    is_prime = primes(10**5+1)
    a = [0 for i in range(10**5+1)]
    for i in range(3,10**5+1):
        if is_prime[i] and is_prime[(i+1)//2]:a[i]+=1
    for i in range(3,10**5+1):a[i]+=a[i-1]
    for i in range(q):
        l,r=map(int,input().split())
        print(a[r]-a[l-1])

main()


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << ' ' << X << ' ' << Y << endl;
    return 0;
}

Measured memory_bytes: 256
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑


int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		vector<double>v(3);
		cin >> v[0] >> v[1] >> v[2];
		sort(all(v));
		if (v[2] * v[2] == (v[0] * v[0]) + (v[1] * v[1])) { cout << "YES" << endl; }
		else { cout << "NO" << endl; }
	}
}


Measured memory_bytes: 3188
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long LL;
const int SIZEN = 3010;
LL f[SIZEN][SIZEN][4] = {0};
LL val[SIZEN][SIZEN] = {0};
struct Node{
    int x,y,z;
    Node(int x,int y,int z){
        this->x = x;
        this->y = y;
        this->z = z;
    }
    Node(){;}
};
queue<Node> q;
int N,M,K;
int dx[] = {0,1};
int dy[] = {1,0};
void BFS(){
    memset(f,-0x3f,sizeof f);
    f[1][1][1] = val[1][1];
    f[1][1][0] = 0;
    q.push(Node(1,1,0));
    q.push(Node(1,1,1));
    while(!q.empty()){
        Node D = q.front();q.pop();
        if(D.y + 1 <= M){
            int x = D.x,y = D.y+1;
            if(f[x][y][D.z] < f[D.x][D.y][D.z]){
                f[x][y][D.z] = f[D.x][D.y][D.z];
                q.push(Node(x,y,D.z));
            }
            if(D.z < 3 && f[x][y][D.z + 1] < f[D.x][D.y][D.z] + val[x][y]){
                f[x][y][D.z+1] = f[D.x][D.y][D.z] + val[x][y];
                q.push(Node(x,y,D.z+1));
            }
        }
        if(D.x + 1 <= N){
            int x = D.x + 1,y = D.y;
            if(f[x][y][0] < f[D.x][D.y][D.z]){
                f[x][y][0] = f[D.x][D.y][D.z];
                q.push(Node(x,y,0));
            }
            if(f[x][y][1] < f[D.x][D.y][D.z] + val[x][y]){
                f[x][y][1] = f[D.x][D.y][D.z] + val[x][y];
                q.push(Node(x,y,1));
            }
        }
    }
    LL ans = max(f[N][M][0],max(f[N][M][1],max(f[N][M][2],f[N][M][3])));
    printf("%lld\n",ans);
}
int main(){
    scanf("%d%d%d",&N,&M,&K);
    memset(val,-0x3f,sizeof val);
    for(int i = 1;i <= K;i++){
        int x,y,z;scanf("%d%d%d",&x,&y,&z);
        val[x][y] = z;
    }
    BFS();
    return 0;
}

Measured memory_bytes: 357428
n,m = map(int,input().split())
Div = []
for i in range(1,int(m**0.5)+1):
  if m%i == 0:
    Div += [i]
    if i != m//i:
      Div += [m//i]
Div.sort(reverse=True)
for div in Div:
  if div <= m//n:
    print(div)
    break

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <iostream>
#define f first
#define s second
#define fore(i,a,b) for(lli i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
    char a;
    lli sum=0;
    while(cin >> a)
    {
      if(a=='1')sum+=1;
      if(a=='2')sum+=2;
      if(a=='3')sum+=3;
      if(a=='4')sum+=4;
      if(a=='5')sum+=5;
      if(a=='6')sum+=6;
      if(a=='7')sum+=7;
      if(a=='8')sum+=8;
      if(a=='9')sum+=0;
      if(a=='0')sum+=0;
    }
    if(sum%9==0)
    {
      cout << "Yes" <<ENDL;
    }
    else
    {
      cout << "No" <<ENDL;
    }
    return 0;
}


Measured memory_bytes: 3580
N, K = [int(nk) for nk in input().split()]
blue = K
red = N-K

import math
for i in range(1, K+1):
  
  #赤はi-1個以上必要
  if red < i-1:
    ans = 0
  
  else:
    #青はi個に分割する　i-1個の仕切りで分割　(K-1)C(i-1)
    blue_arrangement = math.factorial(K-1) // (math.factorial(K-i) * math.factorial(i-1))
    
    #自由に使える赤は仕切り以外の分
    red_free = red - (i-1)
    #自由赤はi+1個に分割する　i個の仕切りで分割　(red_free + i)! // ((red_free)! * (i)!)
    red_arrangement = math.factorial(red_free+i) // (math.factorial(red_free) * math.factorial(i))
    ans = blue_arrangement * red_arrangement
    
  print(ans % (10**9 + 7))

Measured memory_bytes: 66648
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long k = scanner.nextLong();
        long count = 0;
        for (long i = k; i < n + 2; i++){
            long min = (i * (i - 1)) / 2;
            long max = (n * i) + i - ((i * (i + 1)) / 2);
            count += max - min + 1;
        }
        System.out.println((int) (count % (Math.pow(10, 9) + 7)));
    }
}


Measured memory_bytes: 35716
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main(){ _;
  int n;cin>>n;
  int a,odd=0;
  REP(i,n){
    cin>>a;
    if(a%2==1)odd++;
  }
  if(odd%2==0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


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

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int>A(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> A[i];
    }
    vector<int>point(N, K-Q);
    for (int x: A) {
        point[x-1]++;
    }
    for (int i = 0; i < N; ++i) {
        if(point[i] <= 0){
            cout << "No" << "\n";
        } else{
            cout << "Yes" << "\n";
        }
    }
    return 0;
}

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

using namespace std;

bool kaibun(string s){
    size_t len = s.length();
    for(int i = 0; i < len/2; i++){
        if(s[i] != s[len-i-1]) return false;
    }
    return true;
}

int main(){
    string s;
    string out="Yes";
    cin >> s;
    string sub1 = s.substr(0,s.length()/2);
    string sub2 = s.substr((s.length()+1)/2,s.length()/2);
    //cout << sub1 << endl << sub2 << endl;
    if(!(kaibun(s))) out = "No";
    if(!(kaibun(sub1))) out = "No";
    if(!(kaibun(sub2))) out="No";
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
	int a, b;
	int ascore, bscore;

	while (scanf("%d", &n), n) {
		ascore = 0;
		bscore = 0;
		for (int i = 0; i < n; i++) {
			scanf("%d %d", &a, &b);
			if (a > b) ascore += a + b;
			else if (a < b) bscore += a + b;
			else {
				ascore += a;
				bscore += b;
			}
		}
		printf("%d %d\n", ascore, bscore);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
#define int long long
int memo[50];
int fib(int n){
  if(~memo[n]) return memo[n];
  if(n<=1) return 1;
  return memo[n]=(fib(n-1)+fib(n-2));
}
signed main(){
  int n;
  cin>>n;
  memset(memo,-1,sizeof(memo));
  cout<<fib(n)<<endl;
  return 0;
}

Measured memory_bytes: 3076
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		// my code goes here
		string s = Console.ReadLine();
		if(s.Substring(2,1)==s.Substring(3,1)){
			if(s.Substring(4,1)==s.Substring(5,1)){
				Console.WriteLine("Yes");
			}else{
				Console.WriteLine("No");	
			}
		}else{
			Console.WriteLine("No");
		}
	}
}

Measured memory_bytes: 11092
try:
    while True:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
        a = complex(x1, y1)
        b = complex(x2, y2)
        c = complex(x3, y3)
        p = complex(xp, yp)
        s1 = ((a - p).conjugate() * (b - p)).imag
        s2 = ((b - p).conjugate() * (c - p)).imag
        s3 = ((c - p).conjugate() * (a - p)).imag
        if (s1 > 0) ^ (s2 > 0) == False and (s2 > 0) ^ (s3 > 0) == False:
            print('YES')
        else:
            print("NO")
except EOFError:
    exit()



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
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 int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n, m, sum = 0;
    cin >> n >> m;
    rep(i, m) {
        int a;
        cin >> a;
        sum += a;
    }
    cout << (sum > n ? -1 : n - sum) << endl;
    return;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define int long long

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

ll N, K;
int weights[100000];

ll check(ll p) {
    ll i = 0;
    for (ll j = 0; j < K; j++) {
        ll s = 0;
        while (s + weights[i] <= p) {
            s += weights[i];
            i++;
            if (i == N) {
                return N;
            }
        }
    }
    return i;
}

ll solve() {
    ll left  = 0;
    ll right = 100000 * 10000;
    ll mid;
    while (right - left > 1) {
        mid   = (left + right) / 2;
        ll v = check(mid);
        if (v >= N)
            right = mid;
        else
            left = mid;
    }

    return right;
}

signed main() {
    ll n, k;
    cin >> n >> k;
    N = n, K = k;
    for (ll i = 0; i < n; i++) {
        ll w;
        cin >> w;
        weights[i] = w;
    }
    cout << solve() << endl;
}



Measured memory_bytes: 3988
#include <stdio.h>
#include <math.h>

int s[11], c[11], d[11], n;

void digit(int N)
{
	int cnt = n;

	while (N)
	{
		d[cnt--] = N % 10;
		N /= 10;
	}
}

int main(void)
{
	int m, i, j;

	scanf("%d %d", &n, &m);
	for (i = 1; i <= m; i++)
		scanf("%d %d", &s[i], &c[i]);

	for (i = n > 1 ? (int)pow(10.0, n - 1.0) : 0; i < (int)pow(10.0, n); i++)
	{
		digit(i);

		for (j = 1; j <= m; j++)
			if (d[s[j]] != c[j])
				break;
		if (j == m + 1)
		{
			printf("%d", i);
			return 0;
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
	double r,v,l ;
	scanf("%lf",&r) ;
	v=r*r*3.14159265358979323846264338279 ;
	l=2*r*3.14159265358979323846264338279 ;
	printf("%lf %lf\n",v,l) ;
	return 0 ;
}

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

int main() {
  ll n, k; cin >> n >> k;
  cout << min(n%k, abs(n%k-k)) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int iceil(int n,int d){
	return (n+d-1)/d;
}
int main(){
	int before,after;
	int cost_with_tax;
	for(;scanf("%d%d%d",&before,&after,&cost_with_tax),cost_with_tax;){
		int ma=0,x;
		int cost1_with_tax,cost1_without_tax;
		int cost2_with_tax,cost2_without_tax;
		for(cost1_with_tax=1;cost1_with_tax<=cost_with_tax/2;cost1_with_tax++){
			cost1_without_tax=iceil(cost1_with_tax*100,100+before);
			cost2_with_tax=cost_with_tax-cost1_with_tax;
			cost2_without_tax=iceil(cost2_with_tax*100,100+before);
			x=cost1_without_tax*(100+before)/100+cost2_without_tax*(100+before)/100;
			if(x!=cost_with_tax)continue; //入出力は通っているのだが、この辺が未だ嘘解法な感じしかしない
			x=cost1_without_tax*(100+after)/100+cost2_without_tax*(100+after)/100;
			if(ma<x)ma=x;
		}
		printf("%d\n",ma);
	}
	return 0;
}

Measured memory_bytes: 600
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int n = sc.intarr[0];
            int[] a = sc.intarr;
            int[] ans = new int[0];

            var a_index = new List<SetNum>();

            for (int i = 0; i < n; i++)
            {
                var set = new SetNum(a[i], i+1);
                a_index.Add(set);
            }

            var sortList = a_index.OrderBy(rec => rec.a);

            foreach(var i in sortList)
            {
                Console.Write($"{i.index} ");
            }
            Console.WriteLine("");
            
        }


    }

    class SetNum
    {
        public int a;
        public int index;

        public SetNum(int a, int index)
        {
            this.a = a;
            this.index = index;
        }
    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 29788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int A,B;
  cin >> A >> B;
  
  if(A>=10 || B>=10){
    
    cout << "-1" << endl;
    
  }
    
  else{
   
    cout << A*B << endl;
    
  }
  
}

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




class DICE{
private:
	int D[6];//??????????????????
	
public:
	DICE(int*);
	int get();
	void roll(char);
	void set(int, int);
};



//???????????????????????????????????????????????????
DICE::DICE(int* number){
	
	for(int i = 0; i < 6; ++i){
		D[i] = number[i];
	}
}



//??????????????????????????????=========================================
int DICE::get(){
	
	return D[0];
}



//?????????????????¢??????===========================================
void DICE::roll(char order){
	
	int exchange;
		
	if(order == 'N'){//???????????????1????????¢??????
		exchange = D[0];
		D[0] = D[1];
		D[1] = D[5];
		D[5] = D[4];
		D[4] = exchange;
	}
		
	if(order == 'S'){//???????????????1????????¢??????
		exchange = D[0];
		D[0] = D[4];
		D[4] = D[5];
		D[5] = D[1];
		D[1] = exchange;
	}

	if(order == 'E'){//??±????????????1????????¢??????
		exchange = D[0];
		D[0] = D[3];
		D[3] = D[5];
		D[5] = D[2];
		D[2] = exchange;
	}

	if(order == 'W'){//?\?????????????1????????¢??????
		exchange = D[0];
		D[0] = D[2];
		D[2] = D[5];
		D[5] = D[3];
		D[3] = exchange;
	}
}



//??????????????´==================================================
void DICE::set(int n, int m){
	
	for(int i = 0; i < 5; ++i){
		
		if(D[0] == m)	{ break; }
		if(i % 2 == 0)	{ roll('N'); }
		if(i % 2 == 1)	{ roll('W'); }
	}
	
	roll('S');
	
	for(int i = 0; i < 3; ++i){
		
		if(D[0] == n)	{ break; }
		roll('W');
	}
}
	
	
int main(){
	
	int D[6];
	int n;
	
	for(int i = 0; i < 6; ++i){
		cin >> D[i];
	}
	
	DICE dice(D);
	
	cin >> n;
	
	for(int i = 0; i < n; ++i){
		
		int top, front;
		
		cin >> top >> front;
		
		dice.set(top, front);
		
		dice.roll('W');
		
		cout << dice.get() << endl;
	}
	
	
	
	
	return 0;
}

Measured memory_bytes: 1160
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let ans: i32 = read();
    for x1 in 1..10 {
        for x2 in 1..10 {
            if (ans==x1*x2){
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
#define ll long long
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;

    int sum = 0;
    sum += b;
    int eatable;
    if ((a + b + 1) >= c) {
        sum += c;
    } else {
        sum += a + b + 1;
    }
    cout << sum << endl;
	return 0;
}

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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long S;
	scanf("%lld",&S);
	long long W;
	scanf("%lld",&W);

	cout << (W >= S ? "unsafe" : "safe") << endl;

	return 0;
}


Measured memory_bytes: 3684
#include<stdio.h>
int main(void){
    double h,l,n;
    scanf("%lf",&n);
    l=n;
    h=n;
    while(scanf("%lf",&n)!=EOF){
        if(h<n)h=n;
        if(l>n)l=n;
    }
    printf("%lf\n",h-l);
    return 0;
}

Measured memory_bytes: 648
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    vector<pair<int, char>> sc(M);

    rep(i, M) { cin >> sc[i].first >> sc[i].second; }

    int start = pow(10, N - 1);
    if (N==1){start = 0;}
    for (int i = start; i < pow(10, N); i++) {
        debug(i);
        string cand = to_string(i);
        int not_good = 0;
        rep(j, M) {
            if (cand[sc[j].first - 1] != sc[j].second) {
                not_good++;
            }
        }
        if (not_good == 0) {
            cout << cand << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main() {
    int n, m;
    cin >> n >> m;
    int count = 0;
    rep(i, m){
        int num;
        cin >> num;
        count += num;
    }
    if(n >= count) {
        cout << n-count << endl;
    }else {
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
import java.util.*

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val C = ArrayList<Int>()

    for (i in 1 .. N) {
        val c = readLine()!!.toInt()
        if (C.isEmpty() || C.last() != c) {
            C.add(c)
        }
    }

    val mp = TreeMap<Int, ModInt>()
    val MOD = 1e9.toLong() + 7
    val ZERO = ModInt(0, MOD)
    var res = ModInt(1L, MOD)

    for (c in C) {
        val t = (mp[c] ?: ZERO) + res

        res += (mp[c] ?: ZERO)

        mp[c] = t
    }

    println(res.value)
}

class ModInt (value: Long, val mod: Long) {
    init {
        if (mod <= 0) {
            throw IllegalArgumentException("ModInt cannot be created for non-positive modulus: $mod")
        }
    }

    val value = (value % mod + mod) % mod

    private fun assertSameMod(other: ModInt) {
        if (mod != other.mod) {
            throw IllegalArgumentException(
                "You cannot operate summation, subtraction and multiplication for ModInts with different moduli: $mod, ${other.mod}"
            )
        }
    }

    operator fun unaryMinus() = ModInt(mod - value, mod)

    operator fun plus(other: ModInt): ModInt {
        assertSameMod(other)

        return ModInt((value + other.value) % mod, mod)
    }

    operator fun plus(other: Long) = plus(ModInt(other, mod))

    operator fun minus(other: ModInt): ModInt {
        assertSameMod(other)

        return plus(-other)
    }

    operator fun minus(other: Long) = minus(ModInt(other, mod))

    operator fun times(other: ModInt): ModInt {
        assertSameMod(other)

        return ModInt((value * other.value) % mod, mod)
    }

    operator fun times(other: Long) = times(ModInt(other, mod))

    fun pow(k: Long): ModInt {
        var res = 1L
        var a = value
        var l = k

        while (l > 0) {
            if ((l and 1L) == 1L) {
                res = (res * a) % mod
            }

            a = a * a % mod
            l /= 2L
        }

        return ModInt(res, mod)
    }

    /**
     * Returns an inverse element of the value.
     * To ensure `m * m.inv() = 1`, the modulus should be prime, since it uses Fermat's little theorem.
     */
    fun inv() = pow(mod - 2)

    operator fun div(other: ModInt): ModInt {
        assertSameMod(other)
        if (other.value == 0L) {
            throw ArithmeticException()
        }

        return times(other.inv())
    }

    operator fun div(other: Long) = div(ModInt(other, mod))
}


Measured memory_bytes: 72944
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int x, n;
bool ex[102];

int main() {
    fastio();

    cin >> x >> n;
    forn(i, n) {
        int p;
        cin >> p;
        ex[p] = true;
    }

    int d = x;
    int ans = 0;
    for (int i = 1; i <= 101; i++) {
        if (ex[i]) continue;
        if (d > abs(i - x)) {
            ans = i;
            d = abs(i - x);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3664
#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() {
  int l,r,d;
  cin >> l >> r >> d;
  int ans = 0;
  for(int i=l; i<=r; i++)  if(i%d==0) ans++;
  cout << ans << endl;
}

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

int main() {
    ll N;
    cin >> N;
    queue<ll> a;
    ll a_temp;
    for (ll i=0; i<N; i++) {
        cin >> a_temp;
        a.push(a_temp);
    }
    ll count = 0;
    ll num = 1;
    for (ll i=1; i<=N; i++) {
        if (a.front()==num) {
            a.pop();
            num++;
        }
        else {
            a.pop();
            count++;
        }
    }
    if (count == N) {
        count = -1;
    }
    cout << count << endl;
}

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

void pre(char **s,int N);
void init(char **s,int N);
int judge(char *s,char **m,int N);
void fin(char **s,int N);
int main(){
  int N,M,i,ct=0,ans=0;
  char **s,**t;

  scanf("%d",&N);
  s=(char **)malloc(sizeof(char *)*N);
  pre(s,N);
  init(s,N);

  scanf("%d",&M);
  t=(char **)malloc(sizeof(char *)*M);
  pre(t,M);
  init(t,M);

  for(i=0;i<N;i++){
    ct=judge(s[i],s,N)-judge(s[i],t,M);
    if(ans<ct)
      ans=ct;
    ct=0;
  }

  printf("%d\n",ans);
  fin(s,N);
  fin(t,M);

  return 0;
}

void init(char **s,int N){
  for(int i=0;i<N;i++)scanf("%s",s[i]);
}

void pre(char **s,int N){
  for(int i=0;i<N;i++)
    s[i]=(char *)malloc(sizeof(char)*11);
}

int judge(char *s,char **m,int N){
    int i,ct=0;

    for(i=0;i<N;i++){
        if(strcmp(s,m[i])==0)
          ct++;
    }
    return ct;
}
void fin(char **s,int N){
  for(int i=0;i<N;i++)
    free(s[i]);
  free(s);
}


Measured memory_bytes: 128
N=int(input())
A=list(map(int,input().split()))
flag=True
for i in range(N):
    if A[i]%2==0:
        if (A[i]%3==0 or A[i]%5==0)==False:
            flag=False
if flag:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
# B - One Clue

_input = list(map(int, input().split()))
k = _input[0]
x = _input[1]
_min = (x - k + 1 if x - k + 1 >= -1000000 else -1000000)
_max = (x + k - 1 if x + k - 1 <= 1000000 else 1000000)

print(*range(_min, _max + 1))

Measured memory_bytes: 3060