akhauriyash/Code-Regression huggingface dataset:
n=int(input())
s=input()

l = 0
r = 0
for i in range(n):
  if s[i] == ')':
    if r == 0:
      l += 1
    else:
      r -= 1
  else:
    r += 1
if r > 0:
  print( '(' * l + s + ')' * r)
else:
  print( '(' * (l + r) + s)



Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int		compar_int(const void *a, const void *b)
{
	return *(int *)b - *(int *)a;
}

int		main(void)
{
	int	n;
	scanf("%d", &n);
	if (!(4 <= n && n <= 100000))
		return (1);
	int	a[n];
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (int i = 0; i < n; i++)
		if (!(1 <= a[i] && a[i] <= 1000000000))
			return (2);
	qsort(a, n, sizeof(int), compar_int);
	long	x = 0,y = 0;
	int		i = 0;
	while (i < n)
	{
		if (a[i] == a[i+1])
		{
			x = a[i];
			i++;
			i++;
			break;
		}
		i++;
	}
	while (i < n)
	{
		if (a[i] == a[i+1])
		{
			y = a[i];
			i++;
			i++;
			break;
		}
		i++;
	}
	// printf("x = %ld\n", x);
	// printf("y = %ld\n", y);
	printf("%ld\n", x * y);
	return (0);
}

Measured memory_bytes: 892
/*
    A - Buttons
    https://atcoder.jp/contests/abc124/tasks/abc124_a
*/
#include <bits/stdc++.h>
using namespace std;

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

    int a, b;
    cin >> a >> b;

    int sum = 0;
    for (int i = 0; i < 2; i++) {
        if (a > b) {
            sum += a;
            a -= 1;
        } else {
            sum += b;
            b -= 1;
        }
    }
    cout << sum << endl;
}

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

int main()
{
    int N;
    int ac=0,tle=0,re=0,wa=0;
    cin>>N;
    string p;
    for(int i=0;i<N;i++)
    {
        cin>>p;
        if(p.compare("AC")==0)
        {
            ac+=1;
        }
        else if(p.compare("TLE")==0)
        {
            tle+=1;
        }
        else if(p.compare("RE")==0)
        {
            re+=1;
        }
        else if(p.compare("WA")==0)
        {
            wa+=1;
        }
    }
    cout<<"AC x "<<ac<<endl
        <<"WA x "<<wa<<endl
        <<"TLE x "<<tle<<endl
        <<"RE x "<<re<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
typedef long long LL;

using namespace std;

int main() {
	string s; cin >> s;
	int num0, num1;
	num0 = count(s.begin(), s.end(), '0');
	num1 = count(s.begin(), s.end(), '1');
	cout << min(num0, num1) * 2;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    string s;
    cin >> s;
    if(s.substr(0,4)=="YAKI") cout << "Yes" << endl;
    else cout << "No" << endl;        
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define MAX 200005
#define INF (1LL<<60)
typedef long long ll;
typedef pair<ll,ll> P;
struct edge{ll to,cost;};
struct state{
  ll pos,flg,cost;
  bool operator < (const state &p)const{
    return cost > p.cost;
  }
};
 
vector<P> t[MAX][2];
ll W,H,K,X[MAX],Y[MAX];
ll d[MAX][2];
vector<edge> G[MAX][2];
 
ll solve(){
  if(t[1][0].empty())return -1;
  for(int i=0;i<MAX;i++)d[i][0]=d[i][1]=INF;
  priority_queue< state > Q;
  P p=t[1][0][0];
  Q.push((state){p.second, 0, p.first-1} );
  d[p.second][0]=p.first-1;   
  while(!Q.empty()){
    state s=Q.top();Q.pop();
    if(s.cost>d[s.pos][s.flg])continue;
    for(int f=0;f<2;f++){
      int nf=(s.flg+f)%2;
      for(int i=0;i<(int)G[s.pos][nf].size();i++){
        edge e=G[s.pos][nf][i];
        ll ncost=s.cost+e.cost+f;
        if(e.cost==0)ncost=s.cost;
        if(ncost<d[e.to][nf]){
          d[e.to][nf]=ncost;
          Q.push( (state){e.to,nf,ncost} );
        }
      }
    }
  }
  ll res=min(d[K][0],d[K][1]);
  if(res==INF)return -1;
  else return res;
}
       
int main(){
  scanf("%lld %lld %lld",&W,&H,&K);
  for(int i=0;i<K;i++){
    scanf("%lld %lld",&X[i],&Y[i]);
    t[X[i]][0].push_back(P(Y[i],i));
    t[Y[i]][1].push_back(P(X[i],i));
  }
  t[W][0].push_back(P(H,K));
  t[H][1].push_back(P(W,K));
  X[K]=W;
  Y[K]=H;
  for(int i=1;i<=100000;i++){
    for(int f=0;f<2;f++){
      vector<P> &vec=t[i][f];
      sort(vec.begin(),vec.end());
      int size=vec.size();
      for(int j=0;j<size;j++){
        P p=vec[j],q;
        if(0<j){
          q=vec[j-1];
          G[p.second][f].push_back( (edge){q.second,p.first-q.first} );
        }
        if(j+1<size){
          q=vec[j+1];
          G[p.second][f].push_back( (edge){q.second,q.first-p.first} );
        }
      }
    }
  }
  cout<<solve()<<endl; 
  return 0;
}

Measured memory_bytes: 57020
//بسم الله الرحمن الرحيم
///   ***   ---   |||		 In the name of ALLAH		|||   ---   ***   ///
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define el << endl
#define PI 3.141592653589793238
#define _test_ int t; cin >> t; while(t--)
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
ll gcd ( ll  a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }
int dx[]={0,0,+1,-1,+1,-1,-1,+1};
int dy[]={+1,-1,0,0,+1,-1,+1,-1};
///*......................*//* LET'S BEGIN (-_^) *//*............................///
const int mx= 3e5+123;
ll x,k,d;

void _case_()
{
   cin >> x >> k >> d;
   x=abs(x);
   ll r=min(k,x/d);
   k-=r;
   x-=r*d;
   if(k%2==0)
       cout << x el;
   else cout << d-x el;
}

int main()
{

    optimize();
    //_test_
      _case_();
    return 0;

}

///////////*  N A Y E M  *///////////

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll t;
	t=1;
	for(int x=1;x<=t;x++)
	{
	    ll n,m;
	    cin>>n>>m;
	    cout<<(n*(n-1))/2 + (m*(m-1))/2;
	}
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);    
  long long n;
  cin >> n;
  long long i = 1, ans = 1e18;
  while (i * i <= n) {
    if (n % i == 0) {
      ans = min(ans, i - 1 + n / i - 1);
    }
    ++i;
  }
  cout << (ans == 1e18 ? n - 1 : ans) << '\n';
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;

int a[11][70];
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n; cin >> n;
    bitset<64> mask[n];
    
    REP(i, n){
        int k; cin >> k;
        for(int j=0; j<k; ++j){
            int b; cin >> b;
            mask[i].set(b);
        }
    }
    
    int q; cin >> q;
    
    bitset<64> bit;
    REP(i, q){
        int qu, b; cin >> qu >> b;
        if(qu==0) cout << bit[b] << endl;
        if(qu==1) bit |= mask[b];
        if(qu==2) bit &= ~mask[b];
        if(qu==3) bit ^= mask[b];
        if(qu==4) {
            if((bit&mask[b]) == mask[b]) cout << 1 << endl;
            else cout << 0 << endl;
        }
        if(qu==5){
            cout << (bit&mask[b]).any() << endl;
        }
        if(qu==6){
            cout << (bit&mask[b]).none() << endl;
        }
        if(qu==7){
            cout << (bit&mask[b]).count() << endl;
        }
        if(qu==8){
            cout << (bit&mask[b]).to_ullong() << endl;
        }
    }
	return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const ll mod = 1e9 + 7;
const int maxn = 1e6 + 5;
ll fac[maxn], inv[maxn];
ll modpow(ll base, ll pow) {
    ll res = 1;
    while (pow) {
        if (pow & 1)
            res = res * base % mod;
        base = base * base % mod;
        pow >>= 1;
    }
    return res;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    fac[0] = 1;
    inv[0] = modpow(1, mod - 2);
    for (int i = 1; i <= maxn; ++i) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = modpow(fac[i], mod - 2);
    }
    int x, y;
    cin >> x >> y;
    int z = 2 * x - y;
    if (z < 0 || z % 3 != 0) {
        cout << "0\n";
        return 0;
    }
    else {
        ll ty = z / 3;
        if (y - ty < 0 || (y - ty) % 2 != 0) {
            cout << "0\n";
            return 0;
        }
        else {
            ll tx = (y - ty) / 2;
            cout << fac[tx + ty] * inv[tx] % mod * inv[ty] % mod << '\n';
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 15872
import sys
# sys.setrecursionlimit(100000)
from collections import defaultdict
from heapq import heappop, heappush


class Dijkstra:
    """Graph input:
    {
    node:{node:cost,node:cost...},
    node:{node:cost,node:cost...},
    ...
    }
    """

    def __init__(self, graph: dict, N: int):
        self.graph = graph
        self.costs = [float("inf")] * N

    def calculate(self, start):
        queue = list()

        # step1: push the start point into the priority queue
        self.costs[start] = 0
        heappush(queue, (0, start))  # (cost,node)

        while queue:
            # step2: get the minimum cost node from unfixed node and fix the cost
            cost_from_start, min_node = heappop(queue)

            # step3: update the direct connected nodes
            for link, cost in self.graph[min_node].items():
                if cost_from_start + cost < self.costs[link]:
                    self.costs[link] = cost_from_start + cost
                    heappush(queue, (self.costs[link], link))

        return self.costs


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    graph = defaultdict(dict)
    for _ in range(n - 1):
        a, b, c = input_int_list()
        graph[a][b] = c
        graph[b][a] = c
    # dp = warshall_floyd(graph, n + 1) O(n**3) => TLD

    q, k = input_int_list()

    solver = Dijkstra(graph, n + 1)
    costs = solver.calculate(k)

    ans = []
    for _ in range(q):
        x, y = input_int_list()
        ans.append(costs[x] + costs[y])
    for i in ans:
        print(i)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 134388
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int H, W, A, B;

int main() {
    cin >> H >> W >> A >> B;
    int cnt = 0;
    while ((B+cnt+1)*2 <= H) cnt++;
    rep(i,H) {
        if (i%2) {
            if (cnt) {
                cnt--;
                for (int j = 0; j < A; j++) {
                    cout << 0;
                }
                for (int j = A; j < W; j++) {
                    cout << 1;
                }
            } else {
                for (int j = 0; j < A; j++) {
                    cout << 1;
                }
                for (int j = A; j < W; j++) {
                    cout << 0;
                }
            }
        } else {
            for (int j = 0; j < A; j++) {
                cout << 0;
            }
            for (int j = A; j < W; j++) {
                cout << 1;
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;

template<typename T> class SegmentTree{
  private:
    typedef function<T(T,T)> F;
    int n;
    T d0;
    vector<T> vertex;
    F f;
    F g;
  public:
    SegmentTree(int _n,F f,F g,int d):d0(d),f(f),g(g){
        init(_n);
    }
    void init(int _n){
        n=1;
        while(n<_n) n*=2;
        vertex.resize(2*n-1,d0);
    }
    void update(int i,T x){
        int k=i+n-1;
        vertex[k]=g(vertex[k],x);
        while(k>0){
            k=(k-1)/2;
            vertex[k]=f(vertex[2*k+1],vertex[2*k+2]);
        }
        return;
    }
    T query(int l,int r){
        l+=n-1;r+=n-1;
        T vl=vertex[l],vr=vertex[r];
        for(;l<r;l>>=1,r>>=1){
            vl=f(vl,vertex[l]);
            vr=f(vr,vertex[--r]);
        }
        return f(vl,vr);
    }
};
int gcd(int x,int y){return y?gcd(y,x%y):x;};
int main(){
    int n;cin>>n;
    
    SegmentTree<int> seg(n,[](int x,int y){return gcd(x,y);},[](int x,int y){return y;},0);
    REP(i,n){
        int a;cin>>a;
        seg.update(i,a);
    }
    int ans=seg.query(1,n-1);
    REP(i,n-2) ans=max(ans,gcd(seg.query(0,i),seg.query(i+2,n-1)));
    ans=max(ans,seg.query(0,n-2));
    cout<<ans<<endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define eb emplace_back


typedef long long ll;
typedef long double ld;


const ll inf = 2e9;
const ll base = 998244353;
ll mod = 1e9 + 7;



void yes() {
    cout << "Yes" << endl;
}


void no() {
    cout << "No" << endl;
}




ll binpow(ll a, ll n) {
    if (!n) return 1;
    if (n & 1) return a * binpow(a, n - 1) % mod;
    return binpow((a * a) % mod, n / 2) % mod;
}

ll rev(ll a) {
    return binpow(a, mod - 2);
}

int main() {
//    srand(time(NULL));
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
//    std::random_device rd;
//    std::mt19937 g(rd());

    auto start = clock();

    int n; cin >> n;
    int t; cin >> t;
    vector<pair<int, int>> a(n + 5, {inf, -inf});
    a.pb({-1, 0});
    for (int i = 1; i <= n; ++i) {
        cin >> a[i].first >> a[i].second;
//        cerr << a[ i].first << ' ' << a[i].second << '\n';
    }
    sort(a.begin(), a.end());
    vector<vector<int>> dp(t + 5, vector<int>(n + 5, 0));
    for (int T = 1; T < t; ++T) {
        for (int i = 1; i <= n; ++i) {
            if (T >= a[i].first) {
                dp[T][i] = max(dp[T][i - 1], dp[T - a[i].first][i - 1] + a[i].second);
            } else {
                dp[T][i] = dp[T][i - 1];
            }
//            cerr << dp[T][i] << ' ';
        }
//        cerr << '\n';
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans = max(ans, a[i].second + dp[t - 1][i - 1]);
    }
    cout << ans << endl;



    std::cerr << double(clock() - start) / CLOCKS_PER_SEC << std::endl;
    return 0;
}


Measured memory_bytes: 35712
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <complex>
#include <algorithm>

using namespace std;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;

#define int i64

template<class T>
inline bool chmin(T &a, T b) { if(a > b) {a = b; return true;} return false; }
template <class T>
inline bool chmax(T &a, T b) { if(a < b) {a = b; return true;} return false; }
const int INF = 1LL << 60;

signed main() {
	int n;
	cin >> n;

	int mins = INF;
	int res = 0;
	int p;
	for(int i = 0; i < n; i++) {
		cin >> p;
		if(mins >= p) res++;
		if(p < mins) mins = p;
	}

	cout << res << endl;
	
	return 0;
}


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

int main(){
  int card[3][3];
  bool hole[3][3];
  int N;
  for( int i = 0; i < 3; ++i ){
    for( int j = 0; j < 3; ++j ){
      hole[i][j] = false;
    }
  }
  
  for( int i = 0; i < 3; ++i ){
    cin >> card[i][0] >> card[i][1] >> card[i][2];
  }

  cin >> N;
  for( int i = 0; i < N; ++i ){
    int bi;
    cin >> bi;
    
    for( int j = 0; j < 3; ++j ){
      for(int k = 0; k < 3; ++k ){
        if( card[j][k] == bi ){
          hole[j][k] = true;
        }
      }
    }
  }

  for( int i = 0; i < 3; ++i ){
    if( hole[i][0] && hole[i][1] && hole[i][2] ){
      cout << "Yes" << endl;
      return 0;
    }

    if( hole[0][i] && hole[1][i] && hole[2][i]  ){
      cout << "Yes" << endl;
      return 0;
    }
  }

  if( hole[1][1] ){
    if( (hole[0][0] && hole[2][2]) || (hole[0][2] && hole[2][0]) ){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
}

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

int main() {
  int A, B;
  cin >> A >> B;

  int a = min(A, B);
  int b = max(A, B);

  int counter = 1;
  while (true) {
    if (abs(a-counter) == abs(b-counter)) {
      cout << counter << endl;
      break;
    }
    
    if (abs(a-counter) > abs(b-counter)) {
      cout << "IMPOSSIBLE" << endl;
      break;
    }

    counter++;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD 998244353
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 long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    ll n,x,y;
    cin >> n >> x >> y;
    for (ll i=1;i<n;i++){
        ll a,t;
        cin >> a >> t;
        ll x1=a,y1=t;
        if (a<x and x%a!=0){
            x1=x+(a-(x%a));
        }else if (x%a==0){
            x1=x;
        }
        if (t<y and y%t!=0){
            y1=y+(t-(y%t));
        }else if (y%t==0){
            y1=y;
        }
        if (x1/a>y1/t){
            x=x1;
            y=x1/a*t;
        }else{
            y=y1;
            x=y1/t*a;
        }
    }
    cout << x+y << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
			Scanner scan = new Scanner(System.in);
			int N = scan.nextInt();
			
			int[] V= new int[N];
			int[] C=new int[N];
			int sum=0;
			for(int i=0;i<N;i++){				
				V[i]=scan.nextInt();		
			}
			for(int i=0;i<N;i++){				
				C[i] = scan.nextInt();					
			}
			for(int i=0;i<N;i++){
				
				if(V[i]>C[i]){
					 sum += V[i]-C[i];
				}
			}
			System.out.println(sum);
	}

}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	vector<bool> alp(26,false);
	for (int i = 0; i < s.length(); i++) {
		int x = s.at(i) - 'a';
		alp.at(x) = true;
	}
	for (int i = 0; i < 26; i++) {
		if (alp.at(i) == false) {
			char x = 'a' + i;
			cout << x << endl;
			return 0;
		}
	}
	cout << "None" << endl;
}

Measured memory_bytes: 512
def main():
    n, m = map(int, input().split())

    if n == 1 and m == 1:
        ans = 1
    elif n == 1:
        ans = m - 2
    elif m == 1:
        ans = n - 2
    else:
        ans = n*m - (2*n + 2*m - 4)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 8968
N = int(input())
num = 0

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
  
for i in range(1, N+1):
  if len(make_divisors(i)) == 8 and i%2 == 1:
    num += 1
    
print(num)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	vector<int> v(3);
	for (int i=0; i<3; i++)
		cin>>v[i];
	swap (v[0],v[1]);
	swap (v[0],v[2]);
	for (int i=0; i<3; i++)
	cout<<v[i]<<" ";
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3580
def trace(X):
    for i in range(len(X)):
        print(X[i], end='')
        if i != len(X) - 1:
            print(' ', end='')
    print('')


N = int(input())
A = [int(i) for i in input().split()]

for i in range(1, N):
    trace(A)
    v = A[i]
    j = i - 1

    while (j >= 0) and (A[j] > v):
        A[j + 1] = A[j]
        j -= 1

    A[j + 1] = v
trace(A)



Measured memory_bytes: 6320
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
	int N, K;
    cin >> N >> K;
    vector<int> data(N);
    rep(i, N) cin >> data.at(i);

    int cnt = 0;
    for(int h : data) {
        dump(h);
        if(h >= K) cnt++;
    }

    cout << cnt << endl;
}

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

using namespace std;

int n, m, pre[(int)2e5+5];
vector<int> edge[(int)2e5+5];

void dfs(int x, int f) {
  for (vector<int>::iterator i = edge[x].begin();
       i != edge[x].end(); ++i) {
    const int y = *i;
    if (y == f)
      continue;
    pre[y] += pre[x];
    dfs(y, x);
  }
  return;
}

int main(void) {
  scanf("%d%d", &n, &m);
  for (int i = 1; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  for (int i = 1; i <= m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    pre[x] += y;
  }
  dfs(1, 0);
  for (int i = 1; i <= n; ++i)
    printf("%d%c", pre[i], " \n"[i == n]);
  return 0;
}


Measured memory_bytes: 23424
from itertools import accumulate
from collections import Counter

n = int(input())
l = list(map(int,input().split()))
l.insert(0,0)
a = list(accumulate(l))

count_a = Counter(a)

ans = 0

for i in count_a.values():
    if i < 2:
        continue
    ans += i*(i-1)/2
        

print(int(ans))

Measured memory_bytes: 41728
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
int main()
{
   
        FastIO

        string c;
        cin>>c;

        if(c[0]==c[1]&& c[1]==c[2])
        	cout<<"No";
        else
        	cout<<"Yes";
        return 0;
    }
        	


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

public class Main {
	public static long solveMax(int K, long[] A){
		long childrenMax = 2;
		for(int k=K-1;k>=0;k--){
			childrenMax = (childrenMax/A[k])*A[k] + A[k]-1;
		}
		return childrenMax;
	}
	public static long solveMin(int K, long[] A){
		long childrenMin = 2;
		for(int k=K-1;k>=0;k--){
			childrenMin = ((childrenMin+A[k]-1)/A[k])*A[k];
		}
		return childrenMin;
	}
	
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        long[] A = new long[K];
        for(int k=0;k<K;k++)A[k]=sc.nextLong();
        
        long M = solveMax(K,A);
        long m = solveMin(K,A);
        if(M>=m) System.out.println(m+" "+M);
        else System.out.println("-1");
        
        
    }
}

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

using namespace std;

#define int long long
#define MOD 1000000007

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, d;
    cin >> n >> d;

    d = 2 * d + 1;
    cout << ceil(1.0 * n / d) ;
    return 0;
}


Measured memory_bytes: 256
import math
# import itertools
# import statistics
# import numpy as np
#n = int(input())
n, q = list(map(int, input().split()))
#b = list(map(int, input().split()))
s = input()
lr = []
for i in range(q):
    x, y = list(map(int, input().split()))
    lr.append([x, y])

ac_count = [0]*int(len(s))
point = 0
for i in range(len(s)-1):
    if s[i] == "A" and s[i+1] == "C":
        ac_count[i] += point+0.5
        point += 0.5
        ac_count[i+1] += point+0.5
        point += 0.5
    else:
        ac_count[i] = point
ac_count[-1] = point
for i in range(q):
    print(math.floor(ac_count[lr[i][1]-1])-math.floor(ac_count[lr[i][0]-1]))


Measured memory_bytes: 24168
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
const ll MOD=1e9+7;
int main()
{
    int n;
	cin>>n;
	for(int i=1; i<=n; i++){
		int m=(int)((double)i*1.08);
		if(m==n){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<":("<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<ll>
#define vpi vector<pair<ll,ll> >
#define mpi map<ll,ll>
#define  si set<ll>
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define reP(i,a,n) for(ll i=a;i<=n;i++)
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define st string
#define sz size()
#define case(i,n) Case<<" "<<i<<": "<<n<<endl;
#define tc ll t;cin>>t;while(t--)
int main()
{
  ll ara[6];
  for(ll i=0;i<5;i++)
    cin>>ara[i];
  for(ll i=0;i<5;i++)
  {
      if(ara[i]==0)
      {
          cout<<i+1<<endl;
          break;
      }
  }
}


Measured memory_bytes: 3596
n, m, k = map(int, input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return ''.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(n)

from collections import defaultdict
direct_f = defaultdict(int)
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    direct_f[a] += 1
    direct_f[b] += 1
    uf.union(a, b)
ans = [uf.size(i) - direct_f[i] - 1 for i in range(n)]
for i in range(k):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    if uf.same(c,d):
        ans[c] -= 1
        ans[d] -= 1
print(*ans)

Measured memory_bytes: 109656
#include <stdio.h>

 int main(void)
 {
     int n;
     int card[4][13];
     char suit[4] = "SHCD";
     scanf("%d", &n);
     int i,j,c;
     char s;
     for (i=0;i<4;i++)
     {
         for (j=0; j<13;j++)
         {
             card[i][j] = 0;
         }
     }
     for (i=0;i<2*n;i++)
     {
         scanf("%c %d",&s,&c);
         if (s == 'S') card[0][c-1] = 1;
         else if (s == 'H') card[1][c-1] = 1;
         else if (s == 'C') card[2][c-1] = 1;
         else if (s == 'D') card[3][c-1] = 1;
     }
     for (i=0;i<4;i++)
     {
         for (j=0;j<13;j++)
         {
             if (card[i][j] == 0)
             {
                 printf("%c %d\n", suit[i],j+1);
             }
         }
     }
     return 0;
 }


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

using namespace std;

typedef long long LL;

const int N = 1010;

string a, b;

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

    if(a.size() == b.size())
    {
        if(a > b) puts("GREATER");
        else if(a < b) puts("LESS");
        else puts("EQUAL");
    }
    else puts(a.size() > b.size() ? "GREATER" : "LESS");


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

int main(void){
    int N;
    int count=0;
    int a[200];
    cin>>N;
    for(int i=0;i<N;i++ ){
        cin>>a[i];
    }

    sort(a,a+N);    

    for(int i=0;i<N-1;i++){
        if(a[i]<a[i+1])
            count++;
    }
    count++;

    cout<<count;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        long T = sc.nextLong();
        long[] t = new long[N];
        long ans = 0;

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

        for(int i=0; i<N-1; i++){
            if(t[i+1]-t[i]<=T){
                ans += t[i + 1] - t[i];
            }
            else{
                ans += T;
            }
        }
        ans += T;
        System.out.println(ans);
    }
}

Measured memory_bytes: 64172
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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

const int MOD = 1e9 + 7;
const ll INF = 1e17;
const int INT_INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;


int N;
double X[101], Y[101];
double dist(double x, double y) {
	return sqrt(x*x + y * y);
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	REP(i, N) {
		cin >> X[i] >> Y[i];
	}
	double theta = 0;
	double ans = 0;
	while (theta <= 2 * pi) {
		double x = 0, y = 0;
		REP(i, N) {
			if (cos(theta)*X[i] + sin(theta)*Y[i] > 0) {
				x += X[i];
				y += Y[i];
			}
		}
		ans = max(ans, dist(x, y));
		theta += pi / 1000.0;
	}
	cout << setprecision(12) << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n;
    long long max = -1000000;
    long long min = 1000000;
    long long sum = 0 ;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        long x;
        cin >> x;
        if (max < x){
            max = x;
        }
        if (min > x){
            min = x;
        }
        sum += x;
    }
    cout << min << " " << max << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;
    cin >> N;
    vector<ll> A(N),B;
    rep(i,N)cin >> A[i];
    sort(ALL(A));
    B = A;
    // A[0]に+を入れてマイナスしまくる
    for(int i=N-2;i>0;i--){
        if(A[i]>=0)A[0] -= A[i];
        else break;
    }
    for(int i=1;i<N;i++){
        if(A[i]<0) A[N-1] -= A[i];
        else break;
    }
    cout << A[N-1] - A[0] << endl;
    A = B;
    for(int i=N-2;i>0;i--){
        if(A[i]>=0){
            cout << A[0] << " " << A[i] << endl;
            A[0] -= A[i];
        }
        else break;
    }
    for(int i=1;i<N;i++){
        if(A[i]<0){
            cout << A[N-1] << " " << A[i] << endl;
            A[N-1] -= A[i];
        }
        else break;
    }
    cout << A[N-1] << " " << A[0]  << endl;
    
}

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

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

Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main()
{
	int n, m, a, b, c, sum;
	while(scanf("%d %d", &n, &m)!=EOF)
	{
		a =1 , c = 0;
		for(int i=1;i <= m ; i++)
		{
			a *=2;
		    b = i * 1900 * a;
		    c = (n-m) * 100 * a;
		}
			sum = c + b;
		printf("%d\n", sum);
	}
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
ll nCr(ll n, ll r){
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
  ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
  return ret;
}

int main(void){
  ll x;cin>>x;
  ll k;cin>>k;
  vector<ll> R;
  R.push_back(0);
  rep(i,k){
    ll r;cin>>r;
    R.push_back(r);
  }
  ll q;cin>>q;
  vector<ll> T,A;
  rep(i,q){
    ll t,a;
    cin>>t>>a;
    T.push_back(t);
    A.push_back(a);
  }

  vector<ll> fd,fu,xd,xu;
  fd.push_back(0);
  fu.push_back(x);
  xd.push_back(0);
  xu.push_back(x);
  reps(i,k){
    ll sa = R[i] - R[i-1];
    if(i%2==1){
      fd.push_back(max((ll)0, fd[i-1]-sa));
      fu.push_back(max((ll)0, fu[i-1]-sa));
      xd.push_back(xd[i-1] + max((ll)0, sa - fd[i-1]));
      xu.push_back(xu[i-1]);
      xd[i] = min(xd[i],xu[i]);
    }else{
      fd.push_back(min(x, fd[i-1]+sa));
      fu.push_back(min(x, fu[i-1]+sa));
      xd.push_back(xd[i-1]);
      xu.push_back(xu[i-1] - max((ll)0, sa - (x - fu[i-1])));
      xu[i] = max(xd[i],xu[i]);
    }
  }
  rep(i,k+1){
    cerr<<R[i]<<" "<<fd[i]<<" "<<fu[i]<<" "<<xd[i]<<" "<<xu[i]<<endl;
  }
  cerr<<endl;
  rep(i,q){
    ll t,a;
    t = T[i];
    a = A[i];
    int idx = lower_bound(all(R), t) - R.begin() - 1;
    if(t == 0){
      cout<<a<<endl;
      continue;
    }
    chmin(a, xu[idx]);
    chmax(a, xd[idx]);
    a = fd[idx] - xd[idx] + a;
    a = a + (idx%2*2-1) * (t - R[idx]);
    chmin(a, x);
    chmax(a, 0);
    cout<<a<<endl;
  }
  return 0;
}


Measured memory_bytes: 8096
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] A = new int[N][N];
		int[][] B = new int[N][N];
		for(int i = 0; i < N; i++)
			Arrays.fill(B[i], Integer.MAX_VALUE);
		for(int i = 0; i < N; i++)
			for(int j = 0; j < N; j++)
				A[i][j] = sc.nextInt();
		long ans = 0;
		for(int k = 0; k < N; k++)
			for(int i = 0; i < N; i++)
				for(int j = i; j < N; j++) {
					if(k != i && k != j)
						B[i][j] = Math.min(B[i][j], A[i][k] + A[k][j]);
					if(A[i][j] > B[i][j]) {
						System.out.println(-1);
						return;
					}
				}
		for(int i = 0; i < N; i++)
			for(int j = i+1; j < N; j++)
				if(B[i][j] != A[i][j]) 
					ans += A[i][j];
		System.out.println(ans);
	}

}

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

using namespace std;


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

	if (R < 1200) {
		cout << "ABC" << endl;
	} else if (R < 2800) {
		cout << "ARC" << endl;
	} else {
		cout << "AGC" << endl;
	}

}

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

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int A, B, X;
  cin >> A >> B >> X;
  cout << (A <= X && X <= A + B ? "YES" : "NO") << endl;
}


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

using namespace std;

const int N=200005;
vector<int> v[N];
vector<int> id(N);
vector<int> tin(N);
vector<int> tout(N);
int idx=1;

void dfs(int a,int p=-1)
{
    id[idx]=a;
    tin[a]=idx++;
    for(int to:v[a])
    {
        if(to==p) continue;
        dfs(to,a);
    }
    tout[a]=idx;
}

int main()
{
    int n,q;
    scanf("%d%d",&n,&q);
    for(int i=0;i<n-1;i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dfs(1);
    vector<int> d(N,0);
    while(q--)
    {
        int p,x;
        scanf("%d%d",&p,&x);
        d[tin[p]]+=x;
        d[tout[p]]-=x;
    }
    vector<int> res(N,0);
    int now=0;
    for(int i=1;i<=n;i++)
    {
        now+=d[i];
        res[id[i]]=now;
    }
    for(int i=1;i<=n;i++) printf("%d ",res[i]);
    printf("\n");
    return 0;
}


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

int main(){
    ll N, T; cin >> N >> T;
    vector<int> t(200000);
    for(int i=0; i<N; i++){
        cin >> t[i];
    }
    ll sum = T;
    for(int i=1; i<N; i++){
        if(t[i]-t[i-1] >=T)
            sum += T;
        else{
            sum -= (T - (t[i]-t[i-1]));
            sum += T;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4044
#include <stdio.h>

int main(){
	int i, w, n, num[30], bar[30][2], tmp;
	
	scanf("%d %d", &w, &n);
	
	for(i = 0; i < w; i++) num[i] = i + 1;
	
	for(i = 0; i < n; i++) scanf("%d,%d", &bar[i][0], &bar[i][1]);
	
	for(i = 0; i < n; i++){
		tmp = num[bar[i][0] - 1];
		num[bar[i][0] - 1] = num[bar[i][1] - 1];
		num[bar[i][1] - 1] = tmp;
	}
	
	for(i = 0; i < w; i++) printf("%d\n", num[i]);
	
	return 0;
}

Measured memory_bytes: 596
<?php
$S=trim(fgets(STDIN));
$Q=trim(fgets(STDIN));
$p='';
for($I=0;$I<$Q;$I++){
  $C=explode(' ',trim(fgets(STDIN)));

  if($C[0][2]=='i'){
    for($i=$C[1];$i<=$C[2];$i++) $p.=$S[$i];
    $p.=PHP_EOL;
    continue;
  }
  if($C[0][2]=='v'){
    $l=($C[2]-$C[1]+1)>>1;
    for($i=0;$i<$l;$i++){
      $j=$C[2]-$i;
      $k=$C[1]+$i;
      $s=$S[$j];
      $S[$j]=$S[$k];
      $S[$k]=$s;
    }
    continue;
  }
  for($i=$C[1];$i<=$C[2];$i++) $S[$i]=$C[3][$i-$C[1]];
}
print $p;

Measured memory_bytes: 15460
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {   
	string alpha;
	string bravo;
    string resp;
    int tamA;
    int tamB;
    int aux1;
    int aux2;
    int aux3;
    int aux4;
    
    cin >> alpha >> bravo;
    
    tamA = alpha.size();
	tamB = bravo.size();

    vector <vector <int> > matriz(tamA + 1, vector <int> (tamB + 1));
    //int matriz [tamA + 1][tamB + 1];
    
    for(int i = 1; i <= tamA ; i++){
        for(int j = 1; j <= tamB; j++){
            if(alpha[i-1] == bravo[j-1]){
            	matriz[i][j] = matriz[i-1][j-1] + 1;
			}
			
            matriz[i][j] = max(matriz[i][j], matriz[i-1][j]);
            matriz[i][j] = max(matriz[i][j], matriz[i][j-1]);
        }
    }

    int i = tamA;
	int j = tamB;
	
    resp = "";
    
    while(i > 0 && j > 0){
        if(matriz[i][j] == matriz[i-1][j]){
        	i--;
        }
        else if(matriz[i][j] == matriz[i][j-1]){
        	j--;
        }
        else {
            resp = alpha[i-1] + resp;
            i--; j--;
        }
    }
    
    cout << resp << endl;
}

Measured memory_bytes: 35584
import sys
input=lambda: sys.stdin.readline().rstrip()
n,m=map(int,input().split())
H=[int(i) for i in input().split()]
edge = [[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)
ans=0
for i in range(n):
  h=H[i]
  chk=True
  for g in edge[i]:
    if H[g]>=h:
      chk=False
  if chk:
    ans+=1
print(ans)

Measured memory_bytes: 29360
//============================================================================
// Name        : Xcubic.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int x;
	cin >> x;
	cout << x*x*x << endl;
	return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)

int main(){

	lli n;
	cin>>n;

	string s;
	cin>>s;

	lli ans=0;

	for(lli i=0;i<n;i++){
		if(DEBUG)cout<<"i="<<i<<endl;
		lli dataA[26],dataB[26];
		REP(j,0,26){
			dataA[j]=0;
			dataB[j]=0;
		}
		for(lli j=0;j<=i;j++){
			dataA[s.at(j)-'a']++;
		}
		for(lli j=i+1;j<n;j++){
			dataB[s.at(j)-'a']++;
		}
		lli sum=0;
		REP(j,0,26){
			if(dataA[j]>0 && dataB[j]>0)sum++;
		}
		ans = max(ans,sum);
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll a,b;
  cin >> a >> b;
  if(a*b<=0) cout << "Zero" << endl;
  else if(0<a) cout << "Positive" << endl;
  else {
    if((b-a+1)%2) cout << "Negative" << endl;
    else cout << "Positive" << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef int_fast64_t ll;
typedef int_fast32_t intt;
typedef int_fast32_t tmp_m;
#define deb(x) cout << #x << ' ' << x << endl
#define rep(i, a, b) for (tmp_m i = a; i < b; ++i)
#define repp(i, a, b) for (tmp_m i = a; i >= b; --i)
#define pb push_back
#define st stack
#define pa pair
#define vc vector
#define qu queue
#define pq priority_queue
#define fr first
#define sc second
#define mp map
const intt mod = 1e9 + 7;

struct pr {
  intt x;
  intt y;
  intt dst;
  pr() {}
  pr(intt x, intt y, intt dst) : x(x), y(y), dst(dst) {}
  inline bool operator<(const pr& b) const {
    if (dst != b.dst) return dst > b.dst;
    if (x != b.x) return x > b.x;
    return y > b.y;
  }
};

struct point {
  intt x;
  intt y;
  point() {}
  point(intt x, intt y) : x(x), y(y) {}
  inline bool operator<(const point& b) const {
    if (x != b.x) return x > b.x;
    return y > b.y;
  }
};

inline bool spoint(point a, point b) {
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}

inline bool spr(pr a, pr b) {
  if (a.dst != b.dst) return a.dst < b.dst;
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}



void solve() {
  intt r;
  cin >> r;
  printf("%.12lf\n", 2 * r * M_PI);
  // cout << 2 * r * M_PI << endl;
}

void init() {
  // remove if interactive
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(0));
  // memset(dp, -1, sizeof dp);
}

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


Measured memory_bytes: 3784
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int sum = 0;
  REP(i,4) {
    char op;
    cin >> op;
    if(op == '+') sum++;
    if(op == '-') sum--;
  }
  cout << sum << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256