akhauriyash/Code-Regression huggingface dataset:
import itertools
#人数
n = int(input())

#証言リスト
syougen = []
for i in range(n):
  #証言数[a番目の証言]
  a = int(input())
  detail =[]
  for s in range(a):
    t,h = map(int,input().split())
    detail.append([t,h])
  syougen.append(detail)

maxHonor = 0
#全探索
for i in itertools.product([0,1],repeat=n):
  honor = 0
  dare = 0
  for s in i:    
    isCorrect=True
    #正直物の場合
    if s == 1:
      honor+=1
      for d in syougen[dare]:
        # 証言と対象の属性があっているかチェック
        if d[1] == i[d[0]-1]:
          continue
        else:
          isCorrect=False
          break
      if isCorrect==False:
        break
      
    dare+=1
  #全員チェックOKの場合、最大値を保持      
  if isCorrect == True and honor > maxHonor:
    maxHonor = honor

print(maxHonor)

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

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

int A, B, C;

void solve()
{
    cin >> A >> B >> C;
    if((C % gcd(A, B)) == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 256
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        double ans = 0;
        for(int i = 0; i < N; i++){
            double x = sc.nextDouble();
            String u = sc.next();
            if( u.equals("BTC") ) x *= 380000;
            ans += x;
        }
        
        System.out.println(ans);
        
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;

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

    int n;
    cin >> n;

    int cnt = 0;
    int si = 0;
    for (int i = 1; i <= 1000; i++)
    {
        cnt += i;
        si++;
        if (n == cnt)
            break;
    }

    if (n != cnt)
    {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl
         << si + 1 << endl;

    si++;
    cnt = 1;

    V ans[1100];
    for (int i = 0; i < si; i++)
    {
        for (int j = i + 1; j < si; j++)
        {
            ans[i].push_back(cnt);
            ans[j].push_back(cnt);

            cnt++;
        }
    }

    for (int i = 0; i < si; i++)
    {
        cout << ans[i].size();
        for (int j = 0; j < ans[i].size(); j++)
        {
            cout << " " << ans[i][j];
        }
        cout << endl;
    }

    return 0;

    int t[1100][1100];

    cnt = 1;
    for (int i = 0; i < si; i++)
    {
        for (int j = 0; j <= i; j++)
        {
            t[i][j] = cnt;
            cnt++;
        }
    }

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

        cout << si;

        for (int j = 0; j < i; j++)
        {
            cout << " " << t[i][j];
        }

        for (int j = i; j < si; j++)
        {
            cout << " " << t[j][i];
        }

        cout << endl;
    }

    cout << si;

    cnt = 2;
    for (int i = 0; i < si; i++)
    {
        cout << " " << cnt * (cnt - 1) / 2;
        cnt++;
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a)      cout<<a<<" "
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll minize(ll& a,ll b){return a=(a>b?b:a);}
inline ll maxize(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5],B[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	sc(n);
	fu(i,1,n)sc(A[i]);
	fu(i,1,n)sc(B[i]);
	
	fu(i,0,(1LL<<n)-1){
		x=y=0;
		fu(b,0,n-1)if(bit(i,b))x+=A[b+1],y+=B[b+1];
		maxize(ans,x-y);
	}
	pr(ans);


	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	}
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define up_b upper_bound
#define low_b lower_bound
#define nl '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

const int N=2e5+11;
const int M=1e6+11;
const int inf=1e9+1;
const ld EPS=1e-6;
const ll INF=1e18;
const ll mod=/*998244353*/1e9+7;
const int dx[4]={0,0,-1,1};
const int dy[4]={-1,1,0,0};

int a[N];

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0),cout.tie(0);
  int n,k;
  cin>>n>>k;
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  for(int i=k+1;i<=n;i++){
    if(a[i-k]<a[i])cout<<"Yes";
    else cout<<"No";
    cout<<nl;
  }
}


Measured memory_bytes: 4436
#include <stdio.h>

int main(void){
    int num,sign=0,mode,line[3],i,sum=0;
    scanf("%d",&num);
    for(i=0;i<num;i++){
        scanf("%d %d %d",&line[0],&line[1],&line[2]);
        sign=0;
        sum=0;
        if(line[0] == 0){
            printf("0\n");
        }
        else{
            while(1){
            if(line[1]== 0 )
                mode=0;
            else if(line[2] == 0)
                mode=1;
            else
                mode=2;
            switch(mode){
                case 0:
                    if(line[0] >= 3){
                        line[0]-=3;
                        sum++;
                    }
                    else{
                        printf("%d\n",sum);
                        sign=1;
                    }
                    break;
                case 1:
                    if(line[0] >= 2){
                        line[0]-=2;
                        line[1]-=1;
                        sum++;
                    }
                    else{
                        printf("%d\n",sum);
                        sign=1;
                    }
                    break;
                case 2:
                    if(line[0] >= 1){
                        line[0]-=1;
                        line[1]-=1;
                        line[2]-=1;
                        sum++;
                    }
                    else{
                        printf("%d\n",sum);
                        sign=1;
                    }
                    break;
            }
            if(sign == 1)
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
struct Elm {
  int l, r, w;
};
void solve(int n) {
  vector<Elm> v;
  for(int i=0;i<n;++i) {
    int l, r, w; cin >> l >> r >> w;
    r++;
    v.push_back({l, r, w});
  }
  sort(v.begin(), v.end(), [](Elm e1, Elm e2){return (e1.l == e2.l) ? e1.r < e2.r : e1.l < e2.l;});
  vvi dp(367, vi(367, 0));
  for(int i=0;i<n;++i) {
    int l = v[i].l, r = v[i].r, w = v[i].w;
    for(int j=366;j>=1;--j) {
      for(int k=366;k>=1;--k) {
        if(j <= l) {
          dp[r][k] = max(dp[r][k], dp[j][k] + w);
        }
        if(k <= l) {
          dp[j][r] = max(dp[j][r], dp[j][k] + w);
        }
      }
    }
  }
  int ans = 0;
  for(int i=1;i<367;++i) {
    for(int j=1;j<367;++j) {
      ans = max(ans, dp[i][j]);
    }
  }
  cout << ans << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    solve(n);
  }
}



Measured memory_bytes: 3396
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans1, ans2 = x, x
cnt1, cnt2 = 0, 0
while ans1 in p:
    ans1 += 1
    cnt1 += 1
while ans2 in p:
    ans2 -= 1
    cnt2 += 1
if cnt1 >= cnt2:
    print(ans2)
else:
    print(ans1)


Measured memory_bytes: 9180
/*
      author : nishi5451
      created: 10.08.2020 23:57:58
*/

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


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

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

using namespace std;

#define Rep(i,a,b)  for (int i=(a);i<(b);i++)
#define rep(i,n)    for (int i=0;i<(n);i++)
#define all(x)      (x).begin(), (x).end()

#define ll long long

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if ((a < c && c < b) || (b < c && c < a))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}



Measured memory_bytes: 256
def multiply(num_list):
  # if "0" in list, return 0
  if 0 in set(num_list):
    return 0
  
  # if res > 10^18: return -1
  MAX = pow(10,18)
  res = 1
  for i in num_list:
    res *= i
    if res == 0:
      return 0
    if res > MAX:
      return -1
  return res

input()
num_list = list(map(int,input().split()))
print(multiply(num_list))

Measured memory_bytes: 21616
from collections import deque,defaultdict

N,X,Y = map(int,input().split())

L= [[1]]+[[i-1,i+1] for i in range(1,N-1)]+ [[N-2]]
L[X-1].append(Y-1)
L[Y-1].append(X-1)

def BFS(x,L):
  d=[-1 for _ in range(N)] #距離
  d[x]=0
  v=deque([x])
  
  while len(v)>0:
    a=v.popleft()
    for num in L[a]:
      if d[num]==-1:
        d[num]=d[a]+1
        v.append(num)
  return d

ans=defaultdict(int)

for j in range(N):
  tmp=BFS(j,L)
  #print(tmp)
  for num in tmp:
    ans[num] += 1
    
for k in range(1,N):
  if k in ans:
    print(ans[k]//2)
  else:
    print(0)


Measured memory_bytes: 54236
import Control.Monad (replicateM)
import Data.Array.IO

import Control.Monad.ST
import Data.Array.ST

makeSets :: Int -> ST s (STUArray s Int Int)
makeSets n = newListArray (1, n) [1..n]

find :: STUArray s Int Int -> Int -> ST s Int
find arr x = do
  parent <- readArray arr x
  if parent == x
    then return x
    else do
      root <- find arr parent
      writeArray arr x root
      return root

union :: STUArray s Int Int -> Int -> Int -> ST s ()
union sets x y = do
  x_root <- find sets x
  y_root <- find sets y
  writeArray sets x_root y_root

readOperation :: String -> (Int, Int)
readOperation s = let [x, y] = map read . words $ s in (x, y)

solve :: [(Int, Int)] -> [Int] -> Int
solve operations permutation = runST $ do
    sets <- makeSets (length permutation)
    mapM_ (uncurry (union sets)) operations
    sum <$> mapM (beTogether sets) (zip [1..] permutation)
  where
    beTogether sets (i, x) = do
      i_root <- find sets i
      x_root <- find sets x
      if i_root == x_root
        then return 1
        else return 0

main :: IO ()
main = do
  [_n, m] <- map read . words <$> getLine
  permutation <- map read . words <$> getLine
  operations <- replicateM m (readOperation <$> getLine)
  print $ solve operations permutation


Measured memory_bytes: 132988
#include<stdio.h>

int main(void){
  int ice[10];
  int n,i,d;

  for(;;){
    scanf("%d",&n);
    if(n==0)
      break;
    
    // Init
    for(i=0;i<10;i++)
      ice[i]=0;

    // Counting
    for(i=0;i<n;i++){
      scanf("%d",&d);
      ice[d]++;
    }

    // Output
    for(i=0;i<10;i++){
      if(ice[i]==0)
	puts("-");
      else{
	int t=ice[i];
	int j;

	for(j=0;j<t;j++)
	  printf("*");
	puts("");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main()
{
  int n, k;
  cin >> n >> k;
  bool isEven = k % 2 == 0;
  int x = 0, y = 0;
  if (isEven)
  {
    for (int i = 1; i <= n;i++){
      if(i%k==0){
        x++;
      }
      if(i%k==k/2){
        y++;
      }
    }
  }else{
    for (int i = 1; i <= n;i++){
      if(i%k==0){
        x++;
      }
    }
  }
  ll ans = (ll)pow(x, 3) + (ll)pow(y, 3);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include<iomanip>

using namespace std;

const int N = 2000 + 5;
int vertice[N][N];
int edges[N][N];
int row[N][N];
int column[N][N];
int n, m, q;
int a[N][N];

int main()
{
	cin >> n >> m >> q;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		for (int j = 0; j < m; j++)
		{
			a[i][j] = s[j] - '0';
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 2; j <= m; j++)
		{
			row[i][j] = row[i][j - 1];
			if (a[i - 1][j - 1] && a[i - 1][j - 2])
			{
				row[i][j]++;
			}
		}
	}
	for (int i = 2; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			column[i][j] = column[i - 1][j];
			if (a[i - 1][j - 1] && a[i - 2][j - 1])
			{
				column[i][j]++;
			}
		} 
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			vertice[i][j] = a[i - 1][j - 1] + vertice[i - 1][j] + vertice[i][j - 1] - vertice[i - 1][j - 1];
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			edges[i][j] = edges[i - 1][j] + edges[i][j - 1] - edges[i - 1][j - 1];
			if (i != 1 && a[i - 1][j - 1] && a[i - 2][j - 1])
			{
				edges[i][j]++;
			}
			if (j != 1 && a[i - 1][j - 1] && a[i - 1][j - 2])
			{
				edges[i][j]++;
			}
		}
	}
	/*
	cout << endl;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			cout << column[i][j] << " ";
		}
		cout << endl;
	}
	*/
	for (int i = 0; i < q; i++)
	{
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		int v = vertice[x2][y2] - vertice[x1 - 1][y2] - vertice[x2][y1 - 1] + vertice[x1 - 1][y1 - 1];
		int e = edges[x2][y2] - edges[x1][y2] - edges[x2][y1] + edges[x1][y1] + row[x1][y2] - row[x1][y1] + column[x2][y1] - column[x1][y1];
		//cout << v << " " << e << " ";
		cout << v - e << endl;
	}

}


 

Measured memory_bytes: 80256
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <iostream>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long llu;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<int> ans;

ll dp[1000][2];
int tr[1000][2];

int vec[1000];
char visit[1000];
int n;

ll go(int o, int ch) {
	if (o >= n) {
		if (ch) return 0;
		return -1e17;
	}
	if (dp[o][ch] > -2e17) return dp[o][ch];

	ll mav = -1e17;

	ll t = go(o + 2, ch);
	if (mav < t) {
		mav = t;
		tr[o][ch] = 0;
	}

	t = go(o + 2, 1) + vec[o];
	if (mav < t) {
		mav = t;
		tr[o][ch] = 1;
	}

	return dp[o][ch] = mav;
}

int main() {
	for (int i = 0; i < 1000; i++)
		dp[i][0] = dp[i][1] = -3e17;

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &vec[i]);

	ll mav = -1e18, mavi = 0, t;

	t = go(0, 0);
	if (mav < t) {
		mav = t;
		mavi = 0;
	}

	t = go(1, 0);
	if (mav < t) {
		mav = t;
		mavi = 1;
	}

	printf("%lld\n", mav);

	t = mavi;
	int kk = 0;

	while (t < n) {
		if (tr[t][kk]) {
			visit[t] = 1;
			kk = 1;
		}
		t += 2;
	}

	int flag = -1, tt;
	for (int i = n - 1; i >= 0; i--) {
		if (flag != -1) {
			if (visit[i]) {
				tt = (i + flag) / 2;
				for (int j = 0; j < tt - i; j++)
					ans.push_back(tt + 1 - j);
				flag = i;
			}
		}
		else {
			if (visit[i]) flag = i;
			else ans.push_back(i + 1);
		}
	}

	for (int i = 0; i < n; i++) {
		if (visit[i]) break;
		ans.push_back(1);
	}

	printf("%d\n", sz(ans));
	for (int i = 0; i < sz(ans); i++)
		printf("%d\n", ans[i]);
}

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

using ll = long long;

ll modpow(ll x, ll n, const ll mod) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) (res *= x) %= mod;
        (x *= x) %= mod;
        n >>= 1;
    }
    return res;
}
ll inverse(ll x, const ll mod) {
    return modpow(x, mod - 2, mod);
}

// calc c[n - 1], ..., c[0],
//   where P(x) := c[n-1]*x^{p-1} + ... + c[0], P(xs[i]) = ys[i] (mod m) (i = 0, \ldots, n - 1)
// Complexity: O(n^2)
std::vector<ll> lagrange_interpolation(std::vector<ll> xs, std::vector<ll> ys, const int m) {
    const int n = xs.size();
    for(int i = 0; i < n; ++i) {
        xs[i] %= m;
        ys[i] %= m;
    }
    std::vector<ll> all_c(n + 1);
    all_c[0] = 1;
    for(int i = 0; i < n; ++i) {
        std::vector<ll> nxt(n + 1);
        for(int j = 0; j < n; ++j) {
            nxt[j + 1] = all_c[j];
        }
        for(int j = 0; j < n; ++j) {
            nxt[j] = (m + nxt[j] - xs[i] * all_c[j] % m) % m;
        }
        all_c = std::move(nxt);
    }

    std::vector<ll> c(n);
    for(int i = 0; i < n; ++i) {
        ll qi = 1;
        for(int j = 0; j < n; ++j) {
            if(i == j) continue;
            qi = qi * (m + xs[i] - xs[j]) % m;
        }
        qi = inverse(qi, m) * ys[i] % m;

        auto tmp_c = all_c;
        for(int j = n - 1; j >= 0; --j) {
            c[j] = (c[j] + qi * tmp_c[j + 1]) % m;
            tmp_c[j] = (tmp_c[j] + tmp_c[j + 1] * xs[i]) % m;
        }
    }
    return c;
}

using namespace std;

int main() {
    int p; cin >> p;
    vector<ll> xs(p), ys(p);
    for(int i = 0; i < p; ++i) {
        xs[i] = i;
        cin >> ys[i];
    }
    auto res = lagrange_interpolation(xs, ys, p);
    for(int i = 0; i < p; ++i) {
        cout << res[i] << " \n"[i + 1 == p];
    }
}


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

#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    int m, n;
    cin >> n >> m;
    int l, r;
    int mi = 0;
    int ma = 1000000;
    rep(i, m){
        cin >> l >> r;
        mi = max(mi, min(l, r));
        ma = min(ma, max(l, r));
    }
    int ans = ma - mi + 1;
    if(ans >= 0){
        cout << ans << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

ll hp[100001];
int N;
int AA, PA; // All Attack     : B
			// Private Attack : A-B

void input() {
	int A, B;
	cin >> N >> A >> B;
	AA = B;
	PA = A - B;

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

// k回の爆発ですべて倒せるかどうか
bool isWin(ll k) {
	vector<ll> restMonster;
	for (int i = 0; i < N; i++) {
		if (hp[i] > AA*k) restMonster.push_back(hp[i] - AA * k);
	}
	ll tot = 0;
	for (int i = 0; i < restMonster.size(); i++) {
		if (restMonster[i] % PA == 0) tot += restMonster[i] / PA;
		else tot += restMonster[i] / PA + 1;
	}
	return (tot <= k);
}

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

	input();

	// 2分探索
	// 解は left < 解 <= right
	ll left = 0;
	ll right = 1000000000;
	while (right != left + 1) {
		ll mid = (left + right) / 2;
		if (isWin(mid)) right = mid;
		else left = mid;
	}

	cout << right << endl;

	return 0;
}

Measured memory_bytes: 2916
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CSkillUp {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N, M, X;
        cin >> N >> M >> X;
        vector<int> C(N);
        vector<vector<int>> A(N, vector<int>(M));
        REP(i, N) {
            cin >> C[i];
            REP(j, M) {
                cin >> A[i][j];
            }
        }

        int res = INF;
        REP(s, 1 << N) {
            vector<int> x(M);
            int cost = 0;
            REP(i, N) {
                if (s >> i & 1) {
                    REP(j, M) {
                        x[j] += A[i][j];
                    }
                    cost += C[i];
                }
            }
            bool ok = true;
            REP(j, M) {
                if (x[j] < X) {
                    ok = false;
                    break;
                }
            }
            if (!ok) continue;

            res = min(res, cost);
        }
        if (res >= INF) res = -1;
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CSkillUp solver;
    solver.solve(in, out);
    return 0;
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<long long> vecll;
typedef vector<unsigned long long> vecull;

int N, M;

struct Tower {
    int h;
    veci friends;
};

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

    vector<Tower> T(N);

    rep(i, N) {
        cin >> T[i].h;
    }

    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        T[a].friends.push_back(b);
        T[b].friends.push_back(a);
    }

    int ans = 0;

    rep(i, N) {
        bool flag = true;
        for(int idx : T[i].friends) {
            if (T[i].h <= T[idx].h) {
                flag = false;
                break;
            }
        }

        if (flag) ans++;
    }

    // veci searched(N, 0);
    // veci t(N, 0);
    // for(int i = 0; i < N; ++i) {
    //     if (searched[i] != 0) continue;

    //     stack<int> S;
    //     S.push(i);
    //     searched[i] = 1;
    //     int max_h = T[i].h;
    //     bool bucking = false;
    //     bool find = false;

    //     while(!S.empty()) {
    //         int idx = S.top();
    //         for (int k = t[idx]; k < T[idx].friends.size(); ++k) {

    //             if (searched[k] == 0) {
    //                 searched[k] = 1;
    //                 if (max_h == T[k].h) {
    //                     bucking = true;
    //                 }
    //                 else {
    //                     max_h = max(max_h, T[k].h);
    //                     if (max_h == T[k].h) bucking = false;
    //                 }

    //                 t[i] = k;
    //                 find = true;
    //                 break;
    //             }
    //         }

    //         if (!find) {
    //             S.pop();
    //         } 
    //     }

    //     if (!bucking) ans++;
    // }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8980
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)2e9 + 7)
#define INF ((int)2e9)
#define INFLL ((LL)2e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (2 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 2, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 1) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 2;
    LL sum = a;
    while(b){
        if(b&2)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

double exp(double a, LL b){
    double res = 1;
    double sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

PII operator+(const PII &a, const PII &b){
    return PII(a.first + b.first, a.second + b.second);
}

vector<vector<int> > xc(100001), yc(100001);

PII func(PII p){
    PII res(0, 0);
    if(!xc[p.first].empty()){
        vector<int> line = xc[p.first];
        xc[p.first].clear();
        ++res.first;
        for(auto &i:line){
            res = res + func(PII(p.first, i));
        }
    }
    if(!yc[p.second].empty()){
        vector<int> line = yc[p.second];
        yc[p.second].clear();
        ++res.second;
        for(auto &i:line){
            res = res + func(PII(i, p.second));
        }
    }
    return res;
}

signed  main(){
    string str[3];
    REP(i, 3)cin>>str[i];
    REP(i, 2){
        if(str[i].back()!=str[i+1].front()){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;
const ll mod  = 1e9 + 7;
const int INF = 2e9;
using pint = pair <int, int>;

int main() {
  int h, w, n;
  cin >> h >> w >> n;
  int m = max(h, w);
  cout << (n + m - 1) / m << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<set>
#include<algorithm>
using namespace std;
int s[100000];
int p[1000000];
int q[1000000];
int r[1000000];
int ans[100000];
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	set<pair<int,int> >S;
	for(int i=0;i<a;i++){
		S.insert(make_pair(0,i));
	}
	for(int i=0;i<b;i++){
		scanf("%d%d%d",p+i,r+i,q+i);
		p[i]--;
	}
	int now=0;
	for(int i=0;i<c;i++){
		while(now<b&&r[now]==i){
			S.erase(make_pair(-s[p[now]],p[now]));
			s[p[now]]+=q[now];
			S.insert(make_pair(-s[p[now]],p[now]));
			now++;
		}
		pair<int,int> M=*(S.begin());
		ans[M.second]++;
	}
	int val=0;
	int at=0;
	for(int i=0;i<a;i++){
		if(val<ans[i]){
			val=ans[i];
			at=i;
		}
	}
	printf("%d\n",at+1);
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    int alice = 0, bob = 0;
    for(int i = 0; i < n; i++){
        if(i % 2 == 0) alice += a[i];
        else bob += a[i];
    }
    cout << alice - bob << endl;
}

Measured memory_bytes: 256
// author:  Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;

// ll modexp(ll x, ll y, ll p)
// {
// 	ll res = 1;
// 	x = x % p;
// 	while (y > 0)
// 	{
// 		if (y & 1)
// 			res = (res * x) % p;
// 		y = y >> 1;
// 		x = (x * x) % p;
// 	}
// 	return res;
// }

// ll mulmod(ll a, ll b,ll m)
// {
// 	return ((a % m) * (b % m)) % m;
// }

// ll sub_mod(ll a, ll b, ll m){
//    if (a >= b)
//        return a - b;
//    else
//        return m - b + a;
// }

// ll add_mod(ll a, ll b){
//    if (0 == b) 
//        return a;

//    b = mod - b;
//    if (a >= b)
//        return a - b;
//    else
//        return mod - b + a;
// }

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

// ll modInv(ll a) 
// { 
//     ll g = gcd(a, mod); 
//     if (g != 1) 
//         return -1; 
//     else
//         return modexp(a, mod-2, mod); 
// } 
int main()
{
	fastio;
	// #ifndef ONLINE_JUDGE   
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif
	ll a=0,b=0,m=0;
	cin>>a>>b>>m;
	vector<ll>v1(a);
	vector<ll>v2(b);
	ll mina=INT_MAX,minb=INT_MAX;
	for(ll i=0;i<a;++i){
		cin>>v1[i];
		mina=min(v1[i],mina);
	}
	for(ll i=0;i<b;++i){
		cin>>v2[i];
		minb=min(v2[i],minb);
	}
	ll ans=mina+minb;
	ll x=0,y=0,c=0;
	while(m--){
		cin>>x>>y>>c;
		ans=min(ans,v1[--x]+v2[--y]-c);
	}
	cout<<ans<<"\n";

}



Measured memory_bytes: 1792
// inputに入力データ全体が入る
function Main(input) {
  var b;
  b = input.split('\n')[0];
  
  switch(b){
    case 'A':
      console.log('T');
      break;
    case 'C':
      console.log('G');
      break;
    case 'G':
      console.log('C');
      break;
    case 'T':
      console.log('A');
      break;
  }
  
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(){
  int N,K,sum=1;
  cin>>N>>K;
  for (int i=0;i<N;i++){
    if (sum>K){
      cout<<sum+K*(N-i)<<endl;
      break;
    }
    sum*=2;
    if (i==N-1){
      cout<<sum<<endl;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>
#include <ctime>
#include <numeric>
#include <cstdlib>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

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

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

ll N;
ll P;
ll ans = 1;
ll x = 2;
ll num;

ll calc( ll a, ll b ){
	ll res = 1;
	ll temp = a;
	while( b ){
		if( b % 2 ) res *= temp;
		if( res > P ){
			res = mod * mod;
			break;
		}
		temp = temp * temp;
		b /= 2;
	}
	return res;
}

int main(){
	
	cin>>N>>P;
	num = calc( x, N );
	
	if( N > 50 ){
		puts("1");
	}
	else if( N == 1 ){
		cout<<P<<endl;
	}
	else{
		while( num <= P ){
			if( P % num == 0 ) ans = x;
			//cout<<x<<";"<<num<<endl;
			x++;
			num = calc( x, N );
		}
		
		cout<<ans<<endl;
	}
		
	return 0;
	
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  long h,w;
  scanf("%ld %ld", &h, &w);

  long answer;
  long row;
  long column;

  if (h == 1 || w == 1) {
    printf("1\n");
    return 0;
  }

	if (h % 2 == 0) {
    answer = h/2;
    answer *= w;
  } else {
    row = h+1;
    row /= 2;
    if (w % 2 == 0) {
      answer = row*2 - 1;
      column = w/2;
      answer *= column;
    } else {
      answer = row*2 - 1;
      column = w-1;
      column /= 2;
      answer *= column;
      answer += row;
    }
  }

  printf("%ld\n", answer);

  return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    x = 0
    mx = 0
    for Si in S:
        x += 1 if Si == "I" else -1
        mx = max(mx, x)
    print(mx)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		sc.close();
		String ans[] = {"Yay!", ":("};
		int an = 0;
		if(Math.max(a, b) > 8)an = 1;
		System.out.println(ans[an]);
	}

}


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

#define thegamebegins   ios_base::sync_with_stdio(false); cin.tie(NULL); //cout.tie(NULL);
#define fileio          freopen('input.txt', 'r', stdin); freopen('output.txt', 'w', stdout);
#define int             long long
#define float           long double
#define test            int TESTS; cin>>TESTS; for(int CASE=1; CASE<=TESTS; ++CASE)
#define in(a,n)         for(int i=0; i<(n); ++i)  cin>>a[i]
#define r0              return 0
#define E               '\n'
#define S               ' '
#define elif            else if 
#define M               1000000007
#define fi(i,x,y)       for(int i=(x); i<(y); ++i)
#define fb(i,x,y)       for(int i=(x); i>=(y); --i)
#define fa(i,s)         for(auto i:(s))
#define fp(i,s)         for(auto i=(s).begin(); i!=(s).end(); ++i)
#define pf(i,s)         for(auto i=(s).rbegin(); i!=(s).rend(); ++i)
#define all(s)          (s).begin(), (s).end()
#define rev(s)          (s).rbegin(), (s).rend()
#define sz(s)           (int)(s).size()
#define vi              vector <int>
#define vpii            vector <pair <int,int> >
#define mii             map <int,int>
#define pii             pair <int,int>
#define seti            set <int>
#define setd            set <int,greater <int> >
#define sortd(a,n)      sort(a, a+n, greater<int>())
#define pb              push_back
#define fr              first
#define sc              second
#define lb              lower_bound
#define ub              upper_bound
#define er              equal_range
 
const int INF = 0x3f3f3f3f;

signed main()
{
    thegamebegins

    int a,b,c,k;	cin>>a>>b>>c>>k;
    int ans=0;
    ans+=min(k,a);
    k-=min(k,a);
    if(k==0)
    {
    	cout<<ans;
    	r0;
    }
    k-=min(k,b);
    if(k==0)
    {
    	cout<<ans;
    	r0;
    }
    ans-=min(k,c);
    cout<<ans;
    r0;
}


Measured memory_bytes: 3652
//#include<bits/stdc++.h>
#include<iostream>
#include <vector>
#include <cstdio>
#include<algorithm>
#include <utility>
#include<string>
using namespace std;
int main() {
	int i=0, j=0;
	string str[10000] = { "" };
	char ch[10000];
	while (1) {
		scanf("%c", &ch[i]);
		if (ch[i] == '\n') {
			break;
		}
		else if (ch[i] == ' ') {
			j++;
		}
		else {
			str[j] += ch[i];
		}
		i++;
	}int memoa,memop;
	for (int l = 0; l <= j; l++) {
		memoa = str[l].find("apple");
		memop = str[l].find("peach");
		if (memoa != -1) {
			str[l].replace(memoa,5,"peach");
		}
		if (memop != -1) {
			str[l].replace(memop, 5, "apple");
		}
		if (l == j ) {
			cout << str[l] << endl;
		}
		else {
			cout << str[l] << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 3284
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//for
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//range
#define all_range(C) begin(C), end(C)
//STL
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//chmin&chmax
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//GCD
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//LCM
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//POW
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
    --y;
  }

  return sum;
}

//main.cpp----------------------------


int main() {
  int n, k;
  string s;

  string alfa = "abcdefghijklmnopqrstuvwxyz";

  cin >> n >> k >> s;

  rep(i, n) {
    if((i+1)==k) {
      cout << alfa[s[i]-'A'];
    }else cout << s[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
import heapq
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
asort,bsort,csort = sorted(A,reverse=True),sorted(B,reverse=True),sorted(C,reverse=True)
already = set((0,0,0))
print(asort[0] + bsort[0] + csort[0])
x,y,z = 0,0,0
check = []
for k in range(K - 1):
    if (x + 1,y,z) not in already and x + 1 < X:
        already.add((x + 1,y,z))
        heapq.heappush(check,(-(asort[x + 1] + bsort[y] + csort[z]),x + 1,y,z))
    if (x,y + 1,z) not in already and y + 1 < Y:
        already.add((x,y + 1,z))
        heapq.heappush(check,(-(asort[x] + bsort[y + 1] + csort[z]),x,y + 1,z))
    if (x,y,z + 1) not in already and z + 1 < Z:
        already.add((x,y,z + 1))
        heapq.heappush(check,(-(asort[x] + bsort[y] + csort[z + 1]),x,y,z + 1))
    maxsum = heapq.heappop(check)
    print(-maxsum[0])
    x,y,z = maxsum[1],maxsum[2],maxsum[3]

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

using namespace std;

int main() {
	int n, l;
	scanf("%d%d", &n, &l);
	
	int tot = l * n + n * (n - 1) / 2;
	
	if (l >= 0) {
		tot -= l;
	}
	else if (l + n - 1 < 0) {
		tot -= l + n - 1;
	}
	
	printf("%d\n", tot);
}


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

// マクロ //
#define rep(v,times) for(int v = 0; v < (int)(times); v++)
#define req(v,first,endplus1) for(int v = first; v < (int)(endplus1); v++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using plili = pair<lint, lint>;
using vplili = vector<plili>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvli = vector<vli>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using mii = map<int, int>;
using mili = map<int, lint>;
using mci = map<char, int>;
using mcli = map<char, lint>;
using msi = map<string, int>;
using msli = map<string, lint>;


// 関数 //
template<class T, class Q> lint gcd_(T a, Q b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T, class Q> lint lcm_(T a, Q b) {
    return a * b / gcd_(a, b);
}

template<class T, class Q> double distance(T a, Q b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);
const int dx4[4] = { 1,0,-1,0 };
const int dy4[4] = { 0,1,0,-1 };
const int dx8[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy8[8] = { 0,1,1,1,0,-1,-1,-1 };

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
        
    int N, M ,L;
    int cnt = 0;
    cin >> N >> M >> L;
    req(i, N, M + 1) {
        if (i % L == 0) cnt++;
    }
    cou(cnt);


}

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

int main()
{
	int n;
	stack<int> st;

	while(cin>>n)
	{
		if(0<n) st.push(n);
		else
		{
			cout<<st.top()<<endl;;
			st.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 1200
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
			String str = kb.readLine();
			int q = Integer.parseInt( kb.readLine() );
			
			StringBuilder output = new StringBuilder( 1000+1 );
			int start, end;
			while( 0 < q-- ) {
				String[] instruction = kb.readLine().split( " " );
				start = Integer.parseInt( instruction[1] );
				end = Integer.parseInt( instruction[2] );
				if( instruction[0].equals( "print" ) ) {
		        	System.out.println( str.substring( start, end+1 ) );
				} else if( instruction[0].equals( "reverse" ) ) {
					output.append( str.substring( start, end+1 ) );
					output.reverse();
					output.insert( 0, str.substring( 0, start )  );
					output.append( str.substring( end+1 ) );
					str = output.toString();
				} else if( instruction[0].equals( "replace" ) ) {
					output.append( str );
					output.replace( start, end+1, instruction[3]  );
					str = output.toString();
				}
				output.setLength( 0 );
			}
				        
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}

Measured memory_bytes: 21264
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
ll n,x,ans;
void solve(ll x,ll y){
    if(x>y) swap(x,y);
    if(!x){
        ans-=y;
        return;
    }
    ans+=(y/x)*x*2;
    solve(y%x,x);
}
int main(){
    cin>>n>>x;
    ans=n;
    solve(x,n-x);
    cout<<ans<<endl;
    //system("pause");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<vector> //動的配列
#include<string> 
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <cmath>

typedef long long ll;


using namespace std;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}


int n;
int x;
int y;
ll len[32];
string ans[32];


int main(){
    cin>>n;
    ll add[n];
    ll dif[n];
    for (int i=0;i<n;i++){
        cin>>x>>y;
        add[i]=x+y;
        dif[i]=x-y;
    }
    for (int i=0;i<31;i++) {
        len[i]=std::pow(2,(30-i));
    }
    len[31]=1;
    //bool check=true;
    for (int i=0;i<n-1;i++){
        if ((abs(add[i])%2)!=(abs(add[i+1])%2)){
            printf("%d",-1);
            //check=false;
            return 0;
        }
    }
    for (int i=0;i<n;i++){
        for (int j=0;j<33;j++){
            if (add[i]==0 && dif[i]==0 &&(j==32 or j==31)){
                //cout<<n<<i<<j<<endl;
                if (i==0){
                    cout<<j<<endl;
                    for (int k=0;k<j;k++){
                        cout<<len[k]<<" ";
                    }
                    cout<<endl;
                }
                for (int k=0;k<j;k++){
                    cout<<ans[k];
                }
                cout<<endl;
                break;
            }else if (add[i]>=0 && dif[i]>=0){
                ans[j]="R";
                add[i]-=len[j];
                dif[i]-=len[j];
            } else if (add[i]>=0 && dif[i]<=0){
                ans[j]="U";
                add[i]-=len[j];
                dif[i]+=len[j];
            } else if (add[i]<=0 && dif[i]<=0){
                ans[j]="L";
                add[i]+=len[j];
                dif[i]+=len[j];
            } else if (add[i]<=0 && dif[i]>=0) {
                ans[j]="D";
                add[i]+=len[j];
                dif[i]-=len[j];
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256