akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.lang.*;
import java.util.*;

class Main {
   
    public static void main(String[] args) {
        
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        String s = input.next();
        if(a >= 3200)
        {
            System.out.println(s);
        }
        if(a < 3200)
        {
            System.out.println("red");
        }
        
    }
    
}


Measured memory_bytes: 22612
# DPL_2_A - 巡回セールスマン問題

import sys
sys.setrecursionlimit(10 ** 8)

V, E = map(int, sys.stdin.readline().strip().split())
d = [[float('inf')] * V for _ in range(V)]
for _ in range(E):
    s, t, _d = map(int, sys.stdin.readline().strip().split())
    d[s][t] = _d

# dp 初期化 -----------------
dp = [[float('inf')] * V for _ in range(1 << V)]  # 1 << V は 2 ** V に同じ
dp[0][0] = 0  # 頂点 0 からスタートするとする


def res(s, v):
    # s: すでに訪問した街の集合, v: 今いる街の集合, dp: 動的計画法のテーブル
    # 0 から出発して s, v　を満たすコストを返す関数

    if dp[s][v] == -1:  # 到達不可能ならば
        return float('inf')
    elif dp[s][v] != float('inf'):
        return dp[s][v]
    elif (s >> v) & 1 == 0:  # 集合 s に頂点 v が含まれていないならば
        dp[s][v] = -1
        return float('inf')

    ans = float('inf')
    for u in range(V):
        # if (s >> u) & 1 == 1:
        # print(f's: {format(s ^ (1 << v), "b")}, u: {u}')
        # print(f'{d[u][v]}')
        ans = min(ans, res(s ^ (1 << v), u) + d[u][v])

    if ans == float('inf'):  # 到達不可能ならば　
        dp[s][v] = -1
    else:
        dp[s][v] = ans

    return ans


res((1 << V) - 1, 0)

# for i in range(len(dp)):
#     print(dp[i])
print(dp[-1][0])




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

int main() {
 
  int N,x;
  cin >> N >> x;
  
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  
  sort(A.begin(), A.end());
  
  int ans=0;
  for(int i=0; i<N; i++){
    if(x >= A.at(i)){
      x -= A.at(i);
      ans++;
    }
    else{
      break;
    }
  }
  
  if(ans == N && x > 0){
    ans--;
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 3604
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int x = Integer.parseInt(br.readLine());
        StringBuilder sb = new StringBuilder();
        
        for(int i = 2; i < x+1; i++){
            String s = String.valueOf(i);
            if(i%3 == 0){
                sb.append(" " + i);
            }else {
                for (int k = 0; k < s.length(); k++){
                    if (s.indexOf('3') != -1){
                        sb.append(" " + i);
                        break;
                    }
                }
            }
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 27412
#include<bits/stdc++.h>
#include<sstream>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define strep(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<int,int>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<int>
#define rs resize
int main()
{
   std::ios::sync_with_stdio(false);
   bool s= false,d = false;
   int x,a,b;
   cin>>x>>a>>b;
   if(b-a<=x)
    s = true;
   if(b<=x)
    d = true;
   if(d)
    cout<<"delicious";
   else
   {
     if(s)
      cout<<"safe";
     else
      cout<<"dangerous";
   }
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
#include<string.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int n;
  ll k;
	cin >> n >> k;
	vector<pair<int, int>> a(n);
	rep(i, n) cin >> a[i].first >> a[i].second;
	sort(a.begin(), a.end());
	ll cnt = 0;
	rep(i, n) {
		cnt += (ll)a[i].second;
		if (cnt >= k) {
			cout << a[i].first << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define ll long long

int main() {
	int n;
	scanf("%d", &n);
	vector<int> a(n + 2, 0);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] > a[i + 1])
			ans += a[i] - a[i + 1];
	}
	cout << ans << endl;
	return 0;
}


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

char rank[8][4] = {"AAA", "AA", "A", "B", "C", "D", "E", "NA"};
double aa[7] = {35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70.0};
double bb[7] = {71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0};

int main()
{
    double a,b;
    while(cin >> a >> b){
        for(int i=0;i<8;i++){
            if(i==7){
                cout << rank[i] << endl;
                break;
            }
            if(a < aa[i] && b < bb[i]){
                cout << rank[i] << endl;
                break;
            }
        }
    }
    return 0;
}

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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	ll a, b, c;
	cin >> a >> b >> c;
	
	for(ll i = 1; i <= 100000000; ++i){
		ll tmp = i * a - c;
		if(tmp % b == 0){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" <<endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;

int main(){
    int n;
    cin>>n;
    vector<string> s(n);
    for (int i=0; i<n;i++) cin>>s[i];
    int ac_cnt, wa_cnt, tle_cnt, re_cnt;
    ac_cnt=0;
    wa_cnt=0;
    tle_cnt=0;
    re_cnt=0;
    for (int i=0; i<n; i++){
        if (s[i]=="AC") ac_cnt++;
        if (s[i]=="WA") wa_cnt++;
        if (s[i]=="TLE") tle_cnt++;
        if (s[i]=="RE") re_cnt++;
    }
    cout<<"AC x "<<ac_cnt<<endl;
    cout<<"WA x "<<wa_cnt<<endl;
    cout<<"TLE x "<<tle_cnt<<endl;
    cout<<"RE x "<<re_cnt<<endl;
    
    return 0;
}

Measured memory_bytes: 6408
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 100000000000000;

P d[302][302];
ll cost[302][302];

int main()
{
    int n, m, l;
    cin >> n >> m >> l;
    int a[50000], b[50000];
    ll c[50000];
    vector<P> v[302];
    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++){
        cost[i][j] = INF;
        d[i][j] = P(INF, 0);
    }
    for(int i = 0; i < n; i++){
        d[i][i] = P(0, -l);
        cost[i][i] = 0;
    }
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        v[a[i]].push_back(P(b[i], c[i]));
        v[b[i]].push_back(P(a[i], c[i]));
        cost[a[i]][b[i]] = c[i];
        cost[b[i]][a[i]] = c[i];
    }
    for(int i = 0; i < n; i++){
        bool used[302];
        fill(used, used + n, false);
        while(true){
            int v = -1;
            for(int u = 0; u < n; u++){
                if(!used[u] && (v == -1 || d[i][u] < d[i][v])) v = u;
            }
            if(v == -1 || d[i][v].first == INF) break;
            used[v] = true;
            for(int u = 0; u < n; u++){
                if(cost[v][u] > l) continue;
                if(used[u]) continue;
                if(cost[v][u] + d[i][v].second <= 0)
                    d[i][u] = min(d[i][u], P(d[i][v].first, d[i][v].second + cost[v][u]));
                else d[i][u] = min(d[i][u], P(d[i][v].first + 1, cost[v][u] - l));
            }
        }
    }
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int s, t;
        cin >> s >> t;
        s--;
        t--;
        if(d[s][t].first != INF) cout << d[s][t].first << endl;
        else cout << -1 << endl;
    }
}

Measured memory_bytes: 5760
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Majk
 */

#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
#include <queue>
using namespace std;

#define x first
#define y second
constexpr int MOD = 1000000007;

typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned int ui;

template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;

namespace std {
    template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}};
}
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

template<typename T>class vector2:public vector<vector<T>>{public:vector2(){} vector2(size_t a,size_t b,T t=T()):vector<vector<T>>(a,vector<T>(b,t)){}};
template<typename T>class vector3:public vector<vector<vector<T>>>{public:vector3(){} vector3(size_t a,size_t b,size_t c,T t=T()):vector<vector<vector<T>>>(a,vector<vector<T>>(b,vector<T>(c,t))){}};
// #include "../l/mod.h"

class C {
public:
	void solve(istream& cin, ostream& cout) {
		int N; cin >> N;
		vector<int> C(26, 10000);
		for (int i = 0; i < N; ++i) {
			string S; cin >> S;
			vector<int> F(26, 0);
			for (char s: S) {
				F[s-'a']++;
			}
			for (int j = 0; j < 26; ++j) {
				C[j] = min(C[j], F[j]);
			}
		}

		stringstream ss;
		for (int i = 0; i < 26; ++i) {
			for (int j = 0; j < C[i]; ++j) {
				ss << (char)('a'+i);
			}
		}
		cout << ss.str() << endl;
	}
};


int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	C solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[] V = new int [N];
		int[] C = new int [N];

		for (int i = 0; i < N; i++) {
			V[i] = sc.nextInt();
		}

		for (int i = 0; i < N; i++) {
			C[i] = sc.nextInt();
		}

		int maxValue = 0;

		for (int i = 0; i < N; i++) {
			if (V[i] - C[i] > 0) {
				maxValue += V[i] - C[i];
			}
		}

		System.out.println(maxValue);
	}
}




Measured memory_bytes: 22996
// And in the end, the love you take is equal to the love you make.
//                      Paul McCartney (the Beatles). The End. Abbey Road.

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

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char buff[BUFF], *begin = buff, *end = buff;
char getc() {
    if (begin == end) {
        begin = buff;
        end = buff + fread(buff, 1, BUFF, stdin);
    }
    return begin == end ? -1 : *begin++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0; bool pos = true; char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

const size_t N = 200 + 5;
const size_t M = 1e5 + 5;
const int MOD = 1e9 + 7;

void add(int &dp, int val) {
    dp += val;
    if (dp >= MOD) dp -= MOD;
}

int f[N][M], s[N];

int main() {
    int n = read(), x = read();
    generate_n(s, n, read);
    sort(s, s + n); reverse(s, s + n);
    f[0][x] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= x; ++j) {
            if (!f[i][j]) continue;
            add(f[i + 1][j % s[i]], f[i][j]);
            add(f[i + 1][j], (LL) f[i][j] * (n - 1 - i) % MOD);
        }
    }
    int ans = 0;
    for (int i = 0; i <= x; ++i) {
        if (f[n][i]) ans = (ans + (LL) f[n][i] * i) % MOD;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 78208
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  constexpr int64_t kMax = 1e5L;
  const int64_t kUpper = static_cast<int64_t>(sqrt(static_cast<double>(kMax)));
  vector<bool> is_prime(kMax + 1, true);
  is_prime[0] = false;
  is_prime[1] = false;
  for (int64_t i = 4; i <= kMax; i += 2) {
    is_prime[i] = false;
  }
  for (int64_t p = 3; p <= kUpper; p += 2) {
    if (is_prime[p]) {
      for (int64_t j = p * 2; j <= kMax; j += p) {
        is_prime[j] = false;
      }
    }
  }

  vector<int64_t> S(kMax + 1);
  S[0] = 0;
  int64_t count = 0;
  for (int64_t j = 1; j <= kMax; j += 2) {
    if (is_prime[j] && is_prime[(j + 1) / 2]) {
      ++count;
    }
    S[j] = count;
  }

  int64_t Q;
  cin >> Q;
  for (int64_t i = 0; i < Q; ++i) {
    int64_t l, r;
    cin >> l >> r;
    cout << S[r] - S[max(l - 2, 0L)] << endl;
  }
  return 0;
}


Measured memory_bytes: 3936
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <map>

using namespace std;

typedef long long ll;
const int N = 1e5 + 10;

int a[99999];

void asd(){
	memset(a, 0, sizeof(a));
	for(int i = 10000; i <= 99999; i++){
			int q = i % 10;
			int w = i / 10000;
			int x = i / 10;
			x = x % 10;
			int y = i / 1000;
			y = y % 10;
			if((q == w) && (x == y))
				a[i] = 1;
	}
}

int main(){
	asd();
	int n,m;
	while(~scanf("%d %d",&n, &m)){
		int sum = 0;
		for(int i = n; i <= m; i++){
			if(a[i])
				sum++;
		}
		printf("%d\n", sum);
	}
}

Measured memory_bytes: 640
object Main {
  def main(args: Array[String]): Unit = {
    val in = new java.util.Scanner(System.in)
    val n = in.nextInt
    val list:List[Int] = makeList(in,n)
    val re = list.reverse
    printList(re)
    
  }
  def makeList(in:java.util.Scanner,rest:Int):List[Int] = {
    if(rest == 0) return List.empty 
    val a = in.nextInt
     return a :: makeList(in,rest -1)
  }
  def printList(list:List[Int]):Unit = {
    list match{
      case List(n) =>{ println(n); return}
      case n :: ls => {print(n+" ");printList(ls)}
    }
  }
}

Measured memory_bytes: 44968
#include <iostream>
#include <cmath>
#include <algorithm>
#include <unordered_map>
#include <vector>
using namespace std;
int main() {
    int N, M, ans = 0; cin >> N;
    vector<string> S(N, "");
    unordered_map<string, int> s;
    unordered_map<string, int> t;
    for (int i = 0; i < N; ++i) {
        string a; cin >> a; s[a]++;
        S[i] = a;
    }
    cin >> M;
    for (int i = 0; i < M; ++i) {
        string b; cin >> b; t[b]++;
    }
    for (int i = 0; i < N; ++i) {
        ans = max(ans, s[S[i]] - t[S[i]]);
    }
    printf("%d\n", ans);
}


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

int main() {
  int n; cin >>n;
  vector<ll> a(n),b(n);
  rep(i,n) cin >>a[i] >>b[i];
  ll sum = 0;
  for(int i = n-1; 0<=i; i--){
    a[i]+=sum;
    sum += (b[i]-a[i]%b[i])%b[i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 4768
n = gets.to_i
ss = []
n.times do
  ss.push(gets.to_i)
end

t = ss.inject(&:+)
if (t % 10).zero?
  ts = ss.reject { |x| (x % 10).zero? }
  p ts.size.zero? ? 0 : t - ts.min
else
  p t
end


Measured memory_bytes: 1788
//Author : Ayush Jain

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

#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define PI acos(-1.0)
const int N=1e5 + 5;
const int M=1e5 + 5;
vector <int> v[N];
bool vis[N];
multiset <ll> f[N],fu;
int fre=0;
ll a[N];
void dfs(int s)
{
	vis[s]=true;
	f[fre].insert(a[s]);
	for(int i=0;i<v[s].size();i++){
		if(!vis[v[s][i]]){
			dfs(v[s][i]);
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	int n,m,i,p,q;
	for(i=0;i<N;i++){
		vis[i]=false;
	}
	cin>>n>>m;
	
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<m;i++){
		cin>>p>>q;
		v[p].pb(q);
		v[q].pb(p);
	}
	for(i=0;i<n;i++){
		if(!vis[i]){
			dfs(i);
			//sort(f[fre].begin(),f[fre].end());
			fre++;
		}
	}
	if(fre==1){
		cout<<0<<endl;
		return 0;
	}
	ll foo=2*(ll)(fre-1),bar=0;
	ll ans=0;
	for(i=0;i<fre;i++){
		bar+=(ll)f[i].size();
		ans+=*f[i].begin();
		f[i].erase(f[i].begin());
	}
	if(bar<foo){
		cout<<"Impossible\n";
		return 0;
	}
	ll tot=2*(ll)(fre-1) - (ll)fre;
	for(i=0;i<fre;i++){
		while(!f[i].empty()){
			fu.insert(*f[i].begin());
			f[i].erase(f[i].begin());
		}
	}
	for(i=0;i<tot;i++){
		ans+=*fu.begin();
		fu.erase(fu.begin());	
	}	
	cout<<ans<<endl;
		
	return 0;
}

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

typedef long long ll;

ll change(string str){
  stringstream ss;
  ss<<str;
  ll res;
  ss>>res;
  return res;
}

int main(){
  char ch,ch2;
  string ans="", mini, maxm;
  string tmpMin="",tmpMax="";
  int I,d,cc=0;
  
  for(I=1;I<=11;I++){
    mini=maxm="";
   
    for(int i=0;i<I;i++)mini.push_back('0');
    mini[0]='1';
    for(int i=0;i<I;i++)maxm.push_back('9');
    
    cout<<"? "<<mini<<endl;
    cin>>ch;
    cout<<"? "<<maxm<<endl;
    cin>>ch2;
    
    if(ch2=='N'){
      if(tmpMin=="")cc=I;
    }
    
    if(ch=='Y'&&ch2=='Y'){
      d=I;
      tmpMin=mini;
      tmpMax=maxm;
    }
  }

  if(d==11){
    string ans="1";
    for(int i=0;i<cc;i++)ans.push_back('0');
    cout<<"! "<<ans<<endl;
    return 0;
  }
  
  ll L=change(tmpMin);
  ll R=change(tmpMax);
  ll M;
  
  while(L<R){
    M=(L+R)/2;
    cout<<"? "<<M*10<<endl;
    cin>>ch;
    if(ch=='N'){
      L=M+1;
    }else{
      R=M;
    }
  }

  cout<<"! "<<L<<endl;
  
  return 0;
}


Measured memory_bytes: 668
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int) n; i++)
#define repb(i, n) for (int i = (int) n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int) m; i < (int) n; i++)
#define repsb(i, m, n) for (int i = (int) m; i >= (int) n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
# define pb(a) push_back(a)
#define ll long long int
int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };
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; }
//vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));
using namespace std;
int main(int argc, char const * argv[]){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(1){
        c -= b;
        a -= d;
        if (c < 1)
        {
            cout<<"Yes"<<endl;
            break;
        }
        if(a<1){
            cout<<"No"<<endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b; cin >> a >> b;
	for(int i = a; i >= 1; i--){
		if((a%i) == 0 && (b%i) == 0){
			cout << 1ll * a * b / i << endl;
			return 0;
		}
	}
	return 0;
}


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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec g(nmax);





void solve4ts()
{
    
    int a,b,n;
    cin>>a>>b>>n;
    /*
    for(int i=0;i<=n;i++){
        cout<<i<<" "<<round(a*i,b)-a*round(i,b)<<endl;
    }
    */
   int i=min(b-1,n);
    cout<<round(a*i,b)-a*round(i,b)<<endl;
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 7780
n, t = list(map(int, input().split()))
a = list(map(int, input().split()))
min_a = 1000000000
max_dif = 0
max_dif_c = 0
for i in range(n):
    if a[i] < min_a:
        min_a = a[i]
    elif a[i] - min_a > max_dif:
        max_dif = a[i] - min_a
        max_dif_c = 1
    elif a[i] - min_a == max_dif:
        max_dif_c += 1
print(str(max_dif_c))


Measured memory_bytes: 14352
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int k, s;
int ans = 0;
/**********************************************/

int main(){
    cin >> k >> s;
    
    FOR(i, 0, k+1){
        FOR(j, 0, k+1){
                int z = s - i - j;
                if(0 <= z && z <= k){
                    ans++;
                    //cout << i << " " << j << " " << z <<  endl;
                }
        }
    }
    

    cout << ans << endl;
}


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

typedef long long LL;
const int maxn=1e5+10;
int a[maxn];
int main()
{
	int n;
	LL pre=0,ans=0;
	scanf("%d",&n);
	for(int i=0;i<n;++i)
	{
		scanf("%d",&a[i]);
		if(a[i]==0)
		{
			pre=0;
			continue;
		}
		ans+=(pre+a[i])/2;
		pre=(pre+a[i])%2;
		//cout <<i<<" "<<ans<<endl;
	}
	cout <<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int A[3][10];
    int B[3][10];
    int C[3][10];
    int D[3][10];
    int N; cin >> N;
    rep(i,3) rep(j,10) A[i][j]=B[i][j]=C[i][j]=D[i][j]=0;
    rep(i,N){
        int a,b,c,d; cin >> a >> b >> c >> d;
        if(a==1){
            A[--b][--c]+=d;
        }
        else if(a==2){
            B[--b][--c]+=d;
        }
        else if(a==3){
            C[--b][--c]+=d;
        }
        else {
            D[--b][--c]+=d;
        }
    }
    rep(i,3){rep(j,10){cout <<" "<< A[i][j];} cout << endl;}
    rep(i,20) cout << '#'; cout << endl; 
    rep(i,3){rep(j,10){cout <<" "<< B[i][j];} cout << endl;}
    rep(i,20) cout << '#'; cout << endl;  
    rep(i,3){rep(j,10){cout <<" "<< C[i][j];} cout << endl;} 
    rep(i,20) cout << '#'; cout << endl;
    rep(i,3){rep(j,10){cout <<" "<< D[i][j];} cout << endl;} 

    return 0;
}


Measured memory_bytes: 3092
string = input()
ls = list(map(int, string))

count1, count2 = 0, 0

for i in range(len(ls)):
    ck = (i + 1) % 2
    if ls[i] != ck:
        count1 += 1

for j in range(len(ls)):
    ck = (j + 2) % 2
    if ls[j] != ck:
        count2 += 1

print(min(count1, count2))


Measured memory_bytes: 3956
#include<stdio.h>
int main()
{
int a,b,c,tmp;
scanf("%d %d %d",&a,&b,&c);
if (a>b){
tmp=a;
a=b;
b=tmp;
}
if(b>c){
    tmp=b;
    b=c;
    c=tmp;
}
if (a>b){
tmp=a;
a=b;
b=tmp;
}
printf("%d %d %d\n",a,b,c);


return 0;
}



Measured memory_bytes: 2120
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int A[] = new int [9];
        int a[] = new int [9]; 
        for(int i = 0; i < 9; i++){
                A[i] = sc.nextInt();
        }
        int N = sc.nextInt();
        int B[] = new int[N];
        for(int i = 0; i < N; i++){
            B[i] = sc.nextInt();
            for(int j = 0; j < 9; j++){
                if(B[i] == A[j]){
                    a[j] = 1;
                }
            }
        }
        if(a[0] == 1 && a[1] == 1 && a[2] == 1){
            System.out.println("Yes");
        }else if(a[3] == 1 && a[4] == 1 && a[5] == 1){
            System.out.println("Yes");
        }else if(a[6] == 1 && a[7] == 1 && a[8] == 1){
            System.out.println("Yes");
        }else if(a[0] == 1 && a[3] == 1 && a[6] == 1){
            System.out.println("Yes");
        }else if(a[1] == 1 && a[4] == 1 && a[7] == 1){
            System.out.println("Yes");
        }else if(a[2] == 1 && a[5] == 1 && a[8] == 1){
            System.out.println("Yes");
        }else if(a[0] == 1 && a[4] == 1 && a[8] == 1){
            System.out.println("Yes");
        }else if(a[2] == 1 && a[4] == 1 && a[6] == 1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35520
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N, K = in_nn()

    ans = 0
    for b in range(K + 1, N + 1):
        q, r = divmod(N, b)
        ans += q * (b - K) + max(0, r - K + 1)
        if K == 0:
            ans -= 1

    print(ans)


if __name__ == '__main__':
    main()


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

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

    if(n%2 == 1){
        cout << n/2 + 1 << endl;
    }
    else{
        cout << n/2 << endl;
    }

    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define each(i, a) for (auto &&i : (a))
using namespace std;

int main() {
  //入力
  int n;
  cin >> n;
  vector<string> s(n);
  each(s_i, s) cin >> s_i;

  //boolとintは比較子, stringはsの各要素
  vector<tuple<bool, int, int, string>> v;

  //sの各要素を最適化したときの'('と')'の数を数える
  each(s_i, s) {
    int il = 0, ir = 0;
    each(c, s_i) {
      if (c == '(')
        il++;  //'('はそのまま加える ")" -> ")("
      else if (il > 0)
        il--;  //')'は'('が手前にあれば打ち消す ")(" -> ")()" -> ")"
      else
        ir++;  //なければそのまま加える -> ")" -> "))"
    }
    //並べ方
    //(1)左括弧の方が多ければ左端側に置く, 右は右端 [")((", "))("]
    //(2)少ない方の括弧が少ないほど端側に置く ["(", ")((", "))(", ")"]
    //(3)多い方の括弧が多いほど端側に置く [")(((", ")((", "))(", ")))("]
    if (il > ir)
      v.push_back(make_tuple(false, ir, -il, s_i));
    else
      v.push_back(make_tuple(true, -il, ir, s_i));
  }

  //ソートしてstringを繋げる
  sort(begin(v), end(v));
  string a = "";
  each(t, v) a += get<3>(t);

  //繋げたものを最適化
  int al = 0, ar = 0;
  each(c, a) {
    if (c == '(')
      al++;
    else if (al > 0)
      al--;
    else
      ar++;
  }

  //最適化して括弧が無くなればYes
  if (al + ar == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()

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

int n;
ll k;

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

	ll ma=0,g;
	cin>>n>>k;
	REP(i,n) {
		ll a; cin>>a;
		if(i==0) g=a;
		else g=__gcd(g,a);
		ma=max(ma,a);
	}
	if(k<=ma&&k%g==0) cout<<"POSSIBLE"<<endl;
	else cout<<"IMPOSSIBLE"<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <chrono>
#include <complex>
#include <cstdint>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = int64_t;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll n;
        in >> n;
        ll pt = 0, px = 0, py = 0;
        bool ok = true;
        for (int i = 0; i < n; i++) {
            ll t, x, y;
            in >> t >> x >> y;
            ll nt, nd;
            nt = t - pt;
            nd = abs(x - px) + abs(y - py);
            if (nd <= nt && nt % 2 == nd % 2) {
                pt = t;
                px = x;
                py = y;
            }
            else {
                ok = false;
                break;
            }
        }
        out << (ok ? "Yes" : "No") << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


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

using ll = long long;

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

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

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

    int N;
    string S;
    int Q;
    cin >> N >> S >> Q;
    vector<int> K(Q); cin >> K;

    for (int k : K) {
        ll d = 0, m = 0, dm = 0, ans = 0;
        for (int i = 0; i < N; i++) {
            if (i >= k) {
                if (S[i-k] == 'D') {
                    d--;
                    dm -= m;
                } else if (S[i-k] == 'M') {
                    m--;
                }
            }
            if (S[i] == 'D') {
                d++;
            } else if (S[i] == 'M') {
                m++;
                dm += d;
            } else if (S[i] == 'C') {
                ans += dm;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 1948
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <time.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
//const int mod = 1e9 + 7;
//const int mod = 998244353;
const int mod = 1000003;

vector<ll> fac(MAX), finv(MAX), inv(MAX);

void comInit(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(ll 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;
	}
}


ll com(ll n, ll k){
	if(n < k) return 0;
	if(n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

ll modpow(ll x, ll n, ll mod){
	ll res = 1;
	while(n > 0){
		if(n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

int main(){
	ll q; cin >> q;
	comInit();
	while(q--){
		ll x,d,n; scanf("%lld%lld%lld",&x,&d,&n);
		if(d == 0) cout << modpow(x,n,mod) << "\n";
		else{
			if(n >= mod){
				puts("0");
				continue;
			}
			ll p = x * inv[d] % mod;
			if(p + n > mod || p == 1){
				puts("0");
				continue;
			}
			ll ans = fac[p+n-1] * finv[p-1] % mod;
			ans = ans * modpow(d,n,mod) % mod;
			cout << ans << "\n";
		}
	}
}

Measured memory_bytes: 50348
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, C; cin >> n >> C;
    vector<vector<P>> ch(C);
    rep(i,n){
        int s, t, c; cin >> s >> t >> c;
        --c;
        ch[c].push_back(P(s,t)); 
    }
    rep(i,C) sort(ALL(ch[i]));
    for(int i = 0; i < C; i++){
        for(int j = 0; j < (int)ch[i].size() - 1; j++){//cast
            if(ch[i][j].second == ch[i][j+1].first){
                ch[i][j+1].first = ch[i][j].first;
                ch[i][j] = P(1,0);
            }
        }
    }    
    for(int i = 0; i < C; ++i){
        for(int j = 0; j < ch[i].size(); j++){
            ch[i][j].first--;
        }
    }
    vector<int> num(100005);
    for(int i = 0; i < C; i++){
        for(int j = 0; j < ch[i].size(); j++){
            num[ch[i][j].first]++;
            num[ch[i][j].second]--;
        }
    }
    for(int i = 0; i <= 100000; i++){
        num[i+1] += num[i];
    }
    int res = 0;
    for(int i = 0; i <= 100000; i++){
        res = max(res, num[i]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int ans=1;
    for(int i=1;i<s.length();i++){
        if(s[i]!=s[i-1]){
            ans++;
        }
    }
    cout<<ans-1<<endl;
    return 0;
}

Measured memory_bytes: 512
n, m = map(int, input().split())
hole_ids = {int(input()) - 1: 0 for _ in range(m)}
X = 1000000007


def solve(n, hole_ids):
    # nums = []
    nums = [0] * n
    for i in range(n):
        if i in hole_ids:
            # nums.append(0)
            nums[i] = 0
            continue

        if i == 0:
            # nums.append(1)
            nums[i] = 1
        elif i == 1:
            # 1つ前から1段上がるから2つ前から2個飛ばし
            # nums.append(nums[-1] + 1)
            nums[i] = nums[i-1] + 1
        else:
            # nums.append((nums[-1] % X + nums[-2] % X) % X)
            nums[i] = (nums[i-1] + nums[i-2]) % X
    return nums[-1]


print(solve(n, hole_ids))


Measured memory_bytes: 15068
#include<bits/stdc++.h>
using namespace std;
const int maxx = 100001;
int f[maxx];
int num[maxx];
int read(){int k;scanf("%d",&k);return k;}
int main (){
	int n=read();
	int m=read();
	f[1]=1;
	for(int i=1;i<=n;i++)num[i]=1;
	for(int i=1;i<=m;i++){
		int a=read();int b=read();
		if(f[a]==1)f[b]=1;
		num[b]++;num[a]--;
		if(num[a]==0)f[a]=0;
	}
	int ans=0;
	for(int i=1;i<=n;i++)ans+=f[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
using System;
using System.IO;

namespace MinPro2019D
{
    public class Program
    {
        static readonly Stream stream = Console.OpenStandardInput(1024);
        static readonly byte[] buffer = new byte[1024];
        static int index;
        static int length;
        static int L;
        static readonly long[] dp = new long[5];
        static long A;
        static long x;

        static void Main()
        {
            length = stream.Read(buffer, 0, 1024);

            while (48 <= buffer[index] && buffer[index] <= 57)
            {
                L = L * 10 + buffer[index] - 48;
                ++index;
                if (index < length) continue;
                index = 0;
                length = stream.Read(buffer, 0, 1024);
            }

            for (int i = 0; i < L; i++)
            {
                A = 0;

                while (buffer[index] < 48 || 57 < buffer[index])
                {
                    ++index;
                    if (index < length) continue;
                    index = 0;
                    length = stream.Read(buffer, 0, 1024);
                }

                while (48 <= buffer[index] && buffer[index] <= 57)
                {
                    A = A * 10 + buffer[index] - 48;
                    ++index;
                    if (index < length) continue;
                    index = 0;
                    length = stream.Read(buffer, 0, 1024);
                }

                x = A == 0 ? 2 : A & 1;

                dp[0] += A;
                dp[1] += x;
                dp[2] += (x & 1) ^ 1;
                dp[3] += x;
                dp[4] += A;
                dp[1] = Math.Min(dp[1], dp[0]);
                dp[2] = Math.Min(dp[2], dp[1]);
                dp[3] = Math.Min(dp[3], dp[2]);
                dp[4] = Math.Min(dp[4], dp[3]);
            }

            Console.WriteLine(dp[4].ToString());
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
#define MOD2 1000000009
#define sp fixed<<setprecision
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
ll fpow(ll x,ll y,ll p=MOD){x=x%p;ll sum=1;while(y){if(y&1)sum=sum*x;sum%=p;y=y>>1;x=x*x;x%=p;}return sum;}
ll inv(ll a,ll m=MOD){ll c=m;ll y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=c;return x;}
ll add(ll a, ll b) {if(a<0)a+=MOD; if(b<0)b+=MOD; return (a%MOD + b%MOD + MOD)%MOD;}
ll sub(ll a, ll b) {if(a<0)a+=MOD; if(b<0)b+=MOD; return (a%MOD - b%MOD + MOD)%MOD;}
ll mul(ll a, ll b) {if(a<0)a+=MOD; if(b<0)b+=MOD; return ((a%MOD)*(b%MOD) + MOD)%MOD;}
void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (sz(name)) {
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}
int main(){
    setIO();
    string s;
    cin>>s;
    int n = s.size();
    if(s[n-1]=='s'){
      cout<<s;
      cout<<"es\n";
    }
    else{
      cout<<s+"s"<<"\n";
    }
}


Measured memory_bytes: 3640
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
//    cout << fixed << setprecision(10);
    
    int N;
    string S;
    cin >> N >> S;
    
    vector<int> remainR(N+1, 0);
    vector<int> remainB(N+1, 0);
    vector<int> remainG(N+1, 0);
    
    for (int i = N - 1; i >= 0; i--) {
        remainR[i] = remainR[i + 1];
        remainB[i] = remainB[i + 1];
        remainG[i] = remainG[i + 1];
        if (S[i] == 'R') {
            remainR[i]++;
        } else if (S[i] == 'B') {
            remainB[i]++;
        } else {
            remainG[i]++;
        }
    }
    
    int RGB = 'R' + 'G' + 'B';
    long long sum = 0;
    for (int i = 0; i < N - 2; i++) {
        for (int j = i + 1; j < N - 1; j++) {
            char remain = RGB - S[i] - S[j];
            if (S[i] != S[j]) {
                if (remain == 'R') {
                    sum += remainR[j];
                } else if (remain == 'G') {
                    sum += remainG[j];
                } else {
                    sum += remainB[j];
                }
                int target = 2 * j - i;
                if (target < N) {
                    if (S[target] == remain) {
                        sum --;
                    }
                }
            }
        }
    }

    cout << sum;

    return 0;
}

Measured memory_bytes: 3644
//どうかACをお恵みくださいお願いしますお願いしますお願います何もしませんから
using System;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            int n = S.Length;
            int[] s = new int[n];
            for(int x = 0;x < n;x++)
            {
                s[x] = ((int)S[x] + N -64) % 26 + 64;
                if(s[x]==64)
                {
                    s[x] = 90;
                }
                Console.Write((char)s[x]);
            }
        }
    }
}

Measured memory_bytes: 27548
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
    n = readline() |> parseInt
    a = readline() |> split |> parseMap

    ans = 0
    for i in 1:n
        while mod(a[i],2) == 0
            a[i] /= 2
            ans += 1
        end
    end

    println(ans)
end

main()


Measured memory_bytes: 112360
#include<iostream>
#include<algorithm>
#define INF 999999
typedef long long ll;
using namespace std;
int n,a,b,c,maxm,x;
int sum,miniNo,minim;
bool t[1000001];
bool isPrime(int x){
	for(int i=2;i*i<=x;i++){
		if(x%i==0)return false;
	}
	return true;
}
int main(){
	while(1){
		fill(t,t+1000001,0);
		cin>>n>>x;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>a;
			t[a]=true;
			for(int j=1;j+a<1000001;j++){
				t[j+a]=(t[j]||t[j+a]);
			}
		}
		b=0;
		for(int i=x;i>=1;i--){
			if(isPrime(i)&&t[i]){
				cout<<i<<endl;
				b=1;
				break;
			}
		}
		if(b==0)cout<<"NA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 2136
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int64_t N, K;
    cin >> N >> K;
    if(N < K)
    {
        cout << min(K - N, N) << endl;
        return 0;
    }
    else if(N == K)
    {
        cout << 0 << endl;
        return 0;
    }

    int64_t i = N / K;

    cout << min(N-i*K, abs(N-(i+1)*K)) << endl;
    return 0;
}

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

signed main(){

  string s; cin >> s;

  int tosi = (int)(s[0]-'0')*10 + (int)(s[1]-'0');
  int nen = (int)(s[2]-'0')*10 + (int)(s[3]-'0');
  
  if((1 <= nen && nen <= 12) && !(1 <= tosi && tosi <= 12)){
    cout << "YYMM" << endl;
  }
  else if(!(1 <= nen && nen <= 12) && (1 <= tosi && tosi <= 12)){
    cout << "MMYY" << endl;
  }
  else if((1 <= nen && nen <= 12) && (1 <= tosi && tosi <= 12)){
    cout << "AMBIGUOUS" << endl;
  }
  else {
    cout << "NA" << endl;
  }

  return 0;
}


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

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

  string s;
  cin >> s;
  int n = s.size();

  rep(i, 1, n + 1) {
    if ((i % 2 == 1 && s[i - 1] == 'L') || (i % 2 == 0 && s[i - 1] == 'R')) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

int main() {
  int N, paper;
  cin >> N;
  if (N % 2 == 0){
    paper = N/2;
  } 
  else {
    paper = N/2 + 1;
  }
  cout << paper << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String[] ar = str.split("");
        int c = 0;
        String r = "R";
        if (ar[0].equals(r)) {
            c = c + 1;
        } else {
            c = c;
        }
        if (ar[1].equals(r)) {
            c = c + 1;
        } else {
            c = c;
        }
        if (ar[2].equals(r)) {
            c = c + 1;
        } else {
            c = c;
        }
        if (c == 1 || c == 3 || c == 0) {
            System.out.println(c);
        } else if ( c == 2 && ar[0].equals(r) && ar[2].equals(r)) {
            System.out.println(1);
        } else {
            System.out.println(2);
        }
    }
}

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

int main() {
  string s;
  cin >> s;
  
  if (s == "Sunny") cout << "Cloudy" << endl;
  if (s == "Cloudy") cout << "Rainy" << endl;
  if (s == "Rainy") cout << "Sunny" << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val xyh = (1..N).map { readLine()!!.split(" ").map { it.toInt() } }
    var cx = 0; var cy = 0; var H = Int.MAX_VALUE
    for (x in 0..100) for (y in 0..100) {
        val first = xyh.first { it[2] != 0 }
        val h = Math.abs(x - first[0]) + Math.abs(y - first[1]) + first[2]
        if (h < H && xyh.all { it[2] == Math.max(h - Math.abs(x - it[0]) - Math.abs(y - it[1]), 0) }) {
            cx = x; cy = y; H = h
        }
    }
    println("$cx $cy $H")
}

Measured memory_bytes: 37904
#include<bits/stdc++.h>
using namespace std;
int main(){
 int x,y;
 cin >> x >> y;
 vector<int>a(x);
 int sum = 0;
 for(int i = 0;i<x;i++){
   cin >> a[i];
 }
 for(int i = 0;i<x;i++) sum += a[i];
 int d = 0;
 int c = (sum+4*y-1)/(4*y);
 for(int i = 0;i<x;i++){
   if(a[i]>= c) d++;
 }
 if(d<y) cout << "No";
 else cout << "Yes";
 return 0;
}



Measured memory_bytes: 256
def main():
  import sys
  input = sys.stdin.readline
  n=int(input())
  xy=[list(map(int,input().split())) for _ in [0]*n]
  ans=0
  for i in range(n):
    xi,yi=xy[i][0],xy[i][1]
    for j in range(n):
      xj,yj=xy[j][0],xy[j][1]
      ans+=pow(pow(xi-xj,2)+pow(yi-yj,2),0.5)
  print(ans/n)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064