akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int h,w;
    cin >> h >> w;
    vector<string> v(h);
    rep(i,h) cin >> v[i];
    rep(i,w+2) cout << '#';
    cout << endl;
    rep(i,h) cout << '#' << v[i] << '#' << endl;
    rep(i,w+2) cout << '#';
    cout << endl;
}

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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
    int n;
    cin >> n;
    int t = 1;
    int k = 0;
    rep(i, n){
        int a;
        cin >> a;
        if(a == t){
            k++;
            t++;
        }
    }
    if(k != 0) cout << n-k << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3636
A, B = map(int, input().split())

ans = [['#'] * 100 for _ in range(50)]
ans_ = [['.'] * 100 for _ in range(50)]
ans.extend(ans_)

h = 0
w = 0
for i in range(A-1):
    ans[h][w] = '.'
    w += 2
    if w >= 100:
        h += 2
        w = 0

h = 51
w = 0
for i in range(B-1):
    ans[h][w] = '#'
    w += 2
    if w >= 100:
        h += 2
        w = 0

print(100, 100)
for i in range(100):
    print(''.join(ans[i]))


Measured memory_bytes: 38524
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
typedef vector< vector<int> > Graph;
int N, M;
void add_edge(Graph& G, int a, int b){
  G[a].push_back(b);
  G[b].push_back(a);
}
double curr[1<<10][10];
void print_binary(int S){
  REP(i, N) cout<<(S>>i & 1);
}
void update(Graph& G, int idx, int S){
  if(S == (1<<N) - 1) return;
  if(!(S >> idx & 1)) return;
  //printf("update (%d, ", idx);
  //print_binary(S);
  double E = G[idx].size();
  double& next = curr[S][idx];
  //printf(") : %lf ->", next);
  next = 1;
  REP(i, G[idx].size()){
    int u = G[idx][i];
    //printf(" + (%d, ", u); print_binary(S | (1<<u)); printf(")");
    next += curr[S | (1 <<u)][u] / E;
  }
  //printf(" -> %lf\n", next);
}
int main(){
  while(cin>>N>>M){
    REP(i, N)REP(S, 1<<N) curr[i][S] = 0;
    Graph G(N);
    REP(i, M){
      int a, b; cin>>a>>b;
      a--; b--;
      add_edge(G, a, b);
    }
    const int LOOP = 100LL * 50 * 1<<10 /(M * 1<<N);
    REP(iter, LOOP){
      REP(i, N)REP(S, 1<<N){
        update(G, i, S);
      }
    }
    printf("%.6lf\n", curr[1][0]);
  }
  return 0;
}

Measured memory_bytes: 1324
from itertools import*
n,a,b,c,*l=map(int,open(0).read().split())
a=a,b,c
m=10**18
for s in product(*[range(4)]*n):
  if all(i in s for i in(0,1,2)):
    t,c=[0]*4,[0]*4
    for i,v in zip(s,l):
      t[i]+=v
      c[i]+=1
    m=min(m,sum(abs(x-y)+~-z*10for x,y,z in zip(a,t,c)))
print(m)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
vector <int> v;
vector <char> vc;
vector <string> vs;
map <string,int> sm;
map <int,int> mp;
map <char,int>cm;
//int string_to_int(string s){stringstream x(s);double a=0; x>>a; return a;}
//long long int gcd(long long int a, long long int b){if(a%b==0)return b;return gcd(b, a%b);}
//long long int lcm(long long int a, long long int b){return (a*b)/gcd(a, b);}
//int string_sum(string s){int b = 0;auto k =s.size();for(int j=0; j<k; j++){b +=(s[j]-48);}return b;}
//long long int factorial(long long int n){if (n == 0)return 1;return n * factorial(n - 1);}

//int cnt =0;
//
//void SieveOfEratosthenes(int n)
//{
//   // v.push_back(1);
//
//    bool prime[n+1];
//    memset(prime, true, sizeof(prime));
//
//    for (int p=2; p*p<=n; p++)
//    {
//
//        if (prime[p] == true)
//        {
//
//            for (int i=p*p; i<=n; i += p)
//                prime[i] = false;
//        }
//    }
//
//
//    for (int p=2; p<=n; p++)
//       if (prime[p])
//          v.push_back(p);
//}
//
   

//int mod(string num, int a)
//{
//    // Initialize result
//    int res = 0;
//
//    // One by one process all digits of 'num'
//    for (int i = 0; i < num.length(); i++)
//         res = (res*10 + (int)num[i] - '0') %a;
//
//    return res;
//}

int main()
{
    int a,b,c=0,n,mn=0,mx=1000000000;
    string s,p;
    char ch;
    
    cin >> a;
    
    
    for(int i=0; i<a; i++)
    {
        cin >> n;
        v.push_back(n);
    }
    
    for(int i=0;i<a; i++)
    {
        for(int j=i+1; j<a; j++)
        {
            mn+=(v[i]*v[j]);
        }
    }
    
    
    cout << mn << endl;
   
    
    
}


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    ll r,g,b; cin >> r >> g >> b;
    ll num = r * 100 + g * 10 + b;
    if(num % 4 == 0)out("YES");
    else out("NO");
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;

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

  vector<int> oks(n + 1, true);
  for(int i = 0; i < m; i++){
    int a;
    cin >> a;
    oks[a] = false;
  }

  vector<long long int> dp(n + 1);
  dp[0] = 1;
  for(int now = 0; now < n; now++){
    for(int next = now + 1; next <= min(n, now + 2); next++){
      if(oks[next]){
        dp[next] += dp[now];
        dp[next] %= mod;
      }
    }
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 4248
import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)
import Data.List

check1 :: [Integer] -> Bool
check1 (x:xs) = x == 0 && (length . filter (==0)) xs == 0

check2 :: [Integer] -> Bool
check2 [] = True
check2 [_] = True
check2 (x1:x2:xs) = succ x1 == x2 && check2 (x2:xs)

solve :: [Integer] -> Integer
solve [_] = 1
solve (x1:x2:xs) = (x1^x2) * solve (x2:xs)

main :: IO ()
main = do
    _ <- getLine
    d <- map (fst . fromJust . BS.readInteger)
        . BS.words <$> BS.getLine :: IO [Integer]
    let d' = group $ sort d
    print $
        if check1 d && check2 (map head d')
            then solve (map (fromIntegral . length) d') `rem` 998244353
            else 0


Measured memory_bytes: 22908
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, x;
    cin >> n >> x;
    int ans = 1, p = 0;
    REP(i,n){
        p += in();
        if (p <= x) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main{
	static Scanner s=new Scanner(System.in);
	
	void solve(){
		int n=gInt();
		char[][]f=new char[n][n];
		for(int i:rep(n))
			s.next().getChars(0,n,f[i],0);
		long r=0;
		for(int i:rep(n)) {
			if(_solve(n,f,i,0)) {
				System.err.println(i+" 0");
				r+=n-i;
			}
		}
		for(int j:rep(1,n-1)) {
			if(_solve(n,f,0,j)) {
				System.err.println("0 "+j);
				r+=n-j;
			}
		}
		System.out.println(r);
	}
/*
abc
bab
cba

bca
abb
bac

 */

	private boolean _solve(int n,char[][] f,int I,int J){
		for(int i:rep(n)) {
			for(int j:rep(n)) {
				char a=f[(i+I)%n][(j+J)%n];
				char b=f[(j+I)%n][(i+J)%n];
//				System.err.print(" "+a+b);
				if(a!=b)
					return false;
			}
		}
		return true;
	}

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

	static int gInt(){
		return Integer.parseInt(s.next());
	}
	static long gLong(){
		return Long.parseLong(s.next());
	}
	static double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,Main::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,Main::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,Main::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(Main::gInt).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}
class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}
class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}

	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}

}


Measured memory_bytes: 150596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        const int waru = 1000000000 + 7;
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int M = int.Parse(str[1]);

        if(N == M){
            long n_ans = N;
            for(long i = N - 1; i > 0; i--){
                n_ans *= i;
                if(n_ans > waru){
                    n_ans %= waru;
                }
            }

            long m_ans = M;
            for(long i = M - 1; i > 0; i--){
                m_ans *= i;
                if(m_ans > waru){
                    m_ans %= waru;
                }
            }

            long kai = n_ans * m_ans * 2;
            if(kai > waru){
                Console.WriteLine(kai % waru);
            }
            else{
                Console.WriteLine(kai);
            }
        }
        else if(N == M + 1 || N == M - 1){
            long n_ans = N;
            for(long i = N -1; i > 0; i--){
                n_ans *= i;
                if(n_ans > waru){
                    n_ans %= waru;
                }
            }

            long m_ans = M;
            for(long i = M -1; i > 0; i--){
                m_ans *= i;
                if(m_ans > waru){
                    m_ans %= waru;
                }
            }

            long kai = n_ans * m_ans;
            if(kai > waru){
                Console.WriteLine(kai % waru);
            }
            else{
                Console.WriteLine(kai);
            }
        }
        else{
            Console.WriteLine(0);
        }
    }
}



Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  double n, k;
  cin >> n >> k;
  double ans = 0;
  for(int i = 1 ; i <= n; i++){
    double tmp = i;
    double jousuu = 0;
    while(tmp < k){
      tmp *= 2;
      jousuu += 1;
    }
    ans += 1.0 / ((double)pow(2, jousuu) * n);
  }
  printf("%.12lf\n", ans);
}


Measured memory_bytes: 256
//⣿⣿⣿⣿⣿⣿⠟⠋⠁⣀⣤⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿⣿
//⣿⣿⣿⣿⠋⠁⠀⠀⠺⠿⢿⣿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠻⣿
//⣿⣿⡟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣤⣤⣤⣤⠀⠀⠀⠀⠀⣤⣦⣄⠀⠀
//⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣶⣿⠏⣿⣿⣿⣿⣿⣁⠀⠀⠀⠛⠙⠛⠋⠀⠀
//⡿⠀⠀⠀⠀⠀⠀⠀⠀⡀⠀⣰⣿⣿⣿⣿⡄⠘⣿⣿⣿⣿⣷⠄⠀⠀⠀⠀⠀⠀⠀⠀
//⡇⠀⠀⠀⠀⠀⠀⠀⠸⠇⣼⣿⣿⣿⣿⣿⣷⣄⠘⢿⣿⣿⣿⣅⠀⠀⠀⠀⠀⠀⠀⠀
//⠁⠀⠀⠀⣴⣿⠀⣐⣣⣸⣿⣿⣿⣿⣿⠟⠛⠛⠀⠌⠻⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀
//⠀⠀⠀⣶⣮⣽⣰⣿⡿⢿⣿⣿⣿⣿⣿⡀⢿⣤⠄⢠⣄⢹⣿⣿⣿⡆⠀⠀⠀⠀⠀⠀
//⠀⠀⠀⣿⣿⣿⣿⣿⡘⣿⣿⣿⣿⣿⣿⠿⣶⣶⣾⣿⣿⡆⢻⣿⣿⠃⢠⠖⠛⣛⣷⠀
//⠀⠀⢸⣿⣿⣿⣿⣿⣿⣾⣿⣿⣿⣿⣿⣿⣮⣝⡻⠿⠿⢃⣄⣭⡟⢀⡎⣰⡶⣪⣿⠀
//⠀⠀⠘⣿⣿⣿⠟⣛⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⡿⢁⣾⣿⢿⣿⣿⠏⠀
//⠀⠀⠀⣻⣿⡟⠘⠿⠿⠎⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣵⣿⣿⠧⣷⠟⠁⠀⠀
//⡇⠀⠀⢹⣿⡧⠀⡀⠀⣀⠀⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠋⢰⣿⠀⠀⠀⠀
//⡇⠀⠀⠀⢻⢰⣿⣶⣿⡿⠿⢂⣿⣿⣿⣿⣿⣿⣿⢿⣻⣿⣿⣿⡏⠀⠀⠁⠀⠀⠀⠀
//⣷⠀⠀⠀⠀⠈⠿⠟⣁⣴⣾⣿⣿⠿⠿⣛⣋⣥⣶⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⣿⡀ 
//
//⣿⠛⣷⠀⠀⢸⣟⡛⠀⠀⣿⠛⣷⠀⠀⢸⣟⡛⠀⠀⣴⢟⣛⡀⠀⠀⣸⢿⣇⠀ 
//⣿⠉⠉⠀⠀⢸⣯⣥⠀⠀⣿⠉⠉⠀⠀⢸⣯⣥⠀⠀⢿⣮⣽⡇⠀⢠⡿⠶⣿⡄ 
#include <bits/stdc++.h>
#define DEBUG false
#define debugf if (DEBUG) printf
#define MAXN 150001
#define MAXM 900009
#define MAXLOGN 20
#define ALFA 256
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define EPS 1e-9
#define PI 3.141592653589793238462643383279502884
#define FOR(x,n) for(int x=0; (x)<int(n); (x)++)
#define FOR1(x,n) for(int x=1; (x)<=int(n); (x)++)
#define REP(x,n) for(int x=int(n)-1; (x)>=0; (x)--)
#define REP1(x,n) for(int x=(n); (x)>0; (x)--)
#define pb push_back
#define pf push_front
#define pr printf
#define sc(x) scanf("%d", &x)
#define sc2(x, y) sc(x);sc(y)
#define sc3(x, y, z) sc2(x, y);sc(z)
#define scll(x) scanf("%lld", &x)
#define sc2ll(x, y) scll(x);scll(y)
#define sc3ll(x, y, z) sc2ll(x, y);scll(z)
#define ff first
#define ss second
#define mp make_pair
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define mset(x,y) memset(&x, (y), sizeof(x))
#define LOWBIT(A) (A & -A)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned int uint;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair <ll, ll> pll;
typedef pair < pll, ll > plll;

int n, t;
pll  pratos[3001];
ll dp[3001][3001];

bool cmp(pll a, pll b){
    if(a.ff == b.ff)return a.ss > b.ss;
    return a.ff < b.ff;
}

ll solve(int ind, int custo){
    if(custo >= t)return 0;
    if(ind >= n)return 0;
    ll &curr = dp[ind][custo];
    if(curr != -1)return curr;
    return curr = max(solve(ind + 1, custo), solve(ind + 1, custo + pratos[ind].ff) + pratos[ind].ss);
}

int main(){
    sc2(n, t);
    mset(dp, -1);
    FOR(i, n){sc2ll(pratos[i].ff, pratos[i].ss);}
    sort(pratos, pratos + n, cmp);
    pr("%lld\n", solve(0, 0));
	return 0;
}

Measured memory_bytes: 70784
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	fsc := NewFastScanner()
	N, A, B := fsc.NextInt(), fsc.NextInt(), fsc.NextInt()
	S := fsc.Next()
	passed := 0
	rank := 0
	for i := 0; i < N; i++ {
		if S[i] == 'a' {
			if passed < A+B {
				fmt.Println("Yes")
				passed++
			} else {
				fmt.Println("No")
			}
		} else if S[i] == 'b' {
			rank++
			if passed < A+B && rank <= B {
				fmt.Println("Yes")

				passed++
			} else {
				fmt.Println("No")
			}

		} else {
			fmt.Println("No")
		}
	}
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 3328
# import itertools

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

# tmp = itertools.combinations_with_replacement(P, K)
# tmp = itertools.combinations(P, K)

P.sort()
print(sum(P[0:K]))

# hoge = []
# for i in tmp:
#     hoge.append(sum(i))

# print(min(hoge))


Measured memory_bytes: 8992
#include <iostream>
#include <cstdint>

using namespace std;

const u_int64_t R = 1'000'000'007;

u_int64_t dp[2'000][2'000];
u_int64_t p[2'000][2'000];
int s[2'000], t[2'000];

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

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

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            dp[i][j] = s[i] == t[j] ? (i == 0 || j == 0 ? 1 : (p[i - 1][j - 1] + 1) % R)
                                    : 0;

            u_int64_t a = 0;
            a = (a + (i == 0 ? 0 : p[i - 1][j])) % R;
            a = (a + (j == 0 ? 0 : p[i][j - 1])) % R;
            a = (a + R - (i == 0 || j == 0 ? 0 : p[i - 1][j - 1])) % R;
            a = (a + dp[i][j]) % R;
            p[i][j] = a;
        }
    }

    cout << (p[n - 1][m - 1] + 1) % R << endl;

    return 0;
}


Measured memory_bytes: 62720
l, r = map( int, input().split() )

r = min( r, l + 2019 )

min_ixj = 2019
for i in range( l, r ): 
    for j in range( i+1, r+1 ):
        ixj = ( i % 2019 ) * ( j % 2019 ) % 2019
        if ixj < min_ixj:
            min_ixj = ixj

print( min_ixj )

Measured memory_bytes: 3060
n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(n)]
cd = [tuple(map(int, input().split())) for _ in range(m)]

ans = []
for a, b in ab:
    mx, j = 10**20, 0
    for i in range(m):
        c, d = cd[i]
        l = abs(a-c) + abs(b-d)
        if l < mx: 
            j = i
            mx = l
    ans.append(j+1)

print('\n'.join(map(str, ans)))

Measured memory_bytes: 9188
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

class Graph{

private:


  vector<Graph*> tree;
  int value;

public:
  Graph *master;  
  Graph(int _value);
  void append(Graph *obj);
  void set_master(Graph *_master);
  void set_value(int _value);
  int show_value();
  int show_slave_value_all();
  int show_slave_value_index(int i);  
  int show_slave_num();  
  void show_graph();
  void sort_graph();
  void graph_sum_least();  
  
};

bool graph_slave_compare(Graph* a,Graph* b){

  return a->show_value() < b->show_value();
  
}

int main(void){

  int n;
  string line;

  cin >> n;
  //cout << n << endl;

  //while(c != '\n'){c=getchar();}
  
  //for(cin>>n;n!=0;cin>>n){
  for(int i=0;i<n;i++){


    int votes=0;

    Graph g(0);

    Graph *focus;
    Graph *tmp;    

    focus=&g;

    //cout << "debug" << endl;

    cin >> line;
    //cout << line << endl;

    //for(c=getchar();c != '\n';c=getchar()){
    //while(0){
    for(char c:line){
      //cout << "debug" << endl;    
      //cin>>c;

      if(c=='['){
	tmp = new Graph(0);
	focus->append(tmp);
	focus=tmp;

      }
      else if(c==']'){
	//votes=votes/2+1;
	//focus->set_value(focus->show_value()/2+1);
	if(votes != 0){
	  votes=votes/2+1;
	  focus->set_value(votes);  
	}
	focus=focus->master;
	focus->sort_graph();

	int tmp_v=0;
	
	for(int j=0;j<focus->show_slave_num()/2+1;j++){
	  tmp_v += focus->show_slave_value_index(j);
	}
	focus->set_value(tmp_v);
	votes=0;
      }
      else if(c>='0' && c<='9'){
	votes=10*votes+(c-'0');
	
      }
      else{
	
      }
      
    }

    //g.show_graph();
    cout << g.show_value() << endl;
    //cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
  }
  
}

Graph::Graph(int _value){

  value=_value;
  
}

void Graph::append(Graph *obj){
  obj->set_master(this);
  tree.push_back(obj);
  
}

void Graph::set_master(Graph *_master){
  master=_master;
}

void Graph::set_value(int _value){
  value=_value;
}

void Graph::show_graph(){

  cout << "value:" << value << endl;

  if(tree.size() > 0){
  
    cout << "show slave" << endl;

    cout << "==================" << endl;
  
    for(Graph *x:tree){
      x->show_graph();
    }

    cout << "slave end" << endl;

    cout << "+++++++++++++++++++++++++" << endl;
  }
  
}

int Graph::show_value(){
  return value;
}

int Graph::show_slave_value_all(){
  int tmp=0;
  for(Graph *x:tree){
    tmp += x->show_value();
  }
  return tmp;
}

void Graph::sort_graph(){

  //std::sort(tree.begin(),tree.end(),graph_slave_compare);
  std::sort(tree.begin(),tree.end(),
	    [](auto x,auto y){ return x->show_value() < y->show_value();});
  //[](Graph* x,Graph* y){ return x->show_value() < y->show_value();});  
  
}

int Graph::show_slave_num(){
  return tree.size();
}

int Graph::show_slave_value_index(int i){
  return this->tree[i]->show_value();
}



Measured memory_bytes: 5384
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int dp[100010][11];
vector<int> G[100010];

void dfs(int x, int c, int d) {
    //cout << x << " "<< c << " " << d << endl;
    if (dp[x][d]) return;
    dp[x][d] = c;
    if (d == 0) return;
    dfs(x, c, d - 1);
    for(auto next: G[x]) {
        dfs(next, c, d - 1); 
        
    }
}
int v[100010], d[100010], c[100010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    rep(i, M) {
        int a, b; 
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int Q; cin >> Q;
    rep(i, Q) {
        cin >> v[Q - i - 1] >> d[Q - i - 1] >> c[Q - i - 1];
    }
    rep(i, Q) {
        dfs(v[i], i + 1, d[i]);
    }
    rep(i, N) {
        cout << c[dp[i + 1][0] - 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 12024
#include <iostream>

using namespace std;

#define FOR(a, b) for(int a = 0; a < b; ++a)

int vx[4] = {0, 1, 0, -1};
int vy[4] = {-1, 0, 1, 0};
int a, b, m;
int map[16][16] = {0};
bool chk[16][16] = {false};

void froot(int x, int y){
  FOR(i, 2){
    int nx = x + vx[i + 1];
    int ny = y + vy[i + 1];
    if(map[y][x] == 2){
      ++m;
      return;
    } else if(nx >= 0 && nx < a && ny >= 0 && ny < b && !chk[ny][nx] && map[ny][nx] != 3){
      chk[ny][nx] = true;
      froot(nx, ny);
      chk[ny][nx] = false;
    } 
  }
}

int main(){

  int n, x, y;

  while(1){

    cin >> a >> b;

    if(!a && !b)break;
    
    cin >> n;
    
    m = 0;
    FOR(i, b){
      FOR(j, a){
	map[i][j] = 0;
	chk[i][j] = false;
      }
    }
    map[0][0] = 1;
    map[b-1][a-1] = 2;
    
    FOR(i, n){
      cin >> x >> y;
      map[y - 1][x - 1] = 3;
    }

    froot(0, 0);
    
    cout << m << endl;

  }
  
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n,m; cin>>n>>m;
    vector<ll> h(n);
    rep(i,n) cin>>h[i];
    vector<vector<int>> g(n);
    rep(i,m) {
        int a,b; cin>>a>>b; --a,--b;
        g[a].push_back(b); g[b].push_back(a);
    }
    vector<bool> vi(n);
    int ans = 0;
    rep(i,n) {
        if (vi[i]) continue;
        ll x = h[i];
        bool ok = true;
        for (auto &&e: g[i]) {
            if (x <= h[e]) {
                ok = false;
                break;
            }
        }
        if (ok) ans++;
    }
    cout << ans << '\n';
    return 0;
}

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

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

    int len1 = s.length();
    int len2 = (len1-1)/2;
    int len3 = (len1+3)/2;

    int flag = 1;

    for(int i=0;i < len1 ;i++){
        if(s[i] != s[len1-i-1]){
            flag = 0;
            break;
   }

   for(int i=0;i<len2;i++)
   {
       if(s[i] != s[len2-i-1])
        flag = 0; break;
   }
   for(int i=len3;i<len1;i++)
   {
       if(s[i] != s[len1-1-i])
        flag = 0;break;
   }


}
   if(flag)cout<< "Yes"<<endl;
   else cout<< "No"<<endl;



}


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

int main() {
  int K;
  string S;
  cin >> K >> S;
  if (S.size() <= K)
    cout << S << endl;
  else {
    for (int i = 0; i < K; ++i) cout << S[i];
    cout << "..." << endl;
  }
}

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

void Main()
{
    int a, b;
    cin >> a >> b;
    if(a>b) swap(a, b);
    for (int i = 0; i < b; i++)
    {
        cout << a;
    }
    cout << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3636
// In the name of Allah

#include <bits/stdc++.h>

#define err(A) cout << (A) << " = " << #A << endl

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i) {
        int tmp;
        cin >> tmp;
        a[i] = tmp - 1;
    }
    int b[n];
    bool ok = false;
    for (int i = 0; i < n; i++) {
        int cnt = n - i -1;
        ok = false;
        for (int j = n - 1; j >= 0 && cnt >= 0; j--) {
            if (cnt == a[j]) {
                ok = true;
                b[n-i-1] = cnt;
                a[j] = -1;
            } else if (a[j] != -1) {
                cnt --;
            }
        }
        if (!ok)
            break;
    }
    if (ok) {
        for (int i = 0; i < n; i++) {
            cout << b[i]+1 << endl;
        }
    } else
        cout << "-1" << endl;
    return 0;
}

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

int main(void){
    int n, m, a[55], b[55], c[55], d[55], minnum, dist = 0;
  	long long min = 400000001;
    cin >> n >> m;
    
    for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
    for (int i = 1; i <= m; i++) cin >> c[i] >> d[i];
    
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (a[i] > c[j]) dist += a[i] - c[j];
            else dist += c[j] - a[i];
            if (b[i] > d[j]) dist += b[i] - d[j];
            else dist += d[j] - b[i];
            if (dist < min) {
                min = dist;
                minnum = j;
            }
          	dist = 0;
        }
      	cout << minnum << endl;
        dist = 0;
        min = 1000000000;
    }
    return 0;
}



Measured memory_bytes: 256
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 500005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n;
    cin >> n;
    double d = n / 2;
    if( n % 2 ) d += 1;
    cout << d / n << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
class Main{
	public static void main(String[]args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c[]=new int[b];
		for(int i=0;i<b;i++) {
			c[i]=sc.nextInt();
		}
		Arrays.sort(c);
		c[b-1]--;
		for(int i=b-2;i>=0;i--) {
			c[b-1]-=c[i];
		}
		System.out.println(c[b-1]<0?"0":c[b-1]);
	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<deque>
#include<stdlib.h>
//#include <algorithm>
#include<set>
#include <limits>
#include<iomanip>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_5 100000
#define d9_7 1000000007
int main(void){
  ll n,k;
  cin >> n>>k;
  vector<ll> a(n,0);
  ll tmp;
  rep(i,n){
    cin>>a[i];
  }
  ll sum=0;
  ll msum=0;
  rep(i,k){
    msum+=a[i];
  }
  if(n==k){
    cout<<max((ll)0,msum);
    return 0;
  }
  ll rsum=0;
  rep(i,n-k){
    rsum+=max((ll)0,a[k+i]);
  }
  ll lsum=0;
  rep(i,n-k){
    msum-=a[i];
    msum+=a[k+i];
    if(a[i]>0){
      lsum+=a[i];
    }
    if(a[i+k]>0){
      rsum-=a[i+k];
    }
    sum=max(sum,max(msum,(ll)0)+rsum+lsum);
  }
  cout<<sum;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <math.h>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <numeric>
#include <bits/stdc++.h>

#define int long long

struct edge {
    int to;
    int cost;
};

using namespace std;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vb = vector<bool>;
using qi = queue<int>;
using P = pair<int, int>;
using graph = vector<vector<edge>>;
// using graph = vector<vector<int>>;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define delim(i, n) cout << (i == n-1 ? "\n" : " ");

const int inf = 1LL << 60;
// const int inf = 100000000;
const int mod = 1000000007;

const int maxn = 100001;
int n;
vi visited(maxn);

bool isPrime(int n) {
    if (n == 2 || n == 3) return true;
    if (n == 1 || n%2 == 0 || n%3 == 0) return false;
    int sn = sqrt(n);
    int divisor = 5;
    while(divisor <= sn) {
        if (n%divisor == 0) return false;
        if (n%(divisor+2) == 0) return false;
        divisor += 6;
    }
    return true;
}

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

    visited.assign(maxn, 0);
    set<int> prime;
    vi like(maxn, 0);

    prime.insert(2);
    prime.insert(3);
    like[3] = 1;
    for(int i = 5; i < maxn; i+=2) {
        bool flag = isPrime(i);
        if (flag) prime.insert(i);
        if (flag && prime.count((i+1)/2)) like[i] = 1;
    }

    vi likesum(maxn, 0);
    REP(i, maxn-1) {
        likesum[i+1] = likesum[i] + like[i];
    }

    cin >> n;
    REP(i, n) {
        int l, r; cin >> l >> r;
        cout << likesum[r+1] - likesum[l] << "\n";
    }
}

Measured memory_bytes: 6064
n = int(raw_input())
s = []
t = []
for i in range(n):
	s.append(str(raw_input()))
m = int(raw_input())
for i in range(m):
	t.append(str(raw_input()))
s_uni = list(set(s))
count = 0
for i in range(len(s_uni)):
	tmp = s.count(s_uni[i]) - t.count(s_uni[i])
	count = max(count, tmp)
print count

Measured memory_bytes: 2568
n,k,q=map(int,input().split())
a=[]
for _ in range(q):
  a.append(int(input()))

points = [k]*(n+1)
plus = [0]*(n+1)
for i in range(q):
  plus[a[i]] += 1

for i in range(1,n+1):
  points[i] = points[i] - q + plus[i]
  if points[i] >= 1:
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 17656
a = list(map(int, input().split()))
S = input()
alis = list(S)
if alis[a[1]-1] == 'A':
    alis[a[1]-1] = 'a'
elif alis[a[1]-1] == 'B':
    alis[a[1]-1] = 'b'
else:
    alis[a[1]-1] == 'C'
    alis[a[1]-1] = 'c'

str_changed = "".join(alis)
print(str_changed)


Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var xy = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var sx = xy[0];
        var sy = xy[1];
        var tx = xy[2];
        var ty = xy[3];
        var yoko = tx - sx;
        var tate = ty - sy;
        var yokoAbs = Math.Abs(yoko);
        var tateAbs = Math.Abs(tate);
        var list = new List<char>();
        for (int i = 0; i < yokoAbs; ++i)
        {
            if (yoko < 0) list.Add('L');
            else list.Add('R');
        }
        for (int i = 0; i < tateAbs; ++i)
        {
            if (tate < 0) list.Add('D');
            else list.Add('U');
        }
        for (int i = 0; i < yokoAbs; ++i)
        {
            if (0 < yoko) list.Add('L');
            else list.Add('R');
        }
        for (int i = 0; i < tateAbs; ++i)
        {
            if (0 < tate) list.Add('D');
            else list.Add('U');
        }
        if (0 < tate) list.Add('D');
        if (tate < 0) list.Add('U');
        for (int i = 0; i < yokoAbs + 1; ++i)
        {
            if (yoko < 0) list.Add('L');
            else list.Add('R');
        }
        for (int i = 0; i < tateAbs + 1; ++i)
        {
            if (tate < 0) list.Add('D');
            else list.Add('U');
        }
        if (0 < yoko) list.Add('L');
        if (yoko < 0) list.Add('R');
        if (0 < tate) list.Add('U');
        if (tate < 0) list.Add('D');
        for (int i = 0; i < yokoAbs + 1; ++i)
        {
            if (yoko < 0) list.Add('R');
            else list.Add('L');
        }
        for (int i = 0; i < tateAbs + 1; ++i)
        {
            if (tate < 0) list.Add('R');
            else list.Add('D');
        }
        if (0 < yoko) list.Add('R');
        if (yoko < 0) list.Add('L');
        foreach (var l in list) Console.Write(l);
        Console.WriteLine();
    }
}

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

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

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;

  cout << s1[0] << s2[1] << s3[2] << endl;
  return 0;
}


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

static const int mx[] = {1, 0, -1,  0};
static const int my[] = {0, 1,  0, -1};
static const char cheese_arr[] = {"123456789"};

static const int MAX_MAP_X = 1001;
static const int MAX_MAP_Y = 1001;

static bool visited[MAX_MAP_Y - 1][MAX_MAP_X - 1];

struct MOUSE
{

	int x;
	int y;
	int cnt;

};

int main()
{

	int W, H, N;
	int ans = 0, now_search = 0;
	char MAP[MAX_MAP_Y][MAX_MAP_X];
	bool brkFlg = false;
	queue<MOUSE> search_cheese;

	cin >> H >> W >> N;
	for(int i = 0; i < H; i++) {
		cin >> MAP[i];
		for(int j = 0; j < W || !brkFlg; j++) {
			if(MAP[i][j] == 'S') {
				MOUSE in;
				in.x = j;
				in.y = i;
				in.cnt = 0;
				memset(visited, false, sizeof(visited));
				search_cheese.push(in);
				brkFlg = true;
			}
		}
	}

	brkFlg = false;

	while(!brkFlg) {
		MOUSE next, mouse_info = search_cheese.front();
		search_cheese.pop();
		for (int i = 0; i < 4; i++) {
			int nx = mouse_info.x + mx[i];
			int ny = mouse_info.y + my[i];
			if (nx > -1 && nx < W && ny > -1 && ny < H) {
				if (MAP[ny][nx] == cheese_arr[now_search]) {
					ans += mouse_info.cnt + 1;
					now_search++;
					if(now_search == N) {
						brkFlg = true;
						break;
					}
					while(!search_cheese.empty()) search_cheese.pop();
					mouse_info.x = nx;
					mouse_info.y = ny;
					mouse_info.cnt = 0;
					memset(visited, false, sizeof(visited));
					search_cheese.push(mouse_info);
				}
				else if(MAP[ny][nx] != 'X' && !visited[ny][nx]) {
					next = mouse_info;
					next.x = nx;
					next.y = ny;
					next.cnt++;
					visited[ny][nx] = true;
					search_cheese.push(next);
				}
			}
		}
	}

	cout << ans << endl;

	return 0;

}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;
    cin >> N;

    ll count = 0;
    REP(i, N){
        ll k = log10(i+1);
        if( (k % 2) == 0 ) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
#define MAXN 1000000007
 
 
int main() {
	ll w,h,x,y,r;
	cin>>w>>h>>x>>y>>r;
	if (((((x+r)<=w) and (x>=r)) and ((y+r)<=h)) and (y>=r)) {
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e18

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll x[3];
	for(int i = 0; i < 3; i++){
		cin >> x[i];
	}
	sort(x,x+3);
	ll ans  = 0;
	while(x[0]+2<=x[2]){
		x[0]+=2;
		ans++;
	}
	while(x[1]+2<=x[2]){
		x[1]+=2;
		ans++;
	}
	sort(x,x+3);
	if(x[0]!=x[1]){
		ans+=2;
		cout << ans;
		return 0;
	}
	else{
		if(x[1]==x[2]){
			cout << ans;
			return 0;
		}
		else{
			ans++;
			cout << ans;
			return 0;
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main(){ _;
  string s;
  while(getline(std::cin,s),s!="."){
    bool ok=true;
    stack<char> brackets;
    for(char c:s){
      if(c=='['){
	brackets.push('[');
      }else if(c==']'){
	if(!brackets.empty()&&brackets.top()=='[') brackets.pop();
	else{ok=false;break;}
      }
      else if(c=='('){
	brackets.push('(');
      }else if(c==')'){
	if(!brackets.empty()&&brackets.top()=='(') brackets.pop();
	else{ok=false;break;}
      }
    }
    cout<<(ok&&brackets.empty()?"yes":"no")<<endl;
  }
}

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

int main() 
{
	while (1) {
		int JOI, IOI; JOI = IOI = 0;
		string a;
		cin >> a;
		if (cin.fail())break;
		for (int b = 0; b < (a.length()-2); b++)
		{
			if (a[b] == 'J' || a[b] == 'I')
			{
				if (a[b + 1] == 'O'&&a[b + 2] == 'I')
				{
					if (a[b] == 'J') { JOI++; }
					else { IOI++; }
				}
			}
		}
		cout << JOI << endl << IOI << endl;
	}
}

Measured memory_bytes: 3092
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    string s;
    cin >> s;

    if (s == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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


const int MAX = 1000000;
//bool is_prime[MAX + 10];
//
int memo[MAX + 10];
int key(int n)
{
	//if (is_prime[n])
	//	return n;
	if (~memo[n])
		return memo[n];

	int sum = 0, last;
	for (int i = 2; i <= n; ++i)
	{
		if (n % i == 0)
		{
			sum += i, last = i;
			while (n % i == 0)
				n /= i;
		}
	}
	return memo[n] = 2*last - sum;
}
int main()
{
	//fill_n(is_prime, MAX, true);
	//for (int i = 2; i*i <= MAX; ++i)
	//	if (is_prime[i])
	//		for (int j = 2*i; j <= MAX; j += i)
	//			is_prime[j] = false;

	fill_n(memo, MAX, -1);
	int a, b;
	while (scanf("%d%d", &a, &b), a | b)
		puts(key(a) > key(b) ? "a" : "b");
}

Measured memory_bytes: 4744
import java.io.PrintWriter;
import java.util.Deque;
import java.util.ArrayDeque;
import java.util.Scanner;

class Main{

    static int K;
    static int N;

    static void dec(Deque<Integer> list){
        //毎回N桁目から見ているから遅い
        if(list.peekLast()==1)list.pollLast();
        else{
            list.addLast(list.pollLast()-1);
            while(list.size()<N)list.addLast(K);
        }
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        K = scan.nextInt();
        N =scan.nextInt();
        Deque<Integer> ans = new ArrayDeque<>();
        if(K%2==0){
            ans.add(K/2);
            while(N-->1)ans.add(K);
        }else{
            for(int i=0;i<N;++i)ans.add((K+1)/2);
            for(int i=0;i<(N/2);++i)dec(ans);
        }
        PrintWriter pw = new PrintWriter(System.out);
        StringBuffer sb = new StringBuffer();
        for(int i : ans)if(i!=0)sb.append(i+" ");
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 59976
# coding: utf-8
# Your code here!
import sys

k = int(input())
a = list(map(int,input().split()))[::-1] 
x=2
y=2
if a[0]!=2:
    print(-1)
    sys.exit(0)

for t in a:
    x=((x-1)//t+1)*t
    y=y//t*t+t-1
    #print(x,y) 

if x > y:
    print(-1)
    sys.exit(0)
print(str(x)+" " + str(y)) 

Measured memory_bytes: 14252