akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif

signed main() {
    
    string s[3];
    cin >> s[0] >> s[1] >> s[2];
    
    rep(i,3){
        cout << (char)(s[i][0] + 'A' - 'a');
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#include<vector>
struct UF{
	int n;
	vector<int>parent,rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,0)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a)
	{
		return parent[a]!=a?parent[a]=find(parent[a]):a;
	}
	bool same(int a,int b)
	{
		return find(a)==find(b);
	}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
		}
		else
		{
			parent[b]=a;
			if(rank[a]==rank[b])rank[a]++;
		}
		return true;
	}
};
int n,m;
main()
{
	while(cin>>n>>m,n)
	{
		UF*uf[10000];
		int ans[10000];
		for(int i=0;i<10000;i++)ans[i]=-1,uf[i]=new UF(n);
		vector<pair<int,pair<int,int> > >e;
		for(int i=0;i<m;i++)
		{
			int a,b,w;cin>>a>>b>>w;
			e.push_back(make_pair(w-1,make_pair(a-1,b-1)));
		}
		sort(e.begin(),e.end());
		for(pair<int,pair<int,int> >p:e)
		{
			for(int i=0;i<=p.first;i++)
			{
				if(uf[i]->unite(p.second.first,p.second.second))ans[i]=p.first;
			}
		}
		int s=1e9;
		for(int i=0;i<10000;i++)
		{
			int id=uf[i]->find(0);
			bool flag=1;
			for(int j=1;j<n;j++)flag&=id==uf[i]->find(j);
			if(flag)
			{
				s=min(s,ans[i]-i);
			}
		}
		cout<<(s<1e9?s:-1)<<endl;
	}
}



Measured memory_bytes: 90732
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void visit(const vector<vector<int>> &g, vector<int> &order, vector<int> &mark, int pos){
	for(auto& next : g[pos]){
		if(mark[next]) continue;
		visit(g, order, mark, next);
	}
	mark[pos] = 1;
	order.push_back(pos);
}

vector<int> topologicalSort(const vector<vector<int>> &g){
	vector<int> res;
	vector<int> mark(g.size(), 0);
	for(int i=0;i<g.size();i++){
		if(mark[i]) continue;
		visit(g, res, mark, i);
	}
	reverse(res.begin(), res.end());
	return res;
}

int main(){
    int N, M;
    while(cin >> N >> M){
        vector<vector<int>> g(N), h(N);
        for(int i=0;i<N+M-1;i++){
            int a, b; cin >> a >> b;
            --a; --b;
            g[a].push_back(b);
            h[b].push_back(a);
        }
        vector<int> order = topologicalSort(g);
        vector<int> rank(N);
        for(int i=0;i<order.size();i++){
            rank[order[i]] = i;
        }
        vector<int> res(N, -1);
        for(auto& t : order){
            res[t] = 0;
            int best = -1;
            for(auto dst : h[t]){
                if(best < rank[dst]){
                    res[t] = dst + 1;
                    best = rank[dst];
                }
            }
        }
        for(auto& t : res) cout << t << endl;
    }
}

Measured memory_bytes: 17140
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<vector>
#define LL long long
using namespace std;
const LL INF=1e+18;
const double EPS=1e-9;
const LL MOD=1000000007;
typedef pair<LL,LL> P;
struct edge
{ 
	LL to; 
	LL cost; 
};
const LL dx[]={1,0,-1,0},dy[]={0,-1,0,1};
LL n,q,k,dist[100000];
vector<edge> tree[100000];
 
void dijkstra(LL s)
{
	priority_queue<P,vector<P>,greater<P> > que;
	for(LL i = 0;i < n;i++) dist[i] = INF;
	dist[s] = 0;
	que.push(make_pair(0,s));
	while(!que.empty())
	{
		P p=que.top();
		que.pop();
		LL v=p.second;
		if(dist[v]<p.first) 
		{
			continue;
		}
		for(LL i=0;i<tree[v].size();i++)
		{
			edge e=tree[v][i];
			if(dist[e.to]>dist[v] + e.cost)
			{
				dist[e.to]=dist[v] + e.cost;
				que.push(make_pair(dist[e.to],e.to));
			}
		}
	}
}
int main()
{
	scanf("%lld",&n);
	for(LL i=0;i<n-1;i++)
	{
		LL a,b,c;
		scanf("%lld %lld %lld",&a,&b,&c); 
		a--;
		b--;
		tree[a].push_back({b,c});
		tree[b].push_back({a,c});
	}
	scanf("%lld %lld",&q,&k);
	k--;
	dijkstra(k);
	for(LL i=1;i<=q;i++)
	{
		LL a,b;
		scanf("%lld %lld",&a,&b);
		a--;
		b--;
		printf("%lld\n",dist[a]+dist[b]);
	}
	return 0;
}

Measured memory_bytes: 11120
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

ll func(const string&str,ll r,ll s,ll p)
{
    ll ret=0;
    char prev='\0';
    auto win=[](char c){return c=='r'?'p':c=='s'?'r':'s';};
    for(auto c:str){
        char w=win(c);
        if(w==prev){
            prev='\0';
        }else{
            ret+=w=='r'?r:w=='s'?s:p;
            prev=w;
        }
    }
    return ret;
}
int main()
{
    ll n=in(),k=in();
    ll r=in(),s=in(),p=in();
    string t;cin>>t;
    vector<string>foo(k);
    for(ll i=0;i<n;++i)foo[i%k]+=t[i];
    ll ans=0;
    for(ll i=0;i<k;++i)ans+=func(foo[i],r,s,p);
    cout<<ans<<endl;
}


Measured memory_bytes: 5120
N, T = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
dp = [[0] * (T+1) for _ in range(N+1)]
AB.sort()
ret = 0
for i in range(1,N+1):
    for j in range(1,T+1):
        if j < AB[i-1][0]:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j-AB[i-1][0]] + AB[i-1][1], dp[i-1][j])

m = 0
for i in range(N):
    m = max(m, AB[i][1]+dp[i][T-1])

print(m)


Measured memory_bytes: 116696
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

// Solution
public class Main {
  private static Scanner in;
  private static PrintWriter out;
  private static final String INPUT = ""; // input file name

  /**
   * Interactive get next command
   */
  static int get(int pos) {
    out.println(pos + 1);
    out.flush();
    return ni();
  }

  static void solve() {
    int items = ni();
    int capacity = ni();
    int[][] arr = new int[items][2];

    int totalValue = 0;

    for (int i = 0; i < items; i++) {
      for (int j = 0; j < 2; j++) {
        arr[i][j] = ni();

        if (j == 1)
          totalValue += arr[i][j];
      }
    }

    long[] dp = new long[totalValue + 1];
    Arrays.fill(dp, (long) 1E18 + 5);
    dp[0] = 0;

    for (int i = 0; i < items; i++) {
      for (int j = totalValue; j >= 0; j--) {
        int[] currentElement = arr[i];

        if (0 <= j - currentElement[1]) {
          dp[j] = Math.min(dp[j], dp[j - currentElement[1]] + currentElement[0]);
        }
      }
    }

    long ans = 0;
    // maximum index of i greater than capacity
    for (int i = 0; i <= totalValue; i++) {
      if (dp[i] <= capacity)
        ans = Math.max(i, ans);
    }

    out.println(ans);
  }

  public static void main(String[] args) throws Exception {
    long S = System.currentTimeMillis();
    in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
    out = new PrintWriter(System.out);

    solve();
    out.flush();
    long G = System.currentTimeMillis();
    tr(G - S + "ms");
  }

  private static int gcd(int a, int b) {
    while (b != 0) {
      int t = b;
      b = a % b;
      a = t;
    }

    return a;
  }

  private static int ni() {
    return Integer.parseInt(in.next());
  }

  private static long nl() {
    return Long.parseLong(in.next());
  }

  // Math Utils
  private static int pi(int num, int pow) {
    int result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        result *= num;
      }

      num *= num;
      pow /= 2;
    }

    return result;
  }

  private static int pim(int num, int pow, int mod) {
    int result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        // keep collecting `odd` num in result
        result = (result * num) % mod;
      }

      num = (num * num) % mod;
      pow /= 2;
    }

    return result;
  }

  private static long pl(long num, long pow) {
    long result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        result *= num;
      }

      num *= num;
      pow /= 2;
    }

    return result;
  }

  private static long plm(long num, long pow, long mod) {
    long result = 1;

    while (pow > 0) {
      if (pow % 2 == 1) {
        // keep collecting `odd` num in result
        result = (result * num) % mod;
      }

      num = (num * num) % mod;
      pow /= 2;
    }

    return result;
  }

  static void tr(Object... o) {
    if (!INPUT.isEmpty())
      out.println(Arrays.deepToString(o));
  }
}


Measured memory_bytes: 23380
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())

    ans = 0
    for i in range(1, N + 1):
        if any((not i % 15, not i % 5, not i % 3)):
            continue
        else:
            ans += i
    print(ans)


main()


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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

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

const double EPS = 1e-10;

const int N = 30;
int dp[N+1];
int n;

int main() {
  while (1) {
    scanf("%d ", &n); 
    if (!n) break;
    memset(dp, 0, sizeof(dp));
    dp[0] = 1;
    for (int i=1; i<=n; i++) {
      if (i-3 >= 0) dp[i] += dp[i-3]; 
      if (i-2 >= 0) dp[i] += dp[i-2]; 
      if (i-1 >= 0) dp[i] += dp[i-1]; 
    }
    int res = dp[n]/3650;
    if (dp[n]%3650) res++;
    printf("%d\n", res);
  }

	return 0;
}

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

using namespace std;

using ll = long long;


bool check(int x) {
  int rev = 0;
  int y = x;
  while (x > 0) {
    rev = rev * 10 + x % 10;
    x /= 10;
  }
  return y == rev;
}
int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  for (int i = a; i <= b; i++) {
    if (check(i)) {
      ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}




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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 100000

int main() {
	int a, b, h;

	cin >> a >> b >> h;

	int ans = ( a + b ) * h / 2;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
const int N = 603;
int n, D1, D2, cnt;
bool vis[N][N];
inline void calc(int d){
	int len = 0;
	while(!(d & 3)) d /= 4, ++ len;
	if(d & 1)
		for(Rint i = 0;i < n * 2;i ++)
			for(Rint j = 0;j < n * 2;j ++)
				vis[i][j] |= (((i >> len) & 1) ^ ((j >> len) & 1));
	else if(!(d & 1))
		for(Rint i = 0;i < n * 2;i ++)
			for(Rint j = 0;j < n * 2;j ++)
				vis[i][j] |= ((i >> len) & 1);
}
int main(){
	scanf("%d%d%d", &n, &D1, &D2);
	calc(D1); calc(D2);
	for(Rint i = 0;i < 2 * n && cnt < n * n;i ++)
		for(Rint j = 0;j < 2 * n && cnt < n * n;j ++)
			if(!vis[i][j]){++ cnt; printf("%d %d\n", i, j);}
}

Measured memory_bytes: 1280
#include<iostream>
#include<string>
using namespace std;
int North(int *p){
  int mem;
  mem = p[1];
  p[1] = p[2];
  p[2] = p[6];
  p[6] = p[5];
  p[5] = mem;
  return p[1];
}
int East(int *p){
  int mem;
  mem = p[1];
  p[1] = p[4];
  p[4] = p[6];
  p[6] = p[3];
  p[3] = mem;
  return p[1];
}
int West(int *p){
  int mem;
  mem = p[1];
  p[1] = p[3];
  p[3] = p[6];
  p[6] = p[4];
  p[4] = mem;
  return p[1];
}
int South(int *p){
  int mem;
  mem = p[1];
  p[1] = p[5];
  p[5] = p[6];
  p[6] = p[2];
  p[2] = mem;
  return p[1];
}
int Right(int *p){
  int mem;
  mem = p[2];
  p[2] = p[3];
  p[3] = p[5];
  p[5] = p[4];
  p[4] = mem;
  return p[1];
}
int Left(int *p){
  int mem;
  mem = p[2];
  p[2] = p[4];
  p[4] = p[5];
  p[5] = p[3];
  p[3] = mem;
  return p[1];
}
int main(){
  int n,p[7];;
  string com;
  while(cin >> n){
    if(n==0) break;
    int s = 1;
    for(int i=0;i<=6;i++) p[i] = i;
    for(int i=0;i<n;i++){
      cin >> com;
      if(com=="North") s += North(p);
      else if(com=="East") s += East(p);
      else if(com=="West") s += West(p);
      else if(com=="South") s += South(p);
      else if(com=="Right") s += Right(p);
      else s += Left(p);
    }
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

//素数判定．1:素数
ll is_prime(ll n) {
  if (n == 1) return 0;
  if (n == 2) return 1;
  if (n % 2 == 0) return 0;
  for (ll i = 3; i <= sqrt(n); i += 2)
    if (n % i == 0) return 0;
  return 1;
}

int main() {
  ll q;
  cin >> q;

  vll like2017(1, 3);
  for (ll i = 3; i <= 50000; i += 2) {
    if (is_prime(i) == 1) {
      if (is_prime(2 * i - 1) == 1) {
        like2017.push_back(2 * i - 1);
      }
    }
  }
  ll m = like2017.size();

  for (ll i = 0; i < q; i++) {
    ll l, r;
    cin >> l >> r;
    ll memo1 = -1, memo2 = -1;
    for (ll j = 0; j < m; j++) {
      if (like2017[j] >= l) {
        memo1 = j;
        break;
      }
    }
    if (memo1 == -1) {
      cout << 0 << endl;
      continue;
    }
    for (ll j = 0; j < m; j++) {
      if (like2017[m - 1 - j] <= r) {
        memo2 = m - 1 - j;
        break;
      }
    }
    if (memo2 == -1) cout << 0 << endl;
    else cout << memo2 - memo1 + 1 << endl;
  }
}

Measured memory_bytes: 640
#include<iostream>
        #define rep(i,f,t) for(int i=f;i<t;i++)
        #define ll long long
        #define inf 1000000009
        using namespace std;
        int main(){
        	int h,n;
          	cin>>h>>n;
          	int a[n],b[n];
          	int dp[h+1];
          	rep(i,0,h+1)dp[i]=inf;
          	dp[0]=0;
          	rep(i,0,n){
              	cin>>a[i]>>b[i];
            	rep(j,0,h){
                	dp[min(j+a[i],h)]=min(dp[min(j+a[i],h)],dp[j]+b[i]);
                }
            }
          	cout<<dp[h]<<endl;
         	return 0;
        }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>

typedef long long ll;
using namespace std;

int main()
{
  int n;
  cin >> n;
  ll k = 10000000;
  ll a,res,c;

  for(int i=0; i<n; i++){
    c=0;
    cin >> a;
    while(a%2 == 0){
      c++;
      a/=2;
    }
     k = min(k,c);
  }
  cout << k << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int A, B, m;
	cin >> A >> B >> m;
	vector<int> a(A), b(B);
	rep(i, A) cin >> a[i];
	rep(i, B) cin >> b[i];
	vector<int> x(m), y(m), c(m);
	rep(i, m) {
		cin >> x[i] >> y[i] >> c[i];
		x[i]--; y[i]--;
	}
	int ans = inf;
	rep(i, m) {
		int res = a[x[i]] + b[y[i]] - c[i];
		ans = min(ans, res);
	}

	sort(all(a));
	sort(all(b));
	ans = min(ans, a[0] + b[0]);
	dunk(ans);
	return 0;
}

Measured memory_bytes: 2304
import sys
s = input()
O = "keyence"
k = 0
for i in range(7,0,-1):
    if s[:i] == O[:i]:
        k = i
        if k == 7:
            print("YES")
            sys.exit()
        break
if s[len(s)+k-7:len(s)] == O[k:]:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

int n, L, Q;
int a[100010], dist[100010][100];
P q[100010];
int dist1(int i, int mid){
	if(a[mid]-a[i] <= L)return 1;
	else return 0;
}

int dist2(int l, int r, int mid){
	int p = l;
	rep(i,30){
		if(mid&(1<<i))p = dist[p][i];
	}
	if(r <= p)return 1;
	else return 0;
}

signed main(){
	scanf("%lld", &n);
	rrep(i,n)scanf("%lld", &a[i]);
	scanf("%lld%lld", &L, &Q);
	rep(i,Q){
		int x, y;
		scanf("%lld%lld", &x, &y);
		if(y < x)swap(x, y);
		q[i] = P(x, y);
	}
	
	rrep(i,n){
		int lb = i, ub = n+1;
		while(ub-lb > 1){
			int mid = (ub+lb)/2;
			int f = dist1(i, mid);
			if(f == 1)lb = mid;
			else ub = mid;
		}
		dist[i][0] = lb;
	}
	rrep(j,30)rrep(i,n){
		dist[i][j] = dist[dist[i][j-1]][j-1];
	}
	
	rep(i,Q){
		int l = q[i].fi, r = q[i].se;
		int lb = -1, ub = n;
		while(ub-lb > 1){
			int mid = (ub+lb)/2;
			int f = dist2(l, r, mid);
			if(f == 1)ub = mid;
			else lb = mid;
		}
		printf("%lld\n", ub);
	}
	return 0;
}




Measured memory_bytes: 81280
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

ll X;
bool dp[1010][110];

int main()
{
  scanf( "%lld", &X );

  ll cnt = X/100;
  ll mod = X%100;

  dp[0][mod] = true;

  rep( i, cnt ) rep( j, mod+1 ) rep( k, 6 )
  {
    if( j-k >= 0 )
      dp[i+1][j-k] |= dp[i][j];
  }

  puts( dp[cnt][0] ? "1" : "0" );

  return 0;
}

Measured memory_bytes: 256
-- C
local sub = string.sub
local n = io.read('*n', '*l')
local s = io.read('*l')
ss = {}
for i = 1, n do
	ss[i] = sub(s, i, i)
end
local ret = nil
if ss[1] == 'o' then
	ret = {
		{[1] = 1, [2] = 1, [n] = 1},
		{[1] = 1, [2] = 0, [n] = 0},
		{[1] = 0, [2] = 0, [n] = 1},
		{[1] = 0, [2] = 1, [n] = 0},
	}
else
	ret = {
		{[1] = 1, [2] = 1, [n] = 0},
		{[1] = 1, [2] = 0, [n] = 1},
		{[1] = 0, [2] = 0, [n] = 0},
		{[1] = 0, [2] = 1, [n] = 1},
	}
end
for i = 2, n-2 do
	for j = 1, 4 do
		local ans = ret[j]
		if ss[i] == 'o' then
			if ans[i] == 1 then
				ans[i + 1] = ans[i - 1]
			else
				ans[i + 1] = 1 - ans[i - 1]
			end
		else
			if ans[i] == 1 then
				ans[i + 1] = 1 - ans[i - 1]
			else
				ans[i + 1] = ans[i - 1]
			end
		end
	end
end

local function isOK(a, b, c, ch)
	if ch == "o" then
		if b == 1 then
			return a == c
		else
			return a ~= c
		end
	else
		if b == 1 then
			return a ~= c
		else
			return a == c
		end
	end
end

local sum = 0
local result = nil
for j = 1, 4 do
	local ans = ret[j]
	if isOK(ans[n-2], ans[n-1], ans[n], ss[n-1]) and isOK(ans[n-1], ans[n], ans[1], ss[n]) then
		sum = sum  + 1
		result = ans
		break
	end
end

if sum == 1 then
	for i = 1, n do
		result[i] = result[i] == 1 and "S" or "W"
	end
	print(table.concat(result))
else
	print(-1)
end

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

int main(){
    map<char,int> alp;
    char hoge;
    while(cin >> hoge){
        alp[hoge]++;
    }
    bool flag = true;
    for(auto& e:alp){
        if(e.second%2 != 0){
            flag = false;
            break;
        }
    }
    cout << (flag ? "Yes" : "No") << endl;
}

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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int H, W, K;
char S[333][333];
int A[333][333];

int cnt;
void rec(int y0, int x0, int y1, int x1, pair<int, int> *p, int n) {
    if (n == 1) {
	assert(x0 < x1);
	cnt++;
	for (int i=y0; i<y1; i++) {
	    for (int j=x0; j<x1; j++) {
		A[i][j] = cnt;
	    }
	}
    } else {
	int m = 0;
	if (p[0].first != p[n-1].first) {
	    while (p[0].first == p[m].first) m++;
	    rec(y0, x0, p[m].first, x1, p, m);
	    rec(p[m].first, x0, y1, x1, p+m, n-m);
	} else {
	    rec(y0, x0, y1, p[1].second, p, 1);
	    rec(y0, p[1].second, y1, x1, p+1, n-1);
	}
    }
}

void MAIN() {
    scanf("%d%d%d", &H, &W, &K);
    REP (i, H) scanf("%s", S[i]);

    vector<pair<int, int> > X;
    REP (i, H) REP (j, W) {
	if (S[i][j] == '#') X.emplace_back(i, j);
    }

    rec(0, 0, H, W, X.data(), K);

    REP (i, H) rprintf("%d", A[i], A[i] + W);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    string s;cin>>s;
    if(s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,n;
    cin>>k>>n;
    int a[n+5];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int ans=-1;
    for(int i=0;i<n-1;i++)
    ans=max(ans,a[i+1]-a[i]);
    ans=max(ans,k-a[n-1]+a[0]);
    cout<<k-ans;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.regex.Pattern;

/**
 * @author yousack
 */
public class Main {
    static Scanner in = new Scanner(System.in);
    static int[][] field;
        
    public static void main(String[] args) {
        while (true) {
            int W = in.nextInt();
            int H = in.nextInt();

            if (W == 0 && H == 0) {
                break;
            } else {
                field = new int[H][W];

                for (int i = 0; i < H; i++) {
                    for (int j = 0; j < W; j++) {
                        field[i][j] = in.nextInt();
                    }
                }

                int counter = 0;
                for (int i = 0; i < H; i++) {
                    for (int j = 0; j < W; j++) {
                        if (field[i][j] == 1) {
                            bfs(field, i, j);
                            counter++;
                        }
                    }
                }

                System.out.println(counter);
            }
        }
    }
    
    public static void bfs(int[][] f, int r, int c) {
        Queue<int[]> queue = new LinkedList<int[]>();
        queue.add(new int[]{r, c});
        int[][] dirArray = new int[][]{
                {-1, 0}, {0, 1}, {1, 0}, {0, -1},
                {1, 1}, {1, -1}, {-1, -1}, {-1, 1}
        };
        
        while (!queue.isEmpty()) {
            int[] curPos = queue.poll();
            int curR = curPos[0], curC = curPos[1];
            if (f[curR][curC] == 1) {
                f[curR][curC] = 0;
                for (int[] next : dirArray) {
                    if (ok(curR + next[0], curC + next[1], f.length, f[0].length)) {
                        queue.add(new int[]{curR + next[0], curC + next[1]});
                    }
                }
            }
        }
    }
    
    public static boolean ok(int posR, int posC, int boundR, int boundC) {
        return 0 <= posR && posR < boundR && 0 <= posC && posC < boundC;         
    }
}

Measured memory_bytes: 44612
// Best practice

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define in(x) 		scanf("%d", &x)
#define echo(x)		printf("%d", x)
#define inf 		(int)(1e18)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;

#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}

// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };


// Code from Here -------------------------------------------------------------------------------


signed main() {
	tezz


	int n,k;
	cin >> n >> k;
	vi arr(n);
	for(int i=0; i<n; i++){
		cin >> arr[i];
	}
	int c=0;
	sort(all(arr));
	for(int i=0; i<k; i++){
		c+=arr[i];
	}
	cout << c;

	return 0;
}  


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define PI (acos(-1))
#define _GLIBCXX_DEBUG

int main(){
  
  int _, d2;
  cin >> _ >> _ >> _ >> d2;
  if(d2 == 1)
    cout << 1 << endl;
  else
    cout << 0 << endl;

}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(1,N - 1):
  if A[i - 1] < A[i] and A[i] < A[i + 1]:
    ans += 1
  elif A[i - 1] > A[i] and A[i] > A[i + 1]:
    ans += 1
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
	ll n; cin>>n;
	int a=0,b=0,c=0,d=0; string s;
	while(n--) {
		cin>>s;
		if(s=="AC") a++;
		else if(s=="WA")b++;
		else if(s=="TLE") c++;
		else d++;
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<b<<endl;
	cout<<"TLE x "<<c<<endl;
	cout<<"RE x "<<d<<endl;

}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using ll = long long;
#define AC ios::sync_with_stdio(0),cin.tie(0);

int main()
{
    AC
    int n;
    cin>>n;
    set<int> s;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            for(int k=1;k<=n;k++)
                s.insert(i*100+j*10+k);
    cout<<s.size()<<'\n';
}

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

using namespace std;

int main() {
  int Q;
  cin >> Q;
  vector<long long> ans(Q);
  for (int i = 0; i < Q; i++) {
    long long a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    if (a == b or a + 1 == b) {
      ans[i] = (a - 1) * 2;
    } else {
      long long l = 0, r = 1e9 + 5;
      while (r - l > 1) {
        auto c = (l + r) / 2;
        if (c * c < a * b) {
          l = c;
        } else {
          r = c;
        }
      }
      if (l * (l + 1) < a * b) {
        ans[i] = l * 2 - 1;
      } else {
        ans[i] = l * 2 - 2;
      }
    }
  }
  for (auto a : ans) {
    cout << a << endl;
  }

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int a = sc.nextInt();
		String op = sc.next();
		int b = sc.nextInt();
      
        int ans = 0;
        if (op.equals("+")) {
          ans = a + b;
        } else {
          ans = a - b;
        }
    
		// 出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 23892
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();

    let N = buf.trim().parse::<u32>().unwrap();
    let NN = buf.trim().parse::<f32>().unwrap();
    let ans = match N % 2 == 1 {
        true => (NN / 2.0 + 0.5) / NN,
        false => 0.5,
    };

    println!("{}", ans);
}


Measured memory_bytes: 2176
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
#define pb(x) push_back(x)
#define rep(i,a,n) for(int i=a; i<n; i++)
typedef long long ll;
typedef unsigned long long ull;
const int mod=1e9+7;
const double eps=1e-6;
const int INF=0x3f3f3f3f;
const int N=1e4+5;
int main()
{
    int n,m,k;
    while(~scanf("%d%d%d",&n,&m,&k))
    printf("%d\n",min(k,n*m));
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys
import copy


def partition(array, start, end):
    x = int(array[end][2:])
    i = start - 1
    assert start <= end
    for j in range(start, end):
        if int(array[j][2:]) <= x:
            i += 1
            array[i], array[j] = array[j], array[i]
    array[i + 1], array[end] = array[end], array[i + 1]
    return i + 1


def quick_sort(array, start, end):
    if start < end:
        cursor = partition(array, start, end)
        quick_sort(array, start, cursor - 1)
        quick_sort(array, cursor + 1, end)
    return array


def merge(A, left, mid, right):
    L = A[left:mid] + ['N ' + str(int(1e9 + 1))]
    R = A[mid:right] + ['N ' + str(int(1e9 + 1))]

    i, j = 0, 0

    for k in range(left, right):
        if int(L[i][2:]) <= int(R[j][2:]):
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

    return None


def merge_sort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)
    return A


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(lambda x: x.strip('\n'), _input[1:]))
    assert len(array) == array_length

    merge_array = copy.deepcopy(array)

    # print('merge',merge_array)
    merge_result = merge_sort(A=merge_array, left=0, right=array_length)
    # print(*merge_result, sep='\n')

    # print('quick',array)
    quick_result = quick_sort(array=array, start=0, end=array_length - 1)
    if quick_result != merge_result:
        print('Not stable')
    else:
        print('Stable')
    print(*quick_result, sep='\n')

Measured memory_bytes: 23876
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n=5;int ar[6];
  for(int i=0;i<n;i++)
  {
      cin>>ar[i];
  }
  for(int i=0;i<n;i++)
  {
      if(ar[0]==0){cout<<ar[1]-1<<endl;return 0;}
     else if(ar[i]==0){cout<<ar[i-1]+1<<endl;return 0;}
  }


}


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



struct Si{
    int a[6];
    void move(char c) {
    int b;
     if (c=='N'){
         b=a[0];
         a[0]=a[1];
         a[1]=a[5];
         a[5]=a[4];
         a[4]=b;
      }
      if (c=='E'){
         b=a[0];
         a[0]=a[3];
         a[3]=a[5];
         a[5]=a[2];
         a[2]=b;
      }
      if(c=='S'){
         b=a[0];
         a[0]=a[4];
         a[4]=a[5];
         a[5]=a[1];
         a[1]=b;
      }
      if(c=='W'){
         b=a[0];
         a[0]=a[2];
         a[2]=a[5];
         a[5]=a[3];
         a[3]=b;
      }
    }
int up(){return a[0];}
};
int main()
{  Si r;
    int d[6];
     for (int i=0;i<6;i++){
         cin>>r.a[i];
     }
     string k;
     cin>>k;
     for (int i=0;i<k.size();i++){
         r.move(k[i]);
     }
     cout <<r.up()<<endl;
    return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

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

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  vector< int > tap;
  for(int i = 0; i < N; i++) {
    if(S[i] == 'o') {
      if(tap.size() && i - tap.back() <= C) continue;
      tap.emplace_back(i);
    }
  }
  vector< int > ris;
  reverse(begin(S), end(S));
  for(int i = 0; i < N; i++) {
    if(S[i] == 'o') {
      if(ris.size() && i - ris.back() <= C) continue;
      ris.emplace_back(i);
    }
  }
  reverse(begin(ris), end(ris));
  for(auto &p : ris) p = N - p - 1;
  if(tap.size() > K) {
    return 0;
  }
  for(int i = 0; i < tap.size(); i++) {
    if(tap[i] == ris[i]) {
      cout << tap[i] + 1 << "\n";
    }
  }
}




Measured memory_bytes: 3468
require "prime"

class Integer
  def divisors
    prime_division.inject([1]) do |ary, (p, e)|
      (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
    end.sort
  end
  def kawara_wari(k); t=self; while t % k == 0 do t/=k end; t end 
end

n = gets.to_s.to_i

ans = (n-1).divisors.size - 1

n.divisors.each do |k|
  next if k == 1
  ans += 1 if n.kawara_wari(k) % k == 1
end

puts ans

Measured memory_bytes: 2552
C = [list(map(int, input().split())) for i in range(3)]

for a1 in range(0, 101):
    b1 = C[0][0] - a1
    b2 = C[0][1] - a1
    b3 = C[0][2] - a1
    if b1 < 0 or b2 < 0 or b3 < 0:
        continue
    a2 = C[1][0] - b1
    if a2 < 0 or C[1][1] - b2 != C[1][2] - b3 or C[1][1] - b2 != a2:
        continue
    a3 = C[2][0] - b1
    if a3 < 0 or a3 != C[2][1]- b2 or a3 != C[2][2] - b3:
        continue
    print ("Yes")
    exit()
print ("No") 

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

int main(){
    int n,q;
    cin >> n >>q;
    vector<vector<int>> G(n);
    vector<int> sr(n,0);
    for(int i=1;i<n;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    rep(i,q){
        int p,x;
        cin>>p>>x;
        sr[p-1]+=x;
    }
    vector<int> used(n,0);
    used[0]=1;
    queue<int> que;
    que.emplace(0);
    while(!que.empty()){
        int v=que.front();que.pop();
        for(int u:G[v]){
            if(used[u]) continue;
            sr[u]+=sr[v];
            used[u]=1;
            que.emplace(u);
        }
    }

    rep(i,n) cout<<sr[i]<<" ";
    cout<<endl;
    return 0;
}

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

using namespace std;

void test()
{
   int n;
   cin>>n;

   int res=0;

   for(int i=1;i<=n;i++)
   {
       int r=i;
       vector<char>vec;

       while(r)
       {
           vec.push_back((char)(48+r%10));
           r/=10;
       }

       if(vec.size()%2)
        res++;
   }

   cout<<res<<"\n";

}

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

    test();

    return 0;
}


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

int main()
{
    int a, b, c, d; cin >> a >> b >> c >> d;

    vector<int> v(200);

    for(int i = a; i < b; i++) v[i]++;
    for(int i = c; i < d; i++) v[i]++;

    int ans = 0;

    for(int i = 0; i < 200; i++) ans += v[i] == 2;

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

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> vec(n);
  for(int i=0;i<n;i++)
    cin >> vec.at(i);
  sort(vec.begin(),vec.end());
  int sum = 0;
  for(int i=0;i<k;i++){
    sum += vec.at(i);
  }
  cout << sum;
}

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

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

Measured memory_bytes: 256
nk = list(map(int,input().split()))
n = nk[0]
k = nk[1]
a = list(map(int,input().split()))
counter = k
town = 1
seen = {
    1:0
}
cycle_p = 1
while True:
    town = a[town-1]
    counter-=1
    if counter == 0:
        break
    if town not in seen:
        seen[town]=cycle_p
        cycle_p+=1
    else:
        cycle_length = cycle_p-seen[town]
        remainder = (counter) % cycle_length
        while True:
            if remainder == 0:
                break
            town = a[town-1]
            remainder-=1
        break
print(town)


Measured memory_bytes: 32348
#include <cstdio>
#include <map>

int main()
{
  long long n, k;
  scanf("%lld%lld", &n, &k);
  std::map<long long, long long> m;
  for (int i = 0; i < n; ++i)
  {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    m[a] += b;
  }
  
  long long count = 0;
  for (auto &p : m)
  {
    count += p.second;
    if (count >= k)
    {
      printf("%lld\n", p.first);
      return 0;
    }
  }
}

Measured memory_bytes: 4224
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

// O(N log log N)
/// --- primes {{{ ///
#include <vector>
vector< int > primes(int n) {
  vector< int > res;
  for(int i = 2; i <= n; ++i) {
    bool isp = 1;
    for(int p : res) {
      if((ll) p * p > i) break;
      if(i % p == 0) {
        isp = 0;
        break;
      }
    }
    if(isp) res.emplace_back(i);
  }
  return res;
}
/// }}}--- ///

// O(N^.5)
/// --- primeFactors {{{ ///
#include <map>
map< ll, int > primeFactors(ll n) {
  map< ll, int > res;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) n /= i, res[i]++;
  }
  if(n != 1) res[n] = 1;
  return res;
}
/// }}}--- ///

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  vector<ll> a(n + 1);
  int g = 0;
  for(int i = n; i >= 0; i--) cin >> a[i], g = __gcd<ll>(g, a[i]);

  auto pf = primeFactors(abs(g));
  vector<int> ans;
  for(auto p : pf) ans.push_back(p.first);

  auto ps = primes(n);

  for(auto p : ps) {
    auto b = a;
    for(int i = n; i >= p; i--) (b[i - p + 1] += b[i]) %= p; /////

    bool ok = 1;
    for(int i = p - 1; i >= 0; i--) ok &= b[i] % p == 0;
    if(ok) ans.push_back(p);
  }

  sort(begin(ans), end(ans));
  ans.erase(unique(begin(ans), end(ans)), ans.end());
  for(auto e : ans) cout << e << "\n";

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        int a; cin>>a;
        v[a-1]++;
    }
    sort(v.begin(),v.end());
    cout<<n-accumulate(v.end()-k,v.end(),0)<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>>
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("explicit.in","r",stdin);freopen("explicit.out","w",stdout)
#define pll pair <lli,lli>
#define vll vector <lli>
#define vpll vector <pll>
#define f first
#define s second
#define pb push_back
#define priq priority_queue
#define unm unordered_map
#define pf push_front
#define minii LLONG_MAX
#define all(x) x.begin(), x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define ld double
#define eb emplace_back
const long double pi = 3.1415926535898;
const lli mod=1e9+7;
//const lli mod=100000000;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
bool prime (lli k)
{
    if (k==1||k==0) return 0;
    bool flag=1;
    lli a=sqrt(k);
    for (int i=2;i<=a;i++)
    {
        if (k%i==0)
        {flag=0;break;}
    }
    return flag;
}
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    for (int i=2;i*i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=2*i;j<=n;j+=i)
            {qrr[j]=0;}
        }
    }
    return 0;
}

int main()
{
    fio;
    lli n;
    cin>>n;
    lli a[n];
    lli x=0;
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
        x^=a[i];
    }
    for (int i=0;i<n;i++)
    {
        cout<<(x^a[i])<<" ";
    }
    return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

vii graph;
vi dp;
/*FUNCs=================================================*/
int PassLength(int u) {
    if(dp[u]!=-1) return dp[u];
    int ret = 0;
    for(auto v : graph[u]) {
        chmax(ret, PassLength(v) + 1);
    }
    dp[u] = ret;
    return ret;
}

/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n,m, x,y; cin >> n >> m;
    graph.resize(n+1);
    dp.resize(n+1, -1);
    rep(i,m) {
        cin >> x >> y;
        graph[0].emplace_back(x);
        graph[x].emplace_back(y);
    }
    int ans = PassLength(0);
    cout << ans - 1 << '\n';
}

Measured memory_bytes: 9080