akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define pye cout << "Yes" << endl;
#define pno cout << "No" << endl;
#define prin(num) cout << num << endl;
#define sprin(str) cout << "str" << endl;
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 100001
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<ll> PQ;
typedef pair<double, double> doup;
//typedef vector<ll> vec;
//typedef vector<vec> mat;


int main() {
    ll W;
    cin >> W;
    vector<ll> weight;
    ll dp[15][MAX];
    ll i, w;
    for(i=1; i<=W; i*=6) weight.push_back(i);
    for(i=9; i<=W; i*=9) weight.push_back(i);
    ll n=weight.size();
    
    for(i=0; i<15; i++) {
        for(w=0; w<MAX; w++) {
            dp[i][w]=INF;
        }
    }
    for(i=0; i<=n; i++)
        dp[i][0]=0;
    
    for(i=0; i<n; i++) {
        for(w=0; w<=W; w++) {
            dp[i+1][w]=dp[i][w];
            if(w>=weight[i])
                dp[i+1][w]=min(dp[i+1][w-weight[i]]+1, dp[i][w]);
        }
    }
    
    
    prin(dp[n][W]);
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N, ans;
  cin >> N;
  ans=0;
  vector<int> l(N);
  vector<int> r(N);
  for (int i=0; i<N; i++) {
    cin >> l.at(i) >> r.at(i);
  }
  for (int j=0; j<N; j++) {
    ans=ans+r.at(j)-l.at(j)+1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3556
#include<stdio.h>



int main(){
	
	int age;
	
	scanf("%d",&age);
	
	if(age==7 || age==5 || age==3){
		
		printf("YES\n");
		
	}	
	
	else{
		
		printf("NO\n");
	}
	
	return 0;	
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;
void init();
#define REP(var, num) for(sll var = 0; var < num; var++)
#define MAX_OF(type) numeric_limits<type>::max()
#define MIN_OF(type) numeric_limits<type>::min()
#define SORT(vec) sort(vec.begin(), vec.end())
#define REVERSE(vec) reverse(vec.begin(), vec.end())
#define ALL(vec) vec.begin(), vec.end()
typedef signed long long sll;
typedef unsigned long long ull;

int main() {
    init();
    sll n;
    cin >> n;
    vector<sll> as(n);
    vector<sll> bs(n);
    vector<sll> cs(n);
    REP(i, n) { cin >> as[i]; }
    REP(i, n) { cin >> bs[i]; }
    REP(i, n) { cin >> cs[i]; }
    SORT(as);
    SORT(bs);
    SORT(cs);
    sll sum = 0;
    REP(i, n) {
        auto a = lower_bound(ALL(as), bs[i]) - as.begin();
        auto c = n - (upper_bound(ALL(cs), bs[i]) - cs.begin());
        sum += a*c;
    }
   cout << sum << endl;
    return 0;
}

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

Measured memory_bytes: 2560
#include <stdio.h>
 
int field[15][15];
 
int main(void)
{
    int x, y;
    int size;
    int sum = 0, max = 0;
     
    while (scanf("%d,%d,%d", &x, &y, &size) != EOF){
         y += 2;
		 x += 2;
		 
        if (size > 0){
            field[y][x]++;
            field[y - 1][x]++;
			field[y + 1][x]++;
            field[y][x + 1]++;
            field[y][x - 1]++;
            
        }
        if (size > 1){
            field[y - 1][x - 1]++;
            field[y + 1][x + 1]++;
            field[y - 1][x + 1]++;
            field[y + 1][x - 1]++;
        }
        if (size > 2){
            field[y - 2][x]++;
            field[y + 2][x]++;
            field[y][x - 2]++;
            field[y][x + 2]++;
        }
    }
     
    for (int i = 2; i < 12; i++){
        for (int j = 2; j < 12; j++){
			
			if (field[i][j] == 0){
                sum++;
            }
            if (field[i][j] > max){
                max = field[i][j];
            }
        }
    }
	
	printf("%d\n%d\n", sum, max);
	
    return (0);
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    map<int,int> f,b;
    set<int> diff;

    vector<int> ans;
    rep(i,n){
        ++f[a[i]];
        ++b[a[n-1-i]];

        for(int v:{a[i], a[n-1-i]}){
            if(f[v] == b[v]) diff.erase(v);
            else diff.insert(v);
        }

        if(diff.empty()) ans.pb(i+1);
    }

    int A = ans.size();
    rep(i,A) cout << ans[i] << " \n"[i==A-1];
    return 0;
}



Measured memory_bytes: 8880
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int n,m;
string u[300],t[300];
string s;

int main() {
	cout << fixed << setprecision(18);
	cin>>n;
	
	while(n!=0){
		bool UP=true,RUP=false,LUP=false;
		long long int res=0;
		for(int i=0;i<n;i++){
			cin>>s;
			if(s[0]=='r'){RUP=!RUP;}
			else{LUP=!LUP;}
			if(UP==RUP&&UP==LUP){UP=!UP;res++;}
		}
		cout<<res<<endl;
		cin>>n;
	}
} 


Measured memory_bytes: 3104
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 1000000007;
// constexpr int MOD = 998244353;
constexpr int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
constexpr int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

struct UnionFind {
  UnionFind(int n) : data(n, -1) {}

  int root(int ver) { return data[ver] < 0 ? ver : data[ver] = root(data[ver]); }

  bool unite(int u, int v) {
    u = root(u);
    v = root(v);
    if (u == v) return false;
    if (data[u] > data[v]) std::swap(u, v);
    data[u] += data[v];
    data[v] = u;
    return true;
  }

  bool same(int u, int v) { return root(u) == root(v); }

  int size(int ver) { return -data[root(ver)]; }

private:
  std::vector<int> data;
};

int main() {
  int n, m; cin >> n >> m;
  UnionFind uf(n);
  int rem = n - 1;
  while (m--) {
    int a, b; cin >> a >> b; --a; --b;
    rem -= uf.unite(a, b);
  }
  cout << rem << '\n';
  return 0;
}


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

namespace Atc_0028
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();

            int r = int.Parse(str.Split(' ')[0]);
            int D = int.Parse(str.Split(' ')[1]);
            int x = int.Parse(str.Split(' ')[2]);

            int result = r * x - D;
            int index = 0;

            while (index < 10)
            {
                Console.WriteLine(result);

                result = result * r - D;

                index++;
            }
        }
    }
}


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

int ins, a, b, da;
string s;

signed main() {

    int n;
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> s;
        bool flg = false;
        if ( s[0] == 'B' ) {
            b++;
            flg = true;
        }
        if ( s[s.size()-1] == 'A' ) {
            a++;
            if ( flg ) da++;
        }
        for ( int j = 1; j < s.size(); j++ ) {
            if ( s[j-1] == 'A' && s[j] == 'B' ) ins++;
        }
    }
    if ( da ) {
        if ( a-da > 0 && b-da > 0 ) {
            cout << ins + min(a, b) << endl;
        }
        else if ( a-da > 0 || b-da > 0 ){
            cout << ins + da << endl;
        }
        else {
            cout << ins + da - 1 << endl;
        }
    }
    else {
        cout << (ins+min(a, b)) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*
 * Author : Sadi
 * Sat 27/06/2020
 * 14:09:42.49
 */
#include <bits/stdc++.h>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif

    int n;
    cin >> n;
    for(int i = 0; i <= n / 4; ++i) {
        for(int j = 0; j <= n / 7; ++j) {
            if(4 * i + 7 * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3656
#66 成績

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


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

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

	for(int A = 1; A < 10; A++) {
		if(N % A == 0) {
			int B = N / A;
			if(1 <= B && B <= 9) {
				cout << "Yes";
				return 0;
			}
		}
	}

	cout << "No";
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;



int main(){
    //重心（W/2.H/2）を通る直線は長方形を似等分する
    //どんな点（ｘ，ｙ）もその点と重心を通る直線を引ける。
    //よって2等分が答えで、（ｘ，ｙ）が重心なら１そうでないなら０

    ll w,h,x,y;

    cin>>w>>h>>x>>y;


    int ans;
    if(x==0.5*w&&y==0.5*h)ans=1;
    else ans=0;
    
    printf("%.10f %d", (w*h)*0.5, ans);
    //答えが10^18超え

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <string>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    int k=1;
    int c=0;
    
    while(1){
        k -= 1;
        k += a;
        c++;
        if(k>=b){
            break;
        }
    }
    if(b==1){
        cout<<0<<endl;
    }else{
        cout<<c<<endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列
// #include "boost/multi_array.hpp"

//名前空間
using namespace std;
typedef long long ll;

//マクロ
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)  //range(a, b, 1)と対応 aからb回iter
#define FORD(i, a, b) for (ll i = (a); i > (b); i--) //range(a, b, -1)と対応 aからb回iter
#define REP(i, b) FOR(i, 0, b)
#define REPD(i, a) FOR(i, a, 0)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)
#define CC(x) cout << (x) << endl

signed main()
{
    int N, M, a = 0, tmp = 0;
    cin >> N >> M;
    //cout << N << M << endl;
    REP(i, M)
    {
        cin >> tmp;
        a += tmp;
    }
    if (N - a < 0)
        cout << -1 << endl;
    else
        CC(N - a);
}


Measured memory_bytes: 3624
import java.util.Scanner;


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

	public Main() {
		new AOJ1125().main();
	}
	
	class AOJ1125{
		int n,w,h,plusX,plusY;
		boolean[][] map;
		void main(){
			while(true){
				n = in.nextInt();
				if(n==0)break;
				w = in.nextInt();
				h = in.nextInt();
				map = new boolean[h][w];
				for(int i=0;i<n;i++){
					int x = in.nextInt()-1;
					int y = in.nextInt()-1;
					map[y][x] = true;
				}
				plusX = in.nextInt(); plusY = in.nextInt();
//				print();
				doIt();
			}
		}
		
		void doIt(){
			int max = -1;
			for(int y=0;y<h;y++)for(int x=0;x<w;x++){
				int c = count(x, y);
				max = Math.max(max, c);
			}
			System.out.println(max);
		}
		
		int count(int x,int y){
			int result = 0;
			if(x+plusX > w || y+plusY > h)return -1;
			for(int i=x;i<x+plusX;i++)for(int s=y;s<y+plusY;s++)if(map[s][i])result++;
			return result;
		}
		
		void print(){
			System.out.println();
			for(int i=0;i<h;i++){
				for(int s=0;s<w;s++)System.out.print(map[i][s]? '*':'.');
				System.out.println();
			}
		}
		
	}
	
}

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

inline void my_swap(int &a, int &b)
{
  int tmp = a;
  a = b;
  b = tmp;
}

int main(void)
{
  int a, b, c;

  cin >> a >> b >> c;
  my_swap(a, b);
  my_swap(a, c);
  cout << a << " " << b << " " << c << endl;

  return 0;
}

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

int main() {
  string N;
  cin >> N;

  int t = N.size();
  int ans = 0;
  bool kuri = false;
  for(int i = t - 1; i >= 0; i--){
    int c; c = N[i] - '0';
    if(kuri) c++;
    if(c <= 4) {
      ans += c;
      kuri = false;
    }else if(c == 5){
      ans += c;
      if(i > 0 && N[i-1] - '0' >= 5){
        kuri = true;
      }else{
        kuri = false;
      }
    }else if(c <= 9) {
      ans += 10 - c;
      kuri = true;
    }else{
      kuri = true;
    }
  }

  if(kuri) ans++;

  cout << ans << endl;
}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int n; cin>>n;
  ll sum=0;
  rep(i,n){
    int a; cin>>a;
    int k=0;
    while(a%2==0){
      a/=2;k++;
    }
    sum+=k;
  }
  cout<<sum<<endl;

  return 0;
}


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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  const int dx = tx - sx, dy = ty - sy;

  // print string(how many, what)
  cout << string(dy, 'U') << string(dx, 'R');  // path 1 (s->t)
  cout << string(dy, 'D') << string(dx, 'L');  // path 2 (t->s)
  cout << 'L' << string(dy+1, 'U') << string(dx+1, 'R') << 'D';  // path 3 (s->t)
  cout << 'R' << string(dy+1, 'D') << string(dx+1, 'L') << 'U';  // path 4 (t->s)
  cout << endl;
}

Measured memory_bytes: 3604
def ncr(n,r):
    g = 1
    for i in range(1,r+1):
        g*=(n-r+i)
        g//=i
    return g
n,a,b= map(int,input().split())
nv = sorted(list(map(int,input().split())),reverse=True)
print(sum(nv[:a])/a)
ndica = {}
ndicfull = {}
conti = 0
fnv=nv[0]
for i,temp in enumerate(nv):
    if i<a:ndica[temp] = ndica.get(temp,0) + 1
    ndicfull[temp] = ndicfull.get(temp,0) + 1
    if temp==fnv:conti=i+1
if fnv == nv[a-1]:
    subb = min(conti,b)
    g=0
    for t in range(a,subb+1):g+=ncr(conti,t)
    print(g)
else:
    if ndicfull[nv[a-1]]==1:print(1)
    else:print(ncr(ndicfull[nv[a-1]],ndica[nv[a-1]]))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define int long long
using namespace std;
int N,A[200100];
signed main(){
  cin>>N;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    A[a]=i;
  }
  A[0]=N;
  A[N+1]=-1;
  int ans=0,cnt=0;
  for(int i=1;i<=N+1;i++){
    if(A[i]<A[i-1])ans=max(ans,cnt),cnt=1;
    else cnt++;
  }
  cout<<N-ans<<endl;
}

Measured memory_bytes: 5208
#include<bits/stdc++.h>
using namespace std;
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define faster() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const long long int infLL = 9000000000000000000;
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(a) (a).begin(),(a).end()
#define mx_int_prime 999999937
const int inf = 2000000000;
const double PI = acos(-1);
const double eps = 1e-9;
typedef long double ld;
#define MOD 1000000007
typedef long long ll;
const int mx=2e5+125;
ll p[mx],a[mx],b[mx];
#define PB push_back
#define endl '\n'
#define S second
#define F first
int main()
{
    faster();
    string s;
    cin>>s;
    int len=s.size();
    for(int i=0; i<len; i++ )
        cout<<"x";
    cout<<endl;
    return  0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  string s; cin >> s;
  ll K; cin >> K;

  //文字cから何回操作を行えば'a'にできるか
  auto d = [=](char c){
    return (26-(c-'a'))%26;
  };
  ll n = SZ(s);
  REP(i,n){
    if(i==n-1){
      if(d(s[i]) > K) s[i] = char(s[i]+K); 
      else{
        ll t = (K-d(s[i]))%26;
        s[i] = (char)('a'+t);
      }
    }else if(d(s[i]) <= K){
      K -= d(s[i]);
      s[i] = 'a';
    }
  }
  cout << s << endl;
}



Measured memory_bytes: 512
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var a = int.Parse(_[0]);
            var b = int.Parse(_[1]);
            var c = int.Parse(_[2]);

            Console.WriteLine(a + b >= c ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 666666
vector<int> v[N];
int sum;
void dfs(int u,int fa,int s){
	sum++;
	if(!s) return ;
	for(int i=0;i<v[u].size();i++){
		if(v[u][i]==fa) continue;
		dfs(v[u][i],u,s-1);
	}
}
signed main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<n;i++){
		int a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int ans=0;
	if(k%2==0){
		for(int i=1;i<=n;i++){
			sum=0;
			dfs(i,-1,k/2);
			ans=max(ans,sum);
		}
	}else{
		for(int i=1;i<=n;i++){
			for(int j=0;j<v[i].size();j++){
				sum=0;
				dfs(i,v[i][j],k/2);
				dfs(v[i][j],i,k/2);
				ans=max(ans,sum);
			}
		}
	}
	cout<<n-ans;
	return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;
typedef long long ll;
static const int MAX = 200000; 
//pi = 3.14159265358979323846

int main(){
string s;
cin >> s;
rep(i, 3){
  if(s[i] == s[i + 1]){
    cout << "Bad" << endl;
    return 0;
  }
}
cout << "Good" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, ans;
    cin >> a >> b;
    if(a+b==3) ans=3;
    if(a+b==4) ans=2;
    if(a+b==5) ans=1;
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
import java.math.*;
import java.util.*;
  


public class Main {
	
	
	
	public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n=scan.nextInt(),m=scan.nextInt();
        int v[]=new int[m];
        for(int i=0;i<m;i++) { 
        	v[i]=scan.nextInt(); 	
        }
        int dp[]=new int[n+1];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0]=0;
        for(int i=0;i<m;i++) {
        	for(int j=v[i];j<=n;j++) {
        		dp[j]=Math.min(dp[j],dp[j-v[i]]+1);
        	}
        }
        System.out.println(dp[n]);
        
        
	}
	
	
	
}


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

using namespace std;

const int M=26;

int arr[404];
int n;
int c[26];
int s[404][26];
int las[26];

long long calc()
{
	for(int i=0;i<M;i++) las[i]=0;
	long long ans=0;
	for(int i=0;i<n;i++)
	{
		las[arr[i]-1]=i+1;
		ans+=s[i][arr[i]-1];
		for(int j=0;j<M;j++)
			ans-=c[j]*(i+1-las[j]);
		//cout << ans << endl;
	}
	return ans;
}

int main()
{
	//auto start = std::chrono::system_clock::now();
	mt19937 rng(12342);
	cin >> n;
	for(int i=0;i<M;i++) cin >> c[i];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<M;j++) cin >> s[i][j];
	}
	for(int i=0;i<n;i++)
	{
		long long res[M],los[M];
		long long suml=0;
		for(int j=0;j<M;j++)
		{
			los[j]=(i+1-las[j])*c[j];
			suml+=los[j];
		}
		for(int j=0;j<M;j++) res[j]=s[i][j]-(suml-los[j]);
		arr[i]=1;
		for(int j=1;j<M;j++) if(res[j]>res[arr[i]-1]) arr[i]=j+1;
		las[arr[i]-1]=i+1;
	}
	//std::chrono::duration<double> elp=std::chrono::system_clock::now()-start;
	int t=100000;
	long long curs=calc();
	while(t--)
	{
		int x=uniform_int_distribution<int>(0, n-1)(rng);
		int y=uniform_int_distribution<int>(0, M-1)(rng);
		int oldx=arr[x];
		arr[x]=y+1;
		if(calc()<curs)
		{
			arr[x]=oldx;
		}
	}
	for(int i=0;i<n;i++)
		cout << arr[i] << endl;
}

Measured memory_bytes: 3664
#include<stdio.h>
int main()
{
    int n,k,x,y;
    scanf("%d",&n);
    scanf("%d",&k);
    scanf("%d",&x);
    scanf("%d",&y);

    int ans;
    if ( n <= k ){
        ans = n * x;
    }else{
        ans = k * x + (n-k) * y;
    }
    printf("%d\n",ans);
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int s = 0;
    int t = n;
    while (t > 0) {
        s += t % 10;
        t /= 10;
    }
    cout << (n % s == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<cmath>
using namespace std;
#define MAX 100000010

int n;
void init(){
  n=0;
}

bool input(){
  cin>>n;
  return n;
}

string solve(){
  int ans=1;
  for(int i=2;i*i<n;i++){
    if(n%i==0){
      ans+=i+n/i;
    }
  }

  if(n==1)ans=0;
  if(ans==n){
    return "perfect number";
  }else if(ans<n){
    return "deficient number";
  }else if(ans>n){
    return "abundant number";
  }
}


int main(){
  while(init(),input()){
    cout<<solve()<<endl;
  }
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
bool odd(char ch)
{
    if(ch == 'R' || ch == 'U' || ch == 'D')
    {
        return true;
    }
    else
    {
        return false;
    }
}
bool even(char ch)
{
    if(ch == 'U' || ch == 'D' || ch == 'L')
    {
        return true;
    }
    else
    {
        return false;
    }
}
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int A[a+5] = {};
    for(int i = 1; i <= a; i++)
    {
        A[i] = b;
    }
    int B[a+5] = {};
    for(int i = 1; i <= c; i++)
    {
        int tem;
        cin >> tem;
        B[tem]++;
    }
    for(int i = 1; i <= a; i++)
    {
        int ke = b - (c-B[i]);
        if(ke <= 0)
        {
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    int N, L;
    cin >> N >> L;
    vector<ll> A(N);
    rep(i, N) { cin >> A[i]; }

    bool judge = 0;
    int l, r;
    rep(i, N - 1) {
        if (A[i + 1] + A[i] >= L) {
            judge = 1;
            l = i;
            r = i + 1;
            break;
        }
    }

    if (!judge) {
        cout << "Impossible" << endl;
        return 0;
    }

    cout << "Possible" << endl;
    for (int i = 1; i <= l; i++) {
        cout << i << endl;
    }
    for (int i = N - 1; i > r; i--) {
        cout << i << endl;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 3992
#include <iostream>
#include <vector>
#include <functional>

using namespace std;

int main(){
    int N, Q;
    cin >> N >> Q;
    vector<vector<int>> V(N+1);

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

    vector<int> q(N+1);
    for(int i=0;i<Q;i++){
        int p, x;
        cin >> p >> x;
        q[p] += x;
    }

    vector<int> ans(N+1);
    //dfsに関数を保持
    //mはすでに訪れたnodeに行くのを防ぐ
    function<void(int ,int, int)> dfs = [&](int n, int m, int value){
        ans[n] = value + q[n];
        for(auto x:V[n]) if (x != m){
                dfs(x, n, ans[n]);
            }
    };

    dfs(1, 0, 0);
    for(int i=1;i<=N;i++) cout << ans[i] << (i != N ? " ":"\n");
}

Measured memory_bytes: 30464
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

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

  vector<int> l(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &l[i]);
  }

  int count = 0;
  int d = 0;
  for (int i = 0; i < n; i++) {
    d += l[i];
    if (d <= x) {
      count++;
    }
  }

  cout << count + 1 << endl;
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  std::string s, t;
  std::cin >> s >> t;
  for (size_t i = 0; i < s.size(); i++) {
    if (s[i] != t[i]) {
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}

Measured memory_bytes: 3580
// 2019/07/09 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

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

	int A[100002];
	A[0] = 0;
	for(int i=1; i<=N; i++){
		cin >> A[i];
	}
	A[N+1] = 0;
	N = N+2;

	int i2 = 1;
	for(int i=1; i<N; i++){
		if(A[i]==A[i2-1])
			continue;

		A[i2++] = A[i];
	}
	N = i2;

	if(N==1){
		cout << 0 << endl;
		return 0;
	}

	i2 = 0;
	for(int i=1; i<N-1; i++){
		if(A[i]-A[i-1]>0 && A[i+1]-A[i]>0)
			continue;
		if(A[i]-A[i-1]<0 && A[i+1]-A[i]<0)
			continue;

		A[i2++] = A[i];
	}
	N = i2;

	if(N==1){
		cout << 1 << endl;
		return 0;
	}

/*
	for(int i=0; i<N; i++){
		cout << A[i] << ' ';
	}
	cout << endl;
*/
	int N1 = 0;
	int N2 = 0;
	int A1[50000], A2[50000];
	for(int i=0; i<N; i++){
		if(i%2==0){
			A1[N1++] = A[i];
		}
		else{
			A2[N2++] = A[i];
		}
	}
	sort(A1, A1+N1);
	sort(A2, A2+N2);
/*
	for(int i=0; i<N1; i++){
		cout << A1[i] << ' ';
	}
	cout << endl;
	for(int i=0; i<N2; i++){
		cout << A2[i] << ' ';
	}
	cout << endl;
*/
	int I = 0;
	int I2 = 1;

	for(int i1=0, i2=0; i2<N2; ){
		if(A1[i1]<=A2[i2]){
			I2--;
			i1++;
		}
		else{
			I2++;
			i2++;
		}

		I = max(I, I2);
	}

	cout << I << endl;

	return 0;
}



Measured memory_bytes: 3828
#include <bits/stdc++.h>
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; }
 
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
 
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
 
const int MAX = 1000000;
const int MOD = 1000000007;
 
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll modPow(ll a, ll n, ll p) {
  if (n == 0) return 1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  ll t = modPow(a, n / 2, p);
  return (t * t) % p;
}
ll choose(ll n, ll r, ll mod){
    ll mul = 1, div = 1;
    for(ll i = 0; i < r; i++){
        mul *= n - i;
        div *= i + 1;
        mul %= mod;
        div %= mod;
    }   
    return mul * modPow(div, mod - 2, mod) % mod;
}
 
int main(){
  int n;
  cin >> n;
  vector<ll>a(n+10,mod);
  rep(i, 0, n)cin >> a[i];
  int i=0;
  int ans = -1;
  while(i<n){
    int temp = 0;
    while(a[i]>=a[i+1]){
      temp++;
      i++;
    }
    i++;
    ans = max(temp,ans);
  }
  cout << ans << endl;
}

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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

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

// 複素数雨セット
typedef complex<double> C;
// 内積
double dot(C a, C b){
    return a.real() * b.real() + a.imag() * b.imag();
}

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

    // input
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    C p1(x1, y1);
    C p2(x2, y2);
    C v = p2 - p1;
    C n = v / abs(v);

    ll Q; cin >> Q;
    while(Q--){
        ll x, y;
        cin >> x >> y;
        C p(x, y);

        auto v = p - p1;
        auto ans = p1 + dot(v, n) * n;
        cout << setprecision(20);
        cout << ans.real() << ' ' << ans.imag() << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3360
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        String lastWeek = sc.next();
        if(lastWeek.equals("ABC")){
            System.out.print("ARC");
        }else{
            System.out.print("ABC");
        }
    }

}


Measured memory_bytes: 35668
#include <cstdio>
int n, m, a, b, c[200005];
int main() {
	scanf("%d%d", &n, &m);
	while(m) {
		scanf("%d%d", &a, &b);
		if(a==1) c[b]++;
		if(b==n) c[a]++;
		if(c[a]==2 || c[b]==2) break;
		m--;
	}
	printf("%sPOSSIBLE", m ? "":"IM");
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define fin << '\n'
#define pb push_back
#define all(x) x.begin(), x.end()
#define rep( i, m, n ) for ( int i = m; i < n; ++i )
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

  int n; cin >> n;
  vector<pii> tasks;
  int a, b;

  for ( int i = 0; i < n; ++i ) {

    cin >> a >> b;

    tasks.pb(pii(b, a));

  }

  sort( all(tasks) );

  int sum = 0;
  bool isYes = true;

  for ( auto e : tasks ) {

    sum += e.second;

    if( sum > e.first ){
      isYes = false;
      break;
    }

  }

  if( isYes ) cout << "Yes" fin;
  else cout << "No" fin;

  return 0;
}

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

int main(){
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> ind(n);
    iota(ind.begin(),ind.end(),0);

    sort(ind.begin(),ind.end(),[&a](int i1,int i2) {
        return a[i1] < a[i2];
    });

    for(auto t : ind){
        cout << t+1 << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1536
import sys

input = sys.stdin.readline
d = {}
for _ in range(int(input())):
    s = input().replace("\n", "")
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

x = max(d.values())
l = sorted(s for (s, i) in d.items() if i == x)
print(*l, sep="\n")

Measured memory_bytes: 36580
def main():
    n,m = map(int,input().split())
    a,b = [], []
    for i in range(n):
        a.append(input())
    for i in range(m):
        b.append(input())
    for i in range(n-m+1):
        for j in range(n-m+1):
            a_ = []
            for k in range(m):
                a_.append(a[i+k][j:j+m])
            if a_==b:
                print('Yes')
                return
    print('No')

if __name__ == "__main__":
    main()


Measured memory_bytes: 9204
object Main extends App {
  var n = readInt
  var Hs = readLine.split(" ").map(_.toInt)
  var mins = Hs.scanRight(1000000007)(math.min(_,_))
  print(if(Range(0, n).map{t => if(Hs(t)-mins(t) > 1) 1 else 0}.sum > 0) "No" else "Yes")
}

Measured memory_bytes: 52692
use std::io;


fn main() {
    let (h, w) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    let mut vec = Vec::new();
    for _ in 0..h {
        let i = read::<String>();
        vec.push(i);
    }

    for i in 0..h { for j in 0..w {
        if vec[i][j] == "snuke" {
            println!("{}{}", ('A' as u8 + j as u8) as char, i + 1);
        }
    }}
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    int h,a;
    cin>>h>>a;
    int ans=0;
    if(h%a!=0){
        ans=1;
    }
    cout<<h/a+ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 1000

int S[MAX];
int top;
char s[MAX];

void initialize(void);
int isEmpty(void);
int isFull(void);
void push(int);
int pop(void);

int main()
{
  int a,b,x;
  char s[100];

  while( scanf("%s", s) != EOF )
  {
    if( s[0] == '+' )
    {
      a = pop();
      b = pop();
      push(a + b);
    } 
    else if( s[0] == '-' )
    {
      a = pop();
      b = pop();
      push(b - a);
    }
    else if( s[0] == '*' )
    {
      a = pop();
      b = pop();
      push(a * b);
    }
    else
    {
      x = atoi(s);
      push(x);
    }
  }

  printf("%d\n",pop());

  return 0;
}

void initialize()
{
  top = 0;
}

int isEmpty()
{
  if(top == 0)return 1;
  else return 0;
}

int isFull()
{
  if(top >= MAX - 1) return 1;
  else return 0;
}

void push(int x)
{
  if(isFull())
  {
    fprintf(stderr, "??¨?????????????????????????????????\n");
    exit(1);
  }
  else
  {
    top++;
    S[top]=x;
  }
}

int pop()
{
  if(isEmpty())
  {
    fprintf(stderr,"??¨???????????¢?????????????????????\n");
    exit(1);
  }
  else
  {
  top--;
  return S[top+1];
  }
}

Measured memory_bytes: 548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
const int P=1e9+7;
const int MAXN=1e6+10;
int fac[MAXN];
inline int add(int a,int b)
{
	return (a + b) % P;
}
inline int mul(int a,int b)
{
	return 1LL * a * b % P;
}
int fpow(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)
			res=mul(res,a);
		a=mul(a,a);
		b>>=1;
	}
	return res;
}
int inv(int x)
{
	return fpow(x,P-2);
}
int n,H,D,sf=0;
int f[MAXN],sum[MAXN];
int main()
{
	n=read(),H=read(),D=read();
	fac[0]=1;
	for(int i=1;i<=n;++i)
	{
		fac[i]=mul(fac[i-1],i);
		sf=add(sf,fac[i]);
	}
	f[0]=1,sum[0]=1;
	for(int i=1;i<=H;++i)
	{
		if(i-D-1>=0)
			f[i]=add(sum[i-1],P-sum[i-D-1]);
		else
			f[i]=sum[i-1];
		f[i]=mul(f[i],sf);
		sum[i]=add(sum[i-1],f[i]);
	}
	cout<<mul(mul(f[H],fac[n]),inv(sf))<<endl;
	return 0;
}

Measured memory_bytes: 12032
#include <iostream>
#include <cmath>
#include <string>
#include <utility>
using namespace std;
typedef long long int ll;

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

const ll INF = 1LL << 60;
const int MAX_N = 110;
const int MAX_V = 1000 * 100 + 100;

int N, W, w[MAX_N], v[MAX_N];

// dp[i][v]:最初のi個の品物で価値の総和v以上を達成するのに必要な重さの最小値
ll dp[MAX_N][MAX_V];

int main() {
  cin >> N >> W;
  for (int i = 0; i < N; i++) cin >> w[i] >> v[i];

  for (int i = 0; i <= N; i++)
    for (int j = 0; j < MAX_V; j++)
      dp[i][j] = INF;

  dp[0][0] = 0;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < MAX_V; j++) {
      chmin(dp[i+1][j], dp[i][max(j-v[i], 0)] + w[i]);
      chmin(dp[i+1][j], dp[i][j]);
    }
  }

  ll res;
  for (int i = 0; i < MAX_V; i++) {
    if (dp[N][i] > W) break;
    res = i;
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 80128
for i in range(5):
    s=0
    q=0
    n=int(input())
    if n==0:
        break
    n=1000-n
    if n>=500:
        n-=500
        s+=1
    if n>=100:
        q=n//100
        n-=100*q
        s+=q
    if n>=50:
        n-=50
        s+=1
    if n>=10:
        q=n//10
        n-=10*q
        s+=q
    if n>=5:
        n-=5
        s+=1
    if n>=1:
        q=n//1
        s+=q
    print(s)


Measured memory_bytes: 5588
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int pst1,pst2,pst3,ju1,ju2;
	int mpst,mju;
	cin>>pst1>>pst2>>pst3>>ju1>>ju2;

	mpst=min(pst1,pst2);
	mpst=min(mpst,pst3);
	mju =min(ju1,ju2);
	cout<<mpst+mju-50<<endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define pi  3.141592653589793238462643383279
#define int long long
#define ff first
#define ss second
#define endl '\n'
#define inf 21474836478965499999
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=(int)x; i<y; i++)
#define high_functioning_sociopath  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const unsigned int M = 1000000007;
/*------------------------------------- THE GAME IS ON ---------------------------------------------*/
void solve()
{
      int n,x,t;
      cin>>n>>x>>t;
      int tim=(n/x)*t;
      if(n%x)tim+=t;
      cout<<tim<<endl;
}       
int32_t main()
{
   high_functioning_sociopath
   ll t=1;
   //cin>>t;
   while(t--)
   {
      solve();
   }
}

Measured memory_bytes: 3620
from bisect import insort_left, bisect_left
n = int(input())
s = list(input())
Q = int(input())
query = [input() for _ in range(Q)]
dic = {chr(i+ord('a')):[] for i in range(26)}
for ind, c in enumerate(s):
    dic[c].append(ind)

for q in query:
    t, a, b = q.split()
    a = int(a)-1
    if t=='1':
        if s[a]==b:
            continue
        ind = bisect_left(dic[s[a]], a)
        dic[s[a]].pop(ind)
        insort_left(dic[b], a)
        s[a] = b
    else:
        b = int(b)-1
        tmp = 0
        for li in dic.values():
            if li and a<=li[-1] and li[bisect_left(li, a)] <= b:
                tmp += 1
        print(tmp)


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

int main() {
	int N;
	cin >> N;
	for (int i = 1; ; i++) {
		if (floor(i * 1.08) == N) {
			cout << i << endl;
			break;
		} else if (i*1.08 > N) {
			cout << ":(" << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
li = list(map(int,input().split()))
se = set(li)
if len(se) == 1:
    if sum(se) == 0:
        print('Yes')
    else:
        print('No')
elif len(se) == 2:
    a,b = sorted(se)
    if a == 0:
        if li.count(a) * 3 == n:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
elif len(se) == 3:
    a,b,c = se
    if li.count(a) == li.count(b) == li.count(c):
        if a^b == c:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')


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

int main()
{
	int64_t h;
	cin >> h;

	if (h == 1)
	{
		cout << 1 << endl;
		return 0;
	}

	unordered_map<int64_t, int64_t> mp;

	auto f = [](auto &g, int64_t x, auto &mp) -> int64_t {
		if (x == 1)
		{
			return 1;
		}

		if (0 < mp[x])
		{
			return mp[x];
		}

		return mp[x] = 1 + 2 * g(g, x / 2, mp);
	};

	f(f, h, mp);

	cout << mp[h] << endl;

	return 0;
}

Measured memory_bytes: 256
import operator as op

def main():
	N   = int(input())
	abc = [tuple(map(int, input().split())) for _ in range(N)]

	a = list( map(op.itemgetter(0), abc) )
	b = list( map(op.itemgetter(1), abc) )
	c = list( map(op.itemgetter(2), abc) )

	dp = [[0 for _ in range(3)] for _ in range(N)]
	dp[0][0] = a[0]
	dp[0][1] = b[0]
	dp[0][2] = c[0]
	for i in range(1, N):
		dp[i][0] = max(a[i] + dp[i-1][1], a[i] + dp[i-1][2])
		dp[i][1] = max(b[i] + dp[i-1][0], b[i] + dp[i-1][2])
		dp[i][2] = max(c[i] + dp[i-1][0], c[i] + dp[i-1][1])

	print(max(dp[N-1]))
	return

main()



Measured memory_bytes: 44116
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
void dfs(vector< vector< int > > &F, vector< int > &done, set< int > &s, int x) {
	done[x] = 1;
	s.insert(x);
	for (auto j : F[x]) {
		if (done[j])
			continue;
		dfs(F, done, s, j);
	}
}
signed main() {
	cin >> N >> M >> K;
	vector< vector< int > > F(N);
	rep(i, M) {
		int A, B;
		cin >> A >> B;
		--A;
		--B;
		F[A].push_back(B);
		F[B].push_back(A);
	}
	vector< vector< int > > B(N);
	rep(i, K) {
		int C, D;
		cin >> C >> D;
		--C;
		--D;
		B[C].push_back(D);
		B[D].push_back(C);
	}
	vector< int > done(N);
	vector< int > ans(N, 0);
	rep(i, N) if (!done[i]) {
		set< int > s;
		dfs(F, done, s, i);
		for (auto j : s) {
			ans[j] = s.size() - F[j].size() - 1;
			for (auto k : B[j]) {
				if (s.find(k) != s.end())
					ans[j]--;
			}
		}
	}
	rep(i, N) cout << ans[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 19328
import sys

def gcd(a, b):
      a, b = max(a, b), min(a, b)
      while a % b > 0:
            a, b = b, a % b
      return b

def solve():
      input = sys.stdin.readline
      N = int(input())
      A = [int(a) for a in input().split()]
      L = max(A)
      count = [0] * (L + 1)
      isPrime = [False] * (L + 1)
      gcdA = A[0]
      for a in A[1:]:
            gcdA = gcd(gcdA, a)
            count[a] += 1
      if gcdA > 1:
            print("not coprime")
            return 0
      
      for i in range(2, L + 1):
            if not isPrime[i]:
                  c = 0
                  k = i
                  while k <= L:
                        isPrime[i] = True
                        c += count[k]
                        k += i
                  if c > 1:
                        print("setwise coprime")
                        return 0
      print("pairwise coprime")
      return 0

if __name__ == "__main__":
      solve()

Measured memory_bytes: 208720