akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        A: i64,
        B: i64,
    }
    println!("{}", (A+B)%24);
}

Measured memory_bytes: 4352
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

template<int mod>
struct ModInt {
  int val;
  ModInt inv() const{
    int tmp,a=val,b=mod,x=1,y=0;
    while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
    return ModInt(x);
  }
  ModInt():val(0){}
  ModInt(ll x){if((val=x%mod)<0)val+=mod;}
  ModInt pow(ll t){ModInt res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
  ModInt& operator+=(const ModInt& x){if((val+=x.val)>=mod)val-=mod;return *this;}
  ModInt& operator-=(const ModInt& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
  ModInt& operator*=(const ModInt& x){val=(ll)val*x.val%mod; return *this;}
  ModInt& operator/=(const ModInt& x){return *this*=x.inv();}
  bool operator==(const ModInt& x) const{return val==x.val;}
  bool operator!=(const ModInt& x) const{return val!=x.val;}
  bool operator<(const ModInt& x) const{return val<x.val;}
  bool operator<=(const ModInt& x) const{return val<=x.val;}
  bool operator>(const ModInt& x) const{return val>x.val;}
  bool operator>=(const ModInt& x) const{return val>=x.val;}
  ModInt operator+(const ModInt& x) const{return ModInt(*this)+=x;}
  ModInt operator-(const ModInt& x) const{return ModInt(*this)-=x;}
  ModInt operator*(const ModInt& x) const{return ModInt(*this)*=x;}
  ModInt operator/(const ModInt& x) const{return ModInt(*this)/=x;}
  static int get_mod() { return mod; }
};

using modint = ModInt<1000000007>;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> cnt;
  int bef = 0;
  int s = 0;
  for (int i = 1; i*i <= n; ++i) { 
    cnt.push_back(n/i-n/(i+1));
    s += cnt[i-1];
  }
  for (int i = 0; i < n-s; ++i) { cnt.push_back(1); }
  int n2 = cnt.size();
  vector<vector<modint>> dp(k, vector<modint>(n2));
  for (int i = 0; i < n2; ++i) { 
    dp[0][i] = cnt[i];
    // cout << i << " " << dp[0][i].val << endl;
  }
  for (int i = 0; i < k-1; ++i) { 
    modint s = 0;
    for (int j = 0; j < n2; ++j) {
      s += dp[i][n2-j-1];
      dp[i+1][j] = s*cnt[j];
    }
  }
  modint ans(0);
  for (int j = 0; j < n2; ++j) {
    ans += dp[k-1][j];
  }
  cout << ans.val << endl;
}


Measured memory_bytes: 25596
object Main {
  def main(args: Array[String]): Unit = {
    val Array( standard_num, nums ) = io.StdIn.readLine.split(" ").map{_.toInt}

    if( nums == 0 ) println( standard_num )
    else {
      val illegal_nums = io.StdIn.readLine.split(" ").map{_.toInt}
      val check_nums = ( -2000 to 2000 ).filter( !illegal_nums.contains( _ ) )
      var answer_num = 100000
      var min_value  = 100000

      check_nums.foreach{ i =>
        val check_value = Math.abs( standard_num - i )
        if( check_value < min_value ) {
          min_value = check_value
          answer_num = i
        }
      }

      println( answer_num )
    }
  }
}

Measured memory_bytes: 54980
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

ll gcd(ll a,ll b){
	return (b==0?a:gcd(b,a%b));
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

    int n,m;
    cin>>n>>m;
    vi dp(1<<n,inf);
    dp[0]=0;
    rep(i,m){
        int t=0,a,b;
        cin>>a>>b;
        rep(j,b){
            int c;cin>>c;
            t+=1<<(c-1);
        }
        rep(j,1<<n)cmin(dp[j|t],dp[j]+a);
    }
    if(dp.back()==inf)dp.back()=-1;
    cout<<dp.back()<<endl;
}


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

const int N = 805;
int n, m, k;

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
char c[N][N];
int dis[N][N];
queue<pair <int, int> > q;
bool val(int x, int y) {
	if (x < 1 || x > n)
		return false;
	if (y < 1 || y > m)
		return false;
	return c[x][y] == '.';
}
int main() {
	int xs, ys;
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			dis[i][j] = N * N;
			cin >> c[i][j];
			if (c[i][j] == 'S') {
				dis[i][j] = 0;
				c[i][j] = '.';
				xs = i, ys = j;
			}
		}
	}
	q.push({xs, ys});
	while (q.size()) {
		int x = q.front().first, y = q.front().second;
		q.pop();
		for (int i = 0; i < 4; i++) {
			int x2 = x + dx[i], y2 = y + dy[i];
			if (val(x2, y2) && dis[x2][y2] == N * N) {
				q.push({x2, y2});
				dis[x2][y2] = dis[x][y] + 1;
			}
		}
	}
	int ans = N;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
		//	cout << i << " " << j << " " << dis[i][j] << endl;
			if (dis[i][j] <= k) {
				ans = min(ans, (int) ceil((double) (i - 1) / k) + 1);
				ans = min(ans,(int) ceil((double) (j - 1) / k) + 1);
				ans = min(ans,(int) ceil((double) (n - i) / k) + 1);
				ans = min(ans,(int) ceil((double) (m - j) / k) + 1);
			}
		}
	}
	if (xs == 1 || xs == n || ys == 1 || ys == m)
		ans = 0;
	cout << ans;
	return 0;
}

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

int main() {
  unsigned int N;
  std::cin >> N;

  std::vector<unsigned int> H_array(N);
  for (unsigned int i = 0; i < N; ++i) {
    std::cin >> H_array.at(i);
  }

  unsigned int min_val = 0;
  for (unsigned int i = 0; i < N; ++i) {
    const unsigned int& H = H_array.at(i);
    if (H < min_val) {
      std::cout << "No" << std::endl;
      return 0;
    }
    if (min_val < H - 1) {
      min_val = H - 1;
    }
  }
  std::cout << "Yes" << std::endl;

  return 0;
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
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);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] L = new int[N];
            for (int i = 0; i < N; i++) {
                L[i] = in.nextInt();
            }
            Arrays.sort(L);

            long sum = 0;
            for (int i = 0; i < N - 2; i++) {
                int jl = 0;
                int js = 0;
                for (int j = i + 1; j < N - 1; j++) {
                    if (L[j] == jl) {
                        sum += --js;
                        continue;
                    }
                    jl = L[j];
                    js = 0;
                    for (int k = j + 1; k < N; k++) {
                        if (L[i] + L[j] <= L[k]) {
                            break;
                        }
                        if (check(L[i], L[j], L[k])) {
                            js++;
                        }
                    }
                    sum += js;
                }
            }
            out.println(sum);
        }

        boolean check(int a, int b, int c) {
            boolean r = a < b + c && b < c + a && c < a + b;
            return r;
        }

    }
}



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

using ll = long long;

int main() {
  ll A, B, K;
  cin >> A >> B >> K;

  ll takahashi = 0;
  ll aoki = 0;
  if(A < K) {
    takahashi = 0;
    aoki = max(0LL, B - (K - A));
  } else {
    takahashi = A - K;
    aoki = B;
  }
  cout << takahashi << " " << aoki << endl;

  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n,m; cin >> n >> m;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  vector<bool> f(n,1);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--; b--;
    if(h[a]>h[b]) f[b]=0;
    if(h[a]<h[b]) f[a]=0;
    if(h[a]==h[b]) {f[a]=0; f[b]=0;}
  }
  int ans=0;
  rep(i,n){
    if(f[i]) ans++;
  }
  cout << ans << endl;
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  string s;
  cin >> s;
 
  string sR = s;
  reverse(sR.begin(),sR.end());
  if(s!=sR){
    cout << "No" << endl;
    return 0;
  }
  
  string sSub = s.substr(0,(s.length()-1)/2);
  string sSubR = sSub;
  reverse(sSubR.begin(), sSubR.end());
  if(sSub!=sSubR){
    cout << "No" << endl;
    return 0;
  }
  
  string sSub2 = s.substr((s.length()+3)/2 - 1, s.length() - ( (s.length()+3)/2-1) );
  string sSubR2 = sSub2;
  reverse(sSubR2.begin(), sSubR2.end());
  if(sSub2!=sSubR2){
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
 
  return 0;
}




Measured memory_bytes: 3564
#　あまりの問題は周期性がある
#  R-Lが201９を超えたら必ず2019の倍数のものが存在するのでR-Lが2019より小さい時に絞って考えればいい
#  小さい時では高々要素数は2019より小さいので全部探索すればいい
l,r=list(map(int,input().split()))
if r-l>=2019:
  print(0)
else:
  ans=2019
  for i in range(l,r):
    for j in range(i+1,r+1):
      ans=min(ans,(i%2019)*(j%2019)%2019)
      
      
  print(ans)
  

Measured memory_bytes: 9052
#include<iostream>
using namespace std;
int main(){
  int a,b;
  while(true){
  int max = 0;
  int max_shop = 0;
    cin>>a>>b;
    if(!a&&!b)break;
  for(int i=0;i<5;i++){
    if(i)cin>>a>>b;
    if(a+b>max){
      max = a+b;
      max_shop = i;
    }
  }
  cout<<char(max_shop+65)<<" "<<max<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String[] line_ = line.split(" ");
        Integer i1 = Integer.valueOf(line_[0]);
        Integer i2 = Integer.valueOf(line_[1]);
        Integer i3 = Integer.valueOf(line_[2]);
        int counter = 0;
        for(int a = i1 ; a <= i2 ; a++ ) {
            if(i3 % a == 0)
            counter++;
        }
        System.out.println(counter);
    }
}

Measured memory_bytes: 24456
arr = list(map(int, input().split()))
a = arr[0]
b = arr[1]

if 1 <= a <= 13 and 1 <= b <= 13:
  if a == b:
    print('Draw')
  elif a == 1:
    print('Alice')
  elif b == 1:
    print('Bob')
  elif a > b:
    print('Alice')
  elif b > a:
    print('Bob')

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc167/tasks/abc167_f>
 問題文============================================================
 F - Bracket Sequencing
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<string> S(N); for(auto& in:S) cin >> in;
    
    vector<pll> info(N,pll(LINF,0));
    for(int i = 0; i < N;i++){
        ll now_cost = 0;
        for(auto c:S[i]){
            if(c == '(') now_cost += 1;
            else now_cost -= 1;
            info[i].first = min(info[i].first,now_cost);
        }
        info[i].second = now_cost;
    }
    
    vector<pll> plus,minus;
    for(int i = 0; i < N;i++){
        if(info[i].second >= 0) plus.emplace_back(info[i]);
        else minus.emplace_back(info[i].first-info[i].second,-info[i].second);
    }
    
    sort(plus.begin(),plus.end(),[](const pll& l,const pll& r){
        return l.first > r.first;
    });
    ll x = 0;
    for(auto p:plus){
        if(x + p.first < 0) return "No";
        x += p.second;
    }
    sort(minus.begin(),minus.end(),[](const pll& l,const pll& r){
        return l.first > r.first;
    });

    ll y = 0;
    for(auto p:minus){
        if(y + p.first < 0) return "No";
        y += p.second;
    }
    if(x == y) return "Yes";
    else return "No";
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


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

using namespace std;

int main()
{
	double n, m, v = 0.0, dp = 0.0, a = 0.0, s1, s2;
	
	while(true)
	{
		scanf("%lf", &n);
		
		if(n == 0.0)
			break;
		
		vector<double> v1;
		s1 = 0.0;
		s2 = 0.0;
		
		for(int i = 0; i < n; i++)
		{
			scanf("%lf", &m);
			
			v1.push_back(m);
			s1 += m;
		}
			
		a = s1 / v1.size();
		vector<double>::iterator it;
		
		for(it = v1.begin(); it != v1.end(); it++)
			s2 += (pow((*it-a), 2));
		
		v = s2 / n;
		dp = sqrt(v);
		
		printf("%.8lf\n", dp);
	}
	
	return 0;
}


Measured memory_bytes: 3256
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Security.Cryptography;
using System.Security.Policy;

class Program
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var nums = new List<int>();
		for(var i = 0; i < n; ++i) {
			nums.Add(int.Parse(Console.ReadLine()));
		}

		nums.Sort();

		while (nums.Any() && nums.Sum() % 10 == 0) {
			var index = nums.FindIndex(num => num % 10 != 0);
			if (index != -1) {
				nums.RemoveAt(index);
			} else {
				nums.Clear();
			}
		}

		Console.WriteLine(nums.Sum());

		//デバッグ実行での確認用。そのまま提出しても問題なし
		Console.ReadKey();
	}
}


Measured memory_bytes: 18576
NAB = input().split()
N, A, B = int(NAB[0]), int(NAB[1]), int(NAB[2])

ans = 0

for i in range(1, N+1):
    temp = 0
    for j in str(i):
        temp += int(j)
    if A <= temp and temp <= B:
        ans += i

print(ans)

Measured memory_bytes: 3060
#[allow(unused_imports)]
use proconio::{fastout, input};
use std::string::String;
#[fastout]
fn main() {
    input!(n: usize, s: String);

    let (ff, ss) = s.split_at(n / 2);

    println!("{}", if ff == ss { "Yes" } else { "No" });
}


Measured memory_bytes: 2152
#include <bits/stdc++.h>
using namespace std;
int h, w;

void dfs(int x, int y, int d, char buf, vector<vector<char>> &f, vector<vector<int>> &dep){
    if(x >= h || y >= w) return;
    if(f[x][y] == '#' && buf == '.') d++;
    if(dep[x][y] > d){
        dep[x][y] = d;
        dfs(x+1, y, d, f[x][y], f, dep);
        dfs(x, y+1, d, f[x][y], f, dep);
    }
}

int main(){
    cin >> h >> w;
    vector<vector<char>> field(100, vector<char>(100));
    vector<vector<int>> dep(100, vector<int>(100, 1e+7));
    for(int x=0; x< h; x++){
        for(int y = 0; y < w; y++){
            cin >> field[x][y];
        }
    }
    dfs(0, 0, 0, '.', field, dep);
    cout << dep[h-1][w-1] << endl;
}

Measured memory_bytes: 256
H = []
W = []
i = 0
while True:
  h, w = map(int, input().split())
  H.append(h)
  W.append(w)
  if H[i] == 0 and W[i] == 0:
    break
  i += 1

i = 0
while True:
  if H[i] == 0 and W[i] == 0:
    break
  for j in range(H[i]):
    if j % 2 == 1:
      for k in range(W[i]):
        if k % 2 == 1:
          print("#", end = "")
        elif k % 2 == 0:
          print(".", end = "")
    elif j % 2 == 0:
      for k in range(W[i]):
        if k % 2 == 1:
            print(".", end = "")
        elif k % 2 == 0:
            print("#", end = "")
    print()
  print()
  i += 1

Measured memory_bytes: 8976
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
typedef pair<int, bool> sP;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

int dp[1 << 12];
void solve() {
	int n, m; cin >> n >> m;
	fill(dp, dp + (1 << n), mod);
	dp[0] = 0;
	rep(i, m) {
		int a, b; cin >> a >> b;
		int s = 0;
		rep(j, b) {
			int x; cin >> x; x--;
			s += (1 << x);
		}
		per(j, (1 << n)) {
			dp[j|s] = min(dp[j|s], dp[j] + a);
		}
	}
	int ans = dp[(1 << n) - 1];
	if (ans == mod)ans = -1;
	cout << ans << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//init();
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 256
s=str(input())
n=len(s)-1
sum_s=0
for i in range(2**n):
    k_str=format(i,'b').zfill(n)

    ans=''

    for i in range(n):
        ans += s[i]
        if k_str[i]=='0':
            ans= ans + ''
        else:
            ans= ans +','

    ans=ans+s[-1]
    sum_s += sum(list(map(int,ans.split(','))))

print(sum_s)

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

#define PB emplace_back

using namespace std;

const int N = 5e5+100;

int par[N], sz[N];

vector<int>com[N];

int fat(int x) {
    while(x != par[x]) x = par[x];
    return x;
}

void add(int u, int v) {
    u = fat(u);
    v = fat(v);
    if(u != v) {
        if(sz[u] < sz[v]) swap(u, v);
        sz[u] += sz[v];
        for(int uu: (com[v])) com[u].PB(uu);
        par[v] = u;
        com[v].clear();
    }
}

int main () {
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n, m;
    cin >> n >> m;
    iota(par, par + n , 0);
    fill(sz, sz + n, 1);
    for(int i = 0 ; i < n ; i++ ) {
        com[i].PB(i);
    }
    while(m--) {
        int t, u1, u2;
        cin >> t >> u1 >> u2;
        if(t) cout << (fat(u1) == fat(u2)) << '\n';
        else add(u1, u2);
    }
}


Measured memory_bytes: 23064
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define TABLE_SIZE 16777216
#define ORDER_LENGTH 7
#define STR_LENGTH 13
 
using namespace std;
 
int array[128];
 
int translateStr(char buf[]){
    int sum = -1,mult = 1;
    for(int i = 0; buf[i] != '\0'; i++){
        sum += array[buf[i]]*mult;
        mult *= 4;
    }
    return sum;
}
 
int main(){
 
    array['A']=1,array['C']=2,array['G']=3,array['T']=4;
 
    int n;
    scanf("%d",&n);
    char order[ORDER_LENGTH],str[STR_LENGTH];
 



    char* check_table = new char[TABLE_SIZE];
 
    for(int i = 0; i < n; i++){
        scanf("%s %s",order,str);
        if(order[0] == 'i'){
            check_table[translateStr(str)] = 'Y';
        }else{
            if(check_table[translateStr(str)] == 'Y'){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
}


Measured memory_bytes: 4492
fn main() {
    let n: u32 = read();
    let ps: Vec<u32> = read_vec();

    let mut counter = 0;
    for i in 1..(n - 1) as usize {
        let cp = vec![ps[i - 1], ps[i], ps[i + 1]];
        let mut acc = vec![ps[i - 1], ps[i], ps[i + 1]];
        let mut dec = vec!(ps[i-1], ps[i], ps[i+1]);
        acc.sort();
        dec.sort_by_key(|&num| Rev(num));
        if  cp == acc || cp == dec{
            counter += 1;
        }
    }
    println!("{:?}", counter);
}


use std::cmp::Ordering;

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


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


Measured memory_bytes: 4352
import Control.Applicative
import Control.Monad
import Data.Set (Set)
import qualified Data.Set as S

main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
    solve n <$> replicateM n getLine >>= print
    main

solve :: Int -> [String] -> Int
solve n ss = f 1
  where
    cs = map code ss
    f k
      | k > 50 = (-1)
      | otherwise = let st = S.fromList $ map (take k) cs
                    in if S.size st == n
                       then k
                       else f (k + 1)

code :: String -> String
code s = let vs = "aiueo"
             xs = map snd $ filter (flip elem vs . fst) $ zip s (tail s)
         in head s : xs



Measured memory_bytes: 5412
N=int(input())
s=[0]*N
essence={}
count=0
for i in range(N):
   s_i="".join(sorted(input()))
   s[i]=s_i
   if s[i] not in essence:
      essence.setdefault(s[i],1)
   else:
      count+=essence[s[i]]
      essence[s[i]]+=1

print(count)

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

string check(string s)
{
    for(int i=0;i<=2;i++)
    {
        if(s[i]==s[i+1])
        {
            return "Bad";
        }
    }
    return "Good";
}

int main() {
    int n;
    cin>>n;
    string s;
    while(n!=0){
        int x=n%10;
        s+=to_string(x);
        n/=10;
    }
    //cout<<s<<"\n";
    cout<<check(s);
}
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>; // グラフ型

int main()
{
  int n; cin >> n;
  string s; cin >> s;
  rep(i,s.size()){
    s[i]+=n;
    if(s[i]>=91) s[i] -= 26;
  }
  cout << s;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll d[100005];
using Graph=vector<vector<ll>>;
vector<ll>topological_sort(const Graph &G,vector<ll> &indeg, ll V){
vector<ll>sorted;
  queue<ll>que;
  for(int i=0;i<V;i++)
    if(indeg[i]==0)
      que.push(i);
  while(!que.empty()){
  ll v=que.front();
    que.pop();
    sorted.push_back(v);
    for(auto u:G[v]){
    indeg[u]--;
      if(indeg[u]==0)
        que.push(u);
    }
        }return sorted;
}
ll N,M;
int main(){
  cin>>N>>M;
  Graph G(N);
  vector<ll>indeg(N);
  for(int i=0;i<M;i++){
  ll s,t;cin>>s>>t;s--;t--;
    G[s].push_back(t);indeg[t]++;
  }vector<ll>A=topological_sort(G,indeg,N);
    for(int i=0;i<N;i++){
    ll v=A[i];
      for(auto u:G[v]){
      d[u]=max(d[v]+1,d[u]);
      }
    }ll ans=0;
  for(int i=0;i<N;i++)
    if(ans<d[i])ans=d[i];
  cout<<ans<<endl;
  return 0;
}

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

n = int(input())
A = [list(map(int,input().split())) for i in range(n)]
for i in range(n):
    for j in range(n-1):
        A[i][j] -= 1

AA = [[j for j in i] for i in A]

ID = [[-1] * n for i in range(n)]
id_ = 0
for i in range(n):
    for j in range(i+1,n):
        ID[i][j] = id_
        ID[j][i] = id_
        id_ += 1

for i in range(n):
    for j in range(n-1):
        A[i][j] = ID[i][A[i][j]]

M = [[] for i in range(id_)]
IN = [0] * id_
for i in range(n):
    for j in range(n-2):
        M[A[i][j]].append(A[i][j+1])
        IN[A[i][j+1]] +=1
# print(A)
# print(M)

# 以下、トポロジカルソート

S = []
s = 0

for i in range(id_):
    if IN[i] == 0:
        S.append(i)

while s < len(S):
    for x in M[S[s]]:
        IN[x] -= 1
        # print(x,IN)
        if IN[x] == 0:
            S.append(x)
    s += 1

# print(S)

if len(S) < id_:
    print(-1)
else:
    T = [1] * id_
    for i in range(id_):
        for j in M[S[i]]:
            T[j] = max(T[j], T[S[i]] + 1)
    print(max(T))


# 以下、閉路検出(今は削除)

# V = [0] * id_
# S = [0]
# V[0] = 1

# import sys

# def visit(x):
#     if V[x] == 1:
#         print(-1)
#         sys.exit()
#     elif V[x] == 0:
#         V[x] = 1
#         for i in M[x]:
#             visit(i)
#         V[x] = 2

# for i in range(id_):
#     if V[i] == 0:
#         visit(i)
# print("heironasi")

# 閉路検出ここまで


Measured memory_bytes: 149084
n,m = gets.chomp.split(" ").map(&:to_i)
a = Array.new(m)
b = Array.new(m)
c = Array.new(m)
m.times do |i|
  a[i],b[i] = gets.chomp.split(" ").map(&:to_i)
  c[i] = gets.chomp.split(" ").map(&:to_i)
end
dp = Array.new(2.pow(n),100000000000)
dp[0] = 0
for i in 1..m
  bits = 0
  c[i-1].each do |x|
    bits += 2.pow(x-1)
  end
  for j in 0..2.pow(n)-1
    dp[j|bits] = [dp[j|bits], dp[j]+a[i-1]].min
  end
end
puts dp[2.pow(n)-1] != 100000000000 ? dp[2.pow(n)-1] : -1

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

using namespace std;

#define MAX_N 10
#define MAX_S (1<<13)

int N,M[2*MAX_N];
int memo[2*MAX_N][MAX_S+1];

int solve(int p,int rem){
  if(rem == 0){ return memo[p][rem] = 1; }
  if(memo[p][rem] >= 0){ return memo[p][rem]; }
  for(int i = 1 ; i <= M[p] ; i++){
    if(rem-i < 0){ continue; }
    if(solve((p+1)%N,rem-i) == 0){
      return memo[p][rem] = 1;
    }
  }
  return memo[p][rem] = 0;
}

int main(){
  int S;
  while(cin >> N,N){
    cin >> S;
    N *= 2;
    for(int i = 0 ; i < N ; i++){
      cin >> M[i];
    }
    memset(memo,-1,sizeof(memo));
    cout << solve(0,S) << endl;
  }
  return 0;
}

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

int main() {
  vector<int> a(3);

  cin >> a[0] >> a[1] >> a[2];

  sort(a.begin(), a.end(), greater<int>());

  if (a[1] % 2 != a[2] % 2)
    cout << ceil((double)((a[0] - a[1]) + (a[0] - a[2])) / 2) + 1;
  else
    cout << ((a[0] - a[1]) + (a[0] - a[2])) / 2;

  return 0;
}

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

#define ll long long

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

    int n, x, t;
    cin >> n >> x >> t;

    if(n <= x){
        cout << t <<"\n";
    }
    else{
        if(n % x == 0){
            cout << (n-x) / x * t + t<< "\n";
        }
        else{
            cout << (((n-x) / x) + 1 ) * t + t <<"\n";
        }

    }
}



Measured memory_bytes: 3536
#include <stdio.h>

void Swap(int *x,int *y);

int main(){
    //初期入力
    int N;
    scanf("%d",&N);
    int A[N];
    for(int i=0;i<N;i++)
        scanf("%d",&A[i]);
    //変数定義
    int cp;
    int min;
    int min_n;
    int change=0;
    //処理
    for(int i=0;i<N-1;i++){
        min=A[i];
        min_n=i;
        for(int j=i+1;j<N;j++){
            if(min>A[j]){
                min=A[j];
                min_n=j;
            }
        }
        if(min_n!=i){
            Swap(&A[min_n],&A[i]);
            change++;
        }
    }
    //最終出力
    printf("%d",A[0]);
    for(int i=1;i<N;i++){
        printf(" %d",A[i]);
    }
    printf("\n");
    printf("%d\n",change);
}

void Swap(int *x,int *y){
    int cp;

    cp=*x;
    *x=*y;
    *y=cp;
    
}


Measured memory_bytes: 2116
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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 (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N,M;
	string S, T;
	cin >> N >> M;

	if (N == M)cout << "Yes" << endl;
	else cout << "No" << endl;



	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
    #include<stdlib.h>
    #include<time.h>
    #include<math.h>
     
     
    //qsort(pa,n,sizeof(int),(int(*)(const void* ,const void*))cmp);
     
     
    int main(void){
     
      long long n;
      scanf("%lld",&n);
      long long i,j,k;
      long long max=1;
      long long ano;
      //素数の時
      /*for(i=2;i<n;i++){
        if(n%2==0)
        break;
      }
      if(i==n){
        printf("%lld",n-1);
        return 0;
      }*/
     
      for(i=2;i<=sqrt(n);i++){
        if(n%i==0)
        max=i;
      }
      ano=n/max;
      printf("%lld",max+ano-2);
     
     
      return 0;
    }

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

class Q{
public:
	int first,second[30];
	Q(int x,int *y){ first=x; for(int i=0;i<30;i++) second[i]=y[i]; }
};

bool check(int d[30]){
	int c=d[0]; for(int i=1;i<8;i++) if(c!=d[i]) return false;
	c=d[21]; for(int i=22;i<29;i++) if(c!=d[i]) return false;
	if(!(d[9]==d[10]&&d[10]==d[11])) return false;
	if(!(d[12]==d[13]&&d[13]==d[14])) return false;
	if(!(d[15]==d[16]&&d[16]==d[17])) return false;
	if(!(d[18]==d[19]&&d[19]==d[20])) return false;
	return true;
}

int c[4][5][2]={
{ {0,27} ,{1,28} ,{2,29} ,{18,20},{14,15} } ,
{ {0,23} ,{3,26} ,{6,29} ,{9,20} ,{15,17} } ,
{ {6,21} ,{7,22} ,{8,23} ,{12,17},{9,11}  } ,
{ {2,21} ,{5,24} ,{8,27} ,{12,14},{11,18} } };

int N,p[30];

int main(){
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		for(int j=0;j<30;j++) scanf("%d",&p[j]);
		int count=0;
		queue<Q> que;
		que.push(Q(0,p));
		while(!que.empty()){
			Q q=que.front(); que.pop(); int *x; x=q.second; count=q.first;
			if(check(x)) break;
			for(int k=0;k<4;k++){
				int x2[30]; for(int r=0;r<30;r++) x2[r]=x[r];
				for(int r=0;r<5;r++) swap(x2[c[k][r][0]],x2[c[k][r][1]]);
				que.push(Q(count+1,x2));
			}
			
		}
		printf("%d\n",count);
	}	
}

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

 
using namespace std;

long long combination(long long n, long long r){
    long long a = 1;
    long long b = 1;
    if(r==0)return 1;
    for(int i=0;i<r;i++){
        a*=(n-i);
        b*=(i+1);
    }
    return a/b;
}
const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    long long A,B;
    cin >> A >> B;
    if(B>A){
        long long tmp=A;
        A=B;
        B=tmp;
    }
    long long dif = A-B;
    long long base = B-dif;
    if(base<0 || base%3!=0){
        cout << 0 << endl;
        return 0;
    }
    long long x = base/3 + dif;
    long long y = base/3;
    

    COMinit();
    cout << (COM(x+y,y))%1000000007 << endl;
    return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main(){
  int n;
  cin >> n;
  vector<int> a(n+1), b(n+1), c(n+1);

  rep(i,n+1) {
    if(i == 0) continue;
    cin >> a[i];
  }
  rep(i,n+1) {
    if(i == 0) continue;
    cin >> b[i];
  }
  rep(i,n+1) {
    if(i == 0) continue;
    cin >> c[i];
  }

  int ans = 0;
  rep(i,n+1){
    ans += b[a[i]];
    if(i == 0 || i == 1) continue;
    if(a[i] == a[i-1]+1) ans += c[a[i-1]];
    
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
import java.io.FileNotFoundException;
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);

    	double A = sc.nextDouble();
    	BigDecimal B = BigDecimal.valueOf(sc.nextDouble());
    	//double B = sc.nextDouble();

    	BigDecimal times = B.multiply(BigDecimal.valueOf(A));

    	System.out.println(times.longValue());
    }
}

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


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

    set< string >st;
    for (int i = 0; i < s.size(); i++) {
        string t;
        for (int j = i; j < s.size(); j++) {
            t += s[j];
            st.insert(t);
            if (st.size() > k) {
                st.erase(prev(st.end()));
            }
        }
    }

//    for (string t : st) cout << t << endl;

    cout << *prev(st.end()) << endl;

    return 0;
}


Measured memory_bytes: 3676
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<pair<int, int>>vec;
int n, m, l, r, p;
int main() {
	while (true) {
		cin >> n; if (n == 0)break;
		cin >> m >> l >> r >> p; vec.clear();
		vec.push_back(make_pair(1, n));
		for (int i = 0; i < m; i++) {
			int r1, r2; cin >> r1 >> r2;
			vector<pair<int, int>>A, B, C; int sum1 = 0, c = 0;
			for (int j = 0; j < vec.size(); j++) {
				sum1 += (vec[j].second - vec[j].first + 1);
				bool H = false;
				if (sum1 > r2 && c == 0) {
					int Border1 = vec[j].second - (sum1 - r1);
					int Border2 = vec[j].second - (sum1 - r2);
					A.push_back(make_pair(vec[j].first, Border1));
					B.push_back(make_pair(Border1 + 1, Border2));
					C.push_back(make_pair(Border2 + 1, vec[j].second));
					c = 2; H = true;
				}
				if (sum1 > r1 && c == 0) {
					int Border = vec[j].second - (sum1 - r1);
					A.push_back(make_pair(vec[j].first, Border));
					B.push_back(make_pair(Border + 1, vec[j].second));
					c = 1; H = true;
				}
				if (sum1 > r2 && c == 1 && H == false) {
					int Border = vec[j].second - (sum1 - r2);
					B.push_back(make_pair(vec[j].first, Border));
					C.push_back(make_pair(Border + 1, vec[j].second));
					c = 2; H = true;
				}
				if (H == false) {
					if (c == 0) { A.push_back(make_pair(vec[j].first, vec[j].second)); }
					if (c == 1) { B.push_back(make_pair(vec[j].first, vec[j].second)); }
					if (c == 2) { C.push_back(make_pair(vec[j].first, vec[j].second)); }
				}
			}
			vec.clear();
			for (int i = 0; i < C.size(); i++) { if (C[i].first <= C[i].second) vec.push_back(C[i]); }
			for (int i = 0; i < B.size(); i++) { if (B[i].first <= B[i].second)vec.push_back(B[i]); }
			for (int i = 0; i < A.size(); i++) { if (A[i].first <= A[i].second)vec.push_back(A[i]); }
		}
		int sum2 = 0, sum3 = 0;
		for (int i = 0; i < vec.size(); i++) {
			if (vec[i].first > vec[i].second)continue;
			int HB = (vec[i].second - vec[i].first + 1); sum2 += HB;
			int L1 = vec[i].first, R1 = vec[i].second;
			int L2 = 1, R2 = p;
			if (sum2 > r && sum2 - HB <= r) { R1 = vec[i].first + (r - (sum2 - HB)) - 1; }
			if (sum2 - HB < l && sum2 >= l) { L1 = vec[i].first + (l - (sum2 - HB)) - 1; }
			if (sum2 - HB > r)continue;
			if (sum2 < l)continue;

			int L3 = max(L1, L2), R3 = min(R1, R2);
			sum3 += max(0, R3 - L3 + 1);
		}
		cout << sum3 << endl;
	}
	return 0;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
  int A,B,K;
  cin>>A>>B>>K;
  int m=min(A,B);
  int ans=0;
  int cnt=0;
  rep(i,m){
      if(A%(m-i)==0&&B%(m-i)==0){
          cnt++;
      }
      if(cnt==K){
          ans=m-i;
          break;
      }
  }
  cout<<ans<<endl;
  
}

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

using lint = long long;
const lint mod = 998244353;

lint N, M, K;
lint Fact[600005];
lint InvFact[600005];

lint Power(lint n, lint x) {
  if (x == 0) return 1;
  lint res = Power(n, x / 2);
  res *= res;
  res %= mod;
  if (x & 1) res = res * n % mod;
  return res;
}

lint C(lint n, lint k) {
  if (k < 0 || k > n) return 0;
  return (Fact[n] * InvFact[n - k] % mod) * InvFact[k] % mod;
}

lint Solve(lint k) { // k adjacent pairs
  if (k >= N) return 0;

  lint comp = N - k;
  lint choose = C(N - 1, k);

  lint res = choose * Power(M - 1, comp - 1) % mod * M % mod;
  res %= mod;
  if (res < 0) res += mod;
  return res;
}

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

  cin >> N >> M >> K;

  InvFact[0] = Fact[0] = 1;
  for (int i = 1; i < 600005; i++) {
    Fact[i] = 1ll * i * Fact[i - 1] % mod;
    InvFact[i] = Power(Fact[i], mod - 2);
  }
  
  lint ans = 0;
  for (int i = 0; i <= K; i++) {
    ans += Solve(i);
    ans %= mod;
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 13036
road_cnt = {}
for i in range(1, 5):
    road_cnt[i] = 0

for i in range(3):
    a, b = map(int, input().split())
    road_cnt[a] += 1
    road_cnt[b] += 1

one_road = 0
two_road = 0
for k, v in road_cnt.items():
    if v == 2:
        two_road += 1
    elif v == 1:
        one_road += 1

print("YES" if one_road == 2 and two_road == 2 else "NO")

Measured memory_bytes: 3064
#include <iostream>
#include <map>

bool a[5010][5010];
std::pair<int, int> poles[3010];

bool exist(int x, int y) {
    if (0 > x || 5000 < x || 0 > y || 5000 < y) { return false; }
    return a[x][y];
}

int main() {
    while (true) {
        int n;
        std::cin >> n;

        if (n == 0) { break; }

        for (int i = 0; i < 3009; i++) {
            for (int j = 0; j < 3009; j++) {
                a[i][j] = false;
            }
        }

        for (int i = 0; i < n; i++) {
            int x, y;
            std::cin >> x >> y;
            a[x][y] = true;

            poles[i] = std::make_pair(x, y);
        }

        int max = 0;

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < i; j++) {
                int dx = poles[i].first - poles[j].first;
                int dy = poles[i].second - poles[j].second;

                if (exist(poles[j].first + dy, poles[j].second - dx) && exist(poles[i].first + dy, poles[i].second - dx)) {
                    max = std::max(dx * dx + dy * dy, max);
                    continue;
                }
                if (exist(poles[j].first - dy, poles[j].second + dx) && exist(poles[i].first - dy, poles[i].second + dx)) {
                    max = std::max(dx * dx + dy * dy, max);
                }
            }
        }

        std::cout << max << std::endl;
    }
}

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

int main() {
	int dataset[10000];
	int i = 0, x = -1;

	while(x != 0){
		cin >> x;
		dataset[i] = x;
		i++;
	}

	for(int j = 1; j < i; j++){
		cout << "Case " << j << ": " << dataset[j - 1] << endl;
	}

	return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

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

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

int main()
{

  int N,M,K;
  cin >> N >> M >> K;
  vector<int> A(N);
  vector<int> B(M);
  for(int i=0;i<N;i++)
    cin >> A[i];
  for(int i=0;i<M;i++)
    cin >> B[i];

    int A_nBook=0;

  unsigned long long A_time = 0;
  unsigned long long B_time = 0;
  
  int B_nBook=0;
  
  for(int j=0;j<M;j++)
    {
      B_time +=B[j];
//      cout << B_time << " " << B_nBook << endl;
      if(B_time>K)
      {
        B_time -=B[j];
        break;
      }else
      {
        B_nBook++;
      }      
    }

  int max_nBook=B_nBook;


  while(1)
  {
    unsigned long long time = 0;
    
    if(A_nBook > 0)    A_time += A[A_nBook-1];
    if(A_time > K) break;
   
    if(A_time + B_time >K)
    {
      while(1)
      {
        B_time -= B[B_nBook -1];
        B_nBook--;
        if(A_time + B_time <=K) break;
      }
    }


//    cout << A_nBook <<" "<< B_nBook <<endl;
    if( A_nBook + B_nBook > max_nBook )
    {
      max_nBook = A_nBook + B_nBook;
    }

    if(A_nBook==N)
    {
      break;
    }else
    {
      A_nBook++;
    }
  }
  cout << max_nBook << endl;
  return 0;
}
  

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

using namespace std;

int main(){

    int x,y,a,b,c;
    cin >> x >> y >> a>> b>>c;
    vector<int> p(a),q(b),r(c);
    for (int i =0;i < a;i++){
        cin >> p[i];
    }
    for (int i = 0 ; i < b; i++){
        cin >> q[i];
    }
    for (int i = 0 ;i < c;i++){
        cin >>r[i];
    }
    sort(p.begin(),p.end(),greater<>());
    sort(q.begin(),q.end(),greater<>());
    sort(r.begin(),r.end(),greater<>());

    if(x!=a) p.erase(p.begin()+x,p.end());
    if(x!=b) q.erase(q.begin()+y,q.end());

    p.insert(p.end(),q.begin(),q.end());
    p.insert(p.end(),r.begin(),r.end());
    sort(p.begin(),p.end(),greater<>());
    long long ans = 0;
    for (int i=0;i < x+y;i++)
        ans+=p[i];
    cout<<ans << endl;
    return 0;
}


Measured memory_bytes: 2808