akhauriyash/Code-Regression huggingface dataset:
T = gets.to_i
T.times do
    a, b, c, d = gets.split.map(&:to_i)
    if a < b || b > d
        puts 'No'
    else
        gcd = b.gcd(d)
        rem = a % gcd
        min = (c-rem)/gcd*gcd + gcd + rem
        puts min >= b ? 'Yes' : 'No'
    end
end

Measured memory_bytes: 1788
#include<stdio.h>
int main()
{
	long long int n, a;
	scanf("%lld", &n);
	if (n % 2 == 0) {
		printf("%lld\n", n);
	}
	else {
		a = n * 2;
		printf("%lld", a);
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <stack>
#define pb push_back
#include <functional>
#include <vector>
#include <queue>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define mt(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) a.size()
using namespace std;
ll f[105];
int main()
{
	int n;
	cin>>n;
	f[0]=2;f[1]=1;
	rep(i,2,n+1) f[i]=f[i-1]+f[i-2];
	printf("%lld",f[n]);
    return 0;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
VW = [list(map(int, input().split())) for i in range(N)]
# N番目までの品物からWを超えないように選んだ時の最大価値合計
dp = [[0] * (W+1) for i in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if VW[i][1] > j:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-VW[i][1]]+VW[i][0])

print(dp[N][W])


Measured memory_bytes: 25520
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    Integer count = scan.nextInt();
    Integer legs = scan.nextInt();
    
    int turu;
    int kame;
    kame = (legs-(count*2))/2;
    turu = count-kame;
    int total = 2*turu + 4*kame;
        
    if(turu>=0&&kame>=0&&total==legs){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}



Measured memory_bytes: 35736
#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>

using namespace std;
typedef long long int ll;

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

int main(){
    int n;  cin >> n;
    string s;   cin >> s;

    if(n%2==1){
        cout << "No" << endl;
        return 0;
    }

    string front;
    string back;

    int i=0;
    for(i=0;i<n/2;i++) front+=s[i];
    for(;i<n;i++)   back+=s[i];

    if(front==back) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int n;
double p[10];

int main(){
	while(cin>>n&&n){
		p[0]=1.0;
		rep(i,9)p[i+1]=0.0;
		double ans=0.0;
		rep(i,n){
			double q=0.0;
			rep(j,9)q+=p[j+1]*(1.0-1.0/pow(2.0,j+1));
			ans+=1-q;
			rep(j,9)p[9-j]=p[9-j-1]/pow(2.0,9-j-1);
			p[0]=q;
		}
		printf("%.6f\n",ans);
	}
}

Measured memory_bytes: 908
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#define INF 2e9
#define rep(i,m) for(int i=0;i<m;i++)


using namespace std;

int main()
{
	int N;
	int x, y;
	cin >> N;
	cin >> x >> y;

	for (int i = x; i <= y; i++)
	{
		if (i % N == 0)
		{
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}
	

Measured memory_bytes: 3628
N = int(input())
A = sorted([int(x) for x in input().split()])

def check():
    if N % 2 == 0:
        for i in range(1,N)[::2]:
            if A[i-1] != i or A[i] != i:    return 0
        return int(2**(N//2)) % int(1e9+7)
    else:
        if A[0] != 0:   return 0
        else:
            for i in range(2,N)[::2]:
                if A[i-1] != i or A[i] != i:    return 0
            return int(2**((N-1)//2)) % int(1e9+7)
        
print(check())

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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int i##_to_ = (t), i = (f); i <= i##_to_; i++)
#define uptil(f, t, i)   for(int i##_to_ = (t), i = (f); i <  i##_to_; i++)
#define downto(f, t, i)  for(int i##_to_ = (t), i = (f); i >= i##_to_; i--)
#define downtil(f, t, i) for(int i##_to_ = (t), i = (f); i >  i##_to_; i--)
typedef long double LD;
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
#define debug true
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 2
#define _LIBCPP_DEBUG2 2
#define ln << endl
#else
#define debug false
#define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '



signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

    int N, M;
    map<int, int> D, T;
    scanf("%d", &N);
    times(N, i) { int d; scanf("%d", &d); ++D[d]; }
    scanf("%d", &M);
    times(M, i) { int t; scanf("%d", &t); ++T[t]; }
    bool y = true;
    for(auto& p: T) {
        if(D[p.first] < p.second) y = false;
    }
    cout << (y ? "YES" : "NO") ln;

    return 0;
}


Measured memory_bytes: 19072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[200005];
int main(){
    int n,k,y;
    scanf("%d%d",&n,&k);
    for (int i=1;i<=n;i++)scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    ll s=0;
    for (int i=1;i<=n-k;i++)s+=a[i];
    printf("%lld\n",s);
    return 0;
}

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

const long long INF = 1e12;

long long dpa[100001];
long long dpex[100001];

int main()
{
	int n, W;
	cin >> n >> W;
	
	vector < long long > w(n + 1), u(n + 1);
	
	for(int i = 1; i <= n; i++)
	{
		cin >> w[i] >> u[i];
	}
	
	for(int j = 1; j <= 100000; j++)
	{
		dpex[j] = INF;
		dpa[j] = INF;
	}
	
	long long res = 0;
	
	for(int i = 1; i <= n; i++)
	{
		for(long long j = 0; j <= 100000; j++)
		{
			if(dpex[j] + w[i] <= W)
			{
				dpa[j + u[i]] = min(dpa[j + u[i]], dpex[j] + w[i]);
			}
			
			if(dpa[j] <= W)
			{
				res = max(res, j);
			}
			
			dpex[j] = dpa[j];
		}
	}
	
	cout << res;
	
	return 0;
}

Measured memory_bytes: 5212
n=int(input())

a,b,c=0,0,0

for i in range(n):
  x,y,z=map(int,input().split())
  dist=abs(b-y)+abs(c-z)
  if dist>x-a or (dist-(x-a))%2==1:
    print('No')
    exit()
    
  else:
    a,b,c=x,y,z
    continue
    
print('Yes')

Measured memory_bytes: 80016
#include<stdio.h>

int main(void){
    int a,b;
    scanf("%d%d", &a, &b); /*fはformatのf*/
    if(a*b%2 == 0){
        printf("Even");
    }else{
        printf("Odd");
    }
    return 0;
}

/*main()は必ず実行されるのでmain()なんて外で書く必要はない*/

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
    string s;
    int q;
    cin >> s >> q;
    deque<char> d;
    for (char c : s) d.push_back(c);
    bitset<1> state = 1;//1なら元の順、0なら逆順
    rep(i, q) {
        int t; cin >> t;
        if (t == 1) state.flip();
        else {
            int f; char c; cin >> f >> c;
            if (state == 1) {
                if (f == 1) d.push_front(c);
                else d.push_back(c);
            } else {
                if (f == 1) d.push_back(c);
                else d.push_front(c);
            }
        }
    }

    if (state == 1) {
        for (char c : d) cout << c;
        cout << endl;
    }
    else {
        reverse(all(d));
        for (char c : d) cout << c;
        cout << endl;
    }

    return 0;
}

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

int main(void) {
    int x, y;
    long long ans = 1145141919810931;
    cin >> x >> y;
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            if (i)
                x *= -1;
            if (j)
                y *= -1;
            if (x <= y)
                ans = min((long long)(y - x + i + j), ans);
            if (i)
                x *= -1;
            if (j)
                y *= -1;
        }
    }
    cout << ans << endl;
}


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

void solve(long long N, long long M) { cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl; }

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    solve(N, M);
    return 0;
}


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

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

int w, h;
char map[22][22];
/*
	0:X
	1:Ç
	2:X^[g
	3:S[
*/

int result;

//fobOp
void printMap(int x, int y) {
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++) {
			if (i == y && j == x) cout << '*';
			else cout << map[i][j];
		}
		cout << endl;
	}
}

//ÄAÌTõ
//XebvC»ÝÌóµCßÌoHÍmapÅ¨
void solve(int step, int x, int y) {
	if (step == 11) return;//10ñèIíÁ½çI¹
	for (int i = 0; i < 4; i++) {
		if (map[y + dy[i]][x + dx[i]] == '1') continue;//Ì}XÉáQ¨ª ÁÄÍ_
		for (int nextX = x + dx[i], nextY = y + dy[i];; nextX += dx[i], nextY += dy[i]) {
			//mapO»è
			if (nextX < 0 || w <= nextX || nextY < 0 || h <= nextY) goto NEXTDIRECTION;
			switch (map[nextY][nextX]) {
				case '1'://áQ¨
					map[nextY][nextX] = '0';//ÔÂ©Á½áQ¨ÍÁ¦é
					//printMap(nextX - dx[i], nextY - dy[i]);
					solve(step + 1, nextX - dx[i], nextY - dy[i]);//êàOªÌÄAªnÜéê
					map[nextY][nextX] = '1';//³ÉßµÄÌûüÖ
					goto NEXTDIRECTION;
				case '3'://S[
					result = min(result, step);
					return;
			}
		}
NEXTDIRECTION:
		continue;
	}
}

int main() {
	while (1) {
		cin >> w >> h;
		if (w == 0 && h == 0) break;
		result = 11;
		int startX, startY;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> map[i][j];
				if (map[i][j] == '2') {
					startX = j;
					startY = i;
				}
			}
		}
		solve(1, startX, startY);
		if (result == 11) cout << -1 << endl;
		else cout << result << endl;
	}
	return 0;
}

Measured memory_bytes: 868
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int cnt = 0;
		if(N.substring(0, 1).equals("2")) cnt++;
		if(N.substring(1, 2).equals("2")) cnt++;
		if(N.substring(2, 3).equals("2")) cnt++;
		if(N.substring(3, 4).equals("2")) cnt++;
		System.out.println(cnt);
	}
}


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

using namespace std;

int main() {
  int x, y;
  scanf("%d %d", &x, &y);
  int ans;
  if (y > 0) {
    if (x <= y*(-1)) {
      ans = -x-y+1;
    } else if (x < 0) {
      ans = x+y+1;
    } else if (x <= y) {
      ans = y-x;
    } else {
      ans = x-y+2;
    }
  } else if (y == 0) {
    if (x > 0) {
      ans = 1+x;
    } else {
      ans = x*(-1);
    }
  } else {
    if (x <= y) {
      ans = y-x;
    } else if (x < 0) {
      ans = x-y+2;
    } else if (x < y*(-1)) {
      ans = -x-y+1;
    } else {
      ans = x+y+1;
    }
  }
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string.h>
using namespace std;
typedef long long int llint;
int main() {
	int n;
	cin >> n;
	if (n < 10) {
		cout << "ABC00" << n << endl;
	}
	else if (n < 100) {
		cout << "ABC0" << n << endl;
	}
	else {
		cout << "ABC" << n << endl;
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int k = 0;
    rep(i, n) if(p[i] != i + 1) k++;
    if(k <= 2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  string w; cin >> w;
  vll cnum(26, 0);
  REP(i, w.size()) cnum[w[i]-'a']++;
  REP(i, 26) if (cnum[i] % 2 == 1) {cout << "No" << endl; return 0;}
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a=0,b=0;
	scanf("%d %d",&a,&b);

	if(a-b>=a+b && a-b>=a*b)
		printf("%d\n",a-b);
	else if(a*b>=a+b && a*b>=a-b)
		printf("%d\n",a*b);
	else if(a+b>=a-b && a+b>=a*b)
		printf("%d\n",a+b);
		
	return 0;
}

Measured memory_bytes: 128
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
import java.util.LinkedList;

public class Main {
	public class pair implements Comparable<pair> {
		int wt;
		int val;
		double rat;

		pair(int a, int v) {
			wt = a;
			val = v;
			rat = v / wt;
		}

		@Override
		public int compareTo(pair o) {
			// TODO Auto-generated method stub
			return (int) (this.rat - o.rat);
		}

	}

	public static void main(String[] args) throws IOException {
		Scanner scn = new Scanner(System.in);
		String s = scn.next();
		String t = scn.next();
		int dp[][] = new int[s.length() + 1][t.length() + 1];
		for (int i = 0; i <= s.length(); i++) {
			for (int j = 0; j <= t.length(); j++) {
				if (j == 0 || i == 0) {

				} else {
					if (s.charAt(i - 1) == t.charAt(j - 1)) {
						dp[i][j] = dp[i - 1][j - 1] + 1;
					}
					dp[i][j] = Math.max(dp[i][j], Math.max(dp[i][j - 1], dp[i - 1][j]));
				}
			}

		}
		StringBuilder sb = new StringBuilder();
		int i = s.length();
		int j = t.length();
		while (i > 0 && j > 0) {
			if (s.charAt(i - 1) == t.charAt(j - 1)) {
				sb.append(s.charAt(i-1));
				i--;
				j--;
			} else if (dp[i][j] == dp[i - 1][j]) {
				i--;
			} else {
				j--;
			}
		}
		System.out.println(sb.reverse());

	}

}

Measured memory_bytes: 79952
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=179;i++)
	
	{
		if((i*360)%n==0)
		{
			cout<<(i*360)/n;
			break;
		}
	}
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n,a,b ;
	cin >> n >> a >> b ;
	vll x(n) ;
	for(auto &i:x) cin >> i ;
	ll ans = 0 ;
	for(int i=1;i<n;i++){
		ans += min((x.at(i)-x.at(i-1))*a,b) ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 1024
n = int(input())
a_list = list(map(int,input().split(" ")))
mul = 1
if 0 in a_list:
    print(0)
else:
    for i in range(n):
        if mul > 10**18:
            break
        else:
            mul *= a_list[i]
    if mul <= 10**18:
        print(mul)
    else:
        print(-1)

Measured memory_bytes: 21652
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 100010
const int mod=998244353;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,d[N],cnt[N],ans;
int qpow(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}
	return ans;
}
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		d[i]=read();
		++cnt[d[i]];
	}
	if(d[1]||cnt[0]^1)return !printf("0\n");
	ans=1;
	for(int i=1;i<n;++i){
		ans=1LL*ans*qpow(cnt[i-1],cnt[i])%mod;
	}
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

int n;
int a[100];

int main()
{
	IOS;
	cin >> n;
	int p = 0;
	for (int i = 1; i <= n; i++) {
		int e;
		cin >> e;
		if (e != i) p++;
	}
	(p <= 2) ? cout << "YES\n" : cout << "NO\n";
	return 0;
}



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

int main(void)
{
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	int s=(a+b+c)/2;
	
	int ans = sqrt(s*(s-a)*(s-b)*(s-c));
	
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 128
#! /usr/bin/python
# -*- coding: utf-8 -*-

(n, m, a) = map(int, raw_input().split())
while n!=0:
    ami = []
    for i in range(m):
        ami.append(map(int, raw_input().split()))
    ami.sort()
    ami.reverse()

    for i in range(m):
        if ami[i][1] == a:
            a = ami[i][2]
        elif ami[i][2] == a:
            a = ami[i][1]

    print a
    (n, m, a) = map(int, raw_input().split())

Measured memory_bytes: 4316
#include <iostream>
using namespace std;
int main(){
  string s;cin>>s;
  int i = 0;
  long long n;cin>>n;
  for(; s[i] == '1'; i++){
    if(i+1 == n){
      cout << 1 << endl;
      return 0;
    }
  }
  cout << s[i] << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<queue>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<stack> 
#include<bitset>
#include<iterator>
#include<numeric>
using namespace std;
typedef long long ll;

int E,V;
int G[11][11];
int d[11];

void floyd(){
	for(int k = 0 ; k < V ; k ++){
		for(int i = 0 ; i < V ; i ++){
			for(int j = 0 ; j < V ; j ++){
				G[i][j] = min(G[i][j] , G[i][k]+G[k][j]);
			}
		}
	}
}

int main(){
	while(scanf("%d",&E) != EOF && E){
		int u,v,w;
		V = 0;
		memset(G,0x3f3f3f3f,sizeof(G));
		for(int i = 0 ; i < E ; i ++){
			scanf("%d%d%d",&u,&v,&w);
			G[u][v] = w;
			G[v][u] = w;
			// ?点
		 	V = max(V,max(u,v)+1);
		}
		for(int i = 0 ; i < V ; i ++) G[i][i] = 0;
		floyd();
		
		memset(d,0,sizeof(d));		
		int index = 0;
		int ans = 0x3f3f3f3f;
		for(int i = 0 ; i < V ; i ++){
			for(int j = 0 ; j < V ; j ++){
				d[i] += G[i][j];	
			}
			if(ans > d[i]){
				index = i;
				ans = d[i];
			}
		}
		printf("%d %d\n",index,ans);
		
	}	
	return 0;
}

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

int main(){

  string S;
  cin>>S;

  int t=0;
  int i;

  for(i=0;i<=3;i++){

    if(S[i]=='+'){
      t++;
    }
    else{
      t--;
    }
  }

  cout<<t<<endl;

  return 0;
}

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

int main() {
	// your code goes here
	string s;
	int ca =0,cb=0;
	getline (cin,s);
	for(int i=0;i<3;i++){
	    if(s[i]=='A')ca++;
	    else if(s[i]=='B')cb++;
	}
	if(ca*cb)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
use std::collections::HashMap;

fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn is_ok_even(n: i32, vec: Vec<i32>) -> bool {
    let mut cnt_hash: HashMap<i32, i32> = HashMap::new();

    for num in vec {
        if cnt_hash.contains_key(&num) {
            let old = *cnt_hash.get(&num).unwrap();
            cnt_hash.insert(num, old + 1);
        } else {
            cnt_hash.insert(num, 1);
        }
    }

    for num in (1..n).filter(|n| n % 2 == 1) {
        if !cnt_hash.contains_key(&num) {
            return false;
        }

        let cnt = *cnt_hash.get(&num).unwrap();
        if cnt != 2 {
            return false;
        }
    }

    return true;
}

fn is_ok_odd(n: i32, vec: Vec<i32>) -> bool {
    let mut cnt_hash: HashMap<i32, i32> = HashMap::new();

    for num in vec {
        if cnt_hash.contains_key(&num) {
            let old = *cnt_hash.get(&num).unwrap();
            cnt_hash.insert(num, old + 1);
        } else {
            cnt_hash.insert(num, 1);
        }
    }

    for num in (0..n).filter(|n| n % 2 == 0) {
        if !cnt_hash.contains_key(&num) {
            return false;
        }

        let cnt = *cnt_hash.get(&num).unwrap();
        if num == 0 && cnt != 1 {
            return false;
        }
        if num > 0 && cnt != 2 {
            return false;
        }
    }

    return true;
}

fn calc_even(n: i32) -> i32 {
    let mut ans: i32 = 1;
    let cnt: i32 = n / 2;
    for i in 0..cnt {
        ans = (ans * 2) % 1000000007;
    }

    return ans;
}

fn calc_odd(n: i32) -> i32 {
    let mut ans: i32 = 1;
    let cnt: i32 = (n - 1) / 2;
    for i in 0..cnt {
        ans = (ans * 2) % 1000000007;
    }

    return ans;
}

fn main() {
    let n: i32 = getline().trim().parse().unwrap();

    let s = getline();
    let vec: Vec<i32> = s.trim().split(' ').map(|s| s.parse().unwrap()).collect();


    let ans: i32 = if n % 2 == 0 {
        if is_ok_even(n, vec) { calc_even(n) } else { 0 }
    } else {
        if is_ok_odd(n, vec) { calc_odd(n) } else { 0 }
    };
    println!("{}", ans);
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll D;
    cin >> D;
    vector<ll> vec(26);
    rep(i,26){
        cin >> vec[i];
    }
    vector<vector<ll> > happiness(D, vector<ll>(26));
    rep(i,D){
        rep(j,26){
            cin >> happiness[i][j];
        }
    }
    vector<ll> sad(26,0);
    rep(j,26){
        sad[j] += vec[j];
    }
    ll normal_sadistic_per_day = 0;
    rep(i,26){
        normal_sadistic_per_day += vec[i];
    }
    rep(i,363){
        ll sadistic_per_day = 0;
        rep(j,26){
            sadistic_per_day += sad[j];
        }
        ll minus_point = 0;
        ll t = 0;
        minus_point -= sadistic_per_day;
        ll max_point = minus_point;
        rep(j,26){
            if (max_point <= minus_point + sad[j] + happiness[i][j]){
                t = j + 1;
                max_point = minus_point + sad[j] + happiness[i][j];
            }
        }
        rep(j,26){
            sad[j] += vec[j];
        }
        sad[t - 1] = 0;
        cout << t << endl;
    }
    rep(i,1){
        ll sadistic_per_day = 0;
        rep(j,26){
            sadistic_per_day += sad[j];
        }
        ll minus_point = 0;
        ll t1 = 0;
        ll t2 = 0;
        minus_point -= sadistic_per_day;
        ll max_point = minus_point;
        ll prev_minus_point = minus_point;
        ll prev_sadistic_per_day = sadistic_per_day;
        rep(j,26){
            minus_point += sad[j] + happiness[363 + i][j];
            sadistic_per_day += normal_sadistic_per_day;
            sadistic_per_day -= sad[j];
            minus_point -= sadistic_per_day;
            rep(k,26){
                if (max_point <= minus_point + sad[k] + happiness[364 + i][j]){
                    t1 = j + 1;
                    t2 = k + 1;
                    max_point = minus_point + sad[k] + happiness[364 + i][j];
                }
            }
            minus_point = prev_minus_point;
            sadistic_per_day = prev_sadistic_per_day;
        }
        rep(j,26){
            sad[j] += vec[j];
        }
        sad[t1 - 1] = 0;
        rep(j,26){
            sad[j] += vec[j];
        }
        sad[t2 - 1] = 0;
        cout << t1 << endl;
        cout << t2 << endl;
    }
}


Measured memory_bytes: 3744
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
inline long long f (long long x) { return ((x&1) ? x - 1 : x); }

int main() {
    long long a, b, c, d, x;
    cin >> a >> b >> x >> c >> d >> x >> x;
    auto g = [&] (long long k) -> long long {
        return (f(a-k) + f(c-k) + f(d-k) + 3*k + b);
    };
    long long ans = g(0);
    if (a and c and d) ans = max(ans, g(1));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define FNAME ""
 
#include <iostream>
#include <cstdio>
#include <ctime>
#include <cassert>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <string>
 
#define hash padjf9srpi
#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forn(i, n) for (int i = 0; i < (n); i++)
#define fornr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define forab(i, a, b) for (int i = (a); i < (b); i++)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
 
#ifdef _WIN32
    #define I64 "%I64d"
#else
    #define I64 "%lld"
#endif
 
using namespace std;
 
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;                                                                                                                                                                                      
typedef vector <int> vi;
 
template <class T> T sqr(const T &a) {return a * a;}
 
int g[10][10], p[10];
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
    	int s, f;
    	cin >> s >> f;
    	s--,f--;
    	g[s][f] = g[f][s] = 1;
    }
    for (int i = 0; i < n; i++) p[i] = i;
    int ans =0;
    do {
    	bool ok = 1;
    	for (int i = 0; i < n - 1; i++) {
    		if (!g[p[i]][p[i + 1]]) ok = 0;
    	}
    	if (p[0] != 0) ok = 0;
    	ans += ok;
    } while (next_permutation(p, p + n));
    cout << ans << endl;
 
    
    
    return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

i64 power(i64 x, i64 n, i64 M) {
  if (!n) return 1;
  if (n % 2 == 0) {
    i64 t = power(x, n / 2, M);
    return t * t % M;
  }
  return x * power(x, n - 1, M) % M;
}

i64 x;
i64 maxpower(i64 x) {
  if (x == 1) return 1;
  vector<i64> vec;
  for (i64 b = 1; b <= x; ++b) {
    for (i64 p = 2; p <= x; ++p) {
      i64 res = power(b, p, MOD);
      if (res <= x) vec.push_back(res);
    }
  }
  sort(all(vec), greater<i64>());
  return vec[0];
}

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

  cin >> x;
  cout << maxpower(x) << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int height[10];
	int i, j;
	int temp;
	int index;
	for (i = 0; i < 10; i++) {
		scanf("%d", &height[i]);
	}
	for (i = 0; i < 3; i++) {
		temp = 0;
		for (j = 0; j < 10; j++) {
			if (height[j] > temp) {
				temp = height[j];
				index = j;
			}
		}
		printf("%d\n", temp);
		height[index] = 0;
	}
	return 0;
}


Measured memory_bytes: 600
#pragma GCC optimize ("O3")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define dbg1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define dbg2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define dbg3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
lld n,w;
lld arr[150][2];
lld dp[100005];
// lld what(int n, int w)
// {
// 	if(n==0||w==0)
// 		return 0ll;
// 	if(dp[n][w]!=-1)
// 		return dp[n][w];
// 	int we = arr[n-1][0];
// 	int ve = arr[n-1][1];
// 	if(w-we>=0)
// 		return(dp[n][w]=max(what(n-1,w),what(n-1,w-we)+ve));
// 	return(dp[n][w]=what(n-1,w));
// }
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> w;
	// memset(dp,-1,sizeof(dp));
	// fill(dp,dp+n+w, -1); 
	// for(int i=0;i<150;i++)
	// {
	// 	for(int j=0;j<100005;j++)
	// 	{
	// 		dp[i][j]=-1;
	// 	}
	// }
	// lld dp[n+1][w+1];
	// for(int i=0;i<w+1;i++)
	// {
	// 	dp[0][i]=0;
	// }
	// for(int i=0;i<n+1;i++)
	// {
	// 	dp[i][0]=0;
	// }
	for(int i=0;i<n;i++)
	{
		cin >> arr[i][0] >> arr[i][1] ;
	}
	for(int i=1;i<=n;i++)
	{
		lld we = arr[i-1][0];
		lld va = arr[i-1][1];
		for(int j=w;j>=0;j--)
		{
			if(j-we>=0)
			{
				dp[j]=max(dp[j],dp[j-we]+va);
			}
		}
	}
	lld ans=-1;
	// for(int i=0;i<=w;i++)
	// {
	// 	what(n,i);
	// }
	for(int i=0;i<=w;i++)
	{
		ans=max(ans,dp[i]);
	}
	cout << ans;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template<typename T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    int n, q;
    cin >> n >> q;
    vector<ll> v(n);
    Tree<pair<ll, int>> S;
    for (int i = 0; i < n; ++i) {
        S.insert({0, i});
    }
    while(q--){
        int t;
        scanf("%d", &t);
        if(t == 0){
            int a, b;
            scanf("%d %d", &a, &b); a--;
            S.erase(S.find({v[a], a}));
            v[a] -= b;
            S.insert({v[a], a});
        }else {
            int a;
            scanf("%d", &a); a--;
            auto res = S.find_by_order(a);
            printf("%d %lld\n", res->second+1, -res->first);
        }
    }
    return 0;
}


Measured memory_bytes: 9956
#include<iostream>
typedef long long ll;

using namespace std;

int main()
{
    ll n,i,ans=0;
    cin>>n;
    ll a[n];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(i=1; i<n; i++)
    {
        if(a[i-1]>a[i])
        {
            ans=ans+a[i-1]-a[i];
            a[i]=a[i]+(a[i-1]-a[i]);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4728
n, k = map(int, input().split())
i = 0
a = list()
d = 0
while i<k:
    d += int(input())
    a += (map(int, input().split()))
    i += 1
i=0

b = [0]*n
while i<d:
    b[a[i]-1]=1
    i+=1

i=0
ans = 0
while i<n:
    if b[i] ==0:
        ans += 1
    i+=1

print(ans)


Measured memory_bytes: 9220
# -*- coding: utf-8 -*-
n = int(input())
s = list(input())

alphabet = {c:i for i, c in enumerate(list("ABCDEFGHIJKLMNOPQRSTUVWXYZ"))}
ialphabet = {i:c for i, c in enumerate(list("ABCDEFGHIJKLMNOPQRSTUVWXYZ"))}
rst = ''

for c in s:
    idx = alphabet[c]
    new_idx = (idx + n) % 26
    rst += ialphabet[new_idx]

print(rst)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define F first
#define S second
//cout<<fixed<<setprecision(11);
const string nl="\n";
const ll MOD=1000000007;
const ll ARR_MAX = 1e5+1;

void solve(){
    int n;cin>>n;
    ll hpp[n][3];
    ll dp[n+1][3]; //dp[i][j]=maximum points of happiness after i-1 days if jth activity is done on i-1 day.
    for(int i=0;i<n;i++){
    	for(int j=0;j<3;j++){
    		cin>>hpp[i][j];
    	}
    }
    dp[0][0]=0;dp[0][1]=0;dp[0][2]=0;
    for(int i=0;i<n;i++){
    	for(int j=0;j<3;j++){
    		dp[i+1][j] = max(dp[i][(j+1)%3],dp[i][(j+2)%3])+hpp[i][j];
    	}
    }
    ll mx=0;
    for(int i=0;i<3;i++){
    	mx=max(mx,dp[n][i]);
    }
    cout<<mx<<nl;
}

int main(){
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
using namespace std;
typedef long long ll;
ll dp[100100][4];
const ll mod = 1000000007;
string s;
int main(void){
    // Your code here!
    cin >> s;
    ll len = s.length();
    dp[0][0] = 1;
    for (ll i = 0; i < len; i++) {
        if (s[i] == 'A' || s[i] == '?') (dp[i + 1][1] += dp[i][0]) %= mod;
        if (s[i] == 'B' || s[i] == '?') (dp[i + 1][2] += dp[i][1]) %= mod;
        if (s[i] == 'C' || s[i] == '?') (dp[i + 1][3] += dp[i][2]) %= mod;
        for (ll j = 0; j < 4; j++) {
            (dp[i + 1][j] += dp[i][j] * (s[i] == '?' ? 3 : 1)) %= mod;
        }
    }
    cout << dp[len][3] << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int num;
        cin >> num;
        if (num % 2 == 0 && !(num % 3 == 0 || num % 5 == 0))
        {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;

  int C[VMAX+1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for (i=0;i<=VMAX;i++) C[i] = 0;

  for (i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }

  for (i=1;i<=VMAX;i++) C[i] = C[i]+C[i - 1];

  for (j=1;j<=n;j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for (i=1;i<=n;i++){
    if ( i > 1 ) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 8464
n = int(input())
a = [int(i) for i in input().split()]

count = 0
while True:
    flg = True
    for i in range(n):
        if a[i] % 2 == 0:
            count+=1
            a[i] = a[i] / 2
            flg=False
    
    if flg:
        print(count)
        break

Measured memory_bytes: 4148
#include<iostream>

using namespace std;

int a[100], n;

void insertionSort(int a[], int n)
{
	for (int i = 1; i < n; i++)
	{
		int v = a[i];
		int j = i - 1;
		while (j >= 0 && a[j] > v)
		{
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		for (int j = 0; j < n; j++)
		{
			if (j == n - 1) { cout << a[j] << endl; }
			else { cout << a[j] << " "; }
		}
	}
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n - 1; i++)
	{
		cout << a[i] << " ";
	}
	cout << a[n - 1] << endl;
	insertionSort(a, n);
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    int X, Y, Z;
    cin >> X;
    cin >> Y;
    cin >> Z;
    int cnt = 0;
    for(int i = 1; i < 10e5; i++) {
        if (X >= Y * i + Z * (i + 1))
            cnt++;
        else
            break;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>

#define mod 1000000007
#define MP make_pair
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;

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

int main(){
	char in_map[1002][1002];
	bool visited[1002][1002]={};
	int H,W;
	queue <pair<int,int>> q;

	int ans=0;

	cin>>H>>W;
	for(int i=1;i<H+1;i++)for(int j=1;j<W+1;j++){
		cin>>in_map[i][j];
		if(in_map[i][j]=='#'){
			visited[i][j]=true;
			q.push(MP(i,j));
		}
	}

	q.push(MP(-1,-1));
	
	while(!q.empty()){
		int now[2]={q.front().first,q.front().second};
		q.pop();
		if(now[0]==-1 && now[1]==-1){
			if(!q.empty()){
				ans++;
				q.push(MP(-1,-1));
			}
		}
		else{
			rep(i,4){
				if(!visited[now[0]+dx[i]][now[1]+dy[i]] && (now[0]+dx[i])>=1 && (now[0]+dx[i])<=H && (now[1]+dy[i])>=1 && (now[1]+dy[i])<=W ){
					q.push(MP(now[0]+dx[i],now[1]+dy[i]));
					visited[now[0]+dx[i]][now[1]+dy[i]]=true;
				}
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 10384
#include<stdio.h>
 
int main()
{
  int t[4][3][10]={0};
  int b,f,r,v,i,j,k,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d%d%d%d",&b,&f,&r,&v);
t[b-1][f-1][r-1]=t[b-1][f-1][r-1]+v;

      
    
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	printf(" %d",t[i][j][k]);
      }
      printf("\n");
    }
    if(i!=3)printf("####################\n");
  }
  return 0;
}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
#define ll long long
#define _for(i,j,k) for(int i=j;i<k;i++)
#define endl  '\n'
#define inf 1<<29-1
#define ll long long
#define ld long double
#define ull unsigned long long
#define maxn 110
int dp[maxn][maxn];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int num;
    cin>>num;
    for (int k = 0; k <=9 ; ++k) {
        dp[1][k]=1;
    }
    for (int i = 2; i <=10 ; ++i) {
        for (int j = 0; j <=9 ; ++j) {
            dp[i][j]=dp[i-1][j]+dp[i-1][j-1]+dp[i-1][j+1];
        }
    }
    queue<int> ans;
    int l=0, r = 0,fl=0;
    for (int j = 1; j <=10 ; ++j)
	{
        for (int i = 1; i <=9 ; ++i)
		{
            if(num<=dp[j][i])
			{
                l=j;
                r=i;
                fl=1;
                break;
            }
            num-=dp[j][i];
        }
        if(fl==1)break;
    }
    l--;
    ans.push(r);
    while(l!=0)
	{
        if(num<=dp[l][r-1])
		{
            r--;
            ans.push(r);
        }else{
            num-=dp[l][r-1];
            if(num<=dp[l][r])
			{
                ans.push(r);
            }else
			{
                num-=dp[l][r];
                r++;
                ans.push(r);
            }
        }
        l--;
    }
    while(!ans.empty())
	{
        int now=ans.front();
        cout<<now;
        ans.pop();
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        String answer = (a < b && b < c) ? "Yes" : "No";
        System.out.println(answer);
    }

}


Measured memory_bytes: 26396
#include <iostream>
#include <string>

int main() {
    int n, m[100], j, key;

    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> m[i];
    }

    for (int i = 0; i < n; i++) {
        
        key = m[i];
        j = i - 1;
        while (j >= 0 && m[j] > key) {
            m[j+1] = m[j];
            j--;
        }
        m[j+1] = key;

        for (int k = 0; k < n; k++) {
            if (k == n - 1) {
                std::cout << m[k];
            } else {
                std::cout << m[k] << " ";
            }
            
        }
        std::cout << std::endl;
    }

   
}


Measured memory_bytes: 3104
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  
  for(i=0;i<=VMAX;i++){
    C[i]=0;
  }

  for(j=1;j<=n;j++){
    C[A[j]]++;
  }

  for(i=1;i<=VMAX;i++){
    C[i]=C[i]+C[i-1];
  }

  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i<=n-1){
      printf(" ");
    }else{
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 9584
#include<bits/stdc++.h>
using namespace std;
/*
long long solve(string s){
  long long n=0;
  for(int i=0;i<s.size();i++){
    for(int j=s.size()-1;j>0;j--){
      if(s.at(j)=='W'&&s.at(j-1)=='B'){
        swap(s.at(j),s.at(j-1));
        n++;
      }
    }
  }
  return n;
}
*/
int main(){
  string S;
  cin >> S;
  int64_t ans=0,b=0;
  for(int i=0,l=S.size();i<l;i++){
    if(S.at(i)=='B')
      b++;
    else
      ans+=b;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <vector>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 8e3+17;
string str;
bool can = false;
int a,b;
vector<pair<int,int > > vec;
bool dp[2][2][MAXN*2];
int main(int argc ,char const *argv[])
{
    #ifdef GoodbyeMonkeyKing
    freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
    #endif
    cin>>str;
    cin>>a>>b;
    for (int i = 0; i <= 16000; ++i)
    	dp[0][0][i]=dp[0][1][i]=dp[1][0][i]=dp[1][1][i]=false;
    int k = 0,tmp = 0;
    for (int i = 0; i < str.length(); ++i)
    {
    	if(str[i]=='T')
    	{
    		vec.push_back({tmp,k&1});
    		k++;
    		tmp=0;
    	}
    	else
    		tmp++;
    }
    vec.push_back({tmp,k&1});
    int nx = 0,px = 1,ny = 0,py = 1;
    dp[0][0][8000] = dp[0][1][8000] = 1;
    for (int i = 0; i < vec.size(); ++i)
    {
    	if(vec[i].second)
    	{
    		swap(ny,py);
    		for (int j = 0; j <= 16000; ++j)
    			dp[ny][1][j] = false;
    		for (int j = 0; j <= 16000; ++j)
    		{
    			if(dp[py][1][j])
    			{
    				if(j-vec[i].first>=0)
    					dp[ny][1][j-vec[i].first] = 1;
    				if(j+vec[i].first<=16000)
    					dp[ny][1][j+vec[i].first] = 1;
    			}
    		}
    	}
    	else
    	{
    		swap(nx,px);
    		for (int j = 0; j <= 16000; ++j)
    			dp[nx][0][j] = false;
    		for (int j = 0; j <= 16000; ++j)
    		{
    			if(dp[px][0][j])
    			{
    				if(i>0&&(j-vec[i].first>=0))
    					dp[nx][0][j-vec[i].first] = 1;
    				if(j+vec[i].first<=16000)
    					dp[nx][0][j+vec[i].first] = 1;
    			}
    		}
    	}
    }
    if(dp[nx][0][a+8000]&&dp[ny][1][b+8000])
    	cout<<"Yes"<<endl;
    else
    	cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) for (int i = -1; i < n; i+=2)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

char f(int x) {
  char res;
  if(x==1) res = '+';
  else res = '-';
  return res;
}

int main() {
  string s;
  cin >> s;
  vi a(4);
  REP(i, 4) a[i] = s[i]-'0';
  rep(i, 2) rep(j, 2) rep(k, 2) {
    int tmp = a[0] + i*a[1] + j*a[2] + k*a[3];
    if(tmp!=7) continue;
    string ans;
    ans.push_back(s[0]);
    ans.push_back(f(i));
    ans.push_back(s[1]);
    ans.push_back(f(j));
    ans.push_back(s[2]);
    ans.push_back(f(k));
    ans.push_back(s[3]);
    ans += "=7";
    cout << ans << endl;
    return 0;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
using namespace std; 
#define pb push_back 
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rep2(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define sc(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
ll sum[200005];
const ll mod=2019;
int cnt[2021];
ll ad(ll a,ll b)
{
	return (((a%mod+b%mod)%mod)+mod)%mod;
}
ll ap(ll a,ll b)
{
	return ((a%mod)*(b%mod))%mod;
}
ll ksm(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b%2==1)
		{
			res=ap(res,a);}
			a=ap(a,a);
			b/=2;
		
	}
	return res;
}
int main(int argc, char** argv) {
	
	string s;
	cin>>s;
	int ans=0;
	cnt[0]++;
	rep2(i,s.length()-1,0)
	{
		ll x=s[i]-'0';
		sum[i]=ad(sum[i+1],ap(x,ksm(10,s.length()-i-1)))%2019;
		ans+=cnt[sum[i]];
		cnt[sum[i]]++;
	}
	//cout<<sum[0]<<" "<<sum[5]<<endl;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5324
//ダイクストラ、ワーシャルフロイドとかやる
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define ll long long
ll inf = pow(10, 9);

int d, t, s;
int main(){
    cin >> d >> t >> s;
    if(d <= t * s) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main (void){
    int a,b,i,n;
    for(i = 1; i <= 4; i++){
        scanf("%d%d",&a,&b);
        if(a == 1){
            n = 6000;
        }
        if(a == 2){
            n = 4000;
        }
        if(a == 3){
            n = 3000;
        }
        if(a == 4){
            n = 2000;
        }
        printf("%d\n", b * n);
    }
    return 0;
}

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

const int mod = 1e9 + 7;

int query(int x, int y, vector<int>& pre)
{
  if (x == 0)
    return pre[y];
  return (pre[y] - pre[x-1] + mod) % mod;
}


int main()
{
  int n, K;
  cin >> n >> K;
  vector<int> dp(K + 1, 0);
  vector<int> a(n);
  vector<int> prefix(K + 1);

  for (int i = 0; i < n; ++i)
    cin >> a[i];
  dp[0] = 1;

  for (int i = 1; i <= n; ++i)
  {
    prefix[0] = dp[0];
    for (int j = 1; j <= K; ++j)
      prefix[j] = (prefix[j-1] + dp[j]) % mod;
    for (int k = 0; k <= K; ++k)
    {
      dp[k] = query(max(0, k - a[i-1]), k, prefix);
    }

  }
  cout << dp[K] <<'\n';

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
int main() 
{
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;

    rep(i,tx-sx){
        cout << "R";
    }
    rep(i,ty-sy){
        cout << "U";
    }
    rep(i,tx-sx){
        cout << "L";
    }
    rep(i,ty-sy){
        cout << "D";
    }

    cout << "L";
    rep(i,ty-sy+1){
        cout << "U";
    }
  	rep(i,tx-sx+1){
        cout << "R";
    }
    cout << "D";
    cout << "R";
    rep(i,ty-sy+1){
        cout << "D";
    }
  	rep(i,tx-sx+1){
        cout << "L";
    }
    cout << "U";
}

Measured memory_bytes: 764
function Main(input){
	var xs = input.trim().split(' ').map(v=>parseInt(v,10));
    //console.log(xs);
    if(xs[0]+xs[1] == xs[2]+xs[3]){
    console.log('Balanced');
    }else if(xs[0]+xs[1] > xs[2]+xs[3]){
    console.log('Left');
	}else if(xs[0]+xs[1] < xs[2]+xs[3]){
    console.log('Right');
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7372