akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
    long num;
    cin>> num;

    long ans=0;

    for(long i=1;i<num;i++){
        if(i*i>=num){
            break;
        }
        if(num%i==0){
            if(num/(num/i -1)==num%(num/i -1)){
                ans += num/i -1;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<vector>
#include<utility>
#define INF 0x3f3f3f3f3f3f3f3f
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'

using namespace std;
typedef long long ll;
const int maxn = 4e3 + 10;
int R[maxn], G[maxn], B[maxn];

int main() {
	int n;cin >> n;
	string s;cin >> s;
	ll ans = 0;
	R[0] = s[0] == 'R' ? 1 : 0;
	G[0] = s[0] == 'G' ? 1 : 0;
	B[0] = s[0] == 'B' ? 1 : 0;
	for (int i = 1;i <= n;++i) {
		R[i] = R[i - 1];
		G[i] = G[i - 1];
		B[i] = B[i - 1];
		if (s[i] == 'R') {
			R[i]++;
		}
		else if (s[i] == 'G') {
			G[i]++;
		}
		else {
			B[i]++;
		}
	}
	for (int i = 1;i < n;++i) {
		if (s[i] == 'R')continue;
		for (int j = i + 1;j < n;++j) {
			if (s[j] == 'R' || s[i] == s[j])continue;
			ans += R[i - 1];
			if (i - (j - i) >= 0 && s[i - (j - i)] == 'R')--ans;
		}
	}
	for (int i = 1;i < n;++i) {
		if (s[i] == 'G')continue;
		for (int j = i + 1;j < n;++j) {
			if (s[j] == 'G' || s[i] == s[j])continue;
			ans += G[i - 1];
			if (i - (j - i) >= 0 && s[i - (j - i)] == 'G')--ans;
		}
	}
	for (int i = 1;i < n;++i) {
		if (s[i] == 'B')continue;
		for (int j = i + 1;j < n;++j) {
			if (s[j] == 'B' || s[i] == s[j])continue;
			ans += B[i - 1];
			if (i - (j - i) >= 0 && s[i - (j - i)] == 'B')--ans;
		}
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 3272
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  string s;
  cin >> s;
  vector<int> judge(26, 0);
  for (int i = 0; i < s.size(); i++) {
    judge[s[i] - 'a']++;
  }
  bool flag = true;
  for (int i = 0; i < 26; i++) {
    if (judge[i] > 1) flag = false;
  }
  if (flag) cout << "yes" << endl;
  else cout << "no" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  string S ;
  cin >> S ;
  int min = 99999 ;
  for(int i=0;i<S.size()-2;i++){
    if(abs((S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0') - 753) < min){
      min = abs((S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0')- 753) ;
    }
  }
  cout << min << endl;
}

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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入


int main(){
    int N;
    cin >> N;
    vector<ll> a(N);
    ll a_max=-INF;
    ll a_min=INF;
    int i_max,i_min;
    REP(i,N){
        cin >> a[i];
        if(a[i]>a_max){
            a_max=a[i];
            i_max=i;
        }
        if(a[i]<a_min){
            a_min=a[i];
            i_min=i;
        }
    }
    int m=0;
    vector<pair<int,int>> ans(100);
    if(a_min>=0){
        REP(i,N-1){
            if(a[i+1]<a[i]){
                ans[m]=make_pair(i+1,i+2);
                m++;
                a[i+1]+=a[i];
            }
        }
    }else if(a_max<=0){
        REPD2(i,N-1,0){
            if(a[i]<a[i-1]){
                ans[m]=make_pair(i+1,i);
                m++;
                a[i-1]+=a[i];
            }
        }
    }else{
        if(a_max>=-a_min){
            REP(i,N){
                if(a[i]<0){
                    ans[m]=make_pair(i_max+1,i+1);

                    m++;
                    a[i]+=a[i_max];
                }
            }
            REP(i,N-1){
                if(a[i+1]<a[i]){
                    ans[m]=make_pair(i+1,i+2);
                    m++;
                    a[i+1]+=a[i];
                }
            }
        }else{
            REP(i,N){
                if(a[i]>0){
                    ans[m]=make_pair(i_min+1,i+1);
                    m++;
                    a[i]+=a[i_min];
                }
            }
            REPD2(i,N-1,0){
                if(a[i]<a[i-1]){
                    ans[m]=make_pair(i+1,i);
                    m++;
                    a[i-1]+=a[i];
                }
            }
        }
    }

    cout << m <<endl;
    REP(i,m) cout << ans[i].first << " " << ans[i].second << endl;
    
}

Measured memory_bytes: 256
///
// File:  d.cpp
// Author: ymiyamoto
//
// Created on Fri Sep 29 20:21:11 2017
//

#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;
static string turns;
static vector<char> my_turns;

int32_t main()
{
  cin >> turns;

  uint32_t g_count = 0;
  uint32_t p_count = 0;
  int32_t win_count = 0;
  int32_t lose_count = 0;

  for (uint32_t i = 0; i < turns.size(); i++) {
    if (turns[i] == 'g') {
      if (p_count < g_count) {
        p_count++;
        my_turns.push_back('p');
        win_count++;
      } else {
        g_count++;
        my_turns.push_back('g');
      }
    } else {
      if (p_count < g_count) {
        p_count++;
        my_turns.push_back('p');
      } else {
        g_count++;
        lose_count++;
        my_turns.push_back('g');
      }
    }
  }

  cout << win_count - lose_count << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>

//#include <vector>

//#include <algorithm>

//#include <string>


using namespace std;

int main()
{
    int n;
    uint64_t ans = 0;

    cin >> n;

    for(int i = 1; i <= n; ++i)
    {
        if(!(i % 3) || !(i % 5))
            continue;
        ans += i;
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//??°?????????
		while(true){
			//??????H?????????
			int H = sc.nextInt();
			//??????W?????????
			int W = sc.nextInt();
			//?????¶??? W H?????¨??????0????????°??????
			if(H ==0 && W ==0){
				break;
			}
		//H?????§??????
		for(int i = 0; i<H;i++){
		//W?????§??????
			for(int j = 0; j<W; j++){
				//??¨???
				System.out.print("#");
			}//W?????????
			System.out.println();
		}//H?????????
		System.out.println();
		}
	}
}

Measured memory_bytes: 34736
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e14 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug() {
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long n, h = 0, ans = 0; cin >> n;
    string s; cin >> s;

    for(long long i = 0; i < n; i++) {
        if(s[i] == 'I') {
            h++;
        }
        else {
            h--;
        }
        ans = max(ans, h);
    }

    cout << ans;

    return 0;
}


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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  char C;
  std::cin >> C;
  std::cout << (char)(C + 1) << '\n';
}


Measured memory_bytes: 256
n=input()
a=map(int,raw_input().split())

INF=10**18

pr=[0]*(n+2)

pr[0]=1

for i in xrange(n+1):
	pr[i+1]=min(INF,(pr[i]-a[i])*2)

if pr[n+1]<0:
	print "-1"
	exit(0)

s=0
ans=0

for i in xrange(n,-1,-1):
	s=min(s+a[i],pr[i])
	ans+=s

print ans

Measured memory_bytes: 673744
n = int(input())
if n < 3:
  print(0)
else:
  s = str(input())
  r = 0
  g = 0
  b = 0
  for i in s:
    if i == "R":
      r += 1
    if i == "G":
      g += 1
    if i == "B":
      b += 1
  ans = r*g*b
  for i in range(n-2):
    for j in range(i+1,n-1):
      if 2*j-i > n-1:
        break
      if s[i] != s[j] and s[j] != s[2*j-i] and s[i] != s[2*j-i]:
        ans -= 1
print(ans)

Measured memory_bytes: 9200
package main

import (
        "fmt"
)

func solution(h1, m1, h2, m2, k int) int {
        return 60*(h2-h1) + (m2 - m1) - k
}

func main() {
        var h1, m1, h2, m2, k int
        fmt.Scan(&h1, &m1, &h2, &m2, &k)
        fmt.Println(solution(h1, m1, h2, m2, k))
}

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

for i in range(1, len(S)):
	T = S[:-2*i]
	if T[:len(T)//2] == T[len(T)//2:]:
		print(len(T))
		break

Measured memory_bytes: 5200
fn main() {
    let N: i128 = read_line().parse().expect("error");
    let mut cnt: i128 = 0;
    let mut S = Vec::new();
    loop {
        let s = read_line();
        S.push(s);
        cnt += 1;
        if cnt == N {
            break;
        }
    }
    let mut ac_cnt = 0;
    let mut wa_cnt = 0;
    let mut tle_cnt = 0;
    let mut re_cnt = 0;

    for s in &S {
        let ss = s.as_str();
        match ss {
            "AC" => ac_cnt += 1,
            "WA" => wa_cnt += 1,
            "TLE" => tle_cnt += 1,
            "RE" => re_cnt += 1,
            _ => {}
        }
    }
    println!("AC x {}", ac_cnt);
    println!("WA x {}", wa_cnt);
    println!("TLE x {}", tle_cnt);
    println!("RE x {}", re_cnt);
}
fn read_line() -> String {
    let s = {
        let mut s = String::new(); // バッファを確保
        std::io::stdin().read_line(&mut s).unwrap(); // 一行読む。失敗を無視
        s.trim_right().to_owned() // 改行コードが末尾にくっついてくるので削る
    };
    s
}


Measured memory_bytes: 7520
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
 
	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int K = input.nextInt();
		double[] p = new double[N];
		double[] exp = new double[N];
		double ans = 0.0;
		for (int i = 0; i < N; i++) {
			p[i] = input.nextDouble();
			exp[i] = (p[i]+1)*p[i]/2/p[i];
		}
		double StartSum = 0.0;
		for (int i = 0; i < K; i++) {
			StartSum+=exp[i];
		}
		ans=Math.max(ans, StartSum);
		for (int i = 1; i+K<=N; i++) {
			StartSum-=exp[i-1];
			StartSum+=exp[i+K-1];
			ans=Math.max(ans, StartSum);
		}
		System.out.println(ans);
	}	
}

Measured memory_bytes: 160584
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();
        ArrayList<Long> list = new ArrayList<>();
        list.add(a * c);
        list.add(a * d);
        list.add(b * c);
        list.add(b * d);
        System.out.println(Collections.max(list));
    }
}

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

int main(void){
    string str;
    cin >> str;
    int len = str.size();
    int t = len;
    
    bool flag;
    while (true) {
        if (len%2 == 0) {
            flag = true;
            for (int i=0; i<len/2; i++) {
                if (str[i] != str[len/2+i]) {
                    flag = false;
                    break;
                }
            }
            if (flag && len != t) {
                cout << len << endl;
                return 0;
            }
        }
        str.erase(len-1);
        len--;
    }
}


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

int main() {
    int N;
    cin >> N;
    vector<int> D1(N), D2(N);
    for (int i=0; i<N; i++) {
        cin >> D1[i] >> D2[i];
    }
    
    string ans = "No";
    for (int i=0; i<N-2; i++) {
        if (D1[i]==D2[i] and D1[i+1]==D2[i+1] and D1[i+2]==D2[i+2]) {
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int prime(int n)
{int c=0;int f=0;
for(int i=1;i*i<=n;i++)
{ if(n%i==0)
    c=c+2;
 if(c>2){f=1; return 0;}
}if(f==0)return 1;}
int main()
{
int n;cin>>n;int i;
  for(i=n;prime(i)!=1;i++)
  {}
    cout<<i;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long ll;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define MAX_V 100001
#define MOD 1000000007
typedef vector<vector<int> > Graph;

int main(){
    int x;cin>>x;
    int a=x/500;
    x%=500;
    int b=x/5;
    cout<<a*1000+b*5<<endl;
}


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

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
signed main(){
  double n,m,d;cin>>n>>m>>d;
  double mean=2*(n-d)/n/n*(m-1);
  if(d==0)mean/=2;
  printf("%.12lf\n",mean);
  return 0;
}


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

long long mod_nPr(long long n, long long r, long long mod) {
    if (n <= 0 || r <= 0)
        return 1;
    else {
        long long result = 1;
        for (int i = n; i > n-r; i--)
            result = (result * i) % mod;
        return result;
    }
}

// コンビネーションの計算(nCk)
long long modcom(long long n, long long k, long long mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    long long nPk = mod_nPr(n, k, mod);

    vector<long long> finv(k+1, 0), inv(k+1, 0);
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < k+1; i++){
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
    return nPk * finv[k] % mod;
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(void){
    ll mod = 1000000007;
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = modpow(2, n, mod);
    ans--;
    if (ans < 0)
        ans += mod;
    ans -= modcom(n, a, mod);
    if (ans < 0)
        ans += mod;
    ans -= modcom(n, b, mod);
    if (ans < 0)
        ans += mod;
    cout << ans;
}

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

int main(){
  int n;
  int d[110];
  cin >> n;
  for (int i = 0; i<n; i++) cin >> d[i];
  
  int num[110] = {0};
  for (int i = 0; i<n; i++){
    num[d[i]]++;
  }
  
  int res = 0;
  for (int i = 1; i <= 100; i++){
    if (num[i]) {
      res++;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
#define MAX 100001

ll mpow(ll x, ll n) {
    ll res = 1;
    while (n != 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n = n >> 1;
    }
    return res;
}
ll fac(ll i) {
    static ll fatorial[MAX + 1] = {0};

    if (fatorial[i])
        return fatorial[i];
    else if (i == 0)
        return fatorial[0] = 1;
    else
        return fatorial[i] = fac(i - 1) * i % mod;
}
ll ifac(ll i) {
    static ll ifactorial[MAX + 1] = {0};

    if (ifactorial[i])
        return ifactorial[i];
    else if (i == 0)
        return ifactorial[0] = 1;
    else
        return ifactorial[i] = ifac(i - 1) * mpow(i, mod - 2) % mod;
}
ll comb(ll a, ll b) {
    if (a == 0 && b == 0) return 1;
    if (a < b || a < 0) return 0;
    ll tmp = ifac(a - b) * ifac(b) % mod;
    return tmp * fac(a) % mod;
}

int main() {
    ll n, l = 0, c = 0, r = 0;
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n + 1; i++) {
        int a;
        cin >> a;
        if (mp.find(a) != mp.end()) {
            l = mp[a];
            c = i - mp[a] - 1;
            r = n - i;
        }
        mp[a] = i;
    }
    for (int k = 1; k <= n + 1; k++) {
        ll ans;
        ans = comb(n - 1, k);
        ans = (ans + 2 * comb(l + r + c, k - 1) - comb(l + r, k - 1) + mod) % mod;
        if (k > 1) ans = (ans + comb(l + r + c, k - 2)) % mod;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 8960
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int min = 1000000;
		int max = -1000000;
		long sum = 0;
		int n = sc.nextInt();
		for (int cnt = 1; cnt <= n; cnt++) {
			int a = sc.nextInt();
			if (cnt == 1) {
				min = a;
				max = a;
				sum = a;
			} else if (a <= min) {
				min = a;
				sum = sum + a;
			} else if (a >= max) {
				max = a;
				sum = sum + a;
			} else {
				sum = sum + a;
			}
		}
		System.out.println(min + " " + max + " " + sum);
	}
}


Measured memory_bytes: 41656
use proconio::input;

fn main() {
    input! {
        n: usize
    }
    let mut res = vec![0; n];
    for i in 1..=100 {
        for j in 1..=100 {
            for k in 1..=100 {
                let v = i*i + j*j + k*k + i*j + j*k + k*i;
                if v <= n { res[v-1] += 1 }
            }
        }
    }
    for &v in &res { println!("{}", v) }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> l(n);
  rep(i,n)cin>>l.at(i);
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  int ans = 0;
  rep(i,k)ans+=l.at(i);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LOOP(val, times)   for(val = 0; val < (times); val++)
using namespace std;

int main(){
    long long n,i,sum=0,min=1000000,max=-10000000;
    cin>>n;
    vector<int> vec(n);
    LOOP(i,n){cin>>vec.at(i);
             if(min>vec.at(i))min=vec.at(i);
             if(max<vec.at(i))max=vec.at(i);
             sum+=vec.at(i);}
    cout<<min<<" "<<max<<" "<<sum<<endl;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
 
/*** Template Begins ***/
 
typedef long long    ll;
typedef pair<ll,ll>  pll;
typedef pair<ll, pair<ll, ll> > plll;
typedef vector<long long>  vll;
typedef vector<pll>  vp;
typedef long double ld;
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
#define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define h         1000000000000000007LL
#define hell 1000000007LL
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p)
{
  ll res = 1;
  x = x % p;
  while (y > 0)
  { 
     if (y & 1) 
      res = (res*x) % p;
    y = y>>1;
    x = (x*x) % p;
  } 
  return res; 
} 
const int M = 1005;
const int N = 1005;
const long double PI = acos(-1);
// Debug //
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll euclid(ll x,ll y,ll a,ll b)
{
  return (a-x)*(a-x)+(b-y)*(b-y);
}
ll mod;
ll add(ll a,ll b)
{
  a%=mod;
  b%=mod;
  return (a+b)%mod;
}

ll sub(ll a,ll b)
{
  a%=mod;
  b%=mod;
  return (a-b+mod)%mod;
}
ll multiply(ll a,ll b)
{
  a%=mod;
  b%=mod;
  return (a*b)%mod;
}
ll inv(ll a)
{
  a = sub(a,0);
  return power(a,mod-2,mod);
}
//Constants // 
bool comp(ll a,ll b)
{
  return a>b;
}
void solve()
{ 
  string s,t,temp;
  cin>>s>>t;
  temp = t.substr(0,s.length());
  if(s==temp)
    cout<<"Yes";
  else
    cout<<"No";
}
int main()
{ 
  // sieve();
  ios;
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  ll t,i=1;
  t=1;
  // cin>>t;
  // preprocess();
  while(i<=t)
  {
    solve();
    i++;
  }
  return 0;
}

Measured memory_bytes: 3588
using System;


    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0].ToString());
            int b = int.Parse(input[1].ToString());

            int plus = a + b;
            int minus = a - b;
            int product = a * b;

            int max = Math.Max(plus, Math.Max(minus, product));
            Console.WriteLine(max);
        }
    }

Measured memory_bytes: 11092
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
ll dp[3000004];
void addself(ll &a,ll b)
{
	a=(a+b)%M;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    std::vector<ll> v[23];
    for (int i = 0; i < n; ++i)
    {
    	for (int j = 0; j < n; ++j)
    	{
    		ll a;
    		cin>>a;
    		v[i].pb(a);
    	}
    }
    dp[0]=1;
    for (int i = 0; i <=(1<<n)-1; ++i)
    {
    	ll x=__builtin_popcount(i);
    	for (int j = 0; j < n; ++j)
    	{
    		if(((1<<j)&i)==0 && v[j][x]==1)
    		{

    			addself(dp[(1<<j|i)],dp[i]);
    		}
    	}
    }
    cout<<dp[(1<<n)-1]<<'\n';
}


Measured memory_bytes: 18688
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	int n;
	int target[3];
	cin >> n >> target[0] >> target[1] >> target[2];
	int x[8];
	rep(i, n)cin >> x[i];

	int ans = INF;
	rep(i, 1<<2*n) {
		int s[4] = {};
		int c[4] = {};
		rep(j, n) {
			int b = (i >> 2 * j) & 3;
			s[b] += x[j];
			c[b]++;
		}
		if (c[0] == 0 || c[1] == 0 || c[2] == 0)continue;

		int sum = 0;
		rep(j, 3) {
			sum += abs(s[j] - target[j]);
			if (c[j] > 1)sum += 10 * (c[j] - 1);
		}
		ans = min(ans, sum); 
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define e "\n"
#define MaRiaMa { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
#define fix(n) cout << fixed << setprecision(n);
using namespace std;
int main()
{
	MaRiaMa;
	char ar[3][3];
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> ar[i][j];
		}
	}
	cout << ar[0][0] << ar[1][1] << ar[2][2];
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main () {
    long long K;
    cin >> K;
    vector<long long> list;
    for(int i = 1; i<=9; i++) {
        list.push_back(i);
    }
    while(1) {
        if(K <= list.size()) {
            cout << list[K - 1] << endl;
            return 0;
        }
        K -= list.size();
        vector<long long> before;
        swap(before, list);
        for(long long x : before) {
            for(int i = -1 ; i <= 1; i++) {
                long long tmp = x % 10 + i;
                if(tmp < 0 || tmp > 9) continue;
                list.push_back(x * 10 + tmp);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 98, M = 1e9 + 7;
ll f[N], fi[N];
void pre()
{
    f[0] = 1;
    for (int i = 1; i < N; ++i)
        f[i] = i * f[i-1] % M;
    fi[0] = fi[1] = 1;
    for (int i = 2; i < N; ++i)
        fi[i] = (M-M/i) * fi[M%i] % M;
    for (int i = 2; i < N; ++i)
        fi[i] = fi[i] * fi[i-1] % M;
}
ll C(int n,int k)
{
    return f[n] * fi[k] % M * fi[n-k] % M;
}
int main()
{
    pre();
    int n,m,a,b;
    cin >> n >> m >> a >> b;
    a = n - a;
    b--;
    --n,--m;
    ll ans = C(n+m,m);
    for (int i = a; i <= n; ++i) 
        ans -= C(b+i,i) * C(m-b-1 + n-i, n-i) % M;
    cout << (ans % M + M) % M << endl;
}


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

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

  set<int> su;

  for(int i = 0; i < k; i++){
      int d;
      cin >> d;
      for(int j = 0; j < d; j++){
          int a;
          cin >> a;
          su.insert(a);
      }
  }

  int cnt = 0;
  for(int i = 1; i <= n; i++){
      if(!su.count(i))
        cnt++;
  }
  cout << cnt << endl;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<string> str(n);
    ll ans = 0;
    ll endA = 0, stB = 0, both = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> str[i];
        endA += (str[i].back() == 'A');
        stB += (str[i].front() == 'B');
        both += (str[i].back() == 'A') && (str[i].front() == 'B');
        for (int j = 0; j < str[i].size() - 1; j++)
        {
            if (str[i][j] == 'A' && str[i][j + 1] == 'B')
            {
                ans++;
            }
        }
    }
    if (both > 1)
    {
        {
            ans += both - 1;
        }
        endA -= both;
        stB -= both;
        if (endA > 0)
        {
            ans++;
            endA--;
        }
        if (stB > 0)
        {
            ans++;
            stB--;
        }
        cout << ans + min(stB, endA) << endl;
    }
    else
    {
        cout << ans + min(endA, stB) << endl;
    }
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int dp[3][3];
for(int i=0;i<3;i++)
{
    for(int j=0;j<3;j++)
    {
        cin>>dp[i][j];
    }
}
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
    cin>>arr[i];
for(int i=0;i<n;i++)
{int ok=0;
    for(int j=0;j<3;j++)
    {
        for(int k=0;k<3;k++)
        {
            if(dp[j][k]==arr[i])
            {
                dp[j][k]=-1;

            }
        }

    }
}
int cnt=0;
vector<pair<int,int> > a;
for(int i=0;i<3;i++)
{int ok=1;
    for(int j=0;j<3;j++)
    {
        if(dp[i][j]!=-1)
          {
         ok=0;
          }
    }
    if(ok)
        cnt++;
}
for(int i=0;i<3;i++)
{int ok=1;
    for(int j=0;j<3;j++)
    {
        if(dp[j][i]!=-1)
        {
            ok=0;
        }
    }
    if(ok)
        cnt++;
}
int ok=1,ok1=1;
for(int i=0;i<3;i++)
{
    if(dp[i][i]!=-1)
        ok=0;
    if(dp[i][3-i-1]!=-1)
        ok1=0;
}

if(ok)
    cnt++;
if(ok1)
    cnt++;
    ///cout<<cnt<<endl;
if(cnt>=1)
{
    cout<<"Yes"<<endl;
}
else
{
    cout<<"No"<<endl;
}


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()
 
int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;}
int LCM(int a,int b){ return a*b / GCD(a,b) ;}
 
typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;
const int MOD = 1e9+7;

int main(){
      int n,m;cin >> n >> m;
      vector<int> switches(n);
      rep(i,m){
            int k;cin >> k;
            rep(j,k){
                  int s;cin >> s;s--;
                  switches[s] |= (1<<i);
            }
      }
      int p = 0;
      rep(i,m){
            int tmp;cin >> tmp;
            p |= (tmp<<i);
      }
      int ans = 0;
      for(int i=0;i<(1<<n);i++){
            int t = 0;
            for(int j=0;j<n;j++){
                  if((1<<j)&i)t ^= switches[j];
            }
            //cout << "i=" << i << endl;
            //cout << bitset<5>(t) << endl;
            //cout << bitset<5>(p) << endl;
            if(p==t)ans++;
      }
      cout << ans << endl;
      return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define itn int
#define REP(i,n) for(int i=0;i<(n);i++)
#define IREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(n);i++)
#define REPEACH(itr,k) for(auto&& itr : k)
#define MOD 1000000007

using namespace std;
typedef long long ll;

const ll INF = 1LL<<60;

int main(){
  int a,b;
  cin >> a >> b;
  int ans=max(a+b,a-b);
  ans=max(ans,a*b);
  cout << ans << endl;
}


Measured memory_bytes: 256
/*氏名：保坂優介, 学籍番号：200441141
  概要：*/

#include<stdio.h>
#include<math.h>

int main(void)
{
    int i, j, k, n, s[1000];

    scanf("%d", &n);

    while (n != 0)
    {
        double m = 0, a = 0;

        for (i = 0; i < n; i++)
        {
            scanf("%d", &s[i]);

            m = m + (double)s[i];
        }

        m = m / (double)n;
        
        for (i = 0; i < n; i++)
        {
            a = a + pow(((double)s[i] - m), 2);
        }

        a = sqrt(a / (double)n);

        printf("%lf\n", a);

        scanf("%d", &n);

    }

    return 0;
}


Measured memory_bytes: 2036
N, M = map(int, input().split())
E = {i:[] for i in range(N)}
mat = [[False for i in range(N)] for j in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    E[a].append(b)
    E[b].append(a)
    mat[a][b] = True
    mat[b][a] = True
cnt = 0
for i in range(N):
    if sum(mat[i]) == 1:
        while True:
            if len(E[i]) != 1:
                break
            j = E[i][0]
            E[i].remove(j)
            E[j].remove(i)
            cnt += 1
            i = j
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <vector>
#include <tuple>
#include <string>
#include <algorithm>

 
using namespace std;

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 100 + 5;
char s[MAXN];
ll n, t, k;

ll largest(ll a, ll b){
	return (a<b)?b:a;
}
ll smallest(ll a, ll b){
	if(a < b)return a;
	return b;
}


int main(){
	cin >> s >> k;
	bool isone = true;
	for(int i = 0; i < k; ++i){
		if(s[i] != '1'){
			isone = false;
			break;
		}
	}
	if(isone){
		cout << '1' << endl;
		return 0;
	}
	if(k == 1){
		cout << s[0] << endl;
		return 0;
	}
	for(int i = 0; i < strlen(s); ++i){
		if(s[i] != '1'){
			cout << s[i] << endl;
			return 0;
		}
	}
	cout << '1' << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main() {
    int i;
    char s[4] = {};
    char t[4] = {};
    int ans = 0;
 
    scanf("%s%s", s, t);
    for(i = 0; i < 3; i++){
        if(s[i] == t[i]) ans++;
    }
    printf("%d\n", ans);
 
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k;
    cin >> n >> k;
    vector<ll> cnt(k, 0);
    reps(i, 1, n + 1) cnt[i % k]++;
    ll ans = 0;
    rep(a, k) {
        ll b = (k - a) % k;
        ll c = (k - a) % k;
        if ((b + c) % k != 0) continue;
        ans += cnt[a] * cnt[b] * cnt[c];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
const p = console.log;
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

// [ 'CSS', 'CSR', '' ]
const a = input.split('\n');

const yohou = a[0].split('');
const kekka = a[1].split('');

let cnt = 0;

for(let i=0; i<yohou.length; i++){
    if(yohou[i] === kekka[i]){
        cnt++;
    }
}

p(cnt);


Measured memory_bytes: 30656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,int>mp;
vector<ll>v;
int main(){
  int n,k;cin>>n>>k;
  ll pre[n+2];
  pre[0]=0;
  for(int i=0;i<n;i++){
    ll a;cin>>a;v.push_back(a);
    pre[i+1]=pre[i]+a-1;
    pre[i+1]%=k;
  }
  mp[0]++;
  ll ans=0;
  for(int i=1;i<=n;i++){
    if(i>=k){
      mp[pre[i-k]]--;
    }
    ans+=mp[pre[i]];
    mp[pre[i]]++;
  }
  cout<<ans;
  return 0;
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define All(v) (v).begin(), (v).end()
#define Pb push_back

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

    ll a,b;
    cin >> a >> b;
    if(a%3==0 || b%3==0 || (a+b)%3==0){
        cout << "Possible" << "\n";
    }else{
        cout << "Impossible" << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x) do{rep(__i,(x).size()) pri(x,__i);}while(0)
#define pran(x,n) do{rep(__i,n) pri(x,__i);}while(0)
#define pral(x) do{cerr << (#x) << " =";rep(__i,(x).size()) cerr<<" "<<(x[__i]);cerr<<endl;}while(0)
#define prar(x,b,e) do{repr(__i,b,e) pri(x,__i);}while(0)

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

ll MOD = 1000000007;

function<void(int,int)> tensi_no_3p=[&](int v,int d){
};

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

int main() {
	int N = in();
	typedef pair<pint, int> Ten;
	vector<Ten> tt(N + N);
	rep(i, 2 * N) {
		int x = in();
		int y = in();
		int c = i < N ? 1 : 2;
		tt[i] = mp(mp(x, y), c);
	}
	sort(tt.begin(), tt.end());
	int ans = 0;
	rep(i, 2 * N) {
		if (tt[i].second == 2) {
			int ind = -1;
			int maxy = -1;
			rep(k, i) {
				int y = tt[k].first.second;
				if (tt[k].second == 1 && y > maxy && y < tt[i].first.second) {
					maxy = y;
					ind = k;
				}
			}
			if (ind >= 0) {
				ans++;
				tt[ind].first.second = INF;
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}


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

int main(void) {
    int n, t, s, e, ans = 0;
    cin >> n >> t;
    for (int i = 0; i < n; i++) {
        int in;
        cin >> in;
        if (i == 0) {
            s = 0;
            e = t;
        }
        else if (e >= in) {
            e = in + t;
        }
        else {
            ans += e - s;
            s = in;
            e = in + t;
        }
        if (i == n - 1) ans += e - s;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from collections import deque


from collections import deque

N, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N - 1)]
Y = [list(map(int, input().split())) for _ in range(Q)]

tree =[[] for _ in range(N + 1)]
for a, b in X:
    tree[a].append(b)
    tree[b].append(a)

ctr = [0] * (N + 1)
for p, x in Y:
    ctr[p] += x

ans = [0] * (N + 1)
ans[1] = ctr[1]
visited = [False] * (N + 1)
visited[1] = True
q = deque([1])
while q:
    u = q.popleft()
    for v in tree[u]:
        if not visited[v]:
            ans[v] = ans[u] + ctr[v]
            visited[v] = True
            q.append(v)

print(*ans[1:])


Measured memory_bytes: 182700
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

// UnionFind 構造体 for tree
type UnionFind struct {
	par []int
}

/*コンストラクタ*/
func newUnionFind(N int) *UnionFind {
	u := new(UnionFind)
	u.par = make([]int, N)
	for i := range u.par {
		u.par[i] = -1
	}
	return u
}
func (u UnionFind) root(x int) int {
	if u.par[x] < 0 {
		return x
	}
	u.par[x] = u.root(u.par[x])
	return u.par[x]
}
func (u UnionFind) unite(x int, y int) {
	xr := u.root(x)
	yr := u.root(y)
	if xr == yr {
		return
	}
	u.par[yr] += u.par[xr]
	u.par[xr] = yr
}
func (u UnionFind) same(x, y int) bool {
	if u.root(x) == u.root(y) {
		return true
	}
	return false
}
func (u UnionFind) size(x int) int {
	return -u.par[u.root(x)]
}

var mod int = 1000000007

type pair struct {
	fi int
	se int
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	//予備
	n := iScan()
	var (
		a, b, c, d int
	)
	d = n % 10
	c = (n%100 - d) / 10
	b = (n%1000 - c*10 - d) / 100
	a = n / 1000
	s1 := "+"
	s2 := "+"
	s3 := "+"
	for i := 0; i < 2; i++ {
		for j := 0; j < 2; j++ {
			for r := 0; r < 2; r++ {
				ans := a
				if i == 0 {
					ans += b
					s1 = "+"
				} else {
					ans -= b
					s1 = "-"
				}
				if j == 0 {
					ans += c
					s2 = "+"
				} else {
					s2 = "-"
					ans -= c
				}
				if r == 0 {
					ans += d
					s3 = "+"
				} else {
					ans -= d
					s3 = "-"
				}
				if ans == 7 {
					fmt.Printf("%d%s%d%s%d%s%d=7\n", a, s1, b, s2, c, s3, d)
					return
				}
			}
		}
	}
}

Measured memory_bytes: 1772
/*
* @Author: dnhirapara
* @Problem: abc171_d
* @Time: 07-September-2020 : ( 16:27:38 )
*/
#include <bits/stdc++.h>

using namespace std;

/************defination************/

#define endl "\n"
#define logger(x) cout << __LINE__ << ": " << #x << " -> " << (x) << endl;
#define ll long long int
#define ull unsigned long long int

//@time comp :
//@space comp :
int main()
{
    // ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    // cin.ignore(); must be there when using getline(cin, s)
    ll tc = 1;
    //cin >> tc;
    while (tc--)
    {
        ll n;
        cin >> n;
        vector<ll> fre(100005, 0);
        vector<ll> a(n);
        ll sum = 0;
        for (ll i = 0; i < n; i++)
        {
            cin >> a[i];
            fre[a[i]]++;
            sum += a[i];
        }
        ll q;
        cin >> q;
        while (q--)
        {
            ll b, c;
            cin >> b >> c;
            sum = sum - (fre[b] * b) + (fre[b] * c);
            fre[c] += fre[b];
            fre[b] = 0;
            cout << sum << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4848
#include <iostream>

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}

int solve(int k) {
  int ans = 0;
  for (int i = 1; i <= k; ++i) {
    for (int j = 1; j <= k; ++j) {
      int d1 = gcd(i, j);
      for (int c = 1; c <= k; ++c) {
        ans += gcd(d1, c);
      }
    }
  }
  return ans;
}

int main() {
  int k;
  std::cin >> k;
  std::cout << solve(k) << std::endl;
  return 0;
}


Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <utility>
#include <memory>
#include <sstream>
#include <complex>
#include <cassert>
#include <bitset>
#define rep(i, n) for(int i = 0; i < n; i++)
#define fi first
#define se second
using namespace std;
typedef long long int ll; typedef pair <int, int> P; typedef vector <int> vecint; typedef pair<int, P> P1; typedef pair<P, P> P2;
const int inf = 1000000000;
const ll INF = 9000000000000000000;
const double EPS = 10e-9;
int n;
ll a[10001], b[10001];
vecint ag, bg;
int main()
{
	cin >> n;
	rep(i, n)
	{
	    cin >> a[i];
	}
	rep(i, n)
	{
		cin >> b[i];
		if (a[i] > b[i]) ag.push_back(i);
		else if (b[i] > a[i])
		{
			if ((b[i] - a[i]) % 2) b[i]--;
			bg.push_back(i);
		}
	}
	int s = 0;
	rep(i, ag.size())
	{
		ll t = ag[i];
		ll dif = a[t] - b[t];
		while (dif > 0 && s != bg.size())
		{
			ll rest = b[bg[s]] - a[bg[s]];
			ll tmp = rest / 2;
			if (dif > tmp)
			{
				dif -= tmp;
				s++;
			}
			else if (tmp > dif)
			{
				a[bg[s]] += 2 * dif;
				dif = 0;
			}
			else
			{
				dif = 0;
				s++;
			}
		}
		if (s == bg.size() && dif > 0) { cout << "No" << endl; return 0; }
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s,t;
    cin >> s >> t;

    int sary[26];
    int tary[26];
    rep(i,26)
    {
      sary[i] = 0;
      tary[i] = 0;
    }
    rep(i, s.length())
    {
      sary[s[i]-'a'] ++;
      tary[t[i]-'a'] ++;
    }
    sort(sary, sary+26);
    sort(tary, tary+26);
    bool flag = true;
    rep(i,26)
    {
      if (sary[i] != tary[i])
      {
        flag = false;
        break;
      }
    }
    if (flag)
    {
      cout << "Yes" << endl;
    }
    else
    {
      cout << "No" << endl;
    }

    
}


Measured memory_bytes: 916
a, b, k = map(int,input().split())
if (b - a) < 2*k  :
    for i in range(a,b+1):
        print('{}'.format(i))
else:    
    for i in range(k):
        print('{}'.format(a+i))
    for i in range(1,k+1):
        print('{}'.format(b+i-k))
        

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

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] Ws = W.split(" ");

		W = in.readLine();
		String[] Ws2 = W.split(" ");
		int[] A = {Integer.parseInt(Ws2[0]),Integer.parseInt(Ws2[1])};
		W = in.readLine();

		if(W.equals(Ws[0])){
			A[0]--;
		}else{
			A[1]--;
		}

		System.out.println(A[0]+" "+A[1]);

	}


}


Measured memory_bytes: 21460
from collections import Counter
from math import ceil
N = int(input())
S = [input() for _ in range(N)]
a = []
s = S[0]
for i in range(1,N):
  s += S[i]
  s = ''.join([key*(min(val//2,s.count(key)-S[i].count(key))) for key,val in Counter(s).items() if val > 1])
s = sorted(s)
print(''.join(s))

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

using namespace std;

int main() {
	long long int N;
	cin >> N;
	vector<long long int>D( N );
	vector<long long int>idx( N );
	for( size_t i = 0; i < N; i++ ) {
		cin >> D[i];
		idx[D[i] - 1] = i;
	}
	long long int ans = 0;
	set<int>S;
	S.insert( N );
	S.insert( -1 );
	for( size_t i = 0; i < N; i++ ) {
		int now = idx[i];
		auto ite = S.upper_bound( now );
		int Mb = *ite-1;
		ite = S.lower_bound( now );
		ite--;
		int Ma = *ite+1;
		S.insert(now);
		//cout<<Ma<<" "<<Mb<<endl;
		ans += (i + 1)*(Mb - now + 1)*(now - Ma + 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 12800
import sys
for line in sys.stdin:
    n = line
    temp = []
    for i in line[:-1]:
        temp.append(int(i))
    n = temp
    while len(n) > 1:
        temp = []
        for i in range(len(n)-1):
            temp.append(int(str(n[i] + n[i+1])[-1]))
        n = temp
    print(n[0])


Measured memory_bytes: 5604