akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

// x軸方向にtx, y軸方向にtyだけ平行移動
void translation(double tx, double ty, double &x, double &y) 
{
    x += tx;
    y += ty;
}

// thetaだけ回転
void rotation(double theta, double &x, double &y) 
{
    double tx = x;
    double ty = y;

    x = cos(theta) * tx - sin(theta) * ty;
    y = sin(theta) * tx + cos(theta) * ty;
}

// x軸に関する鏡映
void x_reflection(double &x, double &y) 
{
    y *= -1;
}


int main()
{
    double x1, y1, x2, y2, xq, yq;
	cin >> x1 >> y1 >> x2 >> y2;
    double theta = atan((y2 - y1) / (x2 - x1));
	int q;
	cin >> q;
    while (q-->0) {
		cin >> xq >> yq;
        translation(-x1, -y1, xq, yq);
        rotation(-theta, xq, yq);
        x_reflection(xq, yq);
        rotation(theta, xq, yq);
        translation(x1, y1, xq, yq);
        cout << fixed << setprecision(12) << xq << " " << yq << endl;
    }
}

Measured memory_bytes: 1340
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m,q;
	while(cin>>n>>m>>q,n){
		if(n==1){
			cout<<string(m,'0')<<endl;
		}else{
			vs in1(q),in2(q);
			rep(i,q)cin>>in1[i]>>in2[i];
			rep(i,n){
				int c=0;
				rep(j,q){
					if(in1[j][i]=='1')c++;
					if(c%2)in1[j][i]='1';
					else in1[j][i]='0';
				}
			}
			string out="";
			rep(i,m){
				vi ko;
				rep(j,n){
					bool h=true;
					rep(k,q)if(in1[k][j]!=in2[k][i])h=false;
					if(h)ko.pb(j);
				}
				if(ko.size()==1){
					if(ko[0]<10)out+=(char)(ko[0]+'0');
					else out+=(char)(ko[0]-10+'A');
				}else out+="?";
			}
			cout<<out<<endl;
		}
	}
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<std::vector<long long>> D){
    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (D[i][0] == D[i][1]) {
            cnt++;
            ans = max(ans, cnt);
        } else {
            cnt = 0;
        }
    }
    cout << (ans >= 3 ? YES : NO) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::vector<long long>> D(N, std::vector<long long>(2));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < 2 ; j++){
            scanf("%lld",&D[i][j]);
        }
    }
    solve(N, std::move(D));
    return 0;
}


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

namespace _1_6_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int n = int.Parse(str[0]);
            int m = int.Parse(str[1]);
            string[] strA = null;
            string[] strb = null;
            int[][] arrayA = new int[n][];//行の指定
            int[] arrayb = new int[m];//m個の配列
            List<int> sum = new List<int>() { };
            //行の中の列の指定
            for (int i=0; i<n; i++)
            {
                arrayA[i] = new int[m];
            }
            //n行m列のAベクトルを読み込む
            for (int i = 0; i<n; i++)
            {
                strA = Console.ReadLine().Split(' ');
                for (int j =0; j < m; j++)
                {
                    arrayA[i][j] = int.Parse(strA[j]);
                }
            }
            //m行のbベクトルを読み込む
            for (int i = 0; i<m; i++)
            {
                int a = int.Parse(Console.ReadLine());
                arrayb[i] += a;
            }

            //C1の値を計算する
            for (int i = 0; i < n; i++)
            {
                int sum0 = 0;
                for (int j = 0; j < m; j++)
                {
                    sum0= sum0 + (arrayA[i][j] * arrayb[j]);
                }
                sum.Add(sum0);
            }
            for (int i = 0; i < sum.Count(); i++)
            {
                Console.WriteLine(sum[i]);
            }
        }
    }
}



Measured memory_bytes: 18188
#include<bits/stdc++.h>
using namespace std;
int main(){
    string o,e;
    cin >> o >> e;
    if(o.size()-e.size()==0){
    for(int i=0;i<o.size();i++){
        cout << o.at(i) << e.at(i);
        }
        cout << endl;
    }
    else{
        for(int i=0;i<e.size();i++){
            cout << o.at(i) << e.at(i);
        }
        cout << o.at(o.size()-1) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*  
    Through the fish-eyed lens of tear stained eyes
    I can barely define the shape of this moment in time
    And far from flying high in clear blue skies
    I'm spiralling down to the hole in the ground where I hide
    _________________________
    _________________________
    1032 Hours of Solitude
    Quarantine_Day : 43
*/

#include<bits/stdc++.h>

using namespace std;

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

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<ll>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 1000

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

    int n; cin>>n;
    
    for(int i = 0; i <= n; i += 4){
        int k = (n - i) % 7;
        if(k == 0){
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";

    return 0;
}


Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

const int INF=5e8;


pi P,Q;
int n;
pi ps[200005];
const int M=100000000;


void rotate(pi& a){
  a={a.sc,M-1-a.fr};
}
void rotate(){
  rotate(P);rotate(Q);
  REP(i,n) rotate(ps[i]);
}
int main(){
#ifdef LOCAL_REDIR
  freopen("/home/hog/Dropbox/pg/working/in.txt","r",stdin);
#endif
  cin>>P.fr>>P.sc>>Q.fr>>Q.sc;
  cin>>n;
  REP(i,n) scanf("%d%d",&ps[i].fr,&ps[i].sc);

  while(!(P.fr<=Q.fr && P.sc<=Q.sc)){
    rotate();
  }
  if(P.sc==Q.sc){
    while(!(P.fr==Q.fr && P.sc<=Q.sc)){
      rotate();
    }
  }
  const double PI=acos(-1.0);

  double res=(Q.fr-P.fr+Q.sc-P.sc)*100.0;
  if(P.fr==Q.fr){
    int cnt=0;
    REP(i,n) if(ps[i].fr==P.fr && P.sc<=ps[i].sc && ps[i].sc<=Q.sc) ++cnt;
    res+=cnt*((PI*10)-20);
  }else{
    vector<int> ar;
    sort(ps,ps+n);
    REP(i,n){
      if(P.fr<=ps[i].fr && ps[i].fr<=Q.fr && P.sc<=ps[i].sc && ps[i].sc<=Q.sc){
        ar.pb(ps[i].sc);
      }
    }
    int m=ar.size();
    vector<int> dp(m+1,INF);
    dp[0]=-1;
    REP(i,m){
      *lower_bound(ALL(dp),ar[i])=ar[i];
    }
    int len=0;
    REP(i,m+1) if(dp[i]<INF){
        len=i;
      }
    res-=len*(20-PI*5);

    if(len==min(Q.fr-P.fr,Q.sc-P.sc)+1){
      res+=5*PI;
    }
  }
  printf("%.15f\n",res);
  return 0;
}


Measured memory_bytes: 3444
// #include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

const int INF = 1e9;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
   ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
   ostr << "}";
   return ostr;}

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


int main(void){
 ios::sync_with_stdio(false);

 int n;
 cin >> n;
 vector<string> name(n);
 vector<int> lon(n);
 REP(i, n){
   cin >> name[i];
   cin >> lon[i];
 }
 string x;
 cin >> x;

 int ans = 0;
 REP(i, n){

   int val = n - i - 1;
   string tp = name[val];
   if (x != tp) ans += lon[val];
   else break;
 }

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



Measured memory_bytes: 256
<?php
$a=explode(' ',trim(fgets(STDIN)));
if(($a[2]-$a[4]<0)|($a[3]-$a[4]<0)|($a[2]+$a[4]>$a[0])|($a[3]+$a[4]>$a[1])){echo 'No';}
else{echo 'Yes';}
?>

Measured memory_bytes: 15388
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>

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

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

int main()
{
    int sum,k,a,b;
    cin >> k>> a >> b;
    sum = k;
    while (sum<=1000)
    {
        if (a<=sum && sum<=b)
        {
            cout << "OK" << endl;
            return 0;
        }
        sum+= k;
    }

    cout << "NG" << endl;
    
    return 0;
}

Measured memory_bytes: 3648
N = int(input())

XYs = []
for _ in range(N):
  XYs.append(list(map(int, input().split())))
  
for i in range(101):
  for j in range(101):
    f = 1
    for k in range(N):
      if XYs[k][2] > 0:
        h = XYs[k][2] + abs(XYs[k][0]-i) + abs(XYs[k][1]-j)
        break
    for k in range(N):
      if max(h - abs(XYs[k][0]-i) - abs(XYs[k][1]-j), 0) != XYs[k][2]:
        f = 0
        break
    if f == 1:
      print(i,j,h)
      exit()

Measured memory_bytes: 9220
n, y = map(int, input().split())
a = 0
a += (y%5000)//1000
n -= a
y -= a*1000
if n*10000>=y and y>=n*1000:
  if y>= 5000*n:
    m = (y-5000*n)//5000
    print(m,n-m,a)
  else:
    m = y-1000*n+9000
    for i in range(n):
      m -= 9000
      if m < 0:
        print(-1,-1,-1)
        exit(0)
      if m%4000 == 0:
        j = m//4000
        print(i,j,n-i-j+a)
        exit(0)
else:
  print(-1,-1,-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define st first
#define nd second
#define INF 1000000007LL
using namespace std;

int main(){
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for(int i = 0; i < (int)s.size(); i++)
    ans += (s[i] != t[i]);
  cout << ans << '\n'; 
}

Measured memory_bytes: 3820
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	long i,n,k;
	cin>>n>>k;
	pair<long,long>a[114514];
	for(i=0;i<n;i++)cin>>a[i].first>>a[i].second;
	sort(a,a+n);
	for(i=0;;)
	{	
		if(k<=a[i].second)
		{
			cout<<a[i].first<<endl;
			break;
		}
		else
		{
			k-=a[i].second;
			i++;
		}
	}
}

Measured memory_bytes: 2048
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int T, X; cin >> T >> X;
    printf("%.12f\n", (double)T / X);
    return 0;
}


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

using namespace std;


int main()
{

int N;
double x;
string u;

int rate=380000;
double sum;
cin>>N;
for(int i=0;i<N;i++){
  cin>>x>>u;
  if(u=="BTC")x=x*rate;
  sum=sum+x;
}
cout<<sum<<endl;
return 0;
}

Measured memory_bytes: 256
n,x,m=[int(i) for i in raw_input().split()]
x%=m
a=[x]
d={}
d[x]=0
pos=-1
for i in range(1,min(n,100000)):
    t=(a[-1])**2
    t%=m
    if(d.get(t,-1)!=-1):
        pos=d[t]
        break
    d[t]=i
    a.append(t)
s=0
for i in a:
    s+=i
if pos!=-1:
    n-=len(a)
    a=a[pos:]
    s1=0
    for i in a:
        s1+=i
    s+=s1*(n/len(a))
    n%=len(a)
    for i in range(n):
        s+=a[i]
print s


Measured memory_bytes: 83620
import math
a, b, x = map(int, input().split())

if a * a * b / 2 >= x:
    print(90 - math.degrees(math.atan(2 * x / (a * b * b))))
else:
    print(math.degrees(math.atan((2 * a * a * b - 2 * x) / (a * a * a))))


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int pref[200005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, k;
    cin >> n >> k;
    long long ret = 0;
    map<int, int> mp{{0, 1}};
    for (int i=1; i<=n; i++) {
        int a;
        cin >> a;
        pref[i] = (pref[i-1] + a) % k;
        if (i >= k)
            mp[((pref[i-k] - (i - k)) % k + k) % k]--;
        ret += mp[((pref[i] - i) % k + k) % k]++;
    }
    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 13780
N = int(input())


def func(x):
    if len(x) == N:
        print("".join(x))
        return

    last = ord(max(x)) - ord("a") + 1 if x else 0
    for i in range(min(26, last) + 1):
        x.append(chr(ord("a") + i))
        func(x)
        x.pop()


func([])


Measured memory_bytes: 78192
import java.util.*;
import java.io.*;
import java.math.BigInteger;

/*
 * H - Grid
 */
public class Main
{
private double[] trueProb;

public static void main( String[] args ) throws Exception
{
	new Main().run();
}

public void run() throws Exception
{
	final Scanner sc = new Scanner( getInputStream() );
	final int N = sc.nextInt();
	double[] p = new double[ N ];
	for( int i = 0; i < N; ++i )
	{
		p[ i ] = sc.nextDouble();
	}
	trueProb = new double[ N + 1 ];
	trueProb[ 0 ] = 1.0;//一番初めはTRUEの回数が0であるパターンの確率が100%

	for( int i = 1; i <= N; ++i )
	{
		f1( i, p[ i - 1 ] );
	}

	double prob = 0;
	for( int i = (N + 1) / 2; i <= N; ++i )
	{
		prob += trueProb[ i ];
	}

	p( prob );
}

/*
 * n回目
 */
private void f1( int n, double prob )
{
	for( int i = n; i >= 0; --i )
	{
		if( i == n )
		{
			trueProb[ i ] = trueProb[ i - 1 ] * prob;
		}
		else if( i == 0 )
		{
			trueProb[ 0 ] = trueProb[ 0 ] * (1 - prob);
		}
		else
		{
			trueProb[ i ] = trueProb[ i - 1 ] * prob + trueProb[ i ] * (1 - prob);
		}
	}
}

public static void p( Object o )
{
	System.out.println( o );
}

public static InputStream getInputStream() throws IOException
{
	//p( System.getProperties() );
	if( System.getProperty( "test" ) != null )
	{
		return new FileInputStream( "1" );
	}
	else
	{
		return System.in;
	}
}

}


Measured memory_bytes: 36636
#![allow(unused_imports)]
#![allow(dead_code)]

use std::collections::*;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let modulo: i64 = 998244353;
    let n: i64 = sc.read();
    let m: i64 = sc.read();
    let k: i64 = sc.read();
    let comb = CombinationMod::new(n as usize, modulo);
    let mut ans: i64 = 0;
    for i in 0..=k {
        let mut add: i64 = 1;
        add = add * comb.query(n - 1, i) % modulo;
        add = add * m % modulo;
        add = add * modpow(m - 1, n - i - 1, modulo) % modulo;
        ans = (ans + add) % modulo;
    }
    if ans < 0 {
        ans = (ans + modulo) % modulo;
    }
    println!("{}", ans);
}

fn modpow(a: i64, x: i64, m: i64) -> i64 {
    if x == 0 {
        1
    } else if x % 2 != 0 {
        a * modpow(a, x - 1, m) % m
    } else {
        let half = modpow(a, x / 2, m);
        half * half % m
    }
}

struct CombinationMod {
    fac: Vec<i64>,
    inv: Vec<i64>,
    inv_fac: Vec<i64>,
    modulo: i64,
}
impl CombinationMod {
    pub fn new(size: usize, modulo: i64) -> CombinationMod {
        let mut fac = vec![1; size + 1];
        let mut inv = vec![1; size + 1];
        let mut inv_fac = vec![1; size + 1];
        for i in 2..=size {
            fac[i] = fac[i - 1] * i as i64 % modulo;
            inv[i] = modulo - inv[modulo as usize % i] * (modulo / i as i64) % modulo;
            inv_fac[i] = inv_fac[i - 1] * inv[i] % modulo;
        }
        CombinationMod {
            fac: fac,
            inv: inv,
            inv_fac: inv_fac,
            modulo: modulo,
        }
    }
    fn query(&self, n: i64, r: i64) -> i64 {
        self.fac[n as usize] * self.inv_fac[r as usize] % self.modulo
            * self.inv_fac[(n - r) as usize]
            % self.modulo
    }
    fn inverse(&self, n: i64) -> i64 {
        self.inv[n as usize]
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 6760
from itertools import combinations
N = int(input())
town = []
for n in range(N):
    x, y = map(int,input().split())
    town.append((x,y))

ans = 0
for i,j in combinations(town,2):
    ans += ((i[0]-j[0])**2 + (i[1]-j[1])**2)**0.5
print (2*ans/N)

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

long long gcd(long long m,long long n){
    if(n==0){
        return abs(m);
    }else{
        return gcd(n,m%n);
    }
}

int main(){
    int n,m,ans = 0;
    cin >> n;
    cin >> ans;
    for(int i=0;i<n-1;i++){
        long long a;
        cin >> a;
        ans = gcd(ans,a);
    }

    cout << ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;
string st1,st2;
int main(){
	getline(cin,st1);
	getline(cin,st2);
	for(int i=0;i<st1.length()-1;i++)
		for(int j=i+1;j<st1.length();j++)
			if(st1[j]<st1[i]) swap(st1[j],st1[i]);
	for(int i=0;i<st2.length()-1;i++)
		for(int j=i+1;j<st2.length();j++)
			if(st2[j]>st2[i]) swap(st2[j],st2[i]);
	if(st2>st1) printf("Yes\n");
		else printf("No\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
const int MAX=2e5;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  ll A,B,K;
  cin >> A >> B >> K;
  if(K>=A+B){
    cout << 0 << " " << 0 << endl;
  }
  else if(A<=K&&K<A+B){
    cout << 0 << " " << A+B-K << endl;
  }
  else{
    cout << A-K << " " << B << endl;
  }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){  
  string s;
  cin >> s;
  int n=s.size();
  if(s.substr(0,7)=="keyence"){ cout << "YES" << endl; return 0; }
  if(s.substr(n-7,7)=="keyence"){ cout << "YES" << endl; return 0; }
  if(s.substr(0,1)=="k" && s.substr(n-6,6)=="eyence"){ cout << "YES" << endl; return 0; }
  if(s.substr(0,2)=="ke" && s.substr(n-5,5)=="yence"){ cout << "YES" << endl; return 0; }
  if(s.substr(0,3)=="key" && s.substr(n-4,4)=="ence"){ cout << "YES" << endl; return 0; }
  if(s.substr(0,4)=="keye" && s.substr(n-3,3)=="nce"){ cout << "YES" << endl; return 0; }
  if(s.substr(0,5)=="keyen" && s.substr(n-2,2)=="ce"){ cout << "YES" << endl; return 0; }
  if(s.substr(0,6)=="keyenc" && s.substr(n-1,1)=="e"){ cout << "YES" << endl; return 0; }
  cout << "NO" << endl;
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n+1);
    rep(i,n+1) cin >> a[i];
    vector<ll> b(n);
    rep(i,n) cin >> b[i];
    vector<ll> f_1(n), f_2(n);
    ll ans = 0;
    rep(i,n){
        if(i==0){
            f_1[i] = min(a[i],b[i]);
        }else{
            f_1[i] = min(a[i]-f_2[i-1], b[i]);
        }
        f_2[i] = min(a[i+1], b[i]-f_1[i]);
        ans = ans + f_1[i] + f_2[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define endl enjoy_codeforces
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    int n;std::cin>>n;
    std::vector<int>a(n);
    for(int i=0;i<n;i++){
        std::cin>>a.at(i);
        a.at(i)--;
    }
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=i<a.at(i)&&i==a.at(a.at(i));
    }
    std::cout<<ans<<'\n';
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  string right = "yuiophjklnm";
  string s;
  while(cin >> s) {
    if(s[0] == '#') return 0;
    int ans = 0;
    bool isright = right.find(s[0]) != string::npos;
    FOR(i,1,s.length()) {
      // ????????????
      if(right.find(s[i]) != string::npos) {
        if(!isright) ans++;
        isright = true;
      } else {
        if(isright) ans++;
        isright = false;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=max(a*c,a*d);
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    cout<<ans<<endl;
}

Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

class Main {
    static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static final PrintWriter pw = new PrintWriter(System.out);
    public static void main(String[] args) throws IOException {
        String[] inputs = br.readLine().split(" ");
        int n = Integer.parseInt(inputs[0]);
        int r = Integer.parseInt(inputs[1]);
        
        int ans = n < 10 ? r + 100 * (10 - n) : r;

        pw.println(ans);
        pw.flush();
    }
}

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

x, y = map(int, input().split())

# グループを識別する値を入れておく
a = [0,1,3,1,2,1,2,1,1,2,1,2,1]

if a[x] == a[y]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int main(){

	int checkTable[1001],dp[46][501];

	for(int i = 1; i <= 1000; i++)checkTable[i] = 0;

	for(int i = 1; i <= 500; i++)dp[1][i] = i;

	for(int row = 2; row <= 45; row++){
		for(int col = 1; col <= 501-row; col++){
			dp[row][col] = col + dp[row-1][col+1];
			if(dp[row][col] <= 1000)checkTable[dp[row][col]]++;
		}
	}

	int N;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		printf("%d\n",checkTable[N]);
	}
	return 0;
}

Measured memory_bytes: 2676
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

typedef long long ll;

#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 FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;

ll po[POW_MAX + 2];

ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}

ll mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}

ll comb(int n, int r) {
  return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}

int const N_MAX = 1e5;

int N, K;
int h[N_MAX + 1];

int main() {
  scanf("%d %d", &N, &K);
  rep(i, N) {
    scanf("%d", &h[i]);
  }
  sort(h, h + N, greater<int>());

  int h_diff = 1e9;
  rep(i, N - K + 1) {
    h_diff = min(h_diff, h[i] - h[i + K - 1]);
  }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main() {
    int x=0,y=0,z=0,w=0,n=0,m=0;
    cin >>x>>y;
    cout <<(x-1)*(y-1);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

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

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

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

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

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

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


// TODO: write
int main() {
  ll n;cin>>n;
  ll ans = (n / 500) * 1000;
  ans += ((n%500)/5)*5;
  print(ans);
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
s = input()

for i in range(len(s)):
    c = s[i]
    if (i+1)%2==1:
        if c not in ("R","U","D"):
            print("No")
            exit()
    else:
        if c not in ("L","U","D"):
            print("No")
            exit()
print("Yes")


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

using namespace std;

#define ll long long
#define vl vector<ll>
#define pb push_back
#define sz size
#define xx first
#define yy second

#define all(x) begin(x), end(x)

#define FOR(i,start,end) for(ll i=start; i < end; ++i)
#define FORD(i,start,end) for(ll i=start; i < end; --i)

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

  double r = 0;
  FOR(i,0,N) {
    ll x;
    cin >> x;

    r += 1.0 / x;
  }

  cout << 1.0 / r << endl;
}


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


char mat[1005][1005];
int row,col;
long long dp[1005][1005];
long long mod = 1e9+7;

int main()
{
    cin>>row>>col;
    for(int i = 1 ;i<=row;i++)
    {

        for(int j =1 ;j<=col ;j++)
            cin>>mat[i][j];
    }
    if(mat[1][1]=='#')
    cout<<"0";
    else
    {
        dp[1][1] = 1;
        for(int i =2 ;i<=col ;i++)
        {
            if(mat[1][i]=='.')
            dp[1][i] = dp[1][i-1]%mod;
        }
        for(int i =2 ;i<=row ;i++)
        {
            if(mat[i][1]=='.')
            dp[i][1] = dp[i-1][1]%mod;
        }
        for(int i = 2 ; i<=row ;i++)
        {
            for(int j =2  ;j <= col; j++)
            {
                if(mat[i][j]=='.')
                dp[i][j]=(dp[i-1][j]%mod + dp[i][j-1]%mod)%mod;
            }
        }
        cout<<dp[row][col];
    }
}


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

using namespace std;

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

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

	int N, M, X, Y; cin >> N >> M >> X >> Y;
	vector<int> x(N, 0), y(M, 0);
	rep (i, N){
		cin >> x[i];
	} // end rep
	rep (j, M){
		cin >> y[j];
	} // end rep

	sort(ALL(x));
	sort(ALL(y));

	bool ok = false;
	for (int z = -100; z <= 100; ++z){
		if (X < z && z <= Y){
			if (x[N-1] < z && z <= y[0]){
				ok |= true;
			} // end if
		} // end if
	} // end for

	cout << (ok ? "No War" : "War") << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=(1<<16)+5;
const int mod=1e9+7;
ll n,m,a[maxn],jc[maxn],ny[maxn],cnt[maxn],dp[20][maxn];
bool cmp(ll a,ll b){return a>b;}
ll C(ll n,ll m)
{
	//return (jc[n]/jc[m]*jc[n-m])%mod;
	if(n<m) return 0;
	return ((jc[n]*ny[m])%mod*ny[n-m])%mod;
}
ll ksm(ll x,ll k)
{
	ll res=1;
	while(k)
	{
		if(k&1) res=res*x%mod;
		x=x*x%mod;k>>=1;
	}
	return res;
}
int main()
{
	scanf("%lld%lld",&n,&m);
  	for(int i=1;i<=m;i++) scanf("%lld",&a[i]);
  	sort(a+1,a+m+1,cmp);
	ll aim=(1<<n),ans=0;
	jc[0]=1;dp[0][0]=1;
	for(int i=1;i<=aim;i++) jc[i]=jc[i-1]*i%mod;
	ny[aim]=ksm(jc[aim],mod-2);
	for(int i=aim-1;i>=0;i--) ny[i]=ny[i+1]*(i+1)%mod;
  	for(int i=1;i<aim;i++) cnt[i]=cnt[i^(i&-i)]+1;
  	for(int i=0;i<aim;i++) cnt[i]=(cnt[i]&1)?mod-1:1;
	for(int i=1;i<=m;i++)
		for(int s=0;s<aim;s++)
		{
			dp[i][s]=dp[i-1][s];
			for(int j=0;j<n;j++)
				if(s&(1<<j))
    			{
					int t=s^(1<<j);
					dp[i][s]=(dp[i][s]+(dp[i-1][t]*C(aim-a[i]-t,(1<<j)-1)%mod)*jc[(1<<j)])%mod;
				}
		}
	for(int i=0;i<aim;i++)
    	ans=(ans+cnt[i]*dp[m][i]%mod*jc[(aim-1)^i])%mod;
	printf("%lld\n",ans*(1<<n)%mod);
	return 0;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int main()
{
    int N,M;
    while(cin>>N>>M,N)
    {
        vector<int >c(M,0);
        vector<vector<pair<int,int> > >student(M);
        int r;cin>>r;
        REP(i,r)
        {
            int t,n,m,s;
            cin>>t>>n>>m>>s;n--;m--;
            if(s)
            {
                if(c[m]==0)student[m].pb(mp(t,t));
                c[m]++;
            }else
            {
                c[m]--;
                if(c[m]==0)student[m].back().se=t;
            }
        }
        int q;cin>>q;
        REP(i,q)
        {
            int ts,te,m;
            cin>>ts>>te>>m;m--;
            int ans=0;
            REP(j,student[m].size())
            {
                ans+=max(0,min(te,student[m][j].se)-max(ts,student[m][j].fi));
            }
            cout<<ans<<endl;
        }
    }
}


Measured memory_bytes: 3352
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	if(n == 2){
		if(a[0] - a[1] > a[1] - a[0]){
			cout << a[0] - a[1] << endl;
			cout << a[0] << " " << a[1] << endl;
		} else {
			cout << a[1] - a[0] << endl;
			cout << a[1] << " " << a[0] << endl;
		}
		return 0;
	}
	multiset<int> neg, pos;
	for(int i = 0; i < n; i++)
		if(a[i] < 0) neg.insert(a[i]);
		else pos.insert(a[i]);
	if(n == 3){
		if(a[0] == a[n - 1]){
			cout << a[0] << endl;
			cout << a[0] << " " << a[0] << endl;
			cout << a[0] << " " << 0 << endl;
			return 0;
		}
	}
	vector<pair<int,int> > ops;
	if(neg.empty()){
		auto x = *pos.begin(); pos.erase(pos.begin());
		auto y = *(--pos.end()); pos.erase(--pos.end());
		ops.push_back({x, y});
		neg.insert(x - y);
	}
	if(pos.empty()){
		auto x = *neg.begin(); neg.erase(neg.begin());
		auto y = *(--neg.end()); neg.erase(--neg.end());
		ops.push_back({y, x});
		pos.insert(y - x);
	}
	while(pos.size() > 1){
		auto x = *neg.begin(); neg.erase(neg.begin());
		auto y = *pos.begin(); pos.erase(pos.begin());
		ops.push_back({x, y});
		neg.insert(x - y);
	}
	while(neg.size()){
		auto x = *neg.begin(); neg.erase(neg.begin());
		auto y = *pos.begin(); pos.erase(pos.begin());
		ops.push_back({y, x});
		pos.insert(y - x);
	}
	cout << *pos.begin() << endl;
	for(auto e : ops) cout << e.first << " " << e.second << endl;
	return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
int ptn;
string a,b;
int dp[3002][3002];

void print(int m,int n){
	if(m==0||n==0){
		return;
	}
	if(a[m]==b[n]){
		print(m-1,n-1);
		cout<<a[m];
		return;
	}else if(dp[m][n]==dp[m-1][n]){
		print(m-1,n);
	}else{
		print(m,n-1);
	}
}

int main(){
	
	int m,n;
	cin>>a >>b;
	a='0'+a;
	b='0'+b;
	m=a.length()-1;
	n=b.length()-1;
	for(int i=0;i<=m;++i){
		dp[i][0]=0;
	}
	for(int i=0;i<=n;++i){
		dp[0][i]=0;
	}
	for(int i=1;i<=m;++i){
		for(int j=1;j<=n;++j){
			if(a[i]==b[j]){
				dp[i][j]=1+dp[i-1][j-1];
			}else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	ptn=dp[m][n];
	print(m,n);
	cout<<endl;
	return 0;
}

Measured memory_bytes: 35712
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
const int maxn = 100005;
#define NIL -1

struct node{
    int parent;
    int left;
    int right;
};

node T[maxn];
int D[maxn], n;

void rec(int node, int depth){
    D[node] = depth;
    if(T[node].left != NIL)
        rec(T[node].left, depth+1);
    if(T[node].right != NIL)
        rec(T[node].right, depth);
}

void print(int u){
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "depth = " << D[u] << ", ";

    if(T[u].parent == NIL)  cout << "root, ";
    else if(T[u].left == NIL)   cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";

    for(int i = 0, child = T[u].left; child != NIL; i++, child = T[child].right){
        if(i)   cout << ", ";
        cout << child;
    }
    cout << "]" << endl;
}

int main(){
    int v,k,child,sib,root;
    cin >> n;
    for(int i = 0; i < n; i++)
        T[i].parent = T[i].left = T[i].right = NIL;

    for(int i = 0; i < n; i++){
        cin >> v >> k;
        for(int j = 0; j < k; j++){
            cin >> child;
            if(j == 0)  T[v].left = child;
            else    T[sib].right = child;

            sib = child;
            T[child].parent = v;
        }
    }

    for(int i = 0; i < n; i++){
        if(T[i].parent == NIL)
            root = i;
    }

    rec(root,0);
    for(int i = 0; i < n; i++)  print(i);
}



Measured memory_bytes: 4648
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#define ll long long
#include<cstring>
#define rep(i,n) for(int i=0;i<n;i++)
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>QUE;//きゅー

int length(char* str) {
	int len = strlen(str);
	return len;
}

ll LCM(ll a,ll b)
{

    ll r, x, tmp;
    ll i, j;
    ll lcm;
    i = a;
    j = b;

    /* 自然数 a > b を確認・入替 */
    if (a < b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    /* ユークリッドの互除法 */
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    lcm = (i / b) * j;

    return lcm;
}

int main()
{
    int N;
    int ans = 0;
    int a[100010], b[100010];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> b[i];
    }

    
    for (int i = 0; i < N; i++) {
        int sum = 0;
        for (int j = 0; j <= i; j++) {
            sum += a[j];
        }
        for (int j = i; j < N; j++) {
            sum += b[j];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<time.h>
#include<math.h>
int main(void)
{
     int N,i,q=0;
     char S[100],T[100];
     scanf("%d",&N);
     scanf("%s %s",S,T);
     for(i=0;i<N;i++){
         if(q==0){
           printf("%c",S[i]);
           q=1;
         }
         if(q==1){
           printf("%c",T[i]);
           q=0;
         }
      }
     return 0;
}

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

int main()
{
    int n;
    vector<int> p;
    cin >> n;
    p.resize(n);
    for(auto& e : p) cin >> e;
    
    int cnt = 0;
    int min = 0;
    for(int i = 0; i < (int)p.size(); i++)
    {
        if(i == 0)
        {
            cnt++;
            min = p[i];
        }
        else if(p[i] <= min)
        {
            cnt++;
            min = p[i];
        }
    }
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
  int A1,A2,A3;
  scanf("%d %d %d",&A1,&A2,&A3);
  
  if ((A1 + A2 + A3) >= 22) {
    printf("bust\n");
  } else {
    printf("win\n");
  }
    
    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def solve(A: int, B: int):
    A_primes = set(prime_factorize(A))
    B_primes = set(prime_factorize(B))
    print(len(A_primes & B_primes) + 1)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll A, B, Q; cin >> A >> B >> Q;
	vll S(A+2), T(B+2);

	S[0] = T[0] = -1e18;
	S[A+1] = T[B+1] = 1e18;
	for (int i = 1; i <= A; i++) cin >> S[i];
	for (int i = 1; i <= B; i++) cin >> T[i];
	while (Q--) {
		ll x; cin >> x;
		ll minv = LLINF;
		auto pos1 = lower_bound(begin(S), end(S), x);
		auto pos2 = lower_bound(begin(T), end(T), x);
		
		chmin(minv, x - min(*(pos1-1), *(pos2-1)));
		chmin(minv, max(*pos1, *pos2) - x);
		chmin(minv, 2*(x-*(pos1-1)) + (*pos2 - x));
		chmin(minv, (x-*(pos1-1)) + 2*(*pos2 - x));
		chmin(minv, 2*(x-*(pos2-1)) + (*pos1 - x));
		chmin(minv, (x-*(pos2-1)) + 2*(*pos1 - x));
		cout << minv << endl;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	ll N, A, B, C, D, E;
	cin >> N >> A >> B >> C >> D >> E;
	ll mn = min({A, B, C, D, E});
	cout << (N + mn - 1) / mn + 4 << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main(void) {
  ll a, b, c;
  scanf("%lld %lld.%lld", &a, &b, &c);
  ll r = a * (b*100+c) / 100;
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(x) x.begin(),x.end()
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define endl "\n"
const ll maxn = 2e5+2;

int main()
{
    fastio; //remove for interactive
    ll i, j, k, n, m, t;
    vll h, dp(1e5+5,0);

    cin>>n>>k;
    for ( i = 0; i < n; i++)
    {
        cin>>j;
        h.pb(j);
    }

    if(n-1<=k)
    {
        cout<<h[n-1]-h[0]<<endl;
        return 0;
    }
    
    for ( i = 0; i <= k; i++)
    {
        dp[i]=abs(h[i]-h[0]);
    }
    
    for ( i = k+1; i < n; i++)
    {
        ll mini=INT64_MAX;
        for ( j = 1; j <= k; j++)
        {
            mini=min(mini,abs(h[i]-h[i-j])+dp[i-j]);
        }
        dp[i]=mini;
    }
    
    cout<<dp[n-1]<<endl;
        
    return 0;
}

Measured memory_bytes: 4936
#include<bits/stdc++.h>
using namespace std;
template<typename T>
inline void read(T &x)
{
	x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
}
	while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
	x*=f;
	return;
}	
template<typename T>
void write(T x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);
	putchar(x%10+'0');
	return;
}
double a,b;
int main()
{
    cin>>a>>b;
    for(double i=1;i<=100000;i++)
    if(floor(i*0.08)==a&&floor(i*0.1)==b)
    {
        printf("%.0f\n",i);
        return 0;
    }
    cout<<-1<<endl;
	return 0;
}


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

int main() {
  string V = "aiueo";
  char S;
  int flag;
  cin >> S;
  for (int i = 0; i < 5 ;i++ ) {
  	if (S == V.at(i)) { 
      cout << "vowel" << endl;
      break;
    }
    else if (i == 4) {
      cout << "consonant" << endl;
    }
    
  }
 
}

Measured memory_bytes: 256