akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
  int a[3];
  FOR(i,0,2) cin >> a[i];
  sort(a, a+3);
  cout << a[0] + a[1];
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

# sys.setrecursionlimit(100000)
input = sys.stdin.buffer.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(R):
    return 2*R*math.pi


def main():
    R = read_int()
    print(slv(R))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10472
#include <iostream>
#include <string>
using namespace std;
int main() {
	string s;
	cin >> s;
	long long ans = 0;
	for (int i = 0; i < (1 << s.length() - 1); ++i) {
		long long sum = s[0] - '0';
		for (int j = 0; j < s.length() - 1; ++j) {
			if (i & (1 << j)) {
				ans += sum;
				sum = 0;
			}
			sum = sum * 10 + (s[j + 1] - '0');
		}
		ans += sum;
	}
  cout<<ans<<endl;
}


Measured memory_bytes: 256
def main():
    import sys
    from collections import deque
    read=sys.stdin.read
    readline=sys.stdin.readline
    
    n, d, a = map(int, readline().split())
    m = map(int, read().split())
    monsters = sorted(zip(m, m), key=lambda x:x[0])
    
    bomb_area = deque([])
    bomb_power = deque([])
    total_damage = 0
    ans = 0
    for pos, hp in monsters:
        while bomb_area:
            area = bomb_area[0]
            if area < pos:
                bomb_area.popleft()
                power = bomb_power.popleft()
                total_damage -= power
            else:
                break
        if hp <= total_damage:
            continue
        else:
            rest = hp - total_damage
            count = rest // a + (rest % a != 0)
            ans += count
            power = a * count
            total_damage += power
            bomb_area.append(pos + 2 * d)
            bomb_power.append(power)
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  int n,k;
  cin >> n >> k;
  int h[n],c[n];
  for(int i=0;i<n;i++) {cin >> h[i]; c[i] = 1e9;}
  c[0] = 0; c[1] = abs(h[1]-h[0]);
  for(int i=0;i<n;i++){
    for(int j=1;j<=k;j++){
     if(i+j<n) c[i+j] = min(c[i+j],c[i]+abs(h[i+j]-h[i]));
    }
  }
  cout << c[n-1] << endl;
}


Measured memory_bytes: 1024
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int a,b;
    R(a,b);
    W(a==b?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int selectionsort(int A[],int N){
    int sw =0;
    int minj;

    for (int i =0;i<N-1;i++){
        minj =i;
        for(int j=i;j<N;j++){
            if(A[j]<A[minj])
                minj = j;
                
            }
             swap(A[i],A[minj]);
            if(i!=minj)
                sw++;
                
            
        }
    
    return sw;
    
}
int main(){
    int A[100],N,i,sw;
    
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);
    sw = selectionsort(A,N);
    for(int i =0;i<N;i++){
        if(i>0) printf(" ");
        printf("%d",A[i]);
        
    }
    printf("\n");
    printf("%d\n",sw);
    return 0;
    
}


Measured memory_bytes: 3208
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string.h>
using namespace std;
int quick(int  a,int b)
{
    int   ans=1;
    while(b)
    {
        if(b&1)ans=ans*a;
        a*=a;
        b>>=1;
    }
    return ans;
}
int main()
{
    //printf("%d",quick(2,4));
   int n,k,i;
   scanf("%d%d",&n,&k);
   int a[100000];
   memset(a,0,sizeof(a));
   for(i=1;i<=n;i++)
   {
       int s=i;
       while(s<k)
       {
           s=s*2;
           a[i]++;
       }
   }
   /*for(i=1;i<=n;i++)
   {
   printf("%d ",a[i]);
   }*/
   double  sum=0;
   for(i=1;i<=n;i++)
   {
       sum+=1.0000000000/quick(2,a[i]);
   }
   //printf("sum=%d",sum);
   printf("%.10lf",(1.0/n)*sum);
}


Measured memory_bytes: 640
N = int(input())

W = []
for _ in range(N):
    w = input()
    W.append(w)

W_set = set(W)
if len(W_set) != N:
    print('No')
else:
    last = None
    satisfy = True
    for w in W:
        if last == None:
            last = w[-1]
            continue
        else:
            if w[0] != last:
                satisfy = False
                break
            last = w[-1]

    if satisfy:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3060
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	while ( true ) {

	    final int n = Integer.parseInt( stdin.nextLine() );
	    if ( n == 0 ) {
		break;
	    }
	    String input = stdin.nextLine();
	    
	    for ( int i = 0; i < n; i++ ) {
		input = solve( input );
	    }
	    System.out.println( input );
	}	
    }

    static String solve( final String input ) {
	StringBuilder sb = new StringBuilder();

	char current = ( char )255;
	int count = 0;
	for ( final char ch : input.toCharArray() ) {
	    if ( current == 255 ) {
		count++;
		current = ch;
	    } else if ( ch != current ) {
		sb.append( count );
		sb.append( current );
		count = 1;
		current = ch;
	    } else {
		count++;
	    }
	}
	sb.append( count );
	sb.append( current );
	return sb.toString();
    }    
}

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
 if(ch == 'A') return 1;
 else if (ch == 'C') return 2;
 else if (ch == 'G') return 3;
 else if (ch == 'T') return 4;
 else return 0;
}

long long getKey(char str[]){
 long long sum = 0, p = 1, i;
 for(i = 0; i < strlen(str); i++){
  sum += p*(getChar(str[i]));
  p *= 5;
 }
 return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M - 1)); }

int find(char str[]) {
 long long key, i, h;
 key = getKey(str);
 for(i = 0; ; i++){
  h = (h1(key) + i * h2(key)) % M;
  if(strcmp(H[h],str) == 0) return 1;
  else if (strlen(H[h]) == 0) return 0;
 }
 return 0;
}

int insert(char str[]) {
  long long key, i, h;
  key = getKey(str); // 文字列を数値に変換
  for(i=0; ; i++) {
    h = (h1(key) + i * h2(key)) %M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) {
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(void) {
  int i, n;
  char str[L], com[9];
  for(i=0;i<M;i++) H[i][0] = '\0';
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%s %s",com,str); // より高速なscanfを使用
    if(com[0] == 'i') {
      insert(str);
    } else {
      if(find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}


Measured memory_bytes: 16052
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;

int n;

int main()
{
    fastRead;
    int n;
    cin>>n;
    
    vector<int>vec(n) , v1 , v2 , tmp;
    for(int i =0 ; i < n ; i++ ) cin>>vec[i];
    tmp = vec;
    sort(tmp.begin() , tmp.end());
    
    map<int,int>mp;
    for(int i =0 ; i < n ; i+=2) {
        mp[tmp[i]] = 1;
    }
    int ans = 0;
    for(int i = 1 ; i < n ; i+=2 ) {
        if(mp[vec[i]]) ans++;
    }
    
    cout<<ans<<'\n';
    return 0;
    
    
}

Measured memory_bytes: 5760
object Main {
  def main(args: Array[String]): Unit = {
    val scanner = new java.util.Scanner(System.in)

    val n = scanner.nextInt
    val a = Array.fill(n)(scanner.nextInt)

    var c, minj = 0
    for(i <- 0 until n) {
      minj = i
      for(j <- i until n) {
        if(a(j) < a(minj)) {
          minj = j
        }
      }
      if(i != minj) {
        val t = a(i)
        a(i) = a(minj)
        a(minj) = t
        c = c + 1
      }
    }
    println(a.mkString(" "))
    println(c)
  }
}



Measured memory_bytes: 45244
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define pb push_back
#define mp make_pair
typedef pair<ll,ll> P;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

//Combinationを求める

const int MaxN=401001;

ll f[MaxN], rf[MaxN];
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    REP(i, 1, MaxN) f[i] = (f[i - 1] * i) % mod;
    REP(i, 0, MaxN) rf[i] = inv(f[i]);
}
//---------------------------------------------------------------------------------------------------
ll C(int n, int k) {
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % mod;

    return (a * bc) % mod;
}


int main(){
    ll N,K; cin>>N>>K;
    init();
    ll ans=C(2*N-1,N);
    if(K<N-1){
        REP(i,1,N-K){
            ans=(ans+10*mod-((C(N,i)*C(N-1,i-1))%mod))%mod;
        }
    }
    cout<<ans<<endl;

}

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

#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}
int power(long long x, long long y, long long p) {
    long long res = 1;  // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1) res = (res * x) % p;

        // y must be even now
        y = y >> 1;  // y = y/2
        x = (x * x) % p;
    }
    return res;
}

long long modInverse(long long n, long long p) { return power(n, p - 2, p); }

long long nCrModPFermat(long long n, long long r, long long p) {
    if (r == 0) return 1;
    long long fac[n + 1];
    fac[0] = 1;
    for (long long i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p;

    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p;
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

signed main() {
    long long ans = 0;
    string s;
    cin >> s;
    int f, se;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A') {
            f = i;
            break;
        }
    }
    for (int i = s.size(); i > 0; i--) {
        if (s[i] == 'Z') {
            se = i;
            break;
        }
    }
    cout << se - f + 1 << endl;
}

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

const int MX = 100005;

int main(){
    int n;
    cin >> n;
    vector<ll> cnt(MX);
    rep(i,n){
        int a;
        cin >> a;
        cnt[a]++;
    }
    ll tot = 0;
    rep(i,MX) tot += i*cnt[i];

    int q;
    cin >> q;
    rep(i,q){
        int b,c;
        cin >> b >> c;
        tot -= b*cnt[b];
        tot -= c*cnt[c];
        cnt[c] += cnt[b];
        cnt[b] = 0;
        tot += b*cnt[b];
        tot += c*cnt[c];
        cout << tot << endl;
    }
    return 0;
}

Measured memory_bytes: 4048
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	class P {
		double x, y;

		P(double x_, double y_) {
			x = x_;
			y = y_;
		}

		P add(P p) {
			return new P(x + p.x, y + p.y);
		}

		P sub(P p) {
			return new P(x - p.x, y - p.y);
		}

		P mul(double v) {
			return new P(x * v, y * v);
		}

		P div(double v) {
			return new P(x / v, y / v);
		}

		double dot(P p) {
			return x * p.x + y * p.y;
		}

		double det(P p) {
			return x * p.y - y * p.x;
		}

		double abs2() {
			return x * x + y * y;
		}

		double abs() {
			return Math.sqrt(abs2());
		}

		P norm() {
			return div(abs());
		}

		P rot90() {
			return new P(-y, x);
		}

		P proj(P src, P dst) {
			P p_sd = dst.sub(src).norm();
			return src.add(p_sd.mul(sub(src).dot(p_sd)));
		}

		P reflect(P src, P dst) {
			P middle = proj(src, dst);
			return add(middle.sub(this).mul(2));
		}

		public String toString() {
			return String.format("%f %f", x, y);
		}
	}

	P isLL(P p1, P p2, P q1, P q2) {
		double d = p2.sub(p1).det(q1.sub(q2));
		if (Math.abs(d) < 1e-10)
			return null;
		return p1.add(p2.sub(p1).mul(q1.sub(q2).det(p1.sub(q2)) / d));
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		while (q-- > 0) {
			P p1 = new P(sc.nextDouble(), sc.nextDouble());
			P p2 = new P(sc.nextDouble(), sc.nextDouble());
			P q1 = new P(sc.nextDouble(), sc.nextDouble());
			P q2 = new P(sc.nextDouble(), sc.nextDouble());

			P x = isLL(p1, p2, q1, q2);
			System.out.println(String.format("%.20f %.20f", x.x, x.y));
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

Measured memory_bytes: 60088
(format t "~A~%"
        (loop with s1 = (read-line)
              with s2 = (read-line)
              with ls2 = (length s2)
              for i from 0 to (- (length s1) ls2)
              for subst = (subseq s1 i (+ i ls2))
              minimize (loop for i across s2
                             for j across subst
                             count (not (eql i j)))))


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

#define mem(f, v) memset(f,v,sizeof(f))
#define file(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);

typedef long long ll;
const int maxn = 100010;
const int inf = ~(1u << 31u);
const ll linf = (~(1llu << 63u)) >> 2;

using namespace std;

ll f[110][55][55];
ll d[55];

int main() {
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i ++) cin >> d[i];

    for(int i = 0; i <= k; i ++){
        for(int j = 0; j <= n; j ++){
            for(int l = 0; l <= n; l ++){
                f[i][j][l] = -linf;
            }
        }
    }
    f[0][1][n] = 0;
    ll res = -linf;
    for(int i = 1; i <= k; i ++){
        for(int l = 1; l <= n; l ++){
            for(int r = n; r >= l - 1; r --){
                if(i >= 2 && l-1 >= 1) f[i][l][r] = max(f[i][l][r], f[i-2][l-1][r]);
                if(i >= 2 && r+1 <= n) f[i][l][r] = max(f[i][l][r], f[i-2][l][r+1]);
                if(l-1 >= 1 && f[i-1][l-1][r] != -linf) f[i][l][r] = max(f[i][l][r], f[i-1][l-1][r] + d[l-1]);
                if(r+1 <= n && f[i-1][l][r+1] != -linf) f[i][l][r] = max(f[i][l][r], f[i-1][l][r+1] + d[r+1]);
                res = max(res, f[i][l][r]);
            }
        }
    }
    cout << max(0ll, res) << endl;
    return 0;
}

Measured memory_bytes: 2688
<?php
  	$shop_num = intval(fgets(STDIN));
	for($i = 1; $i <= $shop_num; $i++){
      	fscanf(STDIN, '%s %d', $town[$i],$score[$i]);
    }
	arsort($score);
	$town_unique = array_unique($town);
	asort($town_unique);

	foreach($town_unique as $value_t){
      	foreach($score as $key_s => $value_s){
          	if($town[$key_s] == $value_t){
              	echo "$key_s\n";
            }
        }
    }

Measured memory_bytes: 4604
# ワーシャル-フロイド法
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(1,n+1):
        for i in range(1,n+1):
            for j in range(1,n+1):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

##############################
n,w = map(int,input().split()) #n:頂点数　w:辺の数
d = [[float('inf') for i in range(n+1)] for i in range(n+1)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
W = []
for i in range(w):
    x,y,z = map(int,input().split())
    W.append((x,y,z))
    d[x][y] = z
    d[y][x] = z
for i in range(n+1):
    d[i][i] = 0 #自身のところに行くコストは０
a = 0
warshall_floyd(d)
for i in range(w):
    x,y,z = W[i][0],W[i][1],W[i][2]
    if d[x][y] < z:
        a += 1
print(a)

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

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  unordered_map<int,ll> mp;
  rep(i,0,n){
    int a;
    cin >> a;
    ans += a;
    auto itr = mp.find(a);        // "xyz" が設定されているか？
    if( itr != mp.end() ) {
        mp[a]++;
    } else {
        mp[a] = 1;
    }
  }
  int q;
  cin >> q;
  rep(i,0,q){
    int b,c;
    cin >> b >> c;
    ans += (c-b)*mp[b];
    auto itr = mp.find(b);        // "xyz" が設定されているか？
    if( itr != mp.end() ){
        mp[c] += mp[b];
        mp[b] = 0;
    }
    cout << ans << endl;
  }
}

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

int main() {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H.at(i);
  vector<vector<int>> G(N);
  for (int i = 0, a, b; cin >> a >> b; i++) G.at(--a).push_back(--b), G.at(b).push_back(a);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (auto g : G.at(i)) if (H.at(g) >= H.at(i)) goto NG;
    ans++;
    NG:;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 8796
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
#define ll long long
ll gcd(ll m1,ll m2){
	return (m2==0)? m1:gcd(m2,m1%m2);
}
int main(){
	ll n,t[10000],smp,ans=1;
	cin>>n;
	while(n--){
		cin>>smp;
		ans=smp/gcd(ans,smp)*ans;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,x,y,z,ans[100010];
vector <pii> g[100010];

void dfs(int pos,int no,int dist)
{
	if(dist%2==0) ans[pos]=1;
	rep(i,g[pos].size())
	{
		if(g[pos][i].fi==no) continue;
		dfs(g[pos][i].fi,pos,dist+g[pos][i].se);
	}
}

int main()
{
	cin>>n;
	rep(i,n-1)
	{
		scanf("%d%d%d",&x,&y,&z);
		g[x].pb({y,z});
		g[y].pb({x,z});
	}
	dfs(1,0,0);
	repn(i,n) cout<<ans[i]<<endl;
	rt0;
}

Measured memory_bytes: 9216
S = gets.chomp
x = 0
y = 0
z = 0
if S[0] == "o"
 x = 1
 else x = 0
end
if S[1] == "o"
 y = 1
 else y = 0
end
if S[2] == "o"
 z = 1
 else z = 0
end
puts(700+(x*100)+(y*100)+(z*100))

Measured memory_bytes: 1788
#ifndef LOCAL
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif // LOCAL

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define fst first
#define snd second
#define int ll
using namespace std;
using ll = long long; using ull = unsigned ll; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>;
template<typename T> bool mind(T &x, const T &y) {if (y < x) return x = y, true; return false;}
template<typename T> bool maxd(T &x, const T &y) {if (x < y) return x = y, true; return false;}
int log2f(int x) {return 32 - __builtin_clz(x) - 1;}
const int mod = 1e9+7, mod9 = 1e9+9, infi = 1e9+100; const ll infl = 1e18L+1000, modl = 1e18L+3; const ld infd = INFINITY;
/*
#define x(a) real(a)
#define y(a) imag(a)
using G = ll; using point = complex<G>;
istream& operator>>(istream &is, point &p){G x, y; is >> x >> y; p = {x, y}; return is;}
ostream& operator<<(ostream &os, const point &p){os << p.x() << ' ' << p.y(); return os;}
G dot(const point &a, const point &b) {return (conj(a)*b).x();}
G crs(const point &a, const point &b) {return (conj(a)*b).y();}
G ori(const point &a, const point &b, const point &c) {return crs(b-a, c-b);};
bool cmpyx(const point &a, const point &b) {return a.y()<b.y() || (a.y()==b.y()&&a.x()<b.x());};
*/
signed main()
{
    #ifdef LOCAL
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    #endif // LOCAL
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout << fixed << setprecision(15);
    int n, c; cin >> n >> c;
    vector<int> x(n+2), v(n+2); for(int i = 1; i <= n; ++i) cin >> x[i] >> v[i];
    vector<int> a1[2]{vector<int>(n+2), vector<int>(n+2)}, a2[2]{vector<int>(n+2), vector<int>(n+2)};
    for(int i = 1, acc = 0; i <= n; ++i) acc += v[i], a1[0][i] = max(a1[0][i-1], acc-x[i]), a2[0][i] = max(a2[0][i-1], acc-2*x[i]);
    for(int i = n, acc = 0; i >= 1; --i) acc += v[i], a1[1][i] = max(a1[1][i+1], acc-(c-x[i])), a2[1][i] = max(a2[1][i+1], acc-2*(c-x[i]));
    int ans = 0;
    for(int i = 0; i <= n; ++i) maxd(ans, a1[0][i]+a2[1][i+1]);
    for(int i = 0; i <= n; ++i) maxd(ans, a1[1][i+1]+a2[0][i]);
    cout << ans;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;

int n, m, a[MAXM];
vector<int> dist;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m;
    FOR(i,1,m) cin >> a[i];
    sort(a+1, a+m+1);
    int res = a[m] - a[1];

    // FOR(i,1,m) cout << a[i] << ' ';
    // cout << endl;

    FOR(i,2,m) dist.emplace_back(a[i] - a[i-1]);
    sort(ALL(dist));

    n--;
    if (n) {
        FORE(i,SZ(dist)-1,0) {
            //cout << dist[i] << endl;
            res -= dist[i];
            n--;
            if (n == 0) break;
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
char a[55],b[55];int l,i;
int main(){
	scanf("%s%s",a,b);
	l=strlen(b);
	for(i=0;i<l;i++) printf("%c%c",a[i],b[i]);
	if(strlen(a)>strlen(b)) printf("%c",a[l]);
	printf("\n");
	return 0;
}

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

int main(){
  int N, D, X; cin >> N >> D >> X;
  vector<int> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  int ans = X;
  for(int i = 0; i < N; i++){
    ans += 1 + (D - 1) / A[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<random>
#include<ctime>
#include<cstdlib>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
const ll Mod = 1000000007;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct S {//辺の情報を入れる変数
	int from, to, cost;
};
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
struct G {
	int x, y;
};
bool operator<(G a, G b) { 
	if(a.y!=b.y)return a.y < b.y;
	return a.x < b.x;
}
bool operator>(G a, G b) {
	if (a.y != b.y)return a.y > b.y;
	return a.x > b.x;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
	return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
 //---------------------------------------------------
 //+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	string s;
	cin >> s;
	int a = (int)s[0] - '0', b = (int)s[1] - '0', c = (int)s[2] - '0', d = (int)s[3] - '0';
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			for (int z = 0; z < 2; z++) {
				int sum = 0;
				if (i == 0) sum = a + b;
				else sum = a - b;
				if (j == 0) sum += c;
				else sum -= c;
				if (z == 0) sum += d;
				else sum -= d;
				if (sum == 7) {
					cout << a;
					if (i == 0) cout << "+";
					else cout << "-";
					cout << b;
					if (j == 0) cout << "+";
					else cout << "-";
					cout << c;
					if (z == 0) cout << "+";
					else cout << "-";
					cout << d;
					cout << "=7\n";
					goto stop;
				}
			}
		}
	}
stop:;
	getchar(); getchar();
}

Measured memory_bytes: 256
# 整数の入力
a = int(input())

# 文字列の入力
S = str(input())

chr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
SS = []

for k in range(len(S)):
    for j in range(len(chr)):
        if S[k] == chr[j]:
            if (j+a) >= 25:
                SS += chr[j+a-26]
            else:
                SS += chr[j+a]

SS = ''.join(SS)

print(SS)

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

int main() {
  long long L,Ans=0;
  cin>>L;
  cout << fixed << setprecision(10) << L*L*L/27.0<< endl;
}

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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	vector<pair <int, int>> hito;
	int n, k, tmp = 0, len, ans = 0;
	string s;
	cin >> n >> k;
	cin >> s;

	rep(i, n + 1){
		if(i == 0){
			if(s[0] == '0')
				hito.push_back(make_pair(1, 0));
		}else if(i == n){
			hito.push_back(make_pair((int)(s[i - 1] - '0'), tmp));
			if(s[n - 1] == '0')
				hito.push_back(make_pair(1, 0));
		}else if(n > 1 && s[i] != s[i - 1]){
			hito.push_back(make_pair((int)(s[i - 1] - '0'), tmp));
			tmp = 0;
		}
		tmp++;
	}

	len = hito.size();
	if(2 * k + 1 >= len)
		ans = n;
	else{
		rep(i, 2 * k + 1) ans += hito[i].second;
		// cout << ans << endl;
		int ans_tmp = ans;
		for(int i = 2 * k; i < len - 2; i += 2){
			ans_tmp = ans_tmp - hito[i - 2 * k].second - hito[i - 2 * k + 1].second
			+ hito[i + 1].second + hito[i + 2].second;
			chmax(ans, ans_tmp);
			// cout << i - 2 * k + 2 << " " << i + 2 << " " << ans_tmp << endl;
		}
	}
/* 	rep(i, hito.size()){
		cout << (int)hito[i].first << " " << hito[i].second << endl;
	} */
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1528
n = int(input())
A = []
g  =[[] for _ in range(n+1)]
ans = {}
for _ in range(n-1):
    a,b = map(int,input().split())
    g[a].append(b)
    A.append([a,b])
 
 
from collections import deque
 
q = deque()
q.append(1)
 
color = [-1]*(n+1)
color[1] = 0
cnt = 0
 
while q:
    v = q.popleft()
    p = 1
    for u in g[v]:
        if p==color[v]:
            p += 1
        color[u] = p
        ans[v,u] = p
        q.append(u)
        cnt = max(cnt,p)
        p += 1
print(cnt)
 
for i in range(n-1):
    tmp = (A[i][0],A[i][1])
    print(ans[tmp])

Measured memory_bytes: 46768
/*
				" اللهم صلي و سلم علي سيدنا محمد و علي اله وصحبه اجمعين "
*/

#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define f for
#define ll long long
#define ull unsigned long long
#define endl "\n"
using namespace std;
#define BI  acos(-1)
#define all(a) a.begin(), a.end()
void Open()
{
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
ll gcd(ll a, ll b)
{
	return b == 0 ? a : gcd(b, a % b);
}
void madesetprobblem()
{
	//$ $
	//less than or equal => $ 1 \leq 100 $
	//  $(1 \le A,B \le 10^5 )$
	// a[i] => $a_i$
	// a[i][j] => $a_{i,j}$
	// double qoutes ''yext''
	/*
		image
		\begine{center}
		\includegraphics{image.jpg}
		\end{center}
	*/
	/*
		list
		\begin{itemize}
			\item first one
			\item second one
		\end{itemize}
	*/
}

int n, k;
ll a[105][2];
vector<vector<ll>>dp(105, vector<ll>(100005, -1));
ll ans(ll value,ll c )
{
	ll p1 = INT_MAX, p2 = INT_MAX;
	if (c == n)
	{
		if(!value)
		return 0;
		return p1;
	}
	if (dp[c][value] != -1)
	{
		return dp[c][value];
	}
	if (value-a[c][1] >=0)
	{
		p1 = a[c][0] + ans(value-a[c][1], c + 1);
	}
	p2 = ans(value, c + 1);
		return dp[c][value] = min(p1, p2);
}
int main()
{
	// توكلت علي الله 
//Open();
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n >> k;
	ll M = 0, mx = 0;
	f(int i = 0; i < n; i++)
	{
		cin >> a[i][0] >> a[i][1]; M += a[i][1];
	}
	//ll mx = 0;
	f(ll i = M; i >=0; i--)
	{
		if (ans(i, 0) <= k)
		{
			mx = i;
			break;
		}
	}
	cout << mx;
}

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

using namespace std;

#define int long long

const int N = 1e5 + 5;
int n, q, sz, a[N], cnt[N], ans[N];

signed main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> q;
    a[++sz] = n;
    for (int i = 1; i <= q; ++i) {
        int x; cin >> x;
        while(sz && a[sz] >= x) sz --;
        a[++sz] = x;
    }

    cnt[sz] = 1;
    for (int i = sz; i; --i) {
        //cout << "i = " << i << '\n';
        int now = a[i];
        while(now > a[1]) {
            int pos = lower_bound(a + 1, a + 1 + sz, now) - a - 1;
            //cout << "pos = " << pos << '\n';
            cnt[pos] += cnt[i] * (now / a[pos]);
            now %= a[pos];
        }
        ans[now] += cnt[i];
    }

    for (int i = n; i; --i) ans[i] += ans[i + 1];
    for (int i = 1; i <= n; ++i) cout << ans[i] << '\n';

    return 0;
}


Measured memory_bytes: 4096
//“ In order to be irreplaceable, one must always be different”
#include <bits/stdc++.h>
using namespace std;
# define ll long long
#define endl "\n"
# define pi 3.14159265359
# define str string
# define vll vector<ll>
# define vstr vector<str>
# define vchar vector<char>
# define pb push_back
# define popb pop_back
# define pf push_front
# define popf pop_front
# define sll set<ll>
# define schar set<char>
//find()
//erase(x) removes element x
//erase(position,position)
# define qll queue<ll>
# define qstr queue<str>
//front(),back()
# define stll stack<ll>
# define ststr stack<str>
//top()
# define dll deque<ll>
//at()
# define mll map<ll,ll>
#define mchar map<char, ll>
# define mstr map<str,ll>
# define mss map<str,str>
# define mci map<char,ll>
# define vp vector< pair<ll,ll> >
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
# define r(x,y) for(int x=y;x>=0;x--)
# define fr(x,y,z) for(int x=y;x<z;x++)
# define rr(x,y,z) for(int x=y;x>z;x--)
ll power(ll a , ll b){ll res=1;for(ll i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll gcd(ll a, ll b){
    if(b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a, b);
}
void print(vll a){
    for(int i=0;i<a.size();i++){
        cout<<a[i]<<' ';
    }
    cout<<endl;
}
vll inp(int n){
    vll a;
    ll x;
    f(i,n){
        cin>>x;
        a.pb(x);
    }
    return a;
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x,y;
    cin>>x>>y;
    ll m=x%y;
    cout<<min(m,y-m);
}



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

#define ll long long int
#define ull unsigned long long int
#define forr(i,n) for(int i=0;i<n;i++)
#define f(i,a,b) for(ll i=a;i<b;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) int t; cin>>t; while(t--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vi vector<ll>
const ll md=1e9 +7;const ll M1=998244353;
ll mod(ll n){return ((n%M1)+M1)%M1;}
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=res*x;x=x*x;y=y>>1;}return res;}

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

    ll n,k;cin>>n>>k;
    vector<pair<ll,ll>> v(k);
    f(i,0,k)cin>>v[i].F>>v[i].S;

    vi dp(n+1,0);
    dp[0]=0,dp[1]=1;
    f(i,2,n+1){
        ll cur=0;
        f(j,0,k){
            if(v[j].F>=i)continue;
            ll l=max(1LL,i-v[j].S);
            ll r=i-v[j].F;
            cur+=dp[r]-dp[l-1];
        }
        cur=mod(cur);
        dp[i]=mod(dp[i-1]+cur);
    }cs(mod(dp[n]-dp[n-1]));
    //f(i,1,n+1)cs(dp[i]);
}


Measured memory_bytes: 4700
#include<bits/stdc++.h>
using namespace std;
///////////////////////////////////////////////////////////////////////////////////////////////////////
const int maxn=1e5+10;
const int maxm=1e2+10;
long long int dp[maxn][maxm];
int n;
int k;
int w[maxn];
int u[maxn];
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>w[i]>>u[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=k;j>=0;j--){
			if(j>=w[i]){
				dp[i][j]=max(dp[i-1][j-w[i]]+u[i],dp[i-1][j]);
			}
			else{
				dp[i][j]=dp[i-1][j];
			}
		}
	}
	cout<<dp[n][k];
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
#include <string.h>
using namespace std;

int main() {
	int N,d[100]={},k=0,ans=0;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>d[i];
	}
	sort(d,d+N);
	for(int i=0;i<N;i++)
	{
		if(k!=d[i])ans++;
		k=d[i];
	}
	cout<<ans;
	}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
int read()
{
	int f=1,x=0; char c=getchar();
	while (c>'9'||c<'0') {if (c=='-') f=-1; c=getchar();}
	while (c>='0' && c<='9') {x=x*10+c-'0'; c=getchar();}
	return x*f;
}
int A,B,C,D;
int main()
{
	A=read(); B=read(); C=read(); D=read(); int c=0;
	if (A>B) {
		int t=A;
		A=B;
		B=t;
	}
	if (C>D) {
		int t=C;
		C=D;
		D=t;
	}
	for (int i=A; i<=B; i++)
	if (i>=C && i<=D) c++;
	if (c!=0) c--;
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a, b, i;
    char op;
    for(i = 1;;i++){
        scanf("%d %c %d", &a, &op, &b);


	if(op == '+')a+=b;
	
	if(op == '-')a-=b;
  
	if(op == '*')a*=b;
 
	if(op == '/')a/=b;

	if(op == '?')break;
        printf("%d\n", a);

        }
    return 0;
}


Measured memory_bytes: 2088
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<random>
#include<map>

//使い方がよくわからない
#include<stack>
#include<queue>
#include<bitset>
#include<sstream>

#define rep(i,n) for(int i=0;i<(n);i++) 
#define rep1(i,n) for(int i=1;i<(n);i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]){
    ll a,b;
    cin >> a >> b;
    ll c = __gcd(a,b);
    ll d = sqrt(c)+1;
    ll cnt = 1;
    for(ll i = 2;i<=d;i++){
        if(c%i==0) cnt++;
        while(c%i==0){
            c/=i;
        }
    }
    if(c>1) cnt++;
    co(cnt);
    return 0;
}

Measured memory_bytes: 256
#include <iostream> 
using namespace std; 
int main()
{ 
 	int n;  
	cin>>n;  
	int a[n]; 	 
 	for (int i=0;i<n;i++)   
	  cin>>a[i]; 
 	int f,count=0; 
 	do {  	 	
		f=0; 
 		for (int i=0;i<n;i++)
		{  	 	 	
			if (a[i]%2==0)
			{  	 	 	 	
				a[i]=a[i]/2; 
 	 		} 
 	 		else
			{  	 	 	 	
				f=1;  	 	 	 	
				break; 
 	 		} 
 		} 
	 	if (f==0) 
		  count++; 
	}while (f==0); 
 	cout<<count<<endl;  
 	return 0; 
} 


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//入力表示
		int N = sc.nextInt();
		int count = 0;
		 
		for (int i = 1; i <= N; i++) {
			int P = sc.nextInt();
 
			if (P != i) {
				count++;
			}
 
		}
      	//2回以上繰り返したら
	//	System.out.println(count<=2 ? "NO":"YES");
		
		if (count <= 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 23892
#include <iostream>
using namespace std;
string st;
int l;
int main()
{
	cin>>st;
	l=st.size();
	for (int i=0;i<l;i++)
	{
	    if (st[i]=='p') 
	    {
	    	if (st[l-i-1]!='q') 
	    	{
	    		cout<<"No"<<endl;
	    		return 0;
	    	}
	    }
	       if (st[i]=='q') 
	    {
	    	if (st[l-i-1]!='p') 
	    	{
	    		cout<<"No"<<endl;
	    		return 0;
	    	}
	    }
	       if (st[i]=='b') 
	    {
	    	if (st[l-i-1]!='d') 
	    	{
	    		cout<<"No"<<endl;
	    		return 0;
	    	}
	    }
	       if (st[i]=='d') 
	    {
	    	if (st[l-i-1]!='b') 
	    	{
	    		cout<<"No"<<endl;
	    		return 0;
	    	}
	    }
	}
	cout<<"Yes"<<endl;
}

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

#define rep(i, n) for (int i=0; i< (n); ++i)
typedef long long ll;
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; }

using namespace std;

int main() {
    int n, k;

    cin >> n >> k;

    int p[n];
    long double kitaichi_arr[n];
    rep(i, n) {
        cin >> p[i];
        kitaichi_arr[i] = ((long double) p[i] * ((long double) p[i] + 1)) / (2 * (long double) p[i]);
    }

    long double kitaichi_i = 0;
    rep(i, k) {
        kitaichi_i += kitaichi_arr[i];
    }

    long double kitaichi_max = kitaichi_i;
    rep(i, n-k) {
        kitaichi_i = kitaichi_i - kitaichi_arr[i] + kitaichi_arr[i+k];
        if (kitaichi_max < kitaichi_i) {
            kitaichi_max = kitaichi_i;
        }
    }

    printf("%.10Lf\n", kitaichi_max);
}


Measured memory_bytes: 4096
//ITP1_8_B_19140837_Ojima_Yukiya.cpp
//提出日 2020/6/17 wednesday
//プログラミング基礎演習2 CS 第６回課題 ITP1_8_B
//学修番号 19140837　小島優希也
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    vector<int> vec;
    while (true) {
        string s;
        cin >> s;
        int sum = 0;
        if (s == "0") break;
        else {
            for (auto e : s) {
                sum += (int)e - 48;
            }
            vec.push_back(sum);
        }
    }
    for (int e : vec) {
        cout << e << endl;
    }
    return 0;

}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;

int main(){
  int n,k;
  cin >> n >> k;

  int ans;

  if((n % k) == 0){
    ans = 0;
    }else{
      ans = 1;
      }

      cout << ans << endl;
      return 0;
}


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

#define ll long long
#define M 1000000007
#define deb(x) cout<<#x<<" "<<x<<endl;
#define foi(a,b) for(int i=a;i<b;i++)
#define foj(a,b) for(int j=a;j<b;j++)
#define fod(a,b) for(int i=a;i>b;i--)
#define MAX  1e9
#define MIN -1e9
#define nl cout<<"\n";
#define show(arr,a,b) for(int i=a;i<b;i++) cout<<arr[i]<<" "; cout<<endl;
#define  mp(a,b) pair<ll,ll> p(a,b)
#define pb push_back
typedef pair<ll,ll> p1;
typedef vector<ll> vecd;
typedef vector<string> vecsd;
typedef map<ll,ll> mpd;
typedef set<ll> setd;
typedef multiset<ll> msetd;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t; cin>>t;
    ll hap=0;
    hap=(t/500)*1000;
    t=t%500;
    hap+=(t/5)*5;
    cout<<hap<<"\n";
    return 0;
}


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

int main() {
    string ABCD;
    cin >> ABCD;
    int A = ABCD[0] - '0';
    int B = ABCD[1] - '0';
    int C = ABCD[2] - '0';
    int D = ABCD[3] - '0';
    if(A+B+C+D==7) {
        //cout<<"A+B+C+D=7"<<endl;
        cout<<A<<"+"<<B<<"+"<<C<<"+"<<D<<"=7"<<endl;
    }else if(A-B+C+D==7) {
        //cout << "A-B+C+D=7"<<endl;
        cout<<A<<"-"<<B<<"+"<<C<<"+"<<D<<"=7"<<endl;
    }else if(A+B-C+D==7) {
        //cout <<"A+B-C+D=7"<<endl;
        cout<<A<<"+"<<B<<"-"<<C<<"+"<<D<<"=7"<<endl;
    }else if(A-B-C+D==7) {
        //cout <<"A-B-C+D=7"<<endl;
        cout<<A<<"-"<<B<<"-"<<C<<"+"<<D<<"=7"<<endl;
    }else if(A+B+C-D==7) {
        //cout <<"A+B+C-D=7"<<endl;
        cout<<A<<"+"<<B<<"+"<<C<<"-"<<D<<"=7"<<endl;
    }else if(A-B+C-D==7) {
        //cout <<"A-B+C-D=7"<<endl;
        cout<<A<<"-"<<B<<"+"<<C<<"-"<<D<<"=7"<<endl;
    }else if(A+B-C-D==7) {
        //cout <<"A+B-C-D=7"<<endl;
        cout<<A<<"+"<<B<<"-"<<C<<"-"<<D<<"=7"<<endl;
    }else if(A-B-C-D==7) {
        //cout <<"A-B-C-D=7"<<endl;
        cout<<A<<"-"<<B<<"-"<<C<<"-"<<D<<"=7"<<endl;
    }
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <set>
using namespace std;

int main()
{
  string s;
  cin >> s;
  string k = "None";
  set<char> a;
  for (int i = 0; i < s.length(); i++)
  {
    a.insert(s[i]);
  }
  if (a.size() < 26)
  {
    char ca = 'a';
    for (int i = 0; i < 26; i++)
    {
      if (a.find(ca) == a.end())
      {
        k = ca;
        //cout << "zenbu" << endl;
        break;
      }
      else
      {
        ca += 1; //ascii?
      }
    }
  }
  cout << k << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int mod = 998244353;

int expo(int num, int p) {
    if(num == 0) {
        if(p == 0) assert(false);
        return 0;
    }
    num = num % mod;
    int ret = 1;
    while(p) {
        if(p & 1) ret = (ret * num) % mod;
        num = (num * num) % mod;
        p /= 2;
    }
    return ret;
}

signed main() {
    IOS;
    int fact[200005], inv[200005];
    fact[0] = 1;
    for(int i = 1; i < 200005; ++i) fact[i] = (fact[i - 1] * i) % mod;
    for(int i = 0; i < 200005; ++i) inv[i] = expo(fact[i], mod - 2);
    int n, m, k;
    cin >> n >> m >> k;
    int ans = 0;
    if(m == 1) {
        if(k == n - 1) cout << 1;
        else cout << 0;
        return 0;
    }
    for(int i = 0; i <= k; ++i) {
        int cur = (m * expo(m - 1, n - i - 1)) % mod;
        cur = (cur * fact[n - 1]) % mod;
        cur = (cur * inv[i]) % mod;
        cur = (cur * inv[n - i - 1]) % mod;
        ans = (ans + cur) % mod;
    }
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 6776