akhauriyash/Code-Regression huggingface dataset:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

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())

def two_unb(s: str) -> bool:
    judge = False
    st, ed = -1, -1

    for i in range(len(s)-1):
        if len(set(s[i:i+2])) < 2:
            judge = True
            st, ed = i, i+1

            return judge, (st, ed)

    return judge, (st, ed)

def thr_unb(s: str) -> bool:
    judge = False
    st, ed = -1, -1

    for i in range(len(s)-2):
        if len(set(s[i:i+3])) < 3:
            judge = True
            st, ed = i, i+2

            return judge, (st, ed)

    return judge, (st, ed)


s = ns()

jdg2, (st2, ed2) = two_unb(s)
jdg3, (st3, ed3) = thr_unb(s)

if jdg2:
    print(st2+1, ed2+1)

elif jdg3:
    print(st3+1, ed3+1)

else:
    print(-1, -1)


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

LL modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}

void Main()
{
    int a,b;
    cin >> a >> b;

    if(a>=b){
        REP(i,a){
            cout << b;
        }
    }
    else{
        REP(i,b){
            cout << a;
        }
    }

    cout << endl;

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> books[10];
int sale[10][2001],dp[11][2001];
int main() {
	int N,K;
	scanf("%d %d",&N,&K);
	for(int i=0;i<N;i++) {
		int C,G;
		scanf("%d %d",&C,&G);
		books[G-1].push_back(C);
	}
	for(int i=0;i<10;i++) 
		sort(books[i].rbegin(),books[i].rend());
	for(int i=0;i<10;i++) {
		int sum=0;
		for(int j=1;j<=books[i].size();j++) {
			sale[i][j]=(sum+=books[i][j-1])+j*(j-1);
		}
	}
	for(int i=0;i<10;i++) {
		for(int j=0;j<=K;j++) {
			for(int k=0;k<=min(j,(int)books[i].size());k++) {
				dp[i+1][j]=max(dp[i+1][j],dp[i][j-k]+sale[i][k]);
			}
		}
	}
	printf("%d\n",dp[10][K]);
}

Measured memory_bytes: 1192
/*
g++ -std=c++11 -o2 -Wall ABC080C.cpp -o ./out/ABC080C.out
./out/ABC080C.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

constexpr ll INF = 10000000000000000;

int n;
bool f[105][10];
int p[105][10];

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll ans = -10000000000000000;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 5; ++j) {
      for (int k = 0; k < 2; ++k) {
        int a;
        cin >> a;
        f[i][j * 2 + k] = a;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= 10; ++j) {
      cin >> p[i][j];
    }
  }
  ll temp;
  int count;
  for (int i = 1; i < (1 << 10); ++i) {
    temp = 0;
    for (int j = 0; j < n; ++j) {
      count = 0;
      for (int k = 0; k < 10; ++k) {
        if ((i >> k) & 1) {
          count += f[j][k];
        }
      }
      temp += p[j][count];
    }
    ans = max(ans, temp);
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int c = Integer.parseInt(in.next());
            int ans = 0;

            if (a % 2 == 0 && b % 2 == 0 && c % 2 == 0 && a == b && b == c && a == c) {
                out.println(-1);
                return;
            }

            while (true) {
                if (a % 2 != 0 || b % 2 != 0 || c % 2 != 0) break;
                int take_a = a / 2;
                int take_b = b / 2;
                int take_c = c / 2;

                a = take_a + take_c;
                b = take_b + take_a;
                c = take_c + take_b;
                ans++;

            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 21844
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

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

string A, S, C;

int main(int argc, const char * argv[]) {
  cin >> A >> S >> C;
  cout << A[0] << S[0] << C[0] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

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

    int A[N];
    for(int i=0; i<N; i++){
        cin >> A[i];
        A[i] = A[i] - (i+1);
    }

    sort(A, A+N);
    int b = (N+1)/2 - 1 ;

    ll ans = 0;
    for(int i=0; i<N; i++){
        ans = ans + abs(A[i] - A[b]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(){
    long long n = 0;
    long long kaimono = 0;
    long long goukei = 0;
    int i;
    scanf("%lld",&n);
    for (i = 0; i < n; i++) {
        scanf("%lld",&kaimono);
        goukei = goukei + kaimono;
    }
    printf("%lld\n",goukei / n);
    return (0);
}

Measured memory_bytes: 596
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc = new Scanner(System.in);
	int a, b, c, x, y;
	public void run(){
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		x = sc.nextInt();
		y = sc.nextInt();
		solve();
	}
	
	int memo[][];
	
	public void solve(){
		int ans = 0;
		
		System.out.println(ret(x, y, 0));
		
	}
	
	public int ret(int xx, int yy, int sum){
		if(xx == 0 && yy == 0){
			return sum;
		}
		else if(xx == 0){
			if(b <= 2 * c){
				return ret(xx, 0, sum + b*yy);
			}
			else{
				return ret(xx, 0, sum + 2*c*yy);
			}
		}
		else if(yy == 0){
			if(a <= 2*c){
				return ret(0, yy, sum + a*xx);
			}
			else{
				return ret(0, yy, sum + 2*c*xx);
			}
		}
		else{
			int val = 0;
			if(a+b < 2*c){
				val = a+b;
			}
			else{
				val = 2*c;
			}
			
			if(xx < yy){
				return ret(0, yy - xx, sum + (val * xx));
			}
			else{
				return ret(xx-yy, 0, sum + (val * yy));
			}
		}
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
	static class Pair {
        int first,second;
        public Pair(int a,int b) {
            this.first = a;
            this.second = b;
        }
    }	
}


Measured memory_bytes: 23252
use std::io::*; //Not mine.
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let mut n:usize = s.len() - 2;
    let mut ans = 0;
    while ans == 0 {
        let ss = &s[0..n / 2 - 1];
        let tt = &s[n / 2..n - 1];
        if ss == tt {
            ans = n;
            break;
        }
        n -= 2;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
  int N;
  cin >> N;
   for(int i=0;N>0;i++){
     N -= 1000;
   }
  N *= -1;
  cout << N << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#ifndef LOCAL
struct ostdmy{template<class T>ostdmy&operator<<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(const T&i:v)o<<i<<' ';return o;}
bool starts_with(const string&ptn, const string&subj, const int start){
    int l=subj.size();
    REPA(i,ptn){
        if(start+i>=l)return false;
        if(ptn[i]!=subj[start+i])return false;
    }
    return true;
}
const string pts[]={
    "maerd",
    "remaerd",
    "esare",
    "resare"
};
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    string s;
    cin>>s;
    reverse(all(s));
    int p=0;
    int l=s.size();
    bool flag;
    while(p<l){
        flag=false;
        REP(i,4){
            if(starts_with(pts[i], s, p)){
                p+=pts[i].size();
                flag=true;
                break;
            }
        }
        if(!flag){
            YES(0);
            return 0;
        }
    }
    YES(1);
    return 0;
}


Measured memory_bytes: 512
n,m,k = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
b = sum(B)
ka = k
i = m
c = 0
re = 0
A.insert(0, 0)
for a in A:
  ka -= a
  if ka < 0:
    break
  while ka < b and i > 0:
    i -= 1
    b -= B[i]
  c += 1
  re = max(re, c+i)

  
print(re-1)  

Measured memory_bytes: 40544
#include <stdio.h>

int main(){
	int a;
	scanf("%d",&a);
	if(a < 1200){
		printf("ABC\n");
	}
	else if(a >= 1200 && a < 2800){
		printf("ARC\n");
	}
	else if(a >= 2800){
		printf("AGC\n");
	}
	return 0;
}

Measured memory_bytes: 128
N,D = map(int,input().split())

def hoge(n,d):
    if 0 >= n:
        return 0
    if d * 2 + 1 >= n:
        return 1
    return 2 + hoge(n - (d * 2 + 1)*2,d)

print(hoge(N,D))

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

int main(){
  int n; cin >> n;
  for(int i=0; i<n; ++i){
    int x; cin >> x;
    if(x%2==0 && x%3!=0 && x%5!=0){
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int N;
    cin >> N;
    if (N == 1){
        cout << "Yes" << endl;
        cout<<"2"<<endl<<"1 1"<<endl<<"1 1";
        return 0;
    }
    int k = -1;
    for (int kk = 1; kk <= N; kk++) {
        if (kk * (kk - 1) / 2 == N) {
            k = kk;
            break;
        }
    }
    if (k == -1) {
        cout << "No" << endl;
        return 0;
    }
    
    cout << "Yes" << endl;
    cout << k << endl;
    queue<int> Num;
    rep(i, N) { Num.push(i + 1); }

    vector<vector<int>> S(k, vector<int>(0));

    queue<pair<int, int>> sequence{};
    for (int length = 1; length <= N - 1; length++) {
        for (int left = 0; left <= k - 1; left++) {
            int right = left + length;
            if (right >= k) {
                break;
            } else {
                sequence.push({left, right});
            }
        }
    }

    while (!Num.empty()) {
        int num = Num.front();
        Num.pop();
        int a, b;
        tie(a, b) = sequence.front();
        sequence.pop();
        S[a].push_back(num);
        S[b].push_back(num);
    }
    for (int i = 0; i < k; i++) {
        cout << k - 1 << " ";
        for (auto x : S[i]) {
            cout << x << " ";
        }
        cout << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
    int h,n;

    cin >> h >> n;

    int sum = 0;

    for(int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        sum+=tmp;
    }

    if(sum>=h) {
        cout << "Yes" <<endl;
    }else{
        cout << "No" << endl;       
    }

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
 
int main(){
    long N,M; cin>>N>>M;
    vector<int> ship(N);
    for(int i=0;i<M;i++){
        int j,k; cin>>j>>k;
        if(j==1)ship.at(k-1)++;
        if(k==N)ship.at(j-1)++;
    }
    for(int i=0;i<N;i++){
        if(ship.at(i)==2){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
       cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 1024
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,k = map(int, input().split())
    s = list(input().rstrip())
    res = ''
    for i in range(n):
        if i == k-1:
            res += s[i].lower()
        else:
            res += s[i]
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		int n = Integer.parseInt(br.readLine());

		if (n % 1000 == 0) {
			System.out.println("0");
		} else {
			int b = 1000 - (n % 1000);
			System.out.println(b);
		}
	}
}

Measured memory_bytes: 32412
# coding: utf-8
class Case01

  def initialize
  end

  def show
    p self.instance_variables
        .map{ |sym| [sym, self.instance_variable_get(sym)] }
        .to_h
  end
  
  # 実行する
  def execute
    read
    solve
    output
  end

  # 読込
  def read
    @s = gets.chomp
  end

  # 回答
  def solve
    @result = (@s <= '2019/04/30')
  end
  
  # 出力
  def output
    puts @result ? 'Heisei' : 'TBD'
  end

end

# 
Case01.new.execute

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

int Sum(int n){
    int sum=0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}

int main() {
    int n;
    cin>>n;
    int s=Sum(n);
    if(n%s==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue(){
  P x;
  x = Q[head];
  head = (head + 1) % LEN;
  return x;
}


int main(){
  int elaps = 0,c = 0;
  int i, q;
  P u;

  scanf("%d %d", &n, &q);
  head = 0;
  tail = n;

  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  while(c != n){
     u = dequeue();
     if(u.t - q <= 0){
        elaps += u.t;
        printf("%s %d\n",u.name,elaps);
	c++;
      }
      else{
	u.t -= q;
	elaps += q;
        enqueue(u);
      }
  }
  return 0;
}



Measured memory_bytes: 11864
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.{NumericRange, Queue}
import scala.collection.mutable
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val N = sc.nextInt
    val begin = (BigInt(1) to N + 2).product - N - 1
    println(begin)
    for (i <- Range(0, N)) {
      println(N - i + 1)
    }
  }

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}


Measured memory_bytes: 48888
#include <iostream>
using namespace std;
int main() {
    int a, b, c;
    cin >> a;
    cin >> b;
    cin >> c;
    if (a-b<0&&b-c<0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
  
	return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  bool flag = true;
  rep(i, s.size()){
    if (i % 2 == 0) {
      if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D'){
        continue;
      } else {
        flag = false;
      }
    } else {
      if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D'){
        continue;
      } else {
        flag = false;
      }
    }
  }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define ci(x) cin >>x
#define co(x) cout<<x<<endl
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
 ll N;
   ll M;
  cin >>N>>M;
  vl P(M);
  vl Y(M);
  rep(i,M) {
    cin >>P.at(i)>>Y.at(i);
  }
  
vector<pair<pl,pl>> pp(M);
  
  
  rep(i,M) {
    pp.at(i).first.first=P.at(i);
    pp.at(i).first.second=Y.at(i);
    pp.at(i).second.first=i;
  }
  
  sort(all(pp));
 
  rep(i,M) {
    
    pp.at(i).second.second=i;
    
  }
 
  
  vector<pair<pl,pl>> ppp(M);
  rep(i,M) {
    ppp.at(i).first.first=pp.at(i).first.first;
    ppp.at(i).first.second=pp.at(i).first.second;
    ppp.at(i).second.first=pp.at(i).second.first;
  }
  
  ll count=1;
  ppp.at(0).second.second=1;
 rep(i,M-1) {
   if(ppp.at(i).first.first==ppp.at(i+1).first.first) {
     count++;
     ppp.at(i+1).second.second=count;
     
   }
   if(ppp.at(i).first.first!=ppp.at(i+1).first.first) {
     ppp.at(i+1).second.second=1;
     count=1;
   }
 }
  
  
  vector<pair<pl,pl>> ps(M);
  
  rep(i,M) {
    
    ps.at(i).first.first=ppp.at(i).second.first;
     ps.at(i).first.second=ppp.at(i).first.second;
     ps.at(i).second.first=ppp.at(i).first.first;
     ps.at(i).second.second=ppp.at(i).second.second;
  }
  sort(all(ps));
  
  rep(i,M) {
 std::cout << std::setfill('0') << std::right << std::setw(6) << ps.at(i).second.first;
 std::cout << std::setfill('0') << std::right << std::setw(6) << ps.at(i).second.second;
    cout<<endl;
  }
  
  
}
  

Measured memory_bytes: 12416
#include<cstdio>

using namespace std;

int main(){
	int n, k; scanf("%d %d", &n, &k);
	int res = 1;
	for(int i = 0; i < n; i++){
		if(res * 2 <= res + k) res *= 2;
		else res += k;
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
t = [0] * N
x = [0] * N
y = [0] * N
for i in range(N):
    t[i], x[i], y[i] = map(int, input().split())
t.insert(0, 0)
x.insert(0, 0)
y.insert(0, 0)

flag = True
for i in range(N):
    if (t[i+1]-t[i])%2 != (x[i+1]-x[i]+y[i+1]-y[i])%2:
        flag = False
        break
    elif t[i+1]-t[i] < x[i+1]-x[i]+y[i+1]-y[i]:
        flag = False
        break

if flag == True:
    print("Yes")
else:
    print("No")

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

int main()
{
	char c[2][4];
	int i, j, cnt = 1;

	/*for (i = 0; i < 2; i++)
		for (j = 0; j < 3; j++)
			scanf("%c", &c[i][j]);*/
	for (i = 0; i < 2; i++)
		scanf("%s", c[i]);

	for (i = 0; i < 3; i++)
		if (c[0][i] != c[1][2 - i])
			cnt = 0;

	if (cnt)
		printf("YES\n");
	else
	printf("NO\n");

	return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()

def resolve():
    n = int(input())
    WSV = [tuple(map(int, input().split())) for _ in range(n)]
    WSV.sort(key = lambda tup:tup[0] + tup[1])

    # dp[i][w] : i 番目まで見て、total weight が w のときの max value
    # solid_max <= 10^4 なので、total weight > 10^4 は考えなくて良い
    res = 0
    solid_max = 10 ** 4
    dp = [-1] * (solid_max + 1)
    dp[0] = 0

    for w0, s0, v in WSV:
        for w in range(solid_max, -1, -1):
            if dp[w] == -1:
                continue
            if w > s0: # w <= s0
                continue
            if w + w0 > solid_max:
                res = max(res, dp[w] + v)
            else:
                dp[w + w0] = max(dp[w + w0], dp[w] + v)

    res = max(res, max(dp))
    print(res)
resolve()

Measured memory_bytes: 41072
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <limits>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define print_double(val,a) cout << fixed << setprecision(a) << val << endl;
ll mod = 1e9 + 7;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string a;
	cin>>a;
	int ans=0;
	rep(i,4){
		if(a[i]=='+'){ans+=2;}
		ans--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()



void next(string s[], char num){
    /*
    cout << s[0] << endl;
    cout << s[1] << endl;
    cout << s[2] << endl;
    cout << "--------" << endl;
    */
    if(s[num].size() == 0){
        cout << char(num + 'A') << endl;
    }
    else{
        char p = s[num][0] - 'a';
        s[num].erase(s[num].begin());
        next(s, p);
    }
}

int main(){

    string s[3];
    cin >> s[0] >> s[1] >> s[2];

    next(s, 0);
}


Measured memory_bytes: 256
import java.util.*;
public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int p;
		int[] a = new int[n];
		for(int i=0; i<a.length; i++)
		{
			p = sc.nextInt();
			a[p-1] = i+1;

		}
		for(int i=0; i<a.length; i++)
		{
			System.out.println(a[i]);
		}


	}
}

Measured memory_bytes: 59392
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

#define MAX_N 2000005
ll inv[MAX_N], fac[MAX_N], finv[MAX_N];
void make() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i=2; i<MAX_N; i++) {
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    fac[i] = fac[i-1] * (ll)i % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}
ll perm(ll n, ll r) {
  if(n < 0)       return 0;
  else if(n < r)  return 0;
  else            return (fac[n] * finv[n-r]) % mod;
}
ll comb(ll n, ll r) {
  ll ans = 1;
  ans = perm(n, r);
  ans = (ans * finv[r]) % mod;
  return ans;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  make();
  int n, k; cin >> n >> k;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  sort(all(A));
  ll ans = 0;
  rep(i, n) {
    (ans += (A[i]+mod)%mod * comb(i, k-1)%mod) %= mod;
    (ans += (-A[i]+mod)%mod * comb(n-i-1, k-1)%mod) %= mod;
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 50944
import java.util.Scanner;

class Main{
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    long input_n = Long.parseLong(scanner.next());
    long input_s = Long.parseLong(scanner.next());
    scanner.close();

    boolean isFound = false;
    if(input_n == input_s){
      System.out.println(input_n+1);
      isFound = true;
    }else{
      for(int i=2; i<=Math.pow(input_n, 0.5); i++){
        if(input_s == merge(i, input_n)){
          System.out.println(i);
          isFound = true;
          break;
        }
      }
      if(!isFound){
        for(int i=(int)Math.pow(input_n, 0.5); i>0; i--){
          if((input_n-input_s)%i==0 && (int)Math.pow(input_n, 0.5)<(input_n-input_s)/i+1){
            if(input_s == merge((input_n-input_s)/i+1, input_n)){
              System.out.println((input_n-input_s)/i+1);
              isFound = true;
              break;
            }
          }
        }
      }
    }
    if(!isFound){
      System.out.println(-1);
    }
  }

  private static long merge(long exp, long n){
    if(n < exp){
      return n;
    }else{
      return merge(exp, n/exp) + n%exp;
    }
  }
}


Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}


int n,ans[150000];

void solve(int l, int r, int s, int t, int c){
	int i,x=-1,m;
	if(r-l==2){
		ans[l] += s;
		ans[l+1] += t;
		return;
	}
	for(i=0; i<n; ++i){
		if(c&(1<<i)){
			continue;
		}
		if((s&(1<<i))^(t&(1<<i)) && x<0){
			x = i;
		}else{
			m = s^(1<<i);
		}
	}
	if(s&(1<<x)){
		for(i=l; i<(l+r)/2; ++i){
			ans[i] += (1<<x);
		}
	}else{
		for(i=(l+r)/2; i<r; ++i){
			ans[i] += (1<<x);
		}
	}
	s -= (s&(1<<x));
	t -= (t&(1<<x));
	m -= (m&(1<<x));
	c += (1<<x);
	solve(l,(l+r)/2,s,m,c);
	solve((l+r)/2,r,m,t,c);
}

int main(void){
	int i,a,b,m,p=0,q=0;
	cin >> n >> a >> b;
	m = (1<<n);
	for(i=0; i<n; ++i){
		if(a&(1<<i)){
			++p;
		}
		if(b&(1<<i)){
			++q;
		}
	}
	if(!((p%2)^(q%2))){
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
	solve(0,m,a,b,0);
	for(i=0; i<m; ++i){
		cout << ((i)?" ":"") << ans[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define mo 998244353
#define ll long long
using namespace std;
ll A,B,C,D,ans,dp[3010][3010][2];
void add(ll &x,ll y){x=(x+y)%mo;}
int main(){
	cin>>A>>B>>C>>D;
	dp[A][B][0]=1;
	for (ll i=A;i<=C;i++){
		for (ll j=B;j<=D;j++){
			add(dp[i][j+1][1],(dp[i][j][1]+dp[i][j][0])*i);
			add(dp[i+1][j][0],dp[i][j][0]*j+dp[i][j][1]);
		}
	}
	cout<<(dp[C][D][0]+dp[C][D][1])%mo<<endl;
	return 0;
}

Measured memory_bytes: 144604
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>

using namespace std;

int main() {
	int N, M, ans, pow[6];
	scanf("%d %d", &N, &M);
	pow[1] = 2;
	pow[2] = 4;
	pow[3] = 8;
	pow[4] = 16;
	pow[5] = 32;

	printf("%d\n", pow[M] * (100 * N + 1800 * M));

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000000000000
using ll=long long;
using P=pair<ll,int>;
using vi=vector<int>;

int H,W;
int idx(int a, int b){return a*W+b;}
struct node{
    vector<int> to;
    ll min_cost;
    node(){
        min_cost=INF;
    }
};
ll dijkstra(int start_index,vector<node> nodes){
    priority_queue<P,vector<P>,greater<P>> q;
    nodes[start_index].min_cost=0;
    q.push(P(0,start_index));
    ll max_cost=0;
    while (q.size()!=0)
    {
        P p=q.top();
        q.pop();
        int v=p.second;
        if(nodes[v].min_cost<p.first)continue;
        max_cost=max(max_cost,p.first);
        for (int i = 0; i < nodes[v].to.size(); i++){
            int to=nodes[v].to[i];
            ll tmp_cost=nodes[v].min_cost+1;
            if(nodes[to].min_cost>tmp_cost){
                nodes[to].min_cost=tmp_cost;
                q.push(P(nodes[to].min_cost,to));
            }
        }
    }
    return max_cost;
}

int main() {
    cin>>H>>W;
    vector<node> nodes(H*W);
    vector<bool> is_wall(H*W,false);
    for (int i = 0; i < H*W; i++){
        char c;cin>>c;
        if(c=='#')is_wall[i]=true;
    }
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            int pos=idx(i,j);
            if(!is_wall[pos]){
                for(P move:{P(-1,0),P(1,0),P(0,-1),P(0,1)}){
                    int ni=i+move.first;
                    int nj=j+move.second;
                    if(0<=ni && ni<H && 0<=nj && nj<W){
                        int npos=idx(ni,nj);
                        if(!is_wall[npos]){
                            nodes[pos].to.push_back(npos);
                        }
                    }
                }
            }
        }
    }
    int ans=0;
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            ans=max(ans,(int)dijkstra(idx(i,j),nodes));
        }
    }
    cout<<ans<<endl;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX=10000;
int N, K;
int D[10];

int main() {
  cin >> N >> K;
  for(int i = 0; i < K; ++i) {
    cin >> D[i];
  }
  bool match = true;
  for(int i = N; i <= 100000; ++i) {
    match = true;
    string n = to_string(i);
    for(int j = 0; j < K; ++j) {
      int cnt;
      cnt = count(n.begin(), n.end(), to_string(D[j])[0]);
      if(cnt > 0) {
        match = false;
        break;
      }
    }
    if(match) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;

int main() {
    int N,x; cin >> N >> x;
    vector<int> a(N);
    REP(i,N) cin >> a[i];
    ll ans = 0;
    REP(i,N-1){
        if(a[i] + a[i+1] > x){
            if(a[i] <= x){
                ans += a[i+1] - x+a[i];
                a[i+1] = x - a[i];
            }else{
                ans += a[i+1];
                a[i+1] = 0;
                ans += a[i]-x;
                a[i] = x;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3768
import sys
input = sys.stdin.readline
def print_ans(N, hs):
    """Test Case
    >>> print_ans(4, [6, 5, 6, 8])
    3
    >>> print_ans(5, [4, 5, 3, 5, 4])
    3
    >>> print_ans(5, [9, 5, 6, 8, 4])
    1
    """
    ans = 0
    tmp_max = 0
    for h in hs:
        if h >= tmp_max:
            ans +=1
        tmp_max = max(tmp_max, h)
    print(ans)

if __name__ == '__main__':
    N = int(input().rstrip())
    hs = list(map(int, input().rstrip().split()))
    print_ans(N, hs)


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

int main() {
  ll n;
  int a;
  string ans;
  cin >> n;
  while (n) {
    n--;
    ans += 'a' + n%26;
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
  cin >> n;
  vector<long long>dp(100);
  dp.at(0)=2;
  dp.at(1)=1;
  for(int i=2;i<n+1;i++){
  dp.at(i)=dp.at(i-1)+dp.at(i-2);}
  cout << dp.at(n) <<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N=200000+5;
ll mabs(ll x)
{
    if(x<0) return x*-1;
    return x;
}
ll jf(ll a,ll b,ll c,ll d)
{
    return max(a,max(b,max(c,d)))-min(a,min(b,min(c,d)));
}
int Find(ll a[],int L,int R)
{
    ll k=(a[R]-a[L-1])/2;
    int l=L,r=R;
    while(l<=r)
    {
        int m=(l+r)/2;
        if(a[m]-a[L-1]>=k)
        {
            r=m-1;
        }
        else
        {
            l=m+1;
        }
    }
    if(l-1>=L&&mabs(a[l]-a[L-1]-a[R]+a[l])>mabs(a[l-1]-a[L-1]-a[R]+a[l-1]))
    {
        l--;
    }
    if(l+1<R&&mabs(a[l]-a[L-1]-a[R]+a[l])>mabs(a[l+1]-a[L-1]-a[R]+a[l+1]))
    {
        l++;
    }
    return l;
}
ll a[N],sz[N];
int n;
int main() {
    scanf("%d",&n);
    sz[0]=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        sz[i]=sz[i-1]+a[i];
    }
    ll _min=sz[n];
    for(int i=3;i<=n-1;i++)
    {
        int l1=Find(sz,1,i-1),l2=Find(sz,i,n);
        _min=min(_min,jf(sz[l1],sz[i-1]-sz[l1],sz[l2]-sz[i-1],sz[n]-sz[l2]));
    }
    printf("%lld\n",_min);
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>

using namespace std;

int main(){

    int N,K;cin>>N>>K;

    LL A[N],B[N];
    REP(i,N)cin>>A[i]>>B[i];
    LL ans=0;
    REP(i,N){
        if((A[i]|K)==K)ans+=B[i];
    }

    int root;
    for(int i=30;i>=0;i--){
        if(K>>i&1){
            root=(1<<(i+1))-1;
            break;
        }
    }


    for(int i=30;i>=0;i--){
        int bit;
        if(K>>i&1)bit = (K-(1<<i)|(1<<i)-1);
        else continue;
        LL res=0;
        REP(i,N){
            if((A[i]|bit)==bit)res+=B[i];
        }
        ans = max(res,ans);
    }


    cout<<ans<<endl;

    return 0;
}

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

long long solve(long long N) {
  if (N % 2 == 1) return 0;

  long long res = 0;
  N /= 2;
  while (N) {
    res += N / 5;
    N /= 5;
  }
  return res;
}

int main() {
  long long N;
  cin >> N;
  cout << solve(N) << endl;
}

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

int main()
{
    int n,a,b,c;
    cin>> n;

         a=n/100;
         b=n/10%10;
         c=n%10;

  if (a==c)
    cout <<"Yes";
  else
    cout<< "No";
return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left
N = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
ans = 0
for b in B:
    ans += bisect_left(A, b) * (N - bisect_left(C, b + 1))
print(ans)

Measured memory_bytes: 22720
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);
	int n = sca.nextInt();
	int r = sca.nextInt();
	int ans = 0;
	if(n >= 10) {
		ans = r;
	}
	else {
		ans = r + 100*(10 - n);
	}
	System.out.println(ans);

	// 後始末
	sca.close();
	}
}

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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	
	int temp1 = max(max(a,b),c);
	int temp2 = min(min(a,b),c);
	
	cout << temp1 - temp2 << endl;
}

Measured memory_bytes: 256
N, H = input().strip().split(' ')
N, H =[int(N),int(H)]
L =list()
for i in range(0,N):
    X, Y = input().strip().split(' ')
    X, Y =[int(X), int(Y)]
    L.append([X,Y])

L0 = list()
for i in range(0,N):
    L0.append(L[i][0])

L1 = list()
for i in range(0,N):
    L1.append(L[i][1])

M = max(L0)
L2 = list()

for i in range(0,N):
    if L1[i] > M:
        L2.append(L1[i])

L2 = sorted(L2)
L2.reverse()
count = 0

for i in range(0,len(L2)):
    if H > 0:
        H -= L2[i]
        count += 1
        if H <= 0:
            print(count)

if H > 0:
    if H % M == 0:
        count += H//M
        print(count)
    else:
        count = count + H//M + 1
        print(count)

Measured memory_bytes: 23076
s = map(int,raw_input())
dp = [0] * 2019
count = 0
for j in range(len(s)):
    ndp = [0] * 2019
    ndp[s[j]] += 1
    for k in range(len(dp)):ndp[(10*k + s[j]) % 2019] += dp[k]
    count += ndp[0]
    dp = ndp

print count




Measured memory_bytes: 89268
#include <bits/stdc++.h>
using namespace std;
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

int main() {
    int n, m;
    map<int, int> mp;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int e;
        cin >> e;
        mp[e]++;
    }
    
    cin >> m;
    
    for (int i = 0; i < m; i++) {
        int e;
        cin >> e;
        mp[e]--;
    }
    
    bool ok = true;
    for (const auto &e : mp) {
        ok &= (e.second >= 0);
    }
    
    if (ok) {
        cout << "YES" << '\n';
    } else {
        cout << "NO" << '\n';
    }
    
    return 0;
}

Measured memory_bytes: 11648
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define print_array(ary, size) cout << ary[0]; rep1(i, 1, size - 1) cout << ' ' << ary[i]; cout << endl;
typedef long long ll;
typedef unsigned long long ull;

class DisjointSet {
private:
	vector<int> rank, p;

	void makeSet(int x) {
		p[x] = x;
		rank[x] = 0;
	}
	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			if (rank[x] == rank[y]) rank[y]++;
		}
	}
	int findSet(int x) {
		if (x != p[x]) p[x] = findSet(p[x]);
		return p[x];
	}

public:
	DisjointSet() {}
	DisjointSet(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		rep(i, size) makeSet(i);
	}
	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}
	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}
};

int main()
{
	int n, q, com, x, y;

	cin >> n >> q;

	DisjointSet ds(n);

	rep(i, q) {
		cin >> com >> x >> y;
		if (com == 0) ds.unite(x, y);
		else {
			if (ds.same(x, y)) cout << 1 << endl;
			else cout << 0 << endl;
		}
	}

	return 0;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    string s;cin >> s;
    lint ans=0;
    lint n=SZ(s) + 1;
    vector<lint> v(n),l(n),r(n);

    lint count = 0;
    REP(i,n-1){
        if(s[i]=='<'){
            count += 1;
        }else{
            count = 0;
        }
        l[i+1] = count;
    }
    count = 0;
    IREP(i, n - 1)
    {
        if (s[i] == '>')
        {
            count += 1;
        }
        else
        {
            count = 0;
        }
        r[i] = count;
    }
    /*

    REP(i,n){
        cout << l[i] << " ";
    }
    cout << "\n";
    REP(i, n)
    {
        cout << r[i] << " ";
    }
    */
    REP(i, n)
    {
        v[i] = max(l[i], r[i]);
        ans += v[i];
    }
    /*
    cout <<"\n";
    REP(i, n)
    {
        cout << v[i] << " ";
    }
    cout << "\n";
    */
    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 12548
fn main() {
    let s: Vec<char> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().chars().collect()
    };

    for c in s {
        if c == '7' {
            println!("Yes");
            return;
        }
    }
    println!("No");
}

Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll n, d, ans=0;
	cin >> n >> d;
	for(ll i=1; i<=n; i++){
        ll x, y;
        cin >> x >> y;
        double dist=((ll)x*x)+((ll)y*y);
        dist=sqrt(dist);
        if(dist<=(double)d)
            ans++;
	}
	cout << ans << endl;

	return 0;
}


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

using namespace std;

#define ll long long
#define pb push_back
#define sz size()
#define ff first
#define ss second

ll F(ll N, ll p) {
    ll ret = 0, P = 10LL;
    while(P <= N){
        ret += N/P;
        P *= p;
    }
    return ret;
}

int main() {

    ll n;
    cin >> n;
    if(n % 2) cout << 0 << endl;
    else cout << F(n, 5LL) << endl;

    return 0;
}

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

const ll inf = 1LL << 60;

int main(){ 
  
  ll N,M; cin >> N >> M;
  
  vector<ll> A(N);
  vector<ll> B(N+1);
  
  for(ll i = 0; i < N; i++){ cin >> A[i];}
  
  sort(A.begin(),A.end());
  
  B[N] = 0;
  B[N-1] = A[N-1];
  
  for(ll i = N-2; i >= 0; i--){ 
    B[i] = B[i+1]+A[i];
  }
 
  
  //ソート
  
  ll l = 0; ll r = inf;
  
  while( r - l > 1 ){ 
    
    ll d = l+(r-l)/2;
    
    ll cnt = 0;
    
    for(ll i = 0; i < N; i++){ 
      
      // d-A[i]以上となるような人数を求める
      
      ll itr = lower_bound(A.begin(),A.end(),d-A[i])-A.begin();
      
      cnt += N-itr;
     
      
      
    }
    
   if(cnt >= M){ //　もっと下限を上げていい
      l = d;
    }
    else{
      r = d;
    }
  }
  // 最大の下限l発見
  
  r = l;
  
  ll ans = 0;
  ll howmany = 0;
  
 
  for(ll i = 0; i < N; i++){
    //値がr-A[i](=x)以上となるような要素の和をansにたす
    
    ll x = r-A[i];
    
    ll itr = lower_bound(A.begin(),A.end(),x)-A.begin();
    
    // A[itr],,A[N-1]までの和
    
    if( itr == N ){ continue;}
    
    howmany += N-itr;
    
    ans += B[itr]+A[i]*(N-itr);
      
  }
  
  //howmany-r個分はもっとも小さい要素を除いて調整
  
  
  if( howmany > M){ ans -= r*(howmany-M);}

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

Measured memory_bytes: 1792