akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<algorithm>
 
using namespace std;
char str[10];
pair<int,int> v[110][110];
int g[110][110];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		int c;
		scanf("%d",&c);
		for(int j=0;j<b;j++)v[i][j]=make_pair(0,100);
		for(int j=0;j<c;j++){
			int d,e;
			scanf("%d%s%d",&d,str,&e);
			d--;
			if(str[0]=='>'){
				v[i][d].first=max(v[i][d].first,e);
			}else v[i][d].second=min(v[i][d].second,e);
		}
	}
	bool ok=true;
	for(int i=0;i<a;i++)
		for(int j=0;j<b;j++)
			if(v[i][j].first>v[i][j].second)ok=false;
	for(int i=0;i<a;i++)
		for(int j=0;j<a;j++){
			for(int k=0;k<b;k++)if(v[i][k].second<v[j][k].first)g[i][j]=1;
		}
	for(int k=0;k<a;k++)
		for(int i=0;i<a;i++)
			for(int j=0;j<a;j++)
				g[i][j]|=(g[i][k]&g[k][j]);
	for(int i=0;i<a;i++)if(g[i][i])ok=false;
	for(int i=0;ok&&i<a;i++){
		for(int j=0;ok&&j<a;j++){
			for(int k=0;ok&&k<b;k++){
				for(int l=0;ok&&l<b;l++){
					if(v[i][k].second<v[j][k].first&&v[j][l].second<v[i][l].first)ok=false;
					if(v[j][k].second<v[i][k].first&&v[i][l].second<v[j][l].first)ok=false;
				}
			}
		}
	}
	if(ok)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 1140
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pair;
ll inf = 1e10;
int MAX_V;

ll V, E;
vector<Pair> G[100010];
ll d[100010];

void dijkstra(ll s) {
    priority_queue<Pair, vector<Pair>, greater<Pair>> que;
    fill(d, d + V, inf);
    d[s] = 0;
    que.push(Pair(0, s));
    
    while (!que.empty()) {
        Pair p = que.top();
        que.pop();
        
        ll v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++) {
            Pair e = G[v][i];
            if (d[e.first] > d[v] + e.second) {
                d[e.first] = d[v] + e.second;
                que.push(Pair(d[e.first], e.first));
            }
        }
    }
}

int main() {
    cin >> V;
    for (int i = 0; i < V; i++) {
        int a, et;
        cin >> a >> et;
        for (int j = 0; j < et; j++) {
            int b;
            ll r;
            cin >> b >> r;
            G[a].emplace_back(b, r);
            //G[b].emplace_back(a, r);
        }
    }

    dijkstra(0);
    for (int i = 0; i < V; i++) {
        cout << i << " " << d[i] << endl;
    }

}


Measured memory_bytes: 5568
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

a, b, c = map(int, input().split())

ans = 0
if (a != b and a != c and b != c):
    ans = 3
elif (a == b and a == c and b == c):
    ans = 1
else:
    ans = 2
print(ans)



Measured memory_bytes: 9040
V = {}
N = int(input())

MaxVote = 0
while N > 0:
    N -= 1
    ### 
    st = str(input())
    V[st] = V.get(st, 0)
    V[st] += 1
    MaxVote = max(MaxVote, V[st])

ans = []
for key, value in V.items():
    if value == MaxVote:
        ans.append(key)
ans.sort()
print(*ans, sep = '\n')


Measured memory_bytes: 33944
K, N = map(int, input().split())
A = list(map(int, input().split()))

dist = [A[i+1] - A[i] for i in range(N-1)]
dist.append(K - (A[N-1] - A[0]))

if A[N-1] - A[0] <= K / 2:
    res = A[N-1] - A[0]
else:
    res = K - max(dist)

print(res)


Measured memory_bytes: 26444
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    val a = sc.nextInt()
    val b = sc.nextInt()

    for(i in 0..2000) {
        val aa = (i * 0.08)
        val bb = (i * 0.1)

        if(aa.toInt().equals(a) && bb.toInt().equals(b)){
            println(i)
            return
        }

    }

    println(-1)

}


Measured memory_bytes: 31400
def solution(a, b):
    if (a & 1) == 1 and (b & 1) == 1:
        return True
    else:
        return False

def main():
    a, b = [int(i) for i in raw_input().strip().split()]
    if solution(a, b):
        print 'Yes'
    else:
        print 'No'

if __name__ == '__main__':
    main()


Measured memory_bytes: 2568
#  frog

N=int(input())
h=list(map(int,input().split()))

INF=2**50
dp=[INF]*(N+1)
dp[0]=0
dp[1]=0

for i in range(1,N):
    if i < 2:
        dp[i+1]=min(dp[i+1], dp[i]+abs(h[i]-h[i-1]))
    else:
        dp[i+1]=min(dp[i+1], dp[i]+abs(h[i]-h[i-1]), dp[i-1]+abs(h[i-2]-h[i]))
    

print(dp[N])


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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#ifdef LOCAL
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl
#else
#define dmp(x) void(0)
#endif

template <class t, class u>
void chmax(t &a, u b)
{
  if (a < b)
    a = b;
}
template <class t, class u>
void chmin(t &a, u b)
{
  if (b < a)
    a = b;
}
const int mod = 1000000007;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vc<vc<t>>;

using vi = vc<int>;
int gcd(int a, int b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int lcm(int a, int b)
{
  return (a * b) / gcd(a, b);
}
int fact(int n)
{
  if (n == 0)
    return 1;
  return n * fact(n - 1);
}

int main()
{
  int a,b,c,d;
  cin >> a>>b>>c>>d;
  if(a*b>c*d){
  cout<<a*b<<endl;
  }else{
  cout<<c*d<<endl;
  }
  
}

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

int main(){
    int n;

    cin >> n ;

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

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
 ll r;
  cin >> r;
  cout << r*r << endl;
}

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


Measured memory_bytes: 3628
def bin_search(lis, target, low, high):
    while high-low!=1:
        mid = (low+high) // 2
        #print(low, mid, high)
        if lis[mid] == target:
            return mid, 1
        elif lis[mid] > target:
            high = mid
        else:
            low = mid
    if lis[low] == target:
        return low, 1
    elif lis[high] < target:
        return high, 0
    else:
        return low, 0
    
    
n, m = map(int, input().split())
a = [int(i) for i in input().split(" ")]
bc = [[int(i) for i in input().split(" ")] for i in range(m)]
bc = sorted(bc, key=lambda x: x[1])
bc.reverse()
a = sorted(a)
ind = 0
ans = 0
flag = 0
for i in bc:
    if ind >= n:
        break
    if a[min(ind+i[0], n-1)] <= i[1]:
        ans += min(i[0], n-ind)*i[1]
        ind += i[0]
    elif a[ind] >= i[1]:
        ans += sum(a[ind:])
        flag = 1
        break
    else:
        tm = bin_search(a[ind:min(ind+i[0], n-1)], i[1], 0, min(i[0], n-ind))
        ans += i[1]*(tm[0]+1)
        ind += tm[0]+1
        ans += sum(a[ind:])
        flag = 1
        break
if flag == 0:
    ans += sum(a[ind:])
print(ans)

Measured memory_bytes: 83540
#include<bits/stdc++.h>
using namespace std;
bool e[1000005];
int a,b,c,d;
vector<int>s;
main(){
  for(int i=2;i<1000005;i++)
    if(!e[i])for(int j=i+i;j<1000005;j+=i)e[j]=1;
  for(int i=2;i<1000005;i++)
    if(!e[i])s.push_back(i);
  while(cin>>a>>b,a||b){
    c=d=0;
    for(int i=0;i<s.size()&&s[i]<=a;i++){
      int f1=0;
      while(a%s[i]==0)a/=s[i],f1++;
      if(f1)c-=s[i];
      if(a==1){
        c+=s[i]*2;
        break;
      }
    }
    for(int i=0;i<s.size()&&s[i]<=b;i++){
      int f1=0;
      while(b%s[i]==0)b/=s[i],f1++;
      if(f1)d-=s[i];
      if(b==1){
        d+=s[i]*2;
        break;
      }
    }
    if(c>d)cout<<"a"<<endl;
    else cout<<"b"<<endl;
  }
}

Measured memory_bytes: 4144
#include <cstdio>
#include <iostream>
#include <stack>
using namespace std;

typedef struct{
	int x;
	int y;
}point;

int main(){
	while(1){
		point start, pre[1000], nex[1000];
		int n, p=0, q=0;
		int dx[12]={2,2,2,1,0,-1,-2,-2,-2,-1,0,1};
		int dy[12]={1,0,-1,-2,-2,-2,-1,0,1,2,2,2};
		
		scanf(" %d %d", &start.x, &start.y);
		if(start.x==0 && start.y==0) break;
		scanf(" %d", &n);
		
		pre[p++]=start;
		
		for(int i=0; i<n; ++i){
			point s;
			scanf(" %d %d", &s.x, &s.y);
			
			q=0;
			
			for(int j=0; j<p; ++j){
				point t=pre[j];
				for(int k=0; k<12; ++k){
					int nx=t.x+dx[k], ny=t.y+dy[k];
					if(nx>=0 && nx<10 && ny>=0 && ny<10 && s.x-1<=nx && nx<=s.x+1 && s.y-1<=ny && ny<=s.y+1){
						point tmp;
						tmp.x=nx;
						tmp.y=ny;
						nex[q++]=tmp;	
					} 
				}
			}
			
			
			for(int j=0; j<q; ++j) pre[j]=nex[j];
			p=q;	
				
		}
		
		if(q==0) printf("NA\n");
		else printf("OK\n");
		
	}
}

Measured memory_bytes: 1184
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

bool cmp(pair<long long int, long long int> x, pair<long long int, long long int> y) {
    if(x.second!=y.second) {
        return x.second<y.second;
    } else {
        return x.first>y.first;
    }
}

int main() {
    int N;
    cin >> N;
    vector<pair<long long int, long long int> > vec(N);
    for(int n=0; n<N; n++) {
        cin >> vec[n].first >> vec[n].second;
    }
    
    sort(vec.begin(), vec.end(), cmp);
    long long int cur=0;
    bool flag = true;
    for(int n=0; n<N; n++) {
        cur += vec[n].first;
        if(cur>vec[n].second) {
            flag = false;
        }
    }
    if(flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
    
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <math.h>

int main(void){
  long long a,b,c,d;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

  long long ac = a*c;
  long long ad = a*d;
  long long bc = b*c;
  long long bd = b*d;

  long long max = ac;
  if(max < ad) max = ad;
  if(max < bc) max = bc;
  if(max < bd) max = bd;

  printf("%lld\n", max);

  return 0;
}

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

int log5(ll x) {
    int res = 0;
    while (x >= 5) x /= 5, res++;
    return res;
}
ll mpow(ll x, ll n) {
    ll res = 1;
    while (n != 0) {
        if (n & 1) res = res * x;
        x = x * x;
        n = n >> 1;
    }
    return res;
}

int main() {
    ll n, ans = 0;
    cin >> n;
    ll k = log5(n);
    if (n % 2 == 0) {
        for (ll i = k; i >= 1; i--) {
            ll x = mpow(5, i);
            ll c = n / x, d = c / 10;
            c /= 2;
            c -= d;
            ans += c * i;
        }
        cout << ans << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
H, W, D = map(int, input().split())
Aij = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
LRi = [list(map(int, input().split())) for _ in range(Q)]

# 各数字の位置を覚える
pos = [0] * (H * W + 1)
for i in range(H):
    for j in range(W):
        pos[Aij[i][j]] = [i, j]

# 移動累積和を取る
mp_sum = [0] * (H * W + 1)
for i in range(D + 1, H * W + 1):
    s = pos[i - D]
    e = pos[i]
    mp_sum[i] = mp_sum[i - D] + abs(e[0] - s[0]) + abs(e[1] - s[1])


for lr in LRi:
    mp = mp_sum[lr[1]] - mp_sum[lr[0]]
    print(mp)

Measured memory_bytes: 42308
#include <stdio.h>
#include <string.h>
int main()
{
    char a[50];
    int n,court=0;
    scanf("%d",&n);
    getchar();
    gets(a);
    for(int i=0;i<50;i++)
    {
        if(a[i]=='A')
            if(a[i+1]=='B')
            if(a[i+2]=='C')
            court++;
    }
    printf("%d\n",court);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N; cin >> N;
    int M; cin >> M;
    vector<vector<bool>> E(N,vector<bool>(N));
    for (int i=0;i<M;i++){
        int a,b; cin >> a >> b;
        --a; --b;
        E[a][b] = true;
        E[b][a] = true;
    }
    vector<int> order(N);
    for (int i=0;i<N;i++) order[i] = i;
    int res = 0;
    do {
        if (order[0]!=0) continue;
        bool can = true;
        for (int i=0;i<N-1;i++){
            if (!(E[order[i]][order[i+1]])) can = false;
        }
        if (can) res++;
    }while(next_permutation(order.begin(),order.end()));
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextLong()
    val b = sc.nextLong()
    val c = sc.nextLong()
    val k = sc.nextLong()
    println(problem167b(a, b, c, k))
}

fun problem167b(a: Long, b: Long, c: Long, k: Long): Long {
    var k1 = k - a
    if (k1 <= 0L) return Math.min(k, a)
    k1 -= b
    if (k1 <= 0L) return Math.min(k, a)
    return a - k1
}

Measured memory_bytes: 36416
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n, a, ans = 0;
  map<int, int> m;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &a);
    if(m.find(a) == m.end()) m[a] = 1;
    else m[a]++;
  }
  map<int, int>::iterator it;
  for(it = m.begin(); it != m.end(); it++){
    pair<int, int> p = *it;
    ans += (p.first > p.second ? p.second : p.second - p.first);
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 4736
//#include<cstdio>
//#include<cassert>
//#include<iostream>
//#include<cstring>
//#include<algorithm>
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((int)1e6 + 5)
#define MAXL ((ll)1e18 + 5)
#define MAX_X ((ll)1e5 + 2)
#define pi (2.0*acos(0))
#define M ((int)1e6 + 7)
#define MOD ((int)1e9 + 7)
#define NN ((int)62500 + 7)
#define N ((int)250 + 5)
#define eps (0)
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL)
#define logn 29
#define endl "\n"
#define mp make_pair
#define BUCK 105
#define LEF (idx<<1)
#define RIG ((idx<<1)|1)
//#define int ll


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;

/*fast io
ios_base::sync_with_stdio(false);
cin.tie(NULL);
*/




typedef tree < int,  null_type,  less < int >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;
//typedef tree < pair < int, int >,  null_type,  less < pair < int, int > >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;
/// o_set s;
/// s.order_of_key(k) : Number of items strictly smaller than k .
/// *(s.find_by_order(k)) : K-th element in a set (counting from zero).



int main()
{
    fastio;
    int a ,b , c, k;
    cin>>a>>b>>c>>k;
    while(b<=a && k>0){
        b += b;
        k--;
    }
    while(c<=b && k>0){
        c += c;
        k--;
    }
    if(c>b && b>a) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll        = long long;
using ld        = long double;
using vl        = vector<ll>;
using vd        = vector<ld>;
using vs        = vector<string>;
using vb        = vector<bool>;
using vvl       = vector<vector<ll>>;
using vvd       = vector<vector<ld>>;
using vvs       = vector<vector<string>>;
using vvb       = vector<vector<bool>>;
using pll       = pair<ll, ll>;
constexpr ll mod= 1e9 + 7;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for(ll(i)= 0; (i) < (n); (i)++)
#define REPS(i, n) for(ll(i)= 1; (i) <= (n); (i)++)
#define RREP(i, n) for(ll(i)= (n - 1); (i) >= 0; (i)--)
#define RREPS(i, n) for(ll(i)= (n); (i) > 0; (i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define YES(n) ((n) ? "YES" : "NO")
#define Yes(n) ((n) ? "Yes" : "No")
#define yes(n) ((n) ? "yes" : "no")

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

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    ll N;
    cin >> N;
    ll ans = 0;
    REPS(i,N){
        for(int l = i;l*i <= N;l++){
            if(l == i){
                if(l*i <= N-1)ans++;
            }else{
                if(l*i <= N-1)ans+=2;
            }
        }
    }
    cout << ans << "\n";
}

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

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

    vector <int> a(n);
    vector <long long> buka(n);
    for(int i = 1; i < n; i++) {
        cin >> a[i];
        buka[a[i] -1] += 1;
    }

    for(int i = 0; i < n; i++) {
        cout << buka[i] << endl;
    }

    return 0;
}

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

int main() {
	int n; cin >> n;
	vector<int>a(n), b(n);
	vector<int>c(55);
	for (auto&& x : a)cin >> x;
	for (auto&& x : b)cin >> x;
	for (int i = 0; i < n - 1; i++) {
		int tmp; cin >> tmp;
		c[i] = tmp;
	}

	int ans = 0, preMeal = 54;
	for (int i = 0; i < n; i++) {
		int tmp = a[i];
		ans += b[a[i]-1];
		if (preMeal+1 ==a[i])ans += c[preMeal-1];
		preMeal = a[i];
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
    char table[100][100];
    int a,b,h,w;
    cin>>a>>b;
    if(a==1&&b==1) h=1;
    else {
        h=max((int)ceil((double)a/24.0)*2,(int)ceil((double)b/24.0)*2);
        a--;b--;
    }
    w=100;
    for(int i=0;i<h;i++){
        if(i%2==0) {
            for(int j=0;j<50;j++) table[i][j]='.';
            for(int j=50;j<100;j++) table[i][j]='#';
        } else {
            for(int j=0;j<50;j++) {
                if(j%2==1&&b>0&&j<=47) {
                    table[i][j]='#';
                    b--;
                } else {
                    table[i][j]='.';
                }
            }
            for(int j=50;j<100;j++) {
                if(j%2==1&&a>0&&j<=97) {
                    table[i][j]='.';
                    a--;
                } else {
                    table[i][j]='#';
                }
            }
        }
    }
    cout << h << " " << w << endl;
    for(int i=0;i<h;i++) {
        for(int j=0;j<w;j++) {
            printf("%c", table[i][j]);
            if(j==w-1)cout<<endl;
        }
    }
    return 0;
}

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

#define int long long

signed main(){
    int n;
    cin>>n;
    double sum = 0.0;
    double tmp;
    for(int i=0; i<n; i++){
        cin>>tmp;
        sum += 1/tmp;
    }
    double res = 1/sum;
    printf("%0.10f\n", res);
    return 0;
}

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

int aa[11];
int n, m, q;
int a[50], b[50], c[50];
unsigned long d[50];
unsigned long ans = 0;

void solve(int ii, int nowa) {
	int i, nowaa;
	aa[ii] = nowa;
	if (ii == n) {
		unsigned long tmp = 0;
		for (i = 0; i < q; i++) {
			if (aa[b[i]] - aa[a[i]] == c[i]) {
				tmp += d[i];
			}
		}
		if (tmp > ans) {
			ans = tmp;
		}
		return;
	}
	for (nowaa=nowa; nowaa <= m; nowaa++) {
		solve(ii + 1, nowaa);
	}
	return;
}
int main()
{
	int i;
	cin >> n >> m >> q;
	for (i = 0; i < 10; i++) {
		aa[i] = 1;
	}
	for (i = 0; i < q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	for (i = 1; i <= m; i++) {
		solve(0, i);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
from itertools import accumulate
n,k = map(int,input().split())
A = list(map(int,input().split()))
for _ in range(min(k,50)):
    c = [0]*n
    for i,j in enumerate(A):
        l = max(0,i-j)
        r = min(n-1,i+j)
        c[l] += 1
        if r+1 < n:
            c[r+1] -= 1
    A = list(accumulate(c))
print(" ".join(map(str,A)))

Measured memory_bytes: 181352
while True:
    m,f,r = map(int,input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m+f >= 65:
        print("B")
    elif m+f >= 50:
        print("C")
    elif m+f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    elif m+f < 30:
        print("F")


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vii=vector<vi>;
const int MAX = 510000;
const int MOD = 1000000007;
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  double a,b,h,m;
  cin>>a>>b>>h>>m;
  //cout<<sqrt(a*a+b*b-2*a*b*cos(((60*h-11*m)/720)*2*3.14159265358979323846));
  cout << std::fixed << std::setprecision(15) << sqrt(a*a+b*b-2*a*b*cos(((60*h-11*m)/720)*2*3.14159265358979323846)) << endl;
}

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

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int buf;
    cin >> buf;
    v.push_back(buf);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  int len;
  for (int i = 0; i < k; i++) {
    len += v[i];
  }
  cout << len << endl;
  return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void calc(int k, string s) {
    bool[string] d;

    for (int i = 1; i <= 5; i++) {
        for (int j = 0; j < s.length; j++) {
            if (j + i > s.length) break;

            string t = s[j..j+i];
            d[t] = true;
        }
    }

    auto ss = d.keys;
    ss.sort();
    writeln(ss.take(k)[$-1]);
}

void main() {
    string s = readln.chomp;
    int k = readint;

    calc(k, s);
}

Measured memory_bytes: 3452
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
from functools import reduce
import sys
import math
import bisect
import random
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return list(map(float, sys.stdin.readline().split()))
def LS():return sys.stdin.readline().split()
def SR(n): return [list(sys.stdin.readline())[:-1] for i in range(n)]
def IR(n): return [int(sys.stdin.readline()) for i in range(n)]
def LIR(n): return [list(map(int, sys.stdin.readline().split())) for i in range(n)]
def LSR(n): return [list(map(list, sys.stdin.readline().split())) for i in range(n)]
_gcd = lambda x, y: _gcd(y, x%y) if (x%y) else y
_lcm = lambda x, y: x*y // _gcd(x, y)
def gcd(*numbers):
    return reduce(_gcd, numbers)
def lcm(*numbers):
    return reduce(_lcm, numbers)
sys.setrecursionlimit(1000000)
INF = float('inf')
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]


N, K = LI()
ab = LIR(N-1)

#ある頂点からある頂点への隣接リスト
utov = [[] for i in range(N+1)]

for a, b in ab:
    utov[a].append(b)
    utov[b].append(a)

#キュー作る
q = deque()
#ある頂点の塗り方を書き込む配列
bfs = [-1]*(N+1)

#１を木の根と考える
#根の部分は好きに塗れるからK通りの塗り方がある
bfs[1] = K

#根の子たちは、根と違う色かつ他のことも違う色に塗らなくてはいけない
#ある頂点を塗るたびにchildを+1して表現
child = 0
for v in utov[1]:
    if (bfs[v] == -1):
        child += 1
        bfs[v] = K - child
        q.append(v)
        #塗ったところをキューに突っ込む

#キューを回す
while q:
    u = q.popleft()
    #根の子の子からは、その頂点の親(根の子)とさらにその親(根)が塗ってある状態なので、
    #頂点を塗れるとしたらK-2通りがデフォ
    child = 1
    for v in utov[u]:
        if (bfs[v] == -1):
            child += 1
            #ある頂点の最初の子はK-2通り
            #ある頂点の二つ目の子はK-3通り...って感じ
            bfs[v] = K - child
            q.append(v)

#答え格納用の変数
ans = 1

#木の全頂点を見ながら、何通りに塗れるかを掛け合わせていく
#modもとる
for pattern in bfs[1:]:
    ans = ans*pattern % mod

print(ans%mod) #コーナーケース対策にmodとっておく

Measured memory_bytes: 41104
import java.util.*;
 
public class Main {
    public static void main(String args[]) {
       //値の取得
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
       int[] P = new int[N];
       for (int i = 0; i < N; ++i) {
            P[i] = sc.nextInt();
       }
       
       int count = 0; 
       int Pj = P[0]; 
       
       for(int i = 0; i < N; ++i) {
             if(P[i] <= Pj) {
               ++count;
               Pj = P[i]; 
           }
       }
       System.out.println(count);
    }
}

Measured memory_bytes: 60348
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

bool comp(const pii &a, const pii &b){
  return b.first*a.second > a.first*b.second;
}

int main(){
  int n,w;
  cin >> n >> w;
  double res = 0;

  vector<pii> item;
  for(int i=0;i<n;i++){
    int a,b;
    cin >> a >> b;
    if(a<=0 && b>=0)w+=-a, res+=b;
    else if(a<0 && b<0){
      w+=-a, res+=b;
      item.push_back(pii(-a,-b));
    }else if(a>0 && b>0){
      item.push_back(pii(a,b));
    }      
  }
  
  sort(item.begin(),item.end(),comp);

  for(pii p : item){
    if(w>p.first){
      w -= p.first; res += p.second;
    }else{
      res += (double)w/p.first * p.second;
      break;
    }
  }
  cout << fixed << setprecision(9) << res << endl;
}

Measured memory_bytes: 1368
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int g = sc.nextInt();
        List<Integer> p = new ArrayList<>();
        List<Integer> c = new ArrayList<>();
        for (int i = 0; i < d; i++) {
            p.add(sc.nextInt());
            c.add(sc.nextInt());
        }

        int minProgram = Integer.MAX_VALUE;
        for (int i = 0; i < (1 << d); i++) {
            int score = 0;
            int program = 0;
            // 完全に解く問題と全く解かない問題を決定
            for (int j = 0; j <= d; j++) {
                if (((i >> j) & 1) == 1) {
                    score += 100 * (j + 1) * p.get(j) + c.get(j);
                    program += p.get(j);
                }
            }
            // スコアがGより小さい場合、中途半端に解く問題が必要になる
            // もっとも高い配点の問題から加点する
            if (score < g) {
                for (int j = d - 1; j >= 0; j--) {
                    if (((i >> j) & 1) == 0) {
                        for (int k = 0; k < p.get(j) - 1; k++) {
                            score += 100 * (j + 1);
                            program++;
                            if (score >= g) {
                                break;
                            }
                        }
                        break;
                    }
                }
            }
            if (score >= g && program < minProgram) {
                minProgram = program;
            }
        }
        System.out.println(minProgram);
    }

}


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

// g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -o 

int main(){
 ll n,m,x;
 cin>>n>>x>>m;
 ll a=x,sum=x,br;
 map<ll,ll>vis;
 map<ll,ll>stime;
 vis[x]=1;
 ll time=1;
 ll f=0;
 stime[1]=x;
 for(int i=1;i<min(n,m);i++){
  a=((a*a)%m);
  sum+=a;
  if(vis[a]>0){
   br=i+1;
//    cout<<a<<" : "<<vis[a]<<"\n";
   f=vis[a];
   break;
  }
  vis[a]=++time;
  stime[vis[a]]=sum;
 }
//  for(auto x:vis)cout<<x.first<<" "<<x.second<<"\n";
//  cout<<"\n";
//  for(auto x:stime)cout<<x.first<<" "<<x.second<<"\n";
//  cout<<"\n";
//  cout<<br<<" "<<f<<" "<<a<<"\n";
 if(f){
  sum+=(((n-br)/(br-f))*(sum-stime[f]));
  n-=br;
  n%=(br-f);
  for(int i=1;i<=n;i++){
   a=((a*a)%m);
   sum+=a;
  }
 }
 cout<<sum<<"\n";
 return 0;
}


Measured memory_bytes: 9676
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int head;
int tail;
typedef struct{
  char name[11];
  int time;
}Q;
void enqueue(Q *a,Q b);
Q dequeue(Q *a);
int main()
{
  int n,m,k=0,i,sum=0;
  head=0;
  scanf("%d %d",&n,&m);
  Q q[200000];
  Q arr[n];
  tail=n-1;
  for(i=0;i<n;i++){
    scanf("%s",q[i].name);
    scanf("%d",&q[i].time);
  }
  i=0;
  while(1){
    if(k==n)break;
    if(m>=q[i].time){
      sum+=q[i].time;
      arr[k]=dequeue(q);
      arr[k].time=sum;
      k++;
    }else{
      sum+=m;
      q[i].time=q[i].time-m;
      enqueue(q,dequeue(q));
    }
    i++;
  }
  for(i=0;i<n;i++){
    printf("%s %d\n",arr[i].name,arr[i].time);
  }
  return 0;
}
void enqueue(Q *a, Q b){
    tail=tail+1;
    a[tail]=b;
}
Q dequeue(Q *a){
  Q x;
  x=a[head];
    head=head+1;
    return x;
}


Measured memory_bytes: 5448
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {

            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();

            int ans = Math.min(d, b) - Math.max(a, c);
            if (ans < 0)
                ans = 0;
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23252
n=int(input())
F=[[] for i in range(10)]
for i in range(n):
    for j,f in enumerate(list(map(int,input().split()))):
        if f:
            F[j].append(i)
P=[list(map(int,input().split())) for i in range(n)]
ans=-float("inf")
for i in range(1,1024):
    l=[0]*n
    for j in range(10):
        if i>>j&1:
            for k in F[j]:
                l[k]+=1
    t=0
    for j,k in enumerate(l):
        t+=P[j][k]
    ans=max(ans,t)
print(ans)

Measured memory_bytes: 3188
from math import ceil
n, a, b = map(int, input().split())
h = [int(input()) for i in range(n)]

def enough(t):
    count = 0
    for hp in h:
        count += ceil(max(0, hp - b*t) / (a-b))
    if(count <= t):
        return True
    else:
        return False


high = ceil(max(h)/b)
low = 0
while(high - low > 0):
    mid = (high + low) // 2
    if(enough(mid)):
        high = mid
    else:
        low = mid + 1
print(low)


Measured memory_bytes: 7088
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,p;
    cin >> a >> p;
    cout << (a*3+p)/2;


    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    //val (n, a, b) = Triple(12, 5, 2)
    //val s = "cabbabaacaba".toCharArray()
    val (n, a, b) = readLine()!!.split(" ").map { it.toInt() }
    val s = readLine()!!.toCharArray()

    val total_ok = a + b
    var current_ok_a = 0
    var current_ok_b = 0

    s.forEachIndexed { i, person ->
        val result = when (person) {
            'a' -> {
                if ((current_ok_a + current_ok_b) < total_ok) {
                    current_ok_a++
                    true
                } else {
                    false
                }
            }
            'b' -> {
                if ((current_ok_a + current_ok_b) < total_ok && current_ok_b < b) {
                    current_ok_b++
                    true
                } else {
                    false
                }
            }
            'c' -> {
                false
            }
            else -> {
                false
            }
        }
        if (result) println("Yes") else println("No")
    }
}


Measured memory_bytes: 52524
#include <bits/stdc++.h>
using namespace std;
char p[4];
int main(){
 	for (int i=1;i<=3;i++){
    	p[i]=getchar();
    }
  	if (p[1]==p[2] && p[2]==p[3])cout << "No";
	else cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <array>
#include <cassert>
#include <queue>
#include <cstring>
#include <vector>
#include <list>
#include <algorithm>

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define eb emplace_back
#define pb push_back
#define mp make_pair

template <typename T>
bool uax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template <typename T>
bool uin(T& a, T b) { if (b < a) { a = b; return true; } return false; }

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vpi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef list<int> li;
typedef vector<li> vli;
typedef vector<vpi> vvpi;
typedef long long i64;

const int inf = 1e9;

void solve_b() {
  int n, m;
  cin >> n >> m;
  vi p(n);
  forn(i, n) { cin >> p[i]; --p[i]; }
  vvi g(n);
  forn(i, m) {
    int v, u; cin >> v >> u;
    --v; --u;
    g[v].pb(u); g[u].pb(v);
  }
  int ans = 0;
  vi used(n, 0);
  queue<int> Q; vi comp;
  forn(i, n) if (!used[i]) {
    Q.push(i); used[i] = 1; comp.pb(i);
    while (!Q.empty()){ 
      int v = Q.front(); Q.pop();
      for(int u: g[v]) if (!used[u]) {
        used[u] = 1; Q.push(u); comp.pb(u);
      }
    }
    sort(all(comp));
    for (int j: comp) ans += binary_search(all(comp), p[j]);
    comp.clear();
  }
  cout << ans << endl;
}

void solve_a() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  vector<string> vs;
  fore(j, 1, k) forn(i, s.length() - j + 1) {
    vs.pb(s.substr(i, j));
  }
  sort(all(vs));
  vs.erase(unique(all(vs)), vs.end());
  cout << vs[k - 1] << endl;
}

int main() {
#ifdef HOME
  freopen("input.txt", "rt", stdin);
#endif
  solve_b();
  return 0;
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class AACOrWA {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n, m;
        in >> n >> m;
        if(n == m) out << "Yes" << endl;
        else out << "No" << endl;
	}
};


int main() {
	AACOrWA solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;

const int maxn=1e4+5;

typedef long long ll;

const ll mod=1e9+7;

int a[maxn];
int b[maxn];
int dp[2*maxn];

int main(){
	int n,k;
	scanf("%d%d",&k,&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",a+i,b+i);
	} 
	
	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=a[i];j<2*maxn;j++){
			dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
		}
	}
	int ans=0x3f3f3f3f;
	for(int i=k;i<2*maxn;i++){
		ans=min(ans,dp[i]);
	}
	printf("%d",ans);
	return 0;
}

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}

int main() {
    int i,n,m,k,sum=0;
    c_p_c();
   string s;
   cin>>s;




   for (int i = 0; i < s.size(); i+=2)
   {
   	/* code */
   	cout<<s[i];
   }
   cout<<endl;
 	return 0;

   }

Measured memory_bytes: 3728
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, A;
    vector<int> colors;
    cin >> N;
    REP(i, N) {
        cin >> A;
        auto lb = lower_bound(ALL(colors), A);
        if (lb == colors.begin()) {
            colors.insert(colors.begin(), A);
        } else {
            lb--;
            *lb = A;
        }
    }
    cout << colors.size() << endl;
    return 0;
}

Measured memory_bytes: 892
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <fstream>
#include <cassert>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	ll n, x, m; cin >> n >> x >> m;
	ll now = x;
	int l, r; l = r = -1;
	map<int, int> mp;
	vector<ll> f(m + 5);
	for (ll i = 1; i <= n; ++i)
	{
		f[i] = now;
		if (mp[now])
		{
			l = mp[now];
			r = i;
			break;
		}
		mp[now] = i;
		now *= now;
		now %= m;
	}
	ll res = 0;
	if (l == -1)
	{
		for (int i = 1; i <= n; ++i)res += f[i];
		cout << res << endl;
		return 0;
	}
	for (int i = 1; i < l; ++i)res += f[i];
	ll sum = 0;
	for (int i = l; i < r; ++i)sum += f[i];
	ll len = r - l;
	res += ((n - (l - 1)) / len * sum);
	rep(i, ((n - (l - 1)) % len))res += f[i + l];
	cout << res << endl;
}

Measured memory_bytes: 6408
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define digit(a) to_string(a).size()
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    vector<ll> vec(5);
    rep(i, 0, 5) cin >> vec[i];
    rep(i, 0, 5) if (vec[i] == 0) cout << i + 1 << endl;
}

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

using namespace std;

int main() {
	int a, b, c;	
	cin >> a >> b >> c;
	if(a == b || b == c || a == c) {
		if(a != b || a != c || b != c)
			puts("Yes");
		else
			puts("No");
	} else {
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
L, R = gets.split.map(&:to_i)
mod = 2019

L_mod = L % mod
R_mod = R % mod

diff = R - L

if diff <= 2019
  if R_mod <= L_mod
    puts 0
  else
    min = 2019
    (L..R).each do |i|
      (L..R).each do |j|
        next if i >= j

        if (i * j) % mod <= min
          min = (i * j) % mod
        end
      end
    end

    puts min
  end
else
  puts 0
end


Measured memory_bytes: 1788
#include<stdio.h>
int main(void)
{   
	//?????°?????£?¨?
    int x;
    
    //??????????????????????????\???????????°?????\??????
    scanf("%d",&x);
    
    //x???3???????¨??????????
    int y =x*x*x;
    
    //?¨?????????????????????????
	printf("%d\n",y);
	
	return 0;
}
	

Measured memory_bytes: 2756