akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };

// const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
// const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int n;cin>>n;
  vector<ll> a(n);rep(i,n)cin>>a[i];
  sort(all(a));
  
  int ans = 0;
  ll size = 0;
  rep(i,n-1){
    size += a[i];
    if(size*2 >= a[i+1])ans++;
    else ans = 0;
  }
  ans++;
  print(ans);
  return 0;
}



Measured memory_bytes: 1024
s=input()
if s[0]=='A' and s[2:-1].count('C')==1:
    for i in range(len(s[2:-1])):
        if s[2:-1][i]=='C':
            ind=i+2
    ss=s[1:ind]+s[ind+1:]
    if ss==ss.lower():
        print('AC')
        exit()
print('WA')

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

typedef long long LL;

const double PI = acos(-1.0);

LL a, b, n;

int work() {
    scanf("%lld%lld%lld", &a, &b, &n);
    LL x = min(b-1, n);
    LL ans = a*x/b;
    printf("%lld\n", ans);
    return 0;
}

int main() {
    work();
    //while (~scanf("%d", &n)) work();
    //scanf("%d", &T); while (T--) work();

    return 0;
}


Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define MAX 510000
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    ll l = 0;
    ll r = 0;
    ll exor = 0;
    ll sum = 0;
    ll ans = 0;
    while(r != n){
        sum += a[r];
        exor ^= a[r];
        while(sum != exor){
            sum -= a[l];
            exor ^= a[l];
            l++;
        }
        r++;
        ans += r-l;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 79332
//AT5759
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>

#define LL long long
#define Cl(X,Y) memset((X),(Y),sizeof(X))
#define FOR(i,A,B) for(int i=A;i<=B;i++)
#define BOR(i,A,B) for(int i=A;i>=B;i--)
#define Lowbit(X) (X & (-X))
#define INF 0x3f3f3f3f
#define Rson (X<<1|1)
#define Lson (X<<1)
using namespace std;
const int MaxN=2e5+10;

int Num[MaxN],Dep[MaxN];
vector<int>Col[3];
vector<int>Loc[2];
int Next[MaxN<<1],Head[MaxN],End[MaxN<<1],Cur;
int Total,u,v,w;

inline void File() {
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
}

inline void Add_Edge(int From,int To) {
    Next[++Cur]=Head[From];
    Head[From]=Cur;
    End[Cur]=To;
}

inline void DFS(int New,int Pre) {
    Dep[New]=Dep[Pre]+1;
    Loc[Dep[New] & 1].push_back(New);
    for(int i=Head[New];i;i=Next[i]) {
        if(End[i]==Pre) continue;
        DFS(End[i],New);
    }
} 

inline void Solve(int L,int R) {
    while(Loc[L].size() && Col[R].size()) {
        Num[Loc[L].back()]=Col[R].back();
        Loc[L].pop_back(); 
        Col[R].pop_back();
    }
}

int main() {
    // File();
    scanf("%d",&Total);
    FOR(i,1,Total-1) {
        scanf("%d %d",&u,&v);
        Add_Edge(u,v);
        Add_Edge(v,u);
    }
    FOR(i,1,Total) Col[i%3].push_back(i);
    DFS(1,0);
    Solve(Loc[1].size()>Loc[0].size(),1);
    Solve(Loc[1].size()>Loc[0].size(),2);
    Solve(0,0); Solve(1,0);
    FOR(i,1,Total) printf("%d ",Num[i]);
    // fclose(stdin);
    // fclose(stdout);
   // system("pause");
    return 0;
}

Measured memory_bytes: 18500
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  ll x[2],y[2];
  cin >> x[0] >> x[1];
  cin >> y[0] >> y[1];
  ll ans = -LINF;
  REP(i,2) {
    REP(j,2) {
      ll v = x[i] * y[j];
      if (ans < v) ans = v;
    }
  }
  COUT(ans);

  return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>


int main(void)
{
	long int i, j;
	long int n, k;
	long int sum;
	long int max;
	long int count;
	long int flg;
	long int a[2000];
	
	scanf("%ld%ld", &n, &k);
	
	for(i = 0; i < n; i++) {
		scanf("%ld", &a[i]);
	}
	
	sum = 0;
	for(i = 0; i < n; i++) {
		for(j = 0; j < n; j++) {
			if(i != j) {
				if(a[i] < a[j]) {
					sum++;
				}
			}
		}
	}
	
	sum %= 1000000007;
	sum *= ( ( (k - 1) * k / 2) % 1000000007);
	sum %= 1000000007;
	
	count = 0;
	for(i = 0; i < n - 1; i++) {
		for(j = i + 1; j < n; j++) {
			if(a[i] > a[j]) {
				count++;
			}
		}
	}
	
	sum += ( (count * k) % 1000000007);
	sum %= 1000000007;
	
	printf("%ld\n", sum);
	
	return 0;
}


//185297239
//185297239
//845502410
//9223372036854775807
//19桁

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <cstdio>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll H,W,h,w;
    cin>>H>>W>>h>>w;
    cout<<H*W-W*h-((H-h)*w)<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();
			String ans = "";
			int test = (int)(n / 1.08d);
			if((int)(test * 1.08) == n) {
				ans = String.valueOf(test);
			} else if((int)((test + 1) * 1.08) == n) {
				ans = String.valueOf(test + 1);
			} else {
				ans = ":(";
			}
			System.out.println(ans);

		}

	}

}


Measured memory_bytes: 23636
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main() {
	string s, t;
	cin >> s;
	cin >> t;
	t = t.erase(t.size()-1);
	if(s == t){
		cout << "Yes" << endl;
	}else{
		cout << "No" <<endl;
	}
	return 0;
}


Measured memory_bytes: 3600
bingo = []
3.times { bingo << gets.split(' ').map(&:to_i) }
n = gets.to_i
ary = []
n.times { ary << gets.to_i }

tate1 = []
tate2 = []
tate3 = []
nana1 = []
nana2 = []

bingo.each.with_index(0) do |a,i|
  tate1 << a[0]
  tate2 << a[1]
  tate3 << a[2]
  nana1 << a[i]
  nana2 << a[2-i]
end

bingo << tate1
bingo << tate2
bingo << tate3
bingo << nana1
bingo << nana2

result = 'No'
bingo.each do |a|
  result = 'Yes' if a.all? { |i| ary.include?(i) }
end

puts result

Measured memory_bytes: 1788
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int N, M;
	cin >> N >> M;

	double sum = 0;

	vector<int> A(N);

	for (int i = 0; i < N; i++)
	{
		cin >> A.at(i);
		sum = sum + A.at(i);
	}

	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());

	if (A.at(M - 1) < sum / (4.0 * M))
	{
		cout << "No" << endl;
	}

	else
	{
		cout << "Yes" << endl;
	}
}

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

using namespace std;

int main() {
//    freopen("inp.inp", "r", stdin);
    int n, sum = 0;
    cin >> n;
    vector<int> a(n);
    for (int& i : a) {
        cin >> i;
        sum += i;
    }
    int dif = abs(n * a[0] - sum), ans = 0;
    for (int i = 1; i < n; ++i) {
        if (dif > abs(n * a[i] - sum )) {
            ans = i;
            dif = abs(n * a[i] - sum );
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
Z=[list(map(int,input().split())) for i in range(N)]
A,B=zip(*Z)
A=list(A[::-1])
B=list(B[::-1])
ans=0
for i in range(N):
  A[i]+=ans
  if A[i]%B[i]!=0:
    a=B[i]-(A[i]%B[i])
    ans+=a
print(ans)

Measured memory_bytes: 36084
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int 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;
}
void solve()
{
    int n;
    cin >> n;
    string s;
    while (n)
    {
        int c = n % 26;
        n = n / 26;
        char cc = 'a';
        if(c==0){
            c = 26;
            n--;
        }
        c--;
        while (c)
        {
            cc++;
            c--;
        }
        s += cc;
    }
    reverse(all(s));
    cout << s << endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    //cin >> tc;
    while (tc--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int d;
    int s;
    
    while(cin>>d){
        s=0;
        for(int i=1;i<=(600/d)-1;i++){
            s=s+d*(d*i)*(d*i);
        }
            cout<<s<<endl;
    }

}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
using namespace std;
typedef long long ll;

int main(void) {
    int c[4][3], i, j, tmp;
    for(i=0; i<3; i++)
        cin >> c[i][0] >> c[i][1] >> c[i][2];
    
    for(j=0; j<3; j++)
        c[3][j] = c[0][j];
        
    for(i=0; i<3; i++) {
        if(c[i][0]-c[i+1][0]!=c[i][1]-c[i+1][1] || c[i][1]-c[i+1][1]!=c[i][2]-c[i+1][2] || c[i][2]-c[i+1][2]!=c[i][0]-c[i+1][0]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int ans = Math.min(reader.nextInt(), reader.nextInt())+Math.min(reader.nextInt(), reader.nextInt());
        System.out.println(ans);
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 21076
module Main where--
import Control.Monad

solve :: [[Int]] -> Int -> Int -> Int
solve a 0 0 = (a !! 0) !! 0
solve a (-1) _ = 0
solve a _ (-1) = 0
solve a i j = (a !! i) !! j + (max (solve a (i-1) j) (solve a i (j-1)))

main :: IO ()
main = do
        n <- readLn
        a <- map (map read . words) <$> replicateM 2 getLine
--         putStrLn $ show $ (a :: [[Int]])
        putStrLn $ show $ solve a 1 (n-1)


Measured memory_bytes: 1020
loop do
  a, b, c = gets.split(' ')
  break if b == '?'
  a = a.to_i
  c = c.to_i
  ans =
  case b
  when '+' then a + c
  when '-' then a - c
  when '*' then a * c
  when '/' then a / c
  end
  puts ans
end

Measured memory_bytes: 8576
import math
from collections import Counter



def prime_factorization(num):
    """
    素因数分解
    ;param num 素因数分解したい数字
    ;return result {素因数: 回数, ・・・}
    """

    result = dict()

    N = num

    x = 2
    while x <= int(math.sqrt(num)) + 1:
        if (num % x) == 0:
            count = 0
            while (num % x) == 0:
                count += 1
                num = num / x

            result[x] = count

        x += 1

    if num != 1:
        result[num] = 1

    if result == []:
        result[N] = 1

    return result


N = int(input())

# 素因数分解
result = prime_factorization(N)

# 操作の回数を求める
ans = 0
for value in result.values():
    c = 1
    while (value - c) >= 0:
        ans += 1
        value -= c
        c += 1

print(ans)



Measured memory_bytes: 9492
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    int N;
    cin >> N;
    int x[N], y[N];
    for (int i = 0; i < N; i++)
    {
        cin >> x[i] >> y[i];
    }
    double d[N][N];
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (i == j)
            {
                d[i][j] = 0;
                continue;
            }
            d[i][j] = sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
        }
    }
    double sum = 0;
    int cities[N];
    for (int i = 0; i < N; i++)
    {
        cities[i] = i;
    }
    do
    {
        for (int i = 0; i + 1 < N; i++)
        {
            sum += d[cities[i]][cities[i + 1]];
        }
    } while (next_permutation(cities, cities + N));
    for (int i = 1; i <= N; i++)
    {
        sum /= i;
    }
    cout << fixed << setprecision(10) << sum << endl;
}


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

int main() {
  int n,ans=0;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  rep(i,n){
    cin >> a[i];
  }
  rep(i,n){
    cin >> b[i];
  }
  rep(i,n){
    cin >> c[i];
  }
  rep(i,n){
    ans += b[i];
  }
  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<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n;
  cin >> n;
  ll k[n];
  rep(i,n)cin >> k[i];
  ll ans=0;
  rep(i,n)ans=ans^k[i];
  rep(i,n){
    ll an=ans^k[i];
    cout << an;
    if(i!=n-1)cout << " ";
    else cout << endl;
  }
}


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

using namespace std;
using ll = long long;
using P = pair <int, int>;


int main() {
  int a, b, x;
  cin >> x >> a >> b;
  
  int rest = x-a;
  int otsuri = rest%b;
  
  cout << otsuri << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
arr = list(map(int , input().split()))
cur = 0
a = 0
b = 0
prea=0
preb=0
resa = 0
resb =0
# check independently even prefix having negative sum and odd prefix having positive sum
for i in range(0 , n):
	prea = prea+arr[i]
	if (i% 2 ==0 and prea<=0):
		resa = resa-prea+1
		prea=1
	if i%2 ==1 and prea>=0:
		resa = resa+prea+1
		prea=-1
# check independently even prefix having positive sum and odd prefix having negative sum
for i in range(0 , n):
	preb = preb+arr[i]
	if (i%2==1 and preb<=0):
		resb = resb+(-preb+1)
		preb=1
	if i%2 ==0 and preb>=0:
		resb =resb+ preb+1
		preb=-1
# find minimum of the two
print(min(resa , resb))

Measured memory_bytes: 85412
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
a=gi
b=gi
ans=[1,2,3]
ans.delete(a)
ans.delete(b)
puts ans[0]

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

using namespace std;

int main(){
    int N;
    while (cin >> N, N){
        int I[260];
        rep(i, N)cin >> I[i];
        int S, A, C;
        double h = 1e10;
        rep(s, 16){
            rep(a, 16){
                rep(c, 16){
                    int R = s;
                    int x[256] = { 0 };
                    rep(i, N){
                        R = (a*R + c) & 255;
                        int O = (I[i] + R) & 255;
                        x[O]++;
                    }
                    double H = 0;
                    rep(i, 256){
                        if (!x[i]) continue;
                        double t = 1.0*x[i] / N;
                        H -= (t*log(t));
                    }
                    if (H + 1e-9 < h){
                        h = H;
                        S = s;
                        A = a;
                        C = c;
                    }
                }
            }
        }
        cout << S << ' ' << A << ' ' << C << endl;
    }
}

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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;



int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll k;
	cin >> n >> k;
	
	map<int, int64_t> mp;
	rep(i,n){
		ll a,b;
		cin >>a >>b;
		mp[a] = mp[a] + (ll)b;
	}
	ll sm=0;
	for(auto x: mp){
		sm += x.second;
		if(sm >= k){
			cout << x.first <<"\n";
			return 0;
		}
	}
	
	//for(auto x :mp) cout <<x.first << "  "<<x.second; puts("");
	return 0;
}



Measured memory_bytes: 4224
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



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

	string S;
	cin >> S;
	int a = 0;
	rep(i, S.size()) {
		if (a == 0 && S[i] == 'C')a = 1;
		else if (a == 1 && S[i] == 'F')a = 2;
	}
	if (a == 2)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 764
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{

    public static void Main( )
    {
        int N = int.Parse( Console.ReadLine( ) );
        var A = Console.ReadLine( ).Split( ).Select( int.Parse ).ToArray( );
        int Q = int.Parse( Console.ReadLine( ) );

        var Count = new int[ 100001 ];
        long sum = 0;
        for ( int i = 0; i < N; i++ )
        {
            Count[ A[ i ] ]++;
            sum += A[ i ];
        }

        int B, C;
        long addition;
        for ( int i = 0; i < Q; i++ )
        {
            var input = Console.ReadLine( ).Split( ).Select( int.Parse ).ToArray( );
            B = input[ 0 ];
            C = input[ 1 ];
            addition = ( C - B ) * Count[ B ];
            Count[ C ] += Count[ B ];
            Count[ B ] = 0;
            sum += addition;
            Console.WriteLine( sum );
        }
    }

}






Measured memory_bytes: 51124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  int a;
  rep(i,5){
    cin >> a;
    if(a == 0){
      cout << i + 1<< endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3520
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        
        if((a*b) % 2 == 0){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 21844
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define LL long long
using namespace std;
const int maxn = 2020;
int a[maxn],x[maxn],y[maxn],z[maxn];
int main(void) {
//    freopen("e.in","r",stdin);
    int n,k,q; scanf("%d%d%d",&n,&k,&q);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]),x[i-1]=a[i];
    sort(x,x+n);
    int tot=unique(x,x+n)-x;
    int ans=1e9;
    for (int i=0;i<tot;i++) {
        int zz=0;
        for (int j=1,l=0;j<=n+1;j++) {
            if (j==n+1 || a[j]<x[i]) {
                sort(y,y+l);
                for (int u=0;u<l-k+1;u++) z[zz++]=y[u];
                l=0;
            } else y[l++]=a[j];
        }
        if (zz<q) continue;
        sort(z,z+zz);
        ans = min(ans, z[q-1]-z[0]);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,X,Y;
  cin >> N >> M >> X >> Y;
  
  vector<int>x(N);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i);
  }
  sort(x.begin(), x.end());
    
  vector<int>y(M);
  for (int i = 0; i < M; i++) {
    cin >> y.at(i);
  }
  sort(y.begin(), y.end());
  
  if (x.at(N-1) < y.at(0) && x.at(N-1) < Y && y.at(0) > X){
    cout << "No War" << endl;
  }
  else {
    cout << "War" << endl;
  }
}
     

Measured memory_bytes: 3552
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
  int N; cin >> N;
  vector<int> P(N);
  rep(i,N) cin >> P[i];

  unordered_map<int, int> dic;
  rep(i,N) {
    if (dic.count(P[i] - 1)) {
      int u = dic[P[i] - 1];
      dic.erase(P[i] - 1);
      dic.emplace(P[i],u+1);
    } else {
      dic.emplace(P[i],1);
    }
  }

  int ans = 0;
  for (auto i : dic) chmax(ans,i.second);

  cout << N - ans << endl;
}

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

class AGC002
{
    static void Main(string[] args) {
        var spl = Console.ReadLine().Split();
        long N = long.Parse(spl[0]);
        long L = long.Parse(spl[1]);
        var a = Console.ReadLine().Split();
        long idx = -1;
        long pre = long.Parse(a[0]);
        for (long i = 1; i < N; i++) {
            long now = long.Parse(a[i]);
            if (now + pre >= L) {
                idx = i - 1;
                break;
            }
            pre = now;
        }
        if (idx < 0) Console.WriteLine("Impossible");
        else {
            Console.WriteLine("Possible");
            for (long i = 0; i < idx; i++) {
                Console.WriteLine(i + 1);
            }
            for (long i = N-2; i >=idx; i--) {
                Console.WriteLine(i + 1);
            }
        }
    }
}

Measured memory_bytes: 16984
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <cassert>
#include <map>
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
#define ll long long
#define uniq(v) (v).erase(std::unique((v).begin(), (v).end()), (v).end())
constexpr ll MOD = 1e9 + 7;
ll gcd(ll a, ll b) {return b % a ? gcd(b % a, a) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
using namespace std;
using P = pair<ll, ll>;
using VI = vector<ll>;

VI v;

int main() {
    long a, b, k;
    cin >> a >> b >> k;
    for (long i = a; i < a + k; i++) {
        if (i <= b) v.push_back(i);
    }
    for (long i = b; i > b - k; i--) {
        if (i >= a) v.push_back(i);
    }
    sort(v.begin(), v.end());
    uniq(v);
    for (auto i: v) {
        cout << i << endl;
    }
}


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

int main() {
    int n; cin >> n;
    map<string, int> kind_num;
    int maxn = 1;
    set<string> ans;
    for (int i=0; i<n; i++) {
        string s; cin >> s;
        kind_num[s]++;
        if (kind_num[s] > maxn) {
            ans.clear();
            maxn = kind_num[s];
            ans.insert(s);
        }
        else if (kind_num[s] == maxn) {
            ans.insert(s);
        }
    }
    for (auto str: ans) {
        cout << str << endl;
    }
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define dbg(S) { int f=1; for(auto x:S) cerr<<(f?"[":", ")<<x, f=0; cerr<<"]\n"; }

using namespace std;

int main(){
	int n,m; cin>>n>>m;
	vector<vector<int>> G(n);
	rep(i,m){
		int u,v; cin>>u>>v; u--; v--;
		G[u].emplace_back(v);
		G[v].emplace_back(u);
	}

	bool ok=false;
	rep(u,n){
		bool b1=false,b2=false;
		for(int v:G[u]){
			if(v==  0) b1=true;
			if(v==n-1) b2=true;
		}
		if(b1 && b2) ok=true;
	}
	cout<<(ok?"POSSIBLE":"IMPOSSIBLE")<<endl;

	return 0;
}


Measured memory_bytes: 12016
#include <iostream>
#include <vector>
#include <math.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define PI 3.1415926535897932
using namespace std;

int main(){
	int A,B;
	int H,M;
	cin>>A>>B>>H>>M;
	long double AngleH = ((long double)H / 12.0 + ((long double)M/60)/12) * 2.0*PI;
	long double AngleM = ((long double)M / 60.0) * 2.0*PI;
	long double Angle = (long double)abs(AngleH-AngleM);

	
	long double distance = sqrt((long double)(A*A + B*B - 2*A*B*cos(Angle)));
	printf("%20.20Lf\n",distance);
}

Measured memory_bytes: 4080
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  int x[10][10] = {0};
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    x[a][b] = 1;
    x[b][a] = 1;
  }
  vector<int> v;
  for (int i = 2; i <= n; i++) {
    v.push_back(i);
  }
  int ans = 0;
  do {
    bool flag = true;
    if (x[1][v[0]] != 1) {
      flag = false;
    }
    for (int i = 1; i < n - 1; i++) {
      if (x[v[i - 1]][v[i]] != 1) {
        flag = false;
      }
    }
    if (flag) {
      ans++;
    }
  } while (next_permutation(v.begin(), v.end()));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    int slime[101];
    int ans = 0;

    cin >> n;

    for (int i = 0; i < n; i++) cin >> slime[i];

    for (int i = 1; i < n; i++) {
        if (slime[i] == slime[i-1]) {
            ans++;
            slime[i] = -1;
        }
    }

    cout << ans << endl;
}


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

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  vector<int> h(n);
  int bi, ah;
  for(int i = 0; i < n; i++){
    cin >> x[i] >> y[i] >> h[i];
    if(h[i] > 0){
      bi = i;
    }
  }
  for(int i = 0; i <= 100; i++){
    for(int j = 0; j <= 100; j++){
      bool check = true;
      ah = h[bi] + abs(i-x[bi]) + abs(j-y[bi]);
      for(int k = 0; k < n; k++){
        if(h[k] > 0 && ah - h[k] != abs(i-x[k]) + abs(j-y[k])){
          check = false;
        }
        if(h[k] == 0 && ah > abs(i-x[k]) + abs(j-y[k])){
          check = false;
        }
      }
      if(check){
        cout << i << " " << j << " " << ah << endl;
        return 0;
      }
    }
  }
  
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    double a, b, x;
    cin >> a >> b >> x;
    if (x <= a * a * b / 2.0) {
        cout << fixed << setprecision(10) << atan(a * b * b / 2.0 / x) * 180 / acos(-1) << endl;
    } else {
        cout << fixed << setprecision(10) << atan(2.0 * b / a - 2.0 * x / a / a / a) * 180 / acos(-1) << endl;
    }
}

Measured memory_bytes: 4020
# -*- coding: utf-8 -*-

# 1行読んで整数化
N, M, C = map(int, input().split())

# Bは長さが不定なので1行読んで整数化しリストにする
B = list(map(int, input().split()))

# 内包表記で1行読んで整数化しリストにしたものをさらにリストにする
A = [list(map(int, input().split())) for n in range(N)]

# A[i] を渡すと正解かどうか判定する関数
def isAC(a):
  v = C
  for m in range(M):
    v += a[m] * B[m]
  return v > 0

# すべてのソースコードに対して正解かどうか判定し、正解ならカウント
count = 0
for i in range(N):
  if (isAC(A[i])):
    count += 1

# 最後にカウントを出力
print(count)

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif

signed main() {

    int n;
    cin >> n;
    set<int> s;
    rep(i,n){
        int d;
        cin >> d;
        s.insert(d);
    }
    cout << s.size() << endl;
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        var N_M = new List<string>(Console.ReadLine().Split(' ')).Select(ele => Int32.Parse(ele)).ToList();
        int N = N_M[0];
        int M = N_M[1];

        List<int>[] K = new List<int>[N];
        for(int Count = 0;Count < N; Count++) {
            K[Count] = new List<string>(Console.ReadLine().Split(' ')).Select(ele => Int32.Parse(ele)).ToList<int>();
        }

        foreach (var l in K)
            l.RemoveAt(0);

        var result = new List<int>();

        bool Flag;
        for(int Count = 1;Count <= M; Count++) {
            Flag = true;
            foreach(var list in K) {
                if (!list.Contains(Count)) {
                    //WriteLine(Count);
                    Flag = false;
                    break;
                }
            }
            if (Flag) result.Add(Count);
        }

        WriteLine(result.Count());
        /*
        foreach (int x in result)
            Write(x + " ");

    */
        Console.ReadLine();
    }
}


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

#define ll long long
#define ull unsigned long long
#define mod 1e9+7
#define INF 1 << 30
#define MAX (1 << 20)
#define NINF (-(1 << 30))
#define triplet pair<pair<int, int>, int>

const int maxs = 2000;
ll fact[maxs];

ll power(ll base, ll p, ll pr){
    ll ans = 1;

    if(base == 1)
        return 1;

    if(base == 0)
        return 0;

    while(p){
        if(p&1)
            ans = (ans*base)%pr;

        base = (base*base)%pr;
        p >>= 1;
    }

    return ans;
}

ll invMod(ll num) {
    return power(num, mod-2, mod);
}

ll nCk(ll n, ll k) {
    return (fact[n] * invMod((fact[n-k] * fact[k]) % ( (ll) mod))) % ( (ll) mod);
}

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

    int s;

    cin >> s;

    int maxm = s / 3;

    ll ans = 0;
    fact[0] = 1;

    for (int i = 1; i < maxs; i++) {
        fact[i]= (fact[i-1] * i) % ((ll)mod);
    }

    for( int i = 1; i <= maxm; i++ ) {
        int num = s - (i << 1);
        ans = (ans + nCk(num-1, i-1)) % ( (ll) mod);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)



int main() {
	string s, t;
	map<char, ll> ms, mt;
	bool flg = false;
	in(s);
	in(t);
	
	rep(i, 0, s.size() - t.size()+1 ) {
		ms.clear();
		mt.clear();
		flg = true;
		rep(j, 0, t.size()) {
			if (ms[s[i + j]] == mt[t[j]]) {
				if (ms[s[i + j]] == 0) {
					ms[s[i + j]] = mt[t[j]] = j+1;
				}
			}
			else {
				flg = false;
			}
		}
		if (flg) {
			outn("Yes");
			return 0;
		}
	}


	outn("No");

	return 0;

}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll r, c, n; cin >> r >> c >> n;

  vector<vector<P>> p(4, vector<P>());

  rep(i, n) {
    V x(2), y(2);
    Vbo b(2);
    rep(j, 2) {
      cin >> x[j] >> y[j];
      b[j] = (x[j] == 0 || x[j] == r || y[j] == 0 || y[j] == c);
    }
    if (b[0]&&b[1]) rep(j, 2) {
      if (x[j] < r && y[j] == 0) p[0].emplace_back(x[j], i);
      if (x[j] == r && y[j] < c) p[1].emplace_back(y[j], i);
      if (x[j] > 0 && y[j] == c) p[2].emplace_back(x[j], i);
      if (x[j] == 0 && y[j] > 0) p[3].emplace_back(y[j], i);
    }
  }

  sort(all(p[0]));
  sort(all(p[1]));
  sort(all(p[2]), greater<P>());
  sort(all(p[3]), greater<P>());

  stack<int> st;
  Vbo seen(n, false);

  rep(i, 4) for (auto &e : p[i]) {
    int k = e.second;
    if (seen[k]) {
      if (st.top() == k) {
        st.pop();
      }
      else {
        cout << "NO" << "\n";
        return 0;        
      }
    }
    else {
      st.push(k);
      seen[k] = true;
    }
  }

  cout << "YES" << "\n";
  return 0;
}


Measured memory_bytes: 2520
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int main()
{
	vector<vector<int>> c(3, vector<int>(3));

	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> c.at(i).at(j);
		}
	}

	vector<int> a(3), b(3);

	a.at(0) = c.at(0).at(0);
	for (int i = 0; i < 3; i++)
	{
		b.at(i) = c.at(0).at(i) - a.at(0);
	}

	a.at(1) = c.at(1).at(1) - b.at(1);
	a.at(2) = c.at(2).at(2) - b.at(2);

	bool ok = true;
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			if (a.at(i) + b.at(j) != c.at(i).at(j))
			{
				ok = false;
				break;
			}
		}

		if (!ok)
		{
			break;
		}
	}

	cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
N,X,Y,Z=map(int,input().split())
mod=10**9+7
forbit=(1<<(X+Y+Z -1 )) +(1<<(Y+Z -1 ))+(1<<(Z -1 ))
mask = ((1<<(X+Y+Z)) -1)
s=set()
for i in range(mask+1):
    if i & forbit:
        s.add(i)
dp=[[0]*(mask+1) for i in range(N+1)]
dp[0][0]=1
for n in range(1,N+1):
    for i in range(mask+1):
        #if i in s:
            #continue
        for k in range(10):
            t=((i <<(k+1)) | 1<<k) & mask
            #if t in s:
                #continue
            if (t & forbit) == forbit:
                continue
            dp[n][t]+=dp[n-1][i]
            dp[n][t]%=mod
ans=pow(10,N,mod)
for i in range(mask+1):
    #if i in s:
        #continue
    ans-=dp[N][i]
    ans%=mod
print(ans)

Measured memory_bytes: 89064
A, B = [int(i) for i in input().split()]

c = 0
for i in range(A,B+1):
	c += (i % 10 == (i - i % 10000)/10000)*(((i % 10000)-(i%1000))/1000 == (i%100 - i % 10)/10)

print(c)

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

int gcdf(int a,int b)
{
	return(b==0?a:gcdf(b,a%b));
}
int gcd(int a,int b){
	return(a>b?gcdf(a,b):gcdf(b,a));
}

int main(){
	
	int a,b;
	
	while(cin>>a>>b)
		cout<<gcd(a,b)<<endl;
}

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

int main(void){
    int n;
    cin >> n;
    
    int s[100];
    int sum = 0;
    int i;
    for(i = 0; i < n; i++){
        cin >> s[i];
        sum += s[i];
    }
    
    if(sum % 10 != 0){
        cout << sum << endl;
    }else{
        sort(s, s + n);
        i = 0;
        while(i < n && s[i] % 10 == 0){
            i++;
        }
        if(i != n){
            cout << sum - s[i] << endl;
        }else{
            cout << 0 << endl;
        }
    }
    
    return 0;
}


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

using namespace std;

int main(){
    int n,ans=0;
    cin >> n;
    string s;
    cin >> s;
    for(int i=0;i<(n-2);i++){
        if(s[i]=='A'){
            if(s[i+1]=='B' && s[i+2]=='C'){
                ans+=1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256