akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

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

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

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

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

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

const int nmax = 40, abmax = 10,inf = 1000000;
int a[nmax], b[nmax], c[nmax];
int dp[nmax + 1][nmax*abmax + 1][nmax*abmax + 1];

int main() {
	int n, ma, mb; cin >> n >> ma >> mb;

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

	for (int i = 0; i <= n; i++) {
		for (int ca = 0; ca <= nmax*abmax; ca++) {
			for (int cb = 0; cb <= nmax*abmax; cb++) {
				dp[i][ca][cb] = INF;
			}
		}
	}

	dp[0][0][0] = 0;

	for (int i = 0; i < n; i++) {
		for (int ca = 0; ca <= nmax*abmax; ca++) {
			for (int cb = 0; cb <= nmax*abmax; cb++) {
				if (dp[i][ca][cb] == INF)continue;

				//取らない
				dp[i + 1][ca][cb] = min(dp[i + 1][ca][cb], dp[i][ca][cb]);
				//取る
				dp[i + 1][ca + a[i]][cb + b[i]] = min(dp[i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]);
			}
		}
	}

	int ans = INF;

	for (int ca = 1; ca <= nmax*abmax; ++ca) {
		for (int cb = 1; cb <= nmax*abmax; ++cb) {
			if (ca*mb == cb*ma)ans = min(ans, dp[n][ca][cb]);
		}
	}

	if (ans == INF)ans = -1;

	cout << ans << endl;
}


Measured memory_bytes: 25984
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main() {
    int k, x;
    cin >> k >> x;
    cout << (500*k >= x ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int arr[30], brr[30];
int main()
{

    for(int i = 0; i < 26; i++) brr[i] = 55;
    int n;
    scanf("%d",&n);



    for(int i = 0; i < n; i++)
    {
        char s[55];
        memset(arr, 0, sizeof(arr));
        scanf("%s",s);
        for(int j = 0; s[j]; j++)
        {
            arr[s[j] -'a']++;
        }
        for(int i = 0; i < 26; i++)
            brr[i] = min(arr[i], brr[i]);
    }
    for(int i = 0; i < 26; i++)
    {
        while(brr[i]--) printf("%c",i+'a');
    }
    printf("\n");
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int[][] P = new int[N][3];
		for(int i = 0; i < N; i++) {
			P[i][0] = stdIn.nextInt();
			P[i][1] = stdIn.nextInt();
			P[i][2] = stdIn.nextInt();
		}
		
		LABEL: for(int x = 0; x <= 100; x++) {
			for(int y = 0; y <= 100; y++) {
				boolean flag = true;
				int H = 0;
				int temp = 0;
				for(int i = 0; i < N; i++) {
					if(P[i][2] > 0) {
						H = P[i][2]+Math.abs(P[i][0]-x)+Math.abs(P[i][1]-y);
						break;
					}
				}
				for(int j = 0; j < N; j++) {
					if(Math.max(H-Math.abs(P[j][0]-x)-Math.abs(P[j][1]-y),0) != P[j][2]) {
						flag = false;
						break;
					}
				}
				if(flag) {
					System.out.println(x+ " " +y+ " " +H);
					break LABEL;
				}
			}
		}

	}

}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
int v[100];
int dp[50][50][100];
int f(int i,int j,int k){
	if(k==0 or i>j)
		return 0;
	if(dp[i][j][k]!=-1)
		return dp[i][j][k];
	int ans=0;
	if(k>0){
		ans=max(v[i]+f(i+1,j,k-1),ans);
		ans=max(v[j]+f(i,j-1,k-1),ans);
	}
	if(k>1){
		ans=max(f(i+1,j,k-2),ans);
		ans=max(f(i,j-1,k-2),ans);
	}
	return dp[i][j][k]=ans;
}
int main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n,k;
	cin >> n >> k;
	for(int i=0;i<n;i++)
		cin >> v[i];
	memset(dp,-1,sizeof(int)*250000);
	cout << f(0,n-1,k) << endl;
}

Measured memory_bytes: 1280
#include <stdio.h>

int linearsearch(int *A, int key, int n) 
{
    int i = 0;
    A[n] = key;

    while(A[i] != key)
    i++;
    if (i==n) return 0;
    else
    return 1;
}

int main(void)
{
    int n, q, i;
    int S[10000];
    int T[10000];
    int count = 0;

    scanf("%d", &n);
    for(i = 0; i < n; i++) scanf("%d", &S[i]);
    scanf("%d", &q);
    for(i = 0; i < q; i++) scanf("%d", &T[i]);

    for(i = 0; i < q; i++)
    count = count + linearsearch(S, T[i], n);
    printf("%d\n", count);

    return 0;
}


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

int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    int q,w,e;
    q = a+b;
    w = a-b;
    e = a*b;
    int z= max(q,w);
    int r= max(z,e);
    printf("%d\n",r);
    return 0;
}


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

int main(void){
	int num;
  	int ignore = scanf("%d",&num);
  	int count[4] = {0};
  
  	for(int i = 0; i<num; i++){
  		char input[3] = {0};
      	ignore = scanf("%s",&input);
      	if(strcmp(input,"AC") == 0){
        	count[0]++;continue;
        }else if(strcmp(input, "WA") == 0){
          	count[1]++;continue;
        }else if(strcmp(input, "TLE") == 0){
          	count[2]++;continue;
        }else if(strcmp(input, "RE") == 0){
          	count[3]++;continue;
        }
    }
  	printf("AC x %d\n", count[0]);
  	printf("WA x %d\n", count[1]);
  	printf("TLE x %d\n", count[2]);
  	printf("RE x %d", count[3]);
  	ignore++;
  	return 0;
}

Measured memory_bytes: 1736
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
vector<int>v[100000];
int color[100000];
void dpf(int a,int c) {
    color[a] = c;
	stack<int>s;
	for (int i = 0; i < v[a].size(); i++) {
		int t = v[a][i];
		s.push(t);
		color[t] = c;
	}
	while (!s.empty())
	{
		int k = s.top();
		s.pop();
		for (int i = 0; i < v[k].size(); i++) {
			
			int t = v[k][i];
			if (color[t] == 0) {
				s.push(t);
				color[t] = c;
			}
		}
	}
}
void setcolor(int n) {
	int t=1;
	for (int i = 0; i < n; i++) {
		if (color[i] == 0) {
			dpf(i, t++);
		}
	}
}
int main(void) {
	int n,k;
	cin >> n;
	cin >> k;
	for (int i = 0; i < k; i++) {
		int a, b;
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	setcolor(n);
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int a, b;
		cin >> a >> b;
		if (color[a]==color[b])
		{
			cout << "yes";
		}
		else {
			cout << "no";
		}
		cout << endl;
	}
}


Measured memory_bytes: 8980
import java.util.Scanner;
public class Main {
	public static void main(String []args) {
		Scanner sc=new Scanner(System.in);
		long a;
		while(sc.hasNextLong()) {
			a=sc.nextLong();
		double m=Math.sqrt(a);
		long n;
		n=(long)m;
		for(long i=n;i>0;i--) {
			if(a%i==0) {
				System.out.println(i+a/i-2);
				break;
			}
		}
		}	
	}
}

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

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

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//------------------------------------------

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
//------------------------------------------

int main() {
  int64 i = 0, N, T, c, t, ans = 1001;
  cin >> N >> T;

  REP(i, N){
    cin >> c >> t;
    
    if (t <= T) {
      ans = (c < ans)?c:ans;
    }
    
  }
  if(ans == 1001){
    cout << "TLE" << endl;
  }else{
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/**
 * Binary search trees - Binary Search Tree II
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		Tree tree = new Tree();
		int key;

		int n = parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			line = br.readLine();
			switch (line.charAt(0)) {
				case 'i':
					key = parseInt(line.substring(line.indexOf(' ') + 1));
					tree.insert(new Node(key));
					break;
				case 'f':
					key = parseInt(line.substring(line.indexOf(' ') + 1));
					if (tree.find(key) != null) System.out.println("yes");
					else System.out.println("no");
					break;
				case 'p':
					tree.print(Tree.Order.Inorder);
					tree.print(Tree.Order.Preorder);
					break;
			}
		}
	} //end main
}

class Tree {

	enum Order {
		Preorder,
		Inorder,
		Postorder
	}

	Node root;

	Node insert(Node node) {
		Node parent = null;
		Node child = root;
		//
		while (child != null) {
			parent = child;
			if (node.key < child.key) child = child.left;
			else child = child.right;
		}
		node.parent = parent;
		//
		if (parent == null) {
			this.root = node;
		} else if (node.key < parent.key) {
			parent.left = node;
		} else {
			parent.right = node;
		}
		return node;
	}

	Node find(int key) {
		Node ret = null;
		Node node = root;
		while (node != null) {
			if (key != node.key) {
				if (key < node.key) node = node.left;
				else node = node.right;
			} else {
				ret = node;
				break;
			}
		}
		return ret;
	}

	void print(Order order) {
		switch (order) {
			case Preorder:
				walkPreorder(root);
				break;
			case Inorder:
				walkInorder(root);
				break;
			case Postorder:
				walkPostorder(root);
				break;
		}
		System.out.println();
	}

	void walkPreorder(Node node) {
		if (node == null) return;
		System.out.print(" " + node.key);
		walkPreorder(node.left);
		walkPreorder(node.right);
	}

	void walkInorder(Node node) {
		if (node == null) return;
		walkInorder(node.left);
		System.out.print(" " + node.key);
		walkInorder(node.right);
	}

	void walkPostorder(Node node) {
		if (node == null) return;
		walkPostorder(node.left);
		walkPostorder(node.right);
		System.out.print(" " + node.key);
	}
}

class Node {
	int key;
	Node parent, left, right;

	Node(int key) {
		this.key = key;
	}
}

Measured memory_bytes: 126968
#include<bits/stdc++.h>
#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define ret return
#define all(vl) vl.begin(),vl.end()
#define sor sort 
#define cl clear
#define m_p make_pair 
#define sz(a) a.size()
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;
typedef map<string,ll> mapstl;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s,t;
	cin>>s>>t;
	ll ans = 0;
	for(int i=0;i<s.size();i++)
		ans+=(s[i]!=t[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3796
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int s1,s2;

int main(){
	while(1){
		cin>>s1>>s2;
		if(!s1&&!s2) break;
		P ans;
		ans=P(0,s1+s2);
		for(int i=0;i<4;i++){
			cin>>s1>>s2;
			if(ans.second<s1+s2) ans=P(i+1,s1+s2);
		}
		int T=ans.first;
		if(!T) cout<<'A'<<' ';
		else if(T==1) cout<<'B'<<' ';
		else if(T==2) cout<<'C'<<' ';
		else if(T==3) cout<<'D'<<' ';
		else cout<<'E'<<' ';
		cout<<ans.second<<endl;
	}
}

Measured memory_bytes: 1160
import java.io._
import scala.io.StdIn.{readLine,readInt}
import scala.io.Source
import scala.annotation.tailrec

object Main {
  var size = 0
  var count = 0
  val out:BufferedWriter =
    new BufferedWriter(new OutputStreamWriter(new FileOutputStream(FileDescriptor.out), "ASCII"), 512)

  def swap(a:Array[Int],i:Int,j:Int) =  {
    val temp = a(i)
    a(i) = a(j)
    a(j) = temp
  }

  def downHeap(a:Array[Int], i:Int):Unit = {
    var largest = i
    if(i*2 <= size) {
      if(a(i*2-1) > a(i-1)) largest = i*2
      if(i*2+1<=size && a(i*2) > a(largest-1)) largest = i*2+1
      if(largest != i) {
        swap(a,i-1,largest-1)
        downHeap(a,largest)
      }
    }
  }

  def extract(a:Array[Int]):Int = {
    val max = a(0)
    if(size>0) {
      a(0) = a(size-1)
      size -= 1
      downHeap(a,1)
    }
    max
  }

  def upHeap(a:Array[Int], i:Int):Unit = {
    val j = i/2
    if(j>0 && a(j-1) < a(i-1)) { swap(a,j-1,i-1); upHeap(a,j) }
  }

  def insert(a:Array[Int], n:Int) = {
    a(size) = n
    size += 1
    upHeap(a,size)
  }

  def main(args:Array[String]) = {
    val a = new Array[Int](2000000)
    var s = ""
    Source.stdin.getLines.takeWhile(_!="end").foreach { s =>
      val op = s.split(" ")
      if(op(0) == "insert") {
        insert(a, op(1).toInt)
      } else if(op(0) == "extract") {
        val x = extract(a).toString
        out.write(x)
        out.write("\n")
        if(count<100) count += 1
        else {
         out.flush
         count = 0
        }
      }
    }
    out.flush
  }
}

Measured memory_bytes: 462628
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int cnt[1000005],a[200005];
bool f[1000005];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m=1e6;
	cin>>n;
	FOR(i,1,n)cin>>a[i],cnt[a[i]]++;
	sort(a+1,a+n+1);
	int ans=0;
	FOR(i,1,n){
		if(cnt[a[i]]==1&&!f[a[i]])ans++;
		if(f[a[i]])continue;
		for(int j=a[i];j<=m;j+=a[i])f[j]=1;
	}
	cout<<ans;
	RE 0;
}




Measured memory_bytes: 9340
n, x = map(int, input().split())
a = sorted(map(int, input().split()))
rest = x
ans = 0
for i in range(n) :
    if rest > a[i] :
        if i != n-1 :
            rest -= a[i]
            ans += 1
        else :
            print(ans)
            break
    elif rest == a[i] :
        ans += 1
        print(ans)
        break
    else :
        print(ans)
        break
else :
    print(ans)


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#include<iostream>
#include<math.h>
#include <string.h>
using namespace std;
main (){

 char s1[7];
 for (int i=0;i<6;i++){
 cin >> s1[i];
 }
    if (s1[2]==s1[3] && s1[4]==s1[5]){
        cout << "Yes"<<endl;
    }
    else {cout << "No"<<endl;}





}

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>;
using G = vector<vector<int>>;
int cons = 1e6 + 1;
vector<ll> fact(cons, 0);
    
int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    int ans = 0;
    rep(i,n){
        if(i>0){
            if(a[i]==a[i-1]){
                fact[a[i]]++;
                continue;
            }
        }
        for(int j=a[i]; j<cons; j+=a[i]){
            fact[j]++;
        }
    }
    rep(i,n){
        if(fact[a[i]]==1) ans++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12764
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define mid ((l + r) >> 1)
#define lson (x << 1)
#define rson ((x << 1) | 1)
using namespace std;
typedef long long LL;

LL val[800005],tag[800005] = {0};
void pushup(LL x){
	val[x] = val[lson] + val[rson];
}

void pushdown(LL x,LL l,LL r){
	if(!tag[x]) return;
	tag[lson] += tag[x]; val[lson] += (mid - l + 1) * tag[x];
	tag[rson] += tag[x]; val[rson] += (r - mid) * tag[x];
	tag[x] = 0;
}

void modify(LL x,LL l,LL r,LL L,LL R,LL v){
	if(L <= l && r <= R){
		tag[x] += v; val[x] += v * (r - l + 1);
		return;
	}
	pushdown(x,l,r);
	if(L <= mid) modify(lson,l,mid,L,R,v);
	if(R > mid) modify(rson,mid + 1,r,L,R,v);
	pushup(x);
}

LL query(LL x,LL l,LL r,LL L,LL R){
	if(L <= l && r <= R) return val[x];
	LL ret = 0;
	pushdown(x,l,r);
	if(L <= mid) ret += query(lson,l,mid,L,R);
	if(R > mid) ret += query(rson,mid + 1,r,L,R);
	pushup(x); return ret;
}

LL n,a[200005],sum = 0,tp;
int main(){
	ios::sync_with_stdio(false);
	cin >> n; n ++;
	for(LL i = 1;i <= n;i ++) cin >> a[i];
	
	if(n == 1 && a[1] == 1){
		cout << 1 << '\n';
		return 0;
	}
	
	if(a[1]){ cout << -1 << '\n'; return 0; }
	tp = 1; a[n] --; modify(1,1,n,1,n,1);
	for(LL i = 2;i <= n;i ++){
		LL cnt;
		while(1){
			cnt = query(1,1,n,tp,tp);
			if(cnt > a[i]) cnt = a[i];
//			cout << tp << ' ' << cnt << ' ' << a[i] << ' ' << (i - tp) * cnt << endl;
			modify(1,1,n,tp,tp,- cnt);
			modify(1,1,n,tp + 1,i,cnt); modify(1,1,n,i,i,- cnt);
			a[i] -= cnt; sum += (i - tp) * cnt;
			if(!a[i]) break;
			tp ++; if(tp >= i){ cout << -1 << '\n'; return 0; }
		}
	} cout << sum + n << '\n';
	return 0;
}

Measured memory_bytes: 8504
#include <bits/stdc++.h>
#define int long long

using namespace std;
using ll = long long;

main() {
  ios :: sync_with_stdio(0);
  cin.tie(0);
  string a;
  cin >> a;
  int q;
  cin >> q;
  bool rev = 0;
  deque <char> s;
  for (auto x : a) s.push_back(x);
  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      rev ^= 1;
    }
    else {
      int f;
      char c;
      cin >> f >> c;
      if (rev) {
        if (f == 1) {
          s.push_back(c); 
        }
        else {
          s.push_front(c);
        }
      }
      else {
        if (f == 1) {
          s.push_front(c);
        }
        else {
          s.push_back(c);
        }
      }
    }
  } 
  if (rev) {
    reverse(s.begin(), s.end());
  }
  for (auto x : s) cout << x;
  return 0;
}

Measured memory_bytes: 976
from sys import stdin
readline = stdin.readline

N, K = list(map(int, readline().split()))
A = list(map(int, input().split()))

prev = 0
point = 1
ans = []
for i in range(N):
    if i >= K:
        if A[i-K] < A[i]:
            ans.append("Yes")
        else:
            ans.append("No")
print(*ans, sep='\n') 


Measured memory_bytes: 111228
#include<iostream>
         
        using namespace std;
         
        int main(){
        int c[14]={0,13,1,2,3,4,5,6,7,8,9,10,11,12};
     
        int a,b;
        cin>>a>>b;
         
        if(c[a]>c[b])cout<<"Alice"<<endl;
        else if(c[a]<c[b])cout<<"Bob"<<endl;
        else cout<<"Draw"<<endl;
        return 0;
        }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define inf 1e18
using namespace std;

int main(){
    int N;  cin >> N;
    vector<tuple<int,int,int>> Pos(N);
    for(int i=0; i<N; i++){
        int x, y;  cin >> x >> y;
        Pos[i] = make_tuple(i, x, y);
    }
    sort(Pos.begin(), Pos.end(), [](const tuple<int,int,int> &a, const tuple<int,int,int> &b){
        return get<1>(a) < get<1>(b);
    });
    vector<vector<pair<int,ll>>> G;
    G = vector<vector<pair<int,ll>>>(N, vector<pair<int,ll>>());
    for(int i=0; i<N-1; i++){
        int n1 = get<0>(Pos[i]), n2 = get<0>(Pos[i+1]);
        ll dx = abs(get<1>(Pos[i]) - get<1>(Pos[i+1]));
        ll dy = abs(get<2>(Pos[i]) - get<2>(Pos[i+1]));
        G[n1].push_back(make_pair(n2,min(dx, dy)));
        G[n2].push_back(make_pair(n1,min(dx, dy)));
    }
    sort(Pos.begin(), Pos.end(), [](const tuple<int,int,int> &a, const tuple<int,int,int> &b){
        return get<2>(a) < get<2>(b);
    });
    for(int i=0; i<N-1; i++){
        int n1 = get<0>(Pos[i]), n2 = get<0>(Pos[i+1]);
        ll dx = abs(get<1>(Pos[i]) - get<1>(Pos[i+1]));
        ll dy = abs(get<2>(Pos[i]) - get<2>(Pos[i+1]));
        G[n1].push_back(make_pair(n2,min(dx, dy)));
        G[n2].push_back(make_pair(n1,min(dx, dy)));
    }

    ll ans = 0;
    vector<bool> used(N,false);
    priority_queue<pair<ll,int>, vector<pair<ll,int>>, greater<pair<ll,int>>> que;
    que.push(make_pair(0,0));
    while(!que.empty()){
        pair<ll,int> p = que.top();
        que.pop();
        ll cost = p.first;
        int v = p.second;
        if(used[v]) continue;
        used[v] = true;
        ans += cost;
        for(int i=0; i<G[v].size(); i++){
            que.push(make_pair(G[v][i].second, G[v][i].first));
        }
    }
    cout << ans << endl;
}


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

const int INF = 1e9;

int main() {
	int A,B,C,X,Y;
	cin>>A>>B>>C>>X>>Y;
	int ans = INF;
	if(X>Y){
	swap(X,Y);//X<=Y
	swap(A,B);
	}
	ans = min(ans,A*X+B*Y);
	ans = min(ans,2*X*C +B*(Y-X));
	ans = min(ans,2*Y*C);
	cout<<ans<<endl;
}

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

int main()
{
    int n;
    cin >> n;
    int total = 0;
    for (int i = 0; i < n; i++) {
        int l, r;
        cin >> l >> r;
        total += r - l + 1;
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int n,a[202020],b[202020];
vpi v;

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

   cin >> n;
   for(int i=1;i<=n;i++){
      cin >> a[i] >> b[i];
      v.pb( {b[i],a[i]} );
   }

   sort(all(v));
   int cur = 0;
   for(int i=0;i<n;i++){
      int x =v[i].fs;
      int y = v[i].sc;
      if( y+cur<=x ){
         cur+=y;
      }
      else {
         cout << "No" << endl;
         return 0;
      }
   }
   cout << "Yes" << endl;

return 0;
}
///....



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

int main(){
  string S;
  cin>>S;
  int ans = 0;
  int count =0;
  int n = S.length();
  if(S[0]!='A') ans +=1;
  if((S[1]>='A')&&(S[1]<='Z')) ans+=1;
  for(int i=2;i<n-1;++i){
    if(S[i]=='C')count+=1;
    else if((S[i]>='A')&&(S[i]<='Z')) ans+=1;
  }
  if((S[n-1]>='A')&&(S[n-1]<='Z')) ans+=1;
////////////////
  if(ans>0 || count>=2||count==0)cout<<"WA"<<endl;
  else cout<<"AC"<<endl;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

P operator+ (const P &p1, const P &p2) {
  return P(p1.fi + p2.fi, p1.se + p2.se);
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  while(1) {
    int w, h; cin >> w >> h;
    if(w == 0) break;
    vvi hwl(h);
    vvi wwl(h+1);
    REP(i, h) hwl[i].resize(w+1);
    REP(i, h+1) wwl[i].resize(w);

    REP(i, h) {
      hwl[i][0] = 1;
      hwl[i][w] = 1;
    }

    REP(i, w) {
      wwl[0][i] = 1;
      wwl[h][i] = 1;
    }

    REP(i, h-1) {
      REP(j, w-1) cin >> hwl[i][j+1];
      REP(j, w) cin >> wwl[i+1][j];
    }
    REP(j, w-1) cin >> hwl[h-1][j+1];
    vvi d(h);
    vector<P> dif = {P(1, 0), P(-1, 0), P(0, 1), P(0, -1)};
    vector<vector<bool>> sel(h);
    REP(i, h) d[i].resize(w, 0);
    REP(i, h) sel[i].resize(w, false);
    queue<P> q;
    q.push(P(0, 0));
    sel[0][0] = true;
    d[0][0] = 1;
    while(!q.empty()) {
      P now = q.front(); q.pop();
      REP(i, 4) {
        int x = (now+dif[i]).fi;
        int y = (now+dif[i]).se;
        // cout << now.fi << ":" << now.se << " " << x << ":" << y << endl;
        switch(i) {
        case 0:
          // cout << wwl[now.fi+1][now.se] << endl;
          if(wwl[now.fi+1][now.se]) continue;
          break;
        case 1:
          // cout << wwl[now.fi][now.se] << endl;
          if(wwl[now.fi][now.se]) continue;
          break;
        case 2:
          // cout << hwl[now.fi][now.se+1] << endl;
          if(hwl[now.fi][now.se+1]) continue;
          break;
        default:
          // cout << hwl[now.fi][now.se] << endl;
          if(hwl[now.fi][now.se]) continue;
          break;
        }
        if(!sel[x][y]) {
          d[x][y] = d[now.fi][now.se]+1;
          q.push(P(x, y));
          sel[x][y] = true;
        }
      }
      if(sel[h-1][w-1]) break;
    }

    cout << d[h-1][w-1] << endl;
  }
}



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

#define INF  						1e15
#define EPS   						1e-9
#define MOD 						1000000007
#define Pi 							3.14159265358979323846264338327950288419716939937510

#define umap 						unordered_map
#define uset 						unordered_set
#define fi 							first
#define se 							second
#define ll 							long long 
#define vi 							vector<int>
#define pii 						pair<int,int>
#define vll 						vector<ll>
#define pll							pair<ll,ll>
#define pb 							push_back
#define pob 						pop_back
#define pf 							push_front
#define pof 						pop_front
#define maxE(a,n) 					*max_element(a,a+n);
#define minE(a,n) 					*min_element(a,a+n);
#define all(x) 						x.begin(), x.end()

#define fast 						ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fori(i,a,n) 				for (ll  i=a;i<n;i++)
#define ford(i,a,n) 				for (ll  i=n-1;i>=a;i--)

ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll power(ll x, ll b,ll m) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= m;} b >>= 1; x *= x; x %= m;} return p % m;}
void dbg(string s){cout<<s<<endl;}


void solve(){

	int k;
	cin>>k;

	string str = "ACL";
	string op = "";
	while(k--){
		op += str;
	}
	
	cout<<op<<endl;

}


int main(){

	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	fast;
	ll t = 1;

	while(t--){
		solve();
	}
}

Measured memory_bytes: 3652
#define _GLIBCXX_DEBUG    //空コンテナ操作禁止　Clang環境では#define _LIBCPP_DEBUG 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;
using ll = long long;

int main(){
  int N, X;
  cin >> N >> X;
  vector<int> L(N+1);
  for( int i=1; i<=N; i++ ) cin >> L.at(i);
  
  int D = 0, ans = 1;
  for( int i=2; i<=N+1; i++ ){
    D += L.at(i-1);
    if( D <= X ) ans++;
  }
  cout << ans;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

//bool debug = true;
ll solve(mat &cho){
    int res = 0, num = cho.size();
    //K + 1になりそうなときに切る
    vec sum(num, 0);
    rep(j,W){
        bool cut = false;
        rep(i,num) {
            sum[i] += cho[i][j];
            if(sum[i] > K) cut = true;
        }
        if(cut){
            rep(i,num) {
                sum[i] = cho[i][j];
                if(sum[i] > K) return INF;
            }
            ++res;
        }

        /*if(debug) {
            cout<<res<<endl;
            rep(i,num) cout<<sum[i]<<' ';
            cout<<endl;
        }*/
    }
    return res;
}

int main() {
    cin>>H>>W>>K;
    mat cho(H, vec(W));
    rep(i,H) rep(j,W) {
        char c;
        cin>>c;
        cho[i][j] = c - '0';
    }
    ll ans = INF;
    rep(s, 1<<(H - 1)){
        /*if(s == 2) debug = true;
        else debug = false;*/

        ll cut = 0;
        mat memo(1, vec(W));
        rep(i, W) memo[0][i] = cho[0][i];
        rep(i,H - 1) {
            if(!((s>>i)&1)){
                rep(j,W) memo[cut][j] += cho[i + 1][j];
            }else{
                memo.push_back(cho[i + 1]);
                ++cut;
            }
        }
        ans = min(ans, cut + solve(memo));
        //cout<<cut<<' '<<solve(memo)<<endl;
    }
    cout<<ans<<endl;
}

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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

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

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

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

    int N; cin >> N;
    int ans = 0;
    REPS(i, N)
    {
        if(i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
	int D, N; cin >> D >> N;
	int count = 0;
	if(D == 0){
		for(int i = 1;; ++i){
			if(i % 100 != 0){
				count++;
				if(count == N){
					cout << i << endl;
					break;
				}
			}
		}
	}else if(D == 1){
		for(int i = 100;; i += 100){
			if(i % 100 == 0 && i % 10000 != 0){
				count++;
				if(count == N){
					cout << i << endl;
					break;
				}
			}
		}
	}else{
		for(int i = 10000;; i += 10000){
			if(i % 1000000 != 0){
				count++;
				if(count == N){
					cout << i << endl;
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef long long int lli;
 
int main(void){
  vector<lli> a,b,c;
  int n;
  lli x,y;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x;a.pb(x);
  }
  for(int i=0;i<n;i++){
    cin>>x;b.pb(x);
  }
  lli resp=0,resm=0;
  for(int i=0;i<n;i++){
    c.pb(a[i]-b[i]);
    if(a[i]>b[i]) resp+=a[i]-b[i];
    else resm+=(b[i]-a[i])/2;
  }
  //printf("+%d  -%d\n",resp,resm);
  if(resp>resm) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
const int INFTY = (1 << 21); // 2097152
// const ll INFTY = (1LL << 60);
const ll MD = 1000000007LL;
// fprintf(stderr, "%d %lld \n", x, xll);


int H, W;
char M[50][50];
char A[50][50];
vint dx = {-1, -1, -1,  0, 0,  1, 1, 1};
vint dy = {-1,  0,  1, -1, 1, -1, 0, 1};

int main() {
	cin >> H >> W;
	rep(y, H){
		string s; cin >> s;
		rep(x, W) M[y][x] = s[x];
	}

	rep(y, H)
		rep(x, W){
			if(M[y][x] == '#'){
				A[y][x] = '#';
			}
			else{
				int b = 0;
				rep(d, dx.size()){
					int xx = x + dx[d];
					int yy = y + dy[d];
					if(xx >= 0 && xx < W && yy >= 0 && yy < H && M[yy][xx] == '#') b++;
				}
				A[y][x] = '0' + b;
			}
		}

	rep(y, H){
		rep(x, W) cout << A[y][x];
		cout << endl;
	}
}

Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int mod = (int) 1e9 + 7;

int mul(int a, int b) {
  return (long long) a * b % mod;
}

void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

const int maxn = (int) 2e5 + 5;
int n;
int a[maxn];

bool read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  return true;
}

int dp[maxn], dpc[maxn];

void solve() {
  a[n] = maxn - 1;
  memset(dp, 0, sizeof(dp));
  memset(dpc, 0, sizeof(dpc));
  dp[0] = 1;
  dpc[a[0]] = 1;
  for (int i = 0; i < n; i++) {
    if (a[i] == a[i + 1]) {
      continue;
    }
    auto &cur = dp[i + 1];
    cur = dpc[a[i]];
    add(dpc[a[i + 1]], cur);
  }
  printf("%d\n", dp[n]);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        boolean flg = true;
        int count = 0;
        while(flg) {
            flg = false;
            for(int j = n-1; j > 0; j--) {
                if(a[j] < a[j-1]) {
                    int tmp = a[j];
                    a[j] = a[j-1];
                    a[j-1] = tmp;
                    flg = true;
                    count += 1;
                }
            }
        }
        System.out.printf("%d", a[0]);
        for(int i = 1; i < n; i ++) {
            System.out.printf(" %d", a[i]);
        }
        System.out.printf("\n");
        System.out.println(count);
    }
}


Measured memory_bytes: 26652
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////


int main(){fastio
    
    ll x;cin>>x;
    rep(t,1,10000000){
        if(t*(t+1)/2>=x){
            cout<<t<<endl;return 0;
        }
    }
    
    return 0;
}



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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  int cnt = h[0];

  for (int i = 1; i < n; i++) {
    if (h[i] > h[i - 1]) {
      cnt += h[i] - h[i - 1];
    }
  }
  cout << cnt << endl;
}

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

  solve();
  return 0;
}


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

typedef long long llint;
const int MAXL = 11;

char C[MAXL];
llint sol;

int main() {
  scanf("%s", C);
  int l = strlen(C);
  for (int mask = 0; mask < (1 << (l-1)); ++mask) {
    llint curr = 0;
    for (int i = 0; i < l; ++i) {
      if ((mask >> (i-1)) & 1) {
        sol += curr;
        curr = 0;
      }
      curr = curr * 10 + C[i] - '0';
    }
    sol += curr;
  }
  printf("%lld\n", sol);
  return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 11451419194545;

int main(){
    ll A, B; cin >> A >> B;
	ll ans = A - B + 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons;
const dx = [1,0,-1,0];
const dy = [0,1,0,-1];
void read(T...)(auto ref T args){ 
	auto line = readln().split(); 
	foreach(i,ref arg; args) arg = line[i].to!(typeof(arg));
}
int sum(int n){return n * (n + 1)/ 2;}
int tax(int per,int yen) {return cast(int)(yen * (100 +per) / 100);}
void main(){
	int x,y,s;
	while(read(x,y,s),x|y|s){
		int ans ;
		foreach(i;1..s){
			foreach_reverse(j;i..s){
				if (tax(x,i) + tax(x,j) == s ){
					ans = max(ans,tax(y,i) + tax(y,j));break;
				}
			}
		}
		ans.writeln;
	}
}

Measured memory_bytes: 2404
n = int(input())
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))

sa1=[0]*(n+1)
sa2=[0]*(n+1)

for i in range(1,n+1):
  sa1[i] += sa1[i-1]+a1[i-1]
  sa2[i] += sa2[i-1]+a2[i-1]

rewords = [0]*n
for i in range(n):
  rewords[i] = (sa1[i+1]) + (sa2[-1]-sa2[i])

print(max(rewords))  

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = -1, tmp = Integer.MAX_VALUE;
        int ans = 0;
        for(int i = 0; i < n; i++) {
            int h = Integer.parseInt(sc.next());
            sum = tmp >= h ? sum + 1 : 0;
            tmp = h;
            ans = Math.max(ans, sum);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 46720
#include<bits/stdc++.h>
using namespace std;
int main(){

  string s,t,u;
  cin>>s>>t>>u;
  if(s[s.size()-1]==t[0]&&t[t.size()-1]==u[0]){
    cout<<"YES"<<endl;
  }
  else{
	cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 256
line = input()
n1 = int(line[:2])
n2 = int(line[2:])
if n1 > 12 or n1 == 0:
	v1 = False
else:
	v1 = True
if n2 > 12 or n2 == 0:
	v2 = False
else:
	v2 = True
if v1 and v2:
	print("AMBIGUOUS")
elif v1 and not v2:
	print("MMYY")
elif not v1 and v2:
	print("YYMM")
else:
	print("NA")

Measured memory_bytes: 3064
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


class UnionFind:
    def __init__(self, n):
        #親要素のノード番号を格納　xが根のとき-(サイズ)を格納
        self.par = [-1 for i in range(n)]
        self.n = n

    def find(self, x):
        #根ならその番号を返す
        if self.par[x] < 0:
            return x
        else:
            #親の親は親
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def is_same(self, x, y):
        #根が同じならTrue
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y: return

        #木のサイズを比較し、小さいほうから大きいほうへつなぐ
        if self.par[x] > self.par[y]:
            x, y = y, x

        self.par[x] += self.par[y]
        self.par[y] = x

    def size(self, x):
        return -self.par[self.find(x)]

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.par) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    N, M = NMI()
    F = [NLI() for _ in range(M)]
    uf = UnionFind(N)
    for a, b in F:
        a, b = a-1, b-1
        uf.unite(a, b)
    S = [uf.size(x) for x in range(N)]
    print(max(S))


if __name__ == "__main__":
    main()

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

int compf(const void *a, const void *b){
	return (*(int*)a - *(int*)b);
}

int main(){
  int n, k, input, sum = 0;
  scanf("%d %d", &n, &k);
  int list[n];
  
  for(int i = 0; i < n; i++)
  	scanf("%d", list+i);
  	
  qsort(list, n, sizeof(int), compf);
  
  for(int i = 0; i < k; i++)
  	sum += list[i];
  	
  printf("%d\n", sum);
    
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

int countOnes(int m) {
	int ans = 0;
	while (m) { ans++; m = m & (m - 1); }
	return ans;
}

int main() {
	int n; cin >> n;
	vector<vector<int>> match(n);
	for (auto &v : match) { v.resize(n); for (auto &x : v) { cin >> x; } }
	vector<ll> dp((1 << n) + 1, 0); dp[0] = 1;

	for (int mask = 0; mask < (1 << n) - 1; mask++) {		//mask houwe states l B
		int a = countOnes(mask);	//first a bits are already matched
		for (int b = 0; b < n; b++) {
			if (match[a][b] && !(mask & (1<<b))) {
				int newM = mask ^ (1 << b);
				dp[newM] += dp[mask]; dp[newM] %= mod;
			}
		}
	}

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

Measured memory_bytes: 16640
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

int abs(int x){
  return x > 0 ? x : -x;
}

int length(char c[]){
  int cnt=0;
  for(cnt=0;c[cnt]!='\0';cnt++){
  }
  return cnt;
}


int a,b;

int main(){
  scanf("%d %d",&a,&b);
  printf("%d\n",2*b-a);
}


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

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

const ll INF = 1LL << 60;

int main() {
	int a, b, q;
	cin >> a >> b >> q;
	vector<ll> s(a + 2), t(b + 2);
	s[0] = t[0] = -INF;
	s[a + 1] = t[b + 1] = INF;
	REP(i, a) cin >> s[i];
	REP(i, b) cin >> t[i];
	rep(i, q) {
		ll x;
		cin >> x;
		auto itr1 = lower_bound(s.begin(), s.end(), x) - s.begin();
		auto itr2 = lower_bound(t.begin(), t.end(), x) - t.begin();
		ll sr = s[itr1];
		ll tr = t[itr2];
		ll sl = s[itr1 - 1];
		ll tl = t[itr2 - 1];
		ll ans;
		if (sl <= tl && sr <= tr) {
			ans = min(sr - x + min(sr - tl, tr - sr), x - tl + min(tl - sl, sr - tl));
		} else if (sl <= tl && tr <= sr) {
			ans = min(tr - x + min(sr - tr, tr - sl), x - tl + min(tl - sl, sr - tl));
		} else if (tl <= sl && sr <= tr) {
			ans = min(sr - x + min(tr - sr, sr - tl), x - sl + min(sl - tl, tr - sl));
		} else {
			ans = min(tr - x + min(sr - tr, tr - sl), x - sl + min(sl - tl, tr - sl));
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2944
#include<iostream>
using namespace std;
const int N = 20;
const int inf = 0x3f3f3f3f;
int n,m,x,ans;
int t[N];
int c[N];
int a[N][N];
bool check(){
	for(int i=1;i<=m;i++){
		if(t[i]<x){
			return false;
		}
	}
	return true;
}
void dfs(int k,int sum){
	if(check()){
		ans=min(ans,sum);
		return ;
	}
	if(k==n+1){
		return ;
	}
	dfs(k+1,sum);
	for(int i=1;i<=m;i++){
		t[i]+=a[k][i];
	}
	dfs(k+1,sum+c[k]);
	for(int i=1;i<=m;i++){
		t[i]-=a[k][i];
	}
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n>>m>>x;
	for(int i=1;i<=n;i++){
		cin>>c[i];
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
		}
	}
	ans=inf;
	dfs(1,0);
	if(ans==inf){
		ans=-1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3608
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();

    let splited = input.split_whitespace();
    let mut ii : i32 = 0;
    let mut fl : bool = true;
    for a in splited {
        let i : i32 = a.parse().unwrap();
        if ii >= i {
            fl = false;
        }
        ii = i;
    }
    if fl {
        println!("Yes");
    } else {
        println!("No");
    }
}




Measured memory_bytes: 5028