akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;

typedef long long ll;

int N;
vector<int> A;

void input_init(void) {
	cin >> N;
	A.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> A[i];
	sort(A.begin(), A.end(), greater<int>());
}

ll solve(void) {
	ll sum = 0;
	int M = N / 2;
	if (N % 2 == 0) {
		for (int i = 0; i < M - 1; ++i)
			sum += (ll)A[i];
		for (int i = 0; i < M - 1; ++i)
			sum += (ll)A[i + 1];
		sum += (ll)A[M - 1];
	}
	else {
		for (int i = 0; i < M; ++i)
			sum += (ll)A[i];
		for (int i = 0; i < M; ++i)
			sum += (ll)A[i + 1];
	}
	return sum;
}

int main(void) {
	input_init();
	ll ans = solve();
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N; cin>>N;
  vii A(10,vi(10));
  REP(i,1,N){
    string S=to_string(i);
    int P=S[0]-'0',Q=S[S.size()-1]-'0';
    A[P][Q]++;
  }
  int ans=0;
  REP(i,1,N){
    string S=to_string(i);
    int P=S[0]-'0',Q=S[S.size()-1]-'0';
    ans+=A[Q][P];
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 256
a=[]
b={}
n,m=map(int,input().split())
for _ in range(m):
	i,j=map(int,input().split())
	if i==1:
		a.append(j)
	elif j==n:
		b[i]=1
for i in a:
	if i in b:
		print('POSSIBLE')
		break
else:
	print('IMPOSSIBLE')

Measured memory_bytes: 18424
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  set<char> st;
  REP(i,(int)s.size()){
    st.insert(s[i]);
  }
  cout << (s.size()==st.size() ? "yes" : "no")<< '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int s,a,b; cin>>s,a=s/100,b=s%100;
	cout<<(0<a&&a<13?00<b&&b<13?"AMBIGUOUS":"MMYY":00<b&&b<13?"YYMM":"NA");
}

Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod=1e9+7;
const ll INF=0x3f3f3f3f;
const ll maxn=1e5+5;
const ll pi = acos(-1.0);
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s=="SUN") cout<<"7"<<endl;
	else if(s=="MON") cout<<"6"<<endl;
	else if(s=="TUE") cout<<"5"<<endl;
	else if(s=="WED") cout<<"4"<<endl;
	else if(s=="THU") cout<<"3"<<endl;
	else if(s=="FRI") cout<<"2"<<endl;
	else if(s=="SAT") cout<<"1"<<endl;
}

Measured memory_bytes: 256
A,B,M = [int(hoge) for hoge in input().split()]
A = [int(hoge) for hoge in input().split()]
B = [int(hoge) for hoge in input().split()]
ans = min(A) + min(B)
for i in range(M):
    x,y,c = [int(hoge) for hoge in input().split()]
    ans = min(ans,A[x-1]+B[y-1]-c)
print(ans)

Measured memory_bytes: 71108
N,A,B = map(int,input().split())
S = input()

cnt = A + B

for i in range(N):
    if cnt == 0:
        print('No')
    elif cnt > 0 and B == 0 and S[i] == 'b':
        print('No')
    elif S[i] == 'a':
        print('Yes')
        cnt -= 1
    elif S[i] == 'b':
        print('Yes')
        cnt -= 1
        B -= 1
    else:
        print('No')

Measured memory_bytes: 4016
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = sum(b)
for i in range(n-1):
    ind = a[i] - 1
    ind_next = a[i+1] - 1
    if ind + 1 == ind_next:
        ans += c[ind]
print(ans)

Measured memory_bytes: 3188
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <string.h>

using namespace std;

int main()
{
   int n, m, z;
   scanf("%d %d",&n,&m);
   if(n>m)
    z=n+n-1;
   else if(n<m)
    z=m+m-1;
   else
    z=m+n;
   printf("%d\n",z);
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = 2147483647;
const ll LLINF = 1LL<<60;



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

int a,b,c;
cin >> a >> b >> c;
if(a+b+c>=22)fin("bust");else fin("win");

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
h=list(map(int,input().split()))
G=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
ans=0
for i in range(n):
    check=True
    for j in G[i]:
        if h[i]<=h[j]:
            check=False
    if check:
        ans+=1
print(ans)

Measured memory_bytes: 89360
#include <iostream>

using namespace std;

int main() {
    int N;
    scanf("%d", &N);
    int count[200001] = {};
    int A[200001];
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
        count[A[i]]++;
    }
    long long sum = 0;
    for (int i = 1; i <= N; i++) {
        sum += (long)count[i] * (count[i] - 1) / 2;
    }
    for (int i = 0; i < N; i++) {
        cout << sum - count[A[i]] + 1 << '\n';
    }
    return 0;
}


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

const int MAX_N = 1e5 + 5;
int n, ans;
int Arr[MAX_N];
int cnt[MAX_N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> Arr[i];
		if (n < Arr[i]) {
			i--;
			n--;
			ans++;
		}
	}

	for (int i = 0; i < n; i++)
		cnt[Arr[i]]++;

	for (int i = 1; i < MAX_N; i++)
		if (cnt[i] < i)
			ans += cnt[i];
		else
			ans += (cnt[i] - i);

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

Measured memory_bytes: 640
object Main {
  def main(args: Array[String]): Unit = {
    val input = new java.util.Scanner(System.in)
    val a = input.nextInt
    val b = input.nextInt

    println(gcd(a, b))
  }

  def gcd(a: Int, b: Int): Int = if(b == 0){ a }else{gcd(b, a % b)}
}

Measured memory_bytes: 42196
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    ll N,K;
    cin>>N>>K;
    vector<ll> A(N);
    rep(i,N)cin>>A[i];
    vector<ll> F(N);
    rep(i,N)cin>>F[i];
    sort(all(A));
    sort(all(F));
    reverse(all(F));
    //print(A);print(F);

    auto check = [&](ll X){
        //最小値をXにするために必要な修行の回数cnt
        //これがK以下かどうか
        ll cnt = 0;
        rep(i,N){
            //dif
            cnt += max(0LL, A[i] - X/F[i]);
        }
        return cnt <= K;
    };
    //成績の最小値を求める
    ll ng = -1;
    ll ok = 1e13 + 1;
    while(ok - ng > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid)){
            ok = mid;
        }
        else{
            ng = mid;
        }
    }
    cout<<ok<<endl;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
using namespace std;
const int n=55556;

void eratosthenes(bool prime[]){
    for (int i=0; i<n; i++) {
        prime[i]=true;
    }
    prime[0]=prime[1]=false;
    for (int i=0; i<n; i++) {
        if (prime[i]) {
            for (int j=i+i; j<n; j+=i){
                prime[j]=false;
            }
        }
    }
}
int main() {
    std::ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    bool Prime[n];
    eratosthenes(Prime);
    int N;
    cin>>N;
    vector<int> a;
    int idx=0;
    for (int i=0; i<n; i++) {
        if (Prime[i]) {
            if (i%5==1) {
                a.push_back(i);
                idx++;
                if (idx==N) {
                    break;
                }
            }
        }
    }
    for (int i=0; i<N; i++) {
        cout<<a[i]<<" "<<flush;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
  int N;
  cin >> N;
  vector<ll>A(N);
  for (int i = 0; i < N; i ++) cin >> A[i];
  ll kabu_k[100];
  ll kabu_m[100];
  ll mony_m[100];
  kabu_k[0] = 0;
  kabu_m[0] = 1000;
  mony_m[0] = 1000;
  for (int i = 0; i < N; i ++) {
    //baikyaku
    ll hue_m = kabu_k[i] * A[i];
    mony_m[i + 1] = max(mony_m[i], hue_m + kabu_m[i]);
    //kounyuu
    ll kab = mony_m[i] / A[i];
    ll mon = mony_m[i] % A[i];
    kabu_k[i + 1] = kabu_k[i];
    kabu_m[i + 1] = kabu_m[i];
    if (kabu_k[i] < kab) {
      kabu_k[i + 1] = kab;
      kabu_m[i + 1] = mon;
    }
    if (kabu_k[i] == kab && kabu_m[i] < mon) {
      kabu_k[i + 1] = kab;
      kabu_m[i + 1] = mon;
    }
  }
  /*for (int i = 0; i <= N; i ++) {
    cout << kabu_k[i] << ' ' << kabu_m[i] << ' ' << mony_m[i] << endl;
  }*/
  //cout << endl;
  cout << mony_m[N] << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pii pair<int, int>
#define pll pair<long long, long long>
#define rep(i,l,r) for(long long i = l;i<r;i++)

#define fastout  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace __gnu_pbds;

typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> order_set;

const int INF = (int)1e9 + 7;
const long long LLINF = (long long)1e18 + 7;

mt19937 mt('O' + '4' + 'K' + 'O');

void kekek()
{
    
    mt();
    #ifdef EB_UG
        freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout);
    #endif
    #ifndef EB_UG
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #endif
}

int main() {
    kekek();
    string s;
    cin >> s;
    if (s == "MON") {
        cout << 6 << endl;
        return 0;
    }
    if (s == "TUE") {
        cout << 5 << endl;
        return 0;
    }
    if (s == "WED") {
        cout << 4 << endl;
        return 0;
    }
    if (s == "THU") {
        cout << 3 << endl;
        return 0;
    }
    if (s == "FRI") {
        cout << 2 << endl;
        return 0;
    }
    if (s == "SAT") {
        cout << 1 << endl;
        return 0;
    }
    if (s == "SUN") {
        cout << 7 << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int t=0,i,j,a,b,n,k;
	scanf("%d",&n);
	for(i=0;i<25;i++)
	{
		for(j=0;j<25-i;j++)
		{
			if(i*4+j*7==n)t=1;
		}
	}
	if(t)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,a,b;
  cin >> n >> a >> b;
  
  if ((n*a) > b){
      cout << b << endl;
  }
  else if ((n*a) < b){
    cout << n*a << endl;
  }
  else{
    cout << b << endl;
  }
}

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

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string;
		int n, s;
		
		long res[][] = new long[11][1001];
		res[0][0] = 1;
		for(int i = 0; i <= 100; i++){
			for(int j = 9; j >= 0; j--){
				for(int k = 0; k + i <= 1000; k++){
					res[j + 1][i + k] += res[j][k];
				}
			}
		}
		
		while(!(string = reader.readLine()).equals("0 0")){
			n = Integer.valueOf(string.split(" ")[0]);
			s = Integer.valueOf(string.split(" ")[1]);
			
			System.out.println(res[n][s]);
		}
		reader.close();
	}
}

Measured memory_bytes: 25344
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner (System.in);
	int n = Integer.parseInt(scan.nextLine());
	int[][] graph = new int[n+1][n+1];
	int[] index = new int[n+1];
	int u, k, v;
	String[] input;
	for (int i = 0; i < n; i++) {
	    input = scan.nextLine().split(" ");
	    u = Integer.parseInt(input[0]);
	    k = Integer.parseInt(input[1]);
	    for (int j = 0; j < k; j++) {
		v = Integer.parseInt(input[2+j]);
		graph[u][v] = 1;
	    }
	}
	DFS dfs = new DFS(n, graph);
	dfs.dfs();
	dfs.printResult();
    }
}
class DFS {
    int n;
    int[][] graph;
    int[] d;
    int[] f;
    int timestamp;
    DFS (int n, int[][] graph) {
	this.n = n;
	this.graph = graph;
	d = new int[n+1];
	f = new int[n+1];
	timestamp = 1;
    }
    void dfs () {
	for (int i = 1; i <= n; i++) {
	    dfsNode(i);
	}
    }
    void dfsNode (int id) {
	if (d[id] > 0) {
	    return;
	}
	d[id] = timestamp++;
	for (int next = 1; next <=n; next++) {
	    if (graph[id][next] == 1) {
		dfsNode(next);
	    }
	}
	f[id] = timestamp++;
    }
    void printResult () {
	StringBuilder sb = new StringBuilder();
	for (int i = 1; i <= n; i++) {
	    sb.append(i + " " + d[i] + " " + f[i] + "\n");
	}
	System.out.print(sb);
    }
}

Measured memory_bytes: 26964
// dp[i]=min cost occured to reach ith position


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

    vector<int> dp(n);
    for(int i=1;i<n;i++){
        dp[i]=dp[i-1]+(abs(A[i]-A[i-1]));
        if(i>1){
            dp[i]=min(dp[i], dp[i-2]+(abs(A[i]-A[i-2])));
        }
    }

    cout<<dp[n-1]<<endl;
    
}

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

int main(){
  int N;
  cin>>N;
  double A[N],B[N],suma,sumb,cnt;
  suma=0;
  sumb=0;
  cnt=0;
  for (int i=0;i<N;i++){
    cin>>A[i];
    suma=suma+A[i];
  }
  for (int i=0;i<N;i++){
    cin>>B[i];
    sumb=sumb+B[i];
  }  
  for(int i=0;i<N;i++){
    if(A[i]<B[i]){
      cnt+=ceil((B[i]-A[i])/2);
    }
  }
  //cout<<sumb<<" "<<suma<<" "<<cnt<<endl;

  if(sumb-suma>=cnt){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;
const ll INF = 1061109567;
const double EPS = 1e-10;
int main(){

    string a[3];
    int next=0;
    char buf;
    cin>>a[0]>>a[1]>>a[2];
    for(int i=0;i<3;i++){
        reverse(a[i].begin(),a[i].end());
    }
    while(true){
        if(a[0].empty()&&next==0){
            cout<<"A"<<endl;
            break;
        }else if(a[1].empty()&&next==1){
            cout<<"B"<<endl;
            break;
        }else if(a[2].empty()&&next==2){
            cout<<"C"<<endl;
            break;
        }
        buf=a[next].back();
        a[next].pop_back();
        if(buf=='a'){
            next=0;
        }else if(buf=='b'){
            next=1;
        }else{
            next=2;
        }
        
    }
    return 0;
}


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

using namespace std;

int main()
{

    int a,p;
    while(cin>>a>>p)
    {
        int ans=0;
    if(a*3-p>=0)ans=p;
        int sum=0;
        sum=a*3-p;
        ans=ans+sum/2;
        cout<<ans<<endl;

    }


  //  cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{


	static int get(String s) {
		boolean ok=true;
		for(char c:s.toCharArray())
			if(c!='A' && c!='G' && c!='C' && c!='T')
				return 0;
		return s.length();
	}
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner();
		PrintWriter out=new PrintWriter(System.out);
		String s=sc.next();
		int ans=0;
		for(int l=0;l<s.length();l++)
			for(int r=l;r<s.length();r++)
				ans=Math.max(ans, get(s.substring(l, r+1)));
		out.println(ans);
	
		out.close();

	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		Scanner(String fileName) throws FileNotFoundException{
			br=new BufferedReader(new FileReader(fileName));
		}
		String next() throws IOException {
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		String nextLine() throws IOException {
			return br.readLine();
		}
		int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		long nextLong()  throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 23508
import collections
from collections import defaultdict
import math
import numpy as np
import re
import itertools
import bisect

a,b,h,m=map(int, input().split())

l = 6*m
s = 0.5*m+30*h

kakudo = min(abs(l-s),360-abs(l-s))
print(math.sqrt(a*a+b*b-2*b*a*math.cos(math.radians(kakudo))))

Measured memory_bytes: 27208
N = int(input())
K = int(input())

Nstr = str(N)
Nlen = len(Nstr)

'''------dp設定-------
dp[i][j][k] 
dp[][][] 
i:桁数
j:非0の数を使った回数
k: 0:それまでの桁数は、Nと同じ
   1:それまでの桁数で、Nより小さいが確定
配るdpで更新
'''

#初期化
dp = [[[0 for i3 in range(2)] for i2 in range(K+1)] for i1 in range(Nlen+1)]
dp[0][0][0] = 1

#今の桁から次の桁に配るループ
for i in range(Nlen):
    for j in range(4):
        for k in range(2):
            nd = int(Nstr[i])
            for d in range(10):
                ni = i+1
                nj = j
                nk = k
                if d > 0:
                    nj += 1
                if nj > K:
                    continue
                if k == 0:
                    if d > nd:
                        continue
                    if d < nd:
                        nk = 1
                dp[ni][nj][nk] += dp[i][j][k]

print(dp[Nlen][K][0]+dp[Nlen][K][1])

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];

struct xy{double x,y;};
void koch_curve(int n, xy a, xy b){
    if(n < 1) return;
    xy s = {(2*a.x+b.x)/3, (2*a.y+b.y)/3};
    xy t = {(a.x+2*b.x)/3, (a.y+2*b.y)/3};
    double ux = cos(M_PI/3)*(t.x-s.x) - sin(M_PI/3)*(t.y-s.y) + s.x;
    double uy = sin(M_PI/3)*(t.x-s.x) + cos(M_PI/3)*(t.y-s.y) + s.y;
    xy u = {ux,uy};
    
    
    koch_curve(n-1, a, s);
    printf("%f %f\n",s.x,s.y);
    koch_curve(n-1, s, u);
    printf("%f %f\n",u.x,u.y);
    koch_curve(n-1, u, t);
    printf("%f %f\n",t.x,t.y);
    koch_curve(n-1, t, b);
}

int main(){
    int n; cin >> n;
    xy a = {0,0};
    xy b = {100,0};
    
    printf("%f %f\n",a.x,a.y);
    koch_curve(n, a, b);
    printf("%f %f\n",b.x,b.y);
    
    return 0;
}


Measured memory_bytes: 3228
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
int main(){
  int N,mini = 100000000;
  cin >> N;
  for(int i = 1;i <= N-1;++i){
    int tmp_i = i;
    int x = N - tmp_i;
    int i_sum = 0,x_sum = 0;
    while(tmp_i > 0 || x > 0){
      i_sum += tmp_i % 10;
      x_sum += x % 10;
      tmp_i /= 10;
      x /= 10;
    }
    mini = min(mini,i_sum + x_sum);
  }
  cout << mini << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void)
{
    int a[50],b,m,n,i,j=0,k=0,l=0,p=0,x=0,y=0,z=0;
    char s[1000],ss[1000],c;

    scanf("%s",s);
    b=strlen(s);

    for(i=0; i<b; i++){
        if(s[i]!='B'){
            c=s[i];
            ss[j]=c;
            j++;
        }
        else {
            if(j>0) j=j-1;
        }
    } //43
    ss[j]='\0';
    printf("%s",ss);
    return 0;
}

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>
#include <fstream>

#define SIZE 100005
#define MOD 1000000007

using namespace std;

class CSubarraySum {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int n, k, s;
    cin >> n >> k >> s;
    vector<int64_t> v(n, s);
    int64_t now = s;
    for (int j = k; j < n; ++j) v[j] = s == 1 ? s + 1 : s - 1;
    for (const auto &item : v) cout << item << " ";
    cout << endl;
  }
};


int main() {
    CSubarraySum solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include<algorithm>
#include <set>
#include <utility>
#include <cmath>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <ctime>
#include <limits>
#include <istream>
#include <ostream>
#include <complex.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define INF 1e16
#define mod 10000000007
#define mmax(x,y)(x>y?x:y);
#define mmin(x,y)(x<y?x:y);

int main()
{
	int n;
	cin>>n;
	vector<int> a(n);
	vector<int> b(n);
	for(int i=0;i<n;i++)
		{cin>>a[i];

			b[i]=a[i];}
	sort(b.begin(),b.end());
	for(int i=0;i<n;i++)
	{
		if(a[i]==b[n-1])
			cout<<b[n-2]<<endl;
		else
			cout<<b[n-1]<<endl;
	}


	return 0;
}

Measured memory_bytes: 3200
import Control.Monad
import qualified Data.IntMap as IM

solve :: [(Int, Int)] -> [Int] -> [Int]
solve [] _ = []
solve (px:pxs) ts = (sum $ solve' px ts 1) : solve pxs ts

solve' :: (Int, Int) -> [Int] -> Int -> [Int]
solve' _ [] _ = []
solve' px@(p, x) (t:ts) count = current : solve' px ts (count + 1)
  where current = if p == count
                  then x
                  else t

main :: IO ()
main = do
  getLine
  ts <- map read . words <$> getLine :: IO [Int]
  let tis = IM.fromList $ zip [1..] ts
  m <- readLn
  let toTuple [x, y] = (x, y)
  pxs <- replicateM m $ toTuple . map read . words <$> getLine :: IO [(Int, Int)]
  mapM_ print $ solve pxs ts

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

int main() {
  int N;
  cin>>N;
  vector<int> P(N),Q(N);
  for(int i=0;i<N;i++){
    cin>>P.at(i);
  }
  for(int i=0;i<N;i++){
    cin>>Q.at(i);
  }
  vector<int> perm = P;
  int p_num=0,q_num=0;
  int i=1;
  sort(perm.begin(),perm.end());
  do{
    if(perm==P)
      p_num=i;
    if(perm==Q)
      q_num=i;
    i++;
  }while(next_permutation(perm.begin(),perm.end()));
  
  cout<<abs(p_num-q_num)<<endl;
}


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

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

long long MOD = 1000000000 + 7;
int N,M,Q;
vector<int> a,b,c,d;
int max_val;

void solve(vector<int> v){
  if(v.size() <= N){
    // cerr << "vsize " << v.size() << endl;
    int last_num = (v.size() == 0 ? 1: v.back());
    for(int i = last_num; i <= M; i++){
      vector<int> tmp = v;
      tmp.push_back(i);
      solve(tmp);
    }
  } else { 
    int tmp_val = 0;
    for(int i = 0; i < Q; i++){
      if(v.at(b[i]) - v.at(a[i]) == c[i]){
        tmp_val += d[i];
      }
    }
    if(max_val < tmp_val){
      max_val = tmp_val;
    }
  }
}

int main(){
  cout << setprecision(10);
  cin >> N >> M >> Q;
  a.assign(Q,0);
  b.assign(Q,0);
  c.assign(Q,0);
  d.assign(Q,0);
  for(int i = 0; i < Q; i++){
    cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    a.at(i)--;
    b.at(i)--;
  }
  max_val = 0;
  vector<int> tmp;
  solve(tmp);
  cout << max_val << endl;

}


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

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    vector<int>v(3);
    v[0] = a ; v[1]=b ;v[2] = c;
    if( abs(a-c) <=d)cout<<"Yes"<<endl;
    else
    {
        sort(v.begin(),v.end());
        
        if( v[1] - v[0] <= d && v[2] - v[1] <= d) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
char*n[]={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
int main(void){
	int m,d;
	for(;scanf("%d%d",&m,&d),m;puts(n[(d+13*-~m/5)%7]))m<3?d-=2,m+=12:0;
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<math.h>
#include<set>
#include<iomanip>
#include<stdio.h>
#include<deque>
#include<stack>
#include<map>
#include<queue>
#include<cstring>
#define M 1000000007
#define pb push_back
#define mp make_pair
#define int long long
using namespace std;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;cin>>n;
	int i;
	vector<pair<int,int> > v;
	for(i=0;i<n;i++)
	{
		int x;cin>>x;
		v.pb({x,i+1});
	}
	sort(v.begin(),v.end());
	for(i=0;i<n;i++)
		cout<<v[i].second<<' ';
	cout<<endl;
}

Measured memory_bytes: 2544
#include<iostream>
#include<set>
#include<vector>

#define F first
#define S second
#define PB push_back
#define pii pair<int, int>

using namespace std;

const int MAXN = 100005, INF = 1e9;
int d[MAXN];
vector<pii > v[MAXN];
set<pii > s;

void dijkstra(int n, int r)
{
	fill(d, d + n, INF);
	d[r] = 0;
	for(int i = 0; i < n; i++)
		s.insert({d[i], i});
	while(s.size())
	{
		int x = s.begin()->S;
		s.erase(s.begin());
		if(d[x] == INF)
			return;
		for(auto y : v[x])
			if(d[x] + y.S < d[y.F])
			{
				s.erase({d[y.F], y.F});
				d[y.F] = d[x] + y.S;
				s.insert({d[y.F], y.F});
			}
	}
}

int main()
{
	int n, m, r;
	cin >> n >> m >> r;
	for(int i = 0; i < m; i++)
	{
		int x, y, w;
		cin >> x >> y >> w;
		v[x].PB({y, w});
	}
	dijkstra(n, r);
	for(int i = 0; i < n; i++)
		if(d[i] == INF)
			cout << "INF" << endl;
		else
			cout << d[i] << endl;
	return 0;
}

Measured memory_bytes: 14980
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>

using namespace std;

const double eps = 1e-10;

class Vector
{
public:
  double x;
  double y;

  Vector(){}
  Vector( double x, double y ) : x(x), y(y) {}

  Vector operator + ( const Vector v ) { return Vector( x + v.x, y + v.y ); }
  Vector operator - ( const Vector v ) { return Vector( x - v.x, y - v.y ); }
  Vector operator * ( const double k ) { return Vector( x * k, y * k ); }
  Vector operator / ( const double k ) { return Vector( x / k, y / k ); }
  bool operator < ( const Vector &v ) const { return x * x + y * y < v.x * v.x + v.y * v.y; }

  double abs() { return sqrt( norm() ); }
  double norm() { return x * x + y * y; }

  static double dot( Vector v1, Vector v2 ) { return v1.x * v2.x + v1.y * v2.y; }
  static double cross( Vector v1, Vector v2 ) { return v1.x * v2.y - v1.y * v2.x; }
};

class Distance
{
public:
  Vector p0, p1, p2, p3;
  Distance(){}
  Distance( Vector p0, Vector p1, Vector p2, Vector p3 ) : p0(p0), p1(p1), p2(p2), p3(p3) {}
  int solve();
  double dist( Vector a, Vector b );
  bool intersect();
};

bool Distance::intersect()
{
  Vector p10 = p1 - p0;
  Vector p21 = p2 - p1;
  Vector p31 = p3 - p1;

  Vector p32 = p3 - p2;
  Vector p03 = p0 - p3;
  Vector p13 = p1 - p3;

  return ( Vector::cross( p10, p21 ) * Vector::cross( p10, p31 ) < 0 &&
           Vector::cross( p32, p03 ) * Vector::cross( p32, p13 ) < 0 );
}

double Distance::dist( Vector a, Vector b )
{
  double ret;
  double dt = Vector::dot( a, b );

  if ( dt < 0 )
    ret = b.abs();
  else if ( dt < a.norm() )
    ret = fabs( Vector::cross( a, b ) ) / a.abs();
  else
    {
      Vector ba = b - a;
      ret = ba.abs();
    }
      
  return ret;
}

int Distance::solve()
{

  double ret;

  if ( intersect() )
    ret = 0;
  else
    ret = min( min( dist( p1 - p0, p2 - p0 ), dist( p1 - p0, p3 - p0 ) ),
               min( dist( p3 - p2, p0 - p2 ), dist( p3 - p2, p1 - p2 ) ) );
  
  cout << fixed << setprecision(10) << ret << endl;
  
  return 0;
}

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

  for ( auto i = 0; i < q; ++i )
    {
      double x0, y0, x1, y1, x2, y2, x3, y3;
      cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
      
      Distance d( Vector(x0, y0), Vector(x1, y1), Vector(x2, y2), Vector(x3, y3));

      d.solve();
    }      

  return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    ll H;
    cin >> H;

    ll logH = 0;
    while (H > 0) {
        ++logH;
        H /= 2;
    }
    --logH;

    ll ans = 0;
    for (int i = 0; i <= logH; i++) {
        ans += (1LL << i);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <string>
#include <array>
#include <random>
#include <chrono>
 
int main(void){
	int a, b;
	std::cin >> a>> b;
	if(a<13)b/=2;
	if(a<=5)b=0;
	std::cout << b << std::endl;
	return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':

	N, M = map(int, input().split())
	n=[]
	for j in range(N):
		n.append(0)

	for i in range(M):
		a, b = map(int, input().split())
		n[a-1]+=1
		n[b-1]+=1

	for j in range(N):
		print(n[j])

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int main(){
    int N;
    string s;
    cin>>N;
    map<string,int> mp;
    for(int i=0;i<N;i++){
        cin>>s;
        mp[s]=1;
    }
    if(mp.size()==4)
        cout<<"Four";
    else
    {
        cout<<"Three";
    }
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var s = Console.ReadLine();
		var n = s.Length;
		var k = int.Parse(Console.ReadLine());

		foreach (var g in s.Select((c, i) => new { c, i }).GroupBy(_ => _.c).OrderBy(g => g.Key))
		{
			var ss = g.SelectMany(_ => Enumerable.Range(1, Math.Min(k, n - _.i)).Select(j => s.Substring(_.i, j))).Distinct().OrderBy(x => x).ToArray();
			if (k <= ss.Length) { Console.WriteLine(ss[k - 1]); break; }
			k -= ss.Length;
		}
	}
}


Measured memory_bytes: 14064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

ll mod = 1e9+7;

ll mod_pow(ll a, ll n, ll mod){
    ll ret = 1;
    while(n > 0){
        if(n & 1) ret = (ret*(a % mod))%mod;
        a = ((a%mod)*(a%mod)) % mod;
        n = n >> 1;
    }
    return ret;
}

ll dp[100010][13];

int main(){
    string S;
    cin >> S;
    ll N = S.size();

    rep(i, 0, N+1){
        rep(j, 0, 13) dp[i][j] = 0;
    }
    dp[0][0] = 1;

    rep(i, 1, N+1){
        ll pw = mod_pow(10, N-i, 13);
        if(S[i-1] == '?'){
            rep(j, 0, 10){
                ll now = (j * pw) % 13;
                rep(k, 0, 13){
                    dp[i][(now + k) % 13] += dp[i-1][k];
                    dp[i][(now + k) % 13] %= mod;
                }
            }
        }else{
            ll now = (pw * (ll)(S[i-1] - '0')) % mod;
            rep(j, 0, 13){
                dp[i][(now + j) % 13] = dp[i-1][j];
            }       
        }
    }

    cout << dp[N][5] << endl;
    return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

ll v[1<<16], dp[1<<16], done[1<<16], a[20][20];

ll solve(int mask){
    ll &r = dp[mask];
    if(done[mask]) return r;
    done[mask] = true;
    for(int x=mask; x; x = (x-1)&mask){
        r = max(r, solve(x^mask)+v[x]);
    }
    return r;
}

int main(){FIN;
    int n; cin >> n;
    fore(i,0,n) fore(j,0,n) cin >> a[i][j];
    fore(i,0,1<<n){
        fore(j,0,n){
            fore(x,0,n){
                if((i&(1<<j)) && (i&(1<<x))) v[i] += a[j][x];
            }
        }
        v[i] /= 2;
    }
    cout << solve((1<<n)-1) << "\n";
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include <algorithm>
#include <set>
#include<math.h>
#include<vector>
#include<map>
using namespace std;

int main(){
    int n;
    cin >> n;
    int h[n];
    for(int i = 0;i < n;i++){
        int t;
        cin >> t ;
        h[i] = t;
    }
    int count = h[0];
    for(int i = 0;i < n-1;i++){
        if(h[i] >= h[i+1])continue;
        if(h[i] < h[i+1]){
            count += h[i+1]-h[i];
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
def inint(): return int(input())
def inlint(): return list(map(int, input().split()))
def infloat(): return float(input())
def inlffloat(): return list(map(float, input().split()))
def inl(): return list(input())
def putlint(): return "".join(list(map(str, ans)))

a,b = input().split()
if (a=="H" and b=="H") or (a=="D" and b=="D"):
    print("H")
else:
    print("D")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long INF = 1e18+5;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    long long d,n;
    cin >> d >> n;
    long long sol = 100*n;

    if(d == 0 && n != 100) {
        cout << n;
        return 0;
    }
    else if(d == 2)
        sol *= 100;
    if(n == 100) {
        if(d==1)
            cout << 101*100;
        else if(d == 2)
            cout << 101*100*100;
        else
            cout << 101;
    }
    else
        cout << sol;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a,b;
  cin>>a>>b;
  vector<char>mojia(a.size());
  vector<char>mojib(b.size());
  for(int i=0;i<a.size();i++){
    mojia[i]=a[i];
  }
  for(int i=0;i<b.size();i++){
    mojib[i]=b[i];
  }
  sort(a.begin(),a.end());
  sort(b.rbegin(),b.rend());
  if(b[0]-a[0]>0){
    cout<<"Yes"<<endl;
    return 0;
  }else if(b[0]-a[0]<0){
    cout<<"No"<<endl;
    return 0;
  }else{
    for(int i=0;i<min(a.size(),b.size());i++){
      if(b[i]-a[i]<0){
        cout<<"No"<<endl;
        return 0;
      }
    }
    if(a.size()>=b.size()){
      cout<<"No"<<endl;
      return 0;
    }else{
      cout<<"Yes"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	vector<string> cell(8);
	REP(i, 8){
		cin >> cell[i];
	}
	bool first = true;
	int able = 0;
	while (able < 2){
		int turn_n = 0;
		int x, y, w;
		for (int i = (first ? 0 : 7); 0 <= i&&i < 8;i+=(first?1:-1)){
			for (int j = (first ? 0 : 7); 0 <= j&&j < 8; j += (first ? 1 : -1)){
				if (cell[i][j] == '.'){
					int count = 0;
					int w2 = 0;
					REP(k, 8){
						if (0 <= j + dx[k] && j + dx[k] < 8 && 0 <= i + dy[k] && i + dy[k] < 8 && cell[i + dy[k]][j + dx[k]] != '.'){
							int count2 = 0;
							int x2 = j + dx[k];
							int y2 = i + dy[k];
							while (0 <= y2 && y2 < 8 && 0 <= x2 && x2 < 8){
								if (cell[y2][x2] == '.')
									break;
								if (first){
									if (cell[y2][x2] == 'o'){
										count += count2;
										w2 += 1 << k;
										break;
									}
								}
								else{
									if (cell[y2][x2] == 'x'){
										count += count2;
										w2 += 1 << k;
										break;
									}
								}
								x2 += dx[k];
								y2 += dy[k];
								count2++;
							}
						}
					}
					if (count > turn_n){
						turn_n = count;
						x = j;
						y = i;
						w = w2;
					}
				}
			}
		}
		if (turn_n == 0){
			able++;
		}
		else{
			able = 0;
			cell[y][x] = first ? 'o' : 'x';
			REP(i, 8){
				if ((w >> i) & 1){
					int x2 = x+dx[i];
					int y2 = y + dy[i];
					while (0 <= x2 + dx[i] && x2 + dx[i] < 8 && 0 <= y2 + dy[i] && y2 + dy[i] < 8 && cell[y2][x2] == (first ? 'x' : 'o')){
						cell[y2][x2] = first ? 'o' : 'x';
						x2 += dx[i];
						y2 += dy[i];
					}
				}
			}
		}
		first = !first;
	}
	REP(i, 8){
		cout << cell[i] << endl;
	}
}

Measured memory_bytes: 3204
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

#include <complex>
#include <queue>
#include <cstdio>
using namespace std;
 
const double EPS = 1e-9;
const double PI = acos(-1);
 
typedef complex<double> P;
typedef vector<P> G;
 
struct L :public vector<P> {
    L(const P &a,const P &b){
        push_back(a);
        push_back(b);
    }
};
 
#define next(P,i) (P[(i+1)%P.size()])
#define curr(P,i) (P[(i+0)%P.size()])
 
double cross(const P &a,const P &b){
    return imag(conj(a)*b);
}
double dot(const P &a,const P &b){
    return real(conj(a)*b);
}
 
int ccw(P a,P b,P c){
    b -= a;
    c -= a;
    if( cross(b,c) > 0 ) return +1;
    if( cross(b,c) < 0 ) return -1;
    if( dot(b,c) < 0 ) return +2;
    if( norm(b) < norm(c) ) return -2;
    return 0;
}
 
P crosspoint(const L &l,const L &m){
    double A = cross(l[1]-l[0],m[1]-m[0]);
    double B = cross(l[1]-l[0],l[1]-m[0]);
    if( abs(A) < EPS && abs(B) < EPS) return m[0];
    return m[0]+B/A*(m[1]-m[0]);
}
 
 
G convex_cut(const G &poly,const L &l){
    G Q;
    for(int i = 0 ; i < poly.size() ; i++){
        P A = curr(poly,i) , B = next(poly,i);
        if( ccw(l[0],l[1],A)!=-1)Q.push_back(A);
        if( ccw(l[0],l[1],A)*ccw(l[0],l[1],B)<0)Q.push_back(crosspoint(L(A,B),l));
    }
    return Q;
          
}
 
L bisector(P a,P b){
    P A = (a+b) * P(0.5,0);
    return L(A,A+(b-a)*P(0,PI/2));
}
G voronoi(G g,vector<P> v,int s){
    for(int i = 0 ; i < v.size() ; i++){
        if( i != s ){
            g = convex_cut(g,bisector(v[s],v[i]));
        }
    }
    return g;
}
 
double Area(const G& poly) {
	double A = 0;
	for (int i = 0; i < poly.size(); ++i)A += cross(curr(poly, i), next(poly, i));
	return abs(A)/2;
}                                  


int main(){
    int n;
	int a,b,c,d,e,f;
	int t = 1;
    while(cin >> a >> b >> c >> d >> e >> f && a){
        G area,p;
        area.push_back(P(0,0));
        area.push_back(P(0,10000));
        area.push_back(P(10000,10000));
        area.push_back(P(10000,0));
        p.push_back(P(a,b));
		p.push_back(P(c,d));
		p.push_back(P(e,f));
        G v = voronoi(area,p,0);
        printf("%d %.8lf\n",t,(Area(v))/(10000.0*10000.0));
		t++;
    }
}

Measured memory_bytes: 1244
N = int(input())
WS = [[int(i) for i in input().split()] for i in range(N)]
WS = sorted(WS, key=lambda x: x[1])
total = 0
for w in WS:
    total += w[0]
    if total > w[1]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 90072
N, M = map(int, input().split())
# status = [(1, 0)]  # 赤, 白の個数のステータス
# status.extend([(0, 1)]*(N-1))
status = [1]*N
candidate = [False]*N
candidate[0] = True
# print(status)
for _ in range(M):
    x, y = map(lambda x: int(x)-1, input().split())
    if candidate[x]:
        candidate[y] = True
    status[x] -= 1
    if status[x] == 0:
        candidate[x] = False
    status[y] += 1
print(sum(candidate))


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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for (int i=0; i<N; i++) {
    cin >> vec.at(i);
  }
  
  int i=0;
  int num = 1;
  int shutsuryoku = -1;
  while (i<N) {
    num = vec.at(num-1);
    if (num == 2) {
      shutsuryoku = i + 1;
      break;
    }
    i++;
  }
  
  cout << shutsuryoku << endl;
    
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define bg begin()
#define en end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll gcd(ll a,ll b){
    if(a==0)
    return b;
    else
    return gcd(b%a,a);
}
ll sod(ll x){
    ll r,sum=0;
    while(x>0){
        r=x%10;
        x/=10;
        sum+=r;
    }
    return sum;
}
using namespace std;
int main()
{
    ll n,d,x,y,c=0;
    cin>>n>>d;
    ll i;
    for(i=0;i<n;i++){
        cin>>x>>y;
        if(x*x+y*y<=d*d)
        c++;
    }
    cout<<c;
}

Measured memory_bytes: 3632
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL gcd(LL a, LL b) {
	return b != 0 ? gcd(b, a % b) : a;
}

LL lcm(LL a, LL b) {
	return a * b / gcd(a, b);
}



int main() {
	LL a, b; cin >> a >> b;
	cout << lcm(a,b) << endl;
	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())
 
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


int main() {
    int a,b;
    cin>>a >> b;
    cout << 6-a-b << endl;
}

Measured memory_bytes: 256