akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
    int k;
    string s;
    cin >> k;
    cin >> s;
    if(s.size() <= k){
        cout << s << endl;
    }
    else{
        for(int i = 0;i < k;i++){
            cout << s[i];
        }
        cout << "..." <<endl;
    }


    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#define MAX_N 1010

typedef struct _Elm {
  char name[11];
  int time;
} Elm;

Elm que[MAX_N];

int main() {
  int n, q, i, cnt, time, t;
  scanf("%d %d", &n, &q);
  for(i = 0; i < n; ++i) {
    scanf(" %s %d", que[i].name, &(que[i].time));
  }

  for(i = 0, cnt = 0, time = 0; cnt < n; i = (i+1)%n) {
    if(que[i].time <= 0) continue;
    t = q < que[i].time ? q : que[i].time;
    que[i].time -= t;
    time += t;
    if(que[i].time <= 0) {
      printf("%s %d\n", que[i].name, time);
      ++cnt;
    }
  }
  return 0;
}

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

using  namespace std;

int main(){
    int N,ans;
    cin >> N;
    vector<int> D(N);

    for(int i=0;i<N;i++){
        cin >> D[i];
    }
    sort(D.begin(), D.end());
    int harfPoint = N/2;
    ans = D[harfPoint]-D[harfPoint-1];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

using pii = pair<int, int>;

int used[100010];

void bfs(pii p, map<pii, int> &mp, vector<vector<int>> const &G) {
    queue<pii> que;
    que.push(p);
    used[p.first] = 1;
    while(!que.empty()) {
        pii v = que.front();
        que.pop();
        int now2 = 0;
        for(int nv : G[v.first]) {
            if(used[nv] == 1)
                continue;
            now2++;
            if(now2 == v.second)
                now2++;
            used[nv] = 1;
            mp[MP(v.first, nv)] = now2;
            mp[MP(nv, v.first)] = now2;
            que.push(MP(nv, now2));
        }
    }
}

int main() {
    int N;
    cin >> N;
    vector<vector<int>> G(N, vector<int>());
    vector<int> a(N), b(N);
    vector<pii> edges(N);
    rep(i, N - 1) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        edges[i] = MP(a[i], b[i]);
    }
    rep(i, N - 1) {
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    map<pii, int> mp;
    bfs(MP(a[0], -1), mp, G);
    int color = 0;
    for(pair<pii, int> p : mp) {
        color = max(color, p.second);
    }
    cout << color << endl;
    rep(i, N - 1) { cout << mp[edges[i]] << endl; }
    return 0;
}

Measured memory_bytes: 20480
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; i++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	int A, B; cin >> A >> B;
	string S; cin >> S;

	if (S[A] != '-') {
		cout << "No" << endl; return 0;
	}
	if (S.length() != A + B + 1) {
		cout << "No" << endl; return 0;
	}
	for (int i = 0; i < S.length(); i++) {
		if (i != A && S[i] == '-') {
				cout << "No" << endl;
				return 0;
		}
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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; }

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int a[20];
int b[20];
int main(){
    int n, m, c;
    int ans = 0;
    cin >> n >> m >> c;
    rep(i, m) cin >> b[i];
    rep(i, n){
        rep(j, m){
            cin >> a[j];
        }
        int tmp =0;
        rep(j, m){
            tmp += a[j]* b[j];
        }
        if(tmp + c> 0) ans++;
    }

    cout << ans << endl;
}



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

#define ll long long
// #define endl '\n'

void max_self(int &a, int b){ a = max(a, b);}
void min_self(int &a, int b){ a = min(a, b);}

void solve(){
	ll n, d; cin>>n>>d;
	int cnt = 0;
	d = d * d;
	for(int i = 0; i<n; i++){
		ll x, y; cin>>x>>y;
		if((x * x + y * y) <= d) cnt++;
	}
	cout<<cnt<<endl;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;// cin>>t;
	for(int i = 1; i<=t; i++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3648
// ABC093_B
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    ll A, B, K;
    cin >> A >> B >> K;
    
    // calculation
    for (ll i = A; i <= B; ++i) {
        if (i <= A+K-1 || B-K+1 <= i) {
            cout << i << "\n";
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)
#define P pair<ll,ll>
int  u[200];
ll mod = 1000000007;
P p[200005];
ll i, b, c, k,j, n, m, z = 0,mi=10;
//char s[100005];
string s[3] = { "Sunny","Cloudy","Rainy" };
string ss;

vector<ll> v;
int main() {
cin >> ss;
rep(i, 3) {

	if (ss == s[i])cout << s[(i + 1) % 3];

}


//cout << z;

 return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int A; cin >> A;
	print(A + A*A + A*A*A);
}

Measured memory_bytes: 3600
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{

    static void Main(string[] args)
    {

        long[] inp = null;
        inp = Console.ReadLine().Split(' ').Select(k => long.Parse(k)).ToArray();
        long n, m;
        n = inp[0]; m = inp[1];


        var ketas = new List<long>();
        var nums = new List<long>();

        for (int i = 0; i < m; i++)
        {
            inp = Console.ReadLine().Split(' ').Select(k => long.Parse(k)).ToArray();

            ketas.Add(inp[0]);
            nums.Add(inp[1]);
        }


        var str = new List<string>();
        var flg = new List<bool>();
        for (int i = 0; i < n; i++)
        {
            str.Add("0");
            flg.Add(false);
        }


        bool failure = false;
        for (int i = 0; i < m; i++)
        {
            int k = (int)ketas[i] - 1;
            var tmp = long.Parse(str[k]);

            if (flg[k] && nums[i] != tmp)
            {
                failure = true;
            }
            else if (!flg[k])
            {
                str[k] = nums[i].ToString();
                flg[k] = true;
            }
        }


        if (str[0] == "0" && str.Count > 1 && !flg[0])
        {
            str[0] = "1";
        }
        else if(str[0] == "0" && str.Count > 1 && flg[0])
        {
            failure = true;
        }


        long ans = long.Parse(string.Concat(str));
        if (failure) ans = -1;


        Console.WriteLine(ans);

    }
}


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

int A[20000];

bool linSearch(int key,int n)
{
	int i = 0;
	A[n] = key;
	while(A[i]!=key) i++;
	return i!=n;
}

int main()
{
	int cnt = 0;
	int n,q,a;
	cin >> n;
	for(int i = 0; i<n;i++)
		cin >> A[i];
	
	cin >> q;
	for(int i = 0; i<q;i++)
		{
		cin >> a;
		if(linSearch(a,n))
			cnt++;
		}
	cout <<cnt<<endl;
}

Measured memory_bytes: 3116
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt(), n = sc.nextInt();
        int[] num = new int[w];
        for (int i=0; i<w; i++) num[i] = i+1;

        int a, b, tmp;
        String s;
        for (int i=0; i<n; i++) {
            s = sc.next();
            a = Integer.parseInt(s.split(",")[0]) - 1;
            b = Integer.parseInt(s.split(",")[1]) - 1;
            tmp = num[a];
            num[a] = num[b];
            num[b] = tmp;
        }

        for (int i : num) System.out.println(i);
    }
}

Measured memory_bytes: 26152
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9 + 7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4] ={ 1,0,-1,0 };
int dy[4] ={ 0,1,0,-1 };

int N;

signed main() {
	cin >> N;
	if(N % 2 == 0){
		cout << 0.5 << endl;
	}
	else{
		cout << setprecision(32) << (double)(N/2+1) / N << endl;
	}
}

Measured memory_bytes: 256
#ifdef Rahul
# include "RAHUL.h"
#else
# include <bits/stdc++.h>
  using namespace std;
# define error(...) 42;
#endif
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
const int MOD = (int) 1e9 + 7;
const i64 INF = (i64) 1e18 + 42;

int main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  const int N = 365, K = 26;
  vector<int> c(K);
  vector<vector<int>> s(N, vector<int>(K));
  cin >> c[0];
  for (int &x : c) cin >> x;
  for (auto &v : s) for (int &x : v) cin >> x;
  vector<int> best(N);
  int bs = -MOD;
  for (int f = 0; f < 26; ++f) {
    for (int f2 = 0; f2 < 26; ++f2) {
      for (int f3 = 0; f3 < 26; ++f3) {
        vector<int> ans(N);
        vector<int> last(K, -1);
        int score = (int) 1e6;
        for (int i = 0; i < N; ++i) {
          int dec = 0;
          for (int j = 0; j < K; ++j) {
            dec += c[j] * (i - last[j]);
          }
          int mx = -MOD, t = -1;
          if (i == 0) {
            t = f;
          } else if (i == 1) {
            t = f2;
          } else if (i == 2) {
            t = f3;
          } else {
            for (int j = 0; j < K; ++j) {
              if (uax(mx, s[i][j] - dec + c[j] * (i - last[j]))) t = j;
            }
          }
          score += s[i][t] - dec + c[t] * (i - last[t]);
          last[t] = i;
          ans[i] = t;
        }
        if (uax(bs, score)) swap(ans, best);
      }
    }
  }
  for (int &x : best) cout << 1 + x << '\n';
}


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

function main()
  n,k = readline() |> split |> parseArray
  a = zeros(Int, n)
  a = readline() |> split |> parseArray

  for _ in 1:min(k, ceil(Int, 50))
    imos = zeros(Int, n+1)
    for i in 1:n
      d = a[i]
      imos[max(i-d, 1)] += 1
      imos[min(i+d+1, n+1)] += -1
    end
    a = zeros(Int, n)
    c = 0
    for i in 1:n
      c = c+imos[i]
      a[i] = c
    end
  end
  println.(a)
end

main()


Measured memory_bytes: 265596
#include<bits/stdc++.h>
using namespace std;
const int maxn=605;
const int maxm=4001;
const int mod=1e9+7;
typedef long long ll;
typedef pair<double,int> pii;
vector<int> edge[maxn];int n,m;
double e[maxn];int s,t;
vector<pii>edge2[maxn];
bool vis[maxn];
bool dfs(int u)
{
	//cout<<u<<endl;
	if(u==t)
	{
		return true;
	}
	if(vis[u]) return e[u];
	vis[u]=1;
	int cnt=0;double tmp=0;
	for(auto v:edge[u])
	{
		if(dfs(v)) cnt++,tmp+=e[v],edge2[u].push_back({e[v],v});
	}
	sort(edge2[u].begin(),edge2[u].end());
	//cout<<u<<"    "<<edge2[u].size()<<endl;
	if(cnt==0) return false;
	e[u]=(tmp/cnt)+1;
	return true;
}
bool dfs2(int u,int i,int j)
{
	if(u==t){return true;}
	if(vis[u]) return e[u];
	vis[u]=1;
	int cnt=0;double tmp=0;
	for(auto v:edge[u])
	{
		if(v==j&&u==i) continue;
		if(dfs2(v,i,j)) cnt++,tmp+=e[v];
	}
	if(cnt==0) return false;
	e[u]=(tmp/cnt)+1;
	return true;
}
int main()
{
	cin>>n>>m;int u,v;s=1,t=n;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		edge[u].push_back(v);
	}
	dfs(s);double ans=e[1];
	for(int i=1;i<=n;i++)
	{
		int sz=edge2[i].size();
		if(sz>=2)
		{
			memset(e,0,sizeof e);memset(vis,0,sizeof vis);
			int u=edge2[i][sz-1].second;
			//cout<<sz<<" "<<i<<"         "<<u<<endl;
			dfs2(1,i,u);
			ans=min(ans,e[1]);
		}
	}
	printf("%.7lf\n",ans);
 } 

Measured memory_bytes: 5248
N=int(input())
V=list(map(int,input().split()))
V.sort()

while len(V) > 1:
    v1=V.pop(0)
    v2=V.pop(0)
    
    v_mean = (v1+v2)/2
    
    V.append(v_mean)
    V.sort()
print(V[0])

Measured memory_bytes: 61764
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main() {
	int n, k;
	cin >> n >> k ;

	vector<int>hei(n);
	rep(i, n)cin >> hei[i];

	int ans = 0;
	rep(i, n) {
		if (hei[i] >= k) {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
N = int(input())
red = sorted([list(map(int,input().split())) for i in range(N)], key=lambda x: x[0])[::-1]
blue = [list(map(int,input().split())) for i in range(N)]
ans = 0
for i in range(N):
    min_ = 10 ** 9 + 7
    ind = -1
    for j in range(N):
        if red[i][0] <= blue[j][0] and red[i][1] <= blue[j][1] and blue[j][1] < min_:
            ind = j
            min_ = blue[j][1]
    if ind != -1:
        blue[ind][0] = -1
        ans += 1
print(ans)

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


int main(){
  int N;
  cin>>N;
  vector<char> c(N);
  for(int i=0;i<N;i++){
    cin>>c[i];
  }

  int left=0;
  int right=N-1;
  int ans=0;
  while(true){
    if(right<left){
      break;
    }
    if(left>=N){
      break;
    }
    if(right<0){
      break;
    }
    while(c[left]=='R'){
      left++;
      if(left==N){
        break;
      }
    }
    while(c[right]=='W'){
      right--;
      if(right<0){
        break;
      }
    }
    if(left==N){
      break;
    }
    if(right<0){
      break;
    }
    if(right<left){
      break;
    }
    c[left]='R';
    c[right]='W';
    ans++;
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 3628
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <complex>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

template<typename T>
void chmax(T& a,const T& b)
{
	a=max(a,b);
}

int main()
{
	for(int c,d,w,x;scanf("%d%d%d%d",&c,&d,&w,&x),c|d|w|x;){
		static int e[30][15],f[30][15];
		rep(i,c) rep(j,d) scanf("%d",&e[j][i]);
		rep(i,c) rep(j,d) scanf("%d",&f[j][i]);
		
		static int dp[31][6][201]; // [日][2回以上ライブを行った回数][疲労]
		memset(dp,-1,sizeof dp);
		
		dp[0][0][0]=0;
		rep(i,d) rep(j,x+1) rep(k,w+1){
			if(dp[i][j][k]==-1) continue;
			rep(l,c){
				chmax(dp[i+1][j][k],dp[i][j][k]);
				chmax(dp[i+1][j][k+f[i][l]],dp[i][j][k]+e[i][l]);
			}
			if(j==x) continue;
			rep(l,c){
				if(e[i][l]==0) continue;
				int esum=e[i][l],fsum=f[i][l];
				repi(r,l+1,c){
					if(e[i][r]==0) break;
					esum+=e[i][r];
					fsum+=f[i][r];
					chmax(dp[i+1][j+1][k+fsum],dp[i][j][k]+esum);
				}
			}
		}
		
		int res=0;
		rep(i,x+1) rep(j,w+1)
			chmax(res,dp[d][i][j]);
		printf("%d\n",res);
	}
	
	return 0;
}

Measured memory_bytes: 1344
#include<iostream>
using namespace std;
int main(){
	int r, c,num,card[110][110],s,m;
	cin >> r >> c;
	for (int i = 0; i < r; i++){
		for (int j = 0; j < c; j++){
			num = 0;
			cin >> num;
			card[i][j] = num;
		}
	}
	for (int i = 0; i < r; i++){
		s = 0;
		for (int j = 0; j < c; j++){
			s += card[i][j];
			cout << card[i][j] << " ";
		}
		card[r][c] = s;
		cout << s << endl;
	}
	s = 0;
	for (int j = 0; j < c; j++){
		m = 0;
		for (int i = 0; i < r; i++){
			m += card[i][j];
		}
		s += m;
		cout << m <<" ";
	}
	cout << s << endl;
	return 0;
}


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

// int func(int x, int y, int n){
//     double sq = sqrt( (x+y)*(x+y) - 4 * (x*x + y*y + x*y - n));
//     if(ceil(sq) != floor(sq) || sq <= 0){
//         return -1;
//     }
//     else{
//         return (-(x + y) + int(sq)) / 2;
//     }
// }

int judge(int x, int y, int z){
    if(x == y && y == z){
        return 1;
    }
    else if(x != y && y != z && z != x){
        return 6;
    }
    else{
        return 3;
    }
}


int main(){

    int N; cin >> N;
    int x, y, z;
    int tmp;
    vector<int> count(N+1);

    for(x=1; x<=100; x++){
        for(y=1; y<=100; y++){
            for(z=1; z<=100; z++){
                tmp = x*x + y*y + z*z + x*y + y*z + z*x;
                if(tmp <= N){
                    count.at(tmp)++;
                }
            }
        }
    }

    for(int i=0; i<N; i++){
        cout << count.at(i+1) << endl;
    }

    return 0;
}


Measured memory_bytes: 3596
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
// #define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()

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

	// vvi A(N, vi());
	map<int,int> A;
	rp(i, N){
		int k; cin>>k;
		rp(j,k){
			int a; cin>>a;
			// A[i].push_back(a);
			A[a]++;
		}
	}

	// for(auto e:A){cout<<e.first<<","<<e.second<<"\n";}cout<<"--\n";///

	int count = 0;
	for(auto e:A){
		if(e.second==N){
			count++;
		}
	}

	ote(count);
}


Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
MOD = 10**9 + 7
result = 0
(n+1).downto(k) do |i|
  if n + 1 == i
    result += 1
    next
  end
  if n == i
    result += n + 1
    next
  end

  max = i * (n + n - i + 1) / 2
  min = i * (i - 1) / 2
  result += (max - min + 1)
end

puts result % MOD

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

int main() {
  int n;
  cin >> n;
  int h = n / 3600;
  int m = n % 3600 / 60;
  int s = n % 60;
  cout << h << ":" << m << ":" << s << endl;
  return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
struct modint {
    ll x;
    modint(ll x = 0) : x((x % MOD + MOD) % MOD) {
    }
    ll value() const {
        return x;
    }
    modint operator-() const {
        return modint(-x);
    }
    modint& operator+=(const modint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    modint& operator-=(const modint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    modint& operator*=(const modint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    modint operator+(const modint a) const {
        modint res(*this);
        return res += a;
    }
    modint operator-(const modint a) const {
        modint res(*this);
        return res -= a;
    }
    modint operator*(const modint a) const {
        modint res(*this);
        return res *= a;
    }
    modint pow(ll t) const {
        if (t == 0) return 1;
        modint a = pow(t >> 1);
        a *= a;
        if (t % 2 == 1) a *= *this;
        return a;
    }
    modint inv() const {
        return pow(MOD - 2);
    }
    modint& operator/=(const modint a) {
        return (*this) *= a.inv();
    }
    modint operator/(const modint a) const {
        modint res(*this);
        return res /= a;
    }
};
int main() {
    int n;
    cin >> n;
    vector<ll> c(n);
    rep(i, n) cin >> c[i];
    sort(all(c), greater<ll>());
    if (n == 1) {
        cout << (modint(c[0]) * 2).value() << endl;
        return 0;
    }
    modint ans = 0;
    rep(i, n) {
        ans += (modint(2).pow(n - 2)) * (i + 2) * c[i];
    }
    ans *= modint(2).pow(n);
    cout << ans.value() << endl;
}


Measured memory_bytes: 1920
N = int(input())
c = 0
cnt = [ [0]*10 for _ in range(10) ]
for i in range(1,N+1):
    a = str(i)
    top = int(a[0])
    end = int(a[-1])
    cnt[top][end] += 1

for i in range(10):
    for j in range(10):
        for k in range(10):
            for l in range(10):
                if i == l and j == k:
                    c += cnt[i][j] * cnt[k][l]
print(c)

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

int main(){
  int N, M, X, A;
  cin >> N >> M >> X;
  int ans0 = 0, ansN = 0;

  for(int i=0;i<M;i++){
    cin >> A;
    if(A<X) ans0++;
    else ansN++;
  }

  cout << min(ans0, ansN) << endl;
  return 0;
}


Measured memory_bytes: 256
import sys, copy, math, heapq, bisect
from itertools import accumulate
from collections import deque, defaultdict, Counter
input = sys.stdin.readline # 文字列の入力のとき'/n'まで受け取るので注意!!!
sys.setrecursionlimit(500000)

S = input()
T = input()
N = len(S)
ds = {}
dt = {}
ss = 0
tt = 0
SS = []
TT = []
for i in range(N):
    if S[i] in ds:
        SS.append(ds[S[i]])
    else:
        ds[S[i]] = ss
        SS.append(ss)
        ss += 1
    if T[i] in dt:
        TT.append(dt[T[i]])
    else:
        dt[T[i]] = tt
        TT.append(tt)
        tt += 1
flag = True
for i in range(N):
    if SS[i]==TT[i]:
        continue
    else:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')
    



Measured memory_bytes: 57596
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL A, B, C;
	in >> A >> B >> C;
	LL can = std::min(C, A + B + 1);
	out << can + B << std::endl;
}


Measured memory_bytes: 256
from collections import deque
s=input()

tmp=deque(['',''])
ans=[-1,-1]
for i,x in enumerate(s):
    if x in tmp:
        ans=[max(i-1,1),i+1]
        break
    else:
        tmp.pop()
        tmp.appendleft(x)
print('{0[0]} {0[1]}'.format(ans))

Measured memory_bytes: 3444
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

H,W=get_i
a=array(H)
H.times do|i|
    a[i]=get_nsp
end

def BFS(map)
    dir_x=[1,0]
    dir_y=[0,1]
    visit=array(W,0,H)
    queue=[]
    queue.push([0,0]) if map[0][0]=="#"
    until queue==[]
        x,y=queue.shift
        visit[y][x]=1
        2.times do|i|
          next_x,next_y=x+dir_x[i],y+dir_y[i]
          next unless next_x.between?(0,W-1) and next_y.between?(0,H-1)
          next if map[next_y][next_x]=="." or visit[next_y][next_x]==1
          queue.push([next_x,next_y])
          break
        end
    end
    return visit
end
flag=true
visit=BFS(a)
H.times do|i|
    W.times do|j|
        if a[i][j]=="#" and visit[i][j]==0
            flag=false
            break
        end
    end
    unless flag
        break
    end
end
puts yn_judge(flag,"Possible","Impossible")

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

int main(){

  int N[4];
  cin >> N[0] >> N[1] >> N[2] >> N[3];
  int time[4]={};

  int M[4] = {1, 9, 7, 4};

  for(int i = 0 ; i < 4 ; ++i){
    for(int j = 0 ; j < 4 ; ++j){
      // cout << N[j] << "\t" << M[i] << endl;
      if(N[j] == M[i]) time[i]++;
    }
    // cout << time[i] << endl;
  }

  if(time[0] == 1 && time[1] == 1 && time[2] == 1 && time[3] == 1) cout << "YES" << endl;
  else cout << "NO" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
using namespace std; 
 


int main() 
{ 
    int n,k;
    cin>>n>>k;
    // n++;
    int a[n+1];
    memset(a,0,sizeof(a));
    pan(i,n){
        int x;
        cin>>x;
        // cout<<x;
        a[x]++;
    }
    int dis=0;
    n++;
    pan(i,n)
        if(a[i]!=0) dis++;
    int ans=n-1;
    vi v;
    pan(i,n){
        if(a[i]!=0) v.pb(a[i]);
    }
    sort(v.begin(),v.end(),greater<int>());
    int s=v.size();
    if(dis <= k) ans=0;
    else{
        for(int i=0;i<k;i++){
            ans-=v[i];
        }
    }
    cout<<ans;
} 


Measured memory_bytes: 2168
#include <stdio.h>

int main()
{
  int x,y;
  scanf("%d%d",&x,&y);
  int i,j;
  i = 0;
  while (i <= x)
  {
    if (i*2 + (x-i)*4 == y)
    {
      printf("Yes");
      return (0);
    }
    i++;
  }
  printf("No");
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
#define ll long long int
using namespace std;

int main() {
	int N; cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++)cin >> a[i];

	int cnt = 1;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (cnt != a[i]) ans++;
		else cnt++;
	}

	if (ans == N) cout << -1 << endl;
	else cout << ans << endl;
}	

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

int main(){
    int N,M;
    int count=0;
    cin >> N >> M;
    if(N == 1){
        cout << M << endl;
    }else{
        for(int i=M/N;i>0;i--){
            if(count!=0){
                break;
            }
            else if(M%i==0 && M/i>=N){
                cout << i << endl;
                count++;
            }
        }
    }
    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 long long INF = 1LL << 60;
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; }

int main(){
    int n;cin>>n;
    vector<int> x(n);
    vector<int> y(n);
    rep(i,n)cin>>x[i]>>y[i];
    vector<int> d ;
    double sum= 0;
    for(int i =0;i<n;i++){
        d.push_back(i);
    }
    double count = 0;

    do{
        count++;
        for(int i = 0;i<d.size()-1;++i){


            sum+=sqrt((x[d[i+1]]-x[d[i]])*(x[d[i+1]]-x[d[i]])+(y[d[i+1]]-y[d[i]])*(y[d[i+1]]-y[d[i]]));
        }

    }while(next_permutation(d.begin(),d.end()));

    double ans = sum/count;
    cout<<setprecision(15)<<ans<<endl;
}

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

Measured memory_bytes: 3632
program main
   character(len=7) :: s(4) = (/"dream  ", "dreamer", "erase  ", "eraser "/)
   character(len=100000) :: b
   integer :: L(4) = (/5, 7, 5, 6/)
   read(*, *) b
   N = len_trim(b)
   a: do while(N > 0)
      do i = 1, 4
         if(N < L(i)) cycle
         if(trim(s(i)) == b(N-L(i)+1:N))then
            N = N - L(i)
            cycle a
         endif
      enddo
      write(*, *)"NO"
      stop
   enddo a
   write(*, *) "YES"
end

Measured memory_bytes: 700
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
string N;
cin >> N;
if (N.at(0) == '7'|| N.at(1) == '7' || N.at(2) == '7') {
    cout << "Yes" << endl;
} else cout << "No" << endl;




return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define sset(s) cout<<#s<<":";each(i,s)cout <<" "<<i;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int main()
{
    while(1){
        int n,q;
        cin >> n >> q;
        if(n == 0){
            break;
        }
        vector<int> vec(101);
        rep(i,n){
            int m;
            cin >> m;
            rep(j,m){
                int a;
                cin >> a;
                vec[a]++;
            }
        }
        bool flag = false;
        int mx = 0;
        int ans = -1;
        rep(i,101){
            if(vec[i] > max(mx,q-1)){
                ans = i;
                mx = vec[i];
            }
        }
        if(ans >= 0){
            cout << ans << "\n";
        }else{
            cout << "0\n";
        }
    }
}

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

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

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define REP(i,n) for(int i=0;i<n;i++)
#define pb push_back


// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

int main(void) {
	// cin, coutの結びつきを解除し、速くする
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int n; cin >> n;
	vi vs;
	REP(i, n) {
		int a; cin >> a;
		vs.pb(a);
	}

	sort(vs.begin(), vs.end());
	int ans;
	int& max = vs.back();
	ans = max - vs.at(0);
	cout << ans << endl;


}



Measured memory_bytes: 256
function listsGetSortCompare(type, direction) {
  var compareFuncs = {
    "NUMERIC": function(a, b) {
        return parseFloat(a) - parseFloat(b); },
    "TEXT": function(a, b) {
        return a.toString() > b.toString() ? 1 : -1; },
    "IGNORE_CASE": function(a, b) {
        return a.toString().toLowerCase() > b.toString().toLowerCase() ? 1 : -1; },
  };
  var compare = compareFuncs[type];
  return function(a, b) { return compare(a, b) * direction; }
}

function main(input) {
  var args = input.split(' ');
  sorted = args.slice().sort(listsGetSortCompare("NUMERIC", -1));
  result = 0;
  var i_end = sorted.length - 1;
  var i_inc = 1;
  if (1 > i_end) {
    i_inc = -i_inc;
  }
  for (i = 1; i_inc >= 0 ? i <= i_end : i >= i_end; i += i_inc) {
    cur = sorted[(i - 1)];
    next = sorted[((i + 1) - 1)];
    result = result + Math.abs(cur - next);
  }
  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 9420
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<int Mod> class ModInt {
  int v;
public:
  constexpr ModInt(const long long x = 0) noexcept : v((x % Mod + Mod) % Mod) {};
  constexpr ModInt &operator+=(const ModInt rhs) noexcept {
    v += rhs.v;
    if (v >= Mod)
      v -= Mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) noexcept {
    if (v < rhs.v)
      v += Mod;
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) noexcept {
    v = int(1LL * v * rhs.v % Mod);
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) noexcept {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1)
        *this *= rhs;
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  constexpr ModInt operator-() const noexcept { return ModInt(-v); }
  constexpr ModInt operator+(const ModInt rhs) const noexcept {
    return ModInt(*this) += rhs;
  }
  constexpr ModInt operator-(const ModInt rhs) const noexcept {
    return ModInt(*this) -= rhs;
  }
  constexpr ModInt operator*(const ModInt rhs) const noexcept {
    return ModInt(*this) *= rhs;
  }
  constexpr ModInt operator/(const ModInt rhs) const noexcept {
    return ModInt(*this) /= rhs;
  }
  constexpr bool operator==(const ModInt rhs) const noexcept {
    return v == rhs.v;
  }
  constexpr bool operator!=(const ModInt rhs) const noexcept {
    return v != rhs.v;
  }
  constexpr ModInt pow(long long exp) const noexcept {
    ModInt res(1), mul(v);
    while (exp) {
      if (exp & 1)
        res *= mul;
      mul *= mul;
      exp >>= 1;
    }
    return res;
  }
  friend ostream &operator<<(ostream &os, const ModInt obj) noexcept {
    return os << obj.v;
  }
  friend istream &operator>>(istream &is, ModInt &obj) noexcept {
    long long tmp;
    is >> tmp;
    obj = ModInt<Mod>(tmp);
    return is;
  }
};
constexpr int MOD = 1000000007;
using mint = ModInt<MOD>;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<mint> res(k);
  for (int i = k; i > 0; i--) {
    res[i-1] = mint(k/i).pow(n);
    for (int j = i*2; j <= k; j += i)
      res[i-1] -= res[j-1];
  }
  mint ans = 0;
  rep(i, k)
    ans += res[i]*(i+1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3692
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			while (true) {
				int a = sc.nextInt();
				String OP = sc.next();
				char op = OP.charAt(0);
				int b = sc.nextInt();

				if (op == '?') break;

				int ans = 0;

				switch (op) {
					case '+':
						ans = a+b;
						break;

					case '-':
						ans = a-b;
						break;
						
					case '*':
						ans = a*b;
						break;
						
					case '/':
						ans = (int) Math.floor(a/b);
						break;
				}
				System.out.println(ans);
			}
		}
	}

}


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

int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	string s;
	cin >> s;
	long long k;
	cin >> k;
	int n = (int)s.size();
	if (s == string(n, s[0])) {
		cout << n * k / 2 << '\n';
	}
	else {
		int ans1 = 0;
		for (int i = 0; i + 1 < n; i++) {
			if (s[i % n] == s[(i + 1) % n]) {
				++ans1;
				++i;
			}
		}
		int ans2 = 0;
		for (int i = 0; i + 1 < 2 * n; i++) {
			if (s[i % n] == s[(i + 1) % n]) {
				++ans2;
				++i;
			}
		}
		cout << ans1 + (ans2 - ans1) * (k - 1) << '\n';
	}
	return 0;
}

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

using namespace std;
int main()
{
    string g;
    cin >> g;
    int n;
    cin >> n;
    for(int w=0;w<g.size();w+=n)
    {
        cout << g[w];
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n, m = map(int, input().split())
edge = defaultdict(list)
for i in range(m):
    a,b = map(int, input().split())
    edge[a].append(b)

dp = [0]*(n+1)
for i in range(1,n+1):
    dp[i] = max(dp[i],dp[i-1])
    for j in edge[i]:
        dp[j] = max(dp[j], dp[i]+1)
#print(dp)
print(dp[n])

Measured memory_bytes: 27744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;
typedef map<string, int> msi;
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //int t;
    //cin>>t;
    //while(t--)
    //while(!cin.eof())
    {
        int x;
        cin>>x;
        for(long long i=360;;i+=360){
            if(i%x==0){
                cout<<i/x<<endl;
                break;
            }
        }
    }
    return 0;
}
/*

*/


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

int main() {
    int n;
    cin >> n;
    string yomi[10] = {"pon", "pon", "hon", "bon", "hon", "hon", "pon", "hon", "pon", "hon"};
    cout << yomi[n%10] << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <string>

using namespace std; 
int main(){
    int n;
    cin >> n;
    int a;
    int min=0, max=0;
    long int sum=0;
    for(int i=0;i<n;i++){
        cin >>a;
        if(a<min || i == 0) min = a;
        if(a>max || i == 0) max = a;
        sum += a;
    }
    cout << min << " " << max <<" " << sum << endl;
    return 0;
}


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

const int mod = 1e9 + 7;
const int MN = 1010;

int N, R;
vector<int> adj[MN];
int dist[MN], par[MN], del[MN];

void dfs(int u, int p) {
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(v == p) continue;
        if(del[v]) continue;
        dist[v] = dist[u] + 1;
        par[v] = u;
        dfs(v, u);
    }
}

int cc[MN][MN][2];
int dp(int u, int a, int t) {
    int &ret = cc[u][a][t];
    if(ret != -1) return ret;
    if(adj[u].size() == 1 && adj[u][0] == par[u]) return ret = a <= R - dist[u] + t;

    ret = 1;
    for(int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];
        if(v == par[u]) continue;
        if(del[v]) continue;

        int tmp = dp(v, a, t);
        if(a) {
            tmp += dp(v, a - 1, t);
            tmp %= mod;
        }
        ret = 1LL * ret * tmp % mod;
    }
    return ret;
}

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N - 1; i++) {
        int u, v; scanf("%d %d", &u, &v);
        u--; v--;

        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    dfs(0, -1);
    int p = 0;
    for(int i = 1; i < N; i++) if(dist[p] < dist[i]) p = i;
    dist[p] = 0;
    dfs(p, -1);
    p = 0;
    for(int i = 1; i < N; i++) if(dist[p] < dist[i]) p = i;

    memset(cc, -1, sizeof(cc));

    if(dist[p] % 2) {
        R = dist[p] / 2;
        for(int i = 0; i < R; i++) p = par[p];
        int q = par[p];
        del[p] = 1;
        del[q] = 1;

        memset(par, -1, sizeof(par));
        dist[p] = 0;
        dist[q] = 0;
        dfs(p, -1);
        dfs(q, -1);

        int ans = 0;
        for(int i = 0; i <= R; i++) {
            ans += 1LL * dp(p, i, 1) * dp(q, i, 0) % mod;
            ans %= mod;
            if(i) {
                ans += 1LL * dp(p, i - 1, 0) * dp(q, i, 1) % mod;
                ans %= mod;
            }
            if(i != R) {
                ans += mod - 1LL * dp(p, i, 0) * dp(q, i + 1, 0) % mod;
                ans %= mod;
                ans += mod - 1LL * dp(p, i, 0) * dp(q, i, 0) % mod;
                ans %= mod;
            }
        }
        ans *= 2;
        ans %= mod;
        printf("%d", ans);
    }
    else {
        R = (dist[p] + 1) / 2;
        for(int i = 0; i < R; i++) p = par[p];

        memset(par, -1, sizeof(par));
        dist[p] = 0;
        dfs(p, -1);

        int ans = 0;
        for(int i = 0; i <= R; i++) {
            ans += dp(p, i, 0);
            ans %= mod;
        }
        printf("%d", ans);
    }
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

ll nc2(ll n){
    return (n*(n-1))/2;
}


int main(){
    ll N, M; cin >> N >> M;
    UnionFind tree(N);
    vector<ll> A(M), B(M), ANS(M);
    for(int i = 0; i < M; i++){
        cin >> A[i] >> B[i]; A[i]--; B[i]--;
    }
    vector<ll> S(N, 1);
    ll ans = 0;
    ANS[M-1] = 0;
    for(int i = M-1; i >= 1; i--){
        ll u = A[i], v = B[i];
        if(tree.root(u) != tree.root(v)) {
            // サイズの取得
            ll rootu = tree.root(u), rootv = tree.root(v);
            ll sizeu = S[rootu], sizev = S[rootv];
            ll size = sizeu + sizev;
            ans -= nc2(sizeu);
            ans -= nc2(sizev);
            ans += nc2(size);
            tree.unite(u, v);
            S[tree.root(u)] = S[tree.root(v)] = size;

            
        }
        ANS[i-1] = ans;
    }
    ll SUM = nc2(N);
    for(int i = 0; i < M; i++){
        cout << SUM - ANS[i] << endl;
    }

}


Measured memory_bytes: 6752
#include <stdio.h>
#include <string.h>
 
#define N 200000
 
int main() {
 
  int i,j,n,q,a=0,time[N],count=0;
  char name[N][10];
 
  while(1) {
    scanf("%d %d",&n,&q);
    if(1<=n && n<=N) break;
  }
 
  for(i=0; i<n; i++) {
    if(scanf("%s %d",name[i],&time[i])!=2) break;
  }
 
  for(j=0; count!=n; j++) {
    if(i==N) i = 0;
    if(time[j]>q) {
      a += q;
      time[i] = time[j] - q;
      strcpy(name[i],name[j]);
      i++;
    }
    else {
      a += time[j];
      printf("%s %d\n",name[j],a);
      count++;
    }
  }
 
  return 0;
}

Measured memory_bytes: 3212