akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
using P = pair<int, int>;
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9+7;
    string n;
    cin>>n;
    if(count(n.begin()+1,n.end(),'9')==n.size()-1)cout<<n[0]-'0'+9*(n.size()-1)<<endl;
    else cout<<n[0]-'0'-1+9*(n.size()-1)<<endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	t := nextInt()
	a := nextInt()
	l := make([]float64, n)

	for i := 0; i < n; i++ {
		h := nextInt()
		l[i] = float64(t) - float64(h)*0.006
	}

	tmpdiffmin := 100000.0
	idx := 0
	for i := 0; i < n; i++ {
		if abs(l[i]-float64(a)) < abs(tmpdiffmin-float64(a)) {
			idx = i
			tmpdiffmin = l[i]
		}
	}
	fmt.Println(idx + 1)

}
func abs(a float64) float64 {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1800
n, w = map(int, input().split())
weight = [0] * n
values = [0] * n
for i in range(n):
    a, b = map(int, input().split())
    weight[i] = b
    values[i] = a

def chmax(a, b):
    if a > b:
        return a
    else:
        return b

dp = [[0] * (w + 10) for _ in range(n + 10)]
for i in range(n):
    for sum_w in range(w + 1):
        if sum_w >= weight[i]:
            dp[i + 1][sum_w] = chmax(dp[i][sum_w - weight[i]] + values[i], dp[i][sum_w])
        else:
            dp[i + 1][sum_w] = dp[i][sum_w]

print(dp[n][w])


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;
  vector<int> P(N);
  REP(i, N) { cin >> P[i]; }
  int min_p = P[0];
  int ans = 1;
  REPI(i, 1, N) {
    min_p = min(min_p, P[i]);
    if (min_p == P[i]) {
      ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
/*
AB=0,0はコーナーケースこれらを足した上で, 
省いて普通の分析につなげる

S, Tに対して, それぞれの集合は直線上で
sとtは直行

この時, SかTかのどっちかのみ選べる
選び方は2^|S|+2^|T|-1(空集合に注意)
これをS[i]で掛け合わせればいい

問題はS[i]の分類, どうやって同じ直線上の点を検出するか
角度に直して分析? doubleだと誤差がだるそう
最大公約数で割り算? logAなのでいけそう

*/

#include<bits/stdc++.h>
using namespace std;
typedef pair<long,long> P;
#define Q 1000000007 
long gcd(long x,long y){
  return (x%y==0?y:gcd(y,x%y));
}
long pow(long x){
  if(x==0)return 1;
  if(x%2)return pow(x-1)*2%Q;
  else {
    long y=pow(x/2);
    return y*y%Q;
  }
}
int main(){
  long N;cin>>N;
  vector<P>S,T;
  long ans=0;
  for(long i=0;i<N;i++){
    long a,b;cin>>a>>b;
    // [0,90), [90,180)にする
    if(a==0&&b==0){ans++;continue;}
    if((a<0&&b<=0)||(a>=0&&b<0)){a*=-1;b*=-1;}
    if(a>0&&b>=0){//[0,90)
      if(b==0)S.push_back(P(1,0));
      else {long g=gcd(a,b);S.push_back(P(a/g,b/g));}
    }
    else if(a<=0&&b>0){//[90,180), 
      //これをさらに90度回転させて[0,90)に
      
      if(a==0)T.push_back(P(1,0));
      else {long g=gcd(-a,b);T.push_back(P(b/g,-a/g));}
    }
    else cout<<"error";    
  }
  // map<P,P>: ベクトル/ (Sの個数,Tの個数)
  // set, 登録されたベクトル
  map<P,P> VST;
  for(P s:S){
    VST[s].first++;
  }  
  for(P t:T){
    VST[t].second++;
  }
  long x=1;
  for(const auto&[k,v]:VST){
    x=x*((pow(v.first)+pow(v.second)-1)%Q)%Q;
  }
  assert((ans+x-1+Q)%Q>=0);
  cout<<(ans+x-1+Q)%Q;
}

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

long long soma(long long a){
	if (a < 10)
		return a;
	return a%10 + soma(a/10);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n;
    cin >> n;
    if(n % soma(n) == 0)
    	cout << "Yes\n";
    else
    	cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
 
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
 
using namespace std;

void solve(){
    string s, t;
    cin >> s >> t;
    cout << t << s;
}

 
int main(){
    barsik;
    //freopen("file.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(ll i = 1; i <= q; i++){
        solve();
    }
}


Measured memory_bytes: 256
#include<stdio.h>
    int main()
    {
    int a,b,i;
    scanf("%d%d",&a,&b);
    if((a+b)%2==0)
    {
    i=(a+b)/2;
    printf("%d",i);
    }
    else
    printf("IMPOSSIBLE");
    return 0;
    }


Measured memory_bytes: 128
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007

using namespace std;
#define ll long long
#define dbg if(0)

int main(){
    ll n,a,b,ans;
    cin >>n>>a>>b;
    ll st1=0, st2=0, st3=0;
    for(int i=0;i<n;i++){
        ll p;
        cin >>p;
        if(p<=a)st1++;
        else if(p>a&&p<=b)st2++;
        else st3++;
    }
    ans=min(st1,min(st2,st3));
    cout <<ans<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<algorithm>
#include <cstdlib>
#include <cmath>
#include <regex>

using namespace std;
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a*b > c*d) cout << a*b << endl;
	else cout << c*d << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val numbers: String = sc.nextLine
    println((numbers.slice(0, numbers.length - 2), numbers.slice(1, numbers.length - 1), numbers.slice(2, numbers.length)).zipped.foldLeft(753) {
      (presentMin, item) => {
        Math.min(presentMin, Math.abs((item._1.toString + item._2.toString + item._3.toString).toInt - 753))
      }
    })
  }

}


Measured memory_bytes: 27348
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using dbl = double;

int main() {
  ll L; cin >> L;
  dbl vol = (L * L * L) * 1000000 / 27;
  vol /= 1000000;
  cout << fixed << setprecision(7);
  cout << vol << endl;
}


Measured memory_bytes: 256
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n;
    cin >> n;
    string s;
    while (n > 0)
    {
        ll rem = n % 26;
        if (rem == 0)
        {
            s += 'z';
            n = (n / 26) - 1;
        }
        else
        {
            s += char((rem - 1) + 'a');
            n = n / 26;
        }
    }
    reverse(s.begin(), s.end());
    cout << s;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
  IOS();
  ll n;
  cin>>n;
  ll ans = 999;
  REP1(i,9){
    if( i*111 >= n ){
      ans = i*111;
      break;
    }
  }
  cout<<ans<<endl;
}


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

int main() {
  int n;string s;cin>>n>>s;
  int ans=0;
  rep(i,1000){
    string t;
    int x=i;
    rep(j,3){
      t+='0'+x%10;
      x/=10;
    }
    int a=0;
    rep(j,n){
      if(s[j]==t[a]){
        a++;
        if(a==3)break;
      }
    }
    if(a==3)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3700
a,b,c=map(int,input().split())
if a%2!=0 or b%2!=0 or c%2!=0:
    print(0)
else:
    a1=0
    a2=0
    a3=0
    c1=0
    c2=0
    c3=0
    ans=0
    for i in range(2*10**5):
        if a%2!=0:
            c1=1        
        if b%2!=0:
            c2=1        
        if c%2!=0:
            c3=1
        if c1==1 or c3==1 or c2==1:
            ans=i
            break
        else:
            a3=(a+b)//2
            a2=(a+c)//2
            a1=(b+c)//2
            a=a1
            b=a2
            c=a3
        #print(a,b,c)
        if i==199999:
            ans=-1
    print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
using namespace std;
int a[1000][2];
bool st[1000];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=0;j<2;++j){
            cin>>a[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        if(a[i][0]==a[i][1])st[i]=1;
    }
    bool t=0;
    int sum=0;
    for(int i=1;i<=n;++i){
        if(st[i]){
            sum++;
            if(sum==3){
                cout<<"Yes"<<endl;
                return 0;
            }
        }else sum=0;
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int max = 0;
		int x = 0;
		for (int i = 0; i < N; i++) {
			if (S.charAt(i) == 'I') {
				x++;
			} else {
				x--;
			}
			max = Math.max(max, x);
		}
		System.out.println(max);
	}
}

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

public class Main {
	
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s = br.readLine().split(" ");
		int x = Integer.parseInt(s[1]);

		int p = 0;
		int c = 1;
		s = br.readLine().split(" ");
		for ( String l : s ) {
			p += Integer.parseInt(l);
			if ( p > x ) {
				break;
			}
			c++;
		}
		System.out.println(c);
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int> v(n);
    for(int& i:v)cin>>i;
    sort(v.begin(),v.end());
    auto it=unique(v.begin(),v.end());
    cout<<it-v.begin();

    
    
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
list = []

for i in range(N):
    tmp = int(input())
    list.append(tmp)

maxDiff = - 10 ** 9
tmpMin = list[0]
for i in range(N-1):
    maxDiff = max([maxDiff, list[i+1] - tmpMin])
    tmpMin = min([tmpMin, list[i+1]])
print(maxDiff)


Measured memory_bytes: 13592
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
using namespace std;

struct Testimony {
    vector<pii> testimonial;

    void Init(int num) {
        testimonial.resize(num);
        for (int i = 0; i < num; i++) {
            int f, s; cin >> f >> s;
            testimonial[i].first = --f;
            testimonial[i].second = s;
        }
    }

};


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

    vector<Testimony> Person(N);

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

    int max = 0;

    for (int b = 0; b < (1 << N); b++) {

        bitset<15> bs(b);
        bool flag = true;
        for (int d = 0; d < N; d++) {
            if (bs[d] == true) {
                int num = Person[d].testimonial.size();
                for (int k = 0; k < num; k++) {
                    if (bs[Person[d].testimonial[k].first] != Person[d].testimonial[k].second) {
                        flag = false;
                    }
                }
            }
        }

        if (flag) {
            if (bs.count() > max) max = bs.count();
        }
    }

    cout << max << endl;

    system("PAUSE");
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define mem0(x) memset(x,0,sizeof(x))
#define meminf(x) memset(x,0x3f,sizeof(x))
#define VI vector<int>
#define VL vector<ll>
using namespace  std;

int main(){
    ios::sync_with_stdio(0);
    int k;cin>>k;
    // if(k%2==0||k%5==0){
    //     cout<<-1<<'\n';
    // }else{
    //     ll num = 7;
    //     ll cnt = 1;
    //     while(1){
    //         if(num%k!=0){
    //             num = (num*10+7)%k;
    //             ++cnt;
    //         }else{
    //             break;
    //         }
    //     }
    //     cout<<cnt<<'\n';
    // }
    int num = 7%k;
    int cnt = 1;
    rep(i,1,1e7){
        if(num%k==0){
            cout<<cnt;return 0;
        }
        num = (num*10+7)%k;
        ++cnt;
    }
    cout<<-1;
}


Measured memory_bytes: 3516
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include<bits/stdc++.h>
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define pb push_back
#include <x86intrin.h>
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<ll>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 1e5 + 55, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vi a(n);
	for(auto &i : a) cin >> i;
	int ans = 0;
	for(int i = 1; i + 1 < n; i++) {
		ans += (a[i]<a[i-1])^(a[i]<a[i+1]);
	}
	cout << ans;
}


Measured memory_bytes: 384
use proconio::input;

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a

fn main() {
    input! {
        n: usize,
        mut a: [i64; n],  // Vec<(i32, i32, i32)>
    }
    a.sort();
    let reva: Vec<&i64> = a.iter().rev().collect();

    let mut result:i64 = 0;
    for i in 1..reva.len() {
        result += reva[i/2];
    }
    println!("{}", result);
}

Measured memory_bytes: 7132
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		
		long[] a = new long[n];
		
		for(int i = 0; i < n; i++) {
			a[i] = Long.parseLong(sc.next());
		}
		
		Arrays.sort(a);
		
		System.out.println(a[a.length-1]-a[0]);
		
	}
}


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

using namespace std;

int tab[100005];
int opty[100005];

int main(){

ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

int n, k;
cin>>n>>k;

for(int i=1; i<=n; i++){
cin>>tab[i];
opty[i]=999999999;
}
opty[1]=0;

for(int i=2; i<=n; i++){

 for(int j=1; j<=k; j++){
        if(i-j>=1)
    opty[i]=min(abs(tab[i]-tab[i-j])+opty[i-j], opty[i]);

 }

}

cout<<opty[n];

return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include<stdio.h>
char c;
int main(void)
{
    long ans = 0;
    c=getchar();
    while(c<='9'&&c>='0') {ans=(ans<<1)+(ans<<3)+c-'0'; c=getchar();}
    long n = ans + 1;
    for (int i = 2; i < n; ++i)
    {
        int u = 0, v = 0;
        c=getchar();
        while(c<='9'&&c>='0') {u=(u<<1)+(u<<3)+c-'0'; c=getchar();}
        c=getchar();
        while(c<='9'&&c>='0') {v=(v<<1)+(v<<3)+c-'0'; c=getchar();}
        switch(u > v)
        {
            case true: ans += i * (n - i) - v * (n - u); break;
            default: ans += i * (n - i) - u * (n - v);
        }
    }
    printf("%ld", ans);
    return 0;
}


Measured memory_bytes: 1600
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int n, m;
  cin >> n >> m;
  int a, b;
  vector<int> paths[n + 1];
  vector<int> shirubes;
  int shirube[n + 1] = {};

  REP(i, m) {
    cin >> a >> b;
    paths[a].push_back(b);
    paths[b].push_back(a);
  }

  queue<tuple<int, int>> q;

  for(auto p : paths[1]) {
    q.push(make_tuple(p, 1));
  }

  while(!q.empty()) {
    tuple<int, int> val = q.front();
    q.pop();
    int room = get<0>(val);
    if(shirube[room] != 0) continue;
    shirube[room] = get<1>(val);
    for(auto p : paths[room]) {
      q.push(make_tuple(p, room));
    }
  }

  bool none = false;
  for(int i = 2; i <= n; i++) {
    if(shirube[i] == 0) none = true;
  }

  if(none) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    for(int i = 2; i <= n; i++) {
      cout << shirube[i] << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 13004
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;

int main() {
	int A, P;
	cin >> A >> P;

	int ans = ((A * 3) + P) / 2;

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <functional>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  int md = 1;
  for (int i = n; i >= 1; i--) {
    if (n % i == 0 && m % i == 0) {
      md = i;
      break;
    }
  }
  ll ans = n * (ll) m / md;
  map <ll, set <char> > q;
  for (int it = 0; it < n; it++) {
    ll cur = it * (ll) (ans / n);
    q[cur].insert(s[it]);
  }
  for (int it = 0; it < m; it++) {
    ll cur = it * (ll) (ans / m);
    q[cur].insert(t[it]);
  }
  for (auto c : q) {
    if (c.second.size() > 1) {
      cout << "-1\n";
      return 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 23808
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
a,b = LI()
print((a+b)%24)
"""
#B
n,m = LI()
p = LIR(n)
q = LIR(m)
for x,y in p:
    s = 1
    ans = float("inf")
    for i in range(m):
        if abs(x-q[i][0])+abs(y-q[i][1]) < ans:
            ans = abs(x-q[i][0])+abs(y-q[i][1])
            c = i+1
    print(c)
#C
"""
n = I()
ans = int(math.log10(n)+1)
for i in range(2,int(n**0.5)+1):
    if n%i == 0:
        ans = min(ans, max(int(math.log10(i)+1),int(math.log10(n//i)+1)))
print(ans)
"""

#D
"""
n,a,b = LI()
v = LI()
v.sort()
v = v[::-1]
ans = v[:a]
d = {}
d[ans[-1]] = 0
if ans[0] != ans[-1]:
    for i in ans:
        if i == ans[-1]:
            d[i] += 1
    k = d[i]
    d[i] = 0
    for i in v:
        if i == ans[-1]:
            d[i] += 1
    c = 1
    for j in range(min(k,d[ans[-1]]-k)):
        c *= d[ans[-1]]-j
        c //= j+1
else:
    for i in v:
        if i == ans[-1]:
            d[i] += 1
    c = 0
    for k in range(a,min(d[ans[-1]],b)+1):
        p = 1
        for j in range(min(k,d[ans[-1]]-k)):
            p *= d[ans[-1]]-j
            p //= j+1
        c += p
print(sum(ans)/a)
print(c)
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 39792
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

const ll MAX_N = 2e6 + 10;
long long inv[MAX_N], perm[MAX_N], invp[MAX_N];
void calculate() {
    inv[1] = 1;
    perm[1] = perm[0] = invp[1] = invp[0] = 1;
    for(ll i = 2; i < MAX_N; i ++) {
        inv[i] = ((-(mod / i) * inv[mod % i]) % mod + mod) % mod;
        perm[i] = (perm[i - 1] * i) % mod;
        invp[i] = (invp[i - 1] * inv[i]) % mod;
    }
}

ll comb(ll n, ll k) {
    return (((perm[n] * invp[k]) % mod) * invp[n - k]) % mod;
}

ll fpow(ll x, ull p) {
    ll pw = x, ret = 1;
    while(p) {
        if(p & 1ll) {
            ret = (ret * pw) % mod;
        }
        p /= 2ll;
        pw = (pw * pw) % mod;
    }
    return ret;
}

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    calculate();
    ll ans = 0;
    string s;
    ll k;
    cin >> k >> s;
    ll n = s.size();
    ll c = n + k;
    for(ll x = n; x <= c; x ++) {
        ll now = comb(x - 1, n - 1);
        //cout << x << " " << n << " " << now << endl;
        now *= fpow(25, x - n);
        now %= mod;
        now *= fpow(26, c - x);
        now %= mod;
        ans += now;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 52132
n = int(input())
xs = []
ys = []

for i in range(n):
    x, y = map(int, input().split())
    xs.append((x, i))
    ys.append((y, i))


xs.sort()
ys.sort()

es = []

for i in range(n-1):
    es.append((xs[i+1][0] - xs[i][0], xs[i][1], xs[i+1][1]))
    es.append((ys[i+1][0] - ys[i][0], ys[i][1], ys[i+1][1]))

es.sort()

class UF:
    def __init__(self):
        self.p = {}
    def find(self, x):
        if x not in self.p:
            self.p[x] = x
        if x == self.p[x]:
            return x
        self.p[x] = self.find(self.p[x])
        return self.p[x]
    def merge(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            self.p[x] = y


uf = UF()
ans = 0
try:
    for d, i0, i1 in es:
        c0 = uf.find(i0)
        c1 = uf.find(i1)
        if c0 == c1:
            continue
        ans += d
        uf.merge(i0, i1)
    print(ans)
except:
    print(0)


Measured memory_bytes: 58356
from sys import stdin
from random import randint
from time import time
input = lambda: stdin.readline().rstrip()
start = time()
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b.reverse()
good = False
t = time() - start
while t < 1.8:
    ok = True
    for i in range(n):
        if a[i] == b[i]:
            rng = randint(0, n - 1)
            b[i], b[rng] = b[rng], b[i]
            ok = False
    if ok:
        good = True
        break
    t = time() - start
if good:
    print("Yes")
    print(*b)
else:
    print("No")


Measured memory_bytes: 124732
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<cmath>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;



int main(){
  int hantei=1;
  ll N,i=2,tas=1;
  vector<int> V;
  cin>>N;

  if(N==0){
    cout<<0<<endl;
    return 0;
  }

  while(N!=0){
    hantei=(hantei+1)%2;
    //cout<<N<<endl;
    if(N%i!=0){
      V.push_back(1);
      if(hantei) N+=tas;
      else N-=tas;
    }else{
      V.push_back(0);
    }
    i*=2;
    tas*=2;
  }
  for(int i=V.size()-1;i>=0;i--){
    cout<<V[i];
  }
  cout<<endl;
}


Measured memory_bytes: 384
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    A = list(int(readline()) for _ in range(N))
    print('second' if all(A[i] % 2 == 0 for i in range(N)) else 'first')


if __name__ == '__main__':
    main()


Measured memory_bytes: 12932
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
const int N=2005;
int n,k;
vector<int> vec[N];
int f[N][N];
int tmp[N];
int tot[N];
int ans=0;
void dfs (int x,int fa)
{
	f[x][0]=1;tot[x]=1;
	int siz=vec[x].size();
	for (int u=0;u<siz;u++)
	{
		int y=vec[x][u];
		if (y==fa) continue;
		dfs(y,x);
		for (int i=0;i<=k;i++) tmp[i]=0;
		for (int i=0;i<=min(tot[x],k);i++)
		for (int j=0;j<=min(tot[y],k-1);j++)
		{
			int l=i+j+1;
			if (l>k) break;
			tmp[max(i,j+1)]=max(tmp[max(i,j+1)],f[x][i]+f[y][j]);
		}
		for (int i=0;i<=k;i++) f[x][i]=max(f[x][i],tmp[i]);
		tot[x]+=tot[y];
	}
	//printf("x:%d\n",x);
	for (int i=0;i<=k;i++) 
	{
	//	printf("%d ",f[x][i]);
		ans=max(ans,f[x][i]);
	}
	//printf("\n");
}
int main()
{
	scanf("%d%d",&n,&k);
	for (int u=1;u<n;u++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		vec[x].push_back(y);vec[y].push_back(x);
	}
	dfs(1,0);
	printf("%d\n",n-ans);
	return 0;
}

Measured memory_bytes: 16256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		for (int i = 0; i < values.length; i++) {
			values[i] = i + 1;
		}
		for (int i = 0; i < n; i++) {
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;
			int c;
			c = values[a];
			values[a] = values[b];
			values[b] = c;
		}
		for (int i = 0; i < values.length; i++) {
			System.out.println(values[i]);
		}
	}
}

Measured memory_bytes: 26088
#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000000;
int main(){
  int N;
  cin >> N;
  vector<vector<pair<long long, int>>> E(N);
  for (int i = 0; i < N - 1; i++){
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    E[a].push_back(make_pair(c, b));
    E[b].push_back(make_pair(c, a));
  }
  int Q, K;
  cin >> Q >> K;
  K--;
  vector<long long> d(N, INF);
  d[K] = 0;
  queue<int> q;
  q.push(K);
  while (!q.empty()){
    int v = q.front();
    q.pop();
    for (auto P : E[v]){
      int w = P.second;
      if (d[w] == INF){
        d[w] = d[v] + P.first;
        q.push(w);
      }
    }
  }
  for (int i = 0; i < Q; i++){
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    cout << d[x] + d[y] << endl;
  }
}

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

int dfs(ll cur, int n7, int n5, int n3){
	if(cur > N) return 0;
	int ret(0);
	if(n7 > 0 && n5 > 0 && n3 > 0) ret = 1;
	else ret = 0;
	ret +=
	+ dfs(cur*10+7,n7 + 1, n5, n3)
	+ dfs(cur*10+5,n7, n5 + 1, n3)
	+ dfs(cur*10+3,n7, n5, n3 + 1);
	return ret;
}

int main(){
	cin >> N;
	cout << dfs(0, 0, 0, 0) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

string s;

int main()
{
    cin >> s;
    for(char& c : s)
    {
        if(c == ',') c = ' ';
    }

    cout << s << endl;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/11  Problem: ABC 089 B / Link: http://abc089.contest.atcoder.jp/tasks/abc089_b  ----- */


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

	LL N; 
	cin >> N;
	vector<char> a(N);
	LL ans = 0LL;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		if (a[i] == 'Y')ans = 1;
	}

	
	
	cout << (!ans?"Three":"Four") << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111
	
	

	void solve(){

		
		ins(x);
		ins(x1);
		int one = 0;
		FOR(i,0,x.size()){
			if(x[i]!=x1[i])one++;
		}
		out(one);
		
		


			
			
			


				
		


		
		
		
		

		


		
		
	}



	



















int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;

template <typename t>
void print (const t & v){
    for (auto i:v){
        cout << i << " ";
    }
    cout << endl;
}

bool isprime (ll n){
    if ( n == 2 ){
        return true;
    }
    if ( n <= 1){
        return false;
    }
    if ( n%2 == 0){
        return false;
    }

    for (ll i=3; i<= sqrt(n); i+=2){
        if ( n %i == 0 ){
            return false;
        }
    }
    return true;
}

int main(){
    ll n;
    cin >> n;
    ll min=999999999999, present=0, number1=0, number2=0;
    if (isprime(n)){
        cout << n-1 << endl;
    }
    else {
        for ( ll i=2; i <= sqrt(n); i++){
            if ( n %i ==0 ){
                present = abs(i - n/i);
                if (present < min){
                    min = present;
                    number1 = i;
                    number2 = n/i;
                }
            }
        }
        cout << number1 -1 + number2 -1 << endl;
    }
    return 0;
}




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

void solve(){
  string s; cin >> s;
  string ans = "No";
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '7') ans = "Yes";
  }
  cout << ans << endl;
  return;
}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 3576
#include<stdio.h>
#include<string.h>
int main()
{
    char num[1005];
    int sum=0;
    while(1)
    {
        scanf("%s",num);
        sum=0;
        if (num[0]=='0') break;
        int i, sz=strlen(num);
        for(i=0;i<sz;i++)
 
        {
            sum+=num[i] - '0';
        }
 
    printf("%d\n",sum);
}
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;





int main() {
//    cout << setprecision(100);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int ans = 0;
    for (int i = 1; i < n - 1; i++) {
        if ((a[i - 1] < a[i] && a[i] < a[i + 1]) || (a[i - 1] > a[i] && a[i] > a[i + 1])) ans++;
    }

    cout << ans;




}




Measured memory_bytes: 256
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Sun Jan 28 21:02:12 2018
//
package main

import (
	"fmt"
)

func main() {
	var X, A, B int
	fmt.Scan(&X, &A, &B)
	fmt.Println((X - A) % B)
}


Measured memory_bytes: 512
import std.stdio;
import core.stdc.stdio;
import std.algorithm;

struct state{
	int x;
	int y;
	int z;
	int r;
}

void main(){
	while(1){

	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==0&&b==0&&c==0)
		break;
	int m = a+b+c;
	int n;
	scanf("%d",&n);
	int[] dec = new int[m];
	dec[] = 2;
	state[] sts = new state[n];
	for(int i=0;i<n;i++){
		state s;
		scanf("%d%d%d%d",&s.x,&s.y,&s.z,&s.r);
		s.x--;
		s.y--;
		s.z--;
		if(s.r==1){
			dec[s.x] = 1;
			dec[s.y] = 1;
			dec[s.z] = 1;
		}
		sts[i] = s;
	}
	for(int _=0;_<m;_++){
		foreach(st;sts){
			if(st.r==0){
				if(dec[st.x]==1&&dec[st.y]==1)
					dec[st.z]=0;
				else if(dec[st.y]==1&&dec[st.z]==1)
					dec[st.x]=0;
				else if(dec[st.z]==1&&dec[st.x]==1)
					dec[st.y]=0;
			}
		}
	}
	foreach(d;dec)
		printf("%d\n",d);
		
	}
}

Measured memory_bytes: 2392
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
  int n, k;
  cin >> n >> k;
  vector<int> a(n), cnt(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i] - 1]++;
  }
  sort(cnt.begin(), cnt.end());
  int ans = 0;
  for (int i = 0; i < n - k; i++) {
    ans += cnt[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
def run():
    card_num=int(input())

    player1_point=0
    player2_point=0

    for i in range(card_num):
        card1,card2=input().split()
    
        if card1==card2:
            player1_point+=1
            player2_point+=1
            
        else:
            if card1 == sorted([card1,card2])[1]:
                player1_point+=3
            else:
                player2_point+=3

    print(f"{player1_point} {player2_point}")


run()


Measured memory_bytes: 5612
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

bool ans[4];

int main()
{
	int A, B;

	cin >> A >> B;

	ans[A] = true;
	ans[B] = true;

	repc(i, 1, 3) if (!ans[i]) cout << i << endl;

	return 0;
}

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

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

  int t[N] = {0}, x[N] = {0}, y[N] = {0};
  for (int i = 0; i < N; i++) cin >> t[i] >> x[i] >> y[i];

  bool feasible = true;
  for (int i = 0; feasible && i < N; i++) {
    if (t[i] < x[i] + y[i]) feasible = false;
    else {
      int dist = x[i] + y[i];
      if (t[i] % 2 != dist % 2) feasible = false;
    }
  }

  cout << (feasible ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for(LL i=0; i<(n); i++)
typedef long long LL;

int main() {
	LL n; cin >> n;
	vector<LL> t(n), a(n);
	REP(i, n)cin >> t[i] >> a[i];

	LL l, r;
	REP(i, n) {

		if (i == 0)l = t[i], r = a[i];
		else{
			if (t[i] < l || a[i] < r) {
				LL x, y;
				x = l % t[i] == 0 ? l / t[i] : l / t[i] + 1;
				y = r % a[i] == 0 ? r / a[i] : r / a[i] + 1;
				if (x <= y)l = t[i] * y, r = a[i] * y;
				else l = t[i] * x, r = a[i] * x;
			}
			else l = t[i], r = a[i];
		}
		//cout << l << " " << r << endl;
	}
	cout << l + r << endl;
}

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

int main(){

    int N; cin >> N;
    vector<pair<int,int>> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i].first;
        A[i].second = i+1;
    }

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

    for(int i = 0; i < N; i++){
        cout << A[i].second << " " ;
    }
}

Measured memory_bytes: 1536
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

A = input()

n = len(A)
ans = n*(n+1)//2 + 1

for v in Counter(A).values():
	ans -= v*(v+1)//2

print(ans)

Measured memory_bytes: 10640
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;


int main(){
  int n;
  cin >> n;
  string strT, strH;
  int cntT, cntH;
  cntT = cntH = 0;
  for(int i = 0; i < n; i++){
    cin >> strT >> strH;
    if(strT > strH) cntT += 3;
    else if(strH > strT) cntH += 3;
    else if(strT == strH){
      cntT++;
      cntH++;
    }
  }
  cout << cntT << " " << cntH << endl;
}


Measured memory_bytes: 3168
from collections import Counter
def prime_factorize(n):
    f = 2
    primes = []
    while f * f <= n:
        if n % f != 0:
            f += 1
            continue
        primes.append(f)
        n //= f
    if n > 1:
        primes.append(n)
    return list(set(primes))
a, b = map(int, input().split())
ab_primes = Counter(prime_factorize(a) + prime_factorize(b))
ans = 0
for prime in ab_primes.values():
    if prime > 1:
        ans += 1
print(1 + ans)

Measured memory_bytes: 9324
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

int n, M, a[1000010];
char s[1000010];

inline int Solve (int x) {
	int res = 0;
	for (int i = 1, t = 1, su = 0; i <= n; ++i) {
		if (s[i] == '?')
			if (a[i] + t * 2 <= x) ++t, ++su;
			else --su;
		else su += s[i] == '1' ? 1 : -1;
		res = min (res, su);
	}
	return res;
}

int main () {
	scanf ("%s", s + 1);
	n = strlen (s + 1);
	for (int i = 1; i <= n; ++i) {
		a[i] = a[i - 1] + (s[i] == '1' ? 1 : -1);
		M = max (M, a[i]);
	}
	for (int i = n - 1; i >= 1; --i) a[i] = max (a[i], a[i + 1]);
	printf ("%d\n", min (M - Solve (M), M + 1 - Solve (M + 1)));
	return 0;
}

Measured memory_bytes: 8636
(function main() {
  let line = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('');
  // 初めの上昇と平坦を除去
  while (line.length > 0 && line[0] !== '\\') line.shift();
  // 終わりの下降と平坦を除去
  while (line.length > 0 && line[line.length - 1] !== '/') line.pop();

  let height_list = [0];
  let current_height = 0;
  line.forEach(function(e, i){
      if (e === '\\') current_height -= 1
      else if (e === '/') current_height += 1
      height_list.push(current_height);
  });

  let h, sum = 0;
  let holes = [];
  for (;height_list.length > 1;) {
    if (h = makeHole(height_list)) {
      sum += h;
      holes.push(h);
    }
  }

  console.log(sum);
  console.log(holes.length && holes.length + ' ' + holes.join(' '));
})();

function makeHole(list) {
    begin = list.shift();
    if (list[0] < begin && begin <= list.reduce((a, b) => Math.max(a, b), -100000)) {
    let area = 0;
      while (!(list.length === 0 || begin <= list[0])) area += begin - list.shift();
      return area;
    }
    return 0;
}



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

int main() {
  int N,K,x,S;
  cin >> N >> K;
  S=0;
  
  for(int i=0; i<N; i++){
    
    cin >> x;
    
    if(K-x>x){
      S+=x*2;
    }
    else{
      S+=(K-x)*2;
    }
    
  }
  
  cout << S << endl;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
S = []
for i in 1..N
  S.push(gets.chomp)
end
M = gets.chomp.to_i
T = []
for i in 1..M
  T.push(gets.chomp)
end

S_uniq = S.uniq
T_uniq = T.uniq
x = 0

S_uniq.each do |s|
  ss = S.count(s)
  tt = T.count(s)
  flag = ss - tt
  if x < flag
    x = flag
  end
end

print(x)


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

using namespace std;

const int MAXN = 2e5;

const int INF = 1e9;

vector <int> g[MAXN];


int main()
{
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector <vector<int>> dist(n + 1, vector<int>(3, INF));
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
    }
    int s, t;
    cin >> s >> t;
    dist[s][0] = 0;
    queue <pair<int, int>> q;
    q.push({s, 0});
    while (!q.empty()) {
        int v = q.front().first;
        int r = q.front().second;
        q.pop();
        for (auto u : g[v]) {
            if (dist[v][r] + 1 < dist[u][(r + 1) % 3]) {
                dist[u][(r + 1) % 3] = dist[v][r] + 1;
                q.push({u, (r + 1) % 3});
            }
        }
    }
    if (dist[t][0] == INF) {
        cout << -1;
    } else {
        cout << dist[t][0] / 3;
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  string res = "No";
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      int tmp = 4*i + 7*j;
      if (tmp == N) {
        res = "Yes";
        break;
      }
    }
  }
  
  cout << res << endl;
}

Measured memory_bytes: 256
// 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 a,b,c,x;cin>>a>>b>>c>>x;

  int res=0;
  rep(i, 0, a+1){
    rep(j, 0, b+1){
      rep(k, 0, c+1){
        int s = i*500 + j*100 + k*50;
        dump(s,x);
        if (s==x) res++;
      }
    }
  }
  cout << res << 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