akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const ll M=512;
int n;

vl f(){
	vvi g(n);
	int m;
	cin>>m;
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		if(u>v) swap(u,v);
		g[u].push_back(v);
	}
	vl a(n),b(M),c(M);
	for(int i=n-1;i>=0;i--){
		for(auto j:g[i]) c[a[j]]++;
		for(int j=0;;j++) if(!c[j]){
			a[i]=j;
			break;
		}
		for(auto j:g[i]) c[a[j]]--;
	}
	ll t=1;
	for(int i=0;i<n;i++){
		(t*=1000000000000000000%mod)%=mod;
		(b[a[i]]+=t)%=mod;
	}
	return b;
}

int main(){
	cin>>n;
	vl a=f(),b=f(),c=f();
	ll res=0;
	for(int i=0;i<M;i++) for(int j=0;j<M;j++) (res+=a[i]*b[j]%mod*c[i^j])%=mod;
	cout<<res<<endl;
}

Measured memory_bytes: 5192
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#define fRead(x)       freopen(x,"r",stdin)
#define fWrite(x)      freopen (x,"w",stdout)
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}

template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

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

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

int a[N];
bool vis[N];
int main()
{
    int n;
    Int(n);

    for(int i=1;i<=n;++i){
        Int(a[i]);
    }
    sort(a+1,a+n+1);
    int res=0;
    for(int i=1;i<=n;++i){
        if(!vis[a[i]]){
            if(a[i]!=a[i+1])++res;
            for(int j=a[i];j<N;j+=a[i]){
                vis[j] = true;
            }
        }
    }
    printf("%d\n",res);

    return 0;
}






Measured memory_bytes: 5464
// In the name of God

#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5+5;
int a[N], diff[N];

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


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int fir,sec;
bool f,s;
int main(){
    scanf("%2d%2d",&fir,&sec);
    if(1<=fir&&fir<=12) s=1;
    if(1<=sec&&sec<=12) f=1;
    if(f&&s) printf("AMBIGUOUS");
    else if(f) printf("YYMM");
    else if(s) printf("MMYY");
    else printf("NA");
}


Measured memory_bytes: 256
N = int(input())
s = []
for i in range(N):
    val = sorted(input())
    s.append(val)

an = 0
for i in range(N):
    if len(s[an]) <= len(s[i]):
        continue
    else:
        an = i

a = s[an]

for i in range(N):
    n = 0
    while a != s[i] and n < len(a) and n < len(s[i]):
        if a[n] == s[i][n]:
            n += 1
        else:
            if a[n] > s[i][n]:
                s[i].pop(n)
            else:
                a.pop(n)
    if len(a) > len(s[i]):
        a = s[i]

print(''.join(a))

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k;
	cin>>k;
	int a,b;
	cin>>a>>b;
	int count=0;
	for(int i=a; i<=b; i++)
	{
		if(i%k==0)
		{
			count++;
			break;
		}
	}
	if(count>0)
	{
		cout<<"OK"<<endl;
	}else
	{
		cout<<"NG"<<endl;
	}
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>

using namespace std;

struct Node {
    Node() = default;
    Node(int x, Node *p = nullptr, Node *n = nullptr): x_val(x), prev(p), next(n) {}
    int x_val = 0;
    Node *prev = nullptr;
    Node *next = nullptr;
};

Node *insert(Node* first, int x) {
    Node *node = nullptr;
    if (!first) {
        node = new Node(x);
        node->prev = node;
        node->next = node;
    } else {
        node = new Node(x, first->prev, first);
        first->prev->next = node;
        first->prev = node;
    }
    return node;
}

Node *delete_x(Node* first, int x) {
    if (first->x_val == x) {
        if (first->prev != first->next) {
            Node *node = first;
            first->prev->next = first->next;
            first->next->prev = first->prev;
            first = first->next;
            delete node;
        } else {
            delete first;
            return nullptr;
        }
    } else {
        Node *traval_node = first->next;
        while (traval_node != first) {
            if (traval_node->x_val == x) {
                Node *node = traval_node;
                traval_node->prev->next = traval_node->next;
                traval_node->next->prev = traval_node->prev;
                delete node;
                break;
            }
            traval_node = traval_node->next;
        }
    }
    return first;
}

Node *deleteFirst(Node *first) {
    if (first->prev != first) {
        Node *node = first;
        first->prev->next = first->next;
        first->next->prev = first->prev;
        first = first->next;
        delete node;
        return first;
    } else {
        delete first;
        return nullptr;
    }
}

Node *deleteLast(Node *first) {
    if (first->prev != first) {
        Node *node = first->prev;
        first->prev = node->prev;
        node->prev->next = first;
        delete node;
        return first;
    } else {
        delete first;
        return nullptr;
    }
}

Node *print(Node *first) {
    Node *node = first;
    printf("%d", node->x_val);
    while (node->next != first) {
        node = node->next;
        printf(" %d", node->x_val);
    }
    printf("\n");
    return first;
}

int
main(int argc, const char *argv[])
{
    Node *first = nullptr;

    int n;
    cin >> n;
    cin.get();
    while (n--) {
        char input[20];
        fgets(input, 20, stdin);
        input[strlen(input)-1] = '\0';
        if (strcmp(input, "deleteFirst") == 0) {
            first = deleteFirst(first);        
        } else if (strcmp(input, "deleteLast") == 0) {
            first = deleteLast(first);
        } else {
            char command[10];
            int i = 0;
            while (input[i] != ' ') {
                command[i] = input[i]; 
                ++i;
            }
            command[i] = '\0';
            int x = atoi(input+i+1);
            if (strcmp(command, "insert") == 0) {
                first = insert(first, x);    
            } else if (strcmp(command, "delete") == 0) {
                first = delete_x(first, x);
            }
        }
    }
    print(first);

    return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    string s;
    cin >> s;
    int n = s.size();
    vi sum(2019);
    int ans = 0, p = 0, ten = 1;
    sum[0]++;
    repr(i, n) {
        int m = ((s[i] - '0') * ten + p) % 2019;
        ans += sum[m];
        sum[m]++;
        p = m;
        ten = ten * 10 % 2019;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <tuple>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;
 
struct Node
{
  vector<int> to;
  vector<int> cost;
};
Node Graph[1010];
void AddEdge(int from, int to, int cost, Node *graph)
{
  graph[from].to.push_back(to);
  graph[from].cost.push_back(cost);
}
bool negative[1010];
ll dp[1010];
 
int main()
{
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i)
  {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    AddEdge(a, b, -c, Graph);
  }
 
  for (int i = 0; i < 1010; ++i)
  {
    dp[i] = 1e15;
  }
 
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
  for (int v = 0; v < n; ++v)
  {
    for (int k = 0; k < Graph[v].to.size(); ++k)
    {
      int to = Graph[v].to[k];
      ll cost = Graph[v].cost[k];
      if (dp[v] != 1e15 && dp[to] > dp[v] + cost)
      {
        dp[to] = dp[v] + cost;
      }
    }
  }
  }
  for (int v = 0; v < n; ++v)
  {
    for (int k = 0; k < Graph[v].to.size(); ++k)
    {
      int to = Graph[v].to[k];
      ll cost = Graph[v].cost[k];
      if (dp[to] > dp[v] + cost)
      {
        dp[to] = dp[v] + cost;
        negative[to] = true;
      }
    }
  }
  if (negative[n - 1])
  {
    cout << "inf" << endl;
    return 0;
  }
  cout << -dp[n - 1] << endl;
 
  return 0;
}

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

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

    int lose = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'x') lose++;
    }
    if (lose > 7) cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    ll a, b;
    cin >> n >> a >> b;
    vector<ll> x(n);
    rep(i, n) cin >> x[i];
    ll ans = 0;
    rep(i, n - 1) {
        if ((x[i+1] - x[i]) * a < b) {
            ans += (x[i+1] - x[i]) * a;
        }
        else {
            ans += b;
        }
    } 
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4012
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();

        long answer = 0;

        for (int i = 1; i < n; i++) {
            answer += i;
        }

        System.out.println(answer);
    }
}


Measured memory_bytes: 23124
n = input()
s = input()

count = 0
for i in range(10):
  try:
    ii = s.index(str(i))
  except:
    continue
  for j in range(10):
    try:
      ji = s[ii + 1:].index(str(j))
    except:
      continue
    for k in range(10):
      try:
        ki = s[ii + ji + 2:].index(str(k))
        count += 1
      except:
        continue
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int> data(N + 2,0);
  long sum = 0;
  for (int i = 0; i < N + 1; i++) {
    cin >> data.at(i + 1);
    sum += abs(data.at(i) - data.at(i + 1));
  }
  for (int i = 0; i < N; i++) {
    cout << sum - abs(data.at(i) - data.at(i + 1)) - abs(data.at(i + 2) - data.at(i + 1)) + abs(data.at(i) - data.at(i + 2)) << endl; 
  }
  return 0;
}


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

signed main(void)
{
	int x, y, z, w, k;
	cin >> x >> y >> z >> k;
	vector<ll> a(x), b(y), c(z), d, e;
	rep(i, x) cin >> a[i];
	rep(i, y) cin >> b[i];
	rep(i, z) cin >> c[i];
	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	rep(i, x) rep(j, y)
		d.push_back(a[i] + b[j]);
	sort(d.rbegin(), d.rend());
	w = d.size();
	w = min(w, 3000);
	rep(i, w) rep(j, z)
		e.push_back(d[i] + c[j]);
	sort(e.rbegin(), e.rend());
	rep(i, k) cout << e[i] << endl;
	return 0;
}


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

using namespace std;

const int MAXN = 100005;

int path[2*MAXN], depth[2*MAXN], idx[MAXN];     // idx : the index of node in dfs path

int par[MAXN];
vector<int> adjList[MAXN];

class SegmentTree{
private:
    int n;
    vector<int> t;
    
    int combine(int l, int r){
        if (l == -1 || r == -1) return max(l,r);

        if (depth[l] < depth[r]) return l;
        return r;
    }
public:
    SegmentTree(int size){                                 // build tree
        n = size;
        t.assign(n<<1,0);

        for (int i=0; i<n; i++) t[n+i] = i;
        for (int i=n-1; i>0; i--) t[i] = combine(t[i<<1], t[i<<1|1]);
    }
    int query(int l, int r){                               // query in range v[l,r)
        if (r < l) swap(l,r); r++;
        int res = -1;
        for (l+=n, r+=n; l<r; l>>=1, r>>=1){
            if (l&1) res = combine(res,t[l++]);
            if (r&1) res = combine(res,t[--r]);
        }
        return res;
    }
};

int cnt = 0;
void dfs(int curr, int d){
    idx[curr] = cnt;

    path[cnt] = curr;
    depth[cnt++] = d;

    for (int i=0; i<adjList[curr].size(); i++){
        dfs(adjList[curr][i],d+1);

        path[cnt] = curr;
        depth[cnt++] = d;
    }
}

int main(){

    // init
    memset(par,-1,sizeof(par));

    int N;
    scanf("%d",&N);

    for (int u=0; u<N; u++){
        int M;
        scanf("%d",&M);

        int v;
        for (int i=0; i<M; i++){
            scanf("%d",&v);

            par[v] = u;
            adjList[u].push_back(v);
        }
    }

    // find root
    int root;
    for (int i=0; i<N; i++) if (par[i] == -1) root = i;

    dfs(root,0);

    // build RMQ
    SegmentTree st(cnt);
    
    int Q;
    scanf("%d",&Q);

    for (int i=0; i<Q; i++){
        int u, v;
        scanf("%d%d",&u,&v);

        int id = st.query(idx[u],idx[v]);

        cout << path[id] << endl;
    }

	return 0;
}

Measured memory_bytes: 15160
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)


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

    string S;
    ll ac = 0, wa = 0, tle = 0, re = 0;
    rep(i, N){
        cin >> S;

        if(S[0] == 'A'){
            ac++;
        }else if(S[0] == 'W'){
            wa++;
        }else if(S[0] == 'T'){
            tle++;
        }else{
            re++;
        }
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

    return 0;
}


Measured memory_bytes: 3632
main=do
    [hh,ww]<-map read.words<$>getLine::IO[Int]
    [h,w]<-map read.words<$>getLine::IO[Int]
    print $ f hh ww h w
f hh ww h w = (hh*ww) - (h*ww) - (w*hh) + (h*w)

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

int main(){
    int n;
    cin >> n;
    if(n%2==1){
        cout << n/2 +1 << endl;
    }else
    {
        cout << n/2 << endl;
    }
    return 0;
    
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import qualified Data.ByteString.Char8 as B
import Control.Monad
import Data.Array
import qualified Data.Vector.Unboxed as UV
import Data.Array.ST
import Control.Monad.ST

main=do
    n<-readLn::IO Int
    as<-UV.unfoldr(B.readInt.B.dropWhile(<'!'))<$>B.getLine::IO (UV.Vector Int)
    print $ g (fromIntegral n) $ acc as

acc :: UV.Vector Int -> (Int,Int,Int)
acc as = (a1,a2,a3) where
    av = UV.accumulate (+) (UV.replicate 3 0) $ UV.concatMap ma as
    ma 1 = UV.singleton (0,1)
    ma 2 = UV.fromList [(0,1),(1,1)]
    ma 3 = UV.fromList [(0,1),(1,1),(2,1)]
    a1 = av UV.! 0
    a2 = av UV.! 1
    a3 = av UV.! 2

g::Double->(Int,Int,Int)->Double
g n (!a1,!a2,!a3) = runST $ do
    e <- newArray ((0,0,0),(a1,a2,a3)) (-1.0) :: ST s (STUArray s (Int,Int,Int) Double)
    writeArray e (0,0,0) 0.0
    rd e (a1,a2,a3)
    where
        rd :: STUArray s (Int,Int,Int) Double -> (Int,Int,Int) -> ST s Double
        rd e (i,j,k) = do
            e0 <- readArray e (i,j,k)
            if e0 >= 0
                then return e0
                else do
                    e1 <- if i>j then (* fromIntegral (i-j)) <$> rd e (i-1,j,k) else pure 0.0
                    e2 <- if j>k then (* fromIntegral (j-k)) <$> rd e (i,j-1,k) else pure 0.0
                    e3 <- if k>0 then (* fromIntegral k)     <$> rd e (i,j,k-1) else pure 0.0
                    let en = (e1+e2+e3+n) / fromIntegral i
                    writeArray e (i,j,k) en
                    return en

Measured memory_bytes: 218236
#pragma G++ optimize (2)
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <queue>
#define INF 0x3f3f3f3f
#define NO 30005
#define MO 100005
typedef long long ll;
typedef double db;
using namespace std;
inline ll read()
{
	char ch = ' ', last;
	ll ans = 0;
	while (ch < '0' || ch > '9')
		last = ch, ch = getchar();
	while (ch >= '0' && ch <= '9')
		ans = ans * 10 + int(ch - '0'), ch = getchar();
	if (last == '-')
		return -ans;
	return ans;
}
void write(ll x)
{
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
//head

int n, k;
double ans;
//variable

void init()
{
	n = read(), k = read();
}
//functions

int main()
{
	init();
	for (int i = 1; i <= n; i++)
	{
		double cur = (double)1.0 / n, a = i;
		while (a < k)
			a = a * 2.000000000, cur = cur / 2.000000000;
		ans += cur;
	}
	printf("%.9lf\n", ans);
	return 0;
}
//main

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i,n;
  char s[5];
  
  scanf("%s",s);
  for(i=0,n=0;i<4;i++){
    if(s[i]=='+')n++;
    else         n--;
  }
  
  printf("%d\n",n);
  
  return 0;
}

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

int n;
int fun(vector<int> &vc)
{
	vector<int> v;
	for(int i=1;i<=n;i++)
    		v.push_back(i);

    int ans = 0;
    do 
    {
        ans++;
        if(v == vc) 
            return ans;
    } while(next_permutation(v.begin(), v.end()));
    return -1;
}

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    //int t=1 ; cin>>t ; while(t--)
    {
    	int x;
    	cin >> n;
    	vector<int> a, b;
    	for(int i=0;i<n;i++)
    		cin >> x, a.push_back(x);
    	for(int i=0;i<n;i++)
    		cin >> x, b.push_back(x);

    	int ans = abs(fun(a) - fun(b));
    	cout << ans << '\n';


    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

int D[505][505];
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,M,Q; cin >> N >> M >> Q;
    rep(i,M){
        int a,b; cin >> a >> b;
        D[a][b]++;
    }
    rep(i,N) rep(j,N){
        D[i+1][j+1] += D[i+1][j];
    }
    rep(i,N) rep(j,N){
        D[i+1][j+1] += D[i][j+1];
    }
    vi v;
    rep(i,Q){
        int a,b; cin >> a >> b;
        v.eb(D[b][b]-D[b][a-1]-D[a-1][b]+D[a-1][a-1]);
    }
    for(auto a:v){
        cout << a << endl;
    }
}

Measured memory_bytes: 3828
#include <stdio.h>

int main()
{
	int a,b,rt;
	char op;
	
	while( 1 )
	{
		rt = 0;
		scanf("%d %c %d", &a, &op, &b);
		switch(op)
		{
			case '+':
				rt = a + b;
				break;
			case '-':
				rt = a - b;
				break;
			case '*':
				rt = a * b;
				break;
			case '/':
				rt = a / b;
		}

		if( op == '?')
			break;
		printf("%d\n", rt);
	}
	return 0;
}

Measured memory_bytes: 600
fun main(args:Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val gateList = (1..m).map { readLine()!!.split(" ").map { it.toInt() } }
    val lMax = gateList.map { it[0] }.max()!!
    val rMin = gateList.map { it[1] }.min()!!
    val ans = Math.max(0, rMin - lMax + 1)
    println(ans)
}

Measured memory_bytes: 61852
val INF = Long.MAX_VALUE

data class Edge(val a: Int, val b: Int, val c: Long)

fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map(String::toInt)

    val edges = Array(M) {
        val (a, b, c) = readLine()!!.split(" ")
        Edge(a.toInt() - 1, b.toInt() - 1, -c.toLong())
    }

    val dist = LongArray(N) { INF }

    dist[0] = 0

    for (loop in 0..(N - 2)) {
        (0..(M - 1))
                .map { edges[it] }
                .filter { dist[it.a] != INF && dist[it.b] > dist[it.a] + it.c }
                .forEach { dist[it.b] = dist[it.a] + it.c }
    }

    val ans = dist[N - 1]

    val negative = BooleanArray(N) { false }

    for (loop in 0..N - 1) {
        for (i in 0..M - 1) {
            val edge = edges[i]
            if (dist[edge.a] == INF) continue

            if (dist[edge.b] > dist[edge.a] + edge.c) {
                dist[edge.b] = dist[edge.a] + edge.c
                negative[edge.b] = true
            }

            if (negative[edge.a]) {
                negative[edge.b] = true
            }
        }
    }

    if (negative[N - 1]) {
        println("inf")
    } else {
        println(-ans)
    }
}

Measured memory_bytes: 50196
#include <iostream>

using namespace std;

int main(){
    int n,a,b,total=0,nc;
    cin >> n >> a >> b;
    for(int i=0; i<=n; i++){
        nc = i;
        int cnt=0;
        while(nc>0){
            cnt = cnt + nc%10;
            nc = nc/10;
        }
        if(a<=cnt && cnt <=b){
            total = total + i;
        }
    }
    cout << total << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  vector<int> vec2(1);
  vec2.at(0) = vec.at(0);
  for(int j = 1; j < N; j++){
    if(vec.at(j) > vec.at(j - 1)){
      vec2.push_back(vec.at(j));
    }
  }
  cout << vec2.size() << endl;
  return 0;
}

Measured memory_bytes: 256
#inport
import sys

#input
S = str(sys.stdin.readline())
N = len(S)
S = S[0:N-1]
N = len(S)
S_1 = S[0:int((N-1)/2)]
S_2 = S[int((N+3)/2-1):N]
#print(S)
#print(S[::-1])
#print(S_1)
#print(S_1[::-1])
#print(S_2)
#print(S_2[::-1])

if S == S[::-1] and S_1 == S_1[::-1] and S_2 == S_2[::-1]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9092
n = input()
t1 = list(map(int, input().split()))
m = int(input())
a = []
for i in range(m):
    t2 = t1.copy()
    p, x = map(int, input().split())
    t2[p - 1] = x
    a.append(sum(t2))
for i in range(len(a)):
    print(a[i])

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int X[101][101][101];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B, C;
	cin >> A >> B >> C;
	int c = (A % 2) + (B % 2) + (C % 2);

	if (c>=2) {
		cout << "Hom" << endl;
	}
	else {
		cout << "Tem" << endl;
	}
}


Measured memory_bytes: 3236
#include <stdio.h>
#include <string.h>

int E[6] = {3,0,-2,2,0,-3};
int W[6] = {2,0,3,-3,0,-2};
int S[6] = {4,-1,0,0,1,-4};
int N[6] = {1,4,0,0,-4,-1};


void DICE(char a,int d[],int d2[]){

int i;
	if(a == 'E'){
	for(i = 0;i < 6; i++){
		d2[i] = d[i + E[i]];
		}
		}	
	if(a == 'N'){
	for(i = 0;i < 6; i++){
		d2[i] = d[i + N[i]];
		}
		}	
	if(a == 'S'){
	for(i = 0;i < 6; i++){
		d2[i] = d[i + S[i]];
		}
		}	
	if(a == 'W'){
	for(i = 0;i < 6; i++){
		d2[i] = d[i + W[i]];
		}
		}	
}

int main(void){
	int d[6], d2[6],i,count;
	char x;
	char mark[128];
	
	for(i = 0; i < 6; i++){
	scanf("%d",&d[i]);
}

scanf("%s",mark);

for(i = 0,count = 0;mark[i] != '\0' ;i++){

	if(i % 2 == 0)
DICE(mark[i],d,d2);
	if(i % 2 == 1)
		DICE(mark[i],d2,d);
	
count++;
}

if(count % 2 == 1)
	memcpy(d,d2,6);

printf("%d\n",d[0]);


return 0;
}
	

Measured memory_bytes: 596
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
s = sum(A)
nu = [0 for _ in range(10**5+1)]
for i in range(N):
    nu[A[i]] += 1
for j in range(Q):
    B,C = map(int,input().split())
    s += (C-B)*nu[B]
    nu[C] += nu[B]
    nu[B] = 0
    print(s)

Measured memory_bytes: 20904
def main():
    import sys
    import itertools
    N=int(sys.stdin.readline())
    PL=list(map(int,sys.stdin.readline().split()))
    QL=list(map(int,sys.stdin.readline().split()))

    for i,L in enumerate(itertools.permutations(range(1,N+1))):
        if tuple(L)==tuple(PL):
            a=i
        if tuple(L)==tuple(QL):
            b=i

    print(abs(a-b))
main()


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

int f(int a, int hp) {
  return (hp+a-1)/a;
}

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

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

int main() {
  int x, y, s;
  while (cin >> x >> y >> s, x) {
    int ans = 0;
    auto f = [](int p, int x) { return p * (100 + x) / 100; };
    for (int i = 1; i < s; ++i) {
      for (int j = 1; j < s; ++j) {
        if (f(i, x) + f(j, x) != s) continue;
        ans = max(ans, f(i, y) + f(j, y));
      }
    }
    cout << ans << endl;
  }
  return 0;
}



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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
using ll = long long;
using ull = unsigned long long;

struct UnionFind {
  vector<int> par;
  vector<int> siz;

  UnionFind(int n) {
    par = vector<int>(n);
    siz = vector<int>(n, 1);
    rep(i, n) {
      par[i] = i;
    }
  }

  int root(int x) {
    if (par[x] == x) return x;
    return 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;
    if (siz[x] < siz[y]) swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
  }

int size(int x) {
    return siz[root(x)];
  }
};

int main() {
  int n,m;
  cin>>n>>m;
  vector<pair<int, int>> v;
  rep(i, m) {
    int a,b;
    cin>>a>>b;
    a--; b--;
    v.push_back({a,b});
  }
  // 1本以外の辺を架けてチェック
  int ans = 0;
  rep(i, m) {
    UnionFind uf(n);
    rep(j, m) {
      if (i != j) uf.unite(v[j].first, v[j].second);
    }
    set<int> s;
    rep(j, n) {
      s.insert(uf.root(j));
    }
    if (s.size() > 1) ans++;
  }
  cout << ans;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

const M: u64 = 1e+18 as u64;

#[fastout]
fn main() {
    input! {in_n: usize, in_a: [u64; in_n]};
    let mut c = 1;
    let mut p = 1;

    for i in 0..in_a.len() {
        if in_a[i] == 0 {
            println!("0");
            return;
        }
    }

    for i in 0..in_a.len() {
        c = c * in_a[i];

        if c > M || c < p {
            println!("-1");
            return;
        }

        p = c;
    }

    println!("{}", c);
}


Measured memory_bytes: 4580
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
dAl = defaultdict(int)
dAr = defaultdict(int)
for i in range(N):
    L = (i + 1) + A[i]
    R = (i + 1) - A[i]
    dAl[L] += 1
    dAr[R] += 1

# dictの中を見る
ans = 0
for k, v in dAl.items():
    ans += v * dAr[k]
print(ans)

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

//昇順
int asc(const void* a, const void* b){
    if((*(long*)a-*(long*)b)>0) return 1;
    else if((*(long*)a-*(long*)b)<0) return -1;
    return 0;
}

int main(void){
    long H,W;
    scanf("%ld%ld",&H,&W);

    long ans=H*W;
    if(H%3==0) ans=0;
    else if(W%3==0) ans=0;
    else{
        long S[3];
        //例2の切り方
        for(int i=1;i<=W-1;i++){
            S[0]=H*i;
            S[1]=(W-i)*(H/2);
            S[2]=(W-i)*(H-H/2);
            qsort(S,3,sizeof(long),asc);
            ans=MIN(ans,S[2]-S[0]);
        }
        //例3の切り方
        for(int i=1;i<=H-1;i++){
            S[0]=W*i;
            S[1]=(H-i)*(W/2);
            S[2]=(H-i)*(W-W/2);
            qsort(S,3,sizeof(long),asc);
            ans=MIN(ans,S[2]-S[0]);
        }
        //縦斬り
        ans=MIN(ans,H);
        //横切り
        ans=MIN(ans,W);
    }
    printf("%ld\n",ans);

    return 0;
}

Measured memory_bytes: 128
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>
#include <limits>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
//エイリアス
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

//定数
const int intmax = numeric_limits<int>::max();
const ll llmax = numeric_limits<ll>::max();
const ll mod = 1e9 + 7;
const double pi = M_PI;

int n;
ll k;
int a[2 * 100000];

pair<int, ll> calc(int start) {
  if(k == 0) return {start, 1};
  vector<bool> flag(n, false);
  flag[start] = true;
  int cnt = 0;
  while(1) {
    start = a[start] - 1;
    cnt++;
    if(k == cnt){
      k -= cnt;
      return {start, cnt};
    };
    if(flag[start]){
      k -= cnt;
      return {start, cnt};
    }else{
      flag[start] =true;
    }
  }
}

int main()
{
  cin >> n >> k;
  rep(i, n) cin >> a[i];
  auto stop = calc(0);
  if(stop.first != 0) {
    stop = calc(stop.first);
  }
  ll rest = k % stop.second;
  int result = stop.first;
  rep(i, rest) {
    result = a[result] - 1;
  }
  cout << result + 1 << endl;
}


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

int main() {
  long long X;
  cin >> X;
  long long init = 100;
  long long i = 0;
  while (true) {
    i++;    
    init *= 1.01;
    if (init >= X) {
      cout << i << endl;
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3636
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}


*/
typedef long long ll;
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;
 
int main() {
	// 入力
    int N;
    cin >> N;
    
    if ((N/2)*2==N) cout << N << endl;
    else cout << N * 2 << endl;
 
}
 


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;


ll mod_pow(ll x, ll n) {
	if (n == 0) return 1;
	ll res = mod_pow(x*x % mod, n / 2);
	if (n & 1) res = res * x % mod;
	return res;
}


int main() {

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


	ll X,ans=0;
	cin >> X;

	FOR(i, 1, 10000) {
		if ((360 * i )% X == 0) {
			ans = 360 * i / X;
			break;
		}
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3636
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long int lo;
#define pb push_back
#define mp make_pair
#define st first
#define nd second
lo a,b,d,e,x,y,n,p,m,t,a1[500000],c;
lo k;
string s1,s2,s3;
queue <pair<lo,lo> > q;
priority_queue <lo> pq;
map <lo,lo> mp1;
vector <lo> v[100005];
lo oyuncu;
lo power(lo taban,lo us){
	if(us==0) return 1;
	lo z=power(taban,us/2);
	if(us%2==0){
		return (z*z)%m;
	}
	else{
		return (((z*z)%m)*taban%m);
	}
}
int main(){
	// soru
	// freopen("gir.gir","r",stdin);
	// freopen("cik.cik","w",stdout);
    cin >> s1;
	for(lo i = 0 ; i < s1.size() ; i ++){
		cout << "x";
	}
	cout << endl;
    return 0;
}


Measured memory_bytes: 4352
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		var input = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
		long N = input[0];
		long M = input[1];
		List<Tuple<long, long>> AB = new List<Tuple<long, long>>();
        for(var i = 0; i < N; i++)
		{
			var abin = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
			AB.Add(new Tuple<long, long>(abin[0], abin[1]));
		}
		AB.Sort((c, d) => ((int)c.Item1 - (int)d.Item1));
		long ans = 0;
		long cnt = 0;
        for(var i = 0; i < N; i++)
		{
			if (cnt + AB[i].Item2 <= M)
			{
				cnt += AB[i].Item2;
				ans += AB[i].Item1 * AB[i].Item2;
			}
			else
			{
				ans += (M - cnt) * AB[i].Item1;
				break;
			}
		}

        Console.WriteLine(ans);

	}
}

Measured memory_bytes: 23992
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	string s;
	int k;
	set<string> u;
	vector<string> v;
	cin>>s>>k;
	for(int i=0;i<s.size();i++){
		string t;
		t+=s[i];
		u.insert(t);
		for(int j=i+1;j<min(int(s.size()),i+5);j++){
			t+=s[j];
			u.insert(t);
			DEB(t)END
		}
	}
	for(auto x:u){
		v.push_back(x);
	}
	cout<<v[k-1]<<endl;
	return 0;
}

Measured memory_bytes: 1920
import heapq
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)


def dfs(v, visited, G):
    visited[v] = True
    for nv in G[v]:
        if visited[nv]==False:
            dfs(nv, visited, G)


def main():
    N, M = map(int, input().split())
    G = [[] for _ in range(N)]
    for _ in range(M):
        x, y, z = map(int, input().split())
        G[x-1].append(y-1)
        G[y-1].append(x-1)
    
    nodes = list(range(N))
    visited = [False]*N
    ans = 0
    while len(nodes)!=0:
        v = nodes.pop()
        if visited[v]==True:
            continue
        ans += 1
        dfs(v, visited, G)
        # print(visited)
        # print(nodes)
    
    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 114212
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;
const int MOD=1000000007;

int n;
int x[MAXN];

int need[MAXN]; // need[i] = for someone after i to reach the finish, at least need[i] others need to finish first
int dp[MAXN+1]; // dp[i] = # ways for need[i] out of 0..i to finish

void run() {
	scanf("%d",&n); REP(i,n) scanf("%d",&x[i]);

	need[0]=0; dp[0]=1;
	FOR(i,1,n) {
		need[i]=max(need[i-1],i+1-(x[i]+1)/2);
		if(need[i]==need[i-1]) { dp[i]=dp[i-1]; continue; }
		assert(need[i]==need[i-1]+1);
		dp[i]=(ll)(i-need[i-1]+1)*dp[i-1]%MOD;
	}
	//REP(i,n) printf("%d: x=%d need=%d dp=%d\n",i,x[i],need[i],dp[i]);
	int ret=dp[n-2]; FORE(i,1,n-need[n-2]) ret=(ll)ret*i%MOD; printf("%d\n",ret);
}

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


Measured memory_bytes: 1408
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let n: usize = read!();
    let mut t = Vec::with_capacity(n);
    for _ in 0..n {
        let ti: usize = read!();
        t.push(ti);
    }

    let m: usize = read!();

    let sum: usize = t.iter().sum();
    for _i in 0..m {
        let pi: usize = read!();
        let xi: usize = read!();
        println!("{}", sum - t[pi - 1] + xi);
    }
}


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

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

typedef long long LL;

#define MOD 1000000007

LL power(LL x,LL y){
  LL ans=1;
  for(int i=0;i<20;i++){
    if(y&(1<<i)) ans=ans*x%MOD;
    x=x*x%MOD;
  }
  return ans;
}

int main(){
  string s;
  cin >> s;
  vector<vector<LL>> a(3,vector<LL>(s.length(),0)),b(3,vector<LL>(s.length(),0));
  LL count=0;
  for(int i=0;i<s.length();i++){
    if(s[i]=='A') a[0][i]++;
    else if(s[i]=='?') a[1][i]++,count++;
  }
  for(int i=1;i<s.length();i++){
    a[0][i]=(a[0][i]+a[0][i-1])%MOD;
    a[1][i]=(a[1][i]+a[1][i-1])%MOD;
  }
  for(int i=1;i<s.length();i++){
    if(s[i]=='B') b[0][i]=(b[0][i]+a[0][i-1])%MOD,b[1][i]+=(b[1][i]+a[1][i-1])%MOD;
    else if(s[i]=='?') b[1][i]=(b[1][i]+a[0][i-1])%MOD,b[2][i]=(b[2][i]+a[1][i-1])%MOD;
  }
  for(int i=1;i<s.length();i++){
    b[0][i]=(b[0][i]+b[0][i-1])%MOD;
    b[1][i]=(b[1][i]+b[1][i-1])%MOD;
    b[2][i]=(b[2][i]+b[2][i-1])%MOD;
  }
  LL ans=0;
  LL hosei[4];
  for(int i=0;i<4;i++){
    hosei[i]=power(3,count-i);
  }
  for(int i=2;i<s.length();i++){
    if(s[i]=='C'){
      for(int j=0;j<3;j++){
        ans=(ans+b[j][i-1]*hosei[j]%MOD)%MOD;
      }
    }else if(s[i]=='?'){
      for(int j=0;j<3;j++){
        ans=(ans+b[j][i-1]*hosei[j+1]%MOD)%MOD;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6000
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define EPS 1e-8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define MOD 100000
typedef long long ll;
typedef pair < int , int > Pii;
int main(){
	int total=0;
	rep(i,4){
		int tmp;
		scanf("%d",&tmp);
		total += tmp;
	}
	printf("%d\n%d\n",total/60,total%60);
	return 0;
}

Measured memory_bytes: 1188
temp = []

a = int(input())
temp.append(a)
b = int(input())
temp.append(b)
c = int(input())
temp.append(c)
d = int(input())
temp.append(d)
e = int(input())
temp.append(e)
k = int(input())
ans = 'Yay!'
for i in range(len(temp)):
    if i==len(temp):
        break
    for j in range(len(temp)):
        if j==len(temp):
            break       
        if i==j:
            continue
        if i>j:
            if temp[i]-temp[j]>k:
                ans = ':('
                break
        else:
            if temp[j]-temp[i]>k:
                ans = ':('
                break

print(ans)


Measured memory_bytes: 3064
n, m = map(int, input().split())
s = []
for _ in range(m):
    s_ = list(map(int, input().split()))
    s.append(s_)
p = list(map(int, input().split()))

cnt = 0
for i in range(pow(2, n)):
    switch = [i>>j&1 for j in range(n)]
    light = 0
    for j in range(m):
        on = 0
        for k in s[j][1:]:
            if switch[k-1]==1:
                on += 1
        if on%2 == p[j]:
            light += 1
    if light == m:
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <stdio.h>
#include<math.h>
int main(){
  int n,x[102],y[102],i,j,k,D1=0,D4=0;
  double D2=0.0,D3=0.0;
  scanf("%d",&n);
  for(i=0; i<n; i++)scanf("%d",&x[i]);
  for(i=0; i<n; i++)scanf("%d",&y[i]);
  for(i=0; i<n; i++)D1+=abs(x[i]-y[i]);
  for(i=0; i<n; i++)D2+=pow(x[i]-y[i],2);
  D2=pow(D2,(double)1/2);
  for(i=0; i<n; i++)D3+=pow(abs(x[i]-y[i]),3);
  D3=pow(D3,(double)1/3);
  for(i=0; i<n; i++)if(D4<abs(x[i]-y[i]))D4=abs(x[i]-y[i]);
  printf("%lf\n%lf\n%lf\n%lf\n",(float)D1,D2,D3,(float)D4);
  return 0;
}


Measured memory_bytes: 2148
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*};
use superslice::*;
fn main() {
    input! {
        n: i64,
        aa: [i64; n as usize],
    }

    let mut adds = Vec::new();
    let mut subs = Vec::new();

    for (id, tall) in aa.into_iter().enumerate() {
        let id_add_tall = id as i64 + tall;
        adds.push((id_add_tall, id));
        let id_sub_tall = id as i64 - tall;
        subs.push((id_sub_tall, id));
    }
    adds.sort_unstable();
    subs.sort_unstable();

    let mut count = 0;
    // id + tall = other_id - other_tall (id < other_id)
    for &(id_add_tall, id) in &adds {
        let lower = subs.lower_bound(&(id_add_tall, id + 1));
        let upper = subs.upper_bound(&(id_add_tall, n as usize + 1));
        count += upper - lower;
    }

    println!("{}", count);

}


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

#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef long long ll;

const ll INF = 1e18L + 5;

void mini(ll&a, ll b){
    a = min(a, b);
}

int main(){

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

    int N;
    int W;

    vi w;
    vi v;

    cin >> N;
    cin >> W;

    w.resize(N);
    v.resize(N);

    int sumValue = 0;

    for(int i=0; i < N; i++){
        cin >> w[i] >> v[i];
        sumValue += v[i];
    }

    ll dp[sumValue+1];
    // dp[i] - min weight for value i;
    // since the contraints for weight is so big, it is the same thing except swap value dimension with weight dimension

    // here set everything to inf and min weight for value of 0 is 0
    for(int i=0; i <= sumValue; i++){
        dp[i] = INF;
    }
    dp[0] = 0;

    // same recurrence relation as before just swapped dimensions
    for(int i=0; i < N; i++){
        for(int j=sumValue; j >= v[i]; j--){
            mini(dp[j], dp[j-v[i]] + w[i]);
        }

    }

    // this changes too since we are finding a diff ans than before
    int ans = 0;
    for(int i=0; i <= sumValue; i++){
        if(dp[i] <= W) ans = i;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    X = INT()

    money = 100
    for i in range(4000):
        money = int(money*1.01)
        if money >= X:
            print(i+1)
            sys.exit()


if __name__ == '__main__':
    main()

Measured memory_bytes: 10044