akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fcout cout << fixed << setprecision(18)

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

  double N; cin >> N;
  vector<int> A(N); for (ll i = 0; i < N; i++) cin >> A[i];

  vector<vector<vector<double>>> dp(301, vector<vector<double>>(301, vector<double>(301, 0)));
  for (ll i = 0; i <= N; i++) {
    for (ll j = i; j <= N; j++) {
      for (ll k = j; k <= N; k++) {
        double c3 = i, c2 = j - i, c1 = k - j, c0 = N - k;
        // dp[i][j][k] : 3個以上残ってる寿司がi種類、2個以上がj種類、1個以上がk種類のときの残りの期待値
        if (c0 == N) continue;
        if (i > 0) dp[i][j][k] += c3 * (dp[i-1][j][k] + 1.0);
        if (j > 0) dp[i][j][k] += c2 * (dp[i][j-1][k] + 1.0);
        if (k > 0) dp[i][j][k] += c1 * (dp[i][j][k-1] + 1.0);
        dp[i][j][k] += c0;
        dp[i][j][k] /= (N - c0);
      }
    }
  }
  int s3, s2, s1;
  s3 = s2 = s1 = 0;
  for (ll i = 0; i < N; i++) {
    if (A[i] >= 3) s3++;
    if (A[i] >= 2) s2++;
    if (A[i] >= 1) s1++;
  }
  fcout << dp[s3][s2][s1] << '\n';
  return 0;
}

Measured memory_bytes: 216832
n = int(input())
ab = []
cd = []
for i in range(n):
    ai, bi = map(int, input().split())
    ab.append([ai, bi])
for i in range(n):
    ci, di = map(int, input().split())
    cd.append([ci, di])

ab = sorted(ab, key=lambda x: x[1], reverse=True)
cd = sorted(cd)

count = 0
while True:
    if len(cd) == 0:
        break

    flag = 0
    for i in range(len(ab)):
        if ab[i][0] < cd[0][0] and ab[i][1] < cd[0][1]:
            flag = 1
            break

    if flag:
        ab.pop(i)
        count += 1
    cd.pop(0)

print(count)

Measured memory_bytes: 3188
from collections import*
d=defaultdict(int)
n,k,*t=map(int,open(0).read().split())
for a,b in zip(*[iter(t)]*2):d[a]+=b
d=d.items()
m=sum(y for x,y in d if k|x==k)
*k,=bin(k)[2:]
i=-1
for _ in range(k.count('1')):
  t=k[:]
  i=t.index('1',i+1)
  t[i]='0'
  for j in range(i+1,len(t)):t[j]='1'
  t=int(''.join(t),2)
  m=max(m,sum(y for x,y in d if t|x==t))
print(m)

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

using namespace std;

long long cnt[10][10];

void add(int n) {
  int last = n % 10;
  while (n > 9) n /= 10;
  int first = n;
  ++cnt[first][last];
  return;
}

int main() {
  int n;
  cin >> n;
  for (int num = 1; num <= n; ++num) {
  	add(num);
  }
  long long ans = 0;
  for (int i = 1; i <= 9; ++i)
    for (int j = 1; j <= 9; ++j)
      ans += cnt[i][j] * cnt[j][i];
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define EPS 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

/**
 * Usage:
 * 
 * chmin(old, new);
 * chmax(old, new);
 * 
 */ 
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}




ll x, y;

int main () {
  cin >> x >> y;

  ll ans = 0;

  if (x != y) {
    if (x < y) {
      if (x >= 0 || y <= 0) {
        ans = abs(abs(y)-abs(x));
      } else {
        ans = abs(abs(y)-abs(x)) + 1;
      }
    } else {
      if (y > 0 || x < 0) {
        ans = abs(abs(y)-abs(x)) + 2;
      } else {
        ans = abs(abs(y)-abs(x)) + 1;
      }
    }
  }

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

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_H = 50;
const int MAX_W = 50;

const int dxs[] = {1, 0, -1, 0};
const int dys[] = {0, 1, 0, -1};

/* typedef */

typedef pair<int,int> pii;

enum { NA = 0, EW = 1, EB = 2, EWB = 3, W = 7, B = 11};

/* global variables */

int h, w;
int flds[MAX_H][MAX_W];

/* subroutines */

/* main */

int main() {
  for (;;) {
    cin >> w >> h;
    if (w == 0) break;

    for (int y = 0; y < h; y++) {
      string line;
      cin >> line;
      for (int x = 0; x < w; x++) {
	switch (line[x]) {
	case '.': flds[y][x] = NA; break;
	case 'W': flds[y][x] = W; break;
	case 'B': flds[y][x] = B; break;
	}
      }
    }

    for (int y0 = 0; y0 < h; y0++)
      for (int x0 = 0; x0 < w; x0++) {
	int fld = flds[y0][x0];
	if (fld == W || fld == B) {
	  int cl = (fld == W) ? EW : EB;

	  queue<pii> q;
	  q.push(pii(x0, y0));

	  while (! q.empty()) {
	    pii u = q.front();
	    q.pop();

	    int ux = u.first;
	    int uy = u.second;

	    for (int di = 0; di < 4; di++) {
	      int vx = ux + dxs[di];
	      int vy = uy + dys[di];

	      if (vx >= 0 && vx < w && vy >= 0 && vy < h &&
		  ! (flds[vy][vx] & cl)) {
		flds[vy][vx] |= cl;
		q.push(pii(vx, vy));
	      }
	    }
	  }
	}
      }

    int nb = 0, nw = 0;

    for (int y = 0; y < h; y++)
      for (int x = 0; x < w; x++) {
	if (flds[y][x] == EB) nb++;
	if (flds[y][x] == EW) nw++;
      }

    printf("%d %d\n", nb, nw);
  }

  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int64_t N, x;
    cin >> N >> x;
    vector<int64_t> a(N);
    int64_t ans = 0;
    for(int i = 0; i < N; i++) cin >> a[i];
    for(int i = 1; i < N; i++) {
        if (a[i] + a[i - 1] > x) {
            ans += a[i] + a[i - 1] - x;
            if(a[i - 1] > x) {
                a[i] = 0;
                a[i - 1] = x;
            } else {
                a[i] = x - a[i - 1];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int f( char x ){
	switch (x){
		case '0' : return 0 ;
		case '1' : return 1 ;
		case '2' : return 2 ;
		case '3' : return 3 ;
		case '4' : return 4 ;
		case '5' : return 5 ;
		case '6' : return 6 ;
		case '7' : return 7 ;
		case '8' : return 8 ;
		case '9' : return 9 ;
	}
}

int main(){
	
	int n ;
	for( cin >> n ; n-- ; ){
		string a,b ;
		cin >> a >> b ;
		if( a.size() > b.size() ) swap(a,b) ;
		reverse( a.begin() , a.end() ) ;
		reverse( b.begin() , b.end() ) ;
		while( a.size() < b.size() ) a+='0' ;
		
		vector<int> c ;
		c.push_back(0) ;
		for( int i=0 ; i<a.size() ; i++ ){
			c[i] += f(a[i]) + f(b[i]) ;
			c.push_back( c[i]/10 ) ;
			c[i] %= 10 ;
		}
		if( c[c.size()-1] == 0 ) c.pop_back() ;
		reverse( c.begin() , c.end() ) ;
		
		if( c.size() > 80 ) cout << "overflow" << endl ;
		else {
			for( int i=0 ; i<c.size() ; i++ ) cout << c[i] ;
			cout << endl ;
		}
	}
	
return 0 ;
}

Measured memory_bytes: 1240
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
	int A,B,T;
	cin>>A>>B>>T;
	cout<<(T/A)*B<<endl;
}

Measured memory_bytes: 256
long long a[39][2];i,n,k;main(t){for(;~scanf("%d",&k);++n-2?t=!t:++*a[k+9])for(i=8;n>1&++i<30;)a[i][!t]=a[i-k][t]+a[i+k][t];n=!printf("%lld\n",a[k+9][!t]);}

Measured memory_bytes: 0
def main():
    K = int(input())
    A = list(map(int, input().split()))
    mn = 2
    mx = 2
    for a in reversed(A):
        if mx < a:
            print(-1)
            return
        mn = -(-mn//a) * a
        mx = mx // a * a + (a-1)
        if mx < mn:
            print(-1)
            return
    print(mn, mx)


if __name__ == "__main__":
    main()


Measured memory_bytes: 63856
#include<iostream>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
int main()
{
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	ll n, a, b;
	cin >> n >> a >> b;
	ll ans, rem;
	ans = n/(a+b) * a;
	rem = n%(a+b);
	ans += min(rem, a);
	cout << ans << "\n";
	return 0;
}


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

using namespace std;
typedef long long ll;

const int mxN = 1010;
int N;

struct block
{
	int solid, weight, val;
};

block a[mxN];
ll dp[mxN][20005];

bool fun(const block& b1, const block& b2)
{
	return (b1.weight + b1.solid < b2.weight + b2.solid);
}

ll rec(int idx, int wt)
{
	if (idx == N)
	{
		return 0;
	}
	if (dp[idx][wt] != -1)
	{
		return dp[idx][wt];
	}
	dp[idx][wt] = rec(idx + 1, wt);
	if (a[idx].solid >= wt)
	{
		dp[idx][wt] = max(dp[idx][wt], a[idx].val + rec(idx + 1, wt + a[idx].weight));
	}
	return dp[idx][wt];
}

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

	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> a[i].weight >> a[i].solid >> a[i].val;
	}
	sort(a, a + N, fun);
	memset(dp, -1, sizeof(dp));
	ll answer = rec(0, 0);
	cout << answer;

	return 0;
}


Measured memory_bytes: 161488
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}
  
int main()
{
  string s; int i,n;

  cin >> n >> s;

  if(n % 2 == 1){cout << "No" << endl; return 0;}

  rep(i,n/2){
      if(s[i] != s[i + n/2]){cout << "No" << endl; return 0;}
  }
  cout << "Yes" << endl;
  return 0;
}


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

constexpr int mod = 1000000007;
std::vector<int> cal_primes(int upper) {
	++upper;
	std::vector<bool> suspect(upper, true);
	std::vector<int> prime;
	for (auto i = 2; i < upper; ++i) {
		if (suspect[i]) {
			prime.push_back(i);
			for (auto j = i * 2; j < upper; j += i) {
				suspect[j] = false;
			}
		}
	}
	return prime;
}
int cal_sum_of_primefactor(int n, const int &p) {
	if (n == 0) return 0;
	else return n / p + cal_sum_of_primefactor(n / p, p);
}
int main() {
	int n;
	std::cin >> n;
	auto prime = cal_primes(n);
	unsigned long long int sum{ 1 };
	for (const auto &p : prime) {
		sum = (sum * (cal_sum_of_primefactor(n, p) + 1)) % mod;
	}
	std::cout << sum << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int d,t,s;
    cin>>d>>t>>s;
    if(t*s>=d)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3640
dice = ['23542', '14631', '12651', '15621', '13641', '24532']

d = input().split()
q = int(input())

for _ in range(q):
    num = input().split()
    order = str(d.index(num[0]) + 1) + str(d.index(num[1]) + 1)
    [print(d[i]) for i in range(6) if order in dice[i]]


Measured memory_bytes: 5604
local function getgcd(x, y)
  while 0 < x do
    x, y = y % x, x
  end
  return y
end


local k = io.read("*n")
local ret = 0
for a = 1, k do for b = 1, k do for c = 1, k do
  ret = ret + getgcd(a, getgcd(b, c))
end end end
print(ret)


Measured memory_bytes: 2732
#include <iostream>
using namespace std;
int main() 
{
	int i, j, H, W;
	while (1) {
    		cin >> H >> W;
		if(H == 0 && W == 0) {
        			break;
		}	
		for (i = 1; i <= H; i++) {
			for (j = 1; j <= W; j++) {
				if ((i + j) % 2 == 0)
                        			cout << "#";
                        		else
                        			cout << ".";
            		}
		 	cout << endl;
		}
		cout << endl;
	}
	return 0;
}



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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec A(N+1, 0);
    REP(i,1,N+1) cin >> A[i];

    vector<bool> F(N+1, false);
    ll M = 0;
    for(ll i=N; i>=1; --i) {
        ll c = 0;
        for(ll j=2*i; j<=N; j+=i) c += F[j];
        F[i] = (c % 2 != A[i]);
        M += F[i];
    }
    
    PR(M);
    REP(i,1,N+1) {
        if(F[i]) PS(i);
    }
    PR("");

    return 0;
}

/*



*/

Measured memory_bytes: 4692
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def dijkstra(s,graph):
    d = [inf]*n
    d[s] = 0
    h = [(0,s)]
    while h:
        c,v = heappop(h)
        if d[v] < c:
            continue
        for t,cost in graph[v]:
            if d[v] + cost < d[t]:
                d[t] = d[v] + cost
                heappush(h,(d[t],t))
    return d

n, m = LI()
edges = [[] for _ in range(n)]
for i in range(1, n):
    edges[i].append((i-1, 0))

for _ in range(m):
    l, r, c = LI()
    edges[l-1].append((r-1, c))

d = dijkstra(0, edges)
if d[-1] == inf:
    print(-1)
else:
    print(d[-1])

Measured memory_bytes: 96132
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define M 1000000007
//#define M 998244353
using namespace std;
const int inf=4e18;
const double pi=3.14159265358979;
int knapsack(int n,int W,int w[],int v[])
{
	int i,j;
	int dp[n+1][W+1];//CAREFUL: 1-indexing
	for(j=0;j<=W;j++)
	{
		for(i=0;i<=n;i++)
		{
			if(j==0||i==0)
				dp[i][j]=0;
			else
			{
				if(j-w[i]>=0)
					dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
				else
					dp[i][j]=dp[i-1][j];
			}
		}
	}
	return dp[n][W];
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n,W;cin>>n>>W;
	int w[n+1],v[n+1],i;
	for(i=1;i<=n;i++)
		cin>>w[i]>>v[i];
	int o=knapsack(n,W,w,v);
	cout<<o<<endl;
}

Measured memory_bytes: 79104
#include <stdio.h>

int main(void)
{
  int x, y;
  int i, j;
  int n;
  int size;
  int god[10][10] = {};
  int space;
  int mn;

  while (scanf("%d,%d,%d", &x, &y, &size) != EOF) {
    if (size == 1) {
      n = 1;
      god[x][y]++;
      for (i = 0; i < 2; i++) {
        if (x + n >= 0 && x + n < 10) {
          god[x + n][y]++;
        }
        if (y + n >= 0 && y + n < 10) {
          god[x][y + n]++;
        }
        n = -1;
      }
    }
    if (size == 2) {
      n = 1;
      god[x][y]++;
      for (i = 0; i < 2; i++) {
        if (x + n >= 0 && x + n < 10) {
          god[x + n][y]++;
        }
        if (y + n >= 0 && y + n < 10) {
          god[x][y + n]++;
        }
        if (x + n >= 0 && x + n < 10 && y + n >= 0 && y + n < 10) {
          god[x + n][y + n]++;
        }
        if (x + n >= 0 && x + n < 10 && y - n >= 0 && y - n < 10) {
          god[x + n][y - n]++;
        }
        n = -1;
      }
    }
    if (size == 3) {
      n = 1;
      god[x][y]++;
      for (i = 0; i < 2; i++) {
        if (x + n >= 0 && x + n < 10) {
          god[x + n][y]++;
        }
        if (y + n >= 0 && y + n < 10) {
          god[x][y + n]++;
        }
        if (x + n >= 0 && x + n < 10 && y + n >= 0 && y + n < 10) {
          god[x + n][y + n]++;
        }
        if (x + n >= 0 && x + n < 10 && y - n >= 0 && y - n < 10) {
          god[x + n][y - n]++;
        }

        if (x + n * 2 >= 0 && x + n * 2 < 10) {
          god[x + n * 2][y]++;
        }
        if (y + n * 2 >= 0 && y + n * 2 < 10) {
          god[x][y + n * 2]++;
        }
        n = -1;
      }
    }
  }
  space = 0;
  mn = 0;
  for (i = 0; i < 10; i++) {
    for (j = 0; j < 10; j++) {
      //printf("%3d", god[i][j]);
      if (god[i][j] == 0) {
        space++;
      }
      if (mn < god[i][j]) {
        mn = god[i][j];
      }
    }
    //printf("\n");
  }

  printf("%d\n%d\n", space, mn);

  return (0);
}

Measured memory_bytes: 600
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
  inputs = input.split("\n");
  
  console.log( inputs[0].includes('7') ? 'Yes' :'No');
	
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    char c1, c2, c3;
    c1 = s1.at(0);
    c2 = s2.at(0);
    c3 = s3.at(0);
    cout << c1 << c2 << c3 << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <numeric>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	long long N,K;
	cin >> N >>K;
	long long ans = 0;
	for(long long i =K;i<N+2;i++){
		ans += (N - i + 1) * i+1;
		ans = ans % 1000000007;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3636
m[4][3][10];main(n,a,b,c,d){for(scanf("%d",&n);n--;m[a-1][b-1][c-1]+=d)scanf("%d%d%d%d",&a,&b,&c,&d);for(a=0;a<4;a<3?puts("####################"):1,a++)for(b=0;b<3;puts(""),b++)for(c=0;c<10;c++)printf(" %d",m[a][b][c]);exit(0);}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#include <atcoder/all>

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

using namespace std;
using namespace atcoder;
using lint=long long;

map<long long,int> prime_factorize(long long a){
	map<long long,int> res;
	if(a%2==0){
		int cnt=0;
		do{ cnt++; a/=2; }while(a%2==0);
		res.emplace(2,cnt);
	}
	for(long long p=3;p*p<=a;p+=2) if(a%p==0) {
		int cnt=0;
		do{ cnt++; a/=p; }while(a%p==0);
		res.emplace(p,cnt);
	}
	if(a>1) res.emplace(a,1);
	return res;
}

template<class T>
vector<T> divisors(const map<T,int>& pf){
	vector<T> res={T(1)};
	for(const auto& q:pf){
		int m=res.size();
		T pp=1;
		rep(i,q.second){
			pp*=q.first;
			rep(i,m) res.emplace_back(res[i]*pp);
		}
	}
	sort(res.begin(),res.end());
	return res;
}

template<class T>
T xgcd(T a,T b,T& x,T& y){
	if(b==0){ x=1; y=0; return a; }
	T g=xgcd(b,a%b,y,x);
	y-=a/b*x;
	return g;
}

pair<long long,long long> Chinese_remainder(vector<long long> a,vector<long long> b,vector<long long> m){
	int n=a.size();
	assert(n==b.size() && n==m.size());

	long long x=0,M=1;
	rep(i,n){
		a[i]%=m[i]; if(a[i]<0) a[i]+=m[i];
		b[i]%=m[i]; if(b[i]<0) b[i]+=m[i];
		if(a[i]==0){
			if(b[i]!=0) return {-1,-1};
			continue;
		}

		long long p,q,g;
		g=xgcd(a[i],m[i],p,q);
		if(b[i]%g!=0) return {-1,-1};
		m[i]/=g;
		b[i]=(b[i]/g)*p%m[i];

		g=xgcd(M,m[i],p,q);
		if((b[i]-x)%g!=0) return {-1,-1};
		x+=M*((b[i]-x)/g*p%(m[i]/g));
		M*=m[i]/g;
	}
	x%=M; if(x<0) x+=M;
	return {x,M};
}

const long long INF=1LL<<61;

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

	lint ans=LLONG_MAX;
	for(auto d:divisors(prime_factorize(2*n))){
//		vector<lint> a={1,1};
		vector<lint> b={0,2*n/d-1};
		vector<lint> m={d,2*n/d};
//		auto tmp=Chinese_remainder(a,b,m);
		auto tmp=crt(b,m);
		if(tmp.first!=0 || tmp.second!=0){
//		if(tmp.first!=-1){
			ans=min(ans,tmp.first==0?tmp.second:tmp.first);
		}
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 3892
#include<bits/stdc++.h>
      using namespace std;
      #define ll  int
      #define ii pair<ll ,ll >
      #define pb push_back
      #define range 
      #define vi vector <ll >
      #define mod 1000000007
      #define eps 1e-9
      #define fi first
      #define se second
      #define _ <<" "<<
      #define forn(x, n) for(int x = 0; x < n ;++ x) 
      #define forn2(x, n) for(long long ll x = 1; x < n ;++ x) 
      #define forn1(x,n) for(ll x = 1; x <= n ;++ x)
      #define IOS ios_base::sync_with_stdio(0 );cin.tie(0);cout.tie(0);
  vi graph[1005];
  int vis[1005][1005];
    ll gcd(ll a,ll b)
    {
      if(b==0) {return a;}
     return gcd(b,a%b);
    }

  


void solve(){
  string s;
  cin >> s;
  int zcount = 0, ans = 0;
  for (int i = 0; i < s.size(); i++){
    if (s[i] == '0'){
      zcount++;
    }else{
      int t = 1;
      ans++;
      for (int j = i + 1; j < s.size(); j++){
        t *= 2;
        t += s[j] - '0';
        if (zcount + j - i + 1 < t){
          break;
        }
        ans++;
      }
      zcount = 0;
    }
  }
  printf("%d\n", ans);
}
int main(){
   // freopen ("test.txt","r",stdin);
  int n;
  cin>>n;
int b[n-1],a[n];
forn(i,n-1)
{
  cin>>b[i];
}
int sum=0;
a[0]=b[0];
a[n-1]=b[n-2];
for(int i=1;i<=n-2;i++)
{
  a[i]=min(b[i],b[i-1]);
  //cout<<a[i]<<" ";
}

forn(i,n)
{
 sum+=a[i];
}

cout<<sum;
return 0;
} 
 



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int ans,n,x,s;
int a[110];
int main()
{
	scanf("%d%d", &n, &x);
	for (int i=1;i<=n;i++)
		scanf("%d", &a[i]);
	sort(a+1,a+n+1);
	s = 0;
	ans = 0;
	for (int i=1;i<n;i++)
	{
		s += a[i];
		if (s > x) 
			break;
		ans++;
	}
	if (s + a[n] == x) ans++;
	printf("%d\n", ans);
}	

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    a, b = map(int, input().split())

    if b < 0:
        if (b - a) % 2 == 0:
            ans = "Negative"
        else:
            ans = "Positive"
    elif a <= 0 <= b:
        ans = "Zero"
    else:
        ans = "Positive"

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;

using namespace std;

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

    int N;
    cin >> N;

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

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

    return 0;
}



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

using namespace std;
typedef long long ll;
long long mod = 1000000007;
const int INF = 100100100;

int main(){
  int n,u,v;
  cin >> n >> u >> v;
  u--; v--;
  vector<vector<int>> ed(n,vector<int>(0));
  for(int i=0;i<n-1;i++){
    int a,b;
    cin >> a >> b;
    a--; b--;
    ed.at(a).push_back(b);
    ed.at(b).push_back(a); 
  }
  vector<int> distv(n,INF);
  distv.at(v) = 0;
  queue<int> qv;
  qv.push(v);
  while(!qv.empty()){
    int a = qv.front(); qv.pop();
    for(auto b: ed.at(a)){
      if(distv.at(b)==INF){
      distv.at(b) = distv.at(a)+1;
      qv.push(b);
      }
    }    
  }
  
  vector<int> distu(n,INF);
  distu.at(u) = 0;
  queue<int> qu;
  qu.push(u);
  while(!qu.empty()){
    int a = qu.front(); qu.pop();
    for(auto b: ed.at(a)){
      if(distu.at(b)==INF && distv.at(b) >= (distv.at(u)/2)+1){
      distu.at(b) = distu.at(a)+1;
      qu.push(b);
      }
    }    
  }
  int maximum = 0;
  for(int i=0;i<n;i++){
    if(distu.at(i) != INF){
      maximum = max(maximum,distv.at(i));      
    }
  }
  cout << maximum - 1 << endl;
} 

Measured memory_bytes: 6656
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll a[Max],b[Max];
ll n,m,k,res; 
struct BIT {
private:
	vector<ll> node; int n;
public:
	void init(int n_) {
		n = n_; node.resize(n, 0);
	}
	//0-indexed
	void add(int a, ll w) {
		for (int i = a; i < n; i |= i + 1)node[i] += w;
	}
	//[0,a)
	ll sum(int a) {
		ll ret = 0;
		for (int i = a - 1; i >= 0; i = (i&(i + 1)) - 1)ret += node[i];
		return ret;
	}
	//[a,b)
	ll sum(int a, int b) {
		return sum(b) - sum(a);
	}
};
void solve(){
	string s;
	cin>>s;
	ll q;cin>>q;
	ll flag = 1,cnt=0;
	string front="",back="";
	while(q--){
		ll tep;
		cin>>tep;
		if(tep==1){
			cnt++;
			if(flag == 1)flag = 2;
			else flag = 1;
		}else{
			ll p;
			char c;
			cin>>p>>c;
			if(p==flag)front+=c;
			else back+=c;
		}
	}
	if(cnt&1){
		for(int i=sz(back)-1;i>=0;i--)cout<<back[i];
	
		for(int i=sz(s)-1;i>=0;i--)cout<<s[i];
		cout<<front;
	}else {
		for(int i=sz(front)-1;i>=0;i--)cout<<front[i];
		cout<<s<<back; 
	}
	
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 1104
/*
 * Click `Run` to execute the snippet below!
 */

import java.io.*;
import java.util.*;

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String march = "MARCH";
    TreeMap<Character,Integer> mp = new TreeMap<Character, Integer>();
    for(int i = 0; i<5; i++){
      mp.put(march.charAt(i), 0); 
    }
    for(int i = 1; i<=N; i++){
      String s = sc.next();
      mp.put(s.charAt(0), mp.containsKey(s.charAt(0)) ? mp.get(s.charAt(0))+1 : 1);
    }
    long ans = 0;
    for(int i = 0; i<5; i++){
      for(int j = i+1; j<5; j++){
        for(int k = j+1; k<5; k++){
            ans += 1L * mp.get(march.charAt(i)) * mp.get(march.charAt(j)) * mp.get(march.charAt(k));
        }
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 58840
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        if (a+b == 15){
            System.out.println("+");
        } else if (a*b == 15){
            System.out.println("*");
        } else {
            System.out.println("x");
        }
    }
}

Measured memory_bytes: 21972
import itertools

n,m=map(int,input().split())

if n ==2:
    print(1)
    exit()

arr=[[_] for _ in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    #print(a,b)
    
    arr[a-1].append(b-1)
    arr[b-1].append(a-1)

#print("arr",arr)

route=list(itertools.permutations(range(1,n)))
#print("route",route) 
ans=0
for i in route:
    chk0=0
    chk=True
    if i[0] in arr[0]:
        chk0 =True
        #print(i)
        for j in range(1,n-1):
            if i[j] in arr[i[j-1]]:
                chk0+=1
                
                pass
            else:
                #print(1,i[j],arr[i[j-1]])
                break
                
    if chk0==n-1:
        
        ans+=1

print(ans)

Measured memory_bytes: 42736
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2 vector<vec>
#define vecll2 vector<vecll>
#define vec3 vector<vec2d>
#define vecll3 vector<vecll2d>
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(vector<T> v){for(T e:v)cout<<e<<" ";cout<<endl;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
void print(vector<vec> v){for(auto e:v){for(auto ee:e)cout<<ee<<" ";cout<<endl;}}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}

const int N=1e5+10;
ll a[N<<4];
int sum[11];
main(){
    ios
    int h,w,n;scanf("%d%d%d",&h,&w,&n);
    ll x;int y;
    int cnt=0;
    ll m=(ll)(h-2)*(w-2);
    rep(iii,n){
        scanf("%d%d",&x,&y);
        rep(i,3)if( x-i>=1 && x-i<=h-2){
            rep(j,3)if(y-j>=1 && y-j<=w-2){
            a[cnt++]=((x-i)<<32)+(y-j);
            }
        }
    }
    sort(a,a+cnt);
    ll t=1;
    rep(i,cnt){
        if(a[i]==a[i+1])t++;
        else sum[t]++,t=1,m--;
    }
    cout<<m<<" ";
    rep2(i,1,9)cout<<sum[i]<<" ";
}



Measured memory_bytes: 8448
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC150A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var k = input[0];
            var x = input[1];
            if (500 * k >= x)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println(Math.max(Math.max(a + b, a - b), a * b));

		sc.close();
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#define rep(i, n)  for (int i = 0; i <  (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ll INF = ll(1e18)+1;
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    long double a,b;
    cin >> a >> b;
    
    long long result = ll(a*b);
 
    cout << result;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
int dp[200005];
vector<int> G[200005];
int n;
int a[200005];
int ans[200005];
const int inf = 0x3f3f3f3f;
void dfs(int u,int p){
	int ind = (int)(lower_bound(dp,dp+n,a[u]) - dp);
	int cnt = dp[ind];
	dp[ind] = a[u];
	ans[u] = (int)(lower_bound(dp,dp+n,inf) - dp);
	for(int i:G[u]){
		if(i!=p){
			dfs(i,u);
		}
	}
	//undo
	dp[ind] = cnt;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n-1;i++){
		int t1,t2;
		cin>>t1>>t2;
		t1--,t2--;
		G[t1].push_back(t2);
		G[t2].push_back(t1);
	}
	fill(dp,dp+n+2,inf);
	dfs(0,-1);
	for(int i=0;i<n;i++) cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 31036
#include "bits/stdc++.h"
using namespace std;

const int N = 200005;

int main() {
   int a, b, c, d;
   cin >> a >> b >> c >> d;
   bool ok = 0;

   ok |= (abs(a - c) <= d);
   ok |= ((abs(a - b) <= d) && (abs(c - b) <= d));

   cout << (ok? "Yes": "No") << endl;
   return 0;
}


Measured memory_bytes: 256
#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;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll ans = 0;

  rep(i,60) {
    ll x = 0;
    rep(j,n) if (a[j] >> i&1) x++;
    ll now = x*(n-x) % mod;
    rep(j,i) now = now*2%mod;
    ans += now;
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
(let* ((n (read))
       (k (read))
       (line (concatenate 'vector (loop repeat n collect (read))))
       (ans 0)
       (sum 0))
  (loop for i below n
        for j from (- 0 k)
        do
        (progn
          (incf sum (aref line i))
          (when (>= j 0)
            (decf sum (aref line j)))
          (setf ans (max ans sum))))
  (princ (/ (+ ans k) 2.0)))


Measured memory_bytes: 61800
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}

using Graph = vector<vector<int>>;

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

  Graph G(N);
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
  }

  int s, t; cin >> s >> t;
  s--; t--;

  VV dist(N, V(3, INF));
  queue<P> que;
  dist[s][0] = 0;
  que.push(P(s, 0));
  while (!que.empty()) {
    int v, j;
    tie(v, j) = que.front(); que.pop();
    int jj = (j+1) % 3;
    for (auto nv : G[v]) {
      if (chmin(dist[nv][jj], dist[v][j] + 1)) {
        que.push(P(nv, jj));
      }
    }
  }

  if (dist[t][0] == INF) {
    cout << -1 << endl;
  }
  else {
    cout << (dist[t][0] / 3) << endl;
  }
  return 0;
}


Measured memory_bytes: 11772
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#pragma 03
using namespace std;
string s[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
int main(){ 
	string a;
	cin >> a;
	for (int i = 0; i<7; i++){
		if (a == s[i]) cout << 7 - i << endl;
	}
    return 0; 
} 

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());



int main(){
    llong n;
    cin >> n;
    llong ans=1;
    for(llong i=1; i*i <=n ; i++){
        if(n%i==0) ans = i;
    }
    ans = n /ans ;
    int keta = 0;
    llong tmp = 1;
    while(1){
        keta += 1;
        tmp *= 10;
        if( ans < tmp ) break;
    }
    cout << keta << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
int n,m;
vector <pii> neigh[100003];
int dist[100003];
int main() {
	cin>>n>>m;
	for (int i=0; i<m; i++) {
		int x,y,l;
		cin>>x>>y>>l;
		neigh[x].push_back(pii(y,l));
		neigh[y].push_back(pii(x,-l));
	}
	for (int i=1; i<=n; i++) dist[i]=1e9;
	for (int i=1; i<=n; i++)
		if (dist[i]==1e9) {
			queue <int> q;
			q.push(i);
			dist[i]=0;
			while (!q.empty()) {
				int x=q.front();
				q.pop();
				for (int i=0; i<neigh[x].size(); i++) {
					int p=neigh[x][i].first;
					int di=neigh[x][i].second;
					if (dist[p]!=1e9) {
						if (dist[x]+di!=dist[p]) {
							puts("No");
							return 0;
						}
					} else {
						dist[p]=dist[x]+di;
						q.push(p);
					}
				}
			}
		}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 9984
n,k = map(int, input().split())
s = list(input())
if s[k-1] == "A":
    s[k-1] = 'a'
elif s[k-1] == "B":
    s[k-1] = 'b'
else:
    s[k-1] = 'c'

print("".join(s))


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

using namespace std;
using ll = long long int;

int main()
{
    string s, t;
    cin >> s >> t;

    int ans = 0;
    for (size_t i = 0; i < s.size(); i++)
    {
        if (s[i] != t[i])
        {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3900
import java.util.Scanner

fun main(args: Array<String>){
  val cin = Scanner(System.`in`)
  val n = cin.nextLong()
  val t = cin.nextLong()

  var res = 0L
  var tmp = 0L
  for (i in 0..n - 1){
    val a = cin.nextLong()
    if (t < a - tmp){
      res += t
    }
    else {
      res += (a - tmp)
    }
    tmp = a
  }

  println(res + t)
  cin.close()
}

Measured memory_bytes: 70400
#include <stdio.h>
    #include <stdlib.h>
     
    int main(void) {
       int a, b, c, d;
       scanf("%d %d %d %d",&a,&b,&c,&d);
     
       if( abs(a-c) <=d){
        printf("Yes");
          return 0;
       }
     
       if( abs(a-b)<=d && abs(b-c)<=d){
        printf("Yes");
          return 0;
       }
       printf("No");
     return 0;
    }

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

using namespace std;


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

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int n;
	cin >> n;

	ll h[n];
	rep(i, n) cin >> h[i];

	ll c[n];
	c[0] = 0;
	c[1] = abs(h[1] - h[0]);
	for(int i = 1; i+1 <= n-1; i++){
		c[i+1] = min(c[i-1] + abs(h[i+1] - h[i-1]), c[i] + abs(h[i+1] - h[i]));
	}

	cout << c[n-1] << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

const double eps = 1e-10;
const double inf = 1e+10;
const double pi = acos(-1.0);
int sgn(double a) { return a < -eps ? -1 : a > eps; }
using P = complex<double>;
namespace std {
  istream& operator>>(istream& i, P& p) { double x, y; i >> x >> y; p = P(x, y); return i; }
  ostream& operator<<(ostream& o, const P& p) { o << real(p) << ' ' << imag(p); return o; }
  bool operator<(const P& p, const P& q) { return sgn(real(p) - real(q)) ? sgn(real(p) - real(q)) < 0 : sgn(imag(p) - imag(q)) < 0; }
  bool operator>(const P& p, const P& q) { return q < p; }
  bool operator<=(const P& p, const P& q) { return !(p > q); }
  bool operator>=(const P& p, const P& q) { return !(p < q); }
}
bool eq(const P& p, const P& q) { return !(p < q) and !(p > q); }
double dot(const P& p, const P& q) { return real(conj(p) * q); }
double cross(const P& p, const P& q) { return imag(conj(p) * q); }

int ccw(P p0, P p1, P p2) {
  p1 -= p0, p2 -= p0;                         //             (1)
  if (sgn(cross(p1, p2)) > 0) return 1;       //
  if (sgn(cross(p1, p2)) < 0) return -1;      // (-2)---p0---(0)---p1---(2)
  if (sgn(dot(p1, p2) < 0)) return -2;        //
  if (sgn(norm(p1) - norm(p2)) < 0) return 2; //             (-1)
  return 0;
}

double area(const V<P>& g) {
  double res = 0.0;
  for (int i = 0; i < g.size(); i++) res += cross(g[i], g[(i + 1) % g.size()]);
  return 0.5 * res;
}

P intP(P p1, P p2, P q1, P q2) {
  q2 -= q1, p2 -= p1, q1 -= p1;
  return p1 + cross(q1, q2) / cross(p2, q2) * p2;
}

V<P> convex_cut(const P& p0, const P& p1, const V<P>& g) {
  V<P> res;
  int n = g.size();
  for (int i = 0; i < n; i++) {
    if (ccw(p0, p1, g[i]) != -1) res.push_back(g[i]);
    if (ccw(p0, p1, g[i]) * ccw(p0, p1, g[(i + 1) % n]) == -1) res.push_back(intP(p0, p1, g[i], g[(i + 1) % n]));
    if (ccw(p0, p1, g[(i + 1) % n]) != -1) res.push_back(g[(i + 1) % n]);
  }
  res.erase(unique(res.begin(), res.end()), res.end());
  return res;
}

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<P> g(n); for (int i = 0; i < n; i++) cin >> g[i];
  int q; cin >> q;
  for (int i = 0; i < q; i++) {
    P p0, p1; cin >> p0 >> p1;
    cout << fixed << setprecision(10) << area(convex_cut(p0, p1, g)) << '\n';
  }
}


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

int debug =0;

int main()
{
    int n;
    string st;
    map<string,int> mp;

    cin >> n;
    rep(i,n){
        cin >> st;
        auto itr = mp.find(st);
        if(itr != mp.end()){// found
            int val = itr->second;
            itr->second = val+1;
        }else{ // not found
            mp[st]=1;
        }
    }

    if(debug){
        for(auto itr = mp.begin();itr !=mp.end();++itr){
            cout << "<" << itr->first << "," << itr-> second << ">" <<endl;
        }

    }

    cout << mp.size() << endl;
    return 0;
}

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

int main(void){
    int N,K;
    cin >> N >> K;
    int A[200010] = {};
    int B[200010] = {};
    
    for(int i = 1 ; i <= N ; i++){
        cin >> A[i];
        B[A[i]]++;
    }
    
    sort(B,B+N+1,greater<int>());
    
    int a = 0;
    for(int i = 0 ; i < K ; i++){
        a +=B[i];
    }
    int b = 0;
    for(int i = 0 ; i <= N ; i++){
        b +=B[i];
    }
    cout << b - a << endl;
    return 0;
}

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

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

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

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

  int64_t N, K;
  cin >> N >> K;
  vector<int64_t> X(N);
  for (int64_t i = 0; i < N; ++i) {
    cin >> X[i];
  }

  int64_t result = INT64_MAX;
  for (int64_t start_index = 0; start_index + K <= N; ++start_index) {
    const int64_t start = X[start_index];
    const int64_t end = X[start_index + K - 1];
    if (start >= 0) {
      result = min(result, end);
    } else if (end <= 0) {
      result = min(result, -start);
    } else {
      result = min(result, -start * 2 + end);
      result = min(result, end * 2 - start);
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 1024