akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<list>
#include<cstring>
#include<stack>
#include<string>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
const int maxn = 1000000;
long long bit[maxn];
int n;
int sum(int i)
{
	int s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i&-i;
	}
	return s;
}
void add(int i, int x)
{
	while (i <= n)
	{
		bit[i] += x;
		i += i&-i;
	}
}
class num
{
public:
	int pos, val;
	num(int a, int b) :pos(a), val(b) {}
	num() :pos(0), val(0) {}
	bool operator <(const num& n1)
	{
		return this->val > n1.val;
	}
	num& operator=(const num&n)
	{
		this->pos = n.pos;
		this->val = n.val;
		return *this;
	}
};
num N[200100];
int main()
{
	memset(bit, 0, sizeof bit);
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		int val;
		scanf("%d", &val);
		N[i].val = val;
		N[i].pos = i;
		
	}
	sort(N + 1, N + 1 + n);
	long long ans = 0;
	for (int i = 1; i <= n; i++)
	{
		ans += sum(N[i].pos);
		add(N[i].pos, 1);
	}
	cout << ans << endl;
	return 0;
}


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


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    uint64_t X;
    cin >> X;
    uint64_t money = 100;
    int d = 0;

    while (money < X) {
        ++d;
        money = money  + money / 100ULL;
    }
    cout << d << endl;

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
// 検索タグ 文字列 printf
int main() {
	// 入力
	string S;cin>>S;
    
	// 解法
    bool ans = true;
	REP(i,S.size()){
        if ((i+1)%2==1 & S[i]=='L') ans = false;
        if ((i+1)%2==0 & S[i]=='R') ans = false;
        // printf("%lld, %c, %d\n", i, S[i], ans);
    }

	//出力
	if (ans) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<set>
#include<algorithm>
#include<queue>
using namespace std;
const int N=3e5+5;
int a[N];
typedef long long ll;
priority_queue<int,vector<int>,greater<int> >q;
priority_queue<int>Q;
ll pre[N];
int main(){
    int n;scanf("%d",&n);
    int m=3*n;
    for(int i=1;i<=m;i++) scanf("%d",a+i);
    ll sum=0;
    for(int i=1;i<=2*n;i++){
        q.push(a[i]);
        sum+=a[i];
        if(q.size()>n){
            sum-=q.top();
            q.pop();
        }
        if(i>=n) pre[i]=sum;
        pre[i]=max(pre[i],pre[i-1]);
    }
    ll ans=-1e18;
    sum=0;
    for(int i=m;i>n;i--){
        Q.push(a[i]);
        sum+=a[i];
        if(Q.size()>n){
            sum-=Q.top();
            Q.pop();
        }
        if(Q.size()==n){
            ans=max(ans,pre[i-1]-sum);
        }
    }
    printf("%lld",ans);
}


Measured memory_bytes: 4088
import sys
import math

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()

ans = 0
for i in range(N,0,-1):
	if len(str(i))%2: ans += 1
print(ans)

Measured memory_bytes: 3060
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let _ = scan!(usize);
    let vs = scan!(i64;;);
    let total = vs.iter().sum::<i64>();
    let m = scan!(usize);
    for _ in 0..m {
        let (p, x) = scan!(usize, i64);
        println!("{}", total - vs[p - 1] + x);
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
const int INF = (1 << 30);

//毎回変える場所
#define N_MAX 200


//問題文のとおり
int N, even,tmp;
int main() {
	cin >> N;
	REP(i, N) {
		cin >> tmp;
		if (tmp % 2 == 0)even++;
	}
	long ans = 1;
	long dec = 1;
	REP(i, N)ans *= 3;
	REP(i, even)dec *= 2;
	cout << ans - dec << endl;
	cin >> N;
	return 0;
}

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

int main(void){
  int A,B;
  cin>>A>>B;
  if(A!=1&&B!=1){
    if(A>B)cout<<"Alice";
    else if(A==B)cout<<"Draw";
    else cout<<"Bob";
  }
  else if(A!=1&&B==1)cout<<"Bob";
  else if(A==1&&B!=1)cout<<"Alice";
  else cout<<"Draw";
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  cout << "AB" << (n >= 1000 ? "D" : "C") << endl;
}


Measured memory_bytes: 256
K = int(input())
cnt = 9
li = [list(range(1,10))]
if(K<=cnt):
    print(li[0][K-1])
else:
    while(cnt<K):
        li.append([])
        for num in li[-2]:
            s_num = str(num)
            if(s_num[-1]=='0'):
                li[-1].append(num*10)
                li[-1].append(num*10+1)
                cnt += 2
            elif(s_num[-1]=='9'):
                li[-1].append(num*10+8)
                li[-1].append(num*10+9)
                cnt += 2
            else:
                last = int(s_num[-1])
                li[-1].append(num*10+last-1)
                li[-1].append(num*10+last)
                li[-1].append(num*10+last+1)
                cnt += 3
            if(cnt>=K):
                print(li[-1][-(cnt-K+1)])
                break

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

int main(){
 int N;
 cin >> N;
 int A[1000];
 for(int i= 0;i<N;i++){
     cin >> A[i];
 }
 for(int i= 0;i<N;i++){
     if(A[i]%2==0&&A[i]%3!=0&&A[i]%5!=0){
         cout << "DENIED"<<endl;
         return 0;
     }
        
}
 cout << "APPROVED"<<endl;
         return 0;
}

Measured memory_bytes: 256
(n,q),*t=[map(int,t.split())for t in open(0)]
s=[0]
d=s*n
f=s+[1]*n
e=[[]for _ in d]
for a,b in t[:-q]:e[a-1]+=b-1,;e[b-1]+=a-1,
for p,x in t[-q:]:d[p-1]+=x
while s:
 v=s.pop()
 for w in e[v]:
  if f[w]:f[w]=0;d[w]+=d[v];s+=w,
print(*d)

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

using namespace std;

int main()
{
    
    int n;
    cin >> n;
    map<string,int> mp;
    int mx = 0;
    for(int i = 0 ; i < n ; i++)
    {
    	string s;
    	cin >> s;
    	mp[s]++;
    	mx = max(mx , mp[s]);
    }
    vector<string> ans;
    for(auto &k : mp)
       if(k.second == mx)
          ans.push_back(k.first);
          
    sort(ans.begin(),ans.end());
    for(auto &k : ans)
      cout << k << '\n';
}

Measured memory_bytes: 26868
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
ll n;
double dp[305][305][305];
double compute(ll a, ll b, ll c)
{
    if(a==0&&b==0&&c==0) return 0;
    if(a<0||b<0||c<0)
        return 0;
    if(dp[a][b][c] + 1 > 1e-9)
        return dp[a][b][c];
    double denom = a + b + c;
    double ans = ((double)n/denom);
    ans += (a/denom)*compute(a-1, b, c);
    ans += (b/denom)*compute(a+1, b-1, c);
    ans += (c/denom)*compute(a, b+1, c-1);
    return dp[a][b][c] = ans;
}
int main()
{
    she_told_me_dont_worry
    cin>>n;
    ll a = 0, b = 0, c = 0;
    int i, j, k;
    FOR0(i, n+5)FOR0(j, n+5)FOR0(k, n+5) dp[i][j][k] = -1;
    FOR0(i, n)
    {
        ll temp;
        cin>>temp;
        if(temp==1) a++;
        else if(temp==2) b++;
        else c++;
    }
    cout<<setprecision(12)<<compute(a, b, c);
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 221952
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

int main () {
    int N, max, sum = 0;
    cin >> N;

    vector<int> L(N);

    for(int i = 0; i < N; i++){
        cin >> L.at(i);
    }

    sort(L.begin(), L.end(), greater<int>());

    max = L.at(0);

    for(int i = 1; i < N; i++){
       sum += L.at(i);
    }

    //cout << max << "," << sum << endl;

    (max < sum) ? cout << "Yes" <<endl : cout << "No" << endl;

}

Measured memory_bytes: 256
#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);
  }
  sort(vec.begin(), vec.end());
  cout << vec.at((N+1)/2)-vec.at((N+1)/2-1) << endl;
}

Measured memory_bytes: 768
arr = [[''] * 3 for i in range(2)]
for i in range(2):
    tmp = input()
    tmp = list(tmp)
    arr[i] = tmp

if arr[0][0] == arr[1][2] and arr[0][1] == arr[1][1] and arr[0][2] == arr[1][0]:
    print('YES')
else:
    print('NO')


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


int main()
{

	string s;

	cin >> s;

	if (s.length() == 1)
		cout << 1;
	else if (s.length() == 2)
	{
		if (s[0] == s[1])
			cout << 1;
		else
			cout << 2;
	}
	else
	{
		int nr = 0;
		for (int i = 0; i < s.length();)
		{
			if (i == s.length() - 1)
			{
				nr++;
				break;
			}
			else if (i == s.length() - 2)
			{
				if (s[s.length() - 2] == s[s.length() - 1])
					++nr;
				else
					nr+= 2;
				break;
			}
			else
			{
				if (s[i] == s[i + 1])
				{
					i += 3;
					nr += 2;
				}
				else
				{
					++i;

					++nr;
				}
			}
			
		}

		cout << nr;
	}
	
	return 0;
}

Measured memory_bytes: 644
#include<iostream>
#include<queue>
#include<tuple>
#include<algorithm>
using namespace std;
int X[2000][2000];
int V[2000][2000];
int H, W, K, SX, SY, X1, Y1; char c;
int main() {
	cin >> W >> H;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> c;
			if (c == '#') {
				X[i][j] = 2000;
			}
			if(c == '.') {
				X[i][j] = 0;
			}
			if (c == 't') {
				SX = i; SY = j;
				X[i][j] = 0;
			}
		}
	}
	cin >> K;
	for (int i = 1; i <= K; i++) {
		cin >> Y1 >> X1;
		X[X1][Y1] = i;
	}
	queue<tuple<int, int, int> >Q;
	for (int i = 0; i < 1000; i++) {
		for (int j = 0; j < 1000; j++) {
			V[i][j] = 3000;
		}
	}
	V[0][0] = 0;
	Q.push(make_tuple(0, 0, 0));
	while (!Q.empty()) {
		tuple<int, int, int>tup = Q.front();
		Q.pop();
		int a1 = get<0>(tup);
		int a2 = get<1>(tup);
		int a3 = get<2>(tup);
		
		if (a1 - 1 >= 0) {
			int a4 = X[a1 - 1][a2];
			a4 = max(a4, a3);
			if (V[a1 - 1][a2]>a4) {
				V[a1 - 1][a2] = a4;
				Q.push(make_tuple(a1 - 1, a2, V[a1 - 1][a2]));
			}
		}
		if (a1 + 1 < H) {
			int a4 = X[a1 + 1][a2];
			a4 = max(a4, a3);
			if (V[a1 + 1][a2]>a4) {
				V[a1 + 1][a2] = a4;
				Q.push(make_tuple(a1 + 1, a2, V[a1 + 1][a2]));
			}
		}
		if (a2 - 1 >= 0) {
			int a4 = X[a1][a2 - 1];
			a4 = max(a4, a3);
			if (V[a1][a2 - 1]>a4) {
				V[a1][a2 - 1] = a4;
				Q.push(make_tuple(a1, a2 - 1, V[a1][a2 - 1]));
			}
		}
		if (a2 + 1 < W) {
			int a4 = X[a1][a2 + 1];
			a4 = max(a4, a3);
			if (V[a1][a2 + 1]>a4) {
				V[a1][a2 + 1] = a4;
				Q.push(make_tuple(a1, a2 + 1, V[a1][a2 + 1]));
			}
		}
	}
	if (V[SX][SY] >= 2000) {
		cout << "-1" << endl;
	}
	else {
		cout << V[SX][SY] << endl;
	}
	return 0;
}

Measured memory_bytes: 18756
#include<bits/stdc++.h>
using namespace std ;
string s[3] ;
int main()
{
	char c ;
	for ( int i =0 ; i<5 ; i++)
		cin >> c , s[0]+= c ;
	cin >> c ;
	for ( int i = 0 ;i < 7 ; i++)
		cin >> c ,s[1] += c ;
	cin >>c  ;
	for ( int i = 0; i< 5 ; i++)
		cin >> c , s[2] += c ;
	for ( int i = 0 ; i< 3 ; i++)
		cout << s[i] << " " ;


}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


int main(){
  ll n;
  cin >> n;
  vector<string> list(n);
  rep(i, n) cin >> list[i];


  ll res = 0;
  rep(i, n){
    rep(j, (ll)list[i].size()-1){
      if(list[i][j] == 'A' && list[i][j+1] == 'B') res++;
    }
  }

  vector<string> keys = {"BA", "XA", "BX"};
  map<string, ll> ma;
  ll sum = 0;
  rep(i, n){
    string s = "";
    s += list[i][0];
    s += list[i].back();
    
    if(s == "BA")             ma["BA"]++, list[i] = "BA";
    else if(s.back() == 'A')  ma["XA"]++, list[i] = "XA";
    else if(s[0] == 'B')      ma["BX"]++, list[i] = "BX";
  }

  if(0 < ma["BA"]){
    ll d = ma["BA"]-1;
    res += d;
    ma["BA"] -= d;
  }

  if(0 < max(ma["XA"], ma["BX"]) && 0 < ma["BA"]){
    ll e = ma["BA"];
    res += e;
    ma["BA"] -= e;
  }

  ll f = min(ma["XA"], ma["BX"]);
  res += f;
  ma["XA"] -= f;
  ma["BX"] -= f;
  
  cout << res << endl;

  
  return 0;
}



Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
	char name[10];
	int time;	
}queue;
int main(int argc, char *argv[])
{
	int n,q,j,i=-1;
	int top=-1,totaltime=0;
	int *b;
	queue *a;
	scanf("%d%d",&n,&q);
	a=(queue *)malloc(sizeof(queue)*n);//?????°??? 
	b=(int *)malloc(sizeof(int)*2*n);//??????????????¶??´ 
	for(j=0;j<n;j++)
	scanf("%s%d",a[j].name,&a[j].time);
   	while(top!=n-1)
 	{
   		for(j=0;j<n;j++)
  		{
   			if(a[j].time==0)
				continue;
			if(a[j].time<=q)
			{
				totaltime=a[j].time+totaltime;	
				a[j].time=0;
				i=i+2;
				b[i-1]=j;
				b[i]=totaltime;
				top++;
			}
			else
			{
				totaltime=q+totaltime;
				a[j].time=a[j].time-q;		
			}
						
   		}	
   	} 
   	for(i=0;i<2*n;i=i+2)
   	{
   	j=b[i];
   	printf("%s %d\n",a[j].name,b[i+1]);
   	}
	return 0;
}

Measured memory_bytes: 2880
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <utility>
using namespace std;

int main() {
	int n;
	cin >> n;
	bool last = 1 <= n%100 && n%100 <= 12, first = 1 <= n/100 && n/100 <= 12;
	if(first && !last){
		cout << "MMYY" << '\n';
	}
	else if(!first && last){
		cout << "YYMM" << '\n';
	}
	else if(first && last){
		cout << "AMBIGUOUS" << '\n';
	}
	else if(!first && !last){
		cout << "NA" << '\n';
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i,k=0,j;
	char n[27]="DEFGHIJKLMNOPQRSTUVWXYZABC";
	char m[27]="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
	char a[1001];
	scanf("%s",a);
	k=strlen(a);
	for(i=0;i<k;i++){
		for(j=0;j<26;j++){
			if(a[i]==n[j]){
				printf("%c",m[j]);
			}
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 524
import java.util.Scanner;

public class Main{

    public static int eukleides(int a, int b){
        if(b % a == 0){
            return a;
        }
        int mod = b % a;

        return eukleides(mod, a);
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int a = scan.nextInt();
        int b = scan.nextInt();
        int border = scan.nextInt();
        
        // search
        int gcd = eukleides(Math.min(a, b), Math.max(a, b));
        int count = 0;
        for(int i = gcd; i >= 1; i--){
            if(gcd % i == 0){
                count++;
            }
            if(count == border){
                System.out.println(i);
                break;
            }
        }

    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
const int N=110;
int n,k;
int rd[N];
int main(){
//	freopen("1.in","r",stdin);
    cin>>n>>k;
    int sum=(n-1)*(n-2)/2,m=n-1+sum-k;
    if(k>sum){
        puts("-1");
        return 0;
	}
    printf("%d\n",m);
    for(int i=2;i<=n;++i){
        printf("%d %d\n",1,i);
        rd[i]=1;
	}
	int l=2,r=3;
	sum-=k;
	while(sum--){
	    if(r<=n){
	        printf("%d %d\n",l,r);
		}else{
		    l++,r=l+1;
		    printf("%d %d\n",l,r);
		}
		++r;
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    long long int x;
    cin >> x;
    
    long long int ans=x/11;
    if(x%11==0) {
        cout << ans*2 << endl;
    } else if(ans==0) {
        if(x>6) {
            cout << 2 << endl;
        } else {
            cout << 1 << endl;
        }
    } else if(x%11<=6) {
        cout << ans*2+1 << endl;
    } else {
        cout << (ans+1)*2 << endl;
    }

    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> s(H);
  for (int i=0; i<H; i++) cin >> s[i];
  bool can = true;
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      if (s[i][j]=='#') {
        if (i==0) {
          if (j==0) {
            if (s[i+1][j]=='.'&&s[i][j+1]=='.') {
              can = false;
              break;
            }
          }
          else if (j==W-1) {
            if (s[i+1][j]=='.'&&s[i][j-1]=='.') {
              can = false;
              break;
            }
          }
          else {
            if (s[i+1][j]=='.'&&s[i][j-1]=='.'&&s[i][j+1]=='.') {
              can = false;
              break;
            }
          }
        }
        else if (i==H-1) {
          if (j==0) {
            if (s[i-1][j]=='.'&&s[i][j+1]=='.') {
              can = false;
              break;
            }
          }
          else if (j==W-1) {
            if (s[i-1][j]=='.'&&s[i][j-1]=='.') {
              can = false;
              break;
            }
          }
          else {
            if (s[i-1][j]=='.'&&s[i][j-1]=='.'&&s[i][j+1]=='.') {
              can = false;
              break;
            }
          }
        }
        else {
          if (j==0) {
            if (s[i-1][j]=='.'&&s[i+1][j]=='.'&&s[i][j+1]=='.') {
              can = false;
              break;
            }
          }
          else if (j==W-1) {
            if (s[i-1][j]=='.'&&s[i+1][j]=='.'&&s[i][j-1]=='.') {
              can = false;
              break;
            }
          }
          else {
            if (s[i-1][j]=='.'&&s[i+1][j]=='.'&&s[i][j-1]=='.'&&s[i][j+1]=='.') {
              can = false;
              break;
            }
          }
        }
      }
    }
    if (!can) break;
  }
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using  namespace std;
int main(){
  int n;cin >> n;
  double dp[3001][3001];
  dp[0][0]=1;
  for(int i=0;i<n;i++){
    double p;cin >> p;
    for(int j=0;j<=i;j++){
      dp[i+1][j+1]+=dp[i][j]*p;
      dp[i+1][j]+=dp[i][j]*(1-p);
    }
  }
  double ans=0;
  for(int i=n/2+1;i<=n;i++){
    ans+=dp[n][i];
  }
  cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 70400
#include <iostream>

using namespace std;

typedef pair<int, int> p;

int n,u,k,t;
int** v;
p* T;

void bfs(int pos) {
  // if visited
  if (T[pos].first) {
    return;
  }
  // check visit
  T[pos].first = ++t;

  int leng = v[pos][0];
  for (int i = 1; i <= leng; i++) {
    bfs(v[pos][i]);
  }
  T[pos].second = ++t;
}

int main() {
  cin >> n;

  v = new int*[n+1];
  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    v[u] = new int[k+1];
    v[u][0] = k;
    for (int j = 1; j <= k; j++) {
       cin >> v[u][j];
    }
  }

  T = new p[n+1];
  for (int i = 1; i <= n; i++) {
    T[i] = p(0, 0);
  }

  t = 0;
  for (int i = 1; i <= n; i++) {
    bfs(i);
  }

  for (int i = 1; i <= n; i++) {
    cout << i << " " << T[i].first << " " << T[i].second << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1192
def main():
    mod = 10 ** 9 + 7

    n, a, b = map(int, input().split())

    ma = max(a, b)
    tbl = [0] * (ma + 1)

    # f = 1
    # for i in range(1, ma + 1):
    #     f = (f * i) % mod
    #
    # invs = [1] * (ma + 1)
    # invs[ma] = pow(f, mod - 2, mod)
    # for x in range(ma - 1, 0, -1):
    #     invs[x] = invs[x + 1] * (x + 1) % mod

    t = 1
    for i in range(1, max(a, b) + 1):
        t = (t * (n - i + 1) * pow(i, mod - 2, mod)) % mod
        tbl[i] = t

    ans = pow(2, n, mod) - 1 - tbl[a] - tbl[b]
    print(ans % mod)


if __name__ == '__main__':
    main()


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

int main()
{
  int N,M,X;cin>>N>>M>>X;
  int C[13];
  int A[13][13];
  
  for (int i=0;i<N;i++)
  {
    cin>>C[i];
    for (int j=0;j<M;j++)
    {
      cin>>A[i][j]; 
    }
  }
  
  int mn=pow(10,9);
  for (int bit=0;bit<(1<<N);bit++)
  {
    //集合bitを固定してその時の理解度の条件と
    //いくらかかるかを計算してミニマムを求めよう！
    int sum=0;
    vector<int> R(M);
    
    for (int k=0;k<N;k++)
    {
      if (bit & (1<<k)) 
      {
        sum += C[k];
        for (int i=0; i<M; i++)
        {
          R[i] += A[k][i];
        }
      }
    }
    
    int flag=1;
    for (int i=0;i<M;i++)
    {
      if (R[i]<X) flag = 0;
    }
    
    if (flag == 1)
    {
      mn= min(sum,mn); 
    }
    
  }
  if (mn == pow(10,9))
  {
    cout<<-1<<endl;
    return 0;
  }
  cout<<mn<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Max(a, b) (a > b ? a : b)
#define Min(a, b) (a < b ? a : b)
#define ii pair<int, int>
#define fi first
#define se second
const int MAX = 200000; //2 * 10^5
const int MOD = 1000000007; //10^9 + 7
const int OO = 0x3f3f3f3f; // 0x3f3f3f3f;

string ans;
vector<int> arr;
/*
bool cmp(string a, strnig b)
{
	while(a.size() > b.size())
		b = "0" + b;
	while(a.size() < b.size())
		a = "0" + a;
	for(int i = 0; i < a.size(); i++)
		if(a[i] < b[i])
			return true;
	return false; 
}*/

void gen(char d)
{
	if(ans.size() > 10) 
		return;
		
	ans.push_back(d);
	
	arr.push_back(stoll(ans));
	
	gen(d);
	if(d - 1 >= '0') gen(d - 1);
	if(d + 1 <= '9') gen(d + 1);
	
	ans.pop_back();
}

int32_t main()
{
	for(char i = '1'; i <= '9'; i++)
		gen(i);
	
	sort(arr.begin(), arr.end());
	
	arr.resize(unique(arr.begin(), arr.end()) - arr.begin());

	//cout << arr.size() << '\n';
	
	//for(int i = 0; i < 25; i++)
		//cout << arr[i] << ' ';
	//puts("");

	int k;
	cin >> k;
	cout << arr[k - 1] << endl;

	return 0;
}

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

int main() {
  int n; cin >>n;
  map<string, int> mp;
  rep(i,n){
    string s; cin >>s;
    mp[s]++;
  }
  cout << "AC x " << mp["AC"] << endl; 
  cout << "WA x " << mp["WA"] << endl; 
  cout << "TLE x " << mp["TLE"] << endl; 
  cout << "RE x " << mp["RE"] << endl; 
  return 0;
}

Measured memory_bytes: 3660
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int A, B, C;
  ci(A, B, C);
  if(A <= C && C <= B){
    co("Yes");
  }
  else{
    co("No");
  }
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

const int MAXN = 1000;
const int MAXS = 10000;
ll dp[MAXN + 5][2 * MAXS + 5];

auto maxx(auto& a, auto b){a = max(a, b);}

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

  int n;
  cin >> n;
  vi w(n), s(n), v(n);
  rep(i, 0, n) {
    cin >> w[i] >> s[i] >> v[i];
  }
  vi ind(n);
  iota(all(ind), 0);
  sort(all(ind), [&](int i, int j) {return s[i] + w[i] < s[j] + w[j];});


  auto w2 = w, s2 = s, v2 = v;
  rep(i, 0, n) {
    int i2 = ind[i];
    w[i] = w2[i2], s[i] = s2[i2], v[i] = v2[i2];
  }

  
  rep(i, 0, MAXN + 1) rep(j, 0, 2 * MAXS + 1)
    dp[i][j] = -1;
  dp[0][0] = 0;
  rep(i, 0, n) {
    for (int weight = MAXS; weight >= 0; weight--) {
      if (dp[i][weight] == -1) continue;
      maxx(dp[i + 1][weight], dp[i][weight]);
      if (weight <= s[i]) {
	maxx(dp[i + 1][weight + w[i]], dp[i][weight] + v[i]);
      }
    }
  }
  auto res = 0LL;
  rep(i, 0, n + 1)
    maxx(res, *max_element(all(dp[i])));
  cout << res << '\n';
}


Measured memory_bytes: 156800
n = int(input())
t_inputs = [int(i) for i in input().split()]
m = int(input())
p_inputs = [[int(j) for j in input().split()]for i in range(m)]

neutral_sum = sum(t_inputs)

for i in range(m):
    drink_no = p_inputs[i][0]-1
    ans = neutral_sum-t_inputs[drink_no]+p_inputs[i][1]
    print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	map<int, int> mp;
	int count = 0;

	cin >> n;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		mp[tmp] ^= 1;
	}

	for (auto x: mp) {
		count += x.second;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 4992
package main

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

func main() {
	S := ReadString()
	m := make(map[rune]int)
	for _, r := range S {
		m[r]++
	}
	types := 0
	for _, v := range m {
		if v != 2 {
			fmt.Println("No")
			return
		}
		types++
	}
	if types == 2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1840
#include <stdio.h>
 int main(void){
    int r, c, i, j;
    int a[101][101] = { 0 };
 
    scanf("%d %d", &r, &c);
    for (j = 0; j < r; j++){
        for (i = 0; i < c; i++){
            scanf("%d", &a[j][i]);
            a[j][c] += a[j][i];
            a[r][i] += a[j][i];
        }
    }
    for (i = 0; i < c; i++){
        a[r][c] += a[r][i];
    }
    for (j = 0; j <= r; j++){
        for (i = 0; i <= c; i++){
            printf("%d", a[j][i]);
            if (i < c){
                printf(" ");
            }else{
                printf("\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2108
a,b,c,n=map(int,input().split())
res = 0
for i in range(n // a+1):
    for j in range(n//b+1):
        if n < a*i+b*j:
            break
        if (n - a * i - b * j ) // c > -1 and (n - a * i - b * j ) % c == 0:
            res += 1
print(res)

Measured memory_bytes: 40556
#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926535
const long long int MOD = 2019;
#define pb push_back
#define mp make_pair
#define fill(a)  memset(a, 0, sizeof (a))
#define SORT(v)  sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define MAX(v) *max_element(v.begin(), v.end())
#define MIN(v) *min_element(v.begin(), v.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define watch(x) cout << (#x) << " is " << (x) << endl;
const long long int MAXX = 200000 + 5;
const long long int MINN = 2e5 + 5;
const long long int inf = 1e7;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector< iii > viii;

ll lcm(ll a, ll b) {
   return a / __gcd(a, b) * b;
}
int XOR(int x, int y){
  return (x | y) & (~x | ~y);
}
bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
    return (a.second < b.second);
}
// bool isl = binary_search(x.begin(), x.end(), 5);
// __builtin_popcount(x)  - Returns the number of set bits in x
const long long int N = 10050;
const int MAXN = 105;
int binsearch(int lo, int hi){
    while(lo<hi){
        int mid=(lo+hi)/2;
        if((mid))   // check(mid)
            hi=mid;
        else
            lo=mid+1;
    }
    return lo;
}
ll power(ll x,ll y){
    ll res=1;
    while(y>0){
      if(y&1) res=((res*x));

      y/=2;
      x=((x*x));
    }
    return res;
}

int main(){
    FAST
    int h1,h2,m1,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int time = 0;
    if(h2>=h1)
     time = (h2-h1)*60;
    else time = (h2 + 24-h1)*60;
    time+=m2;
    time-=m1;
    cout<<time-k;
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
long long n,a[1000001],s=1,ans;
int main()
{
	cin>>n;
	for(long long i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n+1);
	for(int i=2;i<=n;i++)
    {
        if(a[i]==a[i-1])
		{
			s=(s+1)%2;
		}
        else 
		{
			ans=ans+s;
			s=1;
		}
    }
    if(s%2)
	{
		ans++;
	}
    cout<<ans<<endl;
    return 0;
 } 

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

namespace abc108_b
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int a = x[2] - x[0]; int b = x[3] - x[1];
			Console.WriteLine((x[2] - b) + " " + (x[3] + a) + " " + (x[0] - b) + " " + (x[1] + a));
		}
	}
}

Measured memory_bytes: 13268
#include <stdio.h>
#include <math.h>

int isprime(int n){
    if (n == 2) return 1;
    if (!(n % 2) || (n < 2)) return 0;
    for (int i=3;i<=sqrt(n);i++){if (!(n%i)) return 0;}
    return 1;
}

int main(void){
    int len, score = 0;
    scanf("%d", &len);
    int ary[len];
    for(int i=0;i<len;i++) scanf("%d", &ary[i]);
    for(int i=0;i<len;i++){if (isprime(ary[i])){score++;}}
    printf("%d\n", score);
    return 0;
}


Measured memory_bytes: 2044
n = int(input())
l = list(map(int,input().split()))
max = 0
sum = 0
for i in range(len(l)):
    sum += l[i]
    if l[i] > max:
        max = l[i]
    
if sum - max > max:
    print("Yes")
else:
    print("No")
    


Measured memory_bytes: 2940
n, a, b = map(int, input().split())

if a + b == 0:
    b = 1

x = n // (a + b) * a
# print(x)
y = n % (a + b)
# print(y)

# 余った(色の塊の途中で区切られた)ボールが赤なのか青なのか考える
if y <= a:
    ans = x + y
else:
    ans = x + a

# 11 3 2だとして
# 3 2 3 2 1 y1(青1)
# 12 3 2だとして
# 3 2 3 2 2 y2(青2)
# 13 3 2だとして
# 3 2 3 2 3  y3(青3)
# これらの場合はあまりをそのまま足す

# 14 3 2 だと
# 3 2 3 2 3 1 y4(青3赤1)
# この場合余りを全てたすと赤がまざってしまう

# 15 3 2 だと
# 3 2 3 2 3 2 y0(割り切れるのでそのまま答えが出る)

# つまり青(a)の範囲は0~3なので 
# aがyと同じかそれ以下なら足して
# 違うなら(3+1の状態)a(青3つ)だけ足す


print(ans)

Measured memory_bytes: 3060
#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 <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int a[110000];

int main()
{
  int i,j,n,cnt0,cnt2,x,cnt1;
  scanf("%d",&n);
  cnt2=0;
  cnt0=0;
  cnt1=0;
  for (i=0;i<n;i++)
  {
    a[i]=0;
    scanf("%d",&x);
    while (x%2==0)
    {
      a[i]++;x/=2;
    }
    if (a[i]>2) a[i]=2;
    if (a[i]==2) cnt2++;
    if (a[i]==0) cnt0++;
    if (a[i]==1) cnt1++;
  }
  if (cnt1>0)
  {
    if (cnt2>=cnt0) printf("Yes\n");
    else printf("No\n");
  }
  else
  {
    if (cnt2>=cnt0-1) printf("Yes\n");
    else printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
using namespace std;
const int INF = 1000000000;
int d[50][50][50][50];
string f[2][50];

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

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

int sx[2], sy[2], gx[2], gy[2];


struct State {
	int x1, y1, x2, y2;
};

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

	int H, W;
	while(cin >> W >> H, H) {
		for(int y = 0; y < H; y++) {
			cin >> f[0][y] >> f[1][y];
			for(int x = 0; x < W; x++) {
				if(f[0][y][x] == 'L') sx[0] = x, sy[0] = y;
				if(f[1][y][x] == 'R') sx[1] = x, sy[1] = y;
				if(f[0][y][x] == '%') gx[0] = x, gy[0] = y;
				if(f[1][y][x] == '%') gx[1] = x, gy[1] = y;
			}
		}

		fill((int*)begin(d), (int*)end(d), INF);

		queue<State> q;
		q.push(State{ sx[0], sy[0], sx[1], sy[1] });
		d[sx[0]][sy[0]][sx[1]][sy[1]] = 0;
		while(!q.empty()) {
			State s = q.front();
			q.pop();
			for(int k = 0; k < 4; k++) {
				int nx1 = s.x1 + dx[0][k], ny1 = s.y1 + dy[0][k];
				if(nx1 < 0 || W <= nx1 || ny1 < 0 || H <= ny1 || f[0][ny1][nx1] == '#') {
					nx1 = s.x1, ny1 = s.y1;
				}
				int nx2 = s.x2 + dx[1][k], ny2 = s.y2 + dy[1][k];
				if(nx2 < 0 || W <= nx2 || ny2 < 0 || H <= ny2 || f[1][ny2][nx2] == '#') {
					nx2 = s.x2, ny2 = s.y2;
				}
				if((f[0][ny1][nx1] == '%') ^ (f[1][ny2][nx2] == '%')) {
					continue;
				}
				if(d[s.x1][s.y1][s.x2][s.y2] + 1 < d[nx1][ny1][nx2][ny2]) {
					d[nx1][ny1][nx2][ny2] = d[s.x1][s.y1][s.x2][s.y2] + 1;
					q.push(State{ nx1, ny1, nx2, ny2 });
				}
			}
		}

		if(d[gx[0]][gy[0]][gx[1]][gy[1]] == INF) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}

}

Measured memory_bytes: 28352
import java.io.*;
import java.util.*;
 
public class Main{
	
	long MOD = 1000000007;
	int N;
	int[][][][] memo;
	// a = 0, c = 1, g = 2, t == 3
	public void solve(){
		N = nextInt();
		memo = new int[N + 1][4][4][4];
		for(int i = 0; i < memo.length; i++) {
			for(int j = 0; j < 4; j++) {
				for(int k = 0; k < 4; k++) {
					for(int l = 0; l < 4; l++) {
						memo[i][j][k][l] = -1;
					}
				}
			}
		}
		
		long sum = 0;
		for(int i = 0; i < 4; i++) {
			for(int j = 0; j < 4; j++) {
				for(int k = 0; k < 4; k++) {
					sum += dfs(N, i, j, k);
				}
			}
		}
		
		out.println(sum % MOD);
		
	}
	
	private boolean valid(int a, int b, int c, int d) {
		return valid(a, b, c) &&
			valid(b, a, c) &&
			valid(a, c, b) &&
			valid(a, b, d) &&
			valid(a, c, d);
		
	
	}
	
	private boolean valid(int a, int b, int c) {
		return !(a == 0 && b == 2 && c == 1);
	}
	
	private int dfs(int len, int n1, int n2, int n3) {
		if(memo[len][n1][n2][n3] != -1) {
			return memo[len][n1][n2][n3];
		}
		
		if(len == 2) {
			return memo[len][n1][n2][n3] =  1;
		}
		if(len == 3) {
			if(valid(n1, n2, n3, -1)) {
				return memo[len][n1][n2][n3] =  1;
			}else {
				return memo[len][n1][n2][n3] =  0;
			}
		}
		
		long sum = 0;
		for(int i = 0; i < 4; i++) {
			if(valid(n1, n2, n3, i)) {
				sum += dfs(len - 1, n2, n3, i);
			}
		}
		
		return memo[len][n1][n2][n3] = (int)(sum % MOD);
	}
	
	
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 24916
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> num = new ArrayList<Integer>();
		ArrayList<String> param = new ArrayList<String>();

		while (sc.hasNext()) {
			if (sc.hasNextInt()) {
				num.add(sc.nextInt());
			} else {
				param.add(sc.nextLine());
			}
		}
		Method(num, param);
	}
	
	static void Method(ArrayList<Integer> num, ArrayList<String> param) {
		
		Collections.sort(num);
		if(num.get(0) + num.get(1) == num.get(2)){
			System.out.println("Yes");	
		} else {
			System.out.println("No");
		}
	}
}

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

	if (S.at(0) != S.at(1) && S.at(0) != S.at(2) && S.at(1) != S.at(2)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3628
use std::collections::HashMap;
// stdin
macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

// input
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"6 3 4
3
1
3
2
" => r"No
No
Yes
No
No
No",

r"6 5 4
3
1
3
2
" => r"Yes
Yes
Yes
Yes
Yes
Yes",

r"10 13 15
3
1
4
1
5
9
2
6
5
3
5
8
9
7
9
" => r"No
No
No
No
Yes
No
No
No
Yes
No"
}

fn solve(src: &str) -> String {
    input! {
        source=src,
        n:i32,
        k:i32,
        q:i32,
        a:[i32;q],
    };

    let n: i32 = n;
    let k: i32 = k;
    let q: i32 = q;
    let a: Vec<i32> = a;

    let mut map = HashMap::new();

    for &v in a.iter() {
        match map.get(&v) {
            None => {
                map.insert(v, 1);
            }
            Some(&vv) => {
                map.insert(v, vv + 1);
            }
        }
    }

    let mut ans = vec![];

    for num in 1..n + 1 {
        let tmp = match map.get(&num) {
            None => {
                if k - q > 0 {
                    "Yes"
                }else{
                    "No"
                }
            },
            Some(&v) => {
                if k - (q - v) > 0 {
                    "Yes"
                }else{
                    "No"
                }

            },
        };
        ans.push(tmp);
    }

    let ans = ans.join("\n");

    format!("{}", ans)
}


fn main() {
    println!("{}", solve(&stdin!()));
}



Measured memory_bytes: 12528
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	
	if(a==b){
		printf("%d\n",c);
	} else if(b==c){
		printf("%d\n",a);
	} else{
		printf("%d\n",b);
	}
		
	return 0;
}

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

A = list(map(int, input().split()))
B = list(map(int, input().split()))

I = A[0]
ans = 0

for i in range(N):
    if B[i] <= I:
        ans += B[i]
        I = A[i + 1]
    elif I + A[i + 1] >= B[i] > I:
        ans += B[i]
        I = I + A[i + 1] - B[i]
    elif B[i] > I + A[i + 1]:
        ans += I + A[i + 1]
        I = 0
print(ans)


Measured memory_bytes: 18380
N=int(input())
B=list(map(int,input().split()))
A=[0]*N
for i in range(N):
    if i==0: A[i]=B[i]
    elif i<N-1: A[i]=min(B[i-1],B[i])
    else: A[i]=B[i-1]
print(sum(A))

Measured memory_bytes: 3064
n = int(input())
a = [i for i in map(int, input().split())]
stu = [{'no' : i, 'arv':a[i]} for i in range(n)]

stu.sort(key=lambda x: x['arv'])

res = []
for i in stu:
    res.append(i['no'] + 1)

for i in res:
    print(i, end=" ")

Measured memory_bytes: 45836
#  queue
#  round-robin-scheduler

class Process:
    name = ""
    time = 0

    def __init__(self,name,time):
        self.name = name
        self.time = time


n,q = list(map(int,input().split()))

queue = []
for i in range(n):
    name,time = input().split()
    queue.append(Process(name,int(time)))

time_in_now = 0
while queue:
    if queue[0].time > q:
        queue[0].time -= q
        time_in_now += q
        temp = queue[0]
        queue.pop(0)
        queue.append(temp)
    else:
        time_in_now += queue[0].time
        print(f"{queue[0].name} {time_in_now}")
        queue.pop(0)


Measured memory_bytes: 17252
N,K=map(int,input().split())
P=list(map(int,input().split()))

def kitai(x):
    return (x+1)/2
nP=list(map(kitai,P))
l=[]
m=sum(nP[0:K])
l.append(m)
for i in range(N-K):
    m -= nP[i]
    m += nP[i+K]
    l.append(m)
print(max(l))


Measured memory_bytes: 25060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
 
int main(){
  ll N,K;
  cin >> N >> K;
  vector<ll> A(N+10);
  for(int i=0;i<N;i++)cin >> A[i];
  ll ans=0;
  for(int i=0;i<N;i++){
    ll cnt=0,cnt2=0;
    for(int j=0;j<N;j++){
      if(A[i]>A[j]){cnt++;}
      if(A[i]>A[j] && i<j)cnt2++;
    }
    ll memo=((K-1)*K/2%mod*cnt%mod+K*cnt2%mod)%mod;
    ans=(ans+memo)%mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256