akhauriyash/Code-Regression huggingface dataset:
module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.container.rbtree;
import std.conv;
import std.stdio;
import std.string;
import std.traits;

struct Input
{
	int a, b, m;
	int[] as, bs;
	Waribiki[] waribiki;
}

struct Waribiki
{
    int x;
    int y;
    int c;
}

void parseInput(T)(out Input input, T file)
{
	with (file) with (input)
	{
		auto ar = readln().strip().split().map!(to!int).array();
		a = ar[0];
		b = ar[1];
        m = ar[2];
        as = readln().strip().split().map!(to!int).array();
        bs = readln().strip().split().map!(to!int).array();
        waribiki.length = m;
        foreach (i; 0..m)
        {
            auto w = readln().strip().split().map!(to!int).array();
            waribiki[i].x = w[0];
            waribiki[i].y = w[1];
            waribiki[i].c = w[2];
        }
	}
}

auto main2(Input* input)
{
	with (input)
	{
        auto price = min(as) + min(bs);
        foreach (w; waribiki)
        {
            auto temp = as[w.x - 1] + bs[w.y - 1] - w.c;
            if (temp < price)
                price = temp;
        }
        return price;
	}
}

int min(int[] ar)
{
    int ret = int.max;
    foreach (a; ar)
        if (a < ret)
            ret = a;
    return ret;
}

alias retType = ReturnType!main2;
static if (!is(retType == void))
{
	unittest { writeln("begin unittest"); }
	auto _placeholder_ = ReturnType!main2.init;

	unittest // example1
	{
		string example =
`2 3 1
3 3
3 3 3
1 2 1`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == 5);
	}

	unittest // example2
	{
		string example =
`1 1 2
10
10
1 1 5
1 1 10`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == 10);
	}

	unittest // example3
	{
		string example =
`2 2 1
3 5
3 5
2 2 2`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == 6);
	}

	unittest { writeln("end unittest"); }

	void parseExample(out Input input, string example)
	{
		struct Adapter
		{
			string[] _lines;
			this(string input) { _lines = input.splitLines(); }
			string readln() { auto line = _lines[0]; _lines = _lines[1..$]; return line; }
		}
		parseInput(input, Adapter(example));
	}
}

void printResult(T)(T result)
{
	static if (isFloatingPoint!T) writefln("%f", result);
	else writeln(result);
}

void main()
{
	Input input = void;
	parseInput(input, stdin);
	static if (is(retType == void))
		main2(&input);
	else
	{
		auto result = main2(&input);
		printResult(result);
	}
}


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

using namespace std;

#define ll long long
#define endl '\n'
#define pb push_back
#define inf 1e9

int h, n, damage[1001], cost[1001], dp[10010][10000];

int knapsack(int health, int spellid)
{

    if (health <= 0)
        return 0; //Condição ótima

    if (spellid > n)
        return inf;

    if (dp[health][spellid] != -1)
        return dp[health][spellid];

    int take = knapsack(health - damage[spellid], spellid) + cost[spellid];

    int notake = knapsack(health, spellid+1);

    return dp[health][spellid] = min(take, notake);
}

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

    memset(dp, -1, sizeof dp);

    for (int i = 1; i <= n; i++)
        cin >> damage[i] >> cost[i];

    cout << knapsack(h, 1) << endl;

    return 0;
}


Measured memory_bytes: 391808
#include <iostream>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
int main(){
  int n;cin >> n;
  int ans = 0;
  int a[n], b[n], c[n];
  rep(A, n)cin >> a[A];
  rep(B, n){cin >> b[B];ans+=b[B];}
  rep(C, n)cin >> c[C];
  rep(i, n-1){
    if(a[i] + 1 == a[i+1])ans+=c[a[i]-1];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int unused __attribute__((unused));
  int K;
  int array[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  unused = scanf("%d", &K);
  printf("%d", array[K-1]);

  return 0;
}

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

namespace aizu1
{
    public class Solution
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] A =new int[45];
            A[0] = 1;A[1] = 1;

            Console.WriteLine(Fib(A,n));
        }

        public static int Fib(int[] A, int n)
        {
            if (A[n] != 0) return A[n];
            else
            {
                A[n] = Fib(A,n-1) + Fib(A,n - 2);
                return A[n];
            }
        }
    }
}

Measured memory_bytes: 9108
#include<stdio.h>

int main(void)
{
	long long int a, b, c, N[100001];
	long long int i, j, sum = 0, P[100001];
	
	scanf("%lld", &a);

	for (i = 0; i < 100001; i++) {
		N[i] = 0;
	}

	for (i = 0; i < a; i++) {
		scanf("%lld", &b);
		N[b]++;
		sum += b;
	}

	scanf("%lld", &a);

	for (i = 0; i < a; i++) {
		scanf("%lld%lld", &b, &c);
		sum = sum + (N[b] * (c - b));
		N[c] = N[c] + N[b];
		N[b] = 0;
		P[i] = sum;
	}

	for (i = 0; i < a; i++) {
		printf("%lld\n", P[i]);
	}

	return 0;
}

Measured memory_bytes: 3248
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;

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

const int MAXT = 51, MAXP = 11, MAXR = 500,MAXTIME = 10800;

int tid,pid,atime;
int t,p,r;
string message ;
int ac[MAXT], wa[MAXT][MAXP], pena[MAXT];
bool used[MAXT];
typedef pair<int, int> pp;

int main()
{
    while(cin >> t >> p >> r && t)
    {
        //初期化
        memset(ac, 0, sizeof(ac));
        memset(wa, 0, sizeof(wa));
        memset(used, false , sizeof(used));
        memset(pena, 0, sizeof(pena));
        
        //入力
        REP(r)
        {
            cin >> tid >> pid >> atime >> message;
            if(message == "WRONG")
                wa[tid][pid]++;

            else
            {
                ac[tid]++;
                pena[tid] += (wa[tid][pid] * 1200 + atime);
            }
        }

        rep(j,t)
        {
            int topacc = -1, topp = 100000,top = 0;
            onen(i,t)if(!used[i] &&(topacc < ac[i] || (topacc == ac[i] && topp > pena[i]))) //まだ出してなくて，acが今のtopより多いか，acが同じでpenaが大きい奴でtopを更新
            {
                top = i;
                topacc = ac[i];
                topp = pena[i];
            }
            used[top] = true;
            cout << top << " " << topacc << " " << topp << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 924
#include<iostream>
#define int long long
const int N=5e5+2;
const int mod=998244353;
using namespace std;
int fact[N],inv[N],pn[N],pm[N];
int binpow(int x,int y){
	int tich=1;
	while(y){
		if(y&1){
			tich*=x;
			tich%=mod;
		}
		x*=x;
		x%=mod;
		y>>=1;
	}
	return tich;
}
int C(int x,int y){
	return (fact[y]*((inv[x]*inv[y-x])%mod))%mod;
}
signed main(){
	int n,m,i,j=1,ans=0;
	cin>>n>>m;
	fact[0]=1;
	pn[0]=1;
	pm[0]=1;
	for(i=1;i<=max(n,m);i++){
		pn[i]=(pn[i-1]*(n+1))%mod;
		pm[i]=(pm[i-1]*(m+1))%mod;
		fact[i]=(fact[i-1]*i)%mod;
//		cout<<fact[i]<<endl;
	}
	inv[max(n,m)]=binpow(fact[max(n,m)],mod-2);
	for(i=max(n,m);i>=1;i--){
		inv[i-1]=(inv[i]*i)%mod;
//		cout<<inv[i]<<endl;
	}
	for(i=0;i<=min(n,m);i++){
		ans+=j*((((C(i,n)*C(i,m))%mod)*((fact[i]*pn[m-i])%mod))%mod)*pm[n-i];
		ans%=mod;
		if(ans<0){
			ans+=mod;
		}
		j*=-1;
//		cout<<i<<' '<<ans<<endl;
	}
	cout<<ans;
}

Measured memory_bytes: 15872
from sys import stdin
from collections import deque
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    g=[[] for _ in range(N)]
    AB=[]
    for _ in range(N-1):
        a,b=map(lambda x:int(x)-1,readline().split())
        g[a].append(b)
        g[b].append(a)
        AB.append(str(a)+" "+str(b))

    link=[0]*N
    que=deque([0])
    is_searched=[False]*N
    is_searched[0]=True
    K=0
    ans=dict()
    #bfs
    while len(que)>=1:
        now=que.popleft()
        color=1
        for x in g[now]:
            if is_searched[x]:
                continue
            else:
                is_searched[x]=True
                que.append(x)
                if color==link[now]:
                    color+=1
                link[x]=color
                ans[str(min(now,x))+" "+str(max(now,x))]=color
                color+=1
        color-=1
        K=max(K,color)

    #出力
    print(K)
    for key in AB:
        print(ans[key])
        
if __name__=="__main__":
    main()

Measured memory_bytes: 45264
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

// エラトステネスの篩[2,n]を列挙 O(nloglogn)
vector<lint> sieve_of_eratosthenes(lint n) {
    vector<bool> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;
    for (lint i = 2; i*i <= n; ++i)
        if (is_prime[i])
            for (lint k = i+i; k <= n; k += i)
                is_prime[k] = false;
    vector<lint> primes;
    for (lint i = 2; i <= n; ++i)
        if (is_prime[i])
            primes.push_back(i);
    return primes;
}
        
int main(void) {
    const int INF = 1e5 + 1;
    vector<int> n(INF, 0);
    vector<bool> b(INF, false);
    vector<bool> c(INF, false);
    
    vector<lint> primes = sieve_of_eratosthenes(INF);
    for (int p : primes) {
        b[p] = true;
    }
    
    repeat_from (i, 3, INF) {
        if (i % 2 == 0) continue;
        if (b[i] and b[(i+1)/2]) c[i] = true;
    }
    
    repeat_from (i, 3, INF) {
        n[i] = n[i-1] + (c[i] ? 1 : 0);
    }
    
    int q; cin >> q;
    vector<int> l(q), r(q);
    repeat(i, q) cin >> l[i] >> r[i];
    
    repeat(i, q) {
        cout << n[r[i]] - n[l[i]-1] << endl;
    }
    
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
    using namespace std;
    #define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    #include <ext/pb_ds/assoc_container.hpp> 
    #include <ext/pb_ds/tree_policy.hpp> 
    using namespace __gnu_pbds; 
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
     
    #define ff first
    #define ss second
    #define mp make_pair
     
    #define pb push_back
    #define endl "\n"
     
    #define int long long int
    #define double long double
     
    #define bp __builtin_popcountll
    #define inf 1e17
    const int N=1e6+6;
    const int M=1e9+7;
    
    signed main(){
    	FAST
    	int n,m;
    	cin>>n>>m;
    	string s="";
    	string t="";
    	for(int i=0;i<n;i++)
    	{
    		s+=(m+'0');
    		
    	}
    	for(int i=0;i<m;i++)
    	{
    		t+=(n+'0');
    	}
    	if(s<t)
    	cout<<s;
    	else
    	cout<<t;
    } 
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
// mt19937 gen_rand_int(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 gen_rand_ll(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}
 

signed main()
{
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
 
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    int n,z,w;
    cin>>n>>z>>w;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int mx=0;
    for(int i=1;i<n-1;i++)
    {
        int tt=1e10;
        tt=min(tt,abs(a[n]-a[i]));
        for(int j=i+1;j<n;j++)
        {
            tt=min(abs(a[j]-a[n]),tt);
        }
        mx=max(mx,tt);
    }
    if(n>1)
    {
        mx=max(mx,abs(a[n]-a[n-1]));
    }
    mx=max(mx,abs(a[n]-w));
    cout<<mx;

} 

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

int main(){
	double r;
	cin >> r;
	double P = 3.141592653589793;
	double S = P * r * r;
	double L = 2 * P * r;
	cout << fixed << setprecision(6) << S << ' ' << L << endl;
	return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int maxn = 1e5+10;
const int base = 1e9+7;

int n,a[maxn],been[maxn],x1,x2;
ll ans[maxn],inv[maxn],fact[maxn];

ll pw(int a,int n) {
    if (n==0) return 1ll;
    if (n==1) return a;
    ll tmp = pw(a,n/2);
    tmp = (tmp*tmp)%base;
    if (n%2==0) return tmp;
    return (tmp*a)%base;
}

ll C(int k,int n) {
    //cout<<fact[n]<<endl;
    return fact[n]*inv[k]%base*inv[n-k]%base;
}

int main() {
   // freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    fact[0]=1; inv[0]=1;
    for (int i=1;i<maxn;i++) {
        fact[i] = (fact[i-1]*i)%base;
        inv[i] = pw(fact[i],base-2);
    }
    cin>>n;
    for (int i=1;i<=n+1;i++) {
        cin>>a[i];
        if (been[a[i]]!=0) {
            x1 = been[a[i]];
            x2 = n-i;
        }
        else been[a[i]]=i;
    }
    //cout<<x1<<" "<<x2<<endl;
    for (int i=1;i<=n+1;i++) ans[i] = C(i,n+1);
    for (int i=0;i<=x1+x2;i++) ans[i+1] = (ans[i+1] - C(i,x1+x2) + base) % base;
    for (int i=1;i<=n+1;i++) cout<<ans[i]<<endl;
}


Measured memory_bytes: 4352
import java.util.*;

public class Main{
	public static void main(String[]$){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		String[]a=new String[n];
		int[]b=new int[n+1];
		for(int i=0;i<n;++i) {
			a[i]=s.next();
			b[i+1]=b[i]+s.nextInt();
		}
		String t=s.next();
		for(int i=0;i<n;++i)
			if(t.equals(a[i]))
				System.out.println(b[n]-b[i+1]);
	}
}

Measured memory_bytes: 22996
#include<stdio.h>
 
int count = 0;
 
void merge(int A[], int left, int mid, int right){
  int n1, n2;
  int i, j, k;
   
  n1 = mid - left;
  n2 = right - mid;
 
  int l[n1 + 1],r[n2 + 1];
   
  for(i = 0; i < n1; i++){
    l[i] = A[left + i];
  }
 
 
  for(i = 0; i < n2; i++){
    r[i] = A[mid + i];
  }

  l[n1] = 1000000000;
  r[n2] = 1000000000;
 
  i = 0;
  j = 0;
   
  for(k = left; k < right; k++){
    if(l[i] <= r[j]){
      A[k] = l[i];
      i += 1;
      count++;
    }

    else{
      A[k] = r[j];
      j += 1;
      count++;
    }
  }
}
 
void mergesort(int A[], int left, int right){
  int mid, i;

  if(left + 1 < right){
    mid = (left + right) / 2;

    mergesort(A, left, mid);

    mergesort(A, mid, right);

    merge(A, left, mid, right);
  }
}

int main(){
  int n, S[500000];
  int left = 0;
  int i;
 
  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%d",&S[i]);
  }
  
  mergesort(S,left,n);
   
  for(i = 0; i < n; i++){    
    printf("%d",S[i]);

    if(i < n - 1){
      printf(" ");
    }
  }

  printf("\n");
  printf("%d\n",count);
   
  return 0;
}

Measured memory_bytes: 4508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

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

Measured memory_bytes: 512
#include <stdio.h>
#define N_max 100

int main(){
  int i,j,change,N,array[N_max],count=0;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&array[i]);
  }
  
  i=0;
  while(1){
    for(j=N-1;j>=i+1;j--){
      if(array[j]<array[j-1]){
	change = array[j];
	array[j] = array[j-1];
	array[j-1] = change;
	count++;
      }
    }
    i++;
    if(i==N){
      break;
    }
  }

  for(i=0;i<N-1;i++){
    printf("%d ",array[i]);
  }
  printf("%d\n",array[N-1]);
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2108
N=input()
h=map(int,raw_input().split())

order0=[[h[t],t] for t in range(N)]
order0.sort()
order=[o[1] for o in order0]

Ans=0
Z=[-1]
for t in range(N):
    i=order[t]
    Num=h[i]
    c=0
    for j in range(N):
        if j not in Z and (j-1) in Z:
            c+=1
    Ans+=c*Num
    Z.append(i)
    
    h=[max(0,h0-Num) for h0 in h]

print Ans

Measured memory_bytes: 2692
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    return ret;
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.is_err() || res.ok().unwrap() == 0 || u8b[0] <= ' ' as u8 {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = std::string::String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}
fn parse<T: std::str::FromStr>(s: &str) -> T { s.parse::<T>().ok().unwrap() }

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { parse(&get_word()) }

#[allow(dead_code)]
macro_rules! d {
    ($e:expr) => {println!("{} = {:?}", stringify!($e), $e)}
}

fn run(a: u64, b: u64) -> u64 {
    if a > b {
        run(b, a)            
    } else if b % a == 0 {
        (2 * (b / a) - 1) * a
    } else {
        2 * (b / a) * a + run(b % a, a)
    }
}

fn main() {
    let n : u64 = get();
    let x : u64 = get();

    println!("{}", n + run(x, n-x));
}


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

//テストケースはあんまり見ないほうが良い。デバッグする能力が必要.
int main(){
    ll a, b,k;
    cin >> a >> b >> k;
    if(a+b <=k){cout << 0 << " " << 0 << endl;}
    else if(k>=a){cout << 0 << " " << b+a-k << endl;}
    else{cout << a-k << " " << b << endl;}
    return 0;
}

Measured memory_bytes: 256
import math
l = input().split()

x1 = int(l[0])
y1 = int(l[1])
x2 = int(l[2])
y2 = int(l[3])

yoko = x2-x1
tate = y2-y1

x3 = x2 - tate
y3 = y2 + yoko
x4 = x1 - tate
y4 = y1 + yoko

  
print(str(x3)+' '+str(y3)+' '+str(x4)+' '+str(y4))


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

int main() {

    int n;
    cin >> n;
    vector<ll> a(n+1),b(n);
    rep(i,n+1){
        cin >> a[i];
    }
    rep(i,n){
        cin >> b[i];
    }
    ll d=0;
    ll ans=0;
    rep(i,n){
        ans+=min(a[i],b[i]);
        d=max((ll)0,b[i]-a[i]);
        ans+=min(d,a[i+1]);
        a[i+1]=max((ll)0,a[i+1]-d);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define lld long double
#define F first
#define S second
#define f(i,a,b) for(int i=a;i<=b;i++)
#define g(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mh make_heap
#define ph push_heap
#define pq priority_queue
#define bits(x) __builtin_popcountll(x)
#define op(x) cout<<"Case #"<<x<<": "
#define op1(x) cout<<"Scenario #"<<x<<": "
#define endl "\n"
using namespace std;
const ll mod = 1000000007;
const ll INF = 1e18;
const int N = 20;


/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define policy tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
*/

const ll MAX = 500001;
ll block;
ll freq[MAX];

struct Query {
	ll L, R, index, result;
};

bool compare(Query x, Query y)
{
	if (x.L / block != y.L / block)
		return x.L / block < y.L / block;
	return x.R < y.R;
}

bool compare1(Query x, Query y)
{
	return x.index < y.index;
}

void queryResults(ll a[], ll n, Query q[], ll m)
{
	block = (ll)sqrt(n);

	sort(q, q + m, compare);

	ll currL = 0, currR = 0;
	ll curr_Diff_elements = 0;




	for (int i = 0; i < m; i++) {

		ll L = q[i].L, R = q[i].R;

		while (currL < L) {

			freq[a[currL]]--;
			if (freq[a[currL]] == 0)
				curr_Diff_elements--;

			currL++;
		}


		while (currL > L) {
			freq[a[currL - 1]]++;

			if (freq[a[currL - 1]] == 1)
				curr_Diff_elements++;

			currL--;
		}
		while (currR <= R) {
			freq[a[currR]]++;

			if (freq[a[currR]] == 1)
				curr_Diff_elements++;

			currR++;
		}

		while (currR > R + 1) {

			freq[a[currR - 1]]--;

			if (freq[a[currR - 1]] == 0)
				curr_Diff_elements--;

			currR--;
		}
		q[i].result = curr_Diff_elements;
	}
}


void solve(int t)
{

	ll n, q;
	cin >> n >> q;
	ll a[n];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	Query qr[q];
	for (int i = 0; i < q; i++)
	{
		ll l, r;
		cin >> l >> r;
		qr[i].L = l - 1;
		qr[i].R = r - 1;
		qr[i].index = i;
	}

	queryResults(a, n, qr, q);

	sort(qr, qr + q , compare1);
	for (int i = 0; i < q; i++) {
		cout << qr[i].result << endl;
	}

}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);


	int t = 1;
	//cin >> t;


	for (int i = 1; i <= t; i++)
	{
		solve(i);

	}
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main(){
    gearup;
    ll n;cin>>n;
    vvl c(n,vl(26));
    rep(i,n){
        string s; cin >> s;
        rep(j,s.size()){
            c[i][s[j] - 'a']++;
        }
    }
    string res = "";
    for(char i = 'a';i<='z';i++){
        ll ttl = L_INF;
        rep(j,n){
            ttl = min(c[j][i-'a'],ttl);
        }
        rep(k,ttl)res+= i;
    }
    out(res);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

long long int lcm(long long int A, long long int B);
long long int gcd(long long int A, long long int B);

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	int N;
	vector<int> H;
	cin >> N;
	for(int i=0; i<N; i++) {
		int h;
		cin >> h;
		H.push_back(h);
	}

	bool flg = false;
	int prev = H[N-1];
	for(int i=N-2; i>=0; i--) {
		// cout << prev << ',' << H[i] << endl;
		if(prev >= H[i]) {
			prev = H[i];
		} else if(prev == (H[i] - 1)) {
			// nothing
		} else {
			flg = true;
			break;
		}
		// cout << "prev: " << prev << endl;
	}
	if(flg) {
		cout << "No";
	} else {
		cout << "Yes";
	}
	return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
using namespace std;

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; ++i){
    cin >> a[i];
  }

  vector<int> l(n + 1);
  l[0] = 0;
  for(int i = 0; i < n; ++i){
    l[i + 1] = gcd(l[i], a[i]);
  }

  vector<int> r(n + 1);
  r[0] = 0;
  for(int i = n - 1; i >= 0; --i){
    r[i] = gcd(r[i + 1], a[i]);
  }

  int ans = 0;
  int tmp = 0;
  for(int i =0; i < n; ++i){
    tmp = gcd(l[i], r[i + 1]);
    if(tmp > ans){
      ans = tmp;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

bool solve(LL t, LL n, LL k, VLL &a) {
    if (t == 0) return false;
    LL cnt = 0;
    REP(i,0,n) {
        LL d = (a[i] + t - 1) / t;
        cnt += d - 1;
        // if (a[i] % t == 0) --cnt;
    }
    return cnt <= k;
}

long long meguru_bin(LL n, LL k, VLL &a) {
    long long ok = *max_element(all(a));
    long long ng = -1;

    while (abs(ok - ng) > 1) {
        long long mid = ng + (ok - ng) / 2;
        if (solve(mid,n,k,a)) ok = mid;
        else ng = mid;
    }

    return ok;
}

void solve() {
    LL n,k;
    cin >> n >> k;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    cout << meguru_bin(n,k,a) << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 4756
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

// main starts here

int main(){
    vector<vector<int>> dp(2,vector<int>(2019,0));
    vector<int> reset(2019,0);
    string s; cin >> s;
    ll ss = s.size();
    ll x = s.at(0) - '0';
    dp[0][x]++;
    ll ans = 0;
    for(int i=1;i<ss;i++){
        x = s.at(i) - '0';
        if(i%2){
            dp.at(1) = reset;            
            for(int j=0;j<2019;j++){
                ll y = (j * 10 + x)%2019;
                dp[1][y] += dp[0][j];
            }
            ans += dp[1][0];
            dp[1][x]++;
        }else{
            dp.at(0) = reset;            
            for(int j=0;j<2019;j++){
                ll y = (j * 10 + x)%2019;
                dp[0][y] += dp[1][j];
            }
            dp[0][x]++;
            ans += dp[0][0];
        }
        //cout << ans << endl;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3764
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    int a,b;

    cin >> a >> b;

    int dis = b-a;

    int s = dis*(dis+1)/2;

    
    cout << s - b << endl;

    return 0;
}

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

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

    int n; cin >> n;
    vector<int> b(n - 1);
    for (int i = 0; i < n - 1; ++i) {
        cin >> b[i];
    }

    if (n == 2) {
        cout << 2 * b[0] << endl;
        return 0;
    }

    int res = b[0] + b[n - 2];
    for (int i = 0; i < n - 2; ++i) {
        res += min(b[i], b[i + 1]);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
    char l,k;
    string a;
    cin>>a;
    l=a[0];
    k=a[2];
    if(l==k)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn.readInt

object Main {
  def getMax(i:Int,minv:Int,maxv:Int,r:Int):Int = {
    val m = r-minv
    if(i==1) m.max(maxv)
    else getMax(i-1,r.min(minv),m.max(maxv),readInt)
  }

  def main(args:Array[String]):Unit =
    println(getMax(readInt-1,readInt,Int.MinValue,readInt))
}

Measured memory_bytes: 63084
package main

import "fmt"

func main(){
	var a, b, c ,d int
	fmt.Scan(&a, &b, &c, &d)
	first := a*b
	second := c*d
	if first == second{
		fmt.Println(first)
	}else if first > second{
		fmt.Println(first)
	}else {
		fmt.Println(second)
	}
}

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

int main(){
    int x,y;
    
    cin>>x>>y;
    
    while(!(x == 0 && y ==0)){
        if(x<y){
            cout << x << " " << y << endl;
            
        }
        else{
            cout << y << " " << x <<endl;
            
        }
        
        cin >> x >> y;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <array>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	auto v = array<int, 3>{a, b, c};
	sort(v.begin(), v.end());
	cout << (v[0] + v[1] == v[2] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        t: [usize; 2],
        a: [i64; 2],
        b: [i64; 2],
    }
    let mut a = a;
    let mut b = b;
    if a[0] < b[0] {
        for i in 0..2 {
            std::mem::swap(&mut a[i], &mut b[i]);
        }
    }
    let mut avg = [0; 2];
    for i in 0..2 {
        avg[0] += a[i] * t[i] as i64;
        avg[1] += b[i] * t[i] as i64;
    }
    if avg[0] == avg[1] {
        puts!("infinity\n");
        return;
    }
    if avg[0] > avg[1] {
        puts!("0\n");
        return;
    }
    let peak1 = (a[0] - b[0]) * t[0] as i64;
    let peak2 = peak1 + (a[1] - b[1]) * t[1] as i64;
    let diff = avg[1] - avg[0];
    let mut tot = 0;
    tot += (peak1 - 1) / diff;
    tot += (peak1 - peak2) / diff;
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
typedef long long int ll;
#define MOD 1000000007
#define MAXN 200001
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)
using namespace std;
 
int main() {
    string s;
    cin >> s;
    ll y=0;
    f(i,0,s.size()){
        if(s[i]=='7'){
          	y=1;
            break;
        }
    }
    if(y==0){
        cout << "No";
    }else{
      	cout<<"Yes";
    }
}

Measured memory_bytes: 3628
n = int(input())
arr = []
for i in range(0 , n):
	arr.append(int(input()))
tot = 0
for i in range( 0 , n):
	tot = tot+arr[i]
if tot%10!=0:
	print(tot)
else:
	res =0
	for i in range(0 , n):
		if (tot-arr[i])%10!=0:
			res = max(res, tot-arr[i])
	print(res)

Measured memory_bytes: 62444
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}

signed _main(){
  int N,ans=1; cin >> N;
  unordered_map<int,int> mp;
  for(int i=2;i<=N;i++){
    int num=i;
    for(int j=2;j<=i;j++){
      while(num%j==0){
        num/=j;
        mp[j]++;
      }
    }
  }
  fore(i,mp){
    ans = ans * (i.second+1) % MOD;
    //cout << i.first << " " << (i.second+1) << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import itertools
import bisect



n = int(input())
al = [0 for _ in range(26)]
for i in range(97,123):
    al[i-97] = chr(i)
#print(al)

sm = [0 for _ in range(20)]
for i in range(1,20):
    sm[i] = int(26*(26**i - 1)/25)

#print(sm[4])

xx = bisect.bisect_left(sm, n)
#print(xx)
if(xx > 1):
    rd = n - sm[xx-1]
    ans = []
    tmp = [0 for _ in range(30)]
    for i in range(xx):
        if(xx > 1):
            unt = 26**(xx-i-1)
        if(rd >= unt):
            tmp = [j*unt for j in range(30)]
            num = bisect.bisect_left(tmp,rd)
            ans.append(al[num-1])
            rd -= tmp[num-1]
            #print(rd)
        else:
            ans.append("a")

    print("".join(ans))

else:
    print(al[n-1])
    
    

Measured memory_bytes: 62416
#include <iostream>
#include <string>

int ctoi(char c)
{
	switch (c)
	{
	case '0':
		return 0;
	case '1':
		return 1;
	case '2':
		return 2;
	case '3':
		return 3;
	case '4':
		return 4;
	case '5':
		return 5;
	case '6':
		return 6;
	case '7':
		return 7;
	case '8':
		return 8;
	case '9':
		return 9;
	default:
		return -1;
	}
}

int main()
{
	std::string n;

	std::cin >> n;

	int sum = 0;
	for (auto c : n)
	{
		sum += ctoi(c);
	}
	if (sum % 9 == 0)
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    a = take_mod(a);
    b = take_mod(b);
    return take_mod(a*b);

}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}

ll dp[41][1<<16];
int bit16 = (1<<16)-1;

int main(){
    int N, X, Y, Z;
    cin >> N >> X >> Y >> Z;
    for(int i = 0; i < 41; i++){
        for(int j = 0; j <= bit16; j++){
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;

    for(int i = 1; i <= N; i++){
        for(int j = 0; j < (1<<16); j++){
            for(int k = 1; k <= 10; k++){
                int hist = ((j << k) | (1 << (k-1)));
                if(((hist>>(Z-1)) & 1) == 1 && ((hist>>(Y+Z-1)) & 1) == 1 && ((hist>>(X+Y+Z-1) & 1) == 1)){
                    continue;
                }
                int pos = hist & bit16;
                dp[i][pos] = add(dp[i][pos], dp[i-1][j]);
            }
        }
    }

    ll res = 1;
    for(int i = 0; i < N; i++){
        res = mul(res, 10);
    }
    for(int i = 0; i < (1<<16); i++){
        res = sub(res, dp[N][i]);
    }
    cout << res << endl;

    return 0;

}

Measured memory_bytes: 22784
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
    int N, ans = 0;
    cin >> N;
    map<int, int> mp;
    rep(i, N) {
        int a;
        cin >> a;
        if (mp.find(a) == mp.end()) {
            mp[a] = 1;
            ans++;
        } else {
            if (mp[a] == 1) {
                mp[a] = 0;
                ans--;
            } else {
                mp[a] = 1;
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
//string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

ll fastpow(ll a, ll pw) {
	ll res = 1;
	while (pw) {
		if (pw & 1) (res *= a)%=MOD;
        (a *= a)%=MOD;
		pw >>= 1;
	}
	return res;
}

int main(){
    cin>>N;
    vec x(N), fact(N);
    rep(i,N) cin>>x[i];
    fact[0] = 1;
    reps(i,1, N) fact[i] = (fact[i-1] * ll(i))%MOD;
    ll a = 1, ans = 0;
    reps(i,1,N){
        (ans += ((a * fact[N-1])%MOD)
                *((fastpow(fact[i], MOD - 2) * (x[i] - x[i-1]))%MOD))%=MOD;
        if(ans < 0){
            cout<<fastpow(fact[i], MOD - 2)<<endl;
        }
        (a *= i + 1)%=MOD;
        (a += fact[i])%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int n,m,ans;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for (int i=1;i<=n;++i)
	{
		for (int j=22;j<=m;++j)
		{
			int a=j%10,b=j/10;
			if (a*b==i && a>=2 && b>=2)
			{
				//cout<<i<<" "<<j<<endl;
				++ans;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define T second.first
#define C second.second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int,pair<int,int>> piii;

const int N= 1e4+5, L = 14, OO = 0x3f3f3f3f;
const ll M=1000000007  ;
const double ESP = 1e-8;



int main(){
    FIO
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes\n";
    else
        cout<<"No\n";



}


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

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

		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();

		// 計算
		int k = a + b;
		String result = "No";

		// 出力
		if(k%2 == 0){
		   System.out.println(k/2);
		}else{
		   System.out.println("IMPOSSIBLE");
		}
	}
	
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define lol long long
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol a,b,c=0,d=0,e;
  int ans5=0;
  vector<lol> ans;
  string s;
  cin >>a>>b;
  cin >>s;
  c=a;
  while(true){
    e=0;
    lol f=0;
    bool can=false;
    for(int n=c-1;n>=c-b;n--){
      if(s[n]=='0') e=n,f=c-n;
      if(n==0){
	can=true;
	break;
      }
    }
    c-=f;
    ans.push_back(f),ans5++;
    if(f==0){
      cout <<-1<<'\n';
      return 0;
    }
    if(can) break;
  }
  cout <<ans[ans5-1];
  for(int n=ans5-2;n>=0;n--) cout <<' '<<ans[n];
  cout <<'\n';
  return 0;
}


Measured memory_bytes: 1480
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true) {
			String[] strArray = br.readLine().split(" ");
			int H = Integer.parseInt(strArray[0]);
			int W = Integer.parseInt(strArray[1]);

			if (H ==0 && W == 0) {
				break;
			}
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if (i==0 || i == H-1) {
						System.out.print("#");
					} else if (j ==0 || j == W-1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 30576
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");
		int s = Integer.parseInt(str[0]);

		HashSet<Integer> set = new HashSet<>();
		set.add(s);

		for (int i = 1;; i++) {
			int n = calc(s);
			if (set.contains(n)) {
				System.out.println(i + 1);
				break;
			} else {
				set.add(n);
				s = n;
			}
		}
	}

	static int calc(int a) {
		if (a % 2 == 0) {
			return a / 2;
		} else {
			return 3 * a + 1;
		}
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<128>>;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << (x) << '\n'
typedef long long lint;
const int INF = 2e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const lint LINF = 1e18;
typedef vector<int> vint;
typedef pair<int, int> pint;
template <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}
void print() { cout << endl; }
template <class T, class... A> void print(const T &first, const A &... rest) {
    cout << first;
    print(rest...);
}
template <class... A> void print(const A &... rest) { print(rest...); }
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;
}
int modulo(int a, int b, int n) {
    long long x = 1, y = a;
    while(b > 0) {
        if(b % 2 == 1) {
            x = (x * y) % n; // multiplying with base
        }
        y = (y * y) % n; // squaring the base
        b /= 2;
    }
    return x % n;
}
/* templates */ /* templates */ /* templates */ /* templates */ /* templates */

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

    const int MAXH = 1000, MAXW = 1000;
    int H = in(), W = in();
    string a[MAXH + 10];
    a[0] = '#';
    rep(i, W) { a[0] += '#'; }
    rep(i, 1, H + 1) {
        cin >> a[i];
        a[i] = '#' + a[i];
    }
    // rep(i, H + 1) { print(a[i]); }
    int dp[MAXH + 10][MAXW + 10];
    rep(i, H + 1) {
        rep(j, W + 1) { dp[i][j] = 0; }
    }
    dp[1][1] = 1;
    rep(i, 1, H + 1) {
        rep(j, 1, W + 1) {
            if(i != 1 || j != 1) {
                if(a[i][j] == '#') {
                    dp[i][j] = 0;
                } else {
                    dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
                }
            }
        }
    }
    int ans = dp[H][W];
    print(ans);
}


Measured memory_bytes: 5248