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

int main() {
  int N;

  cin >> N;

  vector<int> a(N);

  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }

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

  int diff = 0;
  for (int i = 0; i < N; i += 2) {
    diff += a.at(i);
    if (i + 1< N) {
      diff -= a.at(i + 1);
    }
  }

  if (diff < 0) {
    diff *= -1;
  }

  cout << diff << endl;
}


Measured memory_bytes: 3564
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
// #include<map>
#include<cmath>
#include<list>
#define ll long long
#define N 150005
#define pb push_back
#define Sca(a) scanf("%d",&a)
#define Scs(a) scanf("%s",&a)
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define Scal(a) scanf("%ld",&a)
#define Scall(a) scanf("%lld",&a)
#define Pri(a) printf("%d",a)
#define Prs(a) printf("%s",a)
#define Pril(a) printf("%ld",a)
#define Prill(a) printf("%lld",a)
#define FAST_IO ios::sync_with_stdio(false)
using namespace std;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
const double pi = 3.141592653;
using namespace std;
template <class T>void tomax(T&a, T b) {
	a = max(a, b);
}
template <class T>void tomin(T&a, T b) {
	a = min(a, b);
}
int main(){
	int n;
	cin>>n;
	cout<<n*n*n<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
typedef vector<lint> LIV;
#define rep(i,n) for(int i=0;i<n;++i)
#define MAXN 100010
#define MAXM 1100000
#define all(v) v.begin(),v.end()
#define inf 2147483647
#define linf 1152921504606846976

#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
typedef vector<lint> LIV;
#define rep(i,n) for(int i=0;i<n;++i)
#define MAXN 100010
#define MAXM 1100000
#define all(v) v.begin(),v.end()
#define inf 2147483647
#define linf 1152921504606846976
#define MAX_N 100010

class UnionFind{
public://par,rank,init,uf,uf,root,same,unite
	int par[MAXN],rank[MAXN],sum[MAXN];
	lint ans;
	void init(int n){
		rep(i,n)par[i]=i,rank[i]=0,sum[i]=1;
	}
	UnionFind(int n){
		init(n);
	}UnionFind(){}
	int root(int x){
		return x==par[x]?x:par[x]=root(par[x]);
	}
	bool same(int x,int y){
		return root(x)==root(y);
	}
	void unite(int x,int y){
		x=root(x);
		y=root(y);
		if(x==y)return;
		ans-=sum[x]*sum[y];
		if(rank[x]<rank[y]){
			par[x]=y;
			sum[y]+=sum[x];
		} else{
			par[y]=x;
			sum[x]+=sum[y];
			if(rank[x]==rank[y])++rank[x];
		}
	}
};

int main(){
	lint n,m;cin>>n>>m;
	vector<pair<lint,lint> > e(m);
	vector<lint>a;
	rep(i,m)cin>>e[i].first>>e[i].second,--e[i].first,--e[i].second;
	UnionFind t(n);
	t.ans=n*(n-1)/2;
	for(int i=m-1;i>=0;--i){
		a.push_back(t.ans);
		t.unite(e[i].first,e[i].second);
	}
	for(int i=m-1;i>=0;--i)cout<<a[i]<<endl;
}


//int main(){//平方数を1<k<=nで割ったあまりを求める
//	lint n;cin>>n;
//	LIV ans(n);
//	for(int i=1;i<=n;++i){
//		set<int> s;
//		rep(x,i)s.insert(x*x%i);
//		cout<<i<<": ";
//		for(auto x:s)cout<<x<<",";cout<<endl;
//		ans[i-1]=s.size();
//	}rep(i,n)cout<<ans[i]<<endl;
//	getchar();
//	getchar();
//}

//sub-EOF


Measured memory_bytes: 4980
#include <bits/stdc++.h>
using namespace std;
int main(){
long double A,B;
cin>>A>>B;
if(A>B){
	cout<<"GREATER";
    }
else if(A<B)
  {
	cout<<"LESS";
}
else
{
	cout<<"EQUAL";
}
return 0;
}
	


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    string s;
    cin >> s;
    rep(i, 4) cout << s[i];
    cout << " ";
    rep(i, 8) cout << s[i+4];
    cout << endl;
}

Measured memory_bytes: 256
from heapq import heappop, heappush

def prim(adjacent:list, root=0):
    '''
    Prim法。最小全域木のコストを求める。負の閉路も可
    --------
        adjacent : 隣接リスト
        root     : 探索開始頂点
    --------
        min_cost : 最小コスト
    '''
    n = len(adjacent)
    visited = [False] * n
    min_cost = 0
    q = [(0, root)]
    while q:
        weight, vi = heappop(q)
        if visited[vi]:
            continue
        visited[vi] = True
        min_cost += weight
        for vj, weight in adjacent[vi]:
            if not visited[vj]:
                heappush(q, (weight, vj))
    return min_cost

n = int(input())
xordered = []
yordered = []
for i in range(n):
    x, y = map(int, input().split())
    xordered.append((x, y, i))
    yordered.append((y, x, i))
xordered.sort()
yordered.sort()

adjacent = [[] for _ in range(n)]
for i in range(n-1):
    x0, y0, v0 = xordered[i]
    x1, y1, v1 = xordered[i+1]
    weight = min(abs(x0-x1), abs(y0-y1))
    adjacent[v0].append((v1, weight))
    adjacent[v1].append((v0, weight))
    x0, y0, v0 = yordered[i]
    x1, y1, v1 = yordered[i+1]
    weight = min(abs(x0-x1), abs(y0-y1))
    adjacent[v0].append((v1, weight))
    adjacent[v1].append((v0, weight))

print(prim(adjacent))



Measured memory_bytes: 136616
N, K = [int(_) for _ in input().split()]
S = input()
s1 = []
s0 = []
if S[0] == '0':
    s1.append(0)

tmp = S[0]
cnt = 1
for s in S[1:]:
    if tmp != s:
        if tmp == '0':
            s0.append(cnt)
        else:
            s1.append(cnt)
        cnt = 0
    tmp = s
    cnt += 1
if tmp == '0':
    s0.append(cnt)
    s1.append(0)
else:
    s1.append(cnt)

val = 0

j = 0
for i in range(min(K, len(s0))):
    val += s0[i] + s1[i]
    j = i + 1
val += s1[j]
l = 0

pre = val
for i in range(j, len(s0)):
    tmp = pre - s0[l] - s1[l]
    tmp += s0[i] + s1[i + 1]
    val = max(val,tmp)
    l += 1
    pre = tmp
print(val)


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

using namespace std;

int main(){
  int N,H,W; cin>>N>>H>>W;

  vector<int>A(N),B(N);
  for(int i=0;i<N;i++){
    cin>>A[i]>>B[i];
  }

  int ans=0;
  for(int i=0;i<N;i++){
    if(A[i]>=H&&B[i]>=W) ans++;
  }

  cout<<ans<<endl;

  return 0;
}


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

typedef long long int LL;
typedef pair<LL, LL> PLL;


int main(int argc, char *argv[]) {
  LL N, C;
  cin >> N >> C;
  N+=2;
  vector<PLL> sushi(N);
  sushi[0].first = sushi[0].second = 0;
  sushi[1].first = C;
  sushi[1].second = 0;
  for (int i = 2; i < N; ++i) {
    cin >> sushi[i].first >> sushi[i].second;
  }
  sort(sushi.begin(), sushi.end());

  vector<LL> acum_cw(N);
  vector<LL> best_cw(N);
  LL acum = 0;
  LL best = 0;
  for (int i = 0; i < N; ++i) {
    acum += sushi[i].second;
    acum_cw[i] = acum;

    LL benefit = acum_cw[i] - 2 * sushi[i].first;
    if (i == 0) {
      best = benefit;
      best_cw[i] = 0;
    } else if (benefit > best) {
      best = benefit;
      best_cw[i] = i;
    } else {
      best_cw[i] = best_cw[i - 1];
    }
  }

  vector<LL> acum_ccw(N);
  vector<LL> best_ccw(N);
  best = 0;
  vector<LL> best_ccw_back(N);
  LL best_back = 0;
  acum = 0;
  for (int i = N - 1; i >= 0; i--) {
    acum += sushi[i].second;
    acum_ccw[i] = acum;

    LL benefit = acum_ccw[i] - (C - sushi[i].first);
    LL benefit_back = acum_ccw[i] - 2 * (C - sushi[i].first);
    if (i == N - 1) {
      best = benefit;
      best_back = benefit_back;
      best_ccw[i] = best_ccw_back[i] = i;
      continue;
    }
    best_ccw[i] = best_ccw[i + 1];
    best_ccw_back[i] = best_ccw_back[i + 1];

    if (benefit > best) {
      best = benefit;
      best_ccw[i] = i;
    }

    if (benefit_back > best_back) {
      best_back = benefit_back;
      best_ccw_back[i] = i;
    }
  }

  best = 0;
  for (int i = 0; i < N-1; ++i) {
    LL walk_cw = sushi[i].first;
    LL benefit_cw = acum_cw[i];
    LL benefit_one_dir = benefit_cw - walk_cw;
    best = max(best, benefit_one_dir);

    
    LL pos_ccw = best_ccw[i + 1];
    LL walk_ccw = C - sushi[pos_ccw].first;
    LL benefit_ccw = acum_ccw[pos_ccw];
    LL benefit_two_dir = benefit_one_dir + benefit_ccw - walk_ccw - walk_cw;
    best = max(best, benefit_two_dir);

    LL pos_ccw_back = best_ccw_back[i + 1];
    LL walk_ccw_back = C - sushi[pos_ccw_back].first;
    LL benefit_ccw_back = acum_ccw[pos_ccw_back];
    LL benefit_two_dir_back = benefit_one_dir + benefit_ccw_back - 2*walk_ccw_back;
    best = max(best, benefit_two_dir_back);
  }

  /*
  cout << endl;
  for (int i = N-1; i > 0; --i) {
    LL walk_ccw = C - sushi[i].first;
    LL benefit_ccw = acum_ccw[i];
    LL benefit_one_dir = benefit_ccw - walk_ccw;
    best = max(best, benefit_one_dir);

    LL pos_cw = best_cw[i - 1];
    LL walk_cw = sushi[pos_cw].first;
    LL benefit_cw = acum_cw[pos_cw];
    LL benefit_two_dir = benefit_one_dir + benefit_cw - 2*walk_cw;
    best = max(best, benefit_two_dir);
  }*/



  cout << best << endl;
  return EXIT_SUCCESS;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vvll = vector<vector<ll>>;
using vll = vector<ll>;

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll res1 = max(a*c,a*d);
    ll res2 = max(b*c,b*d);
    cout<<max(res1,res2);
    //RRre if(0<c && 0<d && a<=0 && b<=d)cout<<b*d;
    //else cout<<max(abs(a),abs(b))*max(abs(c),abs(d));
    return 0;
}

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

int main() {
  int x, y;
  cin >> x >> y;
  int ans = 0;
  ans += max(0, 4-x) * 100000;
  ans += max(0, 4-y) * 100000;
  if (x == 1 && y == 1) ans += 400000;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

typedef tuple<string, int, int> T;

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

    int n, m; cin >> n >> m;
    vector<int> s[m];
    vector<int> p(m);
    for(int i=0; i<m; ++i){
        int k; cin >> k;
        for(int j=0; j<k; ++j){
            int si; cin >> si;
            --si;
            s[i].push_back(si);
        }
    }
    for(int i=0; i<m; ++i) cin >> p[i];

    int ans = 0;
    for(int bit=0; bit<1<<n; ++bit){
        bool all_ok = true;
        for(int i=0; i<m; ++i){
            int cnt = 0;
            for(auto id:s[i]) if(bit&1<<id) ++cnt;
            
            if(cnt%2 != p[i]) { all_ok = false; break; }
        }
        if(all_ok) ++ans;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long int LL;
#define fr(i,p,n) for(LL i=p;i<n;i++)
#define fr1(i,p,n) for(LL i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(10) << std::fixed;

using namespace std;
 
int main()
{
long long N, A[87], CurrentMoney = 1000;
 cin >> N;
 for (int i = 1; i <= N; i++) cin >> A[i];
 for (int i = 1; i <= N - 1; i++) {
 long long Stocks = 0;
 if (A[i] < A[i + 1]) Stocks = CurrentMoney / A[i];
 CurrentMoney += (A[i + 1] - A[i]) * Stocks;
 }
 cout << CurrentMoney << endl;
    return 0;
}

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

int main()
{
	int a,b,c,d,it1=0,it2=0;
	cin>>a>>b>>c>>d;
	it1=a/d;it2=c/b;
	if(it1>=it2)
	{
		if((a%d==0)  && (it1==it2) && (c%b!=0))
		{
			cout<<"No";
			return 0;	
		}
		cout<<"Yes";
	}
	else{
		if(((it1+1)==it2) && (c%b==0) && (a%d!=0) )
		{
			cout<<"Yes";
			return 0;
		}
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(c >= a)
	{
		if(c <= b) printf("Yes");
		else printf("No");
	}
	else printf("No");
	
   	return 0;
}

Measured memory_bytes: 2116
import java.util.Scanner;

public class Main {
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int i = 1;
  do {
   int x = i;
   if (x % 3 == 0) {
    System.out.print(" " + i);
   } else {
    do {
     if (x % 10 == 3) {
      System.out.print(" " + i);
      break;
     }
     x /= 10;
    } while (x != 0);
   }
  } while (++i <= n);
  System.out.println();
 }
}

Measured memory_bytes: 28472
import sys
input = sys.stdin.readline

N, K = map(int,input().split())
P = list(map(int, input().split()))
Ans = sum(P[0:K])+K
Ans_max = Ans

for i in range(0,N-K):
    A = P[i]
    B = P[i+K] 
    Ans = Ans+B-A
    if B > A:
        Ans_max = max(Ans_max, Ans)
    
print(Ans_max/2)

Measured memory_bytes: 67824
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int a,b,c;
	scan(a>>b>>c);
	if(a==b&&b==c) prin("Yes");
	else prin("No");
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();
        int N = r.i();
        int[] P = r.ii();

        int[] Q = new int[N+1];
        for(int i = 0; i < N; i++)
          Q[P[i]] = i;

        ArrayList<Integer> list = new ArrayList<>();
        Collections.addAll(list, -1, -1, N, N);

        long ans = 0;
        for(int v = N; v > 0; v--){
          int i = Q[v];
          int j = -Collections.binarySearch(list, i)-1;
          Iterator<Integer> iterator = list.listIterator(j-2);
          long w = iterator.next();
          long x = iterator.next();
          long y = iterator.next();
          long z = iterator.next();
          long c = (x-w)*(y-i) + (i-x)*(z-y);
          list.add(j, i);
          ans += v*c;
        }
        println(ans);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


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

using namespace std;

int main(void){
  int N;
  cin >> N;
  vector<int> a(N);
  int c = 0;
  for(int i = 0; i < N; i++){
    cin >> a[i];
    if(a[i] == c + 1) c++;
  }
  if(c != 0) cout << N - c << endl;
  else cout << -1 << endl;
  return 0;
}


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

#define vi vector<int>
#define vii vector<int, int>
#define ll long long
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << 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(...) 42
#endif

const int MOD = 1000000007;

int main(){
    IOS;
    string s;
    cin >> s;

    bool f = 0;
    for (int i = 0; i < 3; i++){
        if (s[i] == s[i+1]){
            f = 1;
            break;
        }
    }
    if (f) cout << "Bad" << endl;
    else cout << "Good" << endl;

    #ifdef LOCAL
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int H[3000], W[3000], i, l, k, n;
  for(i=0;;i++){
    scanf("%d %d", &H[i], &W[i]);
    if(H[i]==0 && W[i]==0){
      break;
    }
  }
  n = i-1;
  for(i=0;i<=n;i++){
    for(l=0;l<H[i];l++){
      for(k=0;k<W[i];k++){
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
    return 0;
}

Measured memory_bytes: 1808
#include <stdio.h>
int main(void){
    // Your code here!
    int n;
    scanf("%d\n",&n);
    
    int i,tmp;
    int a[100];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=n-1;i>=0;--i){
        printf("%d",a[i]);
        if(i != 0){
            printf(" ");
        }
        else{
            printf("\n");
        }
    }
    
    return 0;
   
}



Measured memory_bytes: 2128
n=int(input())
from copy import*
ans=[]
for i in range(n+1): #10000円を6円で払う分と9円で払う分に分ける
    count=0
    money6=i
    money9=n-i
    while money6:
        count+=money6%6
        money6//=6
    while money9:
        count+=money9%9
        money9//=9
    ans.append(count)
print(min(ans))


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

namespace ABC150A
{
	class Program
	{
		static void Main(string[] args)
		{
			int k,x,n;
			var word = Console.ReadLine().Split(' ');
			k = int.Parse(word[0]);
			x = int.Parse(word[1]);

			n = 500 * k;
			if (n >= x)
				Console.WriteLine("Yes");
			else
				Console.WriteLine("No");

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int n;
string s, t, m, r;
int main () {
	cin >> s;
	n = s.size();
	r = s;
	reverse(r.begin(), r.end());
	if(s != r) {
		cout << "No";
		return 0;
	}
	for(int i = 0; i < (n - 1) / 2; i++) {
		t += s[i];
	}
	r = t;
	reverse(s.begin(), s.end());
	if(t != r) {
		cout << "No";
		return 0;
	}
	for(int i = (n + 3) / 2 - 1; i < s.size(); i++) {
		m += s[i];
	}
	r = m;
	reverse(r.begin(), r.end());
	if(m != r) {
		cout << "No";
		return 0;
	}
	cout << "Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

int main(){
	int n, k, d, b; cin >> n >> k;
	bool a[110] = {};
	rep(i, k){
		cin >> d;
		rep(j, d){
			cin >> b;
			a[b] = true;
		}
	}
	int ans = -1;
	rep(i, n + 1) if(!a[i]) ans++;
	cout << ans << endl; 
}

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  uint64_t g = gcd(m,n);
  if(m%g==0) return (m/g)*n;
  if(n%g==0) return (n/g)*m;
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

/* 
  //エラトステネスのふるい
  int maxNum = 100000;
  char isNotPrime[maxNum+1] = {};
  isNotPrime[0]=isNotPrime[1]=1;
  for(int i=2;i<maxNum;i++){
    if(isNotPrime[i]==1) continue;
    int num = i+i;
    while(num<=maxNum){
      isNotPrime[num]=1;
      num += i;
    }
  }
*/
// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

// 降順ソート vector<int> v;
// sort(v.begin(),v.end(),greater<int>());

signed main() {
  ll n;
  cin >> n;
  
  // 2, 2, 2, 2, 3, 3 , 5    ->  5*3*2 = 15

  map<int,int> factors;
  for(ull i=2;i<=(ull)n;i++){
    list<ull> fs;
    primeFactorization(i, fs);
    for(auto f:fs){
      factors[(int)f]++;
    }
  }
  
  ull total = 1;
  for(auto f: factors){
    total *= f.second+1;
    total %= MOD;
  }
  
  cout << total << endl;

  return 0;
}



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

void Main() {
    // input
    u_int64_t N;
    cin >> N;
    u_int64_t A[N+1];
    for (u_int64_t i = 1; i <= N; i++) {
        cin >> A[i];
    }


    // process
    u_int64_t mod = 1000000000 + 7;
    u_int64_t sum = 0;
    u_int64_t tmpSum = 0;

    for (u_int64_t i = N - 1; i >= 1; i--) {
        tmpSum += A[i+1];
        tmpSum %= mod;

        u_int64_t tmp = (A[i] * tmpSum) % mod;
        sum = (sum + tmp) % mod;
    }


    // output
    cout << sum << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;

ll H,W,N;
vector< pair<ll,ll> > coor;
vector<ll> ans(10,0);

bool in_range(ll y,ll x)
{
	return y >= 0 && y < H && x >= 0 && x < W;
}

void cnt_around(ll ny,ll nx,int idx)
{
	vector< vector<int> > cnt(3,vector<int>(3,1));
	for(int i = 0;i < 3;i++){
		for(int j = 0;j < 3;j++){
			ll y = ny + i - 1,x = nx + j - 1;
			bool flag = true;
			for(int k = -1;k <= 1;k++){
				for(int l = -1;l <= 1;l++){
					ll yy = y + k,xx = x + l;
					if(in_range(yy,xx) == false){
						flag = false;
						break;
					}
					if(binary_search(coor.begin(),coor.begin() + idx,MP(yy,xx))){
						cnt [i] [j]++;
					}
				}
				if(flag == false) break;
			}
			if(flag){
				ans [cnt [i] [j] - 1]--;
				ans [cnt [i] [j]]++;
			}
		}
	}
}

int main()
{
	scanf("%lld%lld%lld",&H,&W,&N);
	coor.resize(N);
	FOR(i,0,N){
		scanf("%lld%lld",&coor [i].first,&coor [i].second);
		coor [i].first--,coor [i].second--;
	}
	sort(ALL(coor));
	ans [0] = (H - 2) * (W - 2);

	FOR(i,0,N){
		cnt_around(coor [i].first,coor [i].second,i);
	}

	FOR(i,0,10){
		printf("%lld\n",ans [i]);
	}

	return 0;
}


Measured memory_bytes: 2300
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
long long int gcd(long long int a,long long int b);

int main()
{
  long long int N,M;
  long long int i,j,k;
  long long int A,B;
  long long int ans=0;
  char buff[256];

  scanf("%lld",&N);
  
  for(i=1;i<=N;i++){
    for(j=1;j<=N;j++){
      A = gcd(i,j);
      for(k=1;k<=N;k++){
        B = gcd(A,k);
        ans += B;
      }
    }
  }

  printf("%lld\n",ans);
  return 0; 
}


long long int gcd(long long int a,long long int b){

  long long int r;
  long long int space;
  
  if( b > a ){
    space = a; a = b; b = space;
  }
  
  r = a%b;
  while( r!=0 ){
    a = b;
    b = r;
    r = a%b;
  }
  
  //printf("%lld\n",b);
  return b; 
}

Measured memory_bytes: 2152
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

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

		for(int i = 0; i < q; i++) {
			int query = sc.nextInt();

			switch(query) {
			case 0:  //insert
				String key = sc.next();
				int x = sc.nextInt();
				map.put(key, x);
				break;

			case 1:  //get
				key = sc.next();
				System.out.println(map.getOrDefault(key, 0));
				break;

			case 2:  //delete
				key = sc.next();
				map.remove(key);
				break;

			case 3:  //dump
				String first = sc.next();
				String last = sc.next();
				map.subMap(first, true, last, true).forEach((color, value) ->
					System.out.println(color + " " + value));
			}
		}
	}

}



Measured memory_bytes: 203924
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,j,pn=0
    logical:: is_prime(2:55555)
    integer(int32), allocatable:: p(:)

    read*, n
    is_prime(:) = .true.
    do i=2,55555
        if (.not. is_prime(i)) cycle
        j = 2
        do while(i*j <= 55555)
            is_prime(i*j) = .false.
            j=j+1
        end do
        if (mod(i,5) == 1) pn=pn+1
    end do
    allocate(p(pn))
    j=1
    do i=2,55555
        if (.not. is_prime(i)) cycle
        if (mod(i,5) /= 1) cycle
        p(j) = i
        j=j+1
    end do
    print'(*(i0,1x))', p(1:n)
end program main

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

using namespace std;


int main() {

    int R, G, B, N;
    cin >> R >> G >> B >> N;
    long long ans = 0;
    int MAX = N + 1;
    for (int i = 0; i < MAX; ++i) {
        int r = i * R;
        if (r > N){ break;}
        for (int j = 0; j < MAX; ++j) {
            long long balls = i * R + j * G;
            if ((N - balls) % B == 0 && (N - balls) / B >= 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define io_optimized ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

int main () {
	io_optimized
	int t,n,min;
	while(cin>>t)
	{
		t--;
		int sum=1;
		cin>>min;
		while(t--)
		{
			cin>>n;
			if(n<=min)
			{
				min=n;
				sum++;
			}
		}
		cout<<sum<<"\n";
	}

	return 0;
}


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

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            List<string> name = new List<string>();
            List<int> kazu = new List<int>();
            int max = 0;
            int n = int.Parse(Console.ReadLine());
            
            string s = "";
            for(int i = 0 ; i < n ; i++)
            {
                s = Console.ReadLine();
                if(!name.Contains(s))
                {
                    name.Add(s);
                    kazu.Add(0);
                }
                kazu[name.IndexOf(s)]++;
            }
            
            int m = int.Parse(Console.ReadLine());
            for(int i = 0 ; i < m ; i++)
            {
                s = Console.ReadLine();
                if(name.Contains(s))
                {
                    kazu[name.IndexOf(s)]--;
                }
            }
            
            for(int i = 0 ; i < kazu.Count ; i++)
            {
                max = Math.Max(max, kazu[i]);
            }
            
            Console.WriteLine(max);
        }
    }
}

Measured memory_bytes: 13152
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
#define printd(x) printf("%.12f\n", ans);
#define Yes() cout << "Yes" << endl;
#define No() cout << "No" << endl;
#define YES() cout << "YES" << endl;
#define NO() cout << "NO" << endl;
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

const int inf = 1e9 + 10;

int main(void) {
    
    //cin.tie(nullptr);ios::sync_with_stdio(false);cout << fixed << setprecision(20);

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

    string s;
    cin >> s;

    int n = s.size();

    s += 'x';

    int ans1 = 0, ans2 = inf;
    
    rep (i, n) {
        if (s[i] != s[i + 1]) ans1++;
    }
    
    cout << ans1 - 1 << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define DBG(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define fi first
#define se second
#define PI (acos(-1))
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
template<class T,class V> ostream& operator<<(ostream &s,pair<T,V> a)
{
    s<<a.fi<<' '<<a.se;
    return s;
}
void done(bool ok){
    if(ok)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    exit(0);
}
int main()
{
    fastread;
    ll T=1;
//    cin>>T;
    for(ll qq=1;qq<=T;qq++)
    {
        ll n;
        cin>>n;
        ll sum=0,mn=INF;
        deque<ll> v(n);
        for(auto &x:v)cin>>x,mn=min(mn,x),sum+=x;
        ll a=n*(n+1)/2;
        if(sum%a)done(0);
        a=sum/a;
        while(mn!=v.front())v.push_back(v.front()),v.pop_front();
        ll cur=0,cnt=0;
        for(int i=1;i<n;i++){
            v[i]-=cur;
            ll k=(a+v[i-1]-v[i]);
            if(k%n||k<0)done(false);
            k/=n;
            v[i-1]-=k*n;
            v[i]-=k;
            a-=k;
            cnt+=k;
            cur+=k+cnt;
        }
        done(true);
    }
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;

// topological_sort
constexpr int MAX_N = 100005;
int used_topo[MAX_N];
vector<int> edg[MAX_N];

bool __rec_topo(vector<int> &topo, int pos) {
	if (used_topo[pos] == -1) return false;
	if (used_topo[pos] == 1) return true;
	used_topo[pos] = -1;
	for (int i : edg[pos]) {
		if (!__rec_topo(topo, i)) return false;
	}
	used_topo[pos] = 1;
	topo.push_back(pos);
	return true;
}

// Perform topological sort of the graph defined by edg.
// n: The number of vertices.
// The sorting result will be stored in the first argument topo.
// Returning false means the graph is not DAG.
bool topo_sort(vector<int> &topo, int n) {
	bool flag = true;
	for (int i = 0; i < n; i++) {
		if (used_topo[i] == 0) flag &= __rec_topo(topo, i);
	}
	reverse(topo.begin(), topo.end());
	return flag;
}

ll dp[100005];

int main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y; cin >> x >> y;
		x--; y--;
		edg[x].push_back(y);
	}
	vector<int> topo;
	topo_sort(topo, n);
	for (int i : topo) {
		for (int e : edg[i]) {
			dp[e] = max(dp[e], dp[i] + 1);
		}
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) ans = max(ans, dp[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9464
/*********************************************JMD**********************************************/
//                                  |\  |     | |   |   /\                                   //
    //                              | \ |     | |---|  /--\                              //
        //                          |  \| |___| |   | /    \1999                     //
/*******************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) forr(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));

const ll mod=1e9 + 7;

/*******************************************************************************************/

void solve()
{
    ll a,b,t;
    cin>>a>>b>>t;

    cout<<b*(floor(t/a))<<"\n";
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t=1;
    //cin>>t;
    clock_t launch=clock();

    while(t--)
    {
        solve();
    }

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N, M;
    cin >> N >> M;
    cout << (N-1) * (M-1) << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
l=[[0 for j in range(30)] for i in range(4)]
for _ in range(n):
  b,f,r,v=map(int,input().split())
  l[b-1][(f-1)*10+r-1] += v
for i in range(4):
  print('',*l[i][:10])
  print('',*l[i][10:20])
  print('',*l[i][20:])
  if i < 3:
    print('#'*20)


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

#define min(a,b) ((a<b) ? a : b)

int cost[10][10];

/*
void showPath(int n)
{
    int i,j;
    cout << "------------------------" << endl;
    for (i = 0 ; i <= n ; i++) {
        cout << cost[i][0];
        for (j = 1 ; j <= n ; j++) {
            cout << ", " << cost[i][j];
        }
        cout << endl;
    }
    cout << "------------------------" << endl;
}
*/

void calcPath(int n)
{
    int s,i,j,k,d;

    for (s = 0 ; s < 45 ; s++) {
        for (i = 0 ; i <= n ; i++) {
            for (j = 0 ; j <= n ; j++) {
                d = cost[i][j];
                for (k = 0 ; k <= n ; k++) {
                    if ( (cost[i][k] < 0) || (cost[k][j] < 0) ) continue;
                    d = (d >= 0) ? min(d,cost[i][k]+cost[k][j]) : cost[i][k]+cost[k][j];
                }
                cost[i][j] = d;
            }
        }
    }
}

// ----------------------------------------------------------------
int main(void)
{
    int i,j,len, minpath,n, townA, townB, t, townLast, bestTownNo;

    while(cin >> n) {
        if (n <= 0) break;
        // Initialize variables
        memset(cost,-1,sizeof(cost));
        townLast = -1;
        // read & set data
        for (i = 0 ; i < n ; i++) {
            cin >> townA;
            cin >> townB;
            cin >> t;  // time A->B
            cost[townA][townA] = 0;
            cost[townB][townB] = 0;
            cost[townA][townB] = t;
            cost[townB][townA] = t;
            if (townA > townLast) townLast = townA;
            if (townB > townLast) townLast = townB;
        }
        // calculate minimum path
//        showPath(townLast);
        calcPath(townLast);
//        showPath(townLast);
        // find best solution
        bestTownNo = -1;
        minpath = -1;
        for (i = 0 ; i <= townLast ; i++) {
            len = 0;
            for (j = 0 ; j <= townLast ; j++) {
                if(cost[i][j] > 0) len += cost[i][j];
            }
            if ((minpath < 0) || (len < minpath)) {
                minpath = len;
                bestTownNo = i;
            }
        }
        cout << bestTownNo << " " << minpath << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include<iostream>

using namespace std;

int main(){
	int n;

	while(cin >> n) {
		int result = 0;
		for(int a = 0; a <= 9; a++) {
			for(int b = 0; b <= 9; b++) {
				for(int c = 0; c <= 9; c++) {
					for(int d = 0; d <= 9; d++) {
						if (n == a + b + c + d) result++;

					}	
				}	
			}
		}
		cout << result << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN
    ll n,k;cin>>n>>k;
    vll b(n);
    ll a=0;
    ll a2;
    REP(i,n){
        cin>>a2>>b[i];
        a = max(a,a2);
    }
    VSORTR(b);
    // ll sm=0;
    ll i =0;
    while(k>0){
        if (b[i] < a) break;
        k -= b[i];
        i++;
    }
    if (k>0){
        i += k / a;
        if(k%a) i++;
    }

    cout<<i<<endl;
    return 0;
}


Measured memory_bytes: 3972
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc =new Scanner(System.in);
		int n=sc.nextInt();
		long a[]=new long[n+1];
		
		for(int i=1;i<=n;i++) {
			a[i]=sc.nextLong();
		}
		
		long c[][]=new long[20][n+1];
		for(int i=0;i<20;i++) {
			c[i][0]=0;
		}
		for(int j=0;j<20;j++) {
			int second=n+1;
			int latest=n+1;
				for(int i=n;i>=1;i--) {
					if((a[i]>>>j)%2==1) {
						second=latest;
						latest=i;
						
					}
					c[j][i]=second;
					
			}
//				for(int i=count;i<=n;i++) {
//					c[j][i]=n+1;
//				}
		}
		long ans=0;
		for(int i=1;i<=n;i++) {
			long m=n+1;
			for(int j=0;j<20;j++) {
				if(m>c[j][i]) {
					m=c[j][i];
				}
			}
			ans+=m-i;
		}
		
		System.out.println(ans);
		
		
	}
	
}




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

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

	cin >> n;
	cin >> a;

	b = n / 500;
	c = n - (500 * b);

	if(c <= (1 * a)){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3040
import numpy as np
N=int(input())
a=[int(x) for x in input().split()]
A=0
B=0
while 1:
    A+=max(a)
    loc=np.argmax(a)
    a.pop(loc)
    if a==[]:break
    B+=max(a)
    loc=np.argmax(a)
    a.pop(loc)
    if a==[]:break
print(A-B)

Measured memory_bytes: 12452
#[allow(dead_code)]
fn main() {
    let (n, m) = i::u2();
    let uv = if m != 0 { i::uv2(m) } else { Vec::new() };
    let (s, t) = i::u2();

    let mut graph = vec![Vec::new(); n + 1];
    for (u, v) in uv {
        graph[u].push(v);
    }

    let mut dis = vec![vec![std::usize::MAX; 3]; n + 1];
    let mut q = VecDeque::new();
    q.push_front((s, 0));
    dis[s][0] = 0;
    while q.len() > 0 {
        let (from, t) = q.pop_front().unwrap();
        for &to in &graph[from] {
            if dis[to][(t + 1) % 3] == std::usize::MAX {
                dis[to][(t + 1) % 3] = dis[from][t] + 1;
                q.push_back((to, (t + 1) % 3));
            }
        }
    }
    if dis[t][0] == std::usize::MAX {
        println!("{}", -1);
        return;
    }
    println!("{}", dis[t][0] / 3);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 18684
#include "bits/stdc++.h"
using namespace std;
typedef complex<double> P;

int cr(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}

int dt(P a,P b){
  return a.real()*b.real()+a.imag()*b.imag();
}

int main(){
  for(;;){int x,y; P t[3],c;int r;
    for(int i=0;i<3;i++){cin>>x>>y;if((i|x|y)==0)return 0;t[i]=P(x,y);}
    cin>>x>>y;c=P(x,y);cin>>r;
    if(abs(t[0]-c)<=r&&abs(t[1]-c)<=r&&abs(t[2]-c)<=r){cout<<'b'<<endl;}
    else{double d[3];bool f[2]={};
      for(int i=0;i<3;i++){
        P l=t[(i+1)%3]-t[i];
        if(dt(l,c-t[i])>0&&dt(-l,c-t[(i+1)%3])>0){
        	d[i]=fabs(cr(l,c-t[i])/abs(l));
        	}else{
        		d[i]=min(abs(c-t[i]),abs(c-t[(i+1)%3]));
        	}f[cr(l,c-t[i])<0]=true;
      	  }if(f[0]^f[1]&&d[0]>=r&&d[1]>=r&&d[2]>=r){
      		  cout<<'a'<<endl;
      	  }else if(d[0]<=r||d[1]<=r||d[2]<=r){
      		  cout<<'c'<<endl;
      	  }else{
    	  cout<<'d'<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const ll INF = 1000000000000;

int main() {
	
	ll n, w, i, j, m = 0, mv = 0;
	cin >> n >> w;
	vll ws(n), vs(n);

	for (i = 0; i < n; i++) {
		cin >> ws[i] >> vs[i];
		m += vs[i];
	}

	vvll dp(n + 1, vll(m + 1, INF));

	for (i = 0; i <= n; i++) {
		dp[i][0] = 0;
		if (i > 0) {
			for (j = 1; j <= m; j++) {
				dp[i][j] = dp[i - 1][j];
				if (vs[i - 1] <= j)
					dp[i][j] = min(dp[i][j], dp[i - 1][j - vs[i - 1]] + ws[i - 1]);
				if (dp[i][j] <= w)
					mv = max(mv, j);
			}
		}
	}

	cout << mv << "\n";

	return 0;
}

Measured memory_bytes: 83004
N,T = map(int,input().split())
c= [list(map(int,input().split())) for i in range(N)]
s= sorted(c, key=lambda x: x[0])
flg = -1
for i in range(N):
  if s[i][1] <= T:
    flg = i
    break
print(s[flg][0] if flg != -1 else "TLE")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define M ((int)1e9)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi acos(-1)
typedef long long ll;
using namespace std;
int n;

void solve()
{
    ll n;
    cin>>n;
    cout<<n*(n-1)/2<<endl;
}



int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int prime[1000100];
bool is_prime[1000100];
void sieve(int n){
    // n以下の素数を求める
    int p = 0;
    for(int i=0;i<=n;i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <=n ; i++){
        if(is_prime[i]){
            prime[p++]=i;
            for(int j=2*i;j <=n;j+=i) is_prime[j] = false;
        }
    }
}
int main(){
    cout << fixed << setprecision(10);
    sieve(100010);
    vector<int> ans(100010,0);
    for(int i = 1; i < 100010; i++){
        if(i % 2 != 0){
            if( is_prime[(i+1)/2] && is_prime[i]){
                ans[i] = ans[i-1] + 1;
            }else ans[i] = ans[i-1];
        }else ans[i] = ans[i-1];
    }
    int q;
    cin >> q;
    rep(i,q){
        int l,r;
        cin >> l >> r;
        cout << ans[r] - ans[l-1] << endl;
    }

    // cout << "out" << endl;
    // rep(i,12) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 3752