akhauriyash/Code-Regression huggingface dataset:
"use strict";

function isOdd(num) {
  return num % 2 !== 0 ? true : false;
}

function divisor(num) {
  let curDiv = 1;
  let divi = num;
  let i = isOdd(num) ? 3 : 2;
  while (i < divi) {
    divi = num / i;
    if (num % i === 0) {
      curDiv = i;
    }
    i++;
  }
  return curDiv;
}

function main(input) {
  input = parseInt(input.split("\n")[0]);
  let divis = divisor(input);
  console.log(divis - 1 + input / divis - 1);
}

main(require("fs").readFileSync("/dev/stdin", "UTF-8"));


Measured memory_bytes: 23752
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    d = defaultdict(int)
    a = [int(x) for x in input().split()]
    for e in a:
        d[e] += 1
    m = int(input())
    t = [int(x) for x in input().split()]
    for e in t:
        if d[e]:
            d[e] -= 1
        else:
            print("NO")
            return
    print("YES")
    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

1 + k



"""


Measured memory_bytes: 53720
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<deque>
#include<map>
#include<set>

using namespace std;

int main(){
  int N, la = 0, lb = 0, a, b;
  cin >> N;
  for( int i = 0; i < N; i++ ){
    cin >> a >> b;
    if( a > la ){
      la = a;
      lb = b;
    }
  }
  cout << la+lb << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
class Fib:
  def __init__(self):
    self.memo = {}
  def calc(self, n):
    if n == 1 or n == 2:
      self.memo[n] = 1
      return 1
    if n <= 0:
      self.memo[n] = 0
      return 0
    if n in self.memo.keys():
      return self.memo[n]
    self.memo[n] = self.calc(n - 1) + self.calc(n - 2)
    return self.memo[n]
sys.setrecursionlimit(200000)
N, M = map(int, input().split())
ans = 1
mod = 10 ** 9 + 7
pre = -1
for i in range(M):
  a = int(input())
  if a == 1:
    pre = a
    continue
  if a == pre + 1 and pre != 0:
    print(0)
    sys.exit()
  ans *= Fib().calc(a - pre - 1) % mod
  pre = a
ans *= Fib().calc(N - pre) % mod
print(ans % mod)

Measured memory_bytes: 549856
#include <stdio.h>

int main(void){
	int i, N, a, b, c;
	
	scanf("%d", &N);
	
	for(i = 0; i < N; i++){
		scanf("%d %d %d", &a, &b, &c);
		if(a * a + b * b == c * c){
			printf("YES\n");
		}else if(b * b + c * c == a * a){
			printf("YES\n");
		}else if(c * c + a * a == b * b){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int solve(){
  int x,y;cin>>x>>y;
  cout << x + y/2 << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
// By Atul Rathore

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

#define ll long long int
#define f(n) for(int i=0;i<n;i++)
#define p(x) cout<<x<<endl;
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007



int main()
{
	fastio;
	int n;
	cin>>n;
	set<string> s;
	f(n)
	{
		string x;
		cin>>x;
		s.insert(x);
	}
	cout<<s.size();
	
	
	
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<P, int> PPI;

#define INF 1e15

#define MAX_N 1000

struct edge
{
	ll to,dist,cost;
};

int n,m;
vector<edge> g[11111];
ll d[11111],cc[11111];

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n>>m;
		if(n==0)break;
		rep(i,n)g[i].clear();
		rep(i,m){
			ll a,b,c,dd;
			cin>>a>>b>>c>>dd;
			a--; b--;
			g[a].push_back((edge){b,c,dd}); g[b].push_back((edge){a,c,dd});
		}
		priority_queue<P,vector<P>,greater<P> > que;
		que.push(P(0,0));
		ll res=0;
		rep(i,11111)d[i]=cc[i]=INF;
		d[0]=0;
		cc[0]=0;
		while(que.size()){
			ll np=que.top().se,nc=que.top().fi;
			que.pop();
			if(d[np]<nc)continue;
			res+=cc[np];
			rep(i,g[np].size()){
				edge& e=g[np][i];
				if(d[np]+e.dist<d[e.to]){
					d[e.to]=d[np]+e.dist;
					cc[e.to]=e.cost;
					que.push(P(d[e.to],e.to));
				}else if(d[np]+e.dist==d[e.to]){
					minch(cc[e.to],e.cost);
					//dbg(cc[e.to]);
				}
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 6708
#include<iostream>
using namespace std;
int main(void){
  int a,b,c;
  cin >> a >> b >>c;
  
  int nokori;
  nokori = c - a + b;
  if(nokori < 0){
    nokori = 0;
  }
  cout << nokori << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip> 
using namespace std; 
#define rep(i,a,b)		for(long int i=a;i<=b;i++)
#define MOD 1e9+7

int x,y,z;
int main() 
{ 
	ios::sync_with_stdio(false);
    cin.tie(NULL);  
    
    
	cin>>x>>y>>z;
	x-=z;
	cout<<x/(y+z);
}
	

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

int main()
{
	int n, m;
	cin >> n >> m;
	auto v = vector<bool>(n + 1);
	bool ans = false;
	for(auto i = 0; i < m; ++i){
		int a, b;
		cin >> a >> b;
		if(b == n) swap(a, b);
		if(a == 1 || a == n){
			if(v[b]){
				ans = true;
			}
			v[b] = true;
		}
	}
	cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct cc
{
	int x,y;
	bool operator<(cc w)const{return x<w.x;}
}pos[200007];
vector<int> ans;
int main()
{
	int x1,y1,x2,y2,x,y,n,xs=1,ys=1,m=0;
	scanf("%d%d",&x1,&y1);
	scanf("%d%d",&x2,&y2);
	if(x1>x2)xs=-1,x1*=-1,x2*=-1;
	if(y1>y2)ys=-1,y1*=-1,y2*=-1;
	scanf("%d",&n);
	for(int i=0;i<n;++i)
	{
		scanf("%d%d",&x,&y);
		x*=xs,y*=ys;
		if(x<x1||x2<x||y<y1||y2<y)continue;
		pos[++m]={x,y};
	}
	sort(pos+1,pos+m+1);
	for(int i=1;i<=m;++i){
		int v=pos[i].y;
		if(!ans.size()||v>ans[ans.size()-1])ans.push_back(v);
		else *std::lower_bound(ans.begin(),ans.end(),v)=v;
	}
	double val=0;
	if(std::min(y2-y1,x2-x1)+1==ans.size()){
		val+=10*acos(-1)-20;
		ans.pop_back();
	}
	val+=(y2-y1+x2-x1)*100.-(20-acos(-1)*5)*ans.size();
	printf("%.15f",val);
	return 0;
}

Measured memory_bytes: 2936
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

using ll=long long; 
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>; 

#define LLINF ((long long)1e18)
#define INF int(1e9+1e6)
#define MAXN (106)
ll n,dist[MAXN],mx[MAXN];
vector<int>v[MAXN];
int main(){
	FAST
	cin>>n;
	FOR(i,0,n-2){
		ll a,b;cin>>a>>b;
		v[a].eb(b),v[b].eb(a);
	}
	auto bfs=[&](vector<ll> s){
		queue<ll> q;
		mmst(dist,-1);
		for(auto i:s) dist[i]=0, q.emplace(i);
		while(q.size()){
			ll x=q.front();
			q.pop();
			for(auto i:v[x]) if(dist[i]==-1) dist[i]=dist[x]+1, q.emplace(i);
		}
		return max_element(dist+1, dist+n+1) - dist;
	};
	ll one=bfs({1}), two=bfs({one});
	ll diam=dist[two];
	ll c = two;
	while(dist[c] > (diam+1)/2){
		for(auto i:v[c]) if(dist[i]==dist[c]-1) { c=i; break; }
	}
	auto solve2=[&](ll b,ll c){
		bfs({b,c});
		fill(mx,mx+n,1);
		FOR(i,1,n)mx[dist[i]]=max(mx[dist[i]],siz(v[i])-1);
		ll ans=2;
		FOR(i,0,n-1)ans*=mx[i];
		assert(ans <= 1ll<<52);
		return ans;
	};
	if(diam&1){
		ll b=c;
		for(auto i:v[c]) if(dist[i]==dist[c]-1) { b=i; break; }
		assert(b^c);
		cout<<diam/2+1<<' '<<solve2(b,c)<<'\n';
	}else{
		bfs({c});
		fill(mx,mx+n,1);
		FOR(i,1,n)mx[dist[i]]=max(mx[dist[i]],siz(v[i])-(i!=c));
		ll ans=1;
		FOR(i,0,n-1)ans*=mx[i];
		assert(ans <= 1ll<<52);
		for(auto i:v[c]) {
			ans = min(ans, solve2(i, c));
		}
		cout<<diam/2+1<<' '<<ans<<'\n';
	}
}


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

int main()
{ 
  int n, l, max_l = 0, sum_l = 0;

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> l;
    sum_l += l;
    max_l = max(l, max_l);
  }
  cout << (max_l < sum_l - max_l ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
    char a[10],b[10],c[10];
    int n,m;
    scanf("%s %s",&a,&b);
    scanf("%d %d",&n,&m);
    scanf("%s",&c);
    if(strcmp(a,c) == 0){
        n=n-1;
    }
    if(strcmp(b,c) == 0){
        m=m-1;
    }
    printf("%d %d\n",n,m);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 0;
      
      	for(int i = 1;i <= n;i++){
          ans += i;
        }
 		
      	System.out.println(ans);
        
	}
}


Measured memory_bytes: 35704
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    string s;
    cin >> s;
    int n = s.size();
    ll ans = 0;
    rep(i, 1<<(n-1)){
        vector<ll> tans;
        ll tsum = 0;
        rep(j, n-1){
            ll num = s[j]-'0';
            tsum += num;
            if ((i>>j)&1){
                //cout << tsum << endl;
                tans.push_back(tsum);
                tsum = 0;
            }
            tsum*=10;
        }
        tans.push_back(tsum+(s[n-1]-'0'));
        rep(j, tans.size()){
            ans += tans[j];
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  int n;
  cin >> n;
  cout << n * n * n;
}

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

int main(){

    char str[128];
    int alphabet[26] = {};
    int i;
    bool flag = true;

    scanf("%s", str);
    for(i=0;i<strlen(str);i++){
        alphabet[(int)(str[i]-'a')] += 1;
    }
    for(i=0;i<26;i++){
        if((alphabet[i]%2)!=0){
            flag = false;
            break;
        }
    }
    if(flag){
        printf("Yes");
    }else{
        printf("No");
    }
    

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    S = input()
    N = len(S) - 1
    result = 0
    for i in range(2**N):
        f = S[0]
        for j in range(N):
            if i >> j & 1:
                f += "+"
            f += S[j + 1]
        result += eval(f)
    print(result)


if __name__ == "__main__":
    main()


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

int main() {
int X, N;
int m=0, ANS=0;

cin >> X >> N;

if(N != 0){
    vector <int> vec(N);
    for(int k=0; k<N; k++){
        cin >> vec.at(k);
    }

    vector <int> subt(N);
    for(int k=0; k<N; k++){
        subt.at(k) = vec.at(k) - X;
    }


    // 小さい順に並び変え
    sort(subt.begin(), subt.end());
    /*
    for(int k=0; k<N; k++){
        cout << subt.at(k) << endl;
    }
    */
    if(subt.at(0) > 0){
        ANS = 0;
    }
    else if(subt.at(N-1) < 0){
        ANS = 0;
    }
    else if(subt.at(0) <= 0){
        ANS = subt.at(0) - 1;
    }  


    m = subt.at(0);// k番目と比較する初期値
    for(int k=1; k<N; k++){
        if(subt.at(k) > 0 ){
            if(m >= 0){
                if(subt.at(k)-m != 1 && abs(subt.at(k-1)+1) < abs(ANS) ){
                    ANS = subt.at(k-1) + 1;
                }
            }
            else{
                ANS = 0;
            }
        }
        if(subt.at(k) <= 0 ){
            if(subt.at(k)-m != 1 && abs(subt.at(k)-1) < abs(ANS) ){
                ANS = subt.at(k) - 1;
            }
        }

        m = subt.at(k);
    }

    if(ANS == subt.at(0) - 1){
        if(abs(subt.at(N-1)+1) < abs(subt.at(0)-1)){
            ANS = subt.at(N-1) + 1;
        }
    }
    // cout << ANS << endl;
    cout << X+ANS << endl;
}
else{
    cout << X << endl;
}

return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main()
{
	int a[2001], b[2001], c[2001] = { 0 }, ruio = 0, hideo = 0,nagase=0,temp=0;
	scanf("%d %d", &ruio, &hideo);
	for (int i = 1; i <= ruio; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 1; i <= hideo; i++) {
		scanf("%d", &b[i]);
	}
	for (int i = 1; i <= hideo; i++) {
		for (int j = 1; j <= ruio; j++) {
			if (b[i] >= a[j]) {
				nagase = j;
				break;
			}
		}


		c[nagase]++;
		nagase = 0;
	}
	
	for (int i = 1; i <= ruio; i++) {
		if (nagase < c[i]) {
			nagase = c[i];
			temp = i;
		}
	}

	printf("%d\n", temp);
}

Measured memory_bytes: 2720
#include<stdio.h>

main(){

int i,n,a,max,min;
long int sum=0;

scanf("%d",&n);

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

if(i==0){
 max = a;
 min = a;
 }

 if(a > max){
 max = a;
 }

 if(a < min){
 min = a;
 }
 
 sum = sum + a;
}

printf("%d %d %ld\n",min,max,sum);

return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,count=0,y=1,n;
    cin>>a>>b;
    int x=b;
    while(x)
    {
        x/=10;
        count++;
    }

    while(count--){
        y*=10;
    }
    n=a*y+b;
    int n1=sqrt(n);
    if(n1*n1==n) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	void run(){
		for(;;){
			if(!sc.hasNextInt()) break;
			int a = sc.nextInt() + sc.nextInt();
			System.out.println(1+(int)Math.log10(a));
		}
		
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();
		
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int n;
	cin >> n;
	int ans = 0;
	vector<int>v(n), c(n);
	rep(i, n) {
		cin >> v[i];
	}
	rep(i, n) {
		cin >> c[i];
	}
	rep(i, n) {
		ans +=max(0, v[i] - c[i]);
	}
	cout << ans << endl;

}


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

typedef long long ll;

int main ()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    double a,b,h;
    cin>>a>>b>>h;
    cout<<(a+b)/2*h<<endl;
    return 0;
}

Measured memory_bytes: 764
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc156/tasks/abc156_a>
 問題文============================================================
 A - Beginner
 =================================================================
 解説=============================================================
 
 
 
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    
    ll N,R; cin >> N >> R;
    res = R + max(0LL,100*(10-N));
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
//NAME-ADITYYA OJHA
                                               /*
                                                      GURU(MENTOR)-AARADHYA
                                               */
/*
 *     Heart beats fast
 *         Colors and promises
 *             How to be brave
 *                 How can I love when I am afraid to fall...
                                             (courtesy-amnesiac_dusk)
 */

#include <bits/stdc++.h>
#define ll long long int
#define forin for(int i=0;i<n;i++)
#define pb push_back
#define vx vector<ll> x
#define vy  vector<ll> y
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  f   first
#define  s   second
#define mod 1000000007



using namespace std;

//check for corner cases(for n==1)
// check for int overflow
// run on some sample cases before submitting
  const  ll N=1e5 + 5;
int main()
{
  fast;
    ll n;
    cin>>n;
    ll a[n];
    ll f[N];
    memset(f,0,sizeof(f));
    ll sum=0;
    forin
    {
        cin>>a[i];
        f[a[i]]++;
        sum+=a[i];
    }
    ll q;
    cin>>q;
    vx;

    while(q--)
    {
        ll b,c;
        cin>>b>>c;
        ll z=f[b];
        f[b]=0;
        ll z1=f[c];
        sum-=(b*z);
        sum-=(z1*c);
        f[c]=z+z1;
        sum+=c*f[c];


        x.pb(sum);
    }
   for(int i=0;i<x.size();i++)
    cout<<x[i]<<endl;



}


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

int main(){
  
  
  int N;
  int M;
  cin >> N >> M;
  
  if(N == M){
  	cout << "Yes"<< endl;}
  else{
  	cout << "No" << endl;}
    
}  

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

int main(void) {
  int N;
  string S;

  map<int, int> cnt_alpha;
  map<int, int> cnt_coeff;

  cin >> N >> S;

  for (int i = 0; i < S.size(); i++) {
    if (S[i] == '+') continue;
    cnt_alpha[S[i]-'a']++;
  }

  for (int i = 0; i < 26; i++) {
    if (cnt_alpha[i] == 0) continue;

    cnt_coeff[cnt_alpha[i]]++;
  }

  int ans = 0;
  int cnt_term = 0;
  for (int i = 1; i <= N; i++) {
    if (cnt_coeff[i] == 0) continue;
    if (i == 1) {
      ans += cnt_coeff[i];
      cnt_term += cnt_coeff[i];
    } else if (cnt_coeff[i] == 1) {
      ans += 3;
      cnt_term++;
    } else {
      ans += 4 + 2 * cnt_coeff[i] - 1;
      cnt_term++;
    }
  }
  ans += cnt_term - 1;

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

Measured memory_bytes: 3200
n = int(input())
a = list(map(int,input().split()))
s = []
a.reverse()
s.append(a[0])
for i in range(n-1):
    s.append(s[-1]+a[i+1])
mod = 10**9+7
ans = 0
a.reverse()
for i in range(n-1):
    ans += a[i]*s[-2-i]
    ans = ans % mod
print(ans)

Measured memory_bytes: 102060
from collections import Counter
import sys

H,W,M,*hw = map(int,open(0).read().split())

h = hw[::2]
w = hw[1::2]

hw_set = set((hi,wi) for hi,wi in zip(h,w))


raw_count = Counter(h).most_common()
col_count = Counter(w).most_common()


raw_max = raw_count[0][1]
col_max = col_count[0][1]

ans = 0
for hi, rcount in raw_count:
    if rcount<raw_max:break
    for wi, ccount in col_count:
        if ccount<col_max: break
        
        if (hi,wi) in hw_set:
            ans = raw_max + col_max - 1
        else:
            print(raw_max + col_max)
            sys.exit()

print(ans)


Measured memory_bytes: 126336
s = input()
max_plus = len(s)-1
plus = [reversed(bin(i)[2:]) for i in range(2**max_plus)]
value_sum = 0
for i in plus:
    value = 0
    prov_s = s
    end_plus = 0
    for index, j in enumerate(i):
        if j == "1":
            cut_index = (1+index)*(-1)+end_plus
            value += int(prov_s[cut_index:])
            prov_s = prov_s[0:cut_index]
            end_plus += -1 * cut_index
    value_sum += value + int(prov_s)#(int(prov_s) if prov_s else 0)
print(value_sum)

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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/
const ll mod=1e9+7;
const ll INF=1e18;
/*****************************************************************************/

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	string s;
	cin >>s;
	if (sz(s)>=3)
	cout <<s[0] <<s[1] <<s[2];
	else cout <<s;
	return 0; 
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 3596
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};

signed main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> a(n);
    rep(n) cin >> a[i];
    if(n > 1) cout << max(abs(a[n-1] - y), abs(a[n-1] - a[n-2]));
    else cout << abs(a[n-1]-y);
}

Measured memory_bytes: 256
program main
  implicit none
  integer :: N
  integer :: nin
  integer,allocatable :: B(:)
  integer,allocatable :: B1(:),B2(:)
  integer,allocatable :: out(:)
  logical :: lmiss
  integer :: i,j
  read(*,*) N
  allocate(B(N))
  read(*,*) B
  allocate(out(N))
  out=-1
  !
  ! search same num
  allocate(B1(N))
  B1=B
  do j = 0,N-1
     Nin = N-j
     allocate(B2(Nin))
     B2 = B1
     lmiss=.true.
     do i = Nin,1,-1
        if ( B2(i) ==i  ) then ! remove
           deallocate(B1)
           allocate(B1(Nin-1))
           B1(1:i-1) = B2(1:i-1)
           B1(i:Nin-1) = B2(i+1:Nin)
           out(N-j) = i
           lmiss = .false.
           exit
        end if
     end do
     if (lmiss) then
        write(*,'(i0)') -1
        stop
     end if
     deallocate(B2)
  end do
  do i = 1,N
     write(*,'(i0)') out(i)
  end do
  deallocate(B)
  stop
end program main

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;
bool isNum(ll x){
    bool nana=false, go=false, san=false;
    while(x>0){
        int num=x%10;
        x/=10;
        if(num==3) san=true;
        if(num==5) go=true;
        if(num==7) nana=true;
    }
    return san&&go&&nana;
}

int main(){
    fast_io

    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) {
        cin>>a[i];
        a[i]--;
    }
    int ans=0;
    rep(i,n){
        if(i==a[a[i]] && i!=a[i])ans++;
    }
    cout<<ans/2<<endl;
    return 0;
}

Measured memory_bytes: 640
<?php
fscanf(STDIN,"%d",$n);
$a = explode(" ", rtrim(fgets(STDIN)));
$result = 1;
$incdec = 0;
 
for ($i=0; $i < $n-1; $i++)
{ 
	if($a[$i] == $a[$i+1])
	{
		continue;
	}
	elseif($a[$i] < $a[$i+1])
	{
		switch($incdec)
		{
			case '1':
				break;
			case '0':
				$incdec = 1;
				break;
			case '-1':
				$incdec = 0;
				$result++;
				break;
		}
	}
	else
	{
		switch($incdec)
		{
			case '1':
				$incdec = 0;
				$result++;
				break;
			case '0':
				$incdec = -1;
				break;
			case '-1':
				break;
		}
	}
}
 
echo($result);

Measured memory_bytes: 22044
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

bool solve(vector<int64_t> &as) {
  int64_t rem = 0;
  int64_t odds = 0;

  int64_t mi = as[0];
  for (auto &a : as) {
    rem += a - 1;
    if (a % 2 == 1)
      odds++;

    mi = min(mi, a);
  }
  bool win = rem % 2 == 1;

  if (mi > 1 && odds == 1) {
    int g = 0;
    for (auto &a : as) {
      g = gcd(g, a / 2 * 2);
    }
    for (auto &a : as) {
      a /= g;
    }
    win |= !solve(as);
  }

  return win;
}

int main() {
  cin.tie(0);
  int n;
  cin >> n;

  vector<int64_t> as(n);
  for (auto &a : as)
    cin >> a;

  cout << (solve(as) ? "First" : "Second") << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  ll n;
  std::cin>>n;

  ll ans=0;

  rep(i,0,n){
    ll a;
    std::cin>>a;

    if(a%2==1&&i%2==0)ans++;
  }

  std::cout<<ans<<"\n";

  return 0;
}

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

#define gap " "
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ok cout<<"ok"<<endl
#define dbg(x) cout<<(#x)<<" is "<<x<<endl
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int N=100009;

int main()
{
  //fastio; 
  int l,r,d,m,cnt=0;
  cin>>l>>r>>d;
  for(int i=1; ; i++)
  {
     m=d*i;
     if(m>r) break;

     if(m>=l && m<=r) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

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

#define FOR(i,b,e) for (int i = (b); i <= (e); i++)
#define FORD(i,b,e) for (int i = (b); i >= (e); i--)
#define SIZE(c) ((int) (c).size())

#define pb push_back
#define st first
#define nd second

using namespace std;


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

typedef vector <int> VI;
typedef vector <ll> VL;
typedef vector <bool> VB;
typedef vector <pii> VP;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;

const int N = 200002;
const int L = 5;

int dp[N][L];

int main() {
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;

    int n = SIZE(s);

    FOR(i,0,n-1) {
        FOR(len,1,min(L,i+1)) {
            string last = s.substr(i+1-len, len);

            if (len == i + 1) {
                dp[i+1][len] = 1;
                continue;
            }

            FOR(prevLen,1,min(L,i+1-len)) {
                bool ok = false;
                if (prevLen != len) {
                    ok = true;
                } else {
                    ok = last != s.substr(i+1-len-prevLen, prevLen);
                }

                if (ok) {
                    dp[i+1][len] = max(dp[i+1][len], 1 + dp[i+1-len][prevLen]);
                }
            }
        }
    }

    int best = 0;
    FOR(len,1,L) {
        best = max(best, dp[n][len]);
    }

    cout << best;

    return 0;
}

Measured memory_bytes: 4500
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, a[N], vis[N], to[N];
vector <int> edges[N], g[N];
priority_queue <pair <int, int> > que;
int gcd (int a, int b) {
	if (!b)
		return a;
	return gcd (b, a % b);
}
void dfs (int x) {
	vis[x] = 1;
	for (int j = 0; j < edges[x].size (); j ++)
		if (!vis[edges[x][j]]) {
			to[edges[x][j]] = 1;
			g[x].push_back (edges[x][j]);
			dfs (edges[x][j]);
		}
	return ;
}
int main () {
	scanf ("%d", &n);
	for (int i = 1; i <= n; i ++)
		scanf ("%d", &a[i]);
	sort (a + 1, a + n + 1);
	for (int i = 1; i <= n; i ++)
		for (int j = 1; j <= n; j ++)
			if (i != j && gcd (a[i], a[j]) > 1)
				edges[i].push_back (j);
	for (int i = 1; i <= n; i ++)
		if (!vis[i])
			dfs (i);
	for (int i = 1; i <= n; i ++)
		if (!to[i])
			que.push (make_pair (a[i], i));
	while (!que.empty()) {
		int x = que.top().second;
		que.pop ();
		printf ("%d ", a[x]);
		for (int i = 0; i < g[x].size (); i ++)
			que.push (make_pair (a[g[x][i]], g[x][i]));
	}
	return 0;
}

Measured memory_bytes: 24020
//Tanzim bin nasir

#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,i,check=0;
  cin>>n;
  long long int a[n],sum;
  for(i=0;i<n;i++)
  {
      cin>>a[i];
      if(a[i]==0)
        check=1;
  }
  if(check)
  {
      cout<<"0"<<endl;
      return 0;
  }
  sum=1;
  for(i=0;i<n;i++)
  {
      if(a[i]<=1000000000000000000/sum)
      sum=sum*a[i];
      else
        {
            cout<<"-1"<<endl;
            return 0;
        }
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 4340
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

bool check(vector<int> x1, vector<int> x2) {
  int N = x1.size(), acc = 0;
  REP(i, N) {
    int d = x1[i] - x2[i];
    acc += d * d;
  }
  for (int i = 0; i * i <= acc; i++) {
    if (i * i == acc) return true;
  }
  return false;
}

int main() {
  int N, D;
  cin >> N >> D;
  vector<vector<int>> X(N);
  REP(i, N) REP(j, D) {
    int x; cin >> x;
    X[i].push_back(x);
  }
  int ret = 0;
  for (int i = 0; i < N-1; i++) {
    for (int j = i+1; j < N; j++) {
      if (check(X[i], X[j])) ret++;
    }
  }
  cout << ret << endl;
}


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

using namespace std;

int main(){
	long long m[4];
	long long n;
	cin >> m[0] >> m[1] >> m[2] >> m[3];
	cin >> n;
	
	long long m2 = 9e9;
	long long tn = 8;
	for(int i = 0;i < 4;i++){
		m2 = min(m[i] * tn,m2);
		tn /= 2;
	}
	long long m1 = 9e9;
	tn = 4;
	for(int i = 0;i < 3;i++){
		m1 = min(m[i] * tn,m1);
		tn /= 2;
	}
	
	long long ans = (n/2) * m2;
	if(n % 2 != 0) ans += m1;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
    

    int N, K;
    cin >> N >> K;

    vector<int> A(N);

    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }

    N--;
    K--;

    int ans = N / K;

    if(N % K) ans++;

    cout << ans << endl;
}

Measured memory_bytes: 640
n, d = map(int, input().split())
lst = []
cnt = 0
lst = [list(map(int, input().split())) for i in range(n)]

for i in range(n-1):
    for j in range(i+1, n):
        x = 0
        for k in range(d):
            x += (lst[i][k]-lst[j][k]) ** 2
        dist = x ** 0.5
        if dist%1 == 0:
            if dist != 0:
                cnt += 1
print(cnt)

Measured memory_bytes: 3188
//?????????????????¢??°???goto???????????????????????´???
#include<stdio.h>

int main(void){
    int n;
    int i;
    int x;
    
    scanf("%d", &n);
    for(i = 1; i <=n; i++){
        x = i;
        if(x % 3 == 0){
            printf(" %d", i);
            continue;
        }
        do{
            if(x % 10 == 3){
                printf(" %d", i);
            break;
            }
            x /= 10;
        }while(x);
    }
    putchar('\n');
    
    return 0;
}

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

int _abs(
  int lhs
  , int rhs
)
{
  return ((lhs < rhs) ? (rhs - lhs) : (lhs - rhs));
}

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (auto & _h : h)
    cin >> _h;
  vector<int> cost(N);
  int inf = 1000000000;
  for (int i = 1; i < N; ++i)
  {
    vector<int> k(K, inf);
    for (int j = 0; j < K; ++j)
      if (0 <= i - 1 - j)
        k[j] = cost[i - 1 - j] + _abs(h[i - 1 - j], h[i]);
    cost[i] = *min_element(k.begin(), k.end());
  }
  cout << cost[N - 1];
  return 0;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10000000)
import math
import bisect
from collections import deque
def input():
    return sys.stdin.readline()[:-1]

n = int(input())
a = list(map(int,input().split()))
ma = max(a)
lis = [i for i in range(1,ma+1)]
a.sort()
f = [-1 for i in range(ma+1)]
ans = 0

for i in a:
    if f[i]==-1:
        ans +=1
        f[i]=2
        for j in range(i+i,ma+1,i):
            f[j] = 1
    elif f[i]==2:
        ans-=1
        f[i] = 1
    else:
        continue

print(ans)


Measured memory_bytes: 166904
#include <bits/stdc++.h>
#define int long long

/*#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define tr(container, it) \
for(typeof((container).begin()) it = (container).begin(); it != (container).end(); it++)
#define present(container, element) ((container).find(element) != (container).end())
#define cpresent(container, element) (find(all(container),element) != (container).end())
*/

using namespace std;

/*typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
*/

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

int n,k,r,s,p;
cin>>n>>k>>r>>s>>p;
string t;
cin>>t;

int tot=0;
vector<char> ans(t.length()+1,'n');
for(int i=0; i<t.length(); i++)
{
	/*cout<<t[i]<<" "<<i<<'\t';
	if(i-k>=0)
		cout<<t[i-k]<<i-k<<'\n';
	*/
	if(i<k)
	{
	if(t[i]=='r')
	{
		ans[i]='p';
		tot+=p;
	}
	else if(t[i]=='p')
	{
		ans[i]='s';
		tot+=s;
	}
	else 
	{
		ans[i]='r';
		tot+=r;
	}
	}
	else 
	{
	if(t[i]=='r')
	{
		if(ans[i-k]=='p')
		{
		}
		else
		{
		ans[i]='p';
		tot+=p;
		}
	}
	else if(t[i]=='p')
	{
		if(ans[i-k]=='s')
		{
		}
		else
		{
		ans[i]='s';
		tot+=s;
		}
	}
	else 
	{
		if(ans[i-k]=='r')
		{
		}
		else
		{
		ans[i]='r';
		tot+=r;
		}
	}		
	}
	//cout<<ans[i]<<" ";
}
cout<<tot;
return 0;
}


Measured memory_bytes: 512
//#include <fstream>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>

using namespace std;

//ifstream cin("tema.in");
//ofstream cout("tema.out");

const int MAXN = 100;
const int MAXM = 1000;
const int INF = 1000000000;

struct Edge {
    int from, to;
    int cost;

    Edge() {}

    Edge(int _from, int _to, int _cost):
        from(_from), to(_to), cost(_cost) {}
};

Edge edge[1 + MAXM];
vector<pair<int, int> > g[1 + MAXN];
bool ok[1 + MAXM];
int best[1 + MAXN];

class Compare {
    public:
        bool operator()(int &x, int &y) {
            return best[x] > best[y];
        }
};

void Dijkstra(int source, int n, int m) {
    priority_queue<int, vector<int>, Compare> Heap;
    Heap.push(source);
    for (int i = 1; i <= n; i++)
        best[i] = INF;
    best[source] = 0;
    while (!Heap.empty()) {
        int node = Heap.top();
        Heap.pop();
        for (auto &neighbour : g[node])
            if (best[neighbour.first] > best[node] + neighbour.second) {
                best[neighbour.first] = best[node] + neighbour.second;
                Heap.push(neighbour.first);
            }
    }
    for (int i = 1; i <= m; i++)
        if (best[edge[i].from] + edge[i].cost == best[edge[i].to] || best[edge[i].to] + edge[i].cost == best[edge[i].from])
            ok[i] = true;
}

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        g[a].push_back(make_pair(b, c));
        g[b].push_back(make_pair(a, c));
        edge[i] = Edge(a, b, c);
    }
    for (int i = 1; i <= n; i++)
        Dijkstra(i, n, m);
    int answer = 0;
    for (int i = 1; i <= m; i++)
        if (!ok[i])
            answer++;
    cout << answer << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#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 FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 410;
const int MAXM = 1000010;
const int MAXK = 100010;
const int MAXQ = 200010;

int n, a[MAXN];
ll dp[MAXN][MAXN], s[MAXN];

ll sum(int l, int r) {
    return s[r] - s[l-1];
}

ll solve(int l, int r) {
    if (l == r) return 0;
    if (dp[l][r] != -1) return dp[l][r];
    ll Min = 1e18;
    FOR(i,l,r-1) Min = min(Min, solve(l, i) + sum(l, i) + solve(i+1, r) + sum(i+1, r));
    return dp[l][r] = Min;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    FOR(i,1,n) s[i] = s[i-1] + a[i];
    FOR(i,1,n)
        FOR(j,1,n) dp[i][j] = -1;
    cout << solve(1, n);
    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int nibl(vector<int> &v, int tan,int si) {
	int up = si - 1;
	int lo = 0;
	if (tan >= v[up]) {
		return up;
	}
	while (up - lo > 1) {
		int mi = (up + lo) / 2;
		if (tan >= v[mi]) {
			lo = mi;
		}
		else {
			up = mi;
		}
	}
	return lo;
}
int main() {
	int d, n, m;
	cin >> d;
	while (d != 0) {
		cin >> n >> m;
		vector<int> fr(n);
		fr[0] = 0;
		for (int i = 1; i < n; i++) {
			cin >> fr[i];
		}
		sort(fr.begin(), fr.end());
		int ans = 0;
		for (int i = 0; i < m; i++) {
			int to;
			cin >> to;
			int gy=nibl(fr,to,n);
			ans += min(to - fr[gy], fr[(gy + 1) % n] + ((gy + 1) / n)*d - to);
		}
		cout << ans << endl;
		cin >> d;
	}
}


Measured memory_bytes: 3340
#include <bits/stdc++.h>
#define ll long long
#define fort(i,n) for (int i = 1; i <= n; ++i)
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz size()
#define er erase
#define fr first
#define sc second
#define rc(x) return cout << x, 0
using namespace std;

int n,m,a[100005],b[100005],deg[100005],v[100005],root,tps[100005],p[100005];
vi g[100005],s;

void dfs(int nod)
{
    v[nod]=1;
    for (int i : g[nod])
        if (!v[i]) dfs(i);
    s.pb(nod);
}

int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n >> m;
    fort (i,n+m-1)
    {
        cin >> a[i] >> b[i];
        g[a[i]].pb(b[i]);
        ++deg[b[i]];
    }
    fort (i,n)
        if (!deg[i]) root=i;
    dfs(root);
    reverse (s.begin(), s.end());
    fort (i,n)
        tps[s[i-1]]=i;
    fort (i,n+m-1)
        if (tps[a[i]]>tps[p[b[i]]]) p[b[i]]=a[i];
    fort (i,n)
        cout << p[i] << '\n';
}


Measured memory_bytes: 13816
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
int n, m, x[N], ans;
priority_queue<int> q;


int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++ i)
		scanf("%d", &x[i]);
	sort(x+1, x+m+1);
	ans = x[m]-x[1];
	for (int i = 1; i < m; ++ i)
		q.push(x[i+1]-x[i]);
	for (int i = 1; i <= n-1; ++ i){
		if (q.empty()) break;
		ans -= q.top();
		q.pop();
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
int n,in[M];
int st[M];
void dfs(int d)
{
	if(d==18)
	{
		REP(i,0,d-1) printf("%d ",st[i]);
		puts("");
		REP(i,1,n) printf("%d ",in[i]);
		puts("");
		puts("--=-")
			;
	}

		
	int mx = 0;
	REP(i,1,n)
	{
		
		if(in[i] > mx+1)
		{
			st[d] = i;
			in[i] -= mx+1;
			dfs(d+1);
			in[i] += mx+1;
		}

		mx = max(mx, in[i]);
	}
}
int main()
{
	while(~scanf("%d",&n))
	{
		REP(i,1,n) RI(in[i]);
		int mn=0, mn2=0;
		LL ans=0;
		REP(i,1,n)
		{
			mn = mn2;
			int can = in[i]-1;
			int ch = mn+1;

			//printf("%d %d %d => %d\n",can,ch,can/ch,in[i]-can/ch*ch);
			ans += can/ch;
			mn = max(mn, in[i]-can/ch*ch);

			if(in[i] == mn2+1) mn2 = in[i];
			if(mn2==0) mn2=1;
		}
		printf("%lld\n",ans);
	}
	return 0;
}



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

long long f(long long n){
  if(n == 0) return 0;
  long long res;
  long long tmp = (n + 1) / 2;
  res = tmp % 2;
  if(n % 2 == 0) res ^= n;
  return res;
}

int main(){
  long long A, B; cin >> A >> B;
  long long ans;
  ans = f(A-1) ^ f(B);
  cout << ans << endl;
}
    

Measured memory_bytes: 256