akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<queue>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
    int to;
    T cost;
    Edge() {};
    Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
    int n;
    bool directed;
    vector<vector<Edge<T>>> edges;
public:

    Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)){};
    Graph() {};

    void add(int to, T cost) {
        emplace_back(to, cost);
    }

    int size() {
        return n;
    }
};


int main() {

    int N;

    cin >> N;

    vi A(N);

    REP(i,N)cin >> A[i];

    bool ans = true;

    REP(i,N){
        if(A[i]%2==0){
                if(A[i]%3 != 0 && A[i]%5!=0)ans = false;
        }
    }

    cout << (ans?"APPROVED":"DENIED") << endl;

    return 0;
}

Measured memory_bytes: 256
def resolve():
    X, N = map(int, input().split())
    if N == 0:
        print(X)
        return
    A = set(map(int, input().split()))
    dic = {}
    for i in range(-10, 110):
        if i not in A:
            dic[i] = abs(X-i)

    sorted_A = sorted(dic.items(), key=lambda x:(x[1], x[0]))
    print(sorted_A[0][0])

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9196
N, W = map(int, input().split())

inf = float("inf")
dp = [[-inf for _ in range(W+1)] for _ in range(N+1)]
for w in range(W+1):
    dp[0][w] = 0

value = []
weight = []

for _ in range(N):
    v, w = map(int, input().split())
    value.append(v)
    weight.append(w)

for i in range(N):
    for w in range(W+1):
        if w>=weight[i]:
            dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w], dp[i+1][w-weight[i]]+value[i])
            #3項目が重複を許すもの。wが1ずつ増えていき、今回のwの最小は1なので、左のvalueも使える
        else:
            dp[i+1][w] = dp[i][w]

print(dp[N][W])



Measured memory_bytes: 42308
#include<iostream>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;

int M[2001][2001] = {};
int N, Y;

int main()
{
	cin >> N >> Y;
	int x = 0, y = 0, z = 0;
	M[0][0] = Y / 1000;
	for(int j=1;j<2001;j++)
	{
		M[0][j] = M[0][j - 1] - 10;
	}
	for (int i = 1; i<2001; i++)
	{
		M[i][0] = M[i-1][0] - 5;
	}
	for (int i = 1; i<2001; i++)
	{
		for (int j = 1; j<2001; j++)
		{
			M[i][j] = M[i - 1][j-1] - 15;
		}
	}
	REP(i, 2001)
	{
		REP(j, 2001)
		{
			if (M[i][j]>=0&&N == M[i][j] + i + j)
			{
				cout << j << " " << i << " " << M[i][j] << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  rep(j, s.length()) {
    if (s[j] == 'h' && s[j + 1] == 'i')
      j++;
    else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int min(int a, int b)
{
    return a < b? a: b;
}

int main(void)
{
    int n, y;
    scanf("%d%d", &n, &y);
    //1k-yen only.
    int y1k = y / 1000;
    int y5k = 0;
    int y10k = 0;
    int cnt = y1k + y5k + y10k;
    if (cnt == n) printf("%d %d %d\n", y10k, y5k, y1k);
    else if (cnt < n) printf("-1 -1 -1\n");
    //1k-yen and 5k-yen.
    else {
        int dif = cnt - n;
        int y1k2y5k = min(dif / 4, y1k / 5);
        y5k += y1k2y5k;
        y1k -= y1k2y5k * 5;
        cnt = y1k + y5k + y10k;
        if (cnt == n) printf("%d %d %d\n", y10k, y5k, y1k);
        //1k-yen, 5k-yen and 10k-yen.
        else {
            dif = cnt - n;
            int y5k2y10k = min(dif, y5k / 2);
            y10k += y5k2y10k;
            y5k -= y5k2y10k * 2;
            cnt = y1k + y5k + y10k;
            if (cnt == n) printf("%d %d %d\n", y10k, y5k, y1k);
            else printf("-1 -1 -1\n");
        }
    }
    return 0;
}


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

namespace CSharpSample01
{

    
    
    class Program
    {
        //GCD(最大公約数)
        static long GCD(long big, long smoll)
        {
            if(big < smoll)
            {
                long tmp = big;
                big = smoll;
                smoll = tmp;
            }

            while(smoll > 0)
            {
                long amari = big % smoll;
                big = smoll;
                smoll = amari;
            }

            return big;
        }

        //最大公約数(LCM)
        static long LCM(long a, long b)
        {
            return (long)a / GCD(a, b) * b;
        }


        static void Main(string[] args)
        {
            while (true)
            {
                string str = Console.ReadLine();
                if (str == null) break;
                string[] input = str.Split(' ');               
                long a = int.Parse(input[0]);
                long b = int.Parse(input[1]);

                Console.WriteLine($"{GCD(a, b)} {LCM(a, b)}");
                
            }
            
        }
    }
}


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

int n,k,ans=1e18+7;
int a[200005];

inline int up(int aa,int bb)
{
	if (aa%bb==0)  return aa/bb;
	else return (aa/bb)+1;
}

bool check(int len)
{
	int tot=0;
	for (int i=1;i<=n;i++)  tot=tot+up(a[i],len)-1;
	
	if (tot<=k)  return true;
	else return false;
}

int Binary_search(int l,int r)
{
	if (l==r||l+1==r)
	{
		if (check(l))  ans=min(ans,l);
		if (check(r))  ans=min(ans,r);
		return ans; 
	}
	int mid=(l+r)>>1;
	if (check(mid))
	{
		ans=min(ans,mid);
		return Binary_search(l,mid);
	}
	else return Binary_search(mid+1,r);
}

signed main()
{
	cin>>n>>k;
	for (int i=1;i<=n;i++)  cin>>a[i];
	
	cout<<Binary_search(1,1e9)<<endl;
	
	return 0;
}

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

int main()
{
    char s[40];
    int a,b,n;
    while(~scanf("%s",s))
    {
        n=0;
      a=strlen(s);
      for(b=0;b<a;b++)
      {
          if(s[b]=='+')
            n++;
          else if(s[b]=='-')
            n--;
      }
      printf("%d\n",n);

    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#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 MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
const double PI = acos(-1);
typedef long long ll;


int main(void){
    int X;cin>>X;
    int cnt=X/100;
    //cout<<cnt<<endl;
    if(X-100*cnt<=5*cnt){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }
}




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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int a, b;
  char x;
  cin >> a >> x >> b;
  if(x=='+'){
    prt(a+b);
  } else {
    prt(a-b);
  }
}


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

//vector…可変長、データの大きさに合わせてサイズを変える
//list…双方向リスト、要素を挿入、削除の多いとき
//forward_list
//array…固定長配列
//set…集合
//multiset
//bitset…2進数、固定長ビット列
//map…連想配列、キーと値を関連付ける
//multimap
//deque…双方向リスト
//stack…FILO, 深さ優先探索
//queue…FIFO, 幅優先探索
//priority_queue…格納された最大値から順に取り出す
//pair…二つの値を一組
//tuple…複数の値を一組

template<typename T>
void remove(std::vector<T>& vector, char index) {
    vector.erase(vector.begin() + index);
}

template<class T>
T ma(std::vector<T> &v) {
    T maxi = 0;
    for(auto &i:v) maxi = max(maxi, i);
    return maxi;
}
template<class T>
T mi(std::vector<T> &v) {
    T mini = 0;
    for(auto &i:v) mini = min(mini, i);
    return mini;
}
template <class T>
T pow(T x, T y, T n = numeric_limits<T>::max()) {
    if(y == 0) return 1;
    if(y % 2 == 0) return pow((x * x) % n, y / 2);
    return (x * pow(x, y - 1)) % n;
}

#define rep(i, n, m) for (int i = n; i <= m; i++)
#define Rep(i, n, m) for (int i = m; i >= 1; i--)

typedef long long ll;
typedef unsigned long long ull;

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    return !y ? x : gcd(x % y, y);
}

using Graph = vector<vector<int>>;

template <class T, class S>
class Edge {
  T to;  //辺の行き先
  S weight;  //辺の重み

public:
  Edge(T t, S w) : to(t), weight(w) {}
};

int ansi = 0;
ll ansl = 0;
double ansd = 0.0;

int main() {
  int n;
  cin >> n;
  vector<int> P(n);
  rep(i, 0, n-1) cin >> P[i];
  int cont = 0;
  rep(i, 1, P.size()-2) {
    if ((P[i-1] < P[i] && P[i] < P[i+1]) || (P[i-1] > P[i] && P[i] > P[i+1]))
      cont++;
  }
  cout << cont << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cstdlib>
#include <stack>
#include <random>

using namespace std;

typedef long long ll;

int sm(int x)
{
    int res = 0;
    while (x > 0)
    {
        res += x % 10;
        x /= 10;
    }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int a = 1, b = n - 1;
    int ans = sm(a) + sm(b);
    while (a <= b)
    {
        ans = min(ans, sm(a) + sm(b));
        a++;
        b--;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    cout << n/3 << endl;
}
    

Measured memory_bytes: 256
LOCAL = True and False


def dprint(*args):
  if LOCAL:
    print(*args)


n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = input()
t = '*' * k + t

dprint(t)

ans = 0
# for i, x in enumerate(t):
for i in range(k, n + k):
  x = t[i]
  dprint(i, x)
  j = i - k
  if x == 'r':
    dprint('t[j]', '=', t[j])
    dprint('x', '=', x)
    if t[j] != x:
      ans += p
    else:
      t = t[:i] + '*' + t[i + 1:]
  if x == 's':
    if t[j] != x:
      ans += r
    else:
      t = t[:i] + '*' + t[i + 1:]
  if x == 'p':
    if t[j] != x:
      ans += s
    else:
      t = t[:i] + '*' + t[i + 1:]
  dprint(t)
  dprint(ans)

print(ans)


Measured memory_bytes: 3828
#include<iostream>
#include<vector>
#include<algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n, U, a[20], b[20], c, r[20], popcount[1048588], sum[1048588];
vector<pair<int, int>>popcnts[21];
int main() {
	for (int i = 0; i < 20; i++) {
		for (int j = 1 << i; j < 2 << i; j++) {
			popcount[j] = popcount[j - (1 << i)] + 1;
		}
	}
	for (int i = 1; i <= 20; i++) {
		for (int j = 0; j < (1 << i); j++)popcnts[i].push_back(make_pair(popcount[j], j));
		sort(popcnts[i].begin(), popcnts[i].end());
	}
	while (scanf("%d%d", &n, &U), n) {
		for (int i = 0; i < n; i++) {
			scanf("%d%d", &a[i], &b[i]); r[i] = 0;
			for (int j = 0; j < b[i]; j++) {
				scanf("%d", &c);
				r[i] |= 1 << c;
			}
		}
		sum[0] = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 1 << i; j < 2 << i; j++) {
				sum[j] = sum[j - (1 << i)] + a[i];
			}
		}
		int minx = 10000000;
		for (int h = 0; h < (1 << n); h++) {
			int i = popcnts[n][h].second;
			if (sum[i] < U)continue;
			bool flag = false;
			int G = (1 << n) - i - 1;
			for (int j = 0; j < n; j++) {
				if ((i & (1 << j)) && (G & r[j])) {
					flag = true;
					break;
				}
			}
			if (!flag) { minx = min(minx, popcount[i]); break; }
		}
		cout << minx << endl;
	}
	return 0;
}

Measured memory_bytes: 27680
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;
    
    int s_id = N - 1, t_id = 0;
    int cnt = 0;
    for(int i = 1; i <= N; ++i){
        if(s.substr(N - i, i) != t.substr(0, i))        continue;
        
        cnt = i;
    }
    
    cout << N + N - cnt << endl;
}

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

void moveN(int dice[]){
	int temp[6];
	for(int i = 0;i < 6; i++){
		temp[i] = dice[i];
	}
	dice[0] = temp[1];
	dice[1] = temp[5];
	dice[5] = temp[4];
	dice[4] = temp[0];
}

void moveS(int dice[]){
	int temp[6];
	for(int i = 0;i < 6; i++){
		temp[i] = dice[i];
	}
	dice[1] = temp[0];
	dice[5] = temp[1];
	dice[4] = temp[5];
	dice[0] = temp[4];
}

void moveW(int dice[]){
	int temp[6];
	for(int i = 0;i < 6; i++){
		temp[i] = dice[i];
	}
	dice[0] = temp[2];
	dice[2] = temp[5];
	dice[5] = temp[3];
	dice[3] = temp[0];
}

void moveE(int dice[]){
	int temp[6];
	for(int i = 0;i < 6; i++){
		temp[i] = dice[i];
	}
	dice[2] = temp[0];
	dice[5] = temp[2];
	dice[3] = temp[5];
	dice[0] = temp[3];
}

int main(){
	int dice[6];
	int temp[6];
	string command;

	for(int i = 0; i < 6; i++){
		cin >> dice[i];
	}

	cin >> command;
	int lenOfCommand = command.length();

	for(int i = 0; i < lenOfCommand; i++){
		switch(command[i]){
			case 'N': moveN(dice); break;
			case 'S': moveS(dice); break;
			case 'W': moveW(dice); break;
			case 'E': moveE(dice); break;
		}
	}

	cout << dice[0] << endl;

	return 0;
}


Measured memory_bytes: 3220
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;

/* dp[i][j] : Least weight required to make a value j using the first i items.
*/
ll dp[102][N];

void solve()
{
    int n, w;
    scn(n); scn(w);

    vi wt(n+1), val(n+1);

    rep(i, 1, n+1) {
        scn(wt[i]); scn(val[i]);
    }

    rep(i, 1, N)
    dp[0][i] = (int) 2e9;

    dp[0][0] = 0;

    rep(i, 1, n+1) {
        rep(j, 0, N) {
            dp[i][j] = (int) 2e9;
            if(j == 0) {
                dp[i][j] = 0;
            } else {
                if(val[i] <= j and dp[i-1][j - val[i]] != (int) 2e9) {
                    dp[i][j] = min(dp[i-1][j], wt[i] + dp[i-1][j - val[i]]);
                } else {
                    dp[i][j] = dp[i-1][j];
                }
            }
        }
    }

    int mx = 0;

    rep(i, 0, N) {
        if(dp[n][i] <= w)
            mx = i;
    }

    prin(mx);
}

int main()
{
    int t = 1;
    // scn(t);

    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 161576
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iostream>
using namespace std;
template<class _T>inline void read(_T &_a)
{
	bool f=0; char _c=getchar(); _a=0;
	while(_c<'0'||_c>'9'){ if(_c=='-') f=1; _c=getchar(); }
	while(_c>='0'&&_c<='9'){ _a=(_a<<3)+(_a<<1)-'0'+_c; _c=getchar(); }
	if(f) _a=-_a;
}

const double pi=3.1415926;
double r;

int main()
{
	scanf("%lf",&r);
	printf("%.2lf",2*pi*r);
	return 0;
}

Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define  sci(x)   scanf("%d", &x)
#define  scl(x)   scanf("%lld", &x)
#define  scd(x)   scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
 
int main ()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	//CODE TONOY
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b<<endl;			
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YN(x)         cout << ((x) ? "YES" : "NO") << endl
#define Yn(x)         cout << ((x) ? "Yes" : "No") << endl
#define yn(x)         cout << ((x) ? "yes" : "no") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  // 10^18 くらいまでいける

// for DP
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } 

const ll INF = 1LL << 60;

int main(){
  string s;
  ll t, k;
  cin >> t >> k;
  ll ans = 0;
  while (t){
    t = t / k;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n,m;cin>>n>>m;
  map<int,int> ac,wa;
  int cnt1=0,cnt2=0;
  rep(i,m){
    int p;string s;cin>>p>>s;
    if(s=="WA")wa[p]++;
    else {
      if(ac[p]==0){
        cnt2+=wa[p];
        ac[p]=1;
        cnt1++;
      }
    }
  }
  cout<<cnt1<<" "<<cnt2<<endl;
}

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

int main(){
    int n;
    cin >> n;
    pair<int,int> now = {0,0};
    int old = 0;
    for(int i = 0; i < n; i++){
        int s;
        cin >> s;
        int t = s - old;
        old = s;
        int x,y;
        cin >> x >> y;
        if(t-abs(x-now.first)-abs(y-now.second) != 1 && t-abs(x-now.first)-abs(y-now.second) >= 0 && t-abs(x-now.first)-abs(y-now.second) != 3){
            now = {x,y};
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3644
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

public class Program
{

    public static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        char[] a = s[0].ToCharArray();
        char[] b = s[1].ToCharArray();
        char[] c = s[2].ToCharArray();
        Console.WriteLine(a[0].ToString().ToUpper() + b[0].ToString().ToUpper() + c[0].ToString().ToUpper());
    }

    static int[] s_to_i(string[] s)
    {
        int[] ret = Array.ConvertAll<string, int>(s, delegate (string value) { return int.Parse(value); });
        return ret;
    }
}

Measured memory_bytes: 11092
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

ll count(vector<ll> a, ll n, ll v) {
    ll tot = 0;
	for (ll i = 0; i < n; ++i) {
		tot += n - (lower_bound(a.begin(), a.end(), v - a[i]) - a.begin());
	}
	return tot;
}

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n,0);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    vector<ll> s(n+1,0);
    for (ll i = 0; i < n; ++i) {
        s[i+1] = s[i] + a[n - 1- i];
    }

	ll mi = 0;
	for (ll i=40; i>=0; i--) {
        if (count(a, n, mi+(1LL<<i)) >=m ) {
            mi += 1LL<<i;
        }
    }

	ll num=0;
	ll ret=0;
    for (ll i = 0; i < n; ++i) {
		ll x = n - (lower_bound(a.begin(), a.end(), mi - a[i]) - a.begin());
		num += x;
		ret += a[i]*x + s[x];		
	}

	ret -= (num-m)*mi;
	cout<<ret<<endl;
}

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

vector<P> to[MAXN];
ll ans[MAXN][MAXN];
ll n, m, l;

void dijkstra(int s) {
  rep(i, n) ans[s][i] = Inf;
  ans[s][s] = 0;
  priority_queue<P, vector<P>, greater<P>> que;
  que.push(P (0,s));
  while (!que.empty()) {
    P tmp = que.top();
    que.pop();
    ll d, u;
    d = tmp.first; u = tmp.second;
    if (d > ans[s][u]) continue;
    for (P e : to[u]) {
      ll cost, v;
      cost = e.second; v = e.first;
      if (cost <= (l - d%l)) {
        ll nd = d + cost;
        if (nd < ans[s][v]) {
          que.push(P (nd, v));
          ans[s][v] = nd;
        }
      }
      else if (cost <= l) {
        ll nd = d + (l-d%l) + cost;
        if (nd < ans[s][v]) {
          que.push(P (nd, v));
          ans[s][v] = nd;
        }
      }
    }
  }
}

void solve() {
  rep(i, n) dijkstra(i);
  rep(i, n) {
    rep(j, n) {
      if (ans[i][j] == Inf) ans[i][j] = -1;
      if (ans[i][j] > 0) ans[i][j] = (ans[i][j] - 1) / l;
    }
  }
}

int main() {
  cin >> n >> m >> l;
  rep(i, m) {
    ll a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    to[a].push_back(P (b,c));
    to[b].push_back(P (a,c));
  }

  solve();

  int q;
  cin >> q;
  rep(i, q) {
    int s, t;
    cin >> s >> t;
    --s; --t;
    cout << ans[s][t] << endl;
  }
  return 0;
}

Measured memory_bytes: 3584
/*
Problem :
Algorithm :
Status :
*/
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#define DEBUG printf("Passing Line %d in Function [%s].\n",__LINE__,__FUNCTION__);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3f3f3f3f;
const string S = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
const int L = 128;

int n;
vector<string> vec;

int Query(string s){
    cout << "? " << s << endl;
    int res;
    cin >> res;
    return res;
}

string Merge(int l,int r){
    if(l == r)
        return vec[l];
    int mid = (l + r) >> 1;
    string sl = Merge(l,mid),sr = Merge(mid + 1,r);
    string s = "";
    int lenl = sl.length(),lenr = sr.length();
    for(int i = 0,j = 0,k = n - lenl;i <= lenl;i++){
        if(i == lenl){
            while(j < lenr){
                s += sr[j];
                j++;
            }
            break;
        }
        while(j < lenr && Query(s + sr[j] + sl.substr(i)) == k - 1){
            s += sr[j];
            j++;
            k--;
        }
        s += sl[i];
    }
    return s;
}

int main(){
    // freopen("data.in","r",stdin);
    // freopen("data.out","w",stdout);
    for(char c : S){
        string s(L,c);
        int num = L - Query(s);
        if(num)
            vec.push_back(s.substr(0,num));
        n += num;
    }
    string ans = Merge(0,vec.size() - 1);
    cout << "! " << ans << endl;
    return 0;
}


Measured memory_bytes: 3792
#include <iostream>
#include <vector>
#include <string>
#include <map>

int main() {
  std::string w;
  std::cin >> w;

  std::map<char, int> mp;

  for (auto it = w.begin(); it != w.end(); it++) {
    mp[*it]++;
  }

  bool flag = true;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    if (it->second % 2 != 0) flag = false;
  }
  if (flag) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
 
using namespace std;
 
#define MAX 40004
 
int n;
 
 
long double A[MAX];
long double B[MAX];
 
vector<pair<double, double> > v;
 
vector<pair<long double, long double > > mp;
 
struct BIT {
	vector<int> bit;
	void resize(int N) {
		bit.assign(N, 0);
	}
	void add(int i, int j) {
		i++;
		while (i < bit.size()) {
			bit[i] += j;
			i += i&-i;
		}
	}
	int sum(int i) {
		int r = 0;
		i++;
		while (i) {
			r += bit[i];
			i -= i&-i;
		}
		return r;
	}
	int rng(int lef, int rig) {
		int F = sum(rig);
		if (lef) {
			F -= sum(lef - 1);
		}
		return F;
	}
};
BIT b;
 
map<long double, int> mpp;
int ord[MAX];
 
int cnt_lef(long double X) {
	b.resize(n + 1);
	mp.clear();
	for (int i = 0; i < n; i++) {
		mp.push_back({ A[i] * X + B[i],ord[i] } );
	}
	sort(mp.begin(), mp.end());
	int same = 0;
	int rig = 0;
	double pr = -114;
	int conc = 0;
	for (auto it = mp.rbegin(); it != mp.rend(); it++) {
		if ((*it).first == pr) {
			conc++;
		}
		else {
			conc = 1;
			pr = (*it).first;
		}
		same += conc-1;
		rig += b.sum((*it).second - 1);
		b.add((*it).second, 1);
	}
	int lef = n*(n - 1) / 2 - same - rig;
	return rig - lef;
}
 
double solve() {
	mpp.clear();
	for (int i = 0; i < n; i++) {
		mpp[A[i]] = 0;
	}
	int cc = 0;
	for (auto it = mpp.begin(); it != mpp.end(); it++) {
		(*it).second = cc;
		cc++;
	}
	for (int i = 0; i < n; i++) {
		ord[i] = mpp[A[i]];
	}
	double mint = -199999999;
	double maxt = 199999999;
	double EP = 1e-9;
	for(int i=0;i<70;i++) {
		double mid = (mint + maxt) / 2.0;
		int flag = cnt_lef(mid);
		if (flag <= 0) {
			maxt = mid;
		}
		else {
			mint = mid;
		}
	}
	return mint;
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		A[i] = (long double)(a) / (long double)(b);
		B[i] = -(long double)(c) / (long double)(b);
	}
	double X = solve();
	for (int i = 0; i < n; i++) {
		pair<long double, long double> p = make_pair(0, B[i]);
		pair<long double, long double> p2 = make_pair(1, A[i] + B[i]);
		swap(p.first, p.second);
		swap(p2.first, p2.second);
		p.first *= -1.0;
		p2.first *= -1.0;
		A[i] = (p2.second - p.second) / (p2.first - p.first);
		B[i] = p.second - A[i] * p.first;
	}
	double Y = solve();
	printf("%.16f %.16f\n", X, Y);
	return 0;
}

Measured memory_bytes: 8304
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn square_sum(sy: usize, sx: usize, k: usize, c: usize, sums: &Vec<Vec<Vec<usize>>>) -> usize {
    sums[c][sy + k][sx + k] +
    sums[c][sy][sx] -
    sums[c][sy][sx + k] -
    sums[c][sy + k][sx]
}

fn main() {
    let n: usize = read();
    let k: usize = read();
    let mut ps = vec![(0, 0, 0); n];
    for i in 0..n {
        let x: usize = read();
        let y: usize = read();
        let c: String = read();
        let x = x % (2 * k);
        let y = y % (2 * k);
        ps[i] = (x, y, if c == 'W'.to_string() { 0 } else { 1 });
    }
    let mut sums = vec![vec![vec![0 as usize; 3 * k + 1]; 4 * k + 1]; 2];
    for i in 0..n {
        let x = ps[i].0;
        let y = ps[i].1;
        let c = ps[i].2;
        for dy in [0, 2 * k].iter() {
            for dx in [0, 2 * k].iter() {
                let nx = x + dx;
                let ny = y + dy;
                if ny >= 4 * k || nx >= 3 * k { continue; }
                sums[c][ny + 1][nx + 1] += 1;
            }
        }
    }
    for c in 0..2 {
        for y in 0..4 * k {
            for x in 0..3 * k {
                sums[c][y + 1][x + 1] += sums[c][y + 1][x] + sums[c][y][x + 1] - sums[c][y][x];
            }
        }
    }
    let mut ans = 0;
    for offset_y in 0..2*k+1 {
        for offset_x in 0..k+1 {
            let mut sum = 0;
            sum += square_sum(offset_y, offset_x, k, 0, &sums);
            sum += square_sum(k + offset_y, offset_x, k, 1, &sums);
            sum += square_sum(offset_y, k + offset_x, k, 1, &sums);
            sum += square_sum(k + offset_y, k + offset_x, k, 0, &sums);
            ans = std::cmp::max(ans, sum);
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 237820
/***
coded by adarsh
***/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef vector<ll> vec; 
typedef vector<vector<ll>> vec2;
typedef pair<ll,ll> pair1;
typedef pair<string,ll> pair2;
typedef pair<ll,string> pair3;
typedef pair<string,string> pair4;
#define fl(i,a,b) for(i=a;i<b;i++)
#define rfl(i,a,b) for(i=b-1;i>=a;i--)
#define f first
#define s second

int main() 
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n,i;cin>>n;
    string a;cin>>a;
    ll sum=0,c=0;
    for(i=0;i<n;i++)
    {
        if(a[i]=='A') c=1;
        else if(c==1)
        {
            if(a[i]=='B') c=2;
            else c=0;
        }
        else if(c==2)
        {
            if(a[i]=='C')
            {
                c=0;sum++;
            }
            else c=0;
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3536
N = int(input())
judge = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for i in range(N):
  judge[input()] += 1
print('AC x ' + str(judge['AC']))
print('WA x ' + str(judge['WA']))
print('TLE x ' + str(judge['TLE']))
print('RE x ' + str(judge['RE']))

Measured memory_bytes: 9200
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

long long a[100005];

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(c<b)
    {
         int n,m;
        a<c ? n=c:n=a;
        b>d ? m=d:m=b;
        if(m-n>0)
            cout<<m-n;
        else
            cout<<"0";
    }
    else
        cout<<"0";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){


  char s[100];
  int i,j;
  int gusu=1,kisu=1;
  int len;

  scanf("%s",s);
  len=strlen(s);

  //ゼロから始まるのでゼロが基数、1が偶数。
  for(i=0;i<len;i=i+2){
    if(!(s[i]=='R'||s[i]=='U'||s[i]=='D')){
      kisu=-1;
    }
  }
  for(i=1;i<len;i=i+2){
    if(!(s[i]=='L'||s[i]=='U'||s[i]=='D')){
      gusu=-1;
    }
  }

  if(gusu==1&&kisu==1)
  printf("Yes");
  else
  printf("No");



return 0;

}


Measured memory_bytes: 128
import itertools
import math

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

tlist = [A, B, C, D, E]
l = itertools.permutations(tlist, 5)

t = []
count = 0

for i in l:
  count = 0
  for j in range(5):
    if j != 4 :
      count += int(math.ceil(i[j] / 10) * 10)
    else:
      count += i[j]
  t.append(count)
  
print(min(t))

Measured memory_bytes: 3064
s = input()[::-1]
l = ['dream'[::-1],'dreamer'[::-1],'erase'[::-1],'eraser'[::-1]]
k = 0
while k<len(s):
    flag = 1
    for w in l:
        if s[k:k+len(w)]==w:
            k+=len(w)
            flag = 0
    if flag:
        print('NO')
        exit()
print('YES')

Measured memory_bytes: 3188
l, r = map(int, input().split())
ans = 10 ** 10
for i in range(l, r):
  for j in range(i+1, r+1):
    if (i * j) % 2019 == 0:
      print(0)
      exit()
    ans = min(ans, (i*j) % 2019)
print(ans)

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

int main() {
  int a, b;
  
  std::cin >> a >> b;
  
  int ave;
  
  if((a+b)%2 == 0) {
    ave = (a+b)/2;
    std::cout << ave;
  }else{
    ave = (a+b)/2;
    std::cout << ave+1;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    int A[11];
    int s[11]={0,0,0,0,0,0,0,0,0};
    for(int i=0;i<9;i++)cin>>A[i];
    cin>> N;
    int b[101];
    for(int i=0;i<N;i++)cin>>b[i];
    for(int i=0;i<N;i++){
    for(int j=0;j<9;j++) {if(b[i]==A[j])s[j]=1;}
    }
    if(s[0]==1 && s[1]==1&&s[2]==1){cout<<"Yes"<<endl;}
    else if(s[4]==1 &&s[5]==1&&s[3]==1){cout<<"Yes"<<endl;}
    else if(s[6]==1 &&s[7]==1&&s[8]==1){cout<<"Yes"<<endl;}
    else if(s[0]==1 &&s[3]==1&&s[6]==1){cout<<"Yes"<<endl;}
    else if(s[1]==1 &&s[4]==1&&s[7]==1){cout<<"Yes"<<endl;}
    else if(s[2]==1 &&s[5]==1&&s[8]==1){cout<<"Yes"<<endl;}
    else if(s[0]==1 &&s[4]==1&&s[8]==1){cout<<"Yes"<<endl;}
    else if(s[2]==1 &&s[4]==1&&s[6]==1){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
    return 0;

}

Measured memory_bytes: 256
const input = require("fs").readFileSync("/dev/stdin", "utf8");
const nums = input.split(' ').map(n => parseInt(n));
const K = nums[0];
const X = nums[1];

const ans = [...Array(K * 2 - 1).keys()].map(n => n + X - K + 1).filter(m => -1000000 <= m && m <= 1000000).join(' ')

console.log(ans);


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

using namespace std;

#define PB push_back
#define SZ(a) (int)a.size()
#define MP make_pair

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;

int main() {

	ll A,V,B,W,T;

	scanf("%lld%lld %lld%lld %lld", &A, &V, &B, &W, &T);

	if (abs(A-B) + W*T <= V*T) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}


	return 0;
}


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

int road[1000][2];
int main() {
	int w, h, n;
	cin >>w>>h>> n;

	int way = 0;
	for (int i = 0;i < n;i++) {
		cin >> road[i][0] >> road[i][1];
	}

	for (int i = 0;i < n - 1;i++) {
		int a = road[i + 1][0] - road[i][0];
		int b = road[i + 1][1] - road[i][1];
		if (a >= 0 && b >= 0) {
			way += min(a, b) + abs(a - b);
		}
		else if (a < 0 && b < 0) {
			int c = abs(a);
			int d = abs(b);
			way += min(c, d) + abs(c - d);
		}
		else {
			way += abs(a) + abs(b);
		}
	}
	cout << way << endl;
	return 0;
}

Measured memory_bytes: 3136
#include <iostream>
#include <string>
#include <vector>

int main() {
  int A, B, M;
  std::cin >> A >> B >> M;

  std::vector<int> as, bs;

  int tmp, a_min = 1000005, b_min = 1000005;
  for (size_t i = 0; i < A; ++i) {
    std::cin >> tmp;
    as.push_back(tmp);
    if (tmp < a_min) a_min = tmp;
  }

  for (size_t i = 0; i < B; ++i) {
    std::cin >> tmp;
    bs.push_back(tmp);
    if (tmp < b_min) b_min = tmp;
  }

  int ans = a_min + b_min;

  int x, y, c;
  for (size_t i = 0; i < M; ++i) {
    std::cin >> x >> y >> c;
    tmp = as.at(x - 1) + bs.at(y - 1) - c;
    if (tmp < ans) ans = tmp;
  }

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


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ABC100 B
// 2020.05.25

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll D, N; cin >> D >> N;
  ll ans;
  if(N != 100){
    ans =  N*pow(100, D);
  }else{
    ans = 101*pow(100, D);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <stack>
#include <set>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;

void solve() {
	string s; cin >> s;
	reverse(s.begin(), s.end());
	for (int i = 0; i < s.length();) {
		if (s.substr(i, 6) == "resare") {
			i += 6; continue;

		}
		else if (s.substr(i, 5) == "esare") {
			i += 5;
			continue;
		}

		else if (s.substr(i, 5) == "maerd") {
			i += 5;
			continue;
		}
		else if (s.substr(i, 7) == "remaerd") {
			i += 7; continue;

		}


		if (i == s.length()) {cout << "YES"; return ;}
		cout << "NO"; return ;

	}
	cout << "YES"; return ;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t; cin >> t;
	// while (t--)
	solve();

}

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

int main(){
    int n, pf = 0;
    cin >> n;
    int d[n];
    for(int i = 0; i < n; i++) cin >> d[i];
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++) pf += d[i] * d[j];
    }
    cout << pf << endl;
}

Measured memory_bytes: 256
H, W, K = map(int, input().split())
C = [list(input()) for _ in range(H)]
ans = 0
for i in range(2 ** H):
    h = []
    for j in range(H): 
        if ((i >> j) & 1):
            h.append(j)
    for k in range(2 ** W):
        w = []
        for l in range(W):
            if ((k >> l) & 1):
                w.append(l)
        cnt = 0
        for a in range(H):
            for b in range(W):
                if a not in h and b not in w and C[a][b] == "#":
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)


Measured memory_bytes: 68532
fun main(args: Array<String>) {
    val (A1, A2, A3) = listOfInt()
    println(if (A1+A2+A3 >= 22) "bust" else "win")
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }

Measured memory_bytes: 37904
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)a
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    ll d, t, s;
    cin >> d >> t >> s;
    cout << (s * t >= d ? "Yes" : "No");
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 3648
n = int(input())
a = [int(input()) for i in range(n)]
a_ = sorted(a)

if a_[-1] == a_[-2]:
    for i in range(n):
        print(a_[n-1])
    exit()

b = list(set(a))

if len(b) == 1:
    for i in range(n):
        print(b[0])
    exit()

for i in a:
    if i == b[-1]:
        print(b[-2])
    else:
        print(b[-1])

Measured memory_bytes: 19256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x.at(i);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (x.at(i) * 2 < k) ans += x.at(i) * 2;
        else ans += (k - x.at(i)) * 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES // for C++  
#include <cmath> 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>
#include <functional>


using namespace std;

int main() {
    string w;
    map<char, int> map;
    bool flag = true;
    cin >> w;
    for (size_t i = 0; i < w.length(); i++)
    {
        auto itr = map.find(w[i]);
        if (itr != map.end())
        {
            itr->second++;
        }
        else
        {
            map.insert(make_pair(w[i], 1));
        }
    }

    for (auto itr = map.begin(); itr != map.end(); itr++)
    {
        if (itr->second % 2 != 0)
        {
            flag = false;
        }
        
    }
    if (flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}   

Measured memory_bytes: 256
from collections import Counter
n = int(input())
V = list(map(int, input().split()))
_n = n // 2
C0 = Counter()
C1 = Counter()
for i in range(n):
    if i % 2 == 0:
        C0[V[i]] += 1
    else:
        C1[V[i]] += 1
C0 = C0.most_common()
C1 = C1.most_common()
if C0[0][0] == C1[0][0]:
    if len(C0) == 1 and len(C1) == 1:
        print(_n)
    elif C0[0][1] == C1[0][1]:
        if C0[1][1] <= C1[1][1]:
            print(abs(C0[0][1] - _n) + abs(C1[1][1] - _n))
        else:
            print(abs(C0[1][1] - _n) + abs(C1[0][1] - _n))
    else:
        if C0[0][1] < C1[0][1]:
            print(abs(C0[1][1] - _n) + abs(C1[0][1] - _n))
        else:
            print(abs(C0[0][1] - _n) + abs(C1[1][1] - _n))
else:
    print(abs(C0[0][1] - _n) + abs(C1[0][1] - _n))


Measured memory_bytes: 24076
n = int(input())
A = list(map(int, input().split()))

import fractions

def segfunc(x, y):
    return fractions.gcd(x, y)

def init(init_val):
    # set_val
    for i in range(n):
        seg[i+num-1] = init_val[i]
    # built
    for i in range(num-2, -1, -1):
        seg[i] = segfunc(seg[2*i+1], seg[2*i+2])

def update(k, x):
    k += num - 1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[2*k+1], seg[2*k+2])

def query(p, q):
    if q <= p:
        return ide_ele
    p += num - 1
    q += num - 2
    res = ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res, seg[p])
        if q&1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res

# identity element
ide_ele = 0

# num: n以上の最小の2のべき乗
num = 2**(n-1).bit_length()
seg = [ide_ele]*2*num

init(A)

ans = -1
for i in range(n):
    ans =max(ans, fractions.gcd(query(0, i), query(i+1, n)))
print(ans)

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

using namespace std;

#define fastio cin.tie(NULL);cout.tie(NULL);ios_base::sync_with_stdio(0);
#define debug(x) cout << x << endl;
#define endl '\n'
#define MAXN 5005
#define INF 0x3f3f3f3f
#define LOG 20
#define pb push_back

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

int32_t main(){
    fastio
    ll a, b, k;
    cin >> a >> b >> k;

    if(k > a){
        k -= a;
        a = 0;
    } else {
        a -= k;
        k = 0;
    }

    if(k > b){
        b = 0;
    } else {
        b -= k;
        k = 0;
    }

    cout << a << " " << b << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;


const int N=1e5+100;

int vis[200];
int main()
{
    int n,k,x;
    cin>>n>>k;
    for(int i=1;i<=k;i++){
        int d;cin>>d;
        while(d--){
            scanf("%d",&x);
            vis[x]=1;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(!vis[i]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
#include <ctype.h>

int main(void) {
	int A, B;
	char S[128];
	int i;
	if (scanf("%d%d", &A, &B) != 2) return 1;
	if (scanf("%127s", S) != 1) return 1;
	for (i = 0; i < A + B + 1; i++) {
		if (!(i == A ? S[i] == '-' : ('0' <= S[i]  && S[i] <= '9'))) {
			puts("No");
			return 0;
		}
	}
	puts(S[A + B + 1] == '\0' ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 128
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Integer, Integer> h = new HashMap<>();
        for (int i = 1; i <= n; i++) {
            h.put(sc.nextInt(), i);
        }

        List<String> result = new ArrayList<>();
        for (int i = 1; i <= n; i++){
            result.add(Integer.toString(h.get(i)));
        }

        System.out.println(String.join(" ", result));
    }
}


Measured memory_bytes: 66092