akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())
keta = []
for _ in range(M):
    keta.append(tuple(map(int, input().split())))

ans = [-1 for _ in range(N)]
for s, c in keta:
    if ans[s - 1] == -1:
        ans[s - 1] = c
    elif ans[s - 1] == c:
        ans[s - 1] = c
    else:
        print(-1)
        break
else:
    if N == 1 and M == 0:
        print(0)
    else:
        for idx, a in enumerate(ans):
            if a == -1 and idx == 0:
                ans[idx] = 1
            elif a == -1 and idx > 0:
                ans[idx] = 0
        if len(str(int("".join(map(str, ans))))) == N:
            print(int("".join(map(str, ans))))

        else:
            print(-1)


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

/// Constant:
#define         eps         0.000000001
#define         pi          2*acos(0)
#define         P1          1000000007
#define         P2          1000000009

#define         fast        ios_base::sync_with_stdio(false);   cin.tie(NULL);
#define         lli         long long int
#define         PB          push_back
#define         pb          pop_back
#define         mp          make_pair
#define         I           insert
/// Loop:
#define         f1(a,b)     for (int i=a; i<=b; i++)
#define         f2(a,b)     for (int j=a; j<=b; j++)
#define         f-1(a,b)     for (int i=b; i>=a; i--)
#define         f-2(a,b)     for (int j=b; j>=a; j--)
///Print:
#define         pY          cout<<"YES"<<endl;
#define         pN          cout<<"NO"<<endl;
#define         py          cout<<"Yes"<<endl;
#define         pn          cout<<"No"<<endl;

using namespace std;
///ISNNJB

///Global Variable:
int ara[200005],brr[200005];

/// Functions:
//lli bigmod(lli b, lli p, lli m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ lli res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//lli mod_inverse(lli a, lli mod) { return bigmod(a,mod-2,mod); }
//lli LCM(lli a, lli b) { return a*b/ __gcd(a,b); }
//vector<int>divisors[1000005]; void divisor(int n) { for (int i=1; i<=n; i++)    for (int j=i; j<=n; j+=i)   divisors[j].PB(i);}

/**int fx[]={+1,-1,+0,+0};
int fy[]={+0,+0,+1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};*/

int main() {

    /**freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/

    fast;

    lli a,b,c,d,t,k,n,m,x,y,q,ctn=0,l1,l2,total=0,l,r;
    string s;

    cin>>n;
    if (n<=599)
        cout<<8<<endl;
    else if(n<=799)
        cout<<7<<endl;
    else if(n<=999)
        cout<<6<<endl;
    else if(n<=1199)
        cout<<5<<endl;
    else if(n<=1399)
        cout<<4<<endl;
    else if(n<=1599)
        cout<<3<<endl;
    else if(n<=1799)
        cout<<2<<endl;
    else
        cout<<1<<endl;

    return 0;
}


Measured memory_bytes: 3652
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    b = SI()
    if b == 'A':
        ans = 'T'
    elif b == 'T':
        ans = 'A'
    elif b == 'G':
        ans = 'C'
    else:
        ans = 'G'

    return ans

print(main())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime){
    primes = {};
    is_prime = {};
    for(int i=0; i<=N; i++){
        is_prime.push_back(true);
    }

    primes.push_back(2);
    for(int j=4; j<=N; j+=2){
        is_prime[j] = false;
    }

    int i;
    for(i=3; i*i<=N; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=N; j+=i){
            is_prime[j] = false;
        }
    }

    for(; i<=N; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }
}


signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    vector<int> b(n);
    for(int i=0; i<n; i++){
        cin >> b[i];
    }
    vector<int> c(n);
    for(int i=0; i<n; i++){
        cin >> c[i];
    }
    sort(a.begin(), a.end());
    // sort(b.begin(), b.end());
    sort(c.begin(), c.end());


    int ans = 0;
    for(int i=0; i<n; i++){
        auto it1 = lower_bound(a.begin(), a.end(), b[i]);
        auto it2 = upper_bound(c.begin(), c.end(), b[i]);
        int idx1 = distance(a.begin(), it1);
        int idx2 = distance(c.begin(), it2);
        ans += idx1 * (n-idx2);
    }
    cout << ans << endl;

    
    return 0;
}

Measured memory_bytes: 5708
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static void main(String args[]) {
		int X[];
		int N, M;
		
		int Dis[];
		int Skips=0;
		
		Scanner scanner = new Scanner(System.in);
		
		N = scanner.nextInt();
		M = scanner.nextInt();
		
		X = new int[M];
		for(int i=0; i<M; i++) {
			X[i] = scanner.nextInt();
		}
		Arrays.sort(X);
		
			//座標の距離を求めソート
		Dis = new int[M-1];
		for(int i=0; i<M-1; i++) {
			Dis[i] = X[i+1] - X[i];
		}
		Arrays.sort(Dis);
		
		
			/*System.out.println("N:"+N + " M:"+M);
			for(int i=0; i<M; i++) {
			System.out.print(X[i]+" ");
			}System.out.print("\n");*/
		
		
			//駒が多ければ移動無し//
		if(N >= M) {
			System.out.print("0");
			return;
		}
		
			//通らない場所を Dis[] の後ろから(N-1)こ取る//
		for(int i=0; i<N-1; i++) {
			Skips += Dis[M-2-i];
		}
		
			// (X[M] - X[1]) - Skips ... Answer
		System.out.print(X[M-1] - X[0] - Skips);
		
	return;
	}
	
	

}


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

    string s;
    cin>>s;

    for(int i=0;i<s.size();i++){
        char cwk =(char)(s.at(i)+n);
        if(cwk>='A'+26)
            cwk-=26;

        s.at(i)=cwk;
    }

    cout<<s<<endl;

    return 0;
}  




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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	


using namespace std;


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

/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 1e6+100;
const ll inf = 1e12;
const ll mod = 1e9+7;


ll a[MAX],n,k;
bool go(ll x){
	ll ans = 0;
	f(i,1,n+1){	
		ans += max(0LL,a[i]-1)/x;
	}
	return ans <= k;
}
int main(){
	fastio;
	cin >> n >> k;
	f(i,1,n+1) cin >> a[i];
	ll ini = 1,fin = 1e9+1;
	while(ini < fin){
		ll mid = (ini + fin)/2;
		if(go(mid)) fin = mid;
		else ini = mid+1;
	}
	cout << ini << endl;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i;
	cin>>n;
	double sum=0;
	double p[n];
	string dw[n]; 
	for(i=0;i<n;i++){
		cin>>p[i]>>dw[i];
		if(dw[i]=="JPY"){
			sum+=p[i];
		}
		if(dw[i]=="BTC"){
			sum+=p[i]*380000.0;
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int main() {
	int n, T, s = 0;
	cin >> n >> T;
	vector<int> t(n);
	rep(i, 0, n)cin >> t[i];
	rep(i, 0, n - 1) {
		s += min(t[i + 1] - t[i], T);
	}
	printf("%d\n", s + T);
	return 0;
}


Measured memory_bytes: 1024
while True:
    n, x = map(int, input().split())
    ans = 0
    if n == 0 and x == 0:
        break
    for a in range(1, n+1):
        for b in range(a+1, n+1):
            for c in range(b+1, n+1):
                if a + b + c == x:
                    ans += 1
    print(ans)


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

int main() {

  int W, H, N;
  cin >> W >> H >> N;

  vector<int> x(N);
  vector<int> y(N);
  vector<int> a(N);

  int ws = 0;
  int we = 0;
  int hs = 0;
  int he = 0;

  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> a[i];
  }

  for (int i = 0; i < N; i++) {
    if (a[i] == 1) {
      ws = max(ws, x[i]); 
    } else if (a[i] == 2) {
      we = max(we, W - x[i]);
    } else if (a[i] == 3) {
      hs = max(hs, y[i]);
    } else {
      he = max(he, H - y[i]);
    }
  }

  W = W - we - ws;
  H = H - he - hs;

  if (W <= 0 || H <= 0) {
    cout << 0 << endl;
  } else {
    cout << W * H << endl;
  }

}

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

int main() {
    int N;
    std::cin >> N;
    std::string S = std::to_string(N);

    int fx = 0;
    for (size_t i = 0; i < S.size(); ++i) {
        fx += (int)(S[i] - '0');
    }

    if (N % fx == 0) {
        std::cout << "Yes\n";
    } else {
        std::cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define W while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007
#define mp make_pair
  int main()
  {
     FASTIO;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1)
    {
        c=c-b;
        if(c<=0)
        {
            cout<<"Yes";
            break;
        }
         a=a-d;
        if(a<=0)
        {
        cout<<"No";
        break;
        }
    }
     }

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
ll ans = 0LL;
int i_index;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
string board[64];

int main(){
    int x = 2;
    for(cin >> N; N >= x; )x *= 2;
    cout << x / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var xyzk = Console.ReadLine().Split();
        var x = int.Parse(xyzk[0]);
        var y = int.Parse(xyzk[1]);
        var z = int.Parse(xyzk[2]);
        var k = int.Parse(xyzk[3]);

        var A = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        var B = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        var C = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);

        Array.Sort(A, rev);
        Array.Sort(B, rev);
        Array.Sort(C, rev);

        var list = new List<long>();
        for (int a = 0; a < x; a++)
        {
            for (int b = 0; b < y; b++)
            {
                if (k < (a + 1) * (b + 1)) break;
                for (int c = 0; c < z; c++)
                {
                    if (k < (a + 1) * (b + 1) * (c + 1)) break;
                    list.Add(A[a] + B[b] + C[c]);
                }
            }
        }

        list.Sort(rev);
        for (int i = 0; i < k; i++)
        {
            Console.WriteLine(list[i]);
        }
    }

    static int rev(long x, long y)
    {
        return y.CompareTo(x);
    }
}


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

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

int binarySearch(int *t,int k,int n)
{
    int l=0,r=n,m;
    while(l<r){
        m=(l+r)/2;
        if(t[m]==k)return m;
        else if(k<t[m])r=m;
        else l=m+1;
    }
}

int main(void)
{
    int n,x[200000],t[200000],m,i;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
        t[i]=x[i];
    }
    qsort(t,n,sizeof(int),q);
    for(i=0;i<n;i++){
        m=binarySearch(t,x[i],n);
        if(n/2>m)printf("%d\n",t[n/2]);
        else printf("%d\n",t[(n-1)/2]);
    }
    return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000;
const int MOD = (int)1e9 + 7;
template <class T>
inline T in()
{
    T x;
    cin >> x;
    return x;
}

signed main()
{
    string s = in<string>();
    string t = in<string>();
    map<char, char> ms;
    map<char, char> mt;
    bool flag = true;
    for (int i = 0; i < s.size(); i++)
    {
        if (!ms[s[i]])
            ms[s[i]] = t[i];
        if (!mt[t[i]])
            mt[t[i]] = s[i];
        if (ms[s[i]] != t[i])
        {
            flag = false;
            break;
        }
        if (mt[t[i]] != s[i])
        {
            flag = false;
            break;
        }
    }
    cout << (flag ? "Yes" : "No") << "\n";   
}

Measured memory_bytes: 776
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

const int NONE = -1;

int select( vector<int> &hands, const int lower ) {
  for ( const int hand : hands ) {
	if ( lower < hand ) {
	  auto it = remove( hands.begin(), hands.end(), hand );
	  hands.erase( it );
	  return hand;
	}
  }
  return NONE;
}

void tostring( vector<int> hands ) {
  cerr << "[";
  for ( const int hand : hands ) {
	cerr << hand << ",";
  }
  cerr << "]" << endl;
}

int main() {
  while( true ) {
	int n;
	cin >> n;
	if ( n == 0 ) break;

	vector<int> taro( n );
	vector<int> hana( n );
	
	for ( int i = 0; i < n; i++ ) {
	  cin >> taro[ i ];
	}
	int index = 0;
	for ( int i = 1; i <= 2 * n; i++ ) {
	  if ( find( taro.begin(), taro.end(), i ) == taro.end() ) {
		hana[ index++ ] = i;
	  }
	}

	sort( taro.begin(), taro.end() );
	sort( hana.begin(), hana.end() );

	bool isTaro = true;
	const int INIT_CARD = -1;
	int card = INIT_CARD;
	while ( !taro.empty() && !hana.empty() ) {
	  if ( isTaro ) {
		const int selected = select( taro, card );
		if ( selected == NONE ) {
		  card = INIT_CARD;
		} else {
		  card = selected;
		}
		isTaro = !isTaro;
	  } else {
		const int selected = select( hana, card );
		if ( selected == NONE ) {
		  card = INIT_CARD;
		} else {
		  card = selected;
		}
		isTaro = !isTaro;
	  }	  
	}
	cout << hana.size() << endl;
	cout << taro.size() << endl;
  }
  return 0;
}

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

string s;
int a[4];

int expr(string &s,int &p){
  //cout<<s<<":"<<p<<endl;
  if(isalpha(s[p])){
    return a[s[p++]-'a'];
  }
  assert(s[p]=='[');
  p++;
  char op=s[p++];
  int x=expr(s,p);
  int y=expr(s,p);
  assert(s[p]==']');
  p++;
  if(op=='+') return x|y;
  if(op=='*') return x&y;
  if(op=='^') return x^y;
  assert(0);
}


signed main(){
  while(cin>>s,s!="."){
    string x;
    cin>>x;
    //cout<<s<<":"<<x<<endl;
    int cnt[16]={};
    for(a[0]=0;a[0]<10;a[0]++){
      for(a[1]=0;a[1]<10;a[1]++){
	for(a[2]=0;a[2]<10;a[2]++){
	  for(a[3]=0;a[3]<10;a[3]++){
	    int p=0;
	    cnt[expr(s,p)]++;
	  }
	}
      }
    }
    for(int i=0;i<4;i++) a[i]=x[i]-'0';
    int p=0;
    int k=expr(s,p);
    cout<<k<<" "<<cnt[k]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  N = 1e6 + 5;

int n,d;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>d;
	int cnt=0;
	for(int i=1;i<=n;i++){
		int x,y;
		cin>>x>>y;
		ll ans=(1ll*x*x+1ll*y*y);
		if(ans<=1ll*d*d) cnt++;
	}
	cout<<cnt<<'\n';
	return 0;
}

Measured memory_bytes: 3644
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x[] = new int[b];
        for (int i=0;i<a;i++){
            int c = sc.nextInt();
            for (int j=0;j<c;j++){
                int d = sc.nextInt();
                x[d-1]=x[d-1]+1;
                //System.out.println("i="+i + ",j="+j + ","+d);
                
            }
            //System.out.println("--");
        }
        int ret = 0;
        for (int k=0;k<b;k++){
            if (a==x[k]) ret=ret+1;
            //System.out.println(k+1 + ":" + a +"=" + x[k]);
        }
        System.out.println(ret);

    }
}

Measured memory_bytes: 23764
#include<iostream>
using namespace std;
struct point{int x,y;};
int main(){
	while(1){
		int n; cin >>n;
		if(n==0)break;
		point p[21];
		point now;
		now.x=10;
		now.y=10;
		int v[21]={};
		int cnt=0;
		for(int i=0;i<n;i++){
			int x,y;
			cin >> x >> y;
			p[i].x=x;
			p[i].y=y;
		}
		int m=0; cin >>m;
		for(int i=0;i<m;i++){
			char d; int l;
			cin >> d >>l;
			for(int j=0;j<l;j++){
				if(d=='N')now.y++;
				if(d=='E')now.x++;
				if(d=='S')now.y--;
				if(d=='W')now.x--;
				for(int k=0;k<n;k++){
					if(now.x==p[k].x&&now.y==p[k].y&&v[k]==0){
						cnt++;
						v[k]=1;
					}
				}
			}			
		}
		if(cnt==n)cout << "Yes"<<endl;
		else cout << "No"<< endl;
	}
	return 0;
}


Measured memory_bytes: 2972
/*
 * 2311.cc: Dessert Witch
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int N = 8;

const int dxs[] = {1,  1,  0, -1, -1, -1, 0, 1};
const int dys[] = {0, -1, -1, -1,  0,  1, 1, 1};

/* typedef */

/* global variables */

string flds[N];

/* subroutines */

void print_flds() {
  for (int y = 0; y < N; y++) cout << flds[y] << endl;
}

int repnum(int x0, int y0, char myc) {
  int sum = 0;
  for (int di = 0; di < 8; di++) {
    int dx = dxs[di], dy = dys[di], cnt = 0;
    for (int x = x0 + dx, y = y0 + dy;
	 x >= 0 && x < N && y >= 0 && y < N;
	 x += dx, y += dy) {
      if (flds[y][x] == '.') break;
      if (flds[y][x] == myc) {
	sum += cnt;
	break;
      }
      cnt++;
    }
  }
  return sum;
}

void put(int x0, int y0, char myc) {
  if (flds[y0][x0] != '.') return;
  flds[y0][x0] = myc;

  for (int di = 0; di < 8; di++) {
    int dx = dxs[di], dy = dys[di], cnt = 0, x1, y1;
    bool flip = false;
    for (x1 = x0 + dx, y1 = y0 + dy;
	 x1 >= 0 && x1 < N && y1 >= 0 && y1 < N;
	 x1 += dx, y1 += dy) {
      if (flds[y1][x1] == '.') break;
      if (flds[y1][x1] == myc) {
	flip = true;
	break;
      }
      cnt++;
    }

    if (flip && cnt > 0)
      for (int x = x0 + dx, y = y0 + dy; x != x1 || y != y1; x += dx, y += dy)
	flds[y][x] = myc;
  }
}

/* main */

int main() {
  for (int y = 0; y < N; y++) cin >> flds[y];

  bool o = true, x = true;

  while (o || x) {
    o = x = false;
    int maxon = 0, maxxn = 0;
    int ox, oy, xx, xy;

    for (int y = 0; y < N; y++)
      for (int x = 0; x < N; x++)
	if (flds[y][x] == '.') {
	  int on = repnum(x, y, 'o');
	  if (maxon < on) maxon = on, ox = x, oy = y;
	}
    if (maxon > 0) {
      put(ox, oy, 'o');
      o = true;
      //printf("put(%d,%d,%c)\n", ox, oy, 'o');
      //print_flds();
    }

    for (int y = N - 1; y >= 0; y--)
      for (int x = N - 1; x >= 0; x--)
	if (flds[y][x] == '.') {
	  int xn = repnum(x, y, 'x');
	  if (maxxn < xn) maxxn = xn, xx = x, xy = y;
	}
    if (maxxn > 0) {
      put(xx, xy, 'x');
      x = true;
      //printf("put(%d,%d,%c)\n", xx, xy, 'x');
      //print_flds();
    }
  }

  print_flds();
  return 0;
}

Measured memory_bytes: 1184
object Main extends App {
  @scala.annotation.tailrec
  def loop(chars: Seq[Char], acc: Seq[Char]): Int = chars match {
    case Seq() => acc.map(i => new String(Array(i)).toInt).sum
    case x :: xs if x == '9' => loop(xs, acc :+ x)
    case xs => xs.length * 9 + acc.map(i => new String(Array(i)).toInt).sum - 1
  }
  val sc = new java.util.Scanner(System.in)
  val x :: xs = sc.next().toCharArray.toList
  println(if (xs.isEmpty) x.toString else loop(xs, Seq(x)))
}


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

using namespace std;

typedef long long ll;

ll dig(ll i){
	int num=0;
	while(i){
		num++;
		i /= 10;
	}
	return num;
}

int main(){
	ios::sync_with_stdio(false);
	ll n;
	int ans = 1e9;
	cin >> n;
	for(ll i=1, x; i*i<=n; i++){
		if(n%i == 0){
			x = max(dig(i), dig(n/i));
			if(x < ans)
				ans = x;
		}
	}
	if(ans == 1e9) ans = 1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
program KEYENCE_String
  implicit none
  character(100) :: s
  integer :: n, i
  read(*,*) s
  n = len_trim(s)
  do i = 1, 6
    if (s(1:i)//s(n-6+i:n) == "keyence") then
      write(*,'(a)') "YES"
      stop
    end if
  end do
  if (s(1:7) == "keyence" .or. s(n-6:n) == "keyence") then
    write(*,'(a)') "YES"
  else
    write(*,'(a)') "NO"
  end if
end program KEYENCE_String

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

using namespace std;

#define H 19
#define W 15

struct State{
  int x,y,S;
  State(int x,int y,int S) : x(x),y(y),S(S) {}
  
  bool operator < (const State &s)const{
    if(x != s.x){
      return x < s.x;
    }else if(y != s.y){
      return y < s.y;
    }else{
      return S < s.S;
    }
  }
};

int num[H][W];
char field[H][W];
map<State,int> step;
const int dx[8] = {-1,-1,-1,0,0,1,1,1};
const int dy[8] = {-1,0,1,-1,1,-1,0,1};

inline bool inH(int y){
  return (0 <= y && y < H);
}

inline bool inW(int x){
  return (0 <= x && x < W);
}

inline bool inField(int x,int y){
  return (inH(y) && inW(x));
}

int bfs(int sx,int sy){
  queue<State> Q;
  Q.push(State(sx,sy,0));
  step[State(sx,sy,0)] = 0;

  while(!Q.empty()){
    State s = Q.front(); Q.pop();
    int x = s.x,y = s.y,S = s.S;
    if(y >= H){
      return step[s];
    }
    for(int i = 0 ; i < 8 ; i++){
      int nx = x+dx[i], ny = y+dy[i], nS = S;
      if(!inField(nx,ny)){ continue; }
      if(field[ny][nx] != 'X'){ continue; }
      if(num[ny][nx] >= 0 && !(S >> num[ny][nx] & 1)){
        bool can = true;
        nS |= (1<<num[ny][nx]);
        while(true){
          nx += dx[i]; ny += dy[i];
          if(ny >= H || (ny == H-1 && inW(nx))){
            return step[s]+1;
          }
          if(!inW(nx) || ny < 0){ can = false; break; }
          if(field[ny][nx] != 'X'){ break; }
          if(nS >> num[ny][nx] & 1){ break; }
          nS |= (1<<num[ny][nx]);
        }
        if(can && step.find(State(nx,ny,nS)) == step.end()){
          step[State(nx,ny,nS)] = step[s]+1;
          Q.push(State(nx,ny,nS));
        }
      }
    }
  }
  return -1;
}

int main(){
  int x,y,n = 0;
  memset(num,-1,sizeof(num));
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      cin >> field[i][j];
      if(field[i][j] == 'O'){
        x = j; y = i;
      }else if(field[i][j] == 'X'){
        num[i][j] = n++;
      }
    }
  }
  cout << bfs(x,y) << endl;
  return 0;
}

Measured memory_bytes: 6416
N = gets.to_i
S = gets.chomp
pp = S.count("P")
ww = S.count("W")
gg = S.count("G")
yy = S.count("Y")
if pp >= 1 && ww >= 1 && gg >= 1 && yy == 0
 puts("Three")
 elsif pp >=1 && ww >= 1 && gg >= 1 && yy >= 1
 puts("Four")
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
int a[3];
vs b;
vi res;

int main(){
	cin>>n;
	for(int i=0;i<3;i++) cin>>a[i];
	b=vs(n);
	res=vi(n);
	for(auto &i:b) cin>>i;
	for(int i=0;i<n;i++){
		int x=b[i][0]-'A',y=b[i][1]-'A';
		if(a[x]==0&&a[y]==0){
			cout<<"No"<<endl;
			return 0;
		}
		if(a[x]==0) res[i]=x;
		else if(a[y]==0) res[i]=y;
		else{
			res[i]=x;
			if(i<n-1&&b[i+1][0]!=b[i][0]&&b[i+1][1]!=b[i][0]) res[i]=y;
		}
		a[res[i]]++;
		a[x+y-res[i]]--;
		assert(a[0]>=0&&a[1]>=0&&a[2]>=0);
	}
	cout<<"Yes"<<endl;
	for(auto i:res) cout<<(char)('A'+i)<<endl;
}

Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int A[n];
  for(int i=0;i<n;i++) cin>>A[i];
  int ans=0;
  for(int i=0;i<n;i++){
    int minj=i;
    for(int j=i;j<n;j++){
      if(A[j]<A[minj]){
	minj=j;
      }
    }
    if(i!=minj){
      swap(A[i],A[minj]);
      ans++;
    }
  }
  for(int i=0;i<n;i++) cout<<A[i]<<" \n"[i==n-1];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3096
#include<iostream>
#include<vector>

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

int main(){
    int n; std::cin >> n;
    std::vector<int> a;
    rep(i,n){
        int b; std::cin >> b;
        if(b%2 == 0) a.push_back(b);
    }
    std::string s="APPROVED";
    for(auto v : a)
        if(v%3 != 0 && v%5 != 0) s="DENIED";
    std::cout << s << std::endl;
    return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int d[100][100];
typedef pair<int, int>pii;
typedef pair<pii, int>pi3;
int x[1000];
int main()
{
	int s, g;
	scanf("%d%d", &g, &s);
	int r = 0;
	for (int i = 0; i <= g; i++)for (int j = 0; j <= g; j++)if (0 <= s - i - j&&s - i - j <= g)r++;
	printf("%d\n", r);
}

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

#define MAX 100000

using namespace std;


int head, tail;
int queue[MAX];


void enq(int v)
{
    queue[tail] = v;
    tail = (tail + 1) % MAX;
}


int deq(void)
{
    int t = queue[head];
    head = (head + 1) % MAX;
    return t;
}


bool is_empty(void)
{
    return head == tail;
}


bool is_full(void)
{
    return head == (tail + 1) % MAX;
}


struct process {
    string name;
    int t;
};

struct process ps[MAX];


int main(void)
{
    int n, q;
    cin >> n;
    cin >> q;

    for (int i = 0; i < n; i++) {
        cin >> ps[i].name;
        cin >> ps[i].t;
        enq(i);
    }

    int passed = 0;
    while(!is_empty()) {
        int p_index = deq();
        if (ps[p_index].t > q) {
            ps[p_index].t = ps[p_index].t - q;
            enq(p_index);
            passed += q;
        } else {
            cout << ps[p_index].name << " ";
            cout << passed + ps[p_index].t << endl;
            passed += ps[p_index].t;
        }
    }
}


Measured memory_bytes: 7412
#include <bits/stdc++.h>
#define ll long long
#define lsb(x) (x & (-x))


using namespace std;



int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    int n, k;
    ios::sync_with_stdio(false);
    cin >> n >> k;
    ll x = 1;
    while(n > 0) {
        if(x * 2 < x + k)
            x *= 2;
        else
            x += k;
        n--;
    }
    cout << x;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,k[100005];
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>k[i];
  }
  sort(k,k+n);
  long long int mon=1000000000,ans;
  double dis;
  for(int i=0;i<n;++i){
    dis=(double)k[i]-(double)k[n-1]/2;
    if(dis<0) dis*=-1;
    if(mon>dis){
      mon=dis;
      ans=i;
    }
  }
  cout<<k[n-1]<<" "<<k[ans]<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
#define prev prev228
#define all(x) (x).begin(), (x).end()

string s;
long long ans = 0;
vector<int> pos[26];
long long p[500000];
long long Pos[500000];

long long tree[2000000];

void Add(int l, int r, int v, int p)
{
    if (l + 1 == r)
    {
        return (void)(tree[v]++);
    }
    int m = (l + r) / 2;
    if (p < m) Add(l, m, 2 * v + 1, p);
    else Add(m, r, 2 * v + 2, p);
    tree[v] = tree[2 * v + 1] + tree[2 * v + 2];
}

int Summ(int l, int r, int v, int L, int R)
{
    if (r <= L || R <= l)
        return 0;
    if (L <= l && r <= R) return tree[v];
    int m = (l + r) / 2;
    return Summ(l, m, 2 * v + 1, L, R) + Summ(m, r, 2 * v + 2, L, R);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        pos[s[i] - 'a'].push_back(i);
    }
    int cnt = 0;
    for (int i = 0; i < 26; i++)
    {
        if (pos[i].size() % 2 == 1) cnt++;
    }
    if (cnt >= 2)
        cout << -1, exit(0);
    vector<pair<int, int> > v;
    int posk = -1;
    for (int i = 0; i < 26; i++)
    {
        if (pos[i].size() % 2 == 1) posk = pos[i][pos[i].size() / 2];
        for (int j = 0; j < pos[i].size() && pos[i].size() - 1 - j > j; j++)
        {
            v.push_back({pos[i][j], pos[i][pos[i].size() - 1 - j]});
        }
    }
    sort(v.begin(), v.end());
    int x = 0, y = s.size() - 1;
    for (int i = 0; i < v.size(); i++)
    {
        if (x == y)
        {
            p[posk] = x;
            continue;
        }
        p[v[i].first] = x;
        p[v[i].second] = y;
        x++;
        y--;
    }
    if (x == y)
    {
        p[posk] = x;
    }
    for (int i = 0; i < s.size(); i++)
    {
        Pos[p[i]] = i;
    }
    for (int i = 0; i < s.size(); i++)
    {
        ans += Summ(0, s.size(), 0, Pos[i], s.size());
        Add(0, s.size(), 0, Pos[i]);
    }
    cout << ans;
}


Measured memory_bytes: 17420
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    bool isYes = true;
    for(int i=0; i<s.length(); i++){
        if(i%2==0){
            if(!(s[i]=='R' || s[i]=='D' || s[i]=='U')){
                isYes = false;
            }
        }else{
            if(!(s[i]=='L' || s[i]=='D' || s[i]=='U')){
                isYes = false;
            }
        }
    }
    if(isYes){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
constexpr int MOD = 1000000007;

int mod(const ll &x){
    return x > 0 ? x % MOD : (x+MOD) % MOD;
}

int modm(const ll &x,const ll &m){
    return x * m % MOD;
}

int modpow(ll x, ll p) {
    int ret = 1;
    while(p > 0) {
        if (p & 1) ret = modm(ret,x);
        x = modm(x,x);
        p >>= 1;
    }
    return ret;
}

// x * modinv(d)
int modd(ll x,ll d) {
    return modm(x,modpow(d,MOD-2));
}

int main(void)
{
    IOS
    constexpr int N = 62;
    int n; cin >> n;
    vector<bitset<N>> v;
    vector<int> cnt(N);
    REP(i,n) {
        ll x;
        cin >> x;
        v.push_back(bitset<N>(x));
        REP(j,N) {
            if(v[i][j]) cnt[j]++;
        }
    }

    int ans = 0;
    REP(i,n-1) {
        REP(j,N) {
            if(v[i][j]) cnt[j]--;
        }
        bitset<N> bs(v[i]);
        ll tmp = 0;
        REP(j,N) {
            if (bs[j]) tmp = mod(tmp + modm(mod(1LL << j),n-i-1-cnt[j]));
            else tmp = mod(tmp + modm(mod(1LL << j),cnt[j]));
        }
        ans = mod(ans + tmp);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <numeric>
#include <ios> // std::left, std::right

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

int main()
{
  float n;

  cin >> n;

  cout << ceil(n/(37*3))*37*3 << endl;

  return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
s=''
for _ in range(h):
  s+=input()
from collections import Counter as c
v=list(c(s).values())
ki=0;ni=0;
for i in v:
  if i%2:
    ki+=1
  elif i%4:
    ni+=1
x='No'
if (h%2)*(w%2):
  if ki==1 and ni<=(h+w-2)//2:
    x='Yes'
elif h%2:
  if ki==0 and ni<=w//2:
    x='Yes'
elif w%2:
  if ki==0 and ni<=h//2:
    x='Yes'
else:
  if ki==0 and ni==0:
    x='Yes'
print(x)

Measured memory_bytes: 3316
import java.util.Scanner;
public class Main{
  
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
       System.out.println(gcd(a,b));
    
       
    
       
    }//main
    
     public static int gcd(int a,int b){
            if(b == 0){
                return a;
            }//if
            return gcd(b, a % b);
        }//gcd
    
}//main


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

int main(){
    
    int n;
    const int cnum = -2;
    cin >> n;
    if(n == 0){
        cout << 0 << endl;
        return 0;
    }
    vector<string> ans;
    while((n != 1)){
        if(abs(n)%2 == 1){
            ans.push_back("1");
            if(n<0){
                n = n/cnum + 1;
            }
            else{
                n = n/cnum;
            }
        }
        else{
            ans.push_back("0");
            n = n/cnum;
        }
    }
    ans.push_back("1");
    for(int i=(int)ans.size()-1; i>=0; i--){
        cout << ans.at(i);
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
string n;
int main()
{
    cin>>n;
    for(int s=2;s<n.size();s++)
    {
        if(n[s]==n[s-1]&&n[s]==n[s-2])
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)

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

    int i, j;
    cin >> i >> j;

    cout << (i == j ? "Yes" : "No") << endl;

    return 0;
}

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

#define MOD 1000000007
#define MODSET(d) if ((d) >= MOD) d %= MOD;

using namespace std;

int arr[205];

int main()
{
    #ifdef VSP4
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

	string str;
	cin >> str;
	
	cout << str.substr(0, 4) << " " << str.substr(4) << "\n";
		
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

    int N;
    cin >> N;

    int a = N /100;
    int ans;
    if (a * 111 < N) {
        ans = (a + 1) * 111;
    }else{
        ans = a * 111;
    }
    
    cout << ans << endl;

    return 0;
}

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

int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int res=0;
    while(k>0){
        if(a>0){
            a--;
            k--;
            res++;
            //cout << k << " ";
            continue;
        }
        else if(b>0){
            b--;
            k--;
            //cout << k << " ";
            continue;
        }
        else{
            c--;
            k--;
            res--;
            //cout << k << " ";
            continue;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>

using namespace std;


int main(){
    int n, d, x;
    scanf("%d", &n);
    scanf("%d %d", &d, &x);
    int a[n];
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    int ans = x;
    for(int i = 0; i < n; i++){
        int day = 1;
        while (day <= d){
            ans++;
            day += a[i];
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
from sys import stdin
rr = lambda: stdin.readline().strip()
rrM = lambda: map(int,rr().split())
debug=0
if debug:
    fi = open('in.txt','r')
    rr=lambda: fi.readline().replace('\n','')

N,A,B = rrM()
smallest = A * (N-1) + B
largest = A + B * (N-1)
print max(0,largest - smallest + 1) if A<=B else 0


Measured memory_bytes: 2692
#include <iostream>

using namespace std;

#define rep(i, n) REP(i, 0, n)
#define REP(i,k,n) for(int i = k; i < n; i++)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define argmax max_element
#define argmin min_element
#define push push_back
#define pop pop_back
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef string str;

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

template<class T = ll> T in() {
    T _in;
    cin >> _in;
    return _in;
}

int w, h;
bool c[55][55] = {};

void DFS(int y, int x) {
    c[y][x] = 0;
    rep(i, 8) {
        if(y+dy[i]<0 || y+dy[i]>=h || x+dx[i]<0 || x+dx[i]>=w) continue;
        if(c[y + dy[i]][x + dx[i]]) {
            DFS(y + dy[i], x + dx[i]);
        }
    }
}

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

    while(cin >> w >> h,w){
        rep(i, h) {
            rep(j, w) {
                cin >> c[i][j];
            }
        }

        int ans = 0;
        // 探索
        rep(y, h) {
            rep(x, w) {
                if (c[y][x]) {
                    DFS(y, x);
                    ans++;
                }
            }
        }

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



Measured memory_bytes: 3212
use std::io;

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let x: Vec<u32> = read_vec();
    println!(
        "{} {} {}",
        x[0] / x[1],
        x[0] % x[1],
        x[0] as f64 / x[1] as f64
    );
}



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

int main(void){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    
    int x = tx - sx;
    int y = ty - sy;
    
    int i;
    for(i = 1; i <= y; i++){
        cout << 'U';
    }
    for(i = 1; i <= x + 1; i++){
        cout << 'R';
    }
    for(i = 1; i <= y + 1; i++){
        cout << 'D';
    }
    for(i = 1; i <= x + 1; i++){
        cout << 'L';
    }
    cout << 'U';
    
    cout << 'L';
    for(i = 1; i <= y + 1; i++){
        cout << 'U';
    }
    for(i = 1; i <= x + 1; i++){
        cout << 'R';
    }
    for(i = 1; i <= y + 1; i++){
        cout << 'D';
    }
    for(i = 1; i <= x; i++){
        cout << 'L';
    }
    
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	//"strconv"
)

func main() {
	var N int
  flag:=1
	fmt.Scanf("%d",&N)
  
    sli := make([]int,N)
  	for i:=0;i<N;i++{
    	fmt.Scanf("%d",&sli[i])
      if sli[i]%2==0{
        if sli[i]%3==0||sli[i]%5==0{
        }else{
          flag=0
       	  break
        }
      }
   	}
  if flag==1{
    fmt.Print("APPROVED")
  }else{
    fmt.Print("DENIED")
  }
}

Measured memory_bytes: 512
#include<iostream>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#define maxn 200010
using namespace std;
char a[maxn],b[maxn];
int c[30],d[30];
int main()
{
   int j,len;
   scanf("%s %s",a,b);
   len=strlen(a);
   for(int i=0;i<len;i++)
   {
   	  j=a[i]-'a';
   	 c[j]++;
   }
   len=strlen(b);
   for(int i=0;i<len;i++)
   {
   	  j=b[i]-'a';
   	  d[j]++;
   }
   sort(c,c+30);
   sort(d,d+30);
   for(int i=0;i<30;i++)
   {
   	 if(c[i]!=d[i])
   	 {
   	 	printf("No\n");
   	 	return 0;
		}
   
   }
   printf("Yes\n");
   return 0;
	
}

Measured memory_bytes: 640
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())

a.sort(reverse=True)

print(sum(a[1:2*n:2]))

Measured memory_bytes: 37212
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;

int main(void)
{
	int n;
	scanf("%d", &n);
	if (n >= 30)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;

constexpr int INF = 1 << 25;
constexpr int MOD = 1000000007;

int main() {
  int n, q;
  cin >> n;
  vector<int> S(n);
  REP(i, n) cin >> S[i];
  cin >> q;

  int cnt = 0, t;
  REP(i, q) {
    cin >> t;
    if (find(ALL(S), t) != S.end()) ++cnt;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 3080
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n, m;
  cin >> n >> m;
  vll a(n);
  rep(i, n){
    cin >> a[i];
  }
  ll sum = accumulate(ALL(a), 0);
  sort(ALL(a));
  reverse(ALL(a));
  ll ans = 0;
  rep(i, n){
    if(a[i] >= (sum+4*m-1)/(4*m)){
      ans++;
    }
  }
  Pr(ans >= m);
}


Measured memory_bytes: 256
using System;
using System.Linq;
public class Global{
    public static long a = long.Parse(Console.ReadLine());
    public static int ans = 0;
}

class program{
  static void Main(){
	divgame(2);
    divgame(3);
    divgame(5);
    int itr = (int)Math.Sqrt(Global.a); 
    for(int i=0;i<=itr;i+=30){
      divgame(7+i);
      divgame(11+i);
      divgame(13+i);
      divgame(17+i);
      divgame(19+i);
      divgame(23+i);
      divgame(29+i);
      divgame(31+i);
    }
    if(Global.a != 1) Global.ans++;
    Console.Write(Global.ans);
  }
  
  static void divgame(long div){
    int meta = 0,ct = 0;
    while(Global.a%div == 0){
      Global.a/=div;
      ct++;
      if(ct > meta){
        meta++;
        Global.ans++;
        ct=0;
      }
    }
    return;
  }
}

Measured memory_bytes: 27412
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

#ifdef DEBUG

#define printd printf

#else

#define printd(...)

#endif

int main() {

    int n, max_weight;
    std::cin >> n >> max_weight;

    std::vector<int> values(n), weights(n);

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

    int dp[n][max_weight + 1] = { 0 };

    printd("weights[0]: %d\n", weights[0]);
    for (int w = 0; w < max_weight + 1; w++) {
        if (w >= weights[0]) {
            dp[0][w] = values[0];
        }
        else {
            dp[0][w] = 0;
        }
    }

    for (int i = 1; i < n; i++) {
        for (int w = 0; w < max_weight + 1; w++) {
            if (w >= weights[i]) {
                dp[i][w] = std::max(dp[i - 1][w - weights[i]] + values[i], dp[i - 1][w]);
            }
            else {
                dp[i][w] = dp[i - 1][w];
            }
        }
    }

    printd("n: %d, w: %d\n", n, max_weight);
    for (int i = 0; i < n; i++) {
        for (int w = 0; w < max_weight + 1; w++) {
            printd("%d ", dp[i][w]);
        }
        printd("\n");
    }

    std::cout << dp[n - 1][max_weight] << std::endl;

    return 0;
}


Measured memory_bytes: 6928
import sys
input = sys.stdin.readline

def main():
    N, M, X, Y = map(int, input().split())
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))

    z_min = max(x) + 1
    z_max = min(y)
    if z_min <= z_max:
        if z_max <= X or Y < z_min:
            print("War")
        else:
            print("No War")
    else:
        print("War")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064