akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var ab = ReadSplitInt();
            var n = DateTime.Parse($"2018-01-01 {ab[0]}:00:00");
            Println(n.AddHours(ab[1]).Hour);
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    long long N,A,B;
    cin >> N >> A >> B;
    long long res;
    if(A>B){
        res = 0;
    }else{
        if(N == 1){
            if(A == B){
                res = 1;
            }else{
                res = 0;
            }
        }else{
            res = (B - A) * (N - 2) + 1;
        }
    }

    cout << res << endl;

    return 0;
} 

Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数

H = iin()
W = iin()
N = iin()

loop_cnt1 = min(H,W)
loop_cnt2 = max(H,W)

ans = 0
cnt = 0
for i in range(loop_cnt1):
    cnt += 1  
    ans += loop_cnt2
    if ans >= N:
        break
if ans >= N:
    print(cnt)

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL a;
  cin >> a;
  cout << 3 * a * a << endl;
}


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

#define ll long long
#define rep(i, n) for(ll i = 1; i*i <= n; i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
   ll N;
   cin >> N;
   ll mi = N;
   rep(i,N){
       if(N%i == 0){
       ll j = i; 
       ll digit1 = 0;
       ll digit2 = 0;
       ll k = i;
       while(j!=0){
           j /= 10;
           digit1++;
       }
       ll q = N/k;
       while(q!=0){
           q /= 10;
           digit2++; 
       }
       //cout << digit1 << digit2<<endl;
       ll digit = max(digit1,digit2);
       //cout << digit <<endl;
       mi = min(digit,mi);
       }
       //else cout << "失敗"<<endl;
   }
    cout << mi <<endl;
}


Measured memory_bytes: 384
package main

import "fmt"

func main() {
    var d, n int
    fmt.Scanln(&d, &n)
    if d == 0 {
        if n == 100 {
            fmt.Printf("%d\n", n * 1 + 1)
        } else {
            fmt.Printf("%d\n", n * 1)
        }
    } else if d == 1 {
        if n == 100 {
            fmt.Printf("%d\n", n * 100 + 100)
        } else {
            fmt.Printf("%d\n", n * 100)
        }
    } else if d == 2 {
        if n == 100 {
            fmt.Printf("%d\n", n * 10000 + 10000)
        } else {
            fmt.Printf("%d\n", n * 10000)
        }
    } else {
        fmt.Printf("0\n")
    }
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
    string S;
    cin>>S;
    if(S=="SUN")
    cout<<"7";
    else if(S=="SAT")
    cout<<"1";
	else if(S=="FRI")
    cout<<"2";
    else if(S=="THU")
    cout<<"3";
    else if(S=="WED")
    cout<<"4";
	else if(S=="TUE")
    cout<<"5";
    else
    cout<<"6";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    
    if(n <= k){
        cout << n * x << endl;
    }else{
        cout << k * x + (n - k) * y << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=acos(-1);
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,m,a,b,g[10][10]={},f,ans=0;
  cin >> n >> m;
  int p[n]={};
  for(int i=0; i<n; i++) {
    p[i]=i;
  }
  for(int i=0; i<m; i++) {
    cin >> a >> b;
    a--,b--;
    g[a][b]=g[b][a]=1;
  }
  do{
    if(p[0]==0) {
      f=1;
      for(int i=0; i<n-1; i++) {
        if(!g[p[i]][p[i+1]]) {
          f=0;
        }
      }
      ans+=f;
    }
  }while(next_permutation(p,p+n));
  cout << ans << endl;
}



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


int main() {
  string s;
  cin>>s;
  while(true){
    s.erase(s.end()-1);
    if(s.size()%2==0){
      string t = s.substr(0,s.size()/2);
      string n = s.substr(s.size()/2,s.size()/2);
      if(t==n){
        cout << s.size();
        return 0;
      }
    }
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int N = 305;
const int MOD = 1e9 + 7;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

inline void Inc(int &x, int y) {
	x += y; if (x >= MOD) x -= MOD;
}

int n, nn, a[N<<1], vis[N<<1], type[N<<1];
int t1, t2, dp[2][N][N];

void init() {
	read(n); nn = n<<1;
	for (int i=1;i<=nn;++i) {
		read(a[i]);
	}
	for (int i=1;i<=nn;i+=2) {
		if (a[i] == -1 && a[i+1] == -1) {
			++t1;
		} else if (a[i] > 0 && a[i+1] > 0) {
			vis[a[i]] = vis[a[i+1]] = 1;
		} else {
			++t2;
			if (a[i] > 0) type[a[i]] = 1;
			else type[a[i+1]] = 1;
		}
	}
}

void solve() {
	dp[0][0][0] = 1;
	int pre = 0, cur = 1;
	for (int i=nn;i>=1;--i) {
		if (vis[i]) continue;
		mset(dp[cur], 0);
		for (int j=0;j<=t1+t2;++j) {
			for (int k=0;k<=t1+t2;++k) {
				if (type[i]) {
					Inc(dp[cur][j][k+1], dp[pre][j][k]);
					if (j) Inc(dp[cur][j-1][k], dp[pre][j][k]);
				} else {
					Inc(dp[cur][j+1][k], dp[pre][j][k]);
					if (j) Inc(dp[cur][j-1][k], dp[pre][j][k]);
					if (k) Inc(dp[cur][j][k-1], 1LL * dp[pre][j][k] * k % MOD);
				}
			}
		}
		pre = cur; cur ^= 1;
	}
	int ans = dp[pre][0][0];
	for (int i=1;i<=t1;++i) {
		ans = 1LL * ans * i % MOD;
	}
	printf("%d\n", ans);
}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll h, w, m; cin >> h >> w >> m;
    vector<ll> hbomb(h, 0);
    vector<ll> wbomb(w, 0);
    map<pair<ll, ll>, ll> mp;
    for (int i = 0; i < m; ++i) {
        ll hi, wi; cin >> hi >> wi;
        hbomb[hi - 1] += 1;
        wbomb[wi - 1] += 1;
        pair<ll, ll> p = make_pair(hi - 1, wi - 1);
        mp[p] = 1;
    }

    vector<pair<ll, ll> > h_pair(h);
    for (int i = 0; i < h; ++i) {
        h_pair[i] = make_pair(hbomb[i], i);
    }
    sort(h_pair.begin(), h_pair.end());
    
    vector<pair<ll, ll> > w_pair(w);
    for (int i = 0; i < w; ++i) {
        w_pair[i] = make_pair(wbomb[i], i);
    }
    sort(w_pair.begin(), w_pair.end());

    ll ans = 0;
    ll h_start = h_pair[h_pair.size() - 1].first;
    ll w_start = w_pair[w_pair.size() - 1].first;
    ll max_h_count = 0;
    ll max_w_count = 0;
    vector<ll> h_cand;
    vector<ll> w_cand;
    for (int i = h_pair.size() - 1; i >= 0; --i) {
        if (h_pair[i].first != h_start) {
            break;
        }
        max_h_count++;
        h_cand.push_back(h_pair[i].second);
    }
    for (int j = w_pair.size() - 1; j >= 0; j--) {
        if (w_pair[j].first != w_start) {
            break;
        }
        max_w_count++;
        w_cand.push_back(w_pair[j].second);
    }

    if (max_h_count * max_w_count > m) {
        ans = h_start + w_start;
    }
    else {
        ll cand_max = h_start + w_start - 1;
        for (auto i: h_cand) {
            for (auto j: w_cand) {
                if (mp.count(make_pair(i, j)) == 0) {
                    cand_max = max(cand_max, hbomb[i] + wbomb[j]);
                }
            }
        }
        ans = cand_max;
    }
    cout << ans << endl;
}

Measured memory_bytes: 44396
X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

a = P[:X] + Q[:Y] + R
a.sort(reverse=True)

print(sum(a[:X + Y]))


Measured memory_bytes: 102800
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>

using namespace std;

int main(){
    int a,b;
    cout << fixed << setprecision(10);
    cin >> a >> b;
    cout << a/b << " " << a%b << " " << (double)a/b << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int n=s.size();
    int x,y; cin>>x>>y;
    int cnt=0;
    rep(i,n){
        if (s[i]!='F') break;
        cnt++;
    }
    x -= cnt;
    s = s.substr(cnt);
    n = s.size();
    if (n==0){
        if (x==0 && y==0){
            cout<<"Yes\n";
        }else{
            cout<<"No\n";
        }
        return 0;
    }
    int mode=0;
    vector<vi> t(2);
    cnt=0;
    rep(i,n){
        if (s[i]=='T'){
            if (cnt>0) t[mode].pb(cnt);
            cnt=0;
            mode=1-mode;
        }
        if (s[i]=='F') cnt++;
    }
    if (cnt>0) t[mode].pb(cnt);
    int m = t[0].size();
    int l = t[1].size();
    int LRsum=0, UDsum=0;
    rep(i,m) LRsum+=t[0][i];
    rep(i,l) UDsum+=t[1][i];
    vector<vector<bool> > dp(m+1, vector<bool>(LRsum*2+1,false));
    vector<vector<bool> > dp2(l+1, vector<bool>(UDsum*2+1,false));
    dp[0][LRsum]=true;
    rep(i,m)rep(j,LRsum*2+1){
        if (j>=t[0][i]) dp[i+1][j] = dp[i+1][j] || dp[i][j-t[0][i]];
        if (j+t[0][i]<=LRsum*2) dp[i+1][j] = dp[i+1][j] || dp[i][j+t[0][i]];
    }
    dp2[0][UDsum]=true;
    rep(i,l)rep(j,UDsum*2+1){
        if (j>=t[1][i]) dp2[i+1][j] = dp2[i+1][j] || dp2[i][j-t[1][i]];
        if (j+t[1][i]<=UDsum*2) dp2[i+1][j] = dp2[i+1][j] || dp2[i][j+t[1][i]];
    }
    if (x+LRsum<0||LRsum<x||y+UDsum<0||UDsum<y){
        cout<<"No\n";
        return 0;
    }
    if (dp[m][x+LRsum]&&dp2[l][y+UDsum]){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b ? a:b;}
ll min(ll a, ll b) {return a<b ? a:b;}


ll N, K;
ll a[5050];
ll dp[5050][5050];

ll C(ll id) {
    vector<ll> b;
    ll i, j;
    for(i=0; i<N; i++) {
        if(i==id) continue;
        b.pb(a[i]);
    }
    
    for(i=0; i<=N; i++)
        for(j=0; j<=K; j++)
            dp[i][j]=0;
    
    dp[0][0]=1;
    for(i=0; i<N-1; i++) {
        for(j=0; j<=K; j++) {
            dp[i+1][j]|=dp[i][j];
            
            if(j+b[i]<=K)
                dp[i+1][j+b[i]]|=dp[i][j];
        }
    }
    
    ll f=0;
    for(i=max(0, K-a[id]); i<K; i++)
        if(dp[N-1][i]) f=1;
    
    if(f) return 1;
    else return 0;
    
}

int main(void) {
    cin >> N >> K;
    ll i;
    
    for(i=0; i<N; i++) cin >> a[i];
    sort(a, a+N);
    
    if(C(0)) {
        pt(0);
        return 0;
    }
    
    
    ll l=0, r=N;
    while(l+1<r) {
        ll mid=(l+r)/2;
        if(C(mid)) r=mid;
        else l=mid;
    }
    
    pt(l+1);
    
}







Measured memory_bytes: 199040
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial

def main():
    a, b, c = map(int, input().split())
    ans = max(0, c - a + b)
    print(ans)






if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
N,M = map(int,input().split(' '))
#PY = [list(map(int,input().split(' '))) for i in [0]*M]

l = []
for i in range(M):
	P,Y = map(int,input().split(' '))
	l.append([P,Y,i])

l.sort(key=lambda x:x[1])

num = [1]*N

for s in l:
	s[1] = num[s[0]-1]
	num[s[0]-1]+=1

l.sort(key=lambda x:x[2])

for s,n,_ in l:
	print(str(s).zfill(6)+str(n).zfill(6))



Measured memory_bytes: 25120
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    constexpr i64 mod = 998244353;
    int n;
    std::string s;
    std::cin >> n >> s;

    i64 c = 0, ret = 0;
    std::vector<std::pair<int, i64>> memo;
    for (int i = 0; i < n; i++) {
        c = (c * 2 + (s[i] == '1')) % mod;

        int d = i + 1;
        if (n % d || (n / d) % 2 == 0) continue;

        i64 overlap = 0;
        for (auto &e : memo) if (d % e.first == 0 && (d / e.first) % 2) {
            overlap = (overlap + e.second) % mod;
        }

        int flg = 1;
        for (int i = 0; i < n; i++) {
            if (i / d % 2) {
                if (s[i] == '0' && s[i % d] == '0') {
                    flg = 0;
                    break;
                } else if (s[i] == '1' && s[i % d] == '1') break;
            } else {
                if (s[i] == '0' && s[i % d] == '1') {
                    flg = 0;
                    break;
                } else if (s[i] == '1' && s[i % d] == '0') break;
            }
        }

        i64 count = (c + flg + mod - overlap) % mod;
        memo.emplace_back(d, count);
        ret = (ret + count * d % mod * 2 % mod) % mod;
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    // Here your code !
    char c;
    cin >> c;
    if([&](){
    for( char a : {'a','i','u','e','o'} ) if(a==c) return true;
    return false;
    }()) cout << "vowel" << endl;
    else
    cout << "consonant" << endl;
    
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BOrdinaryNumber solver = new BOrdinaryNumber();
        solver.solve(1, in, out);
        out.close();
    }

    static class BOrdinaryNumber {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n];
            for (int i = 0; i < n; i++) a[i] = in.nextInt();
            int count = 0;
            for (int i = 1; i < n - 1; i++) {
                if (a[i] > a[i - 1] && a[i + 1] > a[i]) count++;
                if (a[i] < a[i - 1] && a[i + 1] < a[i]) count++;
            }
            out.println(count);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
import java.util.*;

class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt(), i;
		HashMap<Integer, Integer> a = new HashMap<Integer, Integer>();
		long sum = 0;
		for (i = 0; i < N; i++) {
			int temp = sc.nextInt();
			sum += temp;
			if (a.containsKey(temp)) {
				a.put(temp, a.get(temp) + 1);
			} else {
				a.put(temp, 1);
			}
		}
		int Q = sc.nextInt();
		for (i = 0; i < Q; i++) {
			int B = sc.nextInt(), C = sc.nextInt();
			if (a.containsKey(B)) {
				sum = sum + (C - B) * (a.get(B));
				if (a.containsKey(C)) {
					a.put(C, a.get(C) + a.get(B));
				} else {
					a.put(C, a.get(B));
				}
				a.put(B, 0);
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 66528
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const long long inf=1LL<<61;
typedef long long LL;
struct sgt{
	LL mn[maxn*2];
	int id(int l,int r){return l+r|l!=r;}

	void build(int l,int r){
		mn[id(l,r)]=inf;
		if(l==r)return ;
		int mid=(l+r)>>1;
		build(l,mid);
		build(mid+1,r);
	}
	LL Q(int l,int r,int l0,int r0){
		if(l0<=l&&r0>=r)
			return mn[id(l,r)];
		int mid=(l+r)>>1;
		LL ans=inf;
		if(l0<=mid)ans=min(ans,Q(l,mid,l0,r0));
		if(r0>mid)ans=min(ans,Q(mid+1,r,l0,r0));
		return ans;
	}
	void C(int l,int r,int ps,LL val){
		if(l==r){
			mn[id(l,r)]=val;
			return ;
		}
		int mid=(l+r)>>1;
		if(ps<=mid)C(l,mid,ps,val);
		else C(mid+1,r,ps,val);
		mn[id(l,r)]=min(mn[id(l,mid)],mn[id(mid+1,r)]);
	}
}T1,T2;
int n;
LL T,E;
LL d[maxn];
LL dp[maxn],d2[maxn];

LL bf(){

	dp[1]=0;
	for(int i=2;i<=n;i++){
		dp[i]=inf;
		for(int j=1;j<=i;j++){
			dp[i]=min(dp[i],dp[j-1]+d[i]-d[j-1]+max(T,2*(d[i]-d[j])));
		}
		printf("dp[%d]=%lld\n",i,dp[i]);
	}


	LL ans=dp[n]+E-d[n];

	return ans;
}

int main(){
	scanf("%d%lld%lld",&n,&E,&T);
	n++;
	d[1]=0;
	for(int i=2;i<=n;i++){
		scanf("%lld",&d[i]);
		d2[i]=d[i]*2;
	}


	//TODO
//	cout<< bf() <<endl;
//	return 0;
	T1.build(1,n);
	T2.build(1,n);


	dp[1]=0;
	T1.C(1,n,1,0);
	T2.C(1,n,1,0);

	for(int i=2;i<=n;i++){

		dp[i]=dp[i-1]+d[i]-d[i-1]+T;


		auto bin=[&](int lef,int rig){
			int l=1,r=rig-1;

			while(l<r){
				int mid=(l+r)>>1;
				if(2*(d[rig]-d[mid])>=T)
					l=mid+1;
				else
					r=mid;
			}

			int ans=0;
			for(int delta=-10;delta<=10;delta++){
				int ps=delta+l;
				if(1<=ps&&ps<rig){
					if(2*(d[rig]-d[ps])>=T){
						ans=ps;
					}else{
						break;
					}
				}
			}

			return ans;
		};
		int ps=bin(1,i);
		/*
		int ps=0;
		for(int j=1;j<i;j++){
			if(2*(d[i]-d[j])>=T){
				ps=j;
			}else{
				break;
			}
		}
*/
//		cerr<<ps<<" "<<bin(1,i)<<endl; 
//		assert(bin(1,i)==ps);

		//assert(ps==bin(1,i));

//		cerr<<"it is "<<i<<" "<<ps<<endl;
		LL res1=inf,res2=inf;

		if(ps>=1)
			res1=T1.Q(1,n,1,ps)+3*d[i];

		if(ps+1<=i-1)
			res2=T2.Q(1,n,ps+1,i-1)+d[i]+T;
//		cerr<<res1<<" "<<res2<<endl;

		dp[i]=min(dp[i],res1);
		dp[i]=min(dp[i],res2);
//		cerr<<"dp = "<<dp[i]<<endl;
		T1.C(1,n,i,dp[i-1]-d[i-1]-2*d[i]);
		T2.C(1,n,i,dp[i-1]-d[i-1]);
	}

	LL ans=dp[n]+E-d[n];

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

Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
class SCC{//cmp(0 - kk-1) is scc's return. Same number is group. The number is no relatoin.
	public:
	int n;
	vvi G,rG,tG;
	vector<bool>used;
	vi vs,cmp;
	SCC(int size){
		n=size;
		G=rG=vvi(n);
		used=vector<bool>(n);
		cmp=vi(n);
		vs=vi(0);
	}
	void add_edge(int s,int t){
		G[s].pb(t);
		rG[t].pb(s);
	}
	void rdfs(int v,int k){
		used[v]=true;
		cmp[v]=k;
		rep(i,rG[v].size())if(!used[rG[v][i]])rdfs(rG[v][i],k);
	}
	void dfs(int v){
		used[v]=true;
		rep(i,G[v].size())if(!used[G[v][i]])dfs(G[v][i]);
		vs.pb(v);
	}
	int scc(){
		rep(i,n)used[i]=false;
		rep(v,n)if(!used[v])dfs(v);
		rep(i,n)used[i]=false;
		int kk=0;
		for(int i=vs.size()-1;i>=0;i--)if(!used[vs[i]])rdfs(vs[i],kk++);
		return kk;  
	}
	void make(int size){
		int N=size;
		tG=vvi(N);
		rep(i,n)rep(j,G[i].size())if(cmp[i]!=cmp[G[i][j]]){
			tG[cmp[i]].pb(cmp[G[i][j]]);
//			tG[cmp[G[i][j]]].pb(cmp[i]);
		}
	}
};
int main(){
	int n;
	while(cin>>n,n){
		vs in(n);
		rep(i,n)cin>>in[i];
		SCC scc(26);
		rep(i,n-1){
			int t=min(in[i].size(),in[i+1].size());
			if(in[i].substr(0,t)==in[i+1].substr(0,t)){
				if(in[i].size()>in[i+1].size()){
					cout<<"no"<<endl;
					goto end;
				}
			}else{
				rep(j,t)if(in[i][j]!=in[i+1][j]){
					scc.add_edge(in[i][j]-'a',in[i+1][j]-'a');
//					cout<<in[i][j]-'a'<<" "<<in[i+1][j]-'a'<<endl;
					break;
				}
			}
		}
		if(scc.scc()==26)cout<<"yes"<<endl;
		else cout<<"no"<<endl;
		end:;
	}
}

Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef long long ll;
typedef pair<int,int> pint;
const ll mod= 1e9+7;
const int inf=1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  int n,k,q;
  cin>>n>>k>>q;
  map<int,int> mp;
  pint a[n];
  int x[n];
  rep(i,n){
    cin>>a[i].first;
    a[i].second=i;
    x[i]=a[i].first;
    }
  sort(a,a+n);
  vector<int> v;
  v.push_back(n);
  int mi=a[q-1].first-a[0].first;
  rep(i,n){
    vector<int> ans;
    v.push_back(a[i].second);
    x[a[i].second]=-1;
    sort(v.begin(),v.end());
    int num=0;
    int pos=-1;
    for(auto e:v){
      num+=max(0,e-pos-k);
      vector<int>res;
      REP(j,pos+1,e)res.push_back(x[j]);
      sort(res.begin(),res.end());
      rep(j,(int)res.size()-k+1)ans.push_back(res[j]);
      pos=e;
      }
    if(num>=q){
      sort(ans.begin(),ans.end());
      mi=min(mi,ans[q-1]-ans[0]);
    }
  }
  cout<<mi<<endl; 
  
  return 0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        #define mod 1000000000000000000
        #define MOD 		1000000007
        #define ll long long
        #define ull unsigned ll
        #define mp 		make_pair
        #define pb 		push_back
        #define forn(i,n) 	for(ll i=0;i<n;i++)
        #define for1(i,n) 	for(ll i=1;i<=n;i++)
        #define forn1(i,n) 	for(int i=1;i<n;i++)
        #define rep(i,x,n)  for(ll i=x;i<=n;i++)
        #define repr(i,x,j) for(ll i=x;i>=j;i--)
        #define vi vector<ll>
        #define mii map<ll,ll>
        #define vii vector<pair<ll,ll>>
        #define vvi vector<vector<ll>>
        #define pii pair<ll,ll>
        #define F first
        #define S second
        #define fill(a,x) memset(a,x,sizeof a);
        #define all(x) x.begin(),x.end()
        #define test ll t;cin>>t;while(t--)
        #define yes cout<<"YES"<<endl
        #define no cout<<"NO"<<endl
        #define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        ll flag[1000];
        #define R return 0
        int main()
        {
            IOS;
           ll a,b,c,d;
           cin>>a>>b>>c>>d;
           vi v;
           v.pb(a*c);
           v.pb(a*d);
           v.pb(b*c);
           v.pb(b*d);
           sort(v.rbegin(),v.rend());
           cout<<v[0]<<endl;

            R;
        }
        
        /// Happy coding ):

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
int rock = 0, sizz = 1, par = 2;

int Point(int R, int S, int P, char opponent, int mine) {
  if (opponent == 'r') {
    if (mine == par) return P;
  } else if (opponent == 's') {
    if (mine == rock) return R;
  } else {
    if (mine == sizz) return S;
  }
  return 0;
}

int ProbS(int R, int S, int P, string T2) {
  int N = T2.size();
  // VEC<VEC<int>> dp = VEC<VEC<int>>(N, VEC<int>(3, 0));
  // dp[0][rock] = Point(R, S, P, T2[0], rock);
  // dp[0][sizz] = Point(R, S, P, T2[0], sizz);
  // dp[0][par] = Point(R, S, P, T2[0], par);

  // REP(i, 1, N) {
  //   int pr = Point(R, S, P, T2[i], rock);
  //   int ps = Point(R, S, P, T2[i], sizz);
  //   int pp = Point(R, S, P, T2[i], par);
  //   dp[i][rock] = max({dp[i - 1][par] + pr, dp[i - 1][sizz] + pr});
  //   dp[i][sizz] = max({dp[i - 1][par] + ps, dp[i - 1][rock] + ps});
  //   dp[i][par] = max({dp[i - 1][rock] + pp, dp[i - 1][sizz] + pp});
  // }

  map<char, char> wins = {{'r', 'p'}, {'s', 'r'}, {'p', 's'}};
  map<char, int> points = {{'r', R}, {'s', S}, {'p', P}};
  char prev = ' ';
  LL sum = 0;
  REP(i, 0, N) {
    char oppo = T2[i];
    char mine = wins[oppo];
    if (mine != prev) {
      sum += points[mine];
      prev = mine;
    } else {
      prev = ' ';
    }
  }
  return sum;

  // return max({dp[N - 1][rock], dp[N - 1][sizz], dp[N - 1][par]});
}

int main() {
  int N, K, R, S, P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  VEC<string> subs(K, "");
  // DUMP("HI");
  REP(i, 0, N) { subs[i % K].push_back(T[i]); }

  // DUMP("HI2");

  LL sum = 0;
  REP(i, 0, K) { sum += ProbS(R, S, P, subs[i]); }
  cout << sum << endl;

  return 0;
}


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

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

    int n;
    cin >> n;
    
    int ans = 0;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        if(s == "E869120"){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>
#include <math.h>
 
void koch(double x1, double y1, double x2, double y2, int n){
  double ax, ay, bx, by, cx, cy;
  if(n != 0){
    ax = (x2 - x1) / 3 + x1;
    ay = (y2 - y1) / 3 + y1;
    bx = 2 * (x2 - x1) / 3 + x1;
    by = 2 * (y2 - y1) / 3 + y1;
    cx = ((bx - ax)* cos(M_PI/3) - (by - ay)* sin(M_PI/3)) + ax;      // ??????????????¢
    cy = ((bx - ax)* sin(M_PI/3) + (by - ay)* cos(M_PI/3)) + ay;
    koch(x1, y1, ax, ay, n-1);
    koch(ax, ay, cx, cy, n-1);
    koch(cx, cy, bx, by, n-1);
    koch(bx, by, x2, y2, n-1);
  }
  else {
    printf("%f %f\n", x2, y2);
  }
}
 
int main(){
  int n;
  double x1 = 0.0, x2 = 100.0;
  double y1 = 0.0, y2 = 0.0;
  scanf("%d", &n);
  printf("%f %f\n", x1, y1);
  koch(x1, y1, x2, y2, n);
  return 0;
}
 

Measured memory_bytes: 636
import sys

N = int(input())
A = list(map(int, input().split()))

li = [0] * 3

for a in A:
  if a % 2 != 0:
    li[0] += 1

  elif a % 4 == 0:
    li[2] += 1

  else:
    li[1] += 1

if N % 2 == 0:
  if li[0] > li[2]:
    print("No")
    sys.exit()

  li[2] -= li[0]
  li[1] -= li[2]

  if li[1] % 2 != 0:
    print("No")
    sys.exit()


if N % 2 != 0:
  if li[0] - 1 > li[2]:
    ans = "No"

  li[2] -= li[0] - 1
  li[1] -= li[2]

  if li[1] % 2 != 0:
    print("No")
    sys.exit()

print("Yes")

Measured memory_bytes: 14808
import math

def Eratos(n):
	if n==2:
		return [2]
	primes = [2]
	num = [2*i+1 for i in range(1,n//2)]
	tmp = []
	top = 1
	while top < math.sqrt(n) and math.sqrt(n)>=2:
		top = num[0]
		for i in range(1,len(num)):
			if num[i] % top != 0:
				tmp.append(num[i])
		num = tmp
		tmp = []
		primes.append(top)
	for i in range(len(num)):
		primes.append(num[i])
	return primes

n=int(input())
test=n
p=Eratos(math.ceil(math.sqrt(test)))
fac=[]
next_flag=True
while test!=1 and len(p)!=0:
	if next_flag:
		ch=p.pop(0)
		next_flag=False
	if test%ch==0:
		while test%ch==0:
			fac.append(ch)
			test//=ch
	next_flag=True
if test!=1:
	fac.append(test)
print("%d: " % n,end='')
for i in range(len(fac)):
	if i!=len(fac)-1:
		print(fac[i],end=' ')
	else:
		print(fac[i])


Measured memory_bytes: 6356
H, W, K = map(int,input().split())
S = [list(input()) for _ in range(H)]

T = [[-1] * W for _ in range(H)]

ID = 1
st = []
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            T[i][j] = ID
            ID += 1
            st.append((i, j))

for tid, (i, j) in enumerate(st, 1):
    ni, nj = i, j
    while True:
        nj -= 1
        if nj < 0:
            break
        if T[ni][nj] != -1:
            break
        T[ni][nj] = tid
    ni, nj = i, j
    while True:
        nj += 1
        if nj > W-1:
            break
        if T[ni][nj] != -1:
            break
        T[ni][nj] = tid

ei, ej = st[0]
for i in range(ei-1, -1, -1):
    for j in range(W):
        if T[i][j] == -1:
            T[i][j] = T[i+1][j]

for i in range(ei+1, H):
    for j in range(W):
        if T[i][j] == -1:
            T[i][j] = T[i-1][j]

for line in T:
    print(*line)

Measured memory_bytes: 15048
num_a,num_b,num_k = gets.split(" ").map!{|i| i.to_i}
list_com = Array.new

count = 1 
while count <= num_a + num_b 
  if num_a%count == 0 && num_b%count == 0
    list_com.push(count)
  end
  count += 1
end

list_com.reverse!
#p list_com
p list_com[num_k-1]

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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

struct UnionFind
{
	vector<long long> par;

	void init(long long n) {par.assign(n, -1);}

	long long root(long long x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool merge(long long x, long long y)
	{
		x = root(x);
		y = root(y);
		if(x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	bool issame(long long x, long long y)
	{
		return root(x) == root(y);
	}

	long long size(long long x)
	{
		return -par[root(x)];
	}
};


ll N, M;

int main(int argc, char **argv)
{
	cin >> N >> M;

	UnionFind uf;
	uf.init(N);
	
	REP(i, M)
	{
		ll a, b, _; cin >> a >> b >> _;
		--a, --b;
		uf.merge(a, b);
	}

	ll res{1};
	REP(i, N)
	{
		if (!uf.issame(0, i))
		{
			uf.merge(0, i);
			++res;
		}
	}

	std::cout << res << std::endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  string X;
  cin >> X;
  int S = 0, ans = 0;
  for (auto c : X) {
    if (c == 'S')
      S++;
    else if (S == 0)
      ans++;
    else
      S--;
  }
  ans += S;
  cout << ans << endl;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std; 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0); 
	int N; cin >> N; 
	long long cnt[100010] = {}; 
	long long sum = 0;
	for(int i = 0; i < N; i++){
		int a; cin >> a; cnt[a] ++; 
		sum += a; 
	}
	int Q; cin >> Q; 
	while(Q--){
		long long B, C; cin >> B >> C; 
		sum += cnt[B] * (C - B); 
		cnt[C] += cnt[B]; cnt[B] = 0; 
		cout << sum << "\n"; 
	}
}

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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t w, a, b;
  std::cin >> w >> a >> b;

  if (a < b) {
    std::cout << std::max<int64_t>(0, b - a - w) << std::endl;
  } else {
    std::cout << std::max<int64_t>(0, a - b - w) << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;

void seive(vi a, vector<int> &prime)
{
  int max=a.back();
  for(auto i:a)
  {
      for(int j=i;j<=max;j+=i)
        prime[j]++;
  }
}

int main()
{
  fastio;
  int n;
  cin>>n;
  vi a(n);
  range(i,0,n)cin>>a[i];
  sort(a.begin(),a.end());
  vector<int> prime(a.back()+1,0);
  seive(a,prime);
  int c=0;
  for(auto i:a)
    if(prime[i]==1)
      c++;
  cout<<c;
}


Measured memory_bytes: 8732
n = int(input())
s,a,b = 0,0,0
f = True
for _ in [0]*n:
  t,x,y = map(int,input().split())
  p = t-s-(abs(x-a)+abs(y-b))
  if p%2 == 1 or p<0:
    f = False
  s,a,b = t,x,y
print("Yes" if f else "No")

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

int main(){
  int n, x;
  cin >> n >> x;
  int count =1;
  int sum =0;
  rep(i,n){
    int a;
    cin >> a;
    sum+=a;
    if(sum<=x){
      count +=1;
    }
    else break;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl


int main(){
  string s;cin>>s;
  ll t_x,t_y;cin>>t_x>>t_y;
  vector<ll> x,y;
  bool flg_xy=true;

  ll temp=0,index=0;
  s+="E";
  rep(i,s.size()){
    if(s[i]=='F'){
      t_x--;
    }else{
      index=i;
      break;
    }
  }
  FOR(i,index,s.size()){
    temp++;
    if(s[i]!=s[i+1]){
      if(s[i]=='F'){
        if(flg_xy){
          x.pb(temp);
        }else{
          y.pb(temp);
        }
      }else{
        if(temp%2){
          flg_xy=!flg_xy;
        }
      }
      temp=0;
    }
  }
  x.pb(0);
  y.pb(0);
  sort(all(x),greater<ll>());
  sort(all(y),greater<ll>());
  // dbgv(x);
  if(x.size()==0&&y.size()==0){
    if(t_x==0&&t_y==0){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  
  set<ll> s1,s2;
  bool flg=true;
  s1.insert(0);
  rep(i,x.size()){
    if(flg){
      reps(a,s1){
        s2.insert(a+x[i]);
        s2.insert(a-x[i]);
      }
      s1.clear();
      flg=!flg;
    }else{
      reps(a,s2){
        s1.insert(a+x[i]);
        s1.insert(a-x[i]);
      }
      s2.clear();
      flg=!flg;
    }
  }

  if(!(s1.count(t_x)==1||s2.count(t_x)==1)){
    cout<<"No"<<endl;
    return 0;
  }

  flg=true;
  s1.clear();
  s2.clear();
  s1.insert(0);
  rep(i,y.size()){
    if(flg){
      reps(a,s1){
        s2.insert(a+y[i]);
        s2.insert(a-y[i]);
      }
      s1.clear();
      flg=!flg;
    }else{
      reps(a,s2){
        s1.insert(a+y[i]);
        s1.insert(a-y[i]);
      }
      s2.clear();
      flg=!flg;
    }
  }

  if(!(s1.count(t_y)==1||s2.count(t_y)==1)){
    cout<<"No"<<endl;
    return 0;
  }

  cout<<"Yes"<<endl;


  return 0;
}

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

int main(){
    unsigned long long int l, r;
    unsigned long long int i, j;
    unsigned long long int min, i_mod, pre_mod, l_mod;
    unsigned long long int temp;

    cin >> l;
    cin >> r;

    if(l <= 2019 && r >= 2019){
        cout << 0;
    }else{
    min = 2018;
    for(i=l;i<r;i++){
        for(j=i+1;j<=r;j++){
            pre_mod = ((i*j) % 2019);
            if(min > pre_mod){
                min = pre_mod;
            }
            if(min == 0){
                break;
            }
        }
        if(min == 0){
            break;
        }
    }
    cout << min;

    }

    return 0;
}

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


int main(void) {
    char S[5];
    char head[3] = {};
    char tail[3] = {};

    scanf("%s", S);

    strncpy(head, S, 2);
    strncpy(tail, S + 2, 2);

    if (atoi(head) >= 1 && atoi(head) <= 12) {
        if(atoi(tail) >= 1 && atoi(tail) <= 12) {
            puts("AMBIGUOUS");

            return 0;
        }
    }

    if (atoi(head) >= 0) {
        if(atoi(tail) >= 1 && atoi(tail) <= 12) {
            puts("YYMM");

            return 0;
        }
    }

    if (atoi(head) >= 1 && atoi(head) <= 12) {
        if(atoi(tail) >= 0) {
            puts("MMYY");

            return 0;
        }
    }

    puts("NA");

    return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main() {
    int n;cin>>n;
    vector<int> p(n);REP(i,n) cin >> p[i];

    int count=0, mi=1e8;

    REP(i, n){
        mi = min(mi,p[i]);
        if(mi==p[i]) count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int const INF = 1001001001;


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

ll n,T;
cin >> n >> T;
vl t(n+1);
rep(i,n) cin >> t[i];
t[n] = 100000000000;
ll ans = 0;
vl s(n);
rep(i,n){
    s[i] = t[i+1] - t[i];
    ans += min(T,s[i]);
}
cout << ans << endl;

return 0;
}

Measured memory_bytes: 3456
import java.util.*;

public class Main {
    public static void main(String[] args){
        
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        
        String S = scanner.next();
        String[] s = S.split("");
        
        String T = scanner.next();
        String[] t = T.split("");
        
        String ans = "";
        
        for(int i=0; i<N; i++){
            
            ans = ans + s[i] + t[i];
            
        }
        
        System.out.println(ans);
        
    }
}


Measured memory_bytes: 21844
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);



	int bitC(int a) {

		if (a == 0)

			return 0;

		return bitC(a >> 1) + (a & 1);

	}



	void run() {

		int size = 0;

		for (int i = 0; i < 10; i++)

			size += i * (i + 1);

		int[][] dp = new int[size + 1][1 << 10];

		int[][] map = new int[size + 1][11];

		dp[0][0] = 1;

		for (int z = 0; z < 10; z++) {

			for (int j = 0; j < 1 << 10; j++) {

				if (bitC(j) != z)

					continue;

				for (int k = 1, p = 0; k < 1 << 10; k = k << 1, p++) {

					if ((j & k) != 0)

						continue;

					int bc = bitC(j | k);

					for (int i = 0; i + bc * p < size + 1; i++) {

						dp[i + bc * p][j | k] += dp[i][j];

					}

				}

			}

		}

		for (int j = 0; j < size + 1; j++) {

			for (int i = 0; i < 1 << 10; i++) {

				map[j][bitC(i)] += dp[j][i];

			}

		}

		for (; sc.hasNextInt();) {

			int n = sc.nextInt();

			int s = sc.nextInt();

			if (n > 10 || s > size) {

				System.out.println("0");

				continue;

			}

			System.out.println(map[s][n]);

		}

	}



	public static void main(String[] args) {

		Main m = new Main();

		m.run();

	}

}

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

namespace FreeWorks
{
    class Program
    {

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            int len = s.Length;

            int[,] dp = new int[len, len];
            
            for (int j = 0; j < len - 1; j++)
            {
                if (s[len - 1] ==s[j])
                {
                    dp[len - 1, j] = 1;
                }
            }

            for (int i = len - 2; i >= 0; i--)
            {
                for (int j = 0; j < i; j++)
                {
                    if (s[i] == s[j]) dp[i, j] = dp[i + 1, j + 1] + 1;
                }
            }

            int max = 0;
            for (int i = 0; i < len; i++)
            {
                for (int j = 0; j < i; j++)
                {
                    max = Math.Max(max, Math.Min(dp[i, j], i - j));
                }
            }

            Console.WriteLine(max);
    
        }   
    }
}


Measured memory_bytes: 107488