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

class Dice
{
    
    public int [] dice=new int [6];
    
    
    public Dice()
    {
        
    }
    
    public Dice(int [] saikoro)
    {
        this.dice=saikoro;
    }
    
    public void kaiten(char keyword)
    {
        if(keyword=='N')
        {
            int a=dice[0];
            dice[0]=dice[1];
            dice[1]=dice[5];
            dice[5]=dice[4];
            dice[4]=a;
        }
        if(keyword=='S')
        {
            int a=dice[0];
            dice[0]=dice[4];
            dice[4]=dice[5];
            dice[5]=dice[1];
            dice[1]=a;
        }
        if(keyword=='W')
        {
            int a=dice[0];
            dice[0]=dice[2];
            dice[2]=dice[5];
            dice[5]=dice[3];
            dice[3]=a;
        }
        if(keyword=='E')
        {
            int a=dice[0];
            dice[0]=dice[3];
            dice[3]=dice[5];
            dice[5]=dice[2];
            dice[2]=a;
        }
        if(keyword=='R')
        {
            int a=dice[1];
            dice[1]=dice[3];
            dice[3]=dice[4];
            dice[4]=dice[2];
            dice[2]=a;
        }
        if(keyword=='A')
        {
            int a=dice[1];
            dice[1]=dice[4];
            dice[4]=a;
            a=dice[2];
            dice[2]=dice[3];
            dice[3]=a;
        }
    }
    
}


public class Hello{
    public static void Main(){
        //saikoro2.SequenceEqual(d.dice)
        
        int kaisu=int.Parse(Console.ReadLine());
        int [] saikoro=new int [6];
        List<int[]>list=new List <int[]>();
        Dice d=new Dice();
        
        for(int i=0;i<kaisu;i++)
        {
            saikoro=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            list.Add(saikoro);
        }
        
        string str="SSSSESSSSESSSSESSSSERSSSSASSSSR";
        bool an=true;
        for(int i=0;i<kaisu;i++)
        {
            int [] dice1=list[i];
            for(int j=i+1;j<kaisu;j++)
            {
                Dice dd=new Dice(list[j]);
                foreach(char ch in str)
                {
                    dd.kaiten(ch);
                    if(dice1.SequenceEqual(dd.dice))
                    {
                        Console.WriteLine("No");
                        an=false;
                        goto END;
                    }
                }
            }
        }
        
        int [] dic=list[kaisu-1];
        Dice ddd=new Dice(list[0]);
        foreach(char ch in str)
        {
            ddd.kaiten(ch);
            if(dic.SequenceEqual(ddd.dice))
            {
                Console.WriteLine("No");
                an=false;
                goto END;
            }
        }
        
        if(an==true)Console.WriteLine("Yes");
        
        END:
        ;
        
    }
}


Measured memory_bytes: 20428
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ABC149A
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var S = NS;
            var T = NS;
            Console.WriteLine(T + S);
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
}


Measured memory_bytes: 12640
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int N;cin>>N;
    vector<pair<string,int>> as;
    int fa[N];
    REP(i,N){
        string s;
        int a;
        cin>>s>>a;
        as.push_back(make_pair(s,a));
    }
    REP(i,N){
        int score=1;
        REP(y,N){
            if(i!=y){
                if(as[i].first>as[y].first){
                    score++;
                } else if(as[i].first==as[y].first){
                    if(as[i].second<as[y].second){
                        score++;
                    }
                }
            }
        }
        fa[score-1]=i;
    }
    REP(i,N){
        cout<<fa[i]+1<<endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#define tmp 123456 * 2 + 1
int main(void)
{
	int f1, f2, n, cnt, *SL;
	SL = new int [tmp];

	for(f1 = 0; f1 <= tmp; f1++)
	{
		SL[f1] = 1;
	}
	SL[1] = 0;
	for(f1 = 2; f1 * f1 <= tmp; f1++)
	{
		if(SL[f1] == 1){
			for(f2 = f1 * 2; f2 <= tmp; f2 += f1)
			{
				SL[f2] = 0;
			}
		}
	}
	while(scanf("%d",&n) && n > 0)
	{
		cnt = 0;
		for(f1 = n+1; f1 <= n * 2; f1++)
		{
			if(SL[f1] == 1)
				cnt++;
		}
		printf("%d\n",cnt);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

ll R[300100];
int S[100100];
int T[100100];
int Ch[100100];

int main(){
    int N, C;
    cin >> N >> C;
    map<pair<int, int>, int> ma;
    REP(i,N){
        int s, t, c;
        cin >> s >> t >> c;
        s *= 2;
        t *= 2;
        c--;
        ma[make_pair(t, c)] = i;
        S[i] = s;
        T[i] = t;
        Ch[i] = c;
        R[s-1]++;
        R[t]--;
    }

    REP(i,N){
        int s = S[i];
        int c = Ch[i];
        pair<int, int> p = make_pair(s, c);
        if(ma.find(p) != ma.end()){
            R[s-1]--;
            R[s]++;
        }
    }

    ll ans = R[0];
    for(int j = 1; j < 300100; j++){
        R[j] += R[j-1];
        ans = max(ans, R[j]);
    }

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


Measured memory_bytes: 9984
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    k = II()
    x = II()
    y = II()
    ans = 0
    for i in range(n):
        if i >= k:
            ans += y
        else:
            ans += x
    print(ans)
    return

#B
def B():
    w = S()
    d = defaultdict(int)
    for s in w:
        d[s] += 1
    for di in d.values():
        if di % 2:
            print("No")
            return
    print("Yes")
    return

#C
def C():
    n, a = LI()
    x = LI()
    sumx = [0] * n
    for i in range(n):
        sumx[i] = sumx[i - 1] + x[i]
    dp = [[[0] * (n+1) for i in range(sumx[-1] + 1)] for i in range(n)]
    for i in range(n):
        dp[i][x[i]][1] = 1
    for i in range(1, n):
        for s in range(sumx[i] + 1):
            for k in range(1, i + 2):
                if  s >= x[i]:
                    dp[i][s][k] += dp[i - 1][s - x[i]][k - 1]
                dp[i][s][k] += dp[i - 1][s][k]
    ans = 0
    for i in range(1, n + 1):
        if a * i > sumx[-1]:
            break
        ans += dp[-1][a * i][i]
    print(ans)
    return

# D
# 解説AC
# 2 <= b <= √n
# までに関しては全探索すればよくて
# ここで解がない場合はそれ以上を見る 
# √n < b <= n
# に関してはb進数表記で2桁になることが確定してて
# n = p*b+qとするなら p + q = s で(1 <= p < b, 0 <= q < b)
# n = p*b+q >= p*b > p**2 → √n > p がわかるからpを全探索
# b = (n-s)/p + 1なのでpを決めればbが決まってあとは調べればいい
# 数学じゃんこれ！ 
def D():
    def f(b, n):
        if n < b:
            return n
        return f(b, n // b) + (n % b)
    n, s = IR(2)
    if n == s:
        print(n + 1)
        return
    for b in range(2, int(math.sqrt(n)) + 1):
        if s == f(b, n):
            print(b)
            return
    for p in range(int(math.sqrt(n)), 0, -1):
        b = (n - s) // p + 1
        if b <= 1:
            continue
        if s == f(b, n):
            print(b)
            return
    print(-1)
    return


#Solve
if __name__ == '__main__':
    D()


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

int main(){
    long long n,ans=0;
    cin>>n;
    while(n>=5){
        if(n>=500){
            ans+=(n/500)*1000;
            n=n%500;
        }if(n>=5){
            ans+=(n/5)*5;
            n=n%5;
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<map>

using namespace std;

class vec{
  int size;
  map<int,int> m;
public:
  vec(int s){size=s;}
  vec(){}
  int &atUninitCheck(int pos){
    if(pos<0 || pos>=size) throw "out of range";
    if(m.find(pos)==m.end()) throw "uninit";
    return m[pos];
  }
  int &atRangeCheck(int pos){
    if(pos<0 || pos>=size) throw "out of range";
    return m[pos];
  }
};

void parse_dec(const string &str,map<string,vec> &m){
  char buff[100];
  int size;
  sscanf(str.c_str(),"%[^\[][%d]",buff,&size);
  //cout << buff << "[" << size << "]" << endl;
  m[string(buff)]=vec(size);
}

int parse_ass1(const string &str,map<string,vec> &m){
  //with uninit check
  if(isdigit(str[0])) return atoi(str.c_str());
  else{
    char buff[100];
    char buff2[100];
    sscanf(str.c_str(),"%[^\[][%[^]]",buff,buff2);
    return m[string(buff)].atUninitCheck(parse_ass1(buff2,m));
  }
}

void parse_ass(const string &str,map<string,vec> &m){
  string str1,str2;

  int pos=str.find("=");
  str1=str.substr(0,pos);
  str2=str.substr(pos+1);

  //cout << str1 << " = " << str2 << endl;

  char buff[100];
  char buff2[100];
  sscanf(str.c_str(),"%[^\[][%[^]]",buff,buff2);
  //cout << buff << "[" << parse_ass1(string(buff2),m) << "] = " << parse_ass1(str2,m) << endl;
  int right=parse_ass1(str2,m);
  m[string(buff)].atRangeCheck(parse_ass1(string(buff2),m))=right;
}

int main(){
  int ans=0;
  string str;

  map<string,vec> m;

  while(cin >> str){
    ans++;
    if(str=="."){
      if(ans == 1) break;
      cout << 0 << endl;
      m.clear();
      ans=0;
    }

    try{
      //cout << "parsing ... : ";
      if(str.find("=")==string::npos){
	//declaration
	//cout << "declaration" << endl;
	parse_dec(str,m);	
      }else{
	//assignment
	//cout << "assignment" << endl;
	parse_ass(str,m);
      }
    }catch(const char *s){
      //cout << "error : " << s << endl;
      cout << ans << endl;
      ans = 0;
      m.clear();
      while(cin >> str, str!=".");
    }
  }
  
  return 0;
}

Measured memory_bytes: 1072
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional;

void main() {
  auto N = readln.split[0].to!int;
  auto h = readln.split.to!(int[]);

  h ~= 0;

  auto res = 0;
  while(h.reduce!max > 0) {
    foreach(i; 0..N) {
      if(h[i] > 0) {
        h[i]--;
        if(h[i+1] == 0) res++;
      }
    }
  }
  res.writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
typedef pair<int,int>P;
 
int main() {
  ll a,b,small,large,ans,modint;
  cin>>a>>b;
  small=min(a,b);
  large=max(a,b);
  modint=1000000007;
  if(large-small>=2){
    cout<<0<<endl;
  }
  else{
    if(a==b){
      ans=2;
      for(ll i=a;i>0;i--){
        ans*=i;
        if(ans>=modint){
          ans%=modint;
        }
        ans*=i;
        if(ans>=modint){
          ans%=modint;
        }
      }
      cout<<ans<<endl;
    }
    else{
      ans=large;
      for(ll j=small;j>0;j--){
        ans*=j;
        if(ans>=modint){
          ans%=modint;
        }
         ans*=j;
        if(ans>=modint){
          ans%=modint;
        }
      }
      cout<<ans<<endl;
    }
  }
}

Measured memory_bytes: 256
using System;
namespace ino{
    class Ino{
        static void Main(){
            int dekai = (int)1e7;
            string[] n_k = Console.ReadLine().Split(' ');
            int n = int.Parse(n_k[0]);
            int k = int.Parse(n_k[1]);
            char[] s = Console.ReadLine().ToCharArray();
            int[] changes = new int[dekai];
            int j = 1;
            changes[0] = 0;
            for(int i=1;i<n;i++){
                if(s[i]!=s[i-1]){
                    changes[j] = i;
                    j++;
                }
            }
            int[] x = new int[j];
            for(;j<dekai;j++){
                changes[j] = n;
            }
            for(int i=0;i<x.Length;i++){
                if(s[changes[i]]=='0'){
                    if(i==0){
                        x[i] = changes[2*k];
                    }else{
                        x[i] = changes[i+2*k] - changes[i-1];
                    }
                }else{
                    x[i] = changes[i+1+2*k] - changes[i];
                }
            }
            int ans = 0;
            for(int i=0;i<x.Length;i++){
                if(x[i]>ans)ans = x[i];
            }
            Console.WriteLine(ans);
        }
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    B.at(i) = A.at(i) - i - 1;
  }
  sort(B.begin(), B.end());
  int k = B.at(N / 2);
  long long int ans = 0;
  for (int i = 0; i < N; i++) ans += abs(B.at(i) - k);
  cout << ans << endl;
}

Measured memory_bytes: 1792
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int a = 0;
  int b = 0;

  rep(i,3)
  {
    int n;
    cin >> n;

    if ( n == 5)
    {
      a++;
    }
    else if (n == 7)
    {
      b++;
    }
  }

  if(a == 2 && b == 1)
    cout << "YES" << endl;
  else
  {
      cout << "NO"<<endl;
  }
  


  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	int N;
	cin >> N;
	int arr[N+1];
	arr[0]=0;
	for(int i=1;i<N+1;i++) {
		cin >> arr[i];	
	}
	int counter = 0;
	for(int i=1;i<N+1;i++) {
		if(arr[arr[i]]==i) {
			counter++;
		}
	}
	cout << (counter/2);
	return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
from collections import defaultdict
abc = [tuple(map(int,input().split())) for i in range(n-1)]
es = [[] for i in range(n)]
for a,b,c in abc:
    a,b = a-1,b-1
    es[a].append((b,c))
    es[b].append((a,c))

q, k = map(int, input().split())
xy = [tuple(map(int,input().split())) for i in range(q)]

dist = [-1]*n

def dfs(v=0,parent=-1,d=0):
    for next_v,dd in es[v]:
        if dist[next_v] == -1:
            dist[next_v] = d + dd
            dfs(next_v,v,dist[next_v])

dist[k-1] =0
dfs(k-1,-1,0)
ans=[]
for x,y in xy:
    x,y=x-1,y-1
    ans.append(dist[x]+dist[y])

print(*ans,sep='\n')


Measured memory_bytes: 181008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long A, long long P){
   P += A * 3;
   cout << P/2 << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long P;
    scanf("%lld",&P);
    solve(A, P);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
//#include <iomanip> : 表示桁数, ex) cout << fixed << setprecision(15) << ...
//#include <unordered_set>

#define pi 3.14159265358979323846
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using ld = long double;
using Byte = unsigned char;
using namespace std;

//string ans = "Yes";

int power2(int x) {
	int ans = 1;
	rep(i, x) ans *= 2;
	return ans;
}

int SetAns() {
	int H = 0, W = 0, K = 0;
	int ans = 0;
	cin >> H >> W >> K;
	vector<string> s(H);
	rep(i, H) cin >> s[i];


	rep(isH, power2(H)) rep(isW, power2(W)) {
		vector<string> tmps = s;
		rep(h, H) rep(w, W) {
			//isH と isWに従いTMPSを書き換える
			if (((isH >> h) & 1) == 1) rep(i, W) tmps[h][i] = '.';
			if (((isW >> w) & 1) == 1) rep(i, H) tmps[i][w] = '.';
		}

		//tmpsを検討する
		int count = 0;
		rep(h, H) rep(w, W) {
			if (tmps[h][w] == '#') count++;
		}
		if (count == K) ans++;
	}
	return ans;
}

int main() {

	cout << SetAns() << endl;
	return 0;
}


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

    //long long
    using ll = long long;

    // pair<int, int>
    using PII = pair<int, int>;

    //最大値、mod
    const int MOD = 1000000007;
    const int INF = 1000000000;
    const long long LINF = 1e18;

    //出力系
    #define print(x) cout << x << endl
    #define prints(x) cout << fixed << setprecision(10) << x << endl
    #define printc(x) cout << setw(2) << setfill('0') << x << endl;
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

    //for
    #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

    //最大公約数 
    unsigned gcd(unsigned a, unsigned b) {
      if(a < b) return gcd(b, a);
      unsigned r;
      while ((r=a%b)) {
        a = b;
        b = r;
      }
      return b;
    }

    // 最小公倍数
    unsigned lcm(unsigned a, unsigned b){
        return a / gcd(a, b) * b; 
    }

    // a = max(a, b), a = min(a, b)
    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 dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};









int main(){
  string S;
  cin >> S;
  int n = S.length();
  ll ans = 0;
  for(int i = 0; i < (1 << (n - 1)); i++){
    string target = "";
    target += S.at(0);
    for(int j = 0; j < n - 1; j++){
        if(i & 1 << j) target += '+';
        target += S.at(j + 1);
    }
  int pos = 0;
  while(target.find('+', pos) != string::npos){
    int nextpos = target.find('+', pos);
    ans += stoll(target.substr(pos, nextpos - pos));
    pos = nextpos + 1;
  }

    ans+= stoll(target.substr(pos));

  }

  print(ans);
  return 0;

}

Measured memory_bytes: 256
'use strict'

const INF = 900719925474099;
function mapint(temp){
    return temp.split(' ').map((v)=>parseInt(v));
}

function lower_bound(d,a,b,e){
    for(var c;1<b-a;)
        d[c=0|(a+b)/2]<e ? a=c : b=c;
    return d[a]<e?b:a
};

const MOD = 1000000007;

function Main(input){
    let s = input.trim();
    let f = true;
    if(s[0]===s[1]) f=false;
    if(s[1]===s[2]) f=false;
    if(s[2]===s[3]) f=false;

    if(f) console.log('Good');
    else  console.log('Bad');
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  string s; cin >> s;

  
  if(s[s.size()-1] == 's') {
    s += "es";
  } else {
    s += "s";
  }


  cout << s << endl;

}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3716
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;

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;}

#define P (1'000'000'007)

signed main() {
    capi(n);
    string s;
    cin >> s;

    rep(i, s.size()) {
        cout << (char)('A' + (s[i] - 'A' + n) % 26);
    }

    return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
vector<ll> kaijo;
ll pow(ll x,ll y){
  if(y==0) return 1;
  ll ret=pow(x,y/2);
  ret*=ret;
  ret%=mod;
  if(y%2==1) ret*=x;
  ret%=mod;
  return ret;
}
void set_kj(ll n){
  kaijo.push_back(1);
  for(ll i=1;i<=n;i++) kaijo.push_back(kaijo[i-1]*i%mod);
}
ll nCr(ll n,ll r){
  ll ret=kaijo[n];
  ret*=pow(kaijo[r],mod-2);
  ret%=mod;
  ret*=pow(kaijo[n-r],mod-2);
  ret%=mod;
  return ret;
}
int main(){
  ll n,a,b,c;
  cin>>n>>a>>b>>c;
  set_kj(2*n);
  ll ans=pow(a+b,n*2)%mod;
  ans*=(100-c);
  ans%=mod;
  ans=pow(ans,mod-2)%mod;
  ll ans2=0;
  for(ll m=n;m<n*2;m++){
    ll kans=(pow(a,n)*pow(b,m-n))%mod;
    kans+=(pow(a,m-n)*pow(b,n))%mod;
    kans%=mod;
//    cout<<kans<<"/";
    kans*=m*100;
    kans%=mod;
//    cout<<kans<<"/";
    kans*=nCr(m-1,n-1);
    kans%=mod;
//    cout<<kans<<"/";
    kans*=pow(a+b,n*2-m);
    kans%=mod;
    //cout<<m<<" "<<kans<<" "<<(kans*ans)%mod<<endl;
    ans2+=kans;
    ans2%=mod;
  }
  cout<<(ans2*ans)%mod<<endl;
}


Measured memory_bytes: 2420
#include <cstdio>
#include <cmath>
//factorize
using namespace std;
int k = 0;
int A[100000]={};
//?????????2??????root x ?????§????´???°??????????????±?????\?????????
int is_prime(int x) {
	//x????´???°??????????????????????????????
	if (x<2) return 0;
	if (x==2) return 1;
	if (x%2==0) return 0;
	for (int i=3;i*i <= x;i++) {
	if (x%i == 0) return 0;
	}
	return 1;
}

void prime_in(int x) {
	for (int i=2;i*i<=x;i++) {
	if (is_prime(i)) {
	A[k]=i;
	 k++;
	}
	}	
}

int main(){
	int n;
	scanf("%d",&n);
	prime_in(n);	//root 12?????§?????±????´???°?????????????????????
	printf("%d:",n);
	int i = 0;
	
	while (n != 1)  {
	if (is_prime(n)) {
	printf(" %d",n);
	break;
	}
	if (n % A[i] == 0) {
	printf(" %d",A[i]);
	n /= A[i];
	}
	else i++;
	}
	printf("\n");
	

	return 0;
}

Measured memory_bytes: 2760
from collections import Counter
N = int(input())
A_s = list(map(int,input().split()))
ruiseki = [0]
for i,a in enumerate(A_s):
    ruiseki.append(ruiseki[i]+a)
counter = Counter(ruiseki)


answer = 0
for k,v in counter.items():
    if v > 1:
        answer += v * (v-1)//2
print(answer)

Measured memory_bytes: 121836
/*
author: Apoorv Singh
*/

#include <bits/stdc++.h>
using namespace std;

typedef vector <int> vi;
typedef vector <long long> vl;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
#define ll long long
#define pb push_back   
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " " << (x) << endl;
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second

ll modulo = 1e9 + 7;

template <class X>

void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}

ll fpow(ll a, ll n)
{
    ll ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin >> n >> k;
    ll dp[n];
    FOR(i,0,n)
    	dp[i] = LLONG_MAX;
    dp[0] = 0;
    int arr[n];
    FOR(i,0,n)
    	cin >> arr[i];
    FOR(i,0,n)
    {
    	FOR(j,1,k+1)
    	{
    		if (i+j < n)
    			dp[i+j] = min(dp[i+j], abs(arr[i+j]-arr[i]) + dp[i]);
    	}
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1408
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let s: String = read();
    for (i, c) in s.chars().enumerate() {
        if (i + 1) % 2 == 0 {
            if c == 'R' {
                println!("No");
                return;
            }
        } else {
            if c == 'L' {
                println!("No");
                return;
            }
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
long long int __lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
 //__gcd 最小公約数
 //__lcm 最大公倍数

int main() {
  long long int a,b,k;
  cin>>a>>b>>k;
  int c=0;
  for(int i=__gcd(a,b);i>0;i--){
    if(__gcd(a,b)%i==0)
      c++;
    if(c==k){
      cout<<i;
      break;
      }
    }
  }

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<stdio.h>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (b % a == 0)
		cout << a + b << endl;
	else
		cout << b - a << endl;
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	int d[n];
	rep(i, n) cin >> d[i];
	
	sort(d, d + n);
	
	cout << d[n / 2] - d[n / 2 - 1] << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






ll D[51][51];
int N, A[50], B[50];
//---------------------------------------------------------------------------------------------------
int check() {
    rep(i, 0, 51) rep(j, 0, 51) D[i][j] = infl;
    rep(i, 0, 51) D[i][i] = 0;
    rep(i, 0, 51) rep(j, 1, 51) {
        ll c = 1;
        rep(k, 0, j) c *= 2;
        chmin(D[i][i % j], c);
    }
    rep(k, 0, 51) rep(i, 0, 51) rep(j, 0, 51) D[i][j] = min(D[i][j], D[i][k] + D[k][j]);

    rep(i, 0, N) if (D[A[i]][B[i]] == infl) return 1;
    return 0;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) cin >> B[i];

    if (check()) {
        printf("-1\n");
        return;
    }

    ll ans = 0;
    vector<int> use;
    rrep(dig, 50, 1) {
        rep(i, 0, 51) rep(j, 0, 51) D[i][j] = infl;
        rep(i, 0, 51) D[i][i] = 0;
        rep(i, 0, 51) rep(j, 1, dig) {
            ll c = 1;
            rep(k, 0, j) c *= 2;
            chmin(D[i][i % j], c);
        }
        rep(i, 0, 51) fore(j, use) {
            ll c = 1;
            rep(k, 0, j) c *= 2;
            chmin(D[i][i % j], c);
        }
        rep(k, 0, 51) rep(i, 0, 51) rep(j, 0, 51) D[i][j] = min(D[i][j], D[i][k] + D[k][j]);

        int ng = 0;
        rep(i, 0, N) if (D[A[i]][B[i]] == infl) ng = 1;
        if (ng) {
            ll c = 1;
            rep(i, 0, dig) c *= 2;
            ans += c;
            use.push_back(dig);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	int a,b,d,i,j;
	char c[6]="ABCDE";
	scanf("%d %d",&a,&b);
	while(a!=0 && b!=0){
		j=0; d=a+b;
		for(i=1;i<5;i++){
			scanf("%d %d",&a,&b);
			if(a+b>d){
				d=a+b; j=i;
			}
		}
		printf("%c %d\n",c[j],d);
		scanf("%d %d",&a,&b);
	}
	return 0;
}

Measured memory_bytes: 2692
# intervals on the tree
N = int(input())
ans = 0
for _ in range(N-1):
    a, b = map(int, input().split())
    a, b = min(a, b), max(a, b)
    ans -= (N+1-b)*(a)
for i in range(1, N+1):
    ans += i*(i+1)//2
print(ans)

Measured memory_bytes: 69848
N = int(input())
A = [int(x) for x in input().split()]

def F(A, sgn):
  cnt = 0
  cum = 0
  for a in A:
    sgn *= -1
    cum += a
    if cum * sgn > 0:
      continue
    if sgn > 0:
      cnt += 1 - cum
      cum = 1
    else:
      cnt += cum + 1
      cum = -1
  return cnt

answer = min(F(A,1), F(A,-1))
print(answer)

Measured memory_bytes: 14332
S = input()
T = input()
M = len(S)
N = len(T)
dp = [[0] * (N + 1) for i in range(M + 1)]

for i in range(M):
    for j in range(N):
        if S[i] == T[j]:
            dp[i + 1][j + 1] = dp[i][j] + 1
        else:
            dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])

M = i
N = j
ans = ''
while i + 1 > 0 and j + 1 > 0:
    if dp[i + 1][j + 1] == dp[i][j + 1]:
        i -= 1
    elif dp[i + 1][j + 1] == dp[i + 1][j]:
        j -= 1
    else:
        ans = S[i] + ans
        i -= 1
        j -= 1
    
print(ans)

Measured memory_bytes: 112220
//============================================================================
// Name        : JOI.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;


// 1. dp?????????
int dp[201][201];
// 2. n????????????
int d,n;
int a[201],b[201],c[201],t[201];
// ???. calc????????????
int calc(int k,int m){

	// 8. dp???????????°??????
	if(dp[k][m]>=0)return dp[k][m];
	if(t[m]<a[k]||t[m]>b[k])return -1;
	for(int i=1; i<n+1; ++i){
		if(calc(i,m-1)>=0)dp[k][m]=max(dp[k][m],abs(c[k]-c[i])+calc(i,m-1));
	}
	return dp[k][m];

}

int main() {

	cin>>d>>n;

	// 3. ?????????
	for(int i=0;i<201;++i){
		for(int j=0;j<201;++j){
			dp[i][j]=-1;
		}
	}
	// 4.??\???
	for(int i=1; i<d+1; ++i)cin>>t[i];
	for(int j=1; j<n+1; ++j)cin>>a[j]>>b[j]>>c[j];

	// 5. ???????????¨??????

	for(int j=1; j<n+1; ++j){
		if(t[1]>=a[j]&&t[1]<=b[j]){
			dp[j][1]=0;
		}
	}

	// 6. ??????

	int total=0;
	for(int i=1;i<n+1;++i){
		total=max(total,calc(i,d));
	}
	cout<<total<<endl;
	return 0;
}

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

int main()
{
    string s;
    int count = 0;

    cin >> s;

    for (auto ite = s.begin(); ite != s.end(); ite++)
    {
        if ('o' == *ite)
        {
            count++;
        }
    }

    cout << 700 + count * 100 << endl;;
    
    return 0;
}


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

mini = float("inf")

cnt = 0

for i in range(n):
    mini = min(mini,abs(a[i]))
    if a[i] < 0:
        cnt+=1
    a[i] = abs(a[i])

if cnt % 2 == 1:
    print(sum(a) - mini * 2)
else:
    print(sum(a))

Measured memory_bytes: 64752
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int count = 0;
		for(int x = 0; x <= k; x++) {
			for(int y = 0; y <= k; y++) {
				int z = s - (x + y);
				if (z >= 0 && z <= k) {
					count++;
				}
			}
		}
		System.out.println(count);
		sc.close();
	}
}

Measured memory_bytes: 21844
def binary_search(num_list,target):
    first = 0
    last  = len(num_list)-1
    mid   = len(num_list)//2

    while first <= last:
        if   num_list[mid] == target:
            return 1
        elif num_list[mid] >  target:
            last = mid-1 
        elif num_list[mid] <  target:
            first = mid+1
        mid = (first+last)//2
    return 0

n = input()
num_list    = list(map(int,input().split()))
q = input()
target_list = list(map(int,input().split()))
ans = 0

for target in target_list:
    ans += binary_search(num_list,target)
print(ans)



Measured memory_bytes: 16712
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

int main(void) {
    u64 N;
    cin >> N;

    vector<u64> A(N);
    vector<u64> B(N);

    for(u64 n=0; n<N; n++) {
        cin >> A[n] >> B[n];
    }

    sort(A.begin(), A.end(), less<u64>());
    sort(B.begin(), B.end(), greater<u64>());

    if(N % 2) {
        u64 mdn = N / 2;
        u64 mdn_l = A[mdn];
        u64 mdn_r = B[mdn];
        cout << mdn_r - mdn_l + 1 << endl; 
    } else {
        u64 mdn = N / 2 - 1;
        long double mdn_l = (long double)(A[mdn] + A[mdn+1]) / 2;
        long double mdn_r = (long double)(B[mdn] + B[mdn+1]) / 2;
        cout << (u64)((mdn_r - mdn_l + 0.5) * 2) << endl;
    }

    return 0;
}

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

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

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

    int x, y;
    cin>>x>>y;

    cout<<x + y / 2<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;
//#define local
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    int n,left=0,right,up,down=0;
    cin>>right>>up>>n;
    for(int i=0; i<n; i++)
    {
        int x,y,a;
        cin>>x>>y>>a;
        if(a==1&&x>left) left=x;
        if(a==2&&x<right) right=x;
        if(a==3&&y>down) down=y;
        if(a==4&&y<up) up=y;
    }
    if(left>=right||down>=up) cout<<'0'<<endl;
    else cout<<(right-left)*(up-down)<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np

input = sys.stdin.buffer.readline


def primes_np(n):
    is_prime = np.ones(n + 1, dtype=bool)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if not is_prime[i]:
            continue
        is_prime[i * 2:n + 1:i] = False
    return np.where(is_prime)[0].tolist()


N = int(input())
A = tuple(map(int, input().split()))
MAX = 10 ** 6


def pairwise(A):
    table = [0] * (10 ** 6 + 1)
    for a in A:
        table[a] += 1
    for p in primes_np(MAX):
        ct = 0
        for i in range(p, MAX + 1, p):
            ct += table[i]
        if ct > 1:
            return False
    return True


def setwise(A):
    return np.gcd.reduce(A) == 1


if pairwise(A):
    print('pairwise coprime')
elif setwise(A):
    print('setwise coprime')
else:
    print('not coprime')


Measured memory_bytes: 122544
N,M=map(int,input().split())
buf = []
for i in range(N):
  buf.append(list(map(int,input().split())))
buf.sort()
ans, distance = 0, M
for b in buf:
  if(b[1] < distance):
    distance -= b[1]
    ans += b[0]*b[1]
  else:
    ans += b[0]*distance
    break
print(ans)

Measured memory_bytes: 27760
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n; cin >> n;
  vector<ll> t(n);
  rep(i, n) cin >> t[i];
  int m; cin >> m;
  vector<pair<int, int>> v(m);
  rep(i, m){
    int a, b; cin >> a >> b;
    v[i] = make_pair(a, b);
  }
  ll sum  = 0;
  sum = accumulate(t.begin(), t.end(), 0);
  for(int i = 0; i < m; i++){
    cout << sum-t[v[i].first-1]+v[i].second << endl;
  }
  system("pause");
}

Measured memory_bytes: 504
N,Y = (int(i) for i in input().split())

for x in range(N+1):
  for y in range(N+1-x):
    if 10000 * x + 5000 * y + 1000 * (N-x-y) == Y:
      print(str(x)+' '+str(y)+' '+str(N-x-y))
      exit()
print('-1 -1 -1')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int sol = 0;
    for (int i = 0; i < 3; ++i)
        sol += (s[i] == '1');
    cout << sol;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
	
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
	
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]
    
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    
    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N,M=map(int, input().split())
flag=0

uf = UnionFind(N)

for anvoannavsn in range(M):
	A,B=map(int, input().split())
	uf.union(A-1,B-1)


print(-min(uf.parents))


# 2darray [[0] * 4 for i in range(3)]
# import itertools

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(auto& i: A) cin >> i;

  auto S = accumulate(begin(A), end(A), 0);
  auto dp = bitset<4000001>().set(0);
  for(auto i: A) dp |= dp << i;
  for(auto i = (S+1)/2; i <= S; ++i) if(dp.test(i)) {cout << i << endl; break;}
}


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

int main()
{
	long long k;
	cin>>k;
	queue<long long> q;
	for(int i=1;i<=9;i++)
		q.push(i);
	while(!q.empty())
	{
		long long x=q.front();
		q.pop();
		k--;
		if(k==0)
		{
			cout<<x;
			break;
		}		
		for(int y=(x%10)-1;y<=(x%10)+1;y++)
		{
			if(y<0||y>=10)
				continue;
			q.push(x*10+(long long)y);
		}
	}
	return 0;
}

Measured memory_bytes: 1792
from collections import deque
S = input()
Q = int(input())
R = deque(S)
rev = 0

for i in range(Q):
    T = input().split()
    if T[0] == '1':
        rev += 1
    else:
        if T[1] == '1':
            if rev % 2 == 0:
                R.appendleft(T[2])
            else:
                R.append(T[2])
        else:
            if rev % 2 == 0:
                R.append(T[2])
            else:
                R.appendleft(T[2])
ans = ''.join(R)
if rev % 2 ==0:
    print(ans)
else:
    print(ans[::-1])

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;

    REP(i,n){
        REP(j,n){
            if(i*4+j*7==n){
                YES;
                return 0;
            }
        }
    }

    NO;
    return 0;
}


Measured memory_bytes: 256
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    string s;
    cin>>s;
    if(s[1]=='B')
    cout<<"ARC";
    else
    {
      cout<<"ABC";
    }
    
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10620
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int L=sc.nextInt();
		int ans=0;
		if(0<=L){ans=(2*L+N)*(N-1)/2;}
		if(0>=L+N-1){ans=(2*L+N-2)*(N-1)/2;}
		if(L<= 0 &&  0<=L+N-1){ans=(2*L+N-1)*(N)/2;}
		
		System.out.println(ans);

	
	}
}

Measured memory_bytes: 21844