akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<bits/extc++.h>

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()

using namespace std;
using namespace __gnu_pbds;

typedef tree< int, null_type, less< int >, rb_tree_tag, tree_order_statistics_node_update> ost;
// name.find_by_order(x) or name.order_of_key(x)
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<vector<int>> vvi;

void yes() {printf("YES\n");}
void no() {printf("NO\n");}

int dx4[] = {-1, 1, 0, 0};
int dy4[] = {0, 0, -1, 1};
int dx8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};

const int maxn = 2e5 + 5, maxv = 2e6 + 5;
const int MOD = 1e9 + 7;

int mult(ll a, ll b) {return (a * b) % MOD;}
int pot(int n, int k) {
	int ret = 1, pot = n;
	for(;k > 0;k >>= 1, pot = mult(pot, pot)) 
		ret = mult(ret, (k & 1) ? pot : 1);
	return ret;
}
int divide(int a, int b) {return mult(a, pot(b, MOD - 2));}
int add(int a, int b) {a += b;if(a >= MOD) a -= MOD;return a;}
int sub(int a, int b) {a -= b;if(a < 0) a += MOD;return a;}

vector<int> fact;
void calc_fact(int n) {
	fact = vector<int>(n + 1, 1);
	for(int i = 1;i <= n;i++) fact[i] = mult(fact[i - 1], i);
}
int choose(int n, int k) {return divide(fact[n], mult(fact[n - k], fact[k]));}

bool prime(ll a) {
	if (a == 1) return 0;
	for(ll i = 2;i * i <= a;i++) 
		if (a % i == 0) return 0;
	return 1;
}

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

ll phi(ll x) {
	double ret = x;
	for(ll i = 2;i * i <= x;i++) {
		if (x % i) continue;
		ret *= (1.0 - 1.0 / (double)i);
		while (x % i == 0) x /= i;
	}
	if (x > 1) ret *= (1.0 - 1.0 / (double)x );
	return (ll)ret;
}

void solve() {
	int n;
	scanf("%d", &n);
	int cnt = 0, ans = 0;
	for(int i = 0;i < n;i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		if(x != y) {
			ans = max(ans, cnt), cnt = 0;
		} else cnt++;
	}
	ans = max(ans, cnt);
	printf("%s\n", (ans >= 3 ? "Yes" : "No"));
}

int main() {
	int t = 1;
	//scanf("%d", &t);
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 3764
<?php

class Searcher
{
    private $n_array_S;
    private $array_S;
    private $n_array_T;
    private $array_T;
    
    public function __construct()
    {
        fscanf(STDIN, "%d", $this->n_array_S);
        $this->array_S = explode(' ', trim(fgets(STDIN)));
        fscanf(STDIN, "%d", $this->n_array_T);
        $this->array_T = explode(' ', trim(fgets(STDIN)));
    }

    public function countSameNumbers()
    {
        echo count(array_intersect(array_unique($this->array_S), $this->array_T)) . PHP_EOL;
    }
}

$searcher = new Searcher();
$searcher->countSameNumbers();



Measured memory_bytes: 46492
def add(a, w)
  while a <= $n
    $d[a] += w
    a += a & -a
  end
end

def sum(i)
  ret = 0
  x = i
  while x > 0
    ret += $d[x]
    x -= x & -x
  end
  return ret
end

$n, q = gets.split.map(&:to_i)
$d = Array.new($n+1){0}

q.times{
  com, s, t, x = gets.split.map(&:to_i)
  case com
  when 0
    add(s, x)
    add(t+1, -x)
  when 1
    p sum(s)
  end
}

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

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

    int a = b % 10;

    if(a == 2 || a == 4 || a==5||a==7||a==9){
        cout << "hon"<<endl;
    }
    if(a==0||a==1||a==6||a==8){
        cout << "pon" << endl;
    }
    if(a == 3){
        cout << "bon" << endl;
    }
}


Measured memory_bytes: 3620
def main():
  ## IMPORT MODULE
  #import sys

  #sys.setrecursionlimit(100000)
  #input=lambda :sys.stdin.readline().rstrip()

  #f_inf=float("inf")
  #MOD=10**9+7
  
  if 'get_ipython' in globals(): 
    ## SAMPLE INPUT
    a, b = 2, 5

  else:
    ##INPUT 
    #n = input()
    a, b = map(int, input().split())

  ## SUBMITION CODES HERE
  print(a*b)

main()

Measured memory_bytes: 9032
#include <bits/stdc++.h> 
#include <time.h>
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i) 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e5+10;
const int N = 1e5+10;
const int E = 1e6+10;  
ll n,k;
ll a[maxn],b,c,cnt[maxn];
ll sum;

int main(){
	cin>>n;
	F(i,1,n){
		cin>>a[i];
		cnt[a[i]]++;
		sum+=a[i];
	}
	cin>>k;
	while(k--){
		cin>>b>>c;
		sum-=cnt[b]*b;
		sum+=cnt[b]*c;
		cnt[c]+=cnt[b];
		cnt[b] = 0;
		cout<<sum<<endl; 
	}
}

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

int main(){
  string str;
  int q;
  cin >> str;
  cin >> q;
  while(q--){
    string s;
    cin >> s;
    if(s == "print"){
      int a, b;
      cin >> a >> b;
      cout << str.substr( a, b - a + 1) << endl;
    } else if(s == "reverse"){
      int a, b;
      cin >> a >> b;
      reverse( str.begin() + a, str.begin() + b + 1);
    } else {
      int a, b;
      string p;
      cin >> a >> b >> p;
      str.replace( a, b - a + 1, p);
    }
  }
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,dis1=0,dis2=0,m;
    cin>>n;
    int arra[n]={9};
    fill(arra,arra+n,999999999);
    arra[0]=0;
    vector<int> vec;
    for(int i=0;i<n;i++){
            cin>>m;
    vec.push_back(m);
    }
   // cout<<arra[4]<<endl;
    for(int j=0;j<(n-1);j++)
    {
            dis1=arra[j]+abs(vec[j]-vec[j+1]);
            dis2=arra[j]+abs(vec[j]-vec[j+2]);
            if(arra[j+1]>dis1){
            arra[j+1]=dis1;
            //cout<<j+1<<" "<<arra[j+1]<<endl;
            }
            if(arra[j+2]>dis2){
            arra[j+2]=dis2;
  //cout<<arra[j+2]<<" "<<j+2<<endl;
  }
    }
    cout<<arra[n-1]<<endl;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  int D;
  cin >> D;
  const int T = 26;     // type no kazu
  vector<ll> c(T + 1);  // penalty 1-indexed
  REP(i, T) { cin >> c[i + 1]; }
  vector<vector<ll>> s(D + 1, vector<ll>(T + 1));  // 1-indexed
  REP(i, D) REP(j, T) { cin >> s[i + 1][j + 1]; }

  vector<ll> t(D, 1);
  REP(i, D) { cout << t[i] << endl; }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int x, y, a[15];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> x >> y;
	a[4] = a[6] = a[9] = a[11] = 1;
	a[2] = 2;
	cout << (a[x] == a[y] ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int N;
	cin >> N;
	vector<int>s(N);
	int mn = INF;
	int sum = 0;
	bool isOK = false;
	rep(i, N) {
		cin >> s[i];
		sum += s[i];
		if (s[i] % 10 != 0) {
			isOK = true;
			mn = min(mn, s[i]);
		}
	}
	if (!isOK) {
		cout << 0;
		return 0;
	}
	if (sum % 10 != 0)cout << sum;
	else cout << sum - mn;
}

Measured memory_bytes: 256
A = input()
B = input()
C = input()
X = input()

A = int(A)
B = int(B)
C = int(C)
X = int(X)

res = int(0)

for x in range(A+1):
	for y in range(B+1):
		for z in range(C+1):
			total = int(500*x + 100*y + 50*z)
			if(total == X):
				res+=1
			
print(res)

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long

static const int MAX = 10000;
static const int INFTY = (1<<21);
static const int WHITE = 0; // 未到達
static const int GRAY = 1; // 到達
static const int BLACK = 2; // 探索済み

vector<pair<int, int>> adj[MAX]; // 重み付き有向グラフの隣接リスト表現
int color[MAX];
int d[MAX];
int p[MAX];

void dijkstra(int s) {
  // <cost, node>
  priority_queue<pair<int, int>> PQ;
  for (int i = 0; i < MAX; i++) {
    d[i] = INFTY;
    color[i] = 0;
  }

  d[s] = 0;
  PQ.push(make_pair(0, s));
  color[s] = GRAY;

  while (!PQ.empty()) {
    pair<int, int> f = PQ.top();
    PQ.pop();
    int u = f.second;
    color[u] = BLACK;

    for (int j = 0; j < adj[u].size(); j++) {
      int v = adj[u][j].first;
      if (color[v] == BLACK) continue;
      if (d[v] > d[u] + adj[u][j].second) {
        d[v] = d[u] + adj[u][j].second;
        p[v] = u;
        // priority_queueはデフォルトで大きい値を優先するため-1をかける
        PQ.push(make_pair(d[v] * (-1), v));
        color[v] = GRAY;
      }
    }
  }
};

int main() {
  int H, W;
  cin >> H >> W;
  int black = 0;
  char ch;
  rep(i, 1, H * W + 1) {
    cin >> ch;
    if (ch == '.') {
      if ((i % W) != 0) {
        adj[i].push_back(make_pair(i + 1, 1));
      }
      if ((i % W) != 1) {
        adj[i].push_back(make_pair(i - 1, 1));
      }
      if (i > W) {
        adj[i].push_back(make_pair(i - W, 1));
      }
      if (i < (H - 1) * W + 1) {
        adj[i].push_back(make_pair(i + W, 1));
      }
    } else black++;
  }
  dijkstra(1);

  if (color[H * W] != BLACK) {
    cout << -1 << endl;
  } else {
    cout << H * W - black - (d[H * W] + 1) << endl;
  }
};


Measured memory_bytes: 640
from operator import itemgetter
n = int(input())
a = list(map(int,input().split()))
b=[]
for i in range(n):
    b.append([i,a[i]])
c = sorted(b, key=itemgetter(1), reverse=False)
d=[]
for i in range(n):
    d.append((str(c[i][0]+1)))
print(" ".join(d))

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

using namespace std;
using ll = long long;

//cout << std::fixed << std::setprecision(15) << y << endl;

int main() {
    int n = 0;
    cin >> n;
    map<string,ll> s;
    for(int i = 0;i < n;i++){
        string tmpS = "";
        cin >> tmpS;
        sort(tmpS.begin(),tmpS.end());
        s.emplace(tmpS,s[tmpS] ++);
    }
    ll sum = 0;
    for(auto out : s){
        sum += (out.second * (out.second - 1)) / 2;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 11136
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	int n, m, p, q, r;
	vector<P> pre(5000), next(5000);
	while (cin >> n && n) {
		cin >> m >> p >> q >> r;
		pre.clear();
		pre.push_back(P(1, n));
		vector<P> a(m), b(m), c(m);
		rep(i, m) {
			a.clear(); b.clear(); c.clear();
			next.clear();
			int x, y; cin >> x >> y;
			int sum = 0;
			for (P p : pre) {
				int tmp = p.second - p.first + 1;
				if (sum + tmp <= x) {
					a.push_back(p);
				} else if (y <= sum) {
					c.push_back(p);
				} else if (x <= sum && sum + tmp <= y) {
					b.push_back(p);
				} else if (sum < x && y < sum + tmp) {
					P fst = P(p.first, p.first + (x - sum) - 1);
					P snd = P(fst.second + 1, fst.second + (y - x));
					P trd = P(snd.second + 1, p.second);
					a.push_back(fst);
					b.push_back(snd);
					c.push_back(trd);
				} else if (sum < x && x < sum + tmp) {
					P fst = P(p.first, p.first + (x - sum) - 1);
					P snd = P(fst.second + 1, p.second);
					a.push_back(fst);
					b.push_back(snd);
				} else if (sum < y && y < sum + tmp) {
					P fst = P(p.first, p.first + (y - sum) - 1);
					P snd = P(fst.second + 1, p.second);
					b.push_back(fst);
					c.push_back(snd);
				}
				sum += tmp;
			}
			next.insert(next.end(), all(c));
			next.insert(next.end(), all(b));
			next.insert(next.end(), all(a));
			pre = move(next);
		}

		int sum = 0;
		int ans = 0;
		p--;
		for (P item : pre) {
			int tmp = item.second - item.first + 1;
			P ra = P(1ll << 60, 1ll << 60);
			if (sum + tmp <= p) {
				//skip
			} else if (q <= sum) {
				//skip
			} else if (p <= sum && sum + tmp <= q) {
				ra = item;
			} else if (sum < p && q < sum + tmp) {
				int l = item.first + (p - sum);
				int r = l + (q - p);
				ra = P(l, r);
			} else if (sum < p && p < sum + tmp) {
				int l = item.first + (p - sum);
				int r = item.second;
				ra = P(l, r);
			} else if (sum < q && q < sum + tmp) {
				ra = P(item.first, item.first + (q - sum) - 1);
			}

			ans += max(0ll, min(r, ra.second) - ra.first + 1ll);
			sum += tmp;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3656
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_A
// Segments/Lines - Parallel/Orthogonal

#define SUBMIT

#include <utility>
#include <algorithm>
#include <iostream>
#include <vector>
#include <sstream>
#include <cmath>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const double eps = 1e-10;

bool almost_equals(double a, double b) { return std::abs(a - b) < eps; }

class point2d {
public:
    point2d() : point2d(0.0, 0.0) {}

    point2d(double x, double y) : x_(x), y_(y) {}

    point2d operator+(const point2d& rhs) const { return {x_ + rhs.x_, y_ + rhs.y_}; }

    point2d operator-(const point2d& rhs) const { return {x_ - rhs.x_, y_ - rhs.y_}; }

    point2d operator*(double rhs) const { return {x_ * rhs, y_ * rhs}; }

    point2d operator/(double rhs) const { return {x_ / rhs, y_ / rhs}; }

    bool operator==(const point2d& rhs) const { return almost_equals(x_, rhs.x_) && almost_equals(y_, rhs.y_); }

    double l2_norm() const { std::sqrt(squared_l2_norm()); }

    double squared_l2_norm() const { return x_ * x_ + y_ * y_; }

    double x() const noexcept { return x_; }

    double y() const noexcept { return y_; }

    friend double dot(const point2d& lhs, const point2d& rhs);

    friend double cross(const point2d& lhs, const point2d& rhs);

private:
    double x_;
    double y_;

private:
};

double dot(const point2d& lhs, const point2d& rhs) {
    return lhs.x_ * rhs.x_ + lhs.y_ * rhs.y_;
}

double cross(const point2d& lhs, const point2d& rhs) {
    return lhs.x_ * rhs.y_ - lhs.y_ * rhs.x_;
}

bool is_orthogonal(const point2d& lhs, const point2d& rhs) {
    return almost_equals(dot(lhs, rhs), 0.0);
}

bool is_parallel(const point2d& lhs, const point2d& rhs) {
    return almost_equals(cross(lhs, rhs), 0.0);
}


int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    string program_input_str = R"(3
0 0 3 0 0 2 3 2
0 0 3 0 1 1 1 4
0 0 3 0 1 1 2 2
)";
    stringstream stream(program_input_str);
#endif
    int q;
    stream >> q;
    double x0, y0, x1, y1, x2, y2, x3, y3;
    for (int i = 0; i < q; ++i) {
        stream >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        point2d p0(x0, y0), p1(x1, y1), p2(x2, y2), p3(x3, y3);
        point2d s1 = p0 - p1, s2 = p2 - p3;
        if (is_parallel(s1, s2)) cout << 2 << endl;
        else if (is_orthogonal(s1, s2)) cout << 1 << endl;
        else cout << 0 << endl;
    }

    return 0;
}


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

int main(void)
{
    int a=0,b=0,c=0,d=0;
    cin >> a >> b >> c >> d;

    if(d<=a){
      cout << 0 << endl;
    }else if(d>=a && d<=b){
      if(c<=a){cout << d-a << endl;}
      else{cout << d-c << endl;}
    }else{
      if(c<=a){cout << b-a << endl;}
      else if(c<=b){cout << b-c << endl;}//ここ気づけなかった
      else{cout << 0 << endl;}
    }

    return 0;
}


Measured memory_bytes: 256
// Aizu Vol-1 0105: Book Index 
// 2017.8.4

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

char *gets(char *);
char buf[110], *p;

int getInt(void)
{
	int n = 0;
	while (isspace(*p)) p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	return n;
}

void getStr(char *w)
{
	while (isspace(*p)) p++;
	while (isalnum(*p)) *w++ = *p++;
	*w = 0;
}

typedef struct { char w[32]; char n; } T;
T tbl[105];
int end;
char no[105][1005];
int min[105], max[105];

int where(char *w)
{
	int i;
	T *t;

	for (i = 0, t = tbl; i < end; i++, t++) {
		if (!strcmp(t->w, w)) return t->n;
	}
	strcpy(t->w, w), t->n = end;
	return end++;
}

int main()
{
	int i, j, k, f;
	char w[35];
	T tmp, *t, *s;

	end = 0;
	while (gets(p = buf) != NULL) {
		getStr(w); i = where(w), j = getInt();
		if (!min[i] || j < min[i]) min[i] = j;
		if (j > max[i]) max[i] = j;
		no[i][j] = 1;
	}
	for (i = 0; i < end; i++) {
		t = tbl + i;
		for (j = i + 1, s = t+1; j < end; j++, s++) {
			if (strcmp(t->w, s->w) > 0) t = s;
		}
		if (t != (s = tbl + i)) {
			memcpy(&tmp, t, sizeof(T));
			memcpy(t, s, sizeof(T));
			memcpy(s, &tmp, sizeof(T));
		}
	}
	for (i = 0, t = tbl; i < end; i++, t++) {
		puts(t->w), k = t->n;
		for (j = min[k], f = 1; j <= max[k]; j++) {
			if (no[k][j]) {
				if (f) f = 0;
				else putchar(' ');
				printf("%d", j);
			}
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 596
n = int(input())
s = [int(input()) for _ in range(n)]

s.sort()
ac = sum(s)
ans = 0
if ac % 10 != 0:
    ans = ac
else:
    for i in range(n):
        tmp = ac - s[i]
        if tmp % 10 != 0:
            ans = tmp
            break
print(ans)

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

int main(){
    int n; cin >> n;
    int A[n][n];
    
    //初期化
    for (int i=0;i<n;i++){
        for(int j =0;j<n;j++){
            A[i][j] =0;
        }
    }
    
    for(int i = 0;i<n;i++){
        int num,ver;
        cin >> num >> ver;
        for (int j = 0;j< ver;j++){
            int u; cin >> u;
            A[num-1][u-1] =1;
        }
    }
     for (int i=0;i<n;i++){
        for(int j =0;j<n;j++){
            cout << A[i][j]  ;
            if (j != n-1) cout << " ";
            
        }cout << endl;
    }
}


Measured memory_bytes: 3132
MOD=10**9+7
N=int(input())
S=[list(input()) for i in range(2)]

l=[]
i=0
while(i<N):
    if S[0][i]==S[1][i]:
        l.append(1)
        i+=1
    else:
        l.append(2)
        i+=2
n=len(l)
dp=[0]*n
dp[0]=3 if l[0]==1 else 6
for i in range(1,n):
    if l[i-1]==1 and l[i]==1:
        dp[i]=dp[i-1]*2%MOD
    elif l[i-1]==1 and l[i]==2:
        dp[i]=dp[i-1]*2%MOD
    elif l[i-1]==2 and l[i]==1:
        dp[i]=dp[i-1]
    else:
        dp[i]=dp[i-1]*3%MOD
print(dp[n-1])

Measured memory_bytes: 38256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 5e3 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	map<char, int> mc;
	int n;
	cin >> n;
	for (int i = 'a'; i <= 'z'; i++) mc[i] = INF;
	while (n--)
	{
		string str;
		cin >> str;
		map<char, int> mc2;
		for (auto& c : str) mc2[c]++;
		for (int i = 'a'; i <= 'z'; i++) mc[i] = min(mc[i], mc2[i]);
	}
	for (int i = 'a'; i <= 'z'; i++)
	{
		while (mc[i]--)
			putchar(i);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{   int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    a[0]=0;
    a[n+1]=0;
    int cos = 0;
    for(int i=1;i<=n+1;i++)
    {
        cos += abs(a[i-1] - a[i]);
    }
    for(int i=1;i<=n;i++)
    {
        int cnt = cos;
        cnt = cnt - abs(a[i]-a[i-1]) - abs(a[i]-a[i+1]) + abs(a[i-1] -a[i+1]);
        cout<<cnt<<endl;
    }

    return 0;
}


Measured memory_bytes: 1664
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main() {
	int x, y, z,xx,yy;
	int ans;
	scanf("%d %d %d %d %d", &x, &y, &xx, &yy, &z);
	ans = (60 * xx) + yy - (60 * x) - y - z;
	printf("%d\n", ans);


	return 0;
}


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

int digs(int n){
	int cnt = 0;
	while(n > 0){
		cnt++;
		n /= 10;
	}
	
	return cnt;
}

void ans(int n){
	
	int ret = 1000;
	
	for(int x=1;x*x<=n;x++){
		if(n % x == 0){
			int fi = x;
			int se = n / x;
			
			int check = max(digs(fi) , digs(se));
			ret = min(ret , check);
		}
	}
	
	cout << ret;
	
}

int32_t main() {
	
	int n;	cin >> n;
	
	ans(n);
	
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int t[10000],size,sum;
char ch;
int main(){
  while(cin>>t[0]&&t[0]!=0){
    size=1;
    while(1){
      scanf("%c",&ch);
      if(ch=='\n')break;
      cin>>t[size++];
    }
    sort(t,t+size);
    sum=0;
    for(int i=size-1;i>=0;i--){
      if(t[i]!=1)sum+=min(t[i],10);
      else{
	if(sum+11+i<=21)sum+=11;
	else sum++;
      }
    }
    cout<<(sum<=21?sum:0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
import java.util.* ;
class Main {
  public static void main(String[] args) {
    
    Scanner scan = new Scanner(System.in);
	int A = scan.nextInt();
    String s = Integer.toString(A);
    String s1 = s.substring(0,3);
    String s2 = s.substring(1,4);
    String[] s3  = {s1,s2};
    char ch[] = s.toCharArray();
    ArrayList<Character> a = new ArrayList<>();
    for(int i = 0 ; i  < 2 ; i++){
     	for(int j = 0 ; j < 3 ; j++){
           if(!a.contains(s3[i].toCharArray()[j])){
        	a.add(s3[i].toCharArray()[j]);
      		}
        }
      if(a.size()<= 1){
      	System.out.println("Yes");
        break ;
       }
      a.removeAll(a);
    }
    if(a.size()== 0 ){
      System.out.println("No");
    }
    
    
  }
}


Measured memory_bytes: 22740
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C, D = MAP()

CD_lcm = (C * D)//gcd(C, D)

E = B - (B//C + B//D - B//(CD_lcm))
F = A - (A//C + A//D - A//(CD_lcm))

ans = E - F

if A % C != 0 and A % D != 0:
    ans += 1

print(ans)


Measured memory_bytes: 10044
line = readlines
len = line.length
i = 0

while i < len
    line[i] = line[i].chomp
    i += 1
end

S = line[0]
T = line[1]

ls = S.length
lt = T.length

max_match = 0
for i in 1..(ls-lt+1) do
  match = 0
  for j in 1..lt do
    if S[i+j-2] == T[j-1] then
      match += 1
    end
  end
  if match > max_match then
    max_match = match
  end
end
puts lt - max_match

Measured memory_bytes: 14356
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep_start(a,i,n) for(ll i=a;i<=n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define rev1(i,n) for(ll i=n;i>0;i--)
#define sz(a) int((a).size())
#define all(c) c.begin(),c.end()
#define tr(c,i) for(typeof(c).begin() i+=c.begin; i!=c.end(); i++)
#define present(c,x) (c.find(x)!=c.end())
#define cpresent(c,x) (find(all(c),x)!=c.end())
#define pb push_back
#define F first
#define S second
#define INF LONG_MAX
#define mod 1000000007
#define print1(a) cout<<a<<"\n";
#define print2(a,b) cout<<a<<" "<<b<<"\n";
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define mt make_tuple
#define eb emplace_back

typedef long long int ll;
typedef vector<ll> vi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef tuple<int,int,int> State;

void solve(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if( (c-1)/b<=(a-1)/d ) cout<<"Yes";
    else cout<<"No";
}

signed main() {
    // your code goes here
    IOS
    ll t=1;
    //cin>>t;
    rep1(i,t){
        solve(); 
    }
    return 0;
}


Measured memory_bytes: 3620
N = int(input())
XYS = [list(map(int, input().split())) for _ in range(N)]
s = 0
def perm(ns):
    acc = []
    def fill(ms, remains):
        if remains:
            for m in remains:
                fill(ms + [m], [x for x in remains if x != m])
        else:
            acc.append(ms)
    fill([], ns)
    return acc

s = 0
for indexes in perm(list(range(N))):
    xys = [XYS[i] for i in indexes]
    x0, y0 = xys[0]
    for x1, y1 in xys:
        s += ((x0 - x1)**2 + (y0 - y1)**2) ** 0.5
        x0 = x1
        y0 = y1

nf = 1
for i in range(1, N+1):
    nf *= i
ans = s / nf

print(ans)

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

int main() {
  int64_t a[4];
  scanf("%lld %lld %lld %lld", a + 0, a + 1, a + 2, a + 3);

  int64_t best = a[0] * a[2];
  for (int i = 0; i < 2; ++i) {
    for (int j = 2; j < 4; ++j) {
      if (i == j) continue;
      best = std::max(best, a[i] * a[j]);
    }
  }
  printf("%lld\n", best);
}


Measured memory_bytes: 3824
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    while n >= 0:
        if n%4 == 0:
            print('Yes')
            exit()
        else:
            n -= 7
    print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;
#define MAX_N 100001



int main()
{
	int N,K;
	cin>>N>>K;
	vector<int> p(N);
	rep(i,N){
		cin>>p[i];
	}
	sort(p.begin(),p.end());
	ll ans = 0;
	rep(i,K){
		ans += p[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3196
#include<stdio.h>
#include<math.h>

int main(){
    double x_1,y_1,x_2,y_2;
    double len;
    scanf("%lf %lf %lf %lf",&x_1,&y_1,&x_2,&y_2);
    len=(x_2-x_1)*(x_2-x_1)+(y_2-y_1)*(y_2-y_1);
    printf("%f\n",sqrt(len));
    return 0;
}


Measured memory_bytes: 2708
while true
    h = gets.to_i
    break if h == 0
    arr = []
    h.times{arr << gets.chomp.split.map(&:to_i)}
    arr = arr.transpose.map{|ar| ar.reverse}
    score = 0
    while true
        change = false
        h.times{|i|
            0.upto(2){|j|
                if arr[j][i]
                    prev, add = arr[j][i], 1
                    while j + add < 5
                        break if arr[j + add][i].nil?
                        break if prev != arr[j + add][i]
                        add += 1
                    end
                    if add >= 3
                        score += prev * add if add >= 3
                        add.times{|k| arr[j + k][i] = nil}
                        change = true
                    end
                end
            }
        }
        break if change == false
        arr.map!{|ar| ar.compact}
    end
    puts score
end



Measured memory_bytes: 7112
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int c=1;
    for(int i = 0; i < n; i++){
        if(c*2<c+k)
            c*=2;
        else
            c+=k;
    }
    cout<<c;
}

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

int main()
{
	complex<double> arg,ptr;
	complex<double> a90(0.0, 1.0);

	int n;
	while(cin >> n, n!=-1)
	{
		ptr = complex<double>(1.0, 0.0);
		for(int i=1; i<n; i++)
		{
			arg  = ptr*a90;
			ptr += arg/abs(arg);
		}
		cout << ptr.real() << endl << ptr.imag() << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;

void solve()
{
    int n, r;
    cin >> n, r = n % 10;

    if(r == 3)
        cout<<"bon"<<endl;
    else if(r == 2 || r == 4 || r == 5 || r == 7 || r == 9)
        cout<<"hon"<<endl;
    else
        cout<<"pon"<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 3608
import math
import sys
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    if n % 2 == 1:
        print(0)
    else:
        n = n // 2
        num = 0
        for i in range(1, 100):
            num += n // (5 ** i)
        print(num)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
// URL: https://atcoder.jp/contests/abc133/tasks/abc133_a

import std.algorithm, std.container, std.math, std.range, std.typecons, std.string;

version(unittest) {} else
void main()
{
  int n, a, b; io.getV(n, a, b);
  io.put(min(n*a, b));
}

auto io = IO();

struct IO
{
  import std.algorithm, std.conv, std.format, std.range, std.stdio, std.traits;

  dchar[] buf;
  auto sp = (new dchar[](0)).splitter;
  int precision = 10;
  string delimiter = " ";

  void nextLine()
  {
    stdin.readln(buf);
    sp = buf.splitter;
  }

  auto get(T)(ref T v)
  {
    if (sp.empty) nextLine();
    v = sp.front.to!T;
    sp.popFront();
  }

  auto getV(T...)(ref T v)
  {
    foreach (ref w; v) get(w);
  }

  auto getA(T)(size_t n, ref T v)
  {
    v = new T(n);
    foreach (ref w; v) get(w);
  }

  auto getC(T...)(size_t n, ref T v)
  {
    foreach (ref w; v)
      w = new typeof(w)(n);
    foreach (i; 0..n)
      foreach (ref w; v) get(w[i]);
  }

  auto getM(T)(size_t r, size_t c, T v)
  {
    v = new T(r, c);
    foreach (ref w; v) getA(c, w);
  }

  auto putA(T)(T v)
  {
    static if (isInputRange!T && hasLength!T && !isSomeString!T) {
      foreach (i, w; v) {
	putA(w);
	if (i < v.length - 1) write(delimiter);
      }
    } else if (isFloatingPoint!T) {
      writef(format("%%.%df", precision), v);
    } else {
      write(v);
    }
  }

  auto put(T...)(T v)
  {
    foreach (i, w; v) {
      putA(w);
      if (i < v.length - 1) write(delimiter);
    }
    writeln;
  }

  auto putB(S, T)(bool c, S t, T f)
  {
    if (c)
      put(t);
    else
      put(f);
  }

  auto dbg(T...)(T v)
  {
    stderr.writeln(v);
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long int n;
	cin>>n;
	long int i,j,a[n],t=0,x=1,s=0;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}

	for(j=0;j<n;j++)
	{	
			if(x==a[j])
			{
				x++;
			}
			else
			{
				s++;
			}
			
	}
	if(x==1)
	{
		cout<<-1<<endl;
		return 0;
	}
	cout<<s<<endl;
}

Measured memory_bytes: 5148
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int n,k,h[200001];
bool cmp(int a,int b)
{
	return a>b;
}
long long ans=0;
int main()
{
	FAST_IO::read(n);
	FAST_IO::read(k);
	for(int i=1;i<=n;i++)
	{
		FAST_IO::read(h[i]);
	}
	sort(h+1,h+1+n,cmp);
	for(int i=1+k;i<=n;i++)
	{
		ans+=h[i];
	}
	cout<<ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define mc map<char, int>
#define ms map<string, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
#define mod 1000000007LL
//#define mod 998244353 
using namespace std;
int power(int x, int y) ;
int gcd(int a, int b) ;
#define pi 3.141592653589

signed main(){
    quickie
    int a, b, c, d ;
    cin >> a >> b >> c >> d ;
    if(d <= a) {
        cout << d << "\n" ;
    }
    else if(d <= (a+b)) {
        cout << a << "\n" ;
    }
    else {
        cout << a-(d-a-b) << "\n" ;
    }
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}

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

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

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int score = 0;
  rep(i,n-1) {
    if (s[i] == s[i+1]) score++;
  }
  int ans = min(score+2*k, n-1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
from collections import deque

s=list(input())
s=deque(s)
q=int(input())

re=False
for i in range(1,q+1):
    q_i=input().split()
    if q_i[0]=="1":
        re= not re
    else:
        if q_i[1]=="1" and re==False:
            s.appendleft(q_i[2])
        elif q_i[1]=="2" and re==True:
            s.appendleft(q_i[2])
        else:
            s.append(q_i[2])

s=list(s)

if re==True:
    s=s[::-1]

s="".join(s)
print(s)

Measured memory_bytes: 10084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static readonly Dictionary<string, string> dic1 = new Dictionary<string, string>()
        {
            { "A" , "00000" }, { "B" , "00001" }, { "C" , "00010" }, { "D" , "00011" },
            { "E" , "00100" }, { "F" , "00101" }, { "G" , "00110" }, { "H" , "00111" },
            { "I" , "01000" }, { "J" , "01001" }, { "K" , "01010" }, { "L" , "01011" },
            { "M" , "01100" }, { "N" , "01101" }, { "O" , "01110" }, { "P" , "01111" },
            { "Q" , "10000" }, { "R" , "10001" }, { "S" , "10010" }, { "T" , "10011" },
            { "U" , "10100" }, { "V" , "10101" }, { "W" , "10110" }, { "X" , "10111" },
            { "Y" , "11000" }, { "Z" , "11001" }, { " " , "11010" }, { "." , "11011" },
            { "," , "11100" }, { "-" , "11101" }, { "'" , "11110" }, { "?" , "11111" }
        };

        static readonly Dictionary<string, string> dic2 = new Dictionary<string, string>()
        {
            { "101"      , " " }, { "000000"   , "'" }, { "000011"   , "," },
            { "10010001" , "-" }, { "010001"   , "." }, { "000001"   , "?" },
            { "100101"   , "A" }, { "10011010" , "B" }, { "0101"     , "C" },
            { "0001"     , "D" }, { "110"      , "E" }, { "01001"    , "F" },
            { "10011011" , "G" }, { "010000"   , "H" }, { "0111"     , "I" },
            { "10011000" , "J" }, { "0110"     , "K" }, { "00100"    , "L" },
            { "10011001" , "M" }, { "10011110" , "N" }, { "00101"    , "O" },
            { "111"      , "P" }, { "10011111" , "Q" }, { "1000"     , "R" },
            { "00110"    , "S" }, { "00111"    , "T" }, { "10011100" , "U" },
            { "10011101" , "V" }, { "000010"   , "W" }, { "10010010" , "X" },
            { "10010011" , "Y" }, { "10010000" , "Z" }
        };

        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while ((input = Console.ReadLine()) != null)
            {
                string nums = "";

                for (int i = 0; i < input.Length; i++)
                {
                    nums += dic1[input[i].ToString()];
                }

                string res = "";
                bool flg = true;

                while (flg)
                {
                    flg = false;

                    for (int i = 3; i <= 8; i++)
                    {
                        if (nums.Length < i) break;

                        string sub = nums.Substring(0, i);

                        if (dic2.ContainsKey(sub))
                        {
                            res += dic2[sub];
                            nums = nums.Substring(i);
                            flg = true;
                            break;
                        }
                    }
                }
                sb.AppendLine(res);
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9608
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){
  int data1, data2;
  int i;
  scanf("%d %d", &data1, &data2);

  if( (data1*data2)%2 == 0 ) printf("Even\n");
  else printf("Odd\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    int ans=n%1000;
    if(ans) ans=1000-ans;
    cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
typedef long long  ll;
typedef long double ld;
typedef pair<ll ,ll > pll;
typedef pair<int ,int > pii;
const ld pi=3.14159265359;
const int maxn=2e5+7;
const int mod=1e9+7;
const ll INF=9223372036854775807;
const int inf=2e9+7; 
/*Almost copy pasted part :)*/
int a[maxn];
int dp[maxn][2];

int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<n;i++){
		a[i+1]=(s[i]!='.');
	}	
	for(int i=1;i<=n;i++){
		if(a[i]==0){
			dp[i][0]=dp[i-1][0];
			dp[i][1]=min(dp[i-1][0],dp[i-1][1])+1;
		}
		else{
			dp[i][1]=min(dp[i-1][1],dp[i-1][0]);
			dp[i][0]=dp[i-1][0]+1;
		}
	}
	cout<<min(dp[n][0],dp[n][1])<<endl;
}

Measured memory_bytes: 2948
#include<bits/stdc++.h>
using namespace std;
#define nl '\n' 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pii pair <int,int>
ll m=1000000007;

int main()
{
	fast;
	unordered_map<ll,ll>m;
	ll sum=0;
	int n;cin>>n;
	while(n--)
	{
		ll x;cin>>x;
		m[x]++;
		sum+=x;
	}
	int qq;cin>>qq;
	while(qq--)
	{
		ll b,c;cin>>b>>c;
		ll count=m[b];
		m[b]=0;
		m[c]+=count;
		sum-=count*b;
		sum+=count*c;
		cout<<sum<<nl;
	}
}

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

//省略形
#define rep(i,n) for(auto i=0; i<n ; ++i)
#define REP(i,a,b) for(auto i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//よく使う定数
const int INF = 1e9;
const int MOD = 1e9+7;
//逆元
const int INV = 1e9+5;

//UnionFindTree
struct union_find{
  vector<int> data;
  union_find(int size) : data(size , -1) { }

  void merge(int x , int y){
    x = root(x); y = root(y);
    if(x == y) return;
    if(data[y] < data[x]) swap(x , y);
    data[x] += data[y];
    data[y] = x;
    return; 
  }

  bool same(int x , int y){
    x = root(x) , y = root(y);
    return x == y;
  }

  int root(int x){
    return data[x] < 0 ? x : (data[x] = root(data[x]));
  }

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

//プロトタイプ宣言
void faster(void);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);
template <class T>
T modpow(T , T , T);

//メモ
//最大公約数:__gcd　|　最小公倍数:__lcm


int main(){
  faster();
  string s;
  cin >> s;
  int q , cond = 1;
  //0で反転状態、1で未反転状態
  cin >> q;
  int t,f;
  string tmp,forward,back;
  rep(i,q){
    cin >> t;
    if(t==1){
      if(cond) cond = 0;
      else cond = 1;
    }
    else{
      cin >> f >> tmp;
      if(f==1){
        if(cond) forward = tmp + forward;
        else back = back + tmp;
      }
      else{
        if(cond) back = back + tmp;
        else forward = tmp + forward;
      }
    }
  }
  s = forward + s + back;
  if(cond) cout << s;
  else{
    reverse(all(s));
    cout << s;
  }
}


























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//繰り返し自乗法
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//繰り返し自乗法(剰余)
template <class T>
T modpow(T x , T y , T mod){
  if(y == 0) return 1;
  if(y%2 == 1){
    ll temp = modpow(x,y-1,mod);
    return temp*x%mod;
  }
  else{
    ll temp = pow_mod(x,y/2,mod);
    return temp*temp%mod;
  }
}



Measured memory_bytes: 1308
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws java.lang.Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int input = Integer.parseInt(br.readLine());
        System.out.println(input * input * input);

    }
}

Measured memory_bytes: 22864
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
count=0
dp=[0]*n
for i in range(n):
    if i<k:
        if t[i]=='r':
            count+=p
        elif t[i]=='s':
            count+=r
        else:
            count+=s
        dp[i]=1
        continue
    if t[i]==t[i-k] and dp[i-k]==1:
        continue
    if t[i]=='r':
        count+=p
    elif t[i]=='s':
        count+=r
    else:
        count+=s
    dp[i]=1
print(count)

Measured memory_bytes: 42224
w=input()
if w=="RRR":
    print(3)
elif w=="SRR":
    print(2)
elif w=="RRS":
    print(2)
elif w=="RSR":
    print(1)
elif w=="RSS":
    print(1)
elif w=="SRS":
    print(1)
elif w=="SSR":
    print(1)
else :
    print(0)

Measured memory_bytes: 8876
import Data.List

main :: IO ()
main = do
  _ <- getInt
  xs <- getInts
  print $ sum $ map f xs
  where
    f x
      |    even x = 1 + f (x `div` 2)
      | otherwise = 0

getInt :: IO Int
getInt = read <$> getLine

getInts :: IO [Int]
getInts = map read . words <$> getLine


Measured memory_bytes: 7548
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC optimize("Ofast")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <random>
#include <cassert>
#include <complex>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef complex <LD> cld;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

template <typename T1, typename T2>
T2 sum_mod(T1 x, T2 MOD) {
	if (x < 0)
		x += MOD;
	if (x >= MOD)
		x -= MOD;
	return x;
}

template <typename T1, typename T2>
T2 mul_mod(T1 x, T2 MOD) {
	if (x < 0)
		return (abs(x) % MOD == 0 ? 0 : MOD - abs(x) % MOD);
	return x % MOD;
}

template <typename T>
bool uax(T& a, const T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T>
bool uin(T& a, const T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 gen_rand;

const int N = (int)2e5 + 7;
const int LOG = 20;
const int N_ = (int)8e2 + 7;
const int MAXN = (int)2e6 + 7;
const int MOD = (int)1e9 + 7;
const int INF = (int)2e9 + 7;
const int CONST = 300;
const LL LINF = (i64)2e15;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1e-6;

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

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
	gen_rand.seed(0);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	gen_rand.seed(time(0));
#endif

	char c; cin >> c;
	cout << char(c + 1);
		
#ifdef _DEBUG 
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
int main(){
    double n,k;
    cin>>n>>k;
    double w=0;
    for(int i=1;i<=n;i++){
        double a=1.0/n;
        int x=i;
        while(x<k){
            x*=2;
            a/=2;
        }
        w+=a;
    }
    cout<<fixed<<setprecision(12)<<w<<endl;
    return 0;
}

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


int main()
{
    ll n,i,j;
    cin>>n;
    vector< ll >a(n+1,0);
    //ll a[n+1]={};
    for(i=1;i<=n;i++)
    {
        a[i]++;
        for(j=i*2;j<=n;j+=i)
        {
            a[j]++;
        }
    }
    ll ans=0;
    for(i=1;i<=n;i++)
    {
        ans=ans+i*a[i];
       // cout<<a[i]<<" ";
    }
    cout<<ans;
}

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

int main(){
    int A,B,K,count,i;
    cin >> A >> B >> K;
    count = 0;
    i=200;
    while(count<K){
        i--;
        if(A%i==0&&B%i==0){
            count++;
        }
    }
    cout << i << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

#define MAX 3000
#define mod 1000000007

ll add(ll a,ll b)
{
	return (mod+(a+b)%mod)%mod;
}


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

	ll n;
	cin>>n;
	
	ll arr[n];
	ll val = 0;
	for(ll i=0;i<n;i++){
		cin>>arr[i];
		val = (val^arr[i]);
	}
	
	for(ll i=0;i<n;i++)
	{
		cout<<(val^arr[i])<<" ";
	}
	
	cout<<endl;
	
	
	
}















Measured memory_bytes: 5128