akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int t[10001];
int n,m,a,b,ans=0;
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>t[i];
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>a;
    t[n]=a;
    for(b=0;t[b]!=a;b++);
    if(b!=n)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3112
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i + 100*j + 50*k == X:
                ans += 1
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

int main() {
    char a[200008], b[200008];
    int cont = 0;
    
    scanf("%s %s", a, b);
    
    for (int i = 0; i < strlen(a); ++i){
        if (a[i] != b[i])
            cont += 1;
    }
    
    printf("%d\n", cont);
    
    return 0;
}


Measured memory_bytes: 2120
//stay in this moment
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long 
void q1(){
	int ans=0;
	string s,t;
	cin>>s>>t;
	for(int i=0;i<3;++i)
	if(s[i]==t[i])
	ans++;
	cout<<ans;
}
void q2(){
	int a,b;
	cin>>a>>b;	b--;
	int ans=(b+a-2)/(a-1);
	cout<<ans;
}
void q3(){
	int n;
	cin>>n;
	int arr[n],fre[n];
	for(int i=0;i<n;++i)
	{cin>>arr[n-i-1];fre[i]=1;}
	for(int i=1;i<n;++i)
	if(arr[i]>=arr[i-1])
	fre[i]+=fre[i-1];
	int mx=-1;
	for(int i=0;i<n;++i)
	mx=max(mx,fre[i]);
	cout<<mx-1;
}
void q4(){
	int n;
	cin>>n;
	n*=(n-1);
	cout<<n/2;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	q2();
	return 0;
}
	


Measured memory_bytes: 256
def check():
    N = int(input())
    A = [int(input()) for i in range(N)]
    flag = [0]* N
    count = 0
    
    posi = A[0]
    flag[0] = 1

    while 1:
        flag[posi-1] = 1
        count += 1
        if posi == 2:
            return count
        posi = A[posi-1]
        if flag[posi-1] == 1:
            return -1
print(check())


Measured memory_bytes: 7852
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};
//vector<int> bucket[MAX_N/1000];

int main(void){
    lint N,X,M;
    cin >> N >> X >> M;
    lint d[41][M];
    lint sum[41][M];
    rep(i,M) d[0][i]=(i*i)%M,sum[0][i]=i;
    for(int i=1;i<=40;i++){
        rep(j,M){
            d[i][j]=d[i-1][d[i-1][j]];
            sum[i][j]=sum[i-1][j]+sum[i-1][d[i-1][j]];
        }
    }
    lint ans=0;
    rep(i,41) if((1LL<<i)&N) ans+=sum[i][X],X=d[i][X];
    cout << ans << endl;
}

Measured memory_bytes: 67672
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, b;
cin >> a;

int k = 0;
for(int i = 1; i <= (int) a; i++){
   if(i %2 != 0) k++;
}

cout << setprecision(6)  << (double)k/ (double)a;
}









  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define L long long
using namespace std;
int n,m,p,x[20],a[200010],l[200010][20],r[200010][20],f[300000],g[300000],w[200010];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
	  scanf("%d",&a[i]);
	x[0]=m;
	while(x[p])
	  x[++p]=x[p-1]/2;
	for(i=0;i<=p;i++)
	  {
       for(j=k=1;j<=n;j++)
         {
          if(j>1 && a[j]-a[j-1]>x[i])
            k=j;
          l[j][i]=k;
         }
       for(j=k=n;j>0;j--)
         {
          if(j<n && a[j+1]-a[j]>x[i])
            k=j;
          r[j][i]=k;
         }
       r[n+1][i]=n+1;
      }
    for(i=0;i<(1<<p);i++)
      g[i]=n+1;
    for(i=1;i<(1<<p);i++)
      for(j=1;j<=p;j++)
        if(i&(1<<j-1))
          {
           f[i]=max(f[i],r[f[i^(1<<j-1)]+1][j]);
           g[i]=min(g[i],l[g[i^(1<<j-1)]-1][j]);
          }
    for(i=0;i<(1<<p);i++)
      {
       j=l[g[i]-1][0];
       k=r[f[(1<<p)-1^i]+1][0];
       if(j<=k)
         w[j]++,w[k+1]--;
      }
    for(i=1,k=0;i<=n;i++)
      {
       k+=w[i];
       if(k)
         printf("Possible\n");
       else
         printf("Impossible\n");
      }
	return 0;
}


Measured memory_bytes: 36608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
  static InputReader in;
  static PrintWriter out;

  static class Solution {
    void solve() throws IOException {
      while (true) {
        int n = in.nextInt();
        int x = in.nextInt();
        int combination = 0;
        if (x == 0 && n == 0) {
          break;
        }
        for (int i = 1; i <= n - 2 ; i++) {
          for (int j = i + 1; j <= n - 1; j++) {
            for (int k = j + 1; k <= n; k++){              
              if (i + j + k == x) {
                combination++;
              }
            }
          }
        }
        out.println(combination);
      }
      
//      End solve()
    }
//    End Solution
}

  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}

  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }

    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }

    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken());
    }

    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }

    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }


  }

}

Measured memory_bytes: 24696
n = int(input())
a = list(map(int, input().split()))
di1 = {}
di2 = {}
for i, j in enumerate(a):
    if i-j in di1:
        di1[i-j] += 1
    else:
        di1[i-j] = 1
    if i+j in di2:
        di2[i+j] += 1
    else:
        di2[i+j] = 1

ans = 0
for i, j in di1.items():
    if i not in di2:
        continue
    ans += di2[i]*j
print(ans)

Measured memory_bytes: 57680
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int h, n;
    cin >> h >> n;
    int sum = 0;
    FOR(i,1,n) {
        int x;
        cin >> x;
        sum += x;
    }
    if (sum >= h) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
import java.math.*;
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        n = n - n/100*100;
        n = n - n/10*10;
        if(n==3){
            System.out.println("bon");
        } else if(n==2||n==4||n==5||n==7||n==9){
            System.out.println("hon");
        } else {
            System.out.println("pon");
        }
    }
}


Measured memory_bytes: 35700
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

void solve()
{
    IN(n, k);
    VIN(ll, a, n);
    reps(i, k, n) {
        if (a[i-k] < a[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 4780
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var hwab = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var h = hwab[0];
        var w = hwab[1];
        var a = hwab[2];
        var b = hwab[3];
        int[][] res = Enumerable.Repeat(0, h).Select(_ => new int[w]).ToArray();
        for (int i = b; i < h; i++)
            for (int j = 0; j < a; j++)
                res[i][j] = 1;
        for (int i = 0; i < b; i++)
            for (int j = a; j < w; j++)
                res[i][j] = 1;

        Console.WriteLine(string.Join("\n", res.Select(x => string.Join("", x))));
    }
}

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

int main() {
  int N;
  ll T;
  cin >> N >> T;
  ll result = 0;
  ll last_ti = 0;
  for (int i = 0; i < N; ++i) {
    ll ti;
    cin >> ti;
    if (ti - last_ti <= T) {
      result += ti - last_ti;
    } else {
      result += T;
    }
    last_ti = ti;
  }
  result += T;
  cout << result << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int x,y,z,i;
	while(scanf("%d%d%d",&x,&y,&z)!=EOF)
	{
	for(i=0;;i++)
	{
		if((i*y)+(i+1)*z>x) break;
	}
	printf("%d\n",i-1);
	}
}


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

int main(){
  int n;
  cin >> n;
  vector<int> s(n);
  int ans = 0;
  int count = 0
  rep(i,n){
    cin >> s[i];
    ans += s[i];
    if(s[i] % 10 == 0){
      ++count;
    }
  }
  if(count == n){
    cout << 0 << endl;
    return 0;
  }
  if(ans%10 != 0){
    cout << ans << endl;
    return 0;
  }
  sort(s.begin(),s.end());
  int j = 0;
  while(true){
    if(ans%10 == 0){
      if(s[j]%10 != 0){
        ans -= s[j];
        break;
      }
    }
    ++j;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int n;
    cin >> n;
    vi h(n);
    rep(i,n){
        cin >> h[i];
    }
    int ans = 1;
    int mx = h[0];
    rep1(i,n){
        if(mx>h[i]) continue;
        ans ++;
        mx = max(mx,h[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a, b;
    char op;
    
    while(1){
        
        scanf("%d %c %d", &a, &op, &b);
        
        if(op=='+'){
            printf("%d\n", a+b);
        } else if(op=='-'){
            printf("%d\n", a-b);
        } else if(op=='*'){
            printf("%d\n", a*b);
        } else if(op=='/'){
            printf("%d\n", a/b);
        } else if('?'){
            break;
        }
    }
    
    return 0;
}

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

int A[20];
int n;

int slove(int i,int m){
    if(m==0)return 1;
    if(i>=n)return 0;
    int res=slove(i+1, m)||slove(i+1, m-A[i]);
    return res;
}

int main(){
    cin>>n;
    for (int i=0; i<n; i++)cin>>A[i];
    int q;
    cin>>q;
    int m;
    for (int i=0; i<q; i++){
        cin>>m;
        if(slove(0, m))cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}

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

int main()
{
	int n;

   cin >> n;
   for(int i=1; i<10; i++){
     for(int j=1; j<10; j++){
        if(i*j == n){
            cout << "Yes" << endl; 
            return 0;
        }
     }
   }

   cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
//#define                     IO                                              ios_base::sync_with_stdio(0); cin.tie(0)

int main(){
    //IO;
    int n;
    //cin >> n;
    scanf("%d",&n);
    int a[n + 1];
    int dp[n + 1];
    for(int i = 0; i < n; i++) scanf("%d",&a[i]);//cin >> a[i];
    /*
    dp[0] = a[0];
    dp[1] = a[0] + a[1];
    for(int i = 2; i <= n; i++){
        dp[i] = min(dp[i - 1] + a[i],dp[i - 2] + a[i]);
    }
    cout << dp[n - 1] << endl;
    */
    dp[0] = 0;
    dp[1] = abs(a[0] - a[1]);
    for(int i = 2; i <= n; i++){
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]),dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    //cout << dp[n - 1] << endl;
    printf("%d\n",dp[n - 1]);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    string s;
    cin >> s;
    cout << s[0] << s[1] << s[2] << "\n";
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
vector<P> v[100001];
int n;
int solve(int i,int p) {
  if(v[i].size()==1&&v[i][0].first==p) {
    v[i][0].second=n-1;
    return 1;
  }
  int sum=0,k=-1;
  for(int j=0; j<v[i].size(); j++) {
    if(v[i][j].first!=p) {
      if(v[i][j].second==0) {
        v[i][j].second=solve(v[i][j].first,i);
        sum+=v[i][j].second;
      } else sum+=v[i][j].second;
    } else k=j;
  }
  if(k!=-1) v[i][k].second=n-1-sum;
  return sum+1;
}
int d[111111],d2[111111],f2;
void dfs(int x,int k,int y) {
  d[x]=k;
  for(int i=0; i<v[x].size(); i++) {
    if(d[v[x][i].first]==-1&&v[x][i].first!=y) dfs(v[x][i].first,k+1,y);
  }
}
void D(int s,int t) {
  memset(d,-1,sizeof(d));
  dfs(s,0,t);
  int M=-1,x,f=0;
  for(int i=1; i<=n; i++) {
    if(d[i]>M) M=d[i],x=i;
  }
  memset(d,-1,sizeof(d));
  dfs(x,0,t);
  for(int i=1; i<=n; i++) f|=d[i]==n/2-1;
  if(!f) f2=0;
}
bool check(int s, int t, int n) {return (!d2[s]||d2[s]==n/2-1)&&(!d2[t]||d2[t]==n/2-1);}

int main() {
  int s,t;
  cin >> n >> s >> t;
  for(int i=0,x,y; i<n-1; i++) {
    cin >> x >> y;
    v[x].push_back(P(y,0));
    v[y].push_back(P(x,0));
  }
  for(int i=1; i<=n; i++) {
    if(v[i].size()==1) {
      solve(i,-1);
      break;
    }
  }
  int x=-1,y=-1;
  for(int i=1; i<=n; i++) {
    for(int j=0; j<v[i].size(); j++) {
      if(v[i][j].second==n/2) {x=i,y=v[i][j].first;break;}
    }
  }
  if(x!=-1) {
    memset(d2,-1,sizeof(d2));f2=1;
    D(x,y);
    for(int i=1; i<=n; i++) d2[i]=max(d2[i],d[i]);
    if(d2[s]!=-1&&d2[t]!=-1||d2[s]==-1&&d2[t]==-1) f2=0;
    D(y,x);
    for(int i=1; i<=n; i++) d2[i]=max(d2[i],d[i]);
  }
  if(n%2==0&&f2&&check(s,t,n)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 17260
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

struct edge { int u, v, cost; };
bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}

typedef pair<int, int> P;

int N;
vector<P> vx, vy;
vector<edge> es;
int par[100001], rk[100001];
int ans = 0;
void init(int n) {
	REP(i, N) {
		par[i] = i;
		rk[i] = 0;
	}
}

int find(int x) {
	if (par[x] == x) return x;
	else return par[x] = find(par[x]);
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) return;

	if (rk[x] < rk[y]) par[x] = y;
	else par[y] = x;
	if (rk[x] == rk[y]) ++rk[x];
}

bool same(int x, int y) {
	return find(x) == find(y);
}

void kruskal() {
	sort(es.begin(), es.end(), comp);
	init(N);
	REP(i, es.size()) {
		edge e = es[i];
		if (!same(e.u, e.v)) {
			unite(e.u, e.v);
			ans += e.cost;
		}
	}
}


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


	cin >> N;
	REP(i, N) {
		int x, y;
		cin >> x >> y;
		vx.push_back(P(x, i));
		vy.push_back(P(y, i));
	}
	SORT(vx);
	SORT(vy);
	FOR(i, 1, vx.size()) {
		es.push_back({ vx[i - 1].second, vx[i].second, vx[i].first - vx[i - 1].first });
	}
	FOR(i, 1, vy.size()) {
		es.push_back({ vy[i - 1].second, vy[i].second, vy[i].first - vy[i - 1].first });
	}
	kruskal();
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 13024
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int x,y,T,ans,tmp,tmp2;
	scanf("%d",&T);
	while(T--)
	{
		ans=0;
		scanf("%d%d",&x,&y);
		if(x>y)
		{
			swap(x,y);
		}
		if(y==1)
			ans=0;
		else
		{
			ans+=x-1;
			tmp=sqrt((long long)y*x);
			//printf("%d\n",tmp);
			if((long long)tmp*tmp==(long long)x*y)
			{
			//	printf("*");
				ans--;
			}
			ans+=tmp;
			tmp2=((long long)x*y-1)/tmp;
			if(tmp2-x>0)
				ans+=(tmp2-x);
			if(((long long)x*y-1)/tmp2==tmp)
				ans--;
	//		if(x+1==y)
	//			ans--;
	//		if((long long)tmp*(tmp+1)>=(long long)x*y)
	//			ans--;
		}
		printf("%d\n",ans);
	}
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
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; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
    ll A, B;
    cin >> A >> B;
    cout << A*B << endl;
}

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

int main() {
	int A, B;
	string op;
	cin >> A >> op >> B;
	if ("+" == op) {
		cout <<A + B<<endl;
	}
	else {
		cout << A-B<< endl;
	}
	return 0;
}

Measured memory_bytes: 3440
#include<stdio.h>
int main()
{
	int n,c[20],v[20],i,ans=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&v[i]);
	}
	for(i=0;i<n;i++)
	{
		scanf("%d",&c[i]);
		v[i]-=c[i];
	}
	for(i=0;i<n;i++)
	{
		if(v[i]>0)
			ans+=v[i];
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
		Scanner sc = new Scanner(System.in);
		final int a = sc.nextInt();
		final int b = sc.nextInt();

		boolean isZero = false;
		int neg = 0;
		
		for (int i = a; i <= b; i++) {
			if (i < 0){
			    neg++;
			} else if (i == 0){
			    isZero = true;
			}
		}

		if (isZero) {
			System.out.println("Zero");
		} else if (neg % 2 == 0) {
			System.out.println("Positive");
		} else {
			System.out.println("Negative");
		}

		sc.close();
	}
}



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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    REP(i, 0, N) cin >> A[i];

    int r = 0; ll ans = 0, sum = 0;
    REP(l, 0, N) {
        while (r < N && (sum + A[r]) == (sum ^ A[r])) {
            sum += A[r++];
        }
        ans += r - l;
        if (l == r) r++;
        else sum -= A[l];
    }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    int n,m;
    cin>>n>>m;

    vector<bool> judge(n,false);
    vector<int> wanum(n,0);
    int ac=0;
    int wa=0;
    rep(i,m){
        int p;
        string s;
        cin>>p>>s;
        p--;
        if(judge[p]==false){
            if(s=="WA"){
                wanum[p]++;
            }else{
                judge[p]=true;
                ac++;
            }
        }
    }
    rep(i,n){
        if(judge[i]==true)wa+=wanum[i];
    }
    cout<<ac<<" "<<wa<<endl;
    return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n,m;
  cin >> n >> m;

  priority_queue<ll> que;

  REP(i,n) {
    ll ai;
    cin >> ai;
    que.push(ai);
  }

  REP(i,m){
    ll rm = que.top();
    que.pop();
    que.push(rm/2);
  }

  ll ans = 0;

  REP(i,n) {
    ans += que.top();
    que.pop();
  }
  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


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

int main(void) {
    int cnt[3] = {};
    string s;
    cin >> s;
    for (auto c : s)
        cnt[c - 'a']++;
    cout << (cnt[0] == cnt[1] && cnt[1] == cnt[2] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
//It is good to start with zero//
//    kyu @Aryabhatta//




#include<bits/stdc++.h> 
using namespace std;                          
#pragma GCC optimize("O3")
typedef long long ll;
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define vec(i, a)  for( auto i=a.begin();i != a.end(); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define mp make_pair
#define pb push_back
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define in  freopen("input.txt","r",stdin);
#define out freopen("output.txt","w",stdout);
#define sixfive in out 
typedef long double ld;
typedef std::pair<ll, ll> pii;
typedef std::vector<ll> vi;
const ll MOD = 1e9 + 7;
ll n_bits(ll n ) { ll x= __builtin_popcount(n) ;return x ;}
int pow(int a, int b, int m)
{
    int ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%m;
        b/=2;
        a=(a*a)%m;
    }
    return ans;
}
int main()
{    
    #ifndef ONLINE_JUDGE
    sixfive
    #endif
    fast
    ll t=1;
    //cin>>t;
    while(t--)
    {    
        string s;
        cin>>s;
        int n=s.length();
        if(s[n-1]=='s')
        {
            s+="es";
        }  
        else
        s+='s'; 
    cout<<s;
    }
    return 0;
}

//            sometimes I do it for her...//


Measured memory_bytes: 3640
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int a = scan.nextInt();
			int b = scan.nextInt();
			int s = a + b;
			String S = String.valueOf(s);
			if(a == 0 && b == 0){
				System.out.println("0");
			}else{
				System.out.println(S.length());
			}
		}
	}
}

Measured memory_bytes: 20448
#include <stdio.h>

int main(void)
{
        int N, A, B;
        scanf("%d%d%d", &N, &A, &B);

        int i, ans = 0;
        for (i = 1; i <= N; i++) {
                int x = i;
                int sum = 0;
                while (x) {
                        sum += x % 10;
                        x /= 10;
                }
                if (sum >= A && sum <= B)
                        ans += i;
        }
        printf("%d\n", ans);
        return 0;
}


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

void input(int arr[], int size)
{
    for (int i = 1; i <= size; ++i)
  	{
  	    cin >> arr[i];
  	}
}

int main()
{
	int N,A[21],B[21],C[21];
  	cin >> N;
  	input(A,N);
  	input(B,N);
  	input(C,N-1);
  	
  	int point =0;
  	for (int i = 1; i <= N; ++i)
  	{
  	    point += B[i];
  	    if (A[i]+1 == A[i+1]) point += C[A[i]];
  	}
  	
  	cout << point;
  	
	return 0;
}

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

int main(){
  int D,T,S;
  
  cin >> D >> T >> S;
  
  if( D <= S*T) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 3632
using System;

namespace A_We_Love_Golf
{
    class Program
    {
        static void Main()
        {
            var ans = "NG";
            int k = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);

            for(int i = a; i <= b; i++)
            {
                if(i % k == 0)
                {
                    ans = "OK";
                    break;
                }
                
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 27536
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (i64 i = 0; i < h; i++)
    cin >> s[i];
  vector<vector<i64>> cnth(h, vector<i64>(w)), cntw(h, vector<i64>(w));
  for (i64 i = 0; i < h; i++)
  {
    i64 start = 0, cnt = 0;
    for (i64 j = 0; j < w; j++)
      if (s[i][j] == '.')
        cnt++;
      else
      {
        for (i64 k = start; k < j; k++)
          cnth[i][k] = cnt;
        start = j + 1;
        cnt = 0;
      }
    for (i64 k = start; k < w; k++)
      cnth[i][k] = cnt;
  }
  for (i64 i = 0; i < w; i++)
  {
    i64 start = 0, cnt = 0;
    for (i64 j = 0; j < h; j++)
      if (s[j][i] == '.')
        cnt++;
      else
      {
        for (i64 k = start; k < j; k++)
          cntw[k][i] = cnt;
        start = j + 1;
        cnt = 0;
      }
    for (i64 k = start; k < h; k++)
      cntw[k][i] = cnt;
  }
  i64 ans = 0;
  for (i64 i = 0; i < h; i++)
    for (i64 j = 0; j < w; j++)
      if (s[i][j] == '.')
        ans = max(ans, cnth[i][j] + cntw[i][j]);
  cout << ans - 1 << endl;
  return 0;
}


Measured memory_bytes: 67072
#include <iostream>

using namespace std;

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

	for (int i = 0; i < S.length(); i++) {
		if (i == 0) {
			cout << S[i];
		} else if (i % N == 0 && i>=N) {
			cout << S[i];
		}
	}

	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int l,m,x,y,z,i,j,k,q=0;
  cin>>l>>m;
  vector<vector<int>> d(l,vector<int>(l,1e9)),r(m,vector<int>(3));
  for(j=0;j<l;j++) d.at(j).at(j)=0;
  for(j=0;j<m;j++){
    cin>>x>>y>>z;
    x--;y--;
    d.at(x).at(y)=z;
    d.at(y).at(x)=z;
    r.at(j).at(0)=x;
    r.at(j).at(1)=y;
    r.at(j).at(2)=z;
  }
  for(k=0;k<l;k++){
    for(i=0;i<l;i++){
      for(j=0;j<l;j++){
        d.at(i).at(j)=min(d.at(i).at(j),d.at(i).at(k)+d.at(k).at(j));
      }
    }
  }
  for(j=0;j<m;j++) if(d.at(r.at(j).at(0)).at(r.at(j).at(1))<r.at(j).at(2)) q++;
  cout<<q<<endl;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k, s;
	cin >> n >> k >> s;
	vector<int> a(n);
	if (s == 1000000000) {
		rep(i, k) a[i] = s;
		for (int i = k; i < n; ++i) a[i] = 1;
		rep(i, n) cout << a[i] << (i == n - 1 ? "\n" : " ");
	}
	else {
		rep(i, k) a[i] = s;
		for (int i = k; i < n; ++i) a[i] = s + 1;
		rep(i, n) cout << a[i] << (i == n - 1 ? "\n" : " ");
	}
	return 0;
}


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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll N;
	cin>>N;
	set<ll> st;
    string ans = "YES";
	ll a;
    rep(i,N){
        cin>>a;
        if(st.find(a)!= st.end()){
            ans = "NO";
            break;
        }else{
            st.insert(a);
        }
    }
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N;
void solve(){
	cin>>N;
	vector<P>Front,Back;
	int ans=0;
	rep(i,N){
		int K,L,R;cin>>K>>L>>R;
		if(L>=R){
			ans+=L;
			Front.push_back({K-1,L-R});
		}else {
			ans+=R;
			Back.push_back({N-K,R-L});
		}
	}
	sort(all(Front));sort(all(Back));
	priority_queue<int,vector<int>,greater<int>>que;
	int Index=0;
	rep(i,N){
		while(Index<len(Front)&&Front[Index].first<=i)
			que.push(Front[Index++].second);
		while(len(que)>i+1){
			ans-=que.top();que.pop();
		}
	}
	while(len(que))que.pop();
	Index=0;
	rep(i,N){
		while(Index<len(Back)&&Back[Index].first<=i)
			que.push(Back[Index++].second);
		while(len(que)>i){
			ans-=que.top();que.pop();
		}
	}
	cout<<ans<<"\n";
}
signed main(){
	int T;
	cin>>T;
	while(T--)solve();
}


Measured memory_bytes: 8256
import math
n = int(input())
ls = "abcdefghijklmnopqrstuvwxyz"
cnt = 0
base = 26
while n >= base ** cnt:
    n -= base ** cnt
    cnt += 1
ans = ""
#print(cnt, n)
for i in range(cnt-1, -1, -1):
    res = n // (base ** i)
    ans += ls[res]
    n -= base ** i * res
print(ans)

Measured memory_bytes: 9132
/**
*    created: 13.05.2020 23:20:39
**/
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

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

    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> l(n), r(n);
    for (int i = 0; i < n - 1; i++) l[i+1] = __gcd(l[i],a[i]);
    for (int i = n - 1; i > 0; i--) r[i-1] = __gcd(r[i],a[i]);
    
    int ans = 0;
    rep(i,n) ans = max(ans,__gcd(l[i],r[i]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5548
s=list(input())
t=list(input())
l=[]
for i in range(len(s)-1):
    l.append(s[i])
    l.append(t[i])
if len(s)>len(t):
    l.append(s[len(s)-1])
else:
    l.append(s[len(s)-1])
    l.append(t[len(t)-1])

x=''.join(l)
print(x)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
vector<vector<int>>adj;
main() {
	string s;
	cin>>s;
	int n=s.size()+1;
	adj.resize(n);
	int ind[n];
	int val[n];
	for(int i=0; i<n; i++){
		ind[i]=0;
		val[i]=0;
	}
	for(int i=0; i<s.size(); i++){
		if(s[i]=='<'){
			adj[i].pb(i+1);
			ind[i+1]++;
		}
		else{
			adj[i+1].pb(i);
			ind[i]++;
		}
	}
	queue<int>q;
	for(int i=0; i<n; i++){
		if(ind[i]==0){
			q.push(i);
		}
	}
	while(!q.empty()){
		int node=q.front();
		q.pop();
		for(auto u:adj[node]){
			val[u]=1+val[node];
			q.push(u);
		}
	}
	int sum=0;
	for(int i=0; i<n; i++){
		sum+=val[i];
	}
	cout<<sum;
	return 0;
}

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

int main() {
    string s;
    long long k;
    cin >> s >> k;

    char ans = '1';
    for (int i = 0; i < min((long long)s.length(), k); i++) {
        if (s[i] != '1') {
            ans = s[i];
            break;
        }
    }

    cout << ans << endl;
}

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

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

using namespace std;

int main(){
	int k,ans;
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2] >> k;
	REP(i,k){
		sort(a.begin(), a.end() );
		a[2] = a[2]*2;
	}
	ans = 0;
	REP(i,3) ans += a[i];
	cout << ans << endl;
}


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

#ifdef DEBUG
#define debug(...) __VA_ARGS__
#else
#define endl '\n'
#define debug(...)
#endif
#define debugf(...) debug(printf(__VA_ARGS__))

const int N = 1e5 + 5;



int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int k, x;
    cin >> k >> x;

    if (k * 500 >= x) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
%>

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

int main(){
    vector<int> n(4);
    string ans="YES";
    for(int i = 0;i < 4;i ++){
        cin >> n[i];
    }
    sort(n.begin(),n.end());
    if(n[0]!=1||n[1]!=4||n[2]!=7||n[3]!=9) ans = "NO";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t / 2;
    } else {
        return modpow(m, n - 1) * m;
    }
}

int main() {
    int c = 0, f = 0;
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++){
        if (s[i] == 'C'){
            c++;
        }
        if (c > 0 && s[i] == 'F'){
            f++;
        }
    }
    if (c > 0 && f > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

using namespace std;

int main(void) {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	vector<int> A;
	A.push_back(a);
	A.push_back(b);
	A.push_back(c);
	A.push_back(d);
	A.push_back(e);
	vector<int> v;
	for(int i = 0; i < 5; ++i) {
		for(int j = i + 1; j < 5; ++j) {
			v.push_back(abs(A[i] - A[j]));
		}
	}
	sort(v.begin(), v.end());
	if(v.back() > k) {
		cout << ":(\n";
	} else {
		cout << "Yay!\n";
	}
	return 0;
}



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

int main() {
  int N, A, B;
  int p1, p2;
  
  cin >> N >> A >> B;
  p1 = A * N;
  p2 = B;
  
  if (p1 >= p2)
    cout << p2 << endl;
  else
    cout << p1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

int n;
const int V_MAX = 305;
ll d[V_MAX][V_MAX];

void warshall_floyd(){
    for(int k = 0; k < n; k++){
        for(int i = 0; i < n; i++){
            if(d[i][k] == INF) continue;
            for(int j = 0; j < n; j++){
                if(d[k][j] == INF) continue;
                d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
            }
        }
    }
}

int main()
{
    int h,w;
    n = 10;
    cin >> h >> w;
    int a[h][w];
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cin >> d[i][j];
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }
    warshall_floyd();
    ll ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(a[i][j] == -1) continue;
            else ans += d[a[i][j]][1];
        }
    }
    cout << ans << endl;
}   


Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <vector>

static const size_t n_max = 25;
static bool root[n_max];
static std::pair<size_t, size_t> children[n_max];

enum order {
  pre,
  in,
  post
};

void rec(size_t i, order o) {
  if (o == pre)
    printf(" %zu", i);
  if (children[i].first != size_t(-1))
    rec(children[i].first, o);
  if (o == in)
    printf(" %zu", i);
  if (children[i].second != size_t(-1))
    rec(children[i].second, o);
  if (o == post)
    printf(" %zu", i);
}

int main() {
  size_t n;
  scanf("%zu\n", &n);
  std::fill(root, root + n, true);
  for (size_t i = 0; i < n; i++) {
    size_t j;
    int l, r;
    scanf("%zu%d%d", &j, &l, &r);
    children[j].first = size_t(l);
    children[j].second = size_t(r);
    if (l >= 0)
      root[l] = false;
    if (r >= 0)
      root[r] = false;
  }
  auto r = std::find(root, root + n, true) - root;
  puts("Preorder");
  rec(r, pre);
  puts("");
  puts("Inorder");
  rec(r, in);
  puts("");
  puts("Postorder");
  rec(r, post);
  puts("");
  return 0;
}

Measured memory_bytes: 2652
while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break
    
    if m == -1 or f == -1 or m + f < 30:
        print('F')

    elif 80 <= m + f:
        print('A')

    elif 65 <= m + f:
        print('B')

    elif 50 <= m + f:
        print('C')

    elif 30 <= m + f:
        print('DC'[50 <= r])



Measured memory_bytes: 5592
#include <stdio.h>

void swap(int *x, int *y)
{
    int t;
    
    t = *x;
    *x = *y;
    *y = t;
}

int main(void)
{
    int N, A[100], i, j = 0, n = 0;
    
    scanf("%d", &N);
    for (i = 0; i < N; i++) {
       scanf("%d", &A[i]); 
    }
    while (j < N - 1) {
        for (i = N - 1; i > j; i--) {
            if (A[i] < A[i - 1]) {
                swap(&A[i], &A[i - 1]);
                n++;
            }
        }
        j++;
    }
    for (i = 0; i < N; i++) {
        printf("%d", A[i]);
        if (i != N - 1) {
            printf(" ");
        } else {
            printf("\n");
        }
    }
    printf("%d\n", n);
    return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
bool match(char c1, char c2){
  return (c1=='?' ||c2=='?' ||c1==c2);
};
int main(){
  string a,b,c;
  cin>>a>>b>>c;
  int as=a.size(), bs=b.size(), cs=c.size();
  //a+bとを用意してcをくっつけていくか
  //bのスタート地点が-2000から+2000まで
  vector<bool> ab(16010,true), bc(16010,true), ac(16010,true); 
  for(int i=0; i<as; i++){
    for(int j=0; j<bs; j++){
      if(match(a[i], b[j])==false)
        ab[8000+i-j]=false;
    }
  }
  for(int i=0; i<bs; i++){
    for(int j=0; j<cs; j++){
      if(match(b[i], c[j])==false)
        bc[8000+i-j]=false;
    }
  }
  for(int i=0; i<as; i++){
    for(int j=0; j<cs; j++){
      if(match(a[i], c[j])==false)
        ac[8000+i-j]=false;
    }
  }
  //ab[i]=trueとなるiはabが連結可能
  //i<2000の場合はb先頭でスタートしてる
  //bc[j]とca[k]についてはどう絡むか
  //i<2000の場合、bc[j]はj<2000でないといけない？
  //それかbcのうしろにbcつく、はありえない。bはbにつく
  //ab[i]>2000のばあいはabがついてる
  //iはbの先頭を意味してる。
  //bcは同じくcの先頭か。2000がbの頭なのは固定か
  ll ans=10000;
  for(int i=4000; i<=12000; i++){
    for(int j=4000; j<=12000; j++){
      if(ab[i]&&ac[j]&&bc[8000-i+j]){
        ll L=min(8000,min(i,j));
        ll R=max(8000+as,max(i+bs,j+cs));
        ans=min(ans,R-L);
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384