akhauriyash/Code-Regression huggingface dataset:
#include<vector>
#include<iostream>

using namespace std;

int main(){
    int n , k ,q;
    cin>>n>>k>>q;
    vector<int> ar(n , 0);
    for(int i =0; i< q; i ++)
    {
        int temp = 0;
        cin>>temp;
        temp--;
        ar[temp]++;
    }
    // for(auto i: ar)
    //     cout<<i-q<<" ";
    for(auto i: ar)
        if( i-q > -k)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;


    return 0;
}

Measured memory_bytes: 1024
N = int(input())
S = input()
dic = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
ans = ''
for i in S:
    if dic.index(i)+N <= 25:
        index = dic.index(i)+N
    else:
        index = dic.index(i)+N-26
    ans += dic[index]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define li long long int
using namespace std;
li gcd(li a,li b){
    if(a==0)
    return b;
    return gcd(b%a,a);
}
int main() {
	li n,x;
	cin>>n>>x;
	
	cout<<3*(n-gcd(n,x))<<endl;
	
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int a, b;
  cin >> a >> b;

  cout << (a <= 8 && b <= 8 ? "Yay!" : ":(") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  int s=0;
  int a1,a2,a4,a5;
  
  for (int i=a; i<b+1 ;i++){
    a1=i%10;
    a2=(i/10)%10;
    a4=(i/1000)%10;
    a5=(i/10000)%10;
    if(a1==a5&&a2==a4){
      s++;
    }
  }
  cout << s << endl;
  
}
      
        


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
			Scanner sc = new Scanner(System.in);
			int m,f,r;
			m = sc.nextInt();
			f = sc.nextInt();
			r = sc.nextInt();
			
			while(m!=-1 || f!=-1 || r!=-1){
				int x=m+f;
				if(m==-1 || f==-1 || x<30){
					System.out.println("F");
				}else if(x>=30 && x<50){
					if(r>=50){
						System.out.println("C");
					}else{
					System.out.println("D");
					}
				}else if(x>=50 && x<65){
					System.out.println("C");
				}else if(x>=65 && x<80){
					System.out.println("B");
				}else if(x>=80){
					System.out.println("A");
				}
				m = sc.nextInt();
				f = sc.nextInt();
				r = sc.nextInt();
			}
	}

}

Measured memory_bytes: 26492
INlist = []

while True:
    val = list(map(int, input().split()))
    if val[0] == 0 and val[1] == 0:
        break
    else:
        INlist.append(val)

for HW in INlist:
    H, W = HW[0], HW[1]
    for h in range(H):
        print('#'*W,end='\n')
    print()


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const int INF = 1e9;
const int EPS = 1e-9; 

int main() {
  int X;
  cin >> X;
  
  bool isPrime = false;
  while(!isPrime) {
    if(X <= 1) isPrime = false;
    else if (X >= 2 && X <= 3) isPrime = true;
    for (int i = 2; i * i <= X; ++i) {
      if(X % i == 0) {
        isPrime = false;
        break;
      }
      isPrime = true;
    }
    X++;
  }
  --X;
  cout << X << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>

char s[100005];

int main()
{
    scanf("%s", s);
    int lng = strlen(s);

    int a = 0, b = 0, c = 0;
    for (int i = 0; i < lng; i++) {
        if (s[i] == 'a') a++;
        if (s[i] == 'b') b++;
        if (s[i] == 'c') c++;
    }

    bool jdg = true;
    if (abs(a - b) >= 2) jdg = false;
    if (abs(b - c) >= 2) jdg = false;
    if (abs(c - a) >= 2) jdg = false;

    if (jdg) printf("YES\n");
    else printf("NO\n");
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s;

int main() {
	cin >> s;
	
	if(s.size() == 3) { reverse(ALL(s)); }
	
	cout << s << endl;
	
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <random>
#include <set>
#include <ctime>
#include <cmath>

using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll a, v;
	ll b, w;
	ll t;
	cin >> a >> v;
	cin >> b >> w;
	cin >> t;
	if (a > b) {
		swap(a, b);
	}
	cout << (a + t * v >= b + t * w ? "YES" : "NO");
}


Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main()
{
	char S[4];

	scanf("%s", S);

	if (S[0] == S[1] || S[1] == S[2] || S[0] == S[2])
		printf("No\n");
	else
		printf("Yes\n");

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

#define N 36

typedef struct{
  char suit;
  int value;
}Card;

int main(){

  int i,j,n,min,flag=0;
  Card a[N],b[N],a1,a2;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c%d",&a[i].suit,&a[i].value);
    b[i].suit=a[i].suit;
    b[i].value=a[i].value;
  }

  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(a[j].value<a[j-1].value){
	a1=a[j];
	a2=a[j-1];
	a[j]=a2;
	a[j-1]=a1;
      }
    }
  }

    

  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(b[j].value<b[min].value){
	min=j;
      }
    }
    a1=b[i];
    a2=b[min];
    b[i]=a2;
    b[min]=a1;
  }


  for(i=0;i<n-1;i++){
    printf("%c%d ",a[i].suit,a[i].value);
  }
  printf("%c%d\n",a[n-1].suit,a[n-1].value);
  printf("Stable\n");
 
  for(i=0;i<n-1;i++){
    printf("%c%d ",b[i].suit,b[i].value);
  }
  printf("%c%d\n",b[n-1].suit,b[n-1].value);
   
  for(i=0;i<=n-1;i++){
    if(a[i].suit!=b[i].suit){
      flag=1;
    }
  }
 
  if(flag==1) printf("Not stable\n");
  else printf("Stable\n");
  
  return 0;
}

Measured memory_bytes: 608
#include <stdio.h>

int main(){
    int d;
    scanf("%d", &d);
    d = d % 7;
    switch(d){
        case 1:
        printf("fri\n");
        break;
        case 2:
        printf("sat\n");
        break;
        case 3:
        printf("sun\n");
        break;
        case 4:
        printf("mon\n");
        break;
        case 5:
        printf("tue\n");
        break;
        case 6:
        printf("wed\n");
        break;
        case 0:
        printf("thu\n");
        break;
        default:;
    }
    return 0;
}


Measured memory_bytes: 2112
#include"bits/stdc++.h"
using namespace std;
int main()
{
	char a[3][3];
	int i,j;
	char tmp;
	for(i=0;i<3;i++)
	{
		for(j=0;j<3;j++)
			scanf("%c",&a[i][j]);
		scanf("%c",&tmp);
	}
	printf("%c%c%c",a[0][0],a[1][1],a[2][2]);
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std ;
int a,b,c,d;
double long sudut,coss;
double long pi,temp;
int main(){
	
	cin>>a>>b>>c>>d;
	
	pi=acos(-1);
	

	sudut=double (30*c+0.5*d-6*d);
	sudut=abs(sudut);
	sudut=double(pi*sudut/180);
	
	coss=cos(sudut);
	
	
	
	temp=a*a+b*b-2*a*b*coss;
	temp=sqrt(temp);
	cout<<fixed<<setprecision(12)<<temp<<endl;
}

Measured memory_bytes: 4164
#include<stdio.h> 
int main()
{
	int a, b;
	char op;
	while(scanf("%d %c %d", &a, &op, &b))
	{
		int ans;
		ans = 0;
		if(op == '?')
		{
			break;
		}
		if(op == '+')
		{
			ans = a + b;
		}
		if(op == '-')
		{
			ans = a - b;
		}
		if(op == '*')
		{
			ans = a * b;
		}
		if(op == '/')
		{
			ans = a / b;
		}
		printf("%d\n", ans);
	}
	
	    
	return 0;
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;
const int maxN = 1e5 + 5;
int cnt[maxN];

signed main() {
  int n, k;
  std::cin >> n >> k;
  REP(i, n) {
    int a, b;
    a = read();
    b = read();
    cnt[a] += b;
  }
  int ans = 0;
  REP(i, maxN) {
    if (k <= cnt[i]) {
      ans = i;
      break;
    }
    k -= cnt[i];
  }
  print(ans);
}


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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define endl "\n"
#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007
//グリッドグラフの範囲チェック
bool range_validation(int y,int x,int h,int w){
    return y>=0 && y<h && x>=0 && x < w;
}
//ビットカウント
int popcount(long bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int gcd(ll a, ll b){
  if(b == 0){
    return a;
  }else{
    return gcd(b,a%b);
  }
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  int n;
  cin >> n;
  int a[n];
  ll sum = 0;
  REP(i,n){
    cin >> a[i];
    sum += a[i];
  }
  ll accum = 0;
  ll res = INF;

  REP(i,n-1){
    accum += a[i];
    ll bear = (sum - accum);

    res = min(res , abs(accum-bear));
  }
  cout << res << endl;
  return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll N, V[5];

int main(){
  cin >> N;
  for (int i = 0; i < 5; i++) cin >> V[i];
  sort(V, V + 5);

  ll ans = N / V[0] + 4;
  if (N % V[0] != 0) ans++;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main() {

    int a, b, c, k;

    scanf("%d %d %d %d", &a, &b, &c, &k);

    int max_data;
    int other_data;
    if (a >= b && b >= c || a >= c && c >= b) {
        max_data = a;
        other_data = b + c;
    }

    if (b >= c && c >= a || b >= a && a >= c) {
        max_data = b;
        other_data = a + c;
    }

    if (c >= a && a >= b || c >= b && b >= a) {
        max_data = c;
        other_data = b + a;
    }

    for (int i = 0; i < k; i++) {
        max_data *= 2;
    }

    printf("%d", max_data+other_data);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
  int N;
  cin >>N;
  int A[N];
  int min =1000000000;
  int max =1;
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(min >A[i]){
      min =A[i];
    }
    if(max <A[i]){
      max =A[i];
    }
  }
  cout<< max-min <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  ll n, k;
  cin >> n >> k;
  if (k % 2 == 0)
  {
    ll c = n / k;
    ll cc = (n / (k / 2)) - c;
    cout << c * c * c + cc * cc * cc << endl;
  }
  else
  {
    ll c = n / k;
    cout << c * c * c << endl;
  }
}


Measured memory_bytes: 256
// Problem : C - Lamps
// Contest : AtCoder - Tokio Marine & Nichido Fire Insurance Programming Contest 2020
// URL : https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef complex<double> cd;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
#define bugf(...) fprintf(stderr,__VA_ARGS__);
#define bugs(x) cerr<<"    "<<(x);
#define bugx(x) cerr<<"    "<<(#x)<<" = "<<(x);
#define bugl cerr<<"\n";
#define bugL cerr<<"\n================================================\n";
#define bugt bugx(clock());bugl;
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline bool bmax(IT &a,IT b){if(a<b){a=b;return true;}else return false;}
template<class IT>inline bool bmin(IT &a,IT b){if(a>b){a=b;return true;}else return false;}
const int N=200005;
int A[N],B[N];
inline void ac(){
	int n,t,i,l,r;
	scanf("%d%d",&n,&t);
	rep(i,1,n)scanf("%d",&A[i]);
	while(t--){
		rep(i,1,n)B[i]=0;
		rep(i,1,n){
			l=max(i-A[i],1);
			r=min(i+A[i],n);
			++B[l];--B[r+1];
		}
		rep(i,1,n)B[i]+=B[i-1];
		l=1;
		rep(i,1,n)if((A[i]=B[i])!=n)l=0;
		if(l)break;
	}
	rep(i,1,n)printf("%d ",A[i]);
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	
	ac();
	return 0;
}
#undef pque
#undef rep
#undef per
#undef REP
#undef PER
#undef mp
#undef pb
#undef pf
#undef pob
#undef pof
#undef fi
#undef se
#undef bugs
#undef bugx
#undef bugl

Measured memory_bytes: 5384
import java.io.*;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Queue;

public class Main {

  public static void main(final String[] args) {

    Scanner sc = new Scanner(System.in);

    final int k = sc.nextInt();
    // 途中計算用配列
    final Queue<BigInteger> tempList = new ArrayDeque<BigInteger>();
    // 解答用配列
    final ArrayList<BigInteger> ans = new ArrayList<BigInteger>();

    if (k < 10) {
      System.out.println(k);
      return;
    } else {
      for (int i = 1; i < 10; i++) {
        tempList.add(BigInteger.valueOf(i));
      }
    }

    while (ans.size() <= k) {

      BigInteger temp = tempList.poll();
      BigInteger num1 = temp.remainder(BigInteger.valueOf(10));
      BigInteger num2 = temp.multiply(BigInteger.valueOf(10)).add(num1);

      ans.add(temp);

      // 一の位が0でない場合、num - 1の値もセット
      if (num1.compareTo(BigInteger.valueOf(0)) != 0) {
        tempList.add(num2.subtract(BigInteger.valueOf(1)));
      }

      tempList.add(num2);

      // 一の位が9でない場合、num + 1の値もセット
      if (num1.compareTo(BigInteger.valueOf(9)) != 0) {
        tempList.add(num2.add(BigInteger.valueOf(1)));
      }
    }

    System.out.println(ans.get(k - 1));
  }
}

Measured memory_bytes: 56788
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <bitset>
#include <set>
#include <iomanip>
#include <functional>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'a' = 97

int main()
{
    int n;
    cin >> n;
    int p[101] = {};
    for (int i = 2; i <= n; i++) {
        int x = i;
        for (int j = 2; j <= x; j++) {
            while (x % j == 0) {
                x /= j;
                p[j] ++;
            }
        }
    }

    /*for (int i = 0; i <= 100; i++) {
        if (p[i] != 0) cout << i << ":" << p[i] << endl;
    }*/

    int cnt[101] = {};
    for (int i = 2; i <= 97; i++) {
        if (p[i] >= 2) cnt[2] ++;
        if (p[i] >= 4) cnt[4] ++;
        if (p[i] >= 14) cnt[14] ++;
        if (p[i] >= 24) cnt[24] ++;
        if (p[i] >= 74) cnt[74] ++;
    }

    int ans = 0;
    ans += cnt[4] * (cnt[4] - 1) / 2 * (cnt[2] - 2);
    ans += cnt[14] * (cnt[4] - 1);
    ans += cnt[24] * (cnt[2] - 1);
    ans += cnt[74];

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;

int main(){
	int n, ans;
	int x, y, b, p, tmp;
	cin>>n;
	while(n--){
		cin>>x>>y>>b>>p;
		ans = tmp = INF;
		for(int i = b; i <= 10; i++){
			for(int j = p; j <= 10; j++){
				tmp=(x*i+y*j)*(i>=5&&j>=2?0.8:1);
				ans = min(ans, tmp);
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1164
def judgeOdd(x: str):
    if x != "L":
        return True
    else:
        return False


def judgeEven(x: str):
    if x != "R":
        return True
    else:
        return False


if __name__ == "__main__":
    s = input("")

    odd = [s[i] for i in range(len(s)) if i % 2 == 0]
    even = [s[i] for i in range(len(s)) if i % 2 == 1]

    odd = list(map(judgeOdd, odd))
    even = list(map(judgeEven, even))

    if False in odd or False in even:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 3064
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var ans = getAns(a, n);
        Console.WriteLine(ans);
    }
    static int getAns(int[] a, int n)
    {
        var t = 102; var s = 0;
        for (int i = 0; i < n; i++)
        {
            var w = a[i];
            s += w;
            if (w % 2 == 1) t = Min(t, w);
        }
        if (s % 2 == 0) return s / 2;
        else return (s - t) / 2;
    }
}



Measured memory_bytes: 17916
#include<iostream>
#include<math.h>
using namespace std;

int main(){
	
	long long int  n,k;
	cin>>n>>k;
	long long int x = n%k;
	if(abs(x-k) < x ){
		cout<<abs(x - k)<<endl;
	}else{
		cout<<x<<endl;
	}
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int gcd(int a, int b){
    return b ? gcd(b, a % b) : a;
}

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;

    int g = 0, max_a = 0;
    rep(i, N) {
        int a; cin >> a;
        g = gcd(g, a);
        max_a = max(max_a, a);
    }

    if (K % g == 0 && K <= max_a) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))
const int mxN = 1e7 + 5;

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int cnt[mxN];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cnt[i]++;
		for(int j = i * 2; j <= n; j += i){
			cnt[j]++;
		}
	}
	ll ans = 0LL;
	repn(i, 1, n + 1){
		ans += (ll)(1LL * i * cnt[i]);
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

int main(void){
    int alice = 0,bob = 0;
    int N;
   

    cin >> N;
    vector<int> A(N);

    rep(i,N)
    cin >> A.at(i);

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

    rep(i,N){
        if(i%2 == 0)
        alice += A[i];

        else
        bob += A[i];
        
    }

    cout << alice-bob << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>

using namespace std;

const int INF = 100100100;

typedef pair<int, int> pii;

typedef struct edge{
    int to;
    int cost;
}edge;

int N, M, R;
int r[8];
int ans = INF;
vector<vector<edge> > m;
int d[201][201];
int used[201];

void dijkstra(int s)
{

    d[s][s] = 0;

    priority_queue<pii, vector<pii>, greater<pii> > pq;
    pq.push(make_pair(0, s));

    while(!pq.empty())
    {
        pii p = pq.top();
        pq.pop();

        int from = p.second;

        if(d[s][from] < p.first)
        {
            continue;
        }
        
        for (int i = 0; i < m[from].size(); i++)
        {
            int to = m[from][i].to;
            int c = m[from][i].cost;
            //cout << "to  = " << to << endl;
            if (d[s][to] > d[s][from] + c)
            {
                d[s][to] = d[s][from] + c;
                pq.push(make_pair(d[s][to], to));
            }
        }
    }
}

void dfs(int p, int c, int n)
{
    if (n == R)
    {
        ans = min(ans, c);
        return;
    }
    used[p] = 1;

    for (int i = 0; i < R;i++)
    {
        int to = r[i];
        if (used[to] == 1)
        {
            continue;
        }
        dfs(to, c + d[p][to], n + 1);
    }
    used[p] = 0;
}

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

    m.resize(N + 1);


    for (int i = 0; i < 201;i++)
    {
        for (int j = 0; j < 201;j++)
        {
            d[i][j] = INF;
        }
    }

    for (int i = 0; i < R; i++)
    {
        cin >> r[i];
    }
    for (int i = 0; i < M;i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        edge t;
        t.to = a;
        t.cost = c;
        m[b].push_back(t);
        t.to = b;
        m[a].push_back(t);
    }

    for (int i = 0; i < R;i++)
    {
        dijkstra(r[i]);
    }

/*
    for (int i = 0; i < R;i++)
    {
        for (int j = 1; j <= N;j++)
        {
            cout << r[i] << " -> " << j << " : " << d[r[i]][j] << endl;
        }
    }
*/
        for (int i = 0; i < R; i++)
        {
            dfs(r[i], 0, 1);
        }

    

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1144
N = int(input())
S = str(N)
if(len(S) == 1): print(S); exit(0)
for i in range(1, len(S)):
    if(int(S[i]) != 9):
        print(int(S[0]) - 1 + (len(S) - 1) * 9)
        exit(0)
print(int(S[0]) + (len(S) - 1) * 9)


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//#include <iostream>
//using namespace std;

#define NIL NULL

struct node{
  int key;
  struct node *right, *left, *parent;
};

typedef struct node * Node;

Node root;

Node find(Node u, int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key) u=u->left;
    else u=u->right;
  }
  return u;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = /*(Node *)*/malloc(sizeof(struct node));
  z->key = k;
  z->right = NIL;
  while(x!=NIL){
    y = x;
    if(z->key<x->key) x=x->left;
    else x=x->right;
  }
  z->parent = y;
  if(y==NIL) root=z;
  else{
    if(z->key<y->key) y->left=z;
    else y->right=z;
  }
}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i, x;
  char com[10];

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%s", com);
    if(com[0]=='f'){
      scanf("%d", &x);
      Node t = find(root, x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(!strcmp(com, "insert")){
      scanf("%d", &x);
      insert(x);
    }
    else if(!strcmp(com, "print")){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}


Measured memory_bytes: 20496
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        if (a == 1) {
            System.out.println("Hello World");
        } else {
            System.out.println(in.nextInt() + in.nextInt());
        }
    }
}

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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;

const int mod = 998244353;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }  

int dp[3001][3001];
pair<int, int> res[3001][3001];
string x, y;
string sol;

int LCS(int i, int j){
    if(i > x.size() || j > y.size())
        return 0;
    if(dp[i][j] != -1)
        return dp[i][j];
    if(x[i] == y[j]){
        res[i][j] = {i + 1, j + 1};
        return dp[i][j] = 1 + LCS(i+1, j+1);
    } 
    int a, b;
    a = LCS(i+1, j);
    b = LCS(i, j+1);
    if(a > b){
        res[i][j] = {i + 1, j};
        dp[i][j] = a;
    }
    else{
        res[i][j] = {i, j + 1};
        dp[i][j] = b;
    }
    return dp[i][j];
}

int main(){
    memset(dp, -1, sizeof(dp));
    cin >> x >> y;
    LCS(0,0);
    int i = 0, j = 0;
    string rj = "";
    while(i < x.size() && j < y.size()){
        if(x[i] == y[j]){
            rj += x[i];
        }
        if(res[i][j].first == i+1 && res[i][j].second == j+1) i++, j++;
        else if(res[i][j].first == i + 1) i++;
        else j++;
    }
    cout << rj;
}

Measured memory_bytes: 106240
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,x,y,z;
    while(~scanf("%d %d",&a,&b))
    {
         x=a+b;
        y=a-b;
        z=a*b;
            if(x>=y&&y>=z)
                printf("%d\n",x);
            else if(x>=z&&z>=y)
                printf("%d\n",x);
            else if(y>=x&&x>=z)
                printf("%d\n",y);
            else if(y>=z&&z>=x)
                printf("%d\n",y);
            else if(z>=y&&y>=x)
                printf("%d\n",z);
            else
                printf("%d\n",z);
    }
}


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

using namespace std;

int main(){
    int n;
    vector<int> order;
    cin>>n;
    order.resize(n);
    for(int i=0; i<n; i++){
        int tmp;
        cin>>tmp;
        order[tmp-1]=i+1;
    }
    for(int i=0; i<n; i++){
        cout<<order[i];
        if(i!=n-1){
            cout<<" ";
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

   int n,a,b;
   cin>>n>>a>>b;
   if(n%(a+b)==0)
   {
      int z=n/(a+b);
      cout<<z*a;
      return 0;
   }
   long double x=a,y=b;
   int z=ceil((n*1.0)/(x+y));

   if(n%(a+b)<a)
   {
      cout<<(n%(a+b))+(z-1)*a;
   }
   else
   {
      cout<<(z*a);
   }
   

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }


Measured memory_bytes: 512
#include <cstdio>
#include <vector>

using namespace std;

const int V = 100010;

vector<pair<int,int>> graph[V];
bool visited[V];
int dist[V];

void dfs(int v,int d){
	if(visited[v])return;
	dist[v]=d%2;
	visited[v]=true;
	for(auto i:graph[v])dfs(i.first,(d+i.second)%2);
	//firstがpairの1要素目を指す
}

int main(void){
	int n;
	scanf("%d",&n);
	int u,v;
	long long w;
	for(int i=0;i<n-1;i++){
		scanf("%d%d%lld",&u,&v,&w);
		u--;
		v--;
		graph[u].push_back({v,w});//末尾に追加
		graph[v].push_back({u,w});
	}
	dfs(0,0);
	for(int i=0;i<n;i++){
		printf("%d\n",dist[i]%2);
	}
}


Measured memory_bytes: 7680
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
int dx[4]={ 0, 1,  0, -1};
int dy[4]={ 1, 0, -1,  0};
using P = pair<int,int>;
int h, w, n;
int sx, sy, gx, gy;
int ans=0;
char c[1000][1000];
queue<P> que;

int main(){
  cin >> h >> w;
  queue<P> que;
  vector<vector<int>> d(w, vector(h, -1));
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin >> c[j][i];
      if(c[j][i] == '#'){
        que.push(P(j,i));
        d[j][i] = 0;
      }
    }
  }

  while(!que.empty()){
    P p = que.front();
    que.pop();
    int px = p.first, py = p.second;
    for(int i=0; i<4; i++){
      int nx = px+dx[i], ny = py+dy[i];
      if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
      else{
      	if(c[nx][ny] == '.'){
          c[nx][ny] = '#';
          d[nx][ny] = d[px][py] + 1;
          que.push(P(nx, ny));
        }
      }
    }
  }
  
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(ans < d[j][i]) ans = d[j][i];
    }
  }  
  cout << ans << endl;
}

Measured memory_bytes: 16012
import bisect as bs
N = int(input())
A = [int(input()) for _ in range(N)]
def LDS(a):
    N = len(a)
    INF = float("inf")
    dp = [-INF]*N
    dp[N-1] = a[0]
    for i in range(1, N):
        j = bs.bisect_left(dp, a[i])-1
        dp[j] = a[i]
    for i in range(N-1, -1, -1):
        if dp[i] == -INF:
            return N-i-1
    return N
print(LDS(A))

Measured memory_bytes: 7840
n = gets.to_i

dwellers = Array.new(4).map{Array.new(3).map{Array.new(10, 0)}}

while input = gets
    b, f, r, v = input.chomp.split(" ").map(&:to_i)
    
    dwellers[b - 1][f - 1][r - 1] += v
end

for i in 0..3
    for j in 0..2
        for k in 0..9
            print " #{dwellers[i][j][k]}"
        end
        puts ""
    end
    if i != 3
        puts "####################"
    end
end


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> cnt(n, 0);
  int a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    cnt.at(a - 1)++;
    cnt.at(b - 1)++;
  }
  for (int i = 0; i < n; i++) cout << cnt.at(i) << endl;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import defaultdict, deque

n, q = map(int, readline().split())
graph = defaultdict(list)
for i in range(n - 1):
    u, v = map(int, readline().split())
    graph[u - 1].append(v - 1)
    graph[v - 1].append(u - 1)
v = [0] * n
for i in range(q):
    p, x = map(int, readline().split())
    v[p - 1] += x


def dfs(s):
    check = [False] * n
    stack = deque([s])
    while stack:
        now = stack.pop()
        check[now] = True
        for next in graph[now]:
            if check[next]:
                continue
            v[next] += v[now]
            stack.appendleft(next)


dfs(0)
print(*v)


Measured memory_bytes: 72080
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    map<int, int> cnt;
    cnt[a]++;
    cnt[b]++;
    cnt[c]++;
    if (cnt[5] == 2 && cnt[7] == 1) {
        cout << "YES"
             << "\n";
    } else {
        cout << "NO"
             << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
$alfa = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
              'r','s','t','u','v','w','x','y','z');
 
$ans = '';
 
while($n>0){
  $n--;
  $ans .= $alfa[$n%26];
  $n = floor($n/26);
}
 
echo strrev($ans);

Measured memory_bytes: 16220
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    ll ans = 0;
    map<int, int> mp;
    for(int i=0; i<N; i++) {
        ans += mp[i - A[i]];
        mp[i + A[i]]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 21052
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n,k;
  cin >> n >> k;
  ll ans =0;
  while(n!=0)
  {
    n=n/k;
    ans++;
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int N;
string S;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  cin >> S;

  const char abc[] = "ABC";

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'A') {
      if (!((i + 1 < N) && (S[i + 1] == 'B'))) continue;
      if (!((i + 2 < N) && (S[i + 2] == 'C'))) continue;
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc155/tasks/abc155_a
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    a, b, c = map(int, input().split())
    if a != b and b != c and c != a:
        print('No')
        return
    if a == b and b == c and c == a:
        print('No')
        return

    print('Yes')
    return


if __name__ == '__main__':
    main()


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

int main(){
  
  int a,b;
  
  cin >> a >> b;
  
  if ((a+b)%2 == 0){
  cout << (a+b)/2 << endl;
  }
  
  if ((a+b)%2 == 1){
  cout << (a+b)/2 + 1 << endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int a[10];

bool dfs(int i, int left, int right) {
  if(i == 10) { return true; }

  bool ans = false;
  if(left < a[i]) {
    ans = dfs(i+1, a[i], right);
  }
  if(right < a[i]) {
    ans = dfs(i+1, left, a[i]);
  }
  return ans;
}

int main() {
  int n;
  scanf("%d", &n);

  for(int i = 0; i < n; i++) {
    for(int j = 0; j < 10; j++) {
      scanf("%d", &a[j]);
    }
    cout << (dfs(0, 0, 0) ? "YES" : "NO") << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();

        int x = scanner.nextInt();
        int a = scanner.nextInt();
        if(x<a) {
        	System.out.println(0);
        }else {
        	System.out.println(10);
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

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



int main()
{
    int a, b;
    cin >> a >> b;
    cout << max( {a-b, a+b, a*b} ) << "\n";
    /*cout << max( max( a-b, a+b), a*b)<<"\n";*/
    return 0;

}


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

int main(){

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

    int stick_A, stick_B, stick_C;
    int MP;
    int min_MP = 1000000000;

    for(int flag = 0; flag < (1 << 2*N); flag++){

        MP = -30;
        stick_A = 0;stick_B = 0;stick_C = 0;

        for(int i = 0; i < N; i++){

            //00:not used | 01:A | 10:B | 11:C
            if(flag & (1 << 2*i) && !(flag & (1 << (2*i + 1)))){stick_A += l[i]; MP += 10;}
            else if(!(flag & (1 << 2*i)) && flag & (1 << (2*i + 1))){stick_B += l[i]; MP += 10;}
            else if(flag & (1 << 2*i) && flag & (1 << (2*i + 1))){stick_C += l[i]; MP += 10;}
        }if(stick_A==0 || stick_B==0 || stick_C==0){continue;}

        MP += abs(stick_A - A) + abs(stick_B - B) + abs(stick_C - C);

        //printf("%d\n",flag);
        //cout << stick_A << " " << stick_B << " " << stick_C << " " << MP << endl;

        if(min_MP > MP){min_MP = MP;}
    }

    cout << min_MP << endl;
}

Measured memory_bytes: 256
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let m = read::<usize>();
    let py = (0..m)
        .map(|_| (read::<usize>(), read::<usize>()))
        .collect::<Vec<_>>();

    let mut py2 = py.to_owned();
    py2.sort();

    let mut prev = 1;
    let mut number = 1;

    use std::collections::HashMap;
    let mut hm = HashMap::new();
    for &(p, y) in py2.iter() {
        if p != prev {
            prev = p;
            number = 1;
        }
        hm.insert((p, y), number);
        number += 1;
    }

    for (p, y) in py {
        let &num = hm.get(&(p, y)).unwrap();
        println!("{0:>06}{1:>06}", p, num);
    }
}


Measured memory_bytes: 16172
import java.util.*;

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

        int N = sc.nextInt();
        int[] P = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = sc.nextInt();
        }

        int[] Q = new int[N];
        for (int i = 0; i < N; i++) {
            Q[P[i] - 1] = i;
        }

        int cnt = 1;
        int ret = 1;
        int prev = Q[0];
        for (int i = 1; i < N; i++) {
            if (Q[i] > prev) {
                cnt++;
            } else {
                ret = Math.max(ret, cnt);
                cnt = 1;
            }

            prev = Q[i];
        }

        ret = Math.max(ret, cnt);

        System.out.println(N - ret);
    }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> arr(101);
  rep(i, n) {
    int d;
    cin >> d;
    arr[d] = 1;
  }
  int res = 0;
  rep(i, 101) {
    res += arr[i];
  }
  cout << res << endl;
}


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

public class Main {

	private static final int fieldXSize=20+1, fieldYSize=20+1;
	private static final int initXPos=10, initYPos=10;

	private static final boolean[][] initField() {
		boolean[][] field=new boolean[fieldYSize][fieldXSize];
		for(int i=0; i<field.length; i++)
			Arrays.fill(field[i], false);
		return field;
	}

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true) {

			// input gem
			int gemNum=Integer.parseInt(br.readLine());
			if(gemNum==0)
				break;
			boolean[][] field=initField();
			for(int i=0; i<gemNum; i++) {
				String[] strArray=br.readLine().split(" ");
				int x=Integer.parseInt(strArray[0]),y=Integer.parseInt(strArray[1]);
				field[y][x]=true;
			}

			// read & execute instruction
			int instNum=Integer.parseInt(br.readLine());
			int posX=initXPos, posY=initYPos;
			int gemCount=0;
			for(int i=0; i<instNum; i++) {
				String[] strArray=br.readLine().split(" ");
				int val=Integer.parseInt(strArray[1]);
				int dx=0, dy=0;
				if(strArray[0].equals("N")) dy=+1;
				if(strArray[0].equals("S")) dy=-1;
				if(strArray[0].equals("E")) dx=+1;
				if(strArray[0].equals("W")) dx=-1;
				for(int j=0; j<val; j++) {
					posX+=dx;
					posY+=dy;
					if(field[posY][posX]) {
						field[posY][posX]=false;
						gemCount++;
					}
				}
			}

			System.out.println(gemCount==gemNum?"Yes":"No");
		}

		br.close();

	}
}

Measured memory_bytes: 31884
#include <iostream>
using namespace std;
const int N = 300000;

int main(){
  int prime[N];
  int num;
  
  for ( int i = 0; i < N; i++ ){
    prime[i] = 1;
  }

  prime[0] = 0;
  prime[1] = 0;
  for ( int i = 2; i < N; i++ ){
    if ( prime[i] == 1 && ( i % 7 == 1 || i % 7 == 6 ) ){
      for ( int j = i*2; j < N;  j += i ){
	prime[j] = 0;
      }
    }else{
      prime[i] = 0;
    }
  }
  
  while ( true ){
    cin >> num;
    if ( num == 1 ){
      break;
    }
    cout << num << ":";
    for ( int i = 0; i < N; i++ ){
      if ( prime[i] && num % i == 0 ){
	  cout << " " << i;
      }
    }
    cout << endl;
  }
  return 0;
}

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


int main() {

  int X,Y,Z;
  cin >> X >> Y >> Z;

  int tmpA = Y;
  int tmpB = X;
  int tmpC = Y;
  tmpA = Z;

  cout << tmpA << " " << tmpB << " " << tmpC << endl;

  return 0;

}


Measured memory_bytes: 256