akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int r = cin.nextInt();
        int D = cin.nextInt();
        int x = cin.nextInt();

        for (int i = 0; i < 10; i++)
        {
            x = x * r - D;
            Console.WriteLine(x);
        }
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }

    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
struct benefit
{
  long long t_min;
  int c_min;
  long long t_max;
  int c_max;
  long long mouke;
};

int main(){
  long long n,t;
  cin >> n >> t;
  vector<long long> a(n);
  for(int i = 0; i < n; i++)
    cin >> a[i];
  vector<benefit> l;
  long long t_min = a[0];
  long long t_max = a[0];
  int c_min = 1;
  int c_max = 1;
  long long max_mouke = 0;
  for(int i = 0; i < n; i++){
    if(a[i] > t_max){
      t_max = a[i];
    }else if(a[i] == t_max){
      c_max++;
    }else if(a[i] == t_min){
      c_min++;
    }else if(a[i] < t_min){
      benefit temp = {t_min, c_min, t_max, c_max, t_max - t_min};
      l.push_back(temp);
      if(max_mouke < t_max - t_min)
        max_mouke = t_max - t_min;
      c_min = c_max = 1;
      t_min = t_max = a[i];
    }
  }

  benefit temp = {t_min, c_min, t_max, c_max, t_max - t_min};
  l.push_back(temp);
  if(max_mouke < t_max - t_min)
    max_mouke = t_max - t_min;

  long long cnt = 0;
  for(int i = 0; i < l.size(); i++){
    if(l[i].mouke == max_mouke){
      cnt += min(c_min, c_max);
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
ll GCD(ll a,ll b){
    if(b==0) return a;
    return GCD(b,a%b);
}
int main() {
    int n;
    cin>>n;
    vector<ll> a(n);
    ll ans;
    rep(i,n){
        cin>>a[i];
        if(i==0) ans=a[i];
        else ans=GCD(max(ans,a[i]),min(ans,a[i]));
    }
    cout<<ans;
}

Measured memory_bytes: 3860
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    vint p(n);
    REP(i,n) cin >> p[i];
    sort(ALL(p));
    int ans = 0;
    REP(i,k){
        ans += p[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3660
/* attention to overflow */
#include <bits/stdc++.h>

#define dump(x) cerr<< #x << " = " << x <<endl
#define ALL(container) (container).begin(),(container).end()

using namespace std;
const int INF = 1 << 25;
void io() { cin.tie(0); ios::sync_with_stdio(false);}
template <class S,class T> ostream& operator<<(ostream& os, const pair <S,T> &s){return os<<'('<<s.first<<','<<s.second<<')';}
/*printf("%.9Lf\n",cf);*/
const int MOD = 1000000007;
const double EPS=1e-8;

int dp[200010];
struct ed{int u,v,t,c;};
vector <ed> eds(200010);
struct edge{int no,u,tc;};
vector <edge> Graph[100010];

int N,M,S,G;

int memo(int q){
	if(dp[q]!=-1) return dp[q];

	int uofq=eds[q].u;
	int tofq=eds[q].t;

	if(uofq==S) return dp[q]=tofq;

	int tmp=INF;
	for(int i=0;i<Graph[uofq].size();i++){
		int no=Graph[uofq][i].no;
		int tc=Graph[uofq][i].tc;
		//if(tc>tofq) continue;
		if(tc>tofq) break;
		tmp=min(tmp,(tofq-tc)+memo(no));
	}
	return dp[q]=tmp;
}

int main() {
	io();
	cin>>N>>M>>S>>G;
	S--,G--;
	fill_n(dp,M+10,-1);
	for(int i=0;i<M;i++){
		int u,v,t,c;
		cin>>u>>v>>t>>c;
		u--,v--;
		Graph[v].push_back({i,u,t+c});

		//eds.push_back({u,v,t,c});
		eds[i]={u,v,t,c};
	}

	for(int i=0;i<N;i++){
		sort(Graph[i].begin(),Graph[i].end(),[](const edge &a, const edge &b){return a.tc<b.tc;});
	}

	int ans=INF;
	for(int i=0;i<M;i++){
		if(eds[i].v==G) ans=min(ans,memo(i));
	}
	cout<<ans<<endl;


	return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
// inline void CIN() {}
// template <class Head, class... Tail>
// inline void CIN(Head &&head, Tail &&... tail) {
//     cin >> head;
//     CIN(move(tail)...);
// }
// CIN(__VA_ARGS__)
// CIN(__VA_ARGS__)
// CIN(__VA_ARGS__)
// #define Yes(a) cout << (a ? "Yes" : "No") << "\n"
// #define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
// typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int q;
map<string, int> dic;

int main() {
    cin >> q;
    REP(i, q) {
        switch(IN()) {
        case 0:
            dic[IN<string>()] = IN();
            break;
        case 1:
            cout << dic[IN<string>()] << "\n";
            break;
        case 2:
            dic.erase(IN<string>());
            break;
        default:
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 27808
#include<bits/stdc++.h>
using namespace std;
int main(){

  int n;

  cin>>n;

  int ans=0;

  int cnt=n;
  
  while(n!=0){
    ans+=n%10;
    n/=10;
  }


  if(cnt%ans==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    string S;
    cin>>S;
    vi count(26,0);
    for(int i=0;i<S.size();i++){
        count[S[i]-'a']++;
    }
    bool ok=true;
    for(int i=0;i<26;i++){
        if(count[i]%2){
            ok=false;break;
        }
    }
    cout<<(ok?"Yes":"No")<<endl;
}

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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

#define ll long long
#define ull unsigned ll

void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
void reader(double *x){scanf("%lf",x);}
int reader(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF) break;c[s++]=i;}c[s]='\0';return s;}
template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);}
template <class T, class S, class U> void reader(T *x, S *y, U *z){reader(x);reader(y);reader(z);}
template <class T, class S, class U, class V> void reader(T *x, S *y, U *z, V *w){reader(x);reader(y);reader(z);reader(w);}

void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
void writer(double x, char c){printf("%.15f",x);mypc(c);}
void writer(const char c[]){int i;for(i=0;c[i]!='\0';i++)mypc(c[i]);}
void writer(const char x[], char c){int i;for(i=0;x[i]!='\0';i++)mypc(x[i]);mypc(c);}
template<class T> void writerLn(T x){writer(x,'\n');}
template<class T, class S> void writerLn(T x, S y){writer(x,' ');writer(y,'\n');}
template<class T, class S, class U> void writerLn(T x, S y, U z){writer(x,' ');writer(y,' ');writer(z,'\n');}
template<class T> void writerArr(T x[], int n){int i;if(!n){mypc('\n');return;}rep(i,n-1)writer(x[i],' ');writer(x[n-1],'\n');}

char memarr[17000000]; void *mem = memarr;
#define MD 1000000007

int N, L[10000];

int main(){
  int i, j, k;
  int res = 0;

  reader(&N);
  rep(i,2*N) reader(L+i);
  sort(L,L+2*N);
  rep(i,N) res += L[2*i];
  writerLn(res);

  return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  int n,cnt=0;
  cin>>n>>s;
  for(int a=0; a<n; a++)
  {
    
	if(s[a]=='A'&& s[a+1]=='B'&& s[a+2]=='C'){
      cnt++;
    }
  }
  
  cout<<cnt<<endl;
  
}
      

Measured memory_bytes: 3612
#include <stdio.h>

// 最大公約数を返す
long long int gcd(long long int num1, long long int num2) {
  if (num1 % num2 == 0) return num2;
  return gcd(num2, num1%num2);
}

// 最小公倍数を返す
long long int lcm(long long int num1, long long int num2) {
  return num1 * num2 / gcd(num1, num2);
}

int main() {
  long long int a, b, c, d;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
  long long int rslt;
  rslt = b - a + 1;
  rslt = rslt - b/c + (a-1)/c;
  rslt = rslt - b/d + (a-1)/d;
  rslt = rslt + b/lcm(c, d) - (a-1)/lcm(c, d);
  printf("%lld\n", rslt);
  return 0;
}


Measured memory_bytes: 128
// 2020-09-29 21:42:00
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
// #include <atcoder/convolution>
// #include <atcoder/dsu>
// #include <atcoder/fenwicktree>
// #include <atcoder/lazysegtree>
// #include <atcoder/math>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/modint>
// #include <atcoder/scc>
// #include <atcoder/segtree>
// #include <atcoder/string>
// #include <atcoder/twosat>
// #include <atcoder/all>
// using namespace atcoder;

// clang-format on
const int MX = 200020, inf = 1e9;
int n, ans;
vector<P> ps[4];  // U R D L
void init() {
  cin >> n;
  rep(i, n) {
    int x, y, k;
    char u;
    cin >> x >> y >> u;
    if (u == 'U') k = 0;
    if (u == 'R') k = 1;
    if (u == 'D') k = 2;
    if (u == 'L') k = 3;
    ps[k].emplace_back(x, y);
  }
  ans = inf;
}
void check_ur(int k) {
  vector<set<int> > uys(MX * 2 + 10);
  vector<set<int> > rys(MX * 2 + 10);
  for (auto [x, y] : ps[k]) uys[x + y].insert(y);
  for (auto [x, y] : ps[(k + 1) % 4]) rys[x + y].insert(y);
  rep(i, MX * 2) {
    if (uys[i].size() == 0) continue;
    if (rys[i].size() == 0) continue;
    for (auto uy : uys[i]) {
      auto itr = rys[i].upper_bound(uy);
      if (itr == rys[i].end()) continue;
      chmin(ans, ((*itr) - uy) * 10);
    }
  }
}
void check_ud(int k) {
  vector<set<int> > uys(MX + 10);
  vector<set<int> > dys(MX + 10);
  for (auto [x, y] : ps[k]) uys[x].insert(y);
  for (auto [x, y] : ps[(k + 2) % 4]) dys[x].insert(y);
  rep(i, MX) {
    if (uys[i].size() == 0) continue;
    if (dys[i].size() == 0) continue;
    for (auto uy : uys[i]) {
      auto itr = dys[i].upper_bound(uy);
      if (itr == dys[i].end()) continue;
      chmin(ans, ((*itr) - uy) * 5);
    }
  }
}
void rot() {
  rep(k, 4) {
    for (auto& [x, y] : ps[k]) {
      swap(x, y);
      x = -x + 200000;
    }
  }
}
void answer() {
  init();
  rep(k, 4) {
    check_ur(k);
    if (k < 2) check_ud(k);
    rot();
  }
  if (ans == inf) {
    cout << "SAFE" << '\n';
  } else {
    cout << ans << '\n';
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 64028
#include<stdio.h>

void trace(int A[], int N) {
	int i;
	for (i = 0; i < N; i++) {
		if (i > 0)printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

void insertionSort(int A[], int N) {
	int j, i, v;
	for (i = 1; i < N; i++) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j]>v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trace(A, N);
	}
}

int main() {
	int N, i, j;
	int A[100];

	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%d", &A[i]);

	trace(A, N);
	insertionSort(A, N);

	return 0;
}

Measured memory_bytes: 604
// ConsoleApplication15.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
#include<cmath>
#include<cstring>
#include<iomanip>
using namespace std;
int main()
{
	int h, a, aa,n;
	while (cin >> h >> a)
	{
		n = 0;
		for (int i = 0; i < a; i++)
		{
			cin >> aa;
			n += aa;
		}
		if (n >= h)
		{
			cout << "Yes\n";
		}
		else
		{
			cout << "No\n";
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define li long int
#define ld long double
#define pl pair<long long, long long>
#define pi pair<int, int>
#define ppl pair<pl, ll>
#define ppi pair<int, pi>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LLFOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define MOD 1000000007
#define M2 998244353
//std::cout <<setprecision(30) << av << endl;
using namespace std;
int a[200000];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--){
        int n, m;
        cin >> n >> m;
        ll sum=0;
        FOR(i, 0, m){
            cin >> a[i];
            sum+=(ll)a[i];
        }
        if(sum>n){
            cout << "-1" << endl;
        }else{
            cout << n-sum << endl;
        }


    }
}


Measured memory_bytes: 3644
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n;
struct lxs
{
	int t,x;
}st[100010];
bool cmp(lxs a,lxs b)
{
	return a.t<b.t;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&st[i].t);
		st[i].x=i;
	}
	sort(st+1,st+n+1,cmp);
	for(int i=1;i<=n;i++)
		printf("%d ",st[i].x);
	return 0;
}

Measured memory_bytes: 1536
N = int(input())
pos_l = list(map(int,input().split()))
MAX = 100
ans = 10**6
for i in range(1,MAX+1):
    tmpans = 0
    for pos in pos_l:
        tmpans += (pos - i)**2
    
    if(tmpans < ans):
        ans = tmpans

print(ans)

Measured memory_bytes: 38768
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

struct Info{
	Info(){
		used = false;
		depth = 0;
	}
	char message[51];
	int depth;
	bool used;
	vector<int> children;
};

void recursive(Info info[],int id){
	for(int i = 0; i < info[id].depth; i++)printf(".");
	printf("%s\n",info[id].message);
	info[id].used = true;
	for(int i = 0; i < info[id].children.size(); i++){
		recursive(info,info[id].children[i]);
	}
}

int main(){

	int N;
	scanf("%d",&N);
	Info info[N+1];

	int k;
	scanf("%d",&k);
	scanf("%s",info[1].message);

	for(int i = 2; i <= N; i++){
		scanf("%d",&k);
		scanf("%s",info[i].message);
		info[i].depth = info[k].depth+1;
		info[k].children.push_back(i);
	}

	for(int i = 1; i <= N; i++){
		if(info[i].used == false){
			recursive(info,i);
		}
	}

	return 0;
}

Measured memory_bytes: 2768
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i <  B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const int N = 2005;

const int M = 4e5 + 5;

int n, m, x, y;
int fi[N], nt[M], to[M], tot;
vector<int> e[N];

void link(int x, int y) {
	nt[++ tot] = fi[x], to[tot] = y, fi[x] = tot;
	e[x].push_back(y);
}

int bz[N];

int b[N][N];

int d[N], d0, ky[N][N];

void dfs(int x) {
	if(bz[x]) return;
	bz[x] = 1;
	ff(i, 0, e[x].size()) dfs(e[x][i]);
}

#define mem(a) memset(a, 0, sizeof a)

int ans[M];

int main() {
	scanf("%d %d", &n, &m);
	fo(i, 1, m) {
		scanf("%d %d", &x, &y);
		link(x, y);
	}
	fo(st, 1, n) {
		mem(bz); d0 = 0;
		for(int i = fi[st]; i; i = nt[i])
			d[++ d0] = to[i];
		bz[st] = 1;
		fo(i, 1, d0) {
			ky[st][d[i]] |= bz[d[i]];
			dfs(d[i]);
		}
		fo(j, 1, n) b[st][j] |= bz[j];
		mem(bz); bz[st] = 1;
		fd(i, d0, 1) {
			ky[st][d[i]] |= bz[d[i]];
			dfs(d[i]);
		}
		fo(j, 1, n) b[st][j] |= bz[j];
	}
	fo(st, 1, n) {
		for(int i = fi[st]; i; i = nt[i])
			ans[i] = b[to[i]][st] ^ ky[st][to[i]];
	}
	fo(i, 1, m) pp("%s\n", ans[i] ? "diff" : "same");
}

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

const int inf = 1e9+7;

int main(){

	int n,z,w;
	cin>>n>>z>>w;

	int arr[n];

	for(int i=0;i<n;i++) cin>>arr[i];

	int x = abs(arr[n-1]-w);
	int y = x;
	if(1<n){
		y = abs(arr[n-1]-arr[n-2]);
	}
	
	if(x<y) cout<<y;
	else cout<<x;
}


Measured memory_bytes: 256
#include <numeric>
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define int long long
#define inf  998244353
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
int mul[414514]; int divi[414514];
int fact(int x,int y){
    if(y==1)return x;
    else if(y%2==0)return fact(x*x%inf,y/2);
    else return fact(x*x%inf,y/2)*x%inf;
}
int C(int n,int t){
    //cout<<n<<" "<<t<<endl;
    //cout<<mul[n]<<" "<<divi[t]<<" "<<divi[n-t]<<endl;
    return mul[n]%inf*divi[t]%inf*divi[n-t]%inf;
}
signed main(){
    int n,a,b,k;cin>>n>>a>>b>>k;
    mul[0]=1;
    rep(i,1,414514)mul[i]=mul[i-1]*i%inf;
    divi[414513]=fact(mul[414513],inf-2);
    for(int i=414512;i>=0;i--)divi[i]=divi[i+1]*(i+1)%inf;
    int ans=0;
    rep(i,0,n+1){
        int score=a*i;
        if((k-score)%b)continue;
        int h=(k-score)/b;
        if(h<0||n<h)continue;
        //cout<<i<<" "<<h<<endl;
        ans=(ans+C(n,i)*C(n,h)%inf)%inf;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6784
a,b,c,x,y = map(int,input().split())

chp = min(a+b,c*2)
memo1 = min(x,y)
memo2 = max(x,y)-min(x,y)
if x>y:
    a = min(a,c*2)
    print(memo2*a+memo1*chp)
else:
    b = min(b,c*2)
    print(memo2*b+memo1*chp)

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
	long long a,b,c,r=1;
	scanf("%lli%lli",&a,&b);
	c=__gcd(a,b);
	for(long long i=2;i<=sqrt(c);i++)
	{
		if(c%i==0)
		{
			r++;
		}
		while(c%i==0)
		{
			c=c/i;
		}
	}
	if(c!=1)	printf("%lli",r+1);
	else
	{
		printf("%lli",r);
	}
}


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

using ll = long long;
#define f(i,a,b) for (int i = a; i < b; i++)

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n;
	cin>>n;
	int a[n];
	f(i,0,n) cin>>a[i];
	bool found = a[0]?1:0;
	f(i,1,n) if (a[i]>a[i-1]+1)
		found = 1;
	if (found) cout << -1 << endl;
	else {
		ll cnt = 0;
		f(i,1,n) if (a[i]) {
			if (a[i]!=a[i-1]+1)
				cnt+=a[i];
			else cnt++;
		}	
		cout << cnt << endl;
	}


#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int main(void){
    int h,w;
    cin>>h>>w;
    vector<vector<char>> c(h+2,vector<char>(w+2,'.'));
    rep(i,1,h+1){
        rep(j,1,w+1) cin>>c[i][j];
    }
    rep(i,0,h){
        rep(j,0,w) {
            if(c[i][j]=='#'){
                if(c[i-1][j]!='#'&&
                c[i][j-1]!='#'&&
                c[i+1][j]!='#'&&
                c[i][j+1]!='#'){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
class Main{
	static int[] swi = new int[11];
 
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] k = new int[m];
		int[][] s = new int[m][];
		for(int i = 0; i < m; i++){
			k[i] = sc.nextInt();
			s[i] = new int[k[i]];
			for(int j = 0; j < k[i]; j++){
				s[i][j] = sc.nextInt()-1;
			}
		}
		int[] p = new int[m];
		for(int i = 0; i < m ; i++){
			p[i] = sc.nextInt();
		}
		int ans = 0;
		for(int i = 0; i < Math.pow(2,n); i++){
			pra();
			/*for(int aaa : swi){
				System.out.print(aaa);
			}
			System.out.println();*/
			int ba = 0;
			int sumsum = 0;
			for(int j = 0; j < m; j++){
				int sum = 0;
				for(int l = 0; l < k[j]; l++){
					if(swi[s[j][l]] == 1){
						sum++;
					}
				}
				if(sum%2 == p[j]){
					sumsum++;
				}
			}
			if(sumsum == m){
				ans++;
			}
		}
		System.out.print(ans);
	}
 
	static void pra(){
		int idx = 0;
		while(true){
			if(swi[idx] == 0){
				swi[idx] = 1;
				break;
			}else{
				swi[idx] = 0;
				idx++;
			}
		}
	}
}

Measured memory_bytes: 21972
import operator
class SegmentTree:
    def __init__(self, size, fn=operator.add, default=None, initial_values=None):
        """
        :param int size:
        :param callable fn: 区間に適用する関数。引数を 2 つ取る。min, max, operator.xor など
        :param default:
        :param list initial_values:
        """
        default = default or 0
 
        # size 以上である最小の 2 冪を size とする
        n = 1
        while n < size:
            n *= 2
        self._size = n
        self._fn = fn
 
        self._tree = [default] * (self._size * 2 - 1)
        if initial_values:
            i = self._size - 1
            for v in initial_values:
                self._tree[i] = v
                i += 1
            i = self._size - 2
            while i >= 0:
                self._tree[i] = self._fn(self._tree[i * 2 + 1], self._tree[i * 2 + 2])
                i -= 1
 
    def set(self, i, value):
        """
        i 番目に value を設定
        :param int i:
        :param value:
        :return:
        """
        x = self._size - 1 + i
        self._tree[x] = value
 
        while x > 0:
            x = (x - 1) // 2
            self._tree[x] = self._fn(self._tree[x * 2 + 1], self._tree[x * 2 + 2])
 
    def update(self, i, value):
        """
        もとの i 番目と value に fn を適用したものを i 番目に設定
        :param int i:
        :param value:
        :return:
        """
        x = self._size - 1 + i
        self.set(i, self._fn(self._tree[x], value))
 
    def get(self, from_i, to_i=None, k=0, L=None, r=None):
        """
        [from_i, to_i) に fn を適用した結果を返す
        :param int from_i:
        :param int to_i:
        :param int k: self._tree[k] が、[L, r) に fn を適用した結果を持つ
        :param int L:
        :param int r:
        :return:
        """
        if to_i is None:
            return self._tree[self._size - 1 + from_i]
 
        L = 0 if L is None else L
        r = self._size if r is None else r
 
        if from_i <= L and r <= to_i:
            return self._tree[k]
 
        if to_i <= L or r <= from_i:
            return None
 
        ret_L = self.get(from_i, to_i, k * 2 + 1, L, (L + r) // 2)
        ret_r = self.get(from_i, to_i, k * 2 + 2, (L + r) // 2, r)
        if ret_L is None:
            return ret_r
        if ret_r is None:
            return ret_L
        return self._fn(ret_L, ret_r)
 
    def __len__(self):
        return self._size
 
 
def resolve():
    N = int(input())
    H = list(map(int, input().split()))
    A = list(map(int, input().split()))
 
    Flowers = []
    for i in range(N):
        Flowers.append((H[i], (A[i], i)))
    # 高さを昇順にソート
    Flowers.sort()
 
    seg = SegmentTree(N, fn=max)
    for i in range(N):
        h, (a, idx) = Flowers[i]
        maxV = seg.get(0, idx)
        # l=0, r=0 の時Noneを返す仕様
        if maxV == None:
            maxV = 0
        seg.set(idx, maxV+a)
 
    ans = seg.get(0, N)
    print(ans)
    
if __name__ == "__main__":
    resolve()

Measured memory_bytes: 133704
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cstdint>
#include<cstddef>
#include<map>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using usize = uint_fast64_t;
#define rep(i, n) for (usize i = 0; i < (usize)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i64 n;
cin >> n;
map<i64,i64> mp,mp2;
rep(i,n){
    i64 a;
    cin >> a;
    mp[a]++;
}
i64 m;
cin >> m;
rep(i,m){
    i64 a;
    cin >> a;
    mp2[a]++;
}
bool flag = true;
for(auto v:mp2){
    if(v.second > mp[v.first])flag = false;
}
cout << (flag ? "YES" : "NO") << endl;
}

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

using namespace std;
typedef long long ll;
ll n,m,tot,ans;
ll ddis(ll x,ll y,ll z)
{
	if(x>=y&&x>=z) return max(x-y,x-z);
	if(y>=x&&y>=z) return max(y-x,y-z);
	if(z>=x&&z>=y) return max(z-y,z-x);
}
int main()
{
	ans=1000000000000ll;
	scanf("%lld%lld",&n,&m); tot=m*n;
	for(int i=1;i<n;i++)
	{
		ll S1=i*m; 
		if((m&1)&&(n-i)&1)
		{
			if(m>(n-i)) ans=min(ans,ddis(S1,(m/2)*(n-i),(m/2+1)*(n-i)));
			else ans=min(ans,ddis(S1,((n-i)/2)*m,((n-i)/2+1)*m));
		}
		else ans=min(abs(S1-(tot-S1)/2),ans);
	}
	swap(n,m);
	for(int i=1;i<n;i++)
	{
		ll S1=i*m; 
		if((m&1)&&(n-i)&1)
		{
			if(m>(n-i)) ans=min(ans,ddis(S1,(m/2)*(n-i),(m/2+1)*(n-i)));
			else ans=min(ans,ddis(S1,((n-i)/2)*m,((n-i)/2+1)*m));
		}
		else ans=min(abs(S1-(tot-S1)/2),ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include "stdio.h"

int sum(int N,int D,int X,int *span);

int main(){
	int N; //部員数
	int D; //日数
	int X; //残りの個数
	int span[100]; //食べるスパン
	int i;
	
	scanf("%d",&N);
	scanf("%d %d",&D,&X);
	
	for(i=0;i<N;i++){
		scanf("%d",&span[i]);
	}
	
	printf("%d",sum(N,D,X,span));
	
	return 0;
}

int sum(int N,int D,int X,int *span){
	int d,i;
	int chocolate_count=0;
	
	for(d=1;d<=D;d++){
		for(i=0;i<N;i++){
			if((d-1)%span[i]==0){
				chocolate_count+=1;
			}
		}
	}
	
	return chocolate_count+X;
}

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

void input(long &n, vector<long> &a) {
    cin >> n;
    a.resize(n);
    for (long i = 0; i < n; i++) {
        cin >> a[i];
    }
}

long div(long n) { // 整数が2で割り切れる回数
    long count = 0;
    while (n % 2 == 0) {
        n /= 2;
        count++;
    }
    return count;
}

int main() {
    long n; vector<long> a;
    input(n, a);

    long sum = 0;
    for (long i = 0; i < n; i++) { //各要素の2で割り切れる回数の総和
        sum += div(a[i]);
    }
    cout << sum << endl;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>	
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================


int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;

int main()
{
	cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> b;
		a[b-1] = i+1;
	}
	rep(i, n)cout << a[i] << " ";
	cout << endl;

	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
////////////////////////////////////////////////////////////
#define all(x) (x).begin(), (x).end() 
const int inf = 1e9;
const long long INF=1e15;
#define endl '\n'
#define rep(i, n) for(int i=0;i<(n);++i)
#define repp(i, a, b) for(int i=(a);i<=(b);++i)
#define pb push_back
#define eb emplace_back
#define fastio ios::sync_with_stdio(false);cin.tie(0); //cout.tie(0);

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

int solve() {
	ll n,m,v,p;
	cin >>n>>m>>v>>p;
	vll a(n); rep(i,n)cin>>a[i];
	sort(all(a), greater<ll>());
	auto chk = [&](int x) {
		if(x == n) return false;
		if(x < p) return true;
		if(a[x]+m < a[p-1]) return false;
		// p-1+n-x
		ll bsum = 0;
		for(int i=p-1;i<x;i++) bsum += max(0ll, a[x]+m-a[i]);
		if(bsum + (p-1+n-x)*m >= m*v) return true;
		return false;
	};
	int l =0, r=n;
	while(l!=r) {
		int mid=(l+r)/2;
		if(chk(mid) == false) r=mid;
		else l = mid+1;
	}
	cout << l;
}

int main() {
	fastio;
	solve();
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int bfs(int h, int w,vector<string> s) {
	int dx[4] = { 1,0,-1,0 };
	int dy[4] = { 0,1,0,-1 };
	VV dist(h, V(w, upper));
	dist[0][0] = 1;
	queue<P<int>> que;
	que.push(make_pair(0, 0));
	while (!que.empty()) {
		int y = que.front().first;
		int x = que.front().second;
		que.pop();
		rep(dir, 4) {
			int ny = y + dy[dir];
			int nx = x + dx[dir];
			if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
			if (s[ny][nx] == '#') continue;
			if (dist[ny][nx] != upper) continue;
			que.push(make_pair(ny, nx));
			dist[ny][nx] = dist[y][x] + 1;
		}
	}
	return (dist[h - 1][w - 1] == upper) ? -1 : dist[h - 1][w - 1];
}
int main() {
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i, h) {
		cin >> s[i];
	}
	int count = 0;
	rep(i, h) rep(j, w) {
		if (s[i][j] == '#') count++;
	}
	int ans = bfs(h, w, s);
	if (ans == -1) cout << ans << endl;
	else cout << h * w - count - ans << endl;
	return 0;
}

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

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

 map<long long, long long> m;
  for (int i=0; i<N; i++) {
    long long a, b;
    cin >> a >> b;
    m[a] += b;
  }

  long long ans = 0;
  for (auto it = m.begin(); it != m.end(); it++) {
    long long count = min(M, it->second);
    ans += it->first * count;
    M -= count;
    if (!M) break;
  }
  
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 6528
import bisect
x,n = map(int, input().split())
if (n==0):
    print(x)
    exit()
p = list(map(int, input().split()))
a = []
for i in range(102):
    if (i in p):
        continue
    a.append(i)
#print(a)


z = bisect.bisect_left(a,x)
if (z==0):
    print(a[0])
    exit()
elif (z==len(a)):
    print(a[-1])
    exit()
a1 = a[z]
a2 = a[z-1]
if (abs(a1-x) < abs(a2-x)):
    print(a1)
elif (abs(a1-x) > abs(a2-x)):
    print(a2)
else:
    print(a2)


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

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;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&p)
{o<<"{"<<p.first<<", "<<p.second<<"}";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj)
{o<<"{";for(auto itr=obj.begin();itr!=obj.end();++itr)o<<(itr!=obj.begin()?", ":"")<<*itr;o<<"}";return o;}

ll MOD = 1000000007;

int main(){
	cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,m,x;
  cin >> n >> m;
  vector<int> s,t;
  vector<vector<ll>> cnt(n,vector<ll>(m,0)),sum(n,vector<ll>(m,0));
  vector<vector<ll>> dp(n+1,vector<ll>(m+1,1));

  for(int i=0; i<n; i++){
    cin >> x;
    s.push_back(x);
  }
  for(int i=0; i<m; i++){
    cin >> x;
    t.push_back(x);
  }

  for(int i=1; i<=n; i++){
    for(int j=1; j<=m; j++){
      if(s[i-1]==t[j-1]){
        dp[i][j] = dp[i-1][j] + dp[i][j-1];
      }else{
        dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1];
      }
      dp[i][j] += MOD;
      dp[i][j] %= MOD;
    }
  }
  cout << dp[n][m] << endl;

  return 0;
}


Measured memory_bytes: 94336
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    A = sorted(readInts())
    a,b,c = A
    #MaxArea = a * b * c
    #red = 0
    #dist = MaxArea - red
    # for i in range(1,MaxArea//(a*b)//2 + 1):
    #     #print(red)
    #     red += a * b
    #     dist = min(dist,abs(MaxArea - red - red))
    #print(dist)
    print(abs(a*b*(c//2+c%2) - a*b*(c//2)))
if __name__ == '__main__':
  main()


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

using namespace std;

#define MAX 1010
#define MAX_M 101

int dp[MAX_M][MAX];

int main()
{
    int LIMIT, N, M, X;
    string name;
    while (cin >> LIMIT >> N >> M >> X, LIMIT) {
        vector<int> c(N), s(N);
        for (int i = 0; i < N; i++) {
            cin >> name >> c[i] >> s[i];
        }
        int max_s[MAX];
        fill(max_s, max_s + MAX, -1);
        for (int i = 0; i < N; i++) {
            max_s[c[i]] = max(max_s[c[i]], s[i]);
            for (int j = i + 1; j < N; j++) {
                max_s[c[i] + c[j]] = max(max_s[c[i] + c[j]], s[i] + s[j]);
            }
        }
        for (int i = 0; i < LIMIT; i++) {
            max_s[i+1] = max(max_s[i+1], max_s[i]);
        }
        vector<int> sc(M), ss(M);
        for (int i = 0; i < M; i++) {
            cin >> name >> sc[i] >> ss[i];
        }
        for (int i = 0; i <= M; i++) {
            for (int j = 0; j <= LIMIT; j++) {
                dp[i][j] = -1;
            }
        }
        dp[0][0] = 0;
        for (int i = 0; i < M; i++) {
            for (int j = M-1; j >= 0; j--) {
                for (int k = LIMIT-sc[i]; k >= 0; k--) {
                    if (dp[j][k] == -1) continue;
                    int nk = k + sc[i];
                    if (nk <= LIMIT) {
                        dp[j+1][nk] = max(dp[j+1][nk], dp[j][k] + ss[i]);
                    }
                }
            }
        }
        
        int res = 0;
        for (int i = 0; i <= LIMIT; i++) {
            if (max_s[i] == -1) continue;
            for (int j = X; j <= M; j++) {
                if (dp[j][LIMIT-i] == -1) continue;
                res = max(res, max_s[i] + dp[j][LIMIT-i]);                   
            }
        }
        cout << res << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef set<ll> si;
typedef map<string, ll> msi;
#define hell 1000000007
#define MAX 1000000000
#define max_int 1000000
#define F first
#define re 15000000
#define S second
#define pb push_back
#define all(a)  (a).begin(),(a).end()
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define pi 3.1415926536
#define r0 return 0
#define rep(i,a,b) for(ll i = a;i<b;i++)



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

    
    ll n,k;
    cin>>n>>k;
    ll x;
    map<int,int>m;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        m[i]=x;
    }
    int vis[n+1]={0};
    int st=1,len1=0;
    while(!vis[st])
    {
        vis[st]=1;
        st=m[st];
        len1++;
    }
    ll len=1;
    x=m[st];
    while(x!=st)
    {
        x=m[x];
        len++;
    }
    len1-=len,x=1;
    while(k>0 && x!=st)
    {
        x=m[x];
        k--;
    }
    if(k==0)
    {
        cout<<x;
        r0;
    }
    k=k%len;
    while(k--)
    {
        x=m[x];
    }
    cout<<x;

    r0;
}
 

Measured memory_bytes: 13788
from collections import defaultdict
Q = int(input())
queries = [tuple(map(int, input().split())) for i in range(Q)]

total = [0]
prime = defaultdict(lambda: True)
for i in range(2, 100001):
    for j in range(i * 2, 100001, i):
        prime[j] = False
for i in range(1, 50000):
    n = 2 * i + 1
    total.append(total[-1] + int(prime[n] and prime[(n + 1) // 2]))

for i in range(Q):
    l, r = queries[i][0], queries[i][1]
    if l == 1:
        print(total[(r - 1) // 2])
    else:
        print(total[(r - 1) // 2] - total[(l - 1) // 2 - 1])


Measured memory_bytes: 28928
import collections
N=int(input())
S=[input() for i in range(N)]
cnt=collections.Counter(S)
cnt=cnt.most_common()
ans=[]
cnt=sorted(cnt,key=lambda x :x[1],reverse=True)
max=cnt[0][1]
num=len(cnt)
for i in range(num):
  if cnt[i][1]==max:
    ans.append(cnt[i][0])
ans=sorted(ans)
for i in ans:
  print(i)

Measured memory_bytes: 45036
//#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wall"
#pragma GCC diagnostic ignored "-Wextra"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wpedantic"
#include "atcoder/all"
#pragma GCC diagnostic warning "-Wall"
#pragma GCC diagnostic warning "-Wextra"
#pragma GCC diagnostic warning "-Wconversion"
#pragma GCC diagnostic warning "-Wpedantic"
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
using namespace atcoder;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) (((n) >> (k)) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = true;
}  // namespace mydef
using namespace mydef;
#define pb push_back
//#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans


void solve() {
}

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

    int T;
    cin >> T;
    while (T--) {
        int n, m, a, b;
        cin >> n >> m >> a >> b;
        cout << floor_sum(n, m, a, b) << endl;
    }

    solve();
    return 0;
}


Measured memory_bytes: 3692
N, M = list(map(int, input().split()))
list_h = list(map(int, input().split()))
table = [1] * N

for i in range(M):
  A, B = list(map(int, input().split()))
  if list_h[B-1] < list_h[A-1]:
    table[B-1] = 0
  elif list_h[A-1] < list_h[B-1]:
    table[A-1] = 0
  else:
    table[A-1] = 0
    table[B-1] = 0

print(str(sum(table)))

Measured memory_bytes: 20044
#include <stdio.h>

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

     if((a + b) % 3 == 0 | a % 3 == 0 | b % 3 == 0) printf("Possible\n");
     else printf("Impossible\n");

     return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
import math

from decimal import *

def solve(A: int, B: float):
    a = Decimal(A)
    b = Decimal(B)
    # print(math.floor(a * b))
    # return
    if len(str(B)) == 3:
        if str(B)[2] == 0:
            print(math.floor(a*b))
            return
        ans = A * int(str(B)[0])
        ans += Decimal(a * int(str(B)[2]) / 10)
        print(math.floor(ans))
        return

    if len(str(B)) == 4:
        ans = A * int(str(B)[0])
        ans += Decimal(A * int(str(B)[2]) / 10)
        ans += Decimal(A * int(str(B)[3]) / 100)
        print(math.floor(ans))
        return
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = float(next(tokens))  # type: float
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 10124
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n), add(n);
    cin >> a;
    ll ans = 0;
    while(any_of(a.begin(), a.end(), [&](ll x) { return x >= n; })) {
        for(int i = 0; i < n; i++) {
            add[i] = a[i] / n;
            a[i] %= n;
        }
        ll s = accumulate(add.begin(), add.end(), 0ll);
        for(int i = 0; i < n; i++) {
            a[i] += s - add[i];
        }
        ans += s;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256