akhauriyash/Code-Regression huggingface dataset:
n = int(input())
x1 = 0
x2 = 0
x3 = 0
x4 = 0
for i in range(n):
    s = input()
    if s == "AC":
        x1 += 1
    elif s == "WA":
        x2 += 1
    elif s == "TLE":
        x3 += 1
    elif s == "RE":
        x4 += 1
print("AC x", x1)
print("WA x", x2)
print("TLE x", x3)
print("RE x", x4)

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
const int maxn = 222222, mod = 1'000'000'007;
int mul(long long a, long long b){
	return a * b % mod;
}
int p2[maxn], p3[maxn];
int main(){
	p2[0] = p3[0] = 1;
	for(int i = 1; i < maxn; i++){
		p2[i] = mul(p2[i - 1], 2);
		p3[i] = mul(p3[i - 1], 3);
	}
	string s; cin >> s;
	int ans = 0, fac = 1, len = s.size();
	for(int i = 0; i < len; i++){
		if(s[i] == '1'){
			ans += mul(fac, p3[len - i - 1]);
			if(ans >= mod) ans -= mod;
			fac = mul(fac, 2);
		}
	}
	ans += fac;
	if(ans >= mod) ans -= mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
 /* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)*/
template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////
const int MAX = 510000;

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

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

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



int main() {
//	COMinit();
	double ans = 0;
	int N; cin >> N;
	vector<int> A;
	for (int i = 0; i < N; i++)
	{
		int a; cin >> a;
		A.PB(a);
	}
	sort(ALL(A));
	ans = A.at(0);
	for (int i = 1; i < N; i++)
	{
		ans = (ans + double(A.at(i)))/2;
	}
	
	

	cout << setprecision(15) << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String[] input = br.readLine().split(" ");
        int x = Integer.parseInt(input[0]);
        int y= Integer.parseInt(input[1]);
        String ans = "No";
        
        for(int i = 0; i <= x; i++){
            if(y == 2 * i + 4 * (x - i)){
                ans = "Yes";
                break;
            }
        }
        
        out.println(ans);
        out.close();
        
    }
}

Measured memory_bytes: 32744
#include <stdio.h>

int main()
{
    int i, j, minj, N, A[100], tmp, count = 0, k;

    scanf("%d", &N);

    for (i = 0; i < N; i++)
        scanf("%d", &A[i]);

    for (i = 0; i < N; i++)
    {
        minj = i;
        for (j = i; j < N; j++)
        {
            if (A[j] < A[minj])
            {
                minj = j;
            }
        }
        k = A[minj];
        tmp = A[i];
        A[i] = A[minj];
        A[minj] = tmp;
        if (k != A[minj])
            count++;
    }

    for (i = 0; i < N - 1; i++)
        printf("%d ", A[i]);

    printf("%d\n%d\n", A[N - 1], count);

    return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    int A,B;
    cin >> A >> B;
    int sum = 1, ans = 0;
    while(sum < B) sum += A-1, ans++;
    pr(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int id[1005][1005];
bool visited[500005];
bool calculated[500005];
vector<int> d(500005, 1);
vector<int> to[500005];

int dfs(int v){
  if(visited[v]){
    if(!calculated[v])return -1;
    return d[v];
  }
  visited[v]=true;
  for(int nv:to[v]){
    int res=dfs(nv);
    if(res==-1)return -1;
    d[v]=max(d[v], res+1);
  }
  calculated[v]=true;
  return d[v];
}

int main(){
  int n;
  cin >> n;
  int idnum=0;
  rep(i, n){
    for(int j=i+1; j<n; j++){
      id[i][j]=idnum;
      idnum++;
    }
  }
  rep(i,n){
    int a0;
    cin >>a0;
    a0--;
    rep(j, n-2){
      int a;
      cin >> a;
      a--;
      to[id[min(i, a0)][max(i, a0)]].push_back(id[min(i, a)][max(i, a)]);
      a0=a;
    }
  }
  int ans=0;
  rep(i, n*(n-1)/2){
    int di=dfs(i);
    if(di==-1){
      cout << "-1" << endl;
      return 0;
    }
    ans=max(ans, di);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 37564
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define YESes(b) std::cout<< (b ? "Yes" : "No")
#define YES(b) std::cout<< (b ? "YES" : "NO")
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second

int main() {
	int n, m, k, sum = 1;
	cin >> n >> m;
	
	REP(i, n) {
		cin >> k;
	}
	n -= m;
	if (n % (m-1) == 0) {
		sum += n / (m-1);
	}
	else {
		sum += n / (m -1)+ 1;
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
const int INF_INT = 2147483647;
const long long INF_LONG = 9223372036854775807;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int bfs(vector<vector<int>> &g, int h, int w) {
  queue<pair<int, int>> que;
  vector<int> vy = {0, 1, 0, -1};
  vector<int> vx = {1, 0, -1, 0};
  g[1][1] = 1;

  rep (i, 4) {
    if (g[1 + vy[i]][1 + vx[i]] == 0) {
      que.push(make_pair(1 + vy[i], 1 + vx[i]));
      g[1 + vy[i]][1 + vx[i]] = 2;
    }
  }
  while (!que.empty()) {
    int y, x;
    tie(y, x) = que.front();  que.pop();
    rep (i, 4) {
      if (g[y + vy[i]][x + vx[i]] == 0) {
        if (h == y + vy[i] && w == x + vx[i]) return g[y][x] + 1;
        que.push(make_pair(y + vy[i], x + vx[i]));
        g[y + vy[i]][x + vx[i]] = g[y][x] + 1;
      }
    }
  }

  return -1;
}

     
int main() {
  int h, w, s=0;  cin >> h >> w;
  vector<vector<int>> g(h + 2, vector<int>(w + 2, -2));
  for (int i=1; i<h+1; ++i) for (int j=1; j<w+1; ++j) {
    char c;  cin >> c;
    if (c == '.') {
      g[i][j] = 0;
      ++s;
    }
    else g[i][j] = -1;
  }

  int x = bfs(g, h, w);
  if (x == -1) cout << -1 << endl;
  else cout << s - x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000

template <typename T>
struct BIT{
	vector<T> v;
	int n;
	
	const T init_value = 0;
	
	BIT(int sz){
		n=sz+1;
		v.resize(n,init_value);
	}
	
	BIT(vector<T> &x){
		n=x.size()+1;
		v.resize(n,init_value);
		
		for(int i=0;i<x.size();i++){
			add(i,x[i]);
		}
		
	}

	void add(int x,T val){
		x++;
		while(x < n){
			v[x] = func(v[x],val);
			x += x & (-x);
		}
	}
	
	//区間[0,r)におけるクエリ処理
	T query(int r){
		T ret = init_value;
		
		while(r>0){
			ret = func(v[r],ret);
			r -= r & (-r);
		}
		
		return ret;
	}
	
	T query(int l,int r){
		return query(r) - query(l);
	}
	
	T func(T a,T b){
		return a+b;
	}
	
};

int main(){

	int N,Q;
	cin>>N>>Q;
	
	vector<int> c(N);
	for(int i=0;i<N;i++){
		scanf("%d",&c[i]);
		c[i]--;
	}
	
	vector<vector<pair<int,int>>> q(N+1,vector<pair<int,int>>());
	
	for(int i=0;i<Q;i++){
		int l,r;
		cin>>l>>r;
		l--;r--;
		q[r].emplace_back(l,i);
	}
	
	BIT<int> B(N+5);
	
	vector<int> last(N,N);
	B.add(N,N);
	vector<int> ans(Q);
	for(int i=0;i<N;i++){
		B.add(last[c[i]],-1);
		B.add(i,1);
		last[c[i]]=i;
		
		for(int j=0;j<q[i].size();j++){
			ans[q[i][j].second] = B.query(q[i][j].first,i+1);
		}
	}
	
	for(int i=0;i<Q;i++){
		printf("%d\n",ans[i]);
	}
	
	
	return 0;
}


Measured memory_bytes: 33244
#include <iostream>
#include <vector>

using ll = long long;

int main()
{
    ll N, M;
    std::cin >> N >> M;

    std::vector<ll> H(N);
    for (auto& h : H) {
        std::cin >> h;
    }

    std::vector<bool> vec(N);
    std::fill(vec.begin(), vec.end(), true);

    for (int i = 0; i < M; ++i) {
        int A, B;
        std::cin >> A >> B;
        if (H[A - 1] > H[B - 1]) {
            vec.at(B - 1) = false;
        } else if (H[A - 1] < H[B - 1]) {
            vec.at(A - 1) = false;
        } else {
            vec.at(A - 1) = false;
            vec.at(B - 1) = false;
        }
    }

    int sum = 0;
    for (auto v : vec) {
        if (v)
            sum++;
    }

    std::cout << sum << std::endl;

    return 0;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

struct state{
	ll w,s,v;
};

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<state> g(n);
	rep(i,n){
		cin>>g[i].w>>g[i].s>>g[i].v;
	}
	sort(begin(g),end(g),[](const state &a,const state &b){
		return a.w+a.s<b.w+b.s;
	});
	vector<vector<ll>> dp(n+1,vector<ll>(100100,0));
	rep(i,n)rep(j,100100){
		dp[i+1][j]=dp[i][j];
		if(0<=j-g[i].w && j-g[i].w<=g[i].s){
			chmax(dp[i+1][j],dp[i][j-g[i].w]+g[i].v);
		}
	}
	cout<<*max_element(begin(dp[n]),end(dp[n]))<<endl;
	/*
	あるブロックの集合を決め打つと, s+wが小さい順に上から積んでいくのが最適
	(自分の位置以上の重さの上限を与えるものなので)
	あとはナップサック
	*/
}

Measured memory_bytes: 786416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s,t;
  cin >> s >> t;
  int a,b;
  cin >> a >> b;
  string u;
  cin >> u;

  if(s==u){
    cout << --a <<" "<< b << endl;
  }else if(t == u){
    cout << a <<" "<< --b << endl;
  }

}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_POS_MAX		90000									// 最大位置数

// 内部構造体 - 位置情報
typedef struct Pos {
	int miX, miY;												// 座標
} Pos;

// 内部変数
static Pos sz1Pos[D_POS_MAX + 5];								// 位置情報
static int si1Sum[D_POS_MAX + 5];								// 総和

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i, j;
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 高さ・幅・移動量取得
	int liH, liW, liMv;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d%d%d", &liH, &liW, &liMv);

	// 位置情報取得
	for (i = 1; i <= liH; i++) {
		for (j = 1; j <= liW; j++) {
			int liNo;
#ifdef D_TEST
			fscanf(szpFpT, "%d", &liNo);
#else
			fscanf(stdin, "%d", &liNo);
#endif
			sz1Pos[liNo].miX = j;
			sz1Pos[liNo].miY = i;
		}
#ifdef D_TEST
		fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
		fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	}

	// 総和セット
	for (i = 1; i <= liMv; i++) {

		// 初期位置
		si1Sum[i] = 0;

		// 順に移動
		int liFNo = i;
		int liTNo;
		while (1) {
			liTNo = liFNo + liMv;
			if (liTNo > D_POS_MAX) {
				break;
			}
			si1Sum[liTNo] = si1Sum[liFNo] + abs(sz1Pos[liTNo].miX - sz1Pos[liFNo].miX) + abs(sz1Pos[liTNo].miY - sz1Pos[liFNo].miY);
			liFNo = liTNo;
		}
	}

	// クエリ数取得
	int liQCnt;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d", &liQCnt);

	// クエリ数でループ
	for (i = 0; i < liQCnt; i++) {

		// クエリ取得
		int liFNo, liTNo;
#ifdef D_TEST
		fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
		fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
		sscanf(lc1Buf, "%d%d", &liFNo, &liTNo);

		// 合計取得
		int liSum = si1Sum[liTNo] - si1Sum[liFNo];

		// 結果表示
		sprintf(lc1Out, "%d\n", liSum);
#ifdef D_TEST
		fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
		if (strcmp(lc1Buf, lc1Out)) {
			siRes = -1;
		}
#else
		printf("%s", lc1Out);
#endif
	}

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 

#define M 110
#define N 3010
ll n,k,a[N],dp[N][N][2];
ll f(ll left,ll right,ll cond){
	if(left>right) return 0;
	if(dp[left][right][cond]!=-1) return dp[left][right][cond];
	ll ans;
	if(cond)
		ans=max(f(left+1,right,!cond)+a[left],f(left,right-1,!cond)+a[right]);
	else 
		ans=min(f(left+1,right,!cond)-a[left],f(left,right-1,!cond)-a[right]);
	return dp[left][right][cond]=ans;
}
int main(){
	IOS;
	tihs;
	memset(dp,-1,sizeof(dp));
	cin>>n;
	rep(i,0,n)cin>>a[i];
	cout<<f(0,n-1,1);
	return 0;
}

Measured memory_bytes: 141952
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int N, K;
vector<int> A;

void input(void){
	cin >> N >> K;
	A.resize(N);
	for (auto& ai : A)
		cin >> ai;
}

bool judge(int d){
	int cut = 0;
	for (auto ai : A)
		cut += (ai / d) - 1 + (ai % d ? 1 : 0);
	return cut <= K;
}

int main(void){
	input();
	int ok = 1000000000, ng = 0;
	while (ok - ng > 1){
		int mid = (ok + ng) / 2;
		if (judge(mid)) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
	return 0;
}

Measured memory_bytes: 3952
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
// ascending order
#define asort(array, N) sort(array, array + N)
// descending order
#define asort_r(array, N) sort(array, array + N, greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int a[N];
	for(int i = 0; i < N; i++) cin >> a[i];
	asort(a, N);
	cout << a[N - 1] - a[0] << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <time.h>
#define int long long int
#define pb push_back
#define all(a) a.begin(), a.end()
#define scnarr(a, n) for (int i = 0; i < n; ++i) cin >> a[i]
#define vi vector<int>
#define si set<int>
#define pii pair <int, int>
#define sii set<pii>
#define vii vector<pii>
#define mii map <int, int>
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace chrono;
/* -------------------------------Solution Sarted--------------------------------------*/
//Constants
const int MOD = 1000000007; // 1e9 + 7
const int MAXN = 1000005; // 1e6 +5



void solve(){
	int n;
	cin >> n;
	for(int ii = 1; ii <= n; ++ii){
		int cnt = 0;
		for(int i = 1; i <= 100; ++i){
			for(int j = 1; j <= 100; ++j){
				for(int k = 1; k <= 100; ++k){
					if(pow(i + j, 2) + pow(j + k, 2) + pow(k + i, 2) > 2*ii){
						break;
					}else if(pow(i + j, 2) + pow(j + k, 2) + pow(k + i, 2) == 2*ii){
						cnt++;
					}
				}
			}
		}
		cout << cnt << endl;
	}
}

signed main()
{
	faster;
#ifndef ONLINE_JUDGE
	freopen("ip.txt", "r", stdin);
	freopen("op.txt", "w", stdout);
#endif
	// int t; cin >> t; while(t--)
		solve();
	return 0;
}


//Author : Ankit Raj
//Problem Link :

/*Snippets*/
/*
sieve - prime factorization using sieve and primes in range
zpower - pow with mod
plate - Initial template
bfs 
dfs
fenwik - BIT
binary_search
segment_tree
*/
	

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

int main() {
	int n;
	cin >> n;
	long long L[87];
	L[0] = 2;
	L[1] = 1;
	for (int i = 2; i <= n; i++) {
		L[i] = L[i - 1] + L[i - 2];
	}
	cout << L[n]<<endl;
}

Measured memory_bytes: 256
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>

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

using namespace std;

int n;
int a[30];
int ans;

void rec(int i, int A, int B)
{
    if (i == n) {
        ans = min(ans, abs(A - B));
        return;
    }

    rec(i + 1, A + a[i], B);
    rec(i + 1, A, B + a[i]);
}

int solve()
{
    ans = 30000000;
    rec(0, 0, 0);
    return ans;
}

int main()
{
#ifdef LOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    while (true) {
        cin >> n;
        if (n == 0) break;

        rep(n) {
            cin >> a[i];
        }

        cout << solve() << endl;
    }
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
	template <class Arg1, class... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args) {
		const char* sep = strchr(names + 1, ',');
		cerr.write(names, sep - names) << " : " << arg1 << "  ";
		__f(sep + 1, args...);
	}
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
typedef pair<char,int> pci;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plll;
 


#define pb push_back
 
// order_of_key (k), find_by_order(k)
#define fi first
#define se second
#define input_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll> ,greater<ll>>
#define initialise(a, x) memset(a, x, sizeof(a))
#define endl '\n'
#define ordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
#define MAX 1000020
#define maxn 200005
#define eps 0.0000001

const ll mod=998244353;
const ll inf=1e18+2;

#define int ll

int seg[4*maxn];

void update(int l,int h,int pos,int tar,int new1)
{
	if(l>tar || h<tar) return;
	if(l==h)
	{
		seg[pos]=new1;
		return;
	}
	int m=(l+h)/2;

	update(l,m,2*pos+1,tar,new1);
	update(m+1,h,2*pos+2,tar,new1);

	seg[pos]=(seg[2*pos+1]+seg[2*pos+2])%mod;
}

int query(int l,int h,int pos,int ql,int qh)
{
	if(qh<l || ql>h) return 0;
	if(l>=ql and h<=qh) return seg[pos];

	int m=(l+h)/2;
	return (query(l,m,2*pos+1,ql,qh)+query(m+1,h,2*pos+2,ql,qh))%mod;
}


signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	// freopen("input.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);

	int n,k;
	cin>>n>>k;

	vector<pair<ll,ll> > v;

	for(int i=0;i<k;i++)
	{
		int l,r;
		cin>>l>>r;
		v.pb({l,r});
	}

	sort(v.begin(), v.end());

	int dp[n+2];
	initialise(dp,0);

	dp[n]=1;
	update(1,n,0,n,1);

	for(int i=n-1;i>=1;i--)
	{
		for(int j=0;j<k;j++)
		{
			if(v[j].fi+i>n) break;

			dp[i]+=query(1,n,0,v[j].fi+i,min(n,v[j].se+i));
			dp[i]%=mod;
		}

		update(1,n,0,i,dp[i]);
	}

	cout<<dp[1]<<'\n';
	

	return 0;
}

Measured memory_bytes: 9296
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9;
const ll mod=998244353;
signed main(){
    ll n,k,q;cin>>n>>k>>q;
    vector<ll>a(n);
    vector<pll>p(n);
    rep(i,n){
        cin>>a[i];
        p[i]=mp(a[i],i);
    }
    sort(all(p));
    ll ans=p[q-1].first-p[0].first;
    set<ll>st;
    a.pb(0);
    st.insert(n);
    n++;
    rep(i,n){
        priority_queue<ll,vector<ll>,greater<ll> >pq;
        priority_queue<ll,vector<ll>,greater<ll> >qq;
        rep(j,n){
            if(st.find(j)!=st.end()){
                while(pq.size()>=k){
                    ll d=pq.top();
                    pq.pop();
                    qq.push(d);
                }
                while(!pq.empty()){
                    pq.pop();
                }
            }else{
                pq.push(a[j]);
            }
        }
        if(qq.size()>=q){
            ll mi=qq.top();
            qq.pop();
            //cout<<qq.top()<<endl;
            ll ma=qq.top();
            rep(o,q-1){
                ma=qq.top();
                //cout<<qq.top()<<endl;
                qq.pop();
            }
            while(!qq.empty()){
                qq.pop();
            }
            ans=min(ans,ma-mi);
        }else{
            break;
        }
        if(i<n-1)st.insert(p[i].second);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
int gcd(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
signed main(){
	int n,k;
	cin >> n >> k;
	vec(a,n);
	cin >> a[0];
	int min = a[0];
	int t = a[0];
	FOR(i,1,n){
		cin >> a[i];
		min = gcd(min,a[i]);
		t = max(t,a[i]);
	}
	if(k>t || k%min != 0){
		cout << "IMPOSSIBLE" << endl;
	}
	else{
		cout << "POSSIBLE" << endl;
	}
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> vec(H);
  for(int i = 0; i < H; i++){
    cin >> vec.at(i);
  }
  for(int i = 0; i < W + 1; i++){
    cout << "#";
  }
  cout << "#" << endl;
  for(int i = 0; i < H; i++){
    cout << "#" << vec.at(i) << "#"<< endl;
  }
  for(int i = 0; i < W + 1; i++){
    cout << "#";
  }
  cout << "#" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	ini(n);
	int x = n*n;
	out(3*x);
	return 0;
}

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

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

    string S;
    cin >> S;

    int ans = 0;

    for(int i=0, j=S.size()-1; i<j; i++, j--)
        if(S[i] != S[j])
            ans++;

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define xx first
#define yy second
#define sci(n) scanf("%d",&n)
#define scii(n,m) scanf("%d%d",&n,&m)
#define sciii(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define sclll(n,m,w) scanf("%lld%lld%lld",&n,&m,&w)
#define pf(a)   printf("%d\n",a)
#define CASE(a) printf("Case %d:\n",a)
#define dbg(i) printf("yo %lld\n", i)
#define endl '\n'
#define READ  freopen("input.txt","r",stdin)
#define WRITE freopen("output.txt","w",stdout);
#define pi acos(-1)
#define mem(a,b) memset(a,b,sizeof(a))
#define SQR(a) (a)*(a)
#define all(v) v.begin(),v.end()
#define pb push_back
#define pri priority_queue<int>
#define rev_pri priority_queue<int,vector<int>,greater<int> >
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define inf INT_MAX
#define eps 1e-9

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

using namespace __gnu_pbds;
using namespace std;


#define mxn 100005


//bool vis[1LL << 19];
const ll nax=100005;
ll ar[nax],br[nax];
void solve()
{
    ll a,b,n,k=0,c,i,q=0,j,l,m,mx;
    cin>>n;
    FOR(i,1,n+1)cin>>ar[i];
    for(i=n-1,ar[n+1]=mod;i>=1;i--){
        br[i]=min(abs(ar[i]-ar[i+1])+br[i+1],abs(ar[i]-ar[i+2])+br[i+2]);
    }cout<<br[1]<<'\n';
}
int main()
{
    //IOS;
    double start_time = clock();
    ll t=1,mex=1;
   //cin>>t;
    while(t--){
        solve();
    }
    double end_time = clock();
    //fprintf(stderr, "Time = %lf\n", (end_time - start_time) / CLOCKS_PER_SEC);
    return 0;
}


Measured memory_bytes: 1792
package main
import . "fmt"
func main() {
  var n,k,x,s int
  Scan(&n)
  Scan(&k)
  s = 0
  for i:=0;i<n;i++ {
    Scanf("%d",&x)
    s += min(x,k-x)
  }
  Println(2*s)
}
func min(x int,y int) int {
  if x < y {
    return x
  } else {
    return y
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a) for(ll i=ll(a-1);i>=0;--i)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
using ull = unsigned long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll MOD3 = 1e6;
const ll EPS = 1e-10;
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<long double,long double> point;
typedef complex<long double> Point;
const ll MAX = 3000;
constexpr ll nx[4] = {-1,0,1,0};
constexpr ll ny[4] = {0,1,0,-1};
int a[1000005];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    rep(i,1,n+1){
        for (ll j = i;j < n+1;j += i){
            a[j]++;
        }
    }
    ll ans = 0;
    rep(c,1,n){
        ans += a[n-c];
    }
    PRINT(ans);
}


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

#define fori(i, a, b) for (int i = a; i < b; ++ i)
#define fori2(i, a, b) for (int i = a; i <= b; ++ i)
#define ford(i, a, b) for (int i = a; i >= b; -- i)

using namespace std;

typedef long long ll;

int h, w, n;

int sr, sc;
string s, t;

void process() {
		cin >> h >> w >> n >> sr >> sc >> s >> t;

		-- sr;
		-- sc;

		int l, r, u, d;

		l = 0;
		r = 0;
		u = 0;
		d = 0;

		fori(i, 0, n) {
				switch(s[i]) {
						case 'U': {
								++ u;
								break;
						}

						case 'R': {
								++ r;
								break;
						}

						case 'D': {
								++ d;
								break;
						}

						case 'L': {
								++ l;
								break;
						}
				}


				if (sr - u < 0 || sr + d >= h || sc - l < 0 || sc + r >= w) {
						cout << "NO";
						return;
				}

				switch(t[i]) {
						case 'U': {\
								if (sr + d > 0)
										-- d;
								break;
						}

						case 'R': {
								if (sc - l < w - 1)
										-- l;
								break;
						}

						case 'D': {
								if (sr - u < h - 1)
										-- u;
								break;
						}

						case 'L': {
								if (sc + r > 0)
										-- r;
								break;
						}
				}
		}

		cout << "YES";
		return;
 }

int main() {
        ios::sync_with_stdio(false);
        process();
}



Measured memory_bytes: 920
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,M;
  cin>>N>>M;
  ll ans=0;
  vector<int> B(N,0);
  unordered_map<int,int> mp;
  mp.insert(make_pair(0,1));
  for(int i=0; i<N; i++){
    ll a;
    cin>>a;
    if(i==0)
      B[i]=a%M;
    else{
      B[i]=B[i-1]+a;
      B[i]%=M;
    }
    int tmp=mp[B[i]];
    mp[B[i]]=tmp+1;
    ans+=tmp;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4108
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int[] A = new int[N];
    int[] B = new int[N];
    int[] C = new int[N - 1];

    int result = 0;

    for(int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }

    for(int i = 0; i < N; i++) {
      B[i] = sc.nextInt();
      result += B[i];
    }

    for(int i = 0; i < N - 1; i++) {
      C[i] = sc.nextInt();  
    }

    sc.close();

    for(int i = 0; i < N - 1; i++) {
      if (A[i] + 1 == A[i + 1]){
        result += C[A[i] - 1];
      }
    }

    System.out.println(result);

  }

}


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

int main() {
	int n;
	cin >> n;
	
	vector<int> a(n);
	
	int sum  = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if (sum == 0){
			sum = a[i];
		}else{
			sum ^= a[i];
		}
	}
	
	for(int i = 0; i < n; i++){
		cout << (sum ^ a[i]) << " ";
	}
	
	return 0;
}

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

int main() {
  long N,W;
  cin>>N>>W;
  vector<long> w(N);
  vector<long> v(N);
  for(int i=0;i<N;i++) cin>>w[i]>>v[i];
  vector<vector<long>> dp(N+1,vector<long>(W+1));

  for(int i=0;i<N;i++){
    for(int j=0;j<=W;j++){
      if(j-w[i]>=0) dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j]);
      else dp[i+1][j]=dp[i][j];
    }
  }

  for(int i=0;i<=N;i++){
    for(int j=0;j<=W;j++){
      //cout<<dp[i][j]<<" ";
    }
  //  cout<<endl;
  }
cout<<dp[N][W]<<endl;
}


Measured memory_bytes: 83136
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int n, k, a[1000], c;
int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) { cin >> a[i]; a[i] *= -1; }
	sort(a, a + n);
	for (int i = 0; i < k; i++)c += a[i];
	cout << -c << endl;
	return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n;
    cin >> n;

    int ans = 0;
    rep(i, n){
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }

    cout << ans << endl;

    return 0;
}

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

#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int N = 21;
const int M = (1LL<<N);
int a[N][N];
int dp[N][M];
int pw[N+5];
int n;

const int MOD = 1e9 + 7;

void solve()
{
    pw[0] = 1;
    for(int i=1;i<=N;i++) pw[i] = pw[i-1]<<1;
    
    cin >> n;
    f(i,n) f(j,n) cin >> a[i][j];
    
    f(i,n) if(a[0][i] == 1) dp[0][pw[i]] = 1;
        
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<pw[n];j++)
        {
            if(__builtin_popcount(j) != i) continue; 
        
            for(int k=0;k<n;k++)
            {
                if(a[i][k] == 1 && ( (j&pw[k]) == 0))
                    dp[i][j|pw[k]]=(dp[i][j|pw[k]] + dp[i-1][j])%MOD;
            }
        }
    }
    
    cout << dp[n-1][pw[n]-1]; 
}

signed main()
{
    fast;
    solve();
}

Measured memory_bytes: 160000
n,k,q = map(int,input().split())

joi = [0 for i in range(n+1)]

for i in range(q):
    que = int(input())
    joi[que] += 1
    
for i in range(1,n+1):
    if k-q+joi[i] > 0:
        print("Yes")
        
    else:
        print("No")

Measured memory_bytes: 4680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main()
{
  double x=0,y=0,z=0,w=0,n=0,m=0,a=0,b=0;
std::cin >>a;
string s;
std::cin >> s;
rep(i,s.size()-1){
  if(s[i]==s[i+1]){
     eraser(s,i);
     i--;
  }
}
std::cout << s.size() << '\n';
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
    double r; cin >> r;
    cout << 2.0 * M_PI * r << endl;
}


Measured memory_bytes: 3216
#include <iostream>
#include <vector>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main(void){
    uint N;
    cin >> N;
    
    vector<uint> d(N);
    for (uint i=0; i<N; i++) {
        cin >> d[i];
    }
    
    ull ans = 0;
    for (uint i=0; i<N; i++) {
        ull jsum = 0;
        for (uint j=i+1; j<N; j++) {
            jsum += d[j];
        }
        ans += jsum * d[i];
    }
    
    cout << ans;
}


Measured memory_bytes: 256
x, n = map(int, input().split())
lis =  []

if n == 0:
  print(x)
else:
  lis = list(map(int, input().split()))
  if x not in lis:
    print(x)
  else:
    y = x + 1
    z = x - 1
    while True:
      if y in lis and z in lis:
        y += 1
        z -= 1
      elif z not in lis:
        print(z)
        break
      elif y not in lis:
        print(y)
        break
  


Measured memory_bytes: 9192
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include<limits.h>
#include<algorithm>
#include<queue>
#include<set>


#define MOD 1000000007

using namespace std;

long long int modpow(long long int a, long long int n) {
	if (n == 0)return 1;
	if (n == 1)return (a % MOD);

	long long int hanbun = n / 2;
	long long int amari = n % 2;

	long long int ans = (a * a) % MOD;
	ans = modpow(ans, hanbun);

	if (amari == 1)ans *= a;

	ans %= MOD;

	return ans;

}

long long int gcd(long long int a, long long int b) {
	if (a < b) {
		long long int tmp = a;
		a = b;
		b = tmp;
	}

	long long int amari = a % b;

	if (amari == 0)return b;

	return gcd(b, amari);
}

long long int lcm(long long int a, long long int b) {
	long long int ans = (a * b) % MOD;
	long long int wari = modpow(gcd(a, b), MOD - 2);
	ans = (ans * wari) % MOD;
	return ans;
}

long long int factElement[10000] = { 0 };

long long int factrial(int n) {

	if (factElement[n] != 0)return factElement[n];

	if (n == 0) {
		factElement[0] = 1;
		return factElement[n];
	}

	long long int ans = n * factrial(n - 1);
	factElement[n] = ans;
	return factElement[n];

}


int main()
{

	int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

	int num;
	cin >> num;


	cout << a[num - 1] << endl;




	return 0;

}



Measured memory_bytes: 256
import java.util.*;
 
public class Main { //クラス名はMain
    public static void main(String[] args) {
      //整数の入力
      // List<String> list = new ArrayList<String>();
      Scanner sc = new Scanner(System.in);
      int K = Integer.parseInt(sc.next());
      int A = Integer.parseInt(sc.next());
      int B = Integer.parseInt(sc.next());

      //黒板の整数
      String answer = "NG"; 
      for(int i=1; K*i<=1000; i++){
        if(A <= K*i && B >= K * i){
          answer = "OK";
          break;
        }else {
          answer = "NG";
        }
      }
      System.out.println(answer);
    }
}

Measured memory_bytes: 35688
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
const int MOD = 1e9+7;
const int INF = 1e9;
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; }

// debug
template<class T>ostream& operator<<(ostream& os, vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}
#include<type_traits>
template<typename T,size_t SIZE,enable_if_t<!is_same<remove_cv_t<T>,char>::value,nullptr_t> = nullptr>ostream& operator<<(ostream& os,T(&arr)[SIZE]){os<<"{";for(size_t i=0;i<SIZE;++i)os<<(i?", ":"")<<arr[i];os<<"}";return os;}
#ifdef LOCAL
    #define debug(v) cerr<<v<<"\n"
#else
    #define debug(...) 42
#endif


int main() {
  int N; cin >> N;

  int P[N], Q[N];
  rep(i, N) cin >> P[i];
  rep(i, N) cin >> Q[i];
  vi v;
  rep(i, N) v.push_back(i+1);
  int count = 0;
  int a = -1, b = -1;
  do {
    ++count;
    bool isP = true, isQ = true;
    rep(i, N) {
      if (v[i] != P[i])
        isP = false;
      if (v[i] != Q[i])
        isQ = false;
    }
    if (isP)
      a = count;
    if (isQ)
      b = count;
  } while (next_permutation(v.begin(), v.end()));

  cout << abs(a - b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#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 PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N;
  cin>>N;
  ll A[2*N],AA[N],B[2*N],BB[N];
  REP(i,N) cin>>AA[i];
  REP(i,N) cin>>BB[i];
  REP(i,N){
    A[i]=AA[i]^AA[(i+1)%N];
    A[N+i]=A[i];
  }
  REP(i,N){
    B[i]=BB[i]^BB[(i+1)%N];
    B[N+i]=B[i];
  }
  
  ll base=1007,P[N+1],HA=0,HB=0;
  P[0]=1;
  RREP(i,N) P[i]=P[i-1]*base%MOD;
  
  REP(i,N){
    HA+=A[i]*P[N-1-i]%MOD;
    HA%=MOD;
    HB+=B[i]*P[N-1-i]%MOD;
    HB%=MOD;
  }
  
  REP(i,N){
    if(HA==HB){
      ll X=AA[i]^BB[0];
      cout<<i<<" "<<X<<endl;
    }
    HA=HA*base%MOD;
    HA-=A[i]*P[N]%MOD;
    HA+=A[i+N];
    HA%=MOD;
    if(HA<0) HA+=MOD;
  }
  return 0;
}

Measured memory_bytes: 14676