akhauriyash/Code-Regression huggingface dataset:
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Numerics;

namespace AtCoder
{
    class Program
    {

        const int BiggestMod = 1000000007;
        public static void Main()
        {

            var haveA = int.Parse(Console.ReadLine());
            var haveB = int.Parse(Console.ReadLine());
            var haveC = int.Parse(Console.ReadLine());
            var X = int.Parse(Console.ReadLine());
            var maxA = (X / 500);
            var ans = 0;
            if (haveA < maxA) maxA = haveA;
            maxA *= 500;

            for (int i = 0; i <= maxA; i += 500)
            {

                var maxB = ((X - i) / 100);
                if (haveB < maxB) maxB = haveB;
                maxB *= 100;

                for (int j = 0; j <= maxB; j += 100)
                    if (haveC >= ((X - (i + j)) / 50))
                        ans++;

            }

            Console.WriteLine(ans);

        }

    }

}


Measured memory_bytes: 11092
class in{struct myIterator{int it;const bool rev;explicit constexpr myIterator(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(myIterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const myIterator i,n;public:explicit constexpr in(int n):i(0),n(n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const myIterator& begin(){return i;}const myIterator& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n, m, k; cin >> n >> m >> k;
    vector<vector<pii>> adj(n + 1);
    for(int _ : in(m)) {
        int u, v, c;
        cin >> u >> v >> c;
        adj[u].emplace_back(v, c);
        adj[v].emplace_back(u, c);
    }
    for(int _ : in(k)) {
        int s;
        cin >> s;
        adj[0].emplace_back(s, 0);
    }
    priority_queue<pii, vector<pii>, greater<pii>> que;
    que.emplace(0, 0);
    vector<int> dist(n + 1, 1e9);
    dist[0] = 0;
    while(!que.empty()) {
        int curV, curD;
        tie(curD, curV) = que.top(); que.pop();
        if(dist[curV] < curD) continue;
        for(const auto& e : adj[curV]) {
            int to, cost;
            tie(to, cost) = e;
            if(dist[to] > curD + cost) {
                dist[to] = curD + cost;
                que.emplace(dist[to], to);
            }
        }
    }
    int ans = 0;
    for(int u : in(1, n + 1)) {
        int tmp = dist[u];
        for(const auto& e : adj[u]) {
            int v, c; tie(v, c) = e;
            int dis = dist[u] + dist[v] + c;
            dis = (dis & 1) ? dis / 2 + 1 : dis / 2;
            tmp = max(tmp, dis);
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6064
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        String target=scan.next();
        String s;
        int ans=0;
        while(true){
            s=scan.next();
            if(s.equals("END_OF_TEXT")){
                break;
            }
            else{
                if(s.equalsIgnoreCase(target)){
                    ans++;
                }
            }
        }
        System.out.println(ans);
        scan.close();
    }
}

Measured memory_bytes: 26164
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
 
class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
 
 
    void solve()
    {
        var S = cin.next;
        for (int i = 0; i < S.Length - 1; i++)
        {
            if (S[i] == 'A' && S[i + 1] == 'C')
            {
                WriteLine("Yes");
                return;
            }
        }
        WriteLine("No");
    }
 
}
 
class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

using namespace std;
using Graph = vector<vector<pair<int, int>>>;

// field.assign(H, vector<int>(W, 0));
int N;
bool visited[100005];
bool setcolor[100005];

void dfs(const Graph &G, int v, bool is_white) {
    visited[v] = true;
    setcolor[v] = is_white;
    for (auto edge : G[v]) {
        int next_v = edge.first;
        int weitht = edge.second;
        if (visited[next_v]) continue;
        bool color = weitht & 1 ? !is_white : is_white;
        dfs(G, edge.first, color);
    }
}

void solve() {
    cin >> N;
    Graph G(N);
    memset(visited, 0, sizeof(visited));
    for (int i = 0; i < N - 1; ++i) {
        int u, v, w;
        cin >> u >> v >> w;
        u -= 1;
        v -= 1;
        G[u].push_back(make_pair(v, w));
        G[v].push_back(make_pair(u, w));
    }

    dfs(G, 0, true);
    // 頂点0を白
    // 全域木だからdfsは1回

    for (int i = 0; i < N; ++i)
        cout << (setcolor[i] ? 0 : 1) << endl;
}


int main() {
    solve();
}

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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    ll n;
    cin >> n;
    string res = "";
    do{
        n--;
        res = string(1, 'a' + n % 26) + res;
        n /= 26;
    }while(n);
    cout << res;
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,a,b; cin>>n>>a>>b;
	if (n*a<=b) cout<<(n*a);
	else cout<<b<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT
 
using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;
 
template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
 
int n;
int m;

string s[300];
 
int main () {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> s[i];
    int ans = 0;
    for (int b = 0; b < n; b++) {
        int ok = 1;
        for (int i = 0; i < n && ok; i++)
            for (int j = i + 1; j < n && ok; j++)
                ok &= int (s[i][(j + b) % n] == s[j][(i + b) % n]);
        ans += ok * n;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int N,M;
vector<vector<int> > G(101010);
int color[101010];

bool dfs(int v, int c){
  color[v]=c;
  bool res=1;
  for(int u:G[v]){
    if(color[u]==-1) res&=dfs(u,(c+1)%2);
    else if(color[u]==c) res=0;
  }
  return res;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  cin>>N>>M;
  rep(i,M){
    int u,v; cin>>u>>v; u--,v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  rep(i,N) color[i]=-1;
  int koritu=0,nibu=0,kihei=0;
  rep(i,N) if(color[i]==-1){
    if(G[i].size()==0) koritu++;
    else{
      if(dfs(i,0)) nibu++;
      else kihei++;
    }
  }
  ll ans=0;
  ans+=1LL*koritu*koritu;
  ans+=2LL*koritu*(N-koritu);
  ans+=2LL*nibu*nibu;
  ans+=1LL*kihei*kihei;
  ans+=2LL*kihei*nibu;
  cout<<ans<<endl;
  return 0;
}


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

int main () {
  string s;
  cin >> s;
  int aindex, zindex;
  
  for (int i = 0; i < s.size() - 1; i++) {
    if (s.at(i) == 'A')  {
      aindex = i + 1;
      break;
    }
  }
  
  reverse(s.begin(), s.end());
  for (int i = 0; i < s.size() - 1; i++) {
    if (s.at(i) == 'Z')  {
      zindex = i + 1;
      break;
    }
  }
//  cout << aindex << endl;
//  cout << zindex << endl;
  cout << (s.size() - zindex + 1) - aindex + 1 << endl;
  
}

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

int main()
{
    int S;

    cin >> S;

    int h, m, s;

    h = S / 3600;
    
    m = (S - 3600 * h) / 60;
    
    s = S - 3600 * h - 60 * m;

    cout << h << ":" << m << ":" << s << endl;

    return 0;
}


Measured memory_bytes: 3100
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int i = stdIn.nextInt();
		for (int n = 1; i != 0; n++) {
			System.out.println("Case " + n + ": " + i);
			i = stdIn.nextInt();
		}
	}
}

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


int main() {
    int n; cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++){
           cin >> v[i];
    }
    
    vector<int> left(n);
    int left_sum =0;
    for(int i = 0; i < n; i++){
           left_sum += v[i];
           left[i] = left_sum;
    }
    
    vector<int> right(n);
    int right_sum  = 0;
    for (int i = n-1; i >=0; i--){
         right_sum += v[i];
         right[i] = right_sum;
    }
    
    vector<int> ans(n);
    for(int i =0; i < n; i++){
           ans[i] = abs(left[i] - right[i]) - v[i];
    }
    
    int jill = INT_MAX;
    for(int i =0; i < n; i++){
           if(ans[i]>=0)
           jill = min(jill, ans[i]);
    }
    
    cout << jill;
return 0;
}









  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
using namespace std;
using ll = long long;

int main(void) {
    string x;
    cin >> x;

    stack<char> st;

    int cnt = 0;
    rep (i, x.size()) {
        if (st.empty()) {
            if (x[i] == 'S') {
                st.push('S');
            }
            else cnt++;
        }
        else {
            if (x[i] == 'S') {
                st.push('S');
            }
            else st.pop();
        }
    }  
    
    cout << cnt + st.size() << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string.h>

int main(void){
int N,A,B;
scanf("%d %d %d",&N,&A,&B);
int max,min,a;

if(A+B<N){
if(A<B){
  max=A;
}else{
  max=B;
};
  min=0;
}else{
  if(A<B){
    max=A;
    min=A+B-N;
  }else{
    max=B;
    min=A+B-N;

  };
};
  printf("%d %d",max,min);

  return 0;
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int len = s.length();
    //cout << len << endl;
    int lenS = len - 2;
    cout << s[0] << lenS << s[len-1] << endl;

    return 0;
}


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

int main(void)
{
	long int i, j;
	long int n, k;
	long int a[100][100];
	long int count[100] = {0};
	long int work;
	long int flg = 0;
	long int ans = 0;
	char str[10];
	
	scanf("%s", str);
	
	if(str[1] == 'B') {
		printf("ARC\n");
	} else {
		printf("ABC\n");
	}
	
	return 0;
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
using Graph = vector<vector<int>>;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

/*
!) 0-indexed
!) [a, b)に対する演算
!) merge, updateNodeを書く
*/
template<typename Monoid>
struct Segtree{
    int n;
    vector<Monoid> dat;
    Monoid m0; // データの初期化値
    Segtree(int sz, Monoid m0) : m0(m0){
        n = 1;
        while(n < sz) n *= 2;
        dat.assign(2*n-1, m0);
    }

    Monoid merge(Monoid a, Monoid b){ return min(a,b); }
    void updateNode(int k, Monoid x){ dat[k] = x; }

    void update(int k, Monoid x){
        k += n-1;
        updateNode(k, x);
        while(k > 0) {
            k = (k-1)/2;
            dat[k] = merge(dat[k*2+1], dat[k*2+2]);
        }
    }
    Monoid query(int a, int b){
        Monoid L = m0, R = m0;
        int A = a+n-1;
        int B = b+n-1;
        while(A < B) {
            if((A&1) == 0) L = merge(L, dat[A++]);
            if((B&1) == 0) R = merge(dat[--B], R);
            A >>= 1;
            B >>= 1;
        }
        return merge(L, R);
    }
    Monoid operator[](const int &k) const { return dat[k+n-1]; }
};

int main(){
    fastcin();

    int n;
    cin >> n;
    vector<pair<LL, LL>> a(n);
    LL lm = 0, rm = 1000000000;
    rep(i, n){
        cin >>a[i].first >> a[i].second;
        chmax(lm, a[i].first);
        chmin(rm,a[i].second);
    }
    sort(all(a));
    Segtree<LL> seg(n, 1000000000000000);
    rep(i, n) seg.update(i, a[i].second);

    LL ans = 0;
    rep(i, n){
        chmax(ans, a[i].second-a[i].first+1 + max(0LL, rm-lm+1));
    }
    rep1(i, n){
        // cout << seg.query(0,i) << ":"<< a[i-1].first << " " << seg.query(i,n) <<":"<<a[n-1].first << endl;
        chmax(ans, max(0LL, seg.query(0,i)-a[i-1].first+1)+max(0LL, seg.query(i,n)-a[n-1].first+1));
    }
    cout << ans << endl;


}



Measured memory_bytes: 3840
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,k = readInts()
a = readInts()


t = a[0]

for i in range(k,n):
	be = a[i-k]
	af = a[i]
	#print(base)
	if be>=af:
		print("No")
	else:
		print("Yes")



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

pair<int,int> a[60];
pair<int,int> b[60];

#define INF 1000000000

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

    int n,m;cin>>n>>m;

    for(int i=0;i<n;i++)
    {
        int ia,ib;cin>>ia>>ib;
        a[i]=make_pair(ia,ib);
    }

    for(int i=0;i<m;i++)
    {
        int ic,id;cin>>ic>>id;
        b[i]=make_pair(ic,id);
    }

    int ans[60];

    for(int i=0;i<n;i++)
    {
        int dis=INF;
        for(int j=0;j<m;j++)
        {
            int d=abs(a[i].first-b[j].first)+abs(a[i].second-b[j].second);
            if(dis>d)
            {
                dis=d;
                ans[i]=j+1;
            }
        }
    }

    for(int i=0;i<n;i++)cout<<ans[i]<<"\n";

    return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

const int MAX_N = 100000;
int N;
int a[MAX_N];

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

  cin >> N;
  rep(i,N) cin>> a[i];
  sort(a, a+N);
  
  int ans = 0;
  int count = 1;
  for (int i = 0; i < N; ++i) {
    if (i+1 == N || a[i] != a[i+1]) {
      if (a[i] <= count) ans += count-a[i];
      else ans += count;
      count = 1;
      continue;
    }
    ++count;
  }

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


Measured memory_bytes: 888
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <iomanip>
#include <queue>
#include <string>
#include <map>
#include <fstream>
#include <cassert>
#include <stack>
#include <climits>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <memory>
#include <functional>
#include <cfloat>
#include <numeric>

#include <atcoder/mincostflow>
struct Coordinate {
	int x, y;
	std::vector<Coordinate> neighbor() const {
		return { Coordinate{x + 1, y}, Coordinate{x - 1, y}, Coordinate{x, y + 1}, Coordinate{x, y - 1} };
	}
};
int main() {
	int n, k; std::cin >> n >> k;
	std::vector<std::vector<long long int>> cost(n, std::vector<long long int>(n));
	for (auto& line : cost) for (auto& cell : line) std::cin >> cell;
	long long int max_cost{ 0 };
	for (const auto& line : cost) for (const auto& cell : line) max_cost = std::max(max_cost, cell);
	atcoder::mcf_graph<int, long long int> graph(n + n + 2);
	for (auto i = 0; i < n; ++i) {
		graph.add_edge(n << 1, i, k, 0);
		graph.add_edge(i + n, (n << 1) + 1, k, 0);
		for (auto j = 0; j < n; ++j) {
			graph.add_edge(i, j + n, 1, max_cost - cost[i][j]);
		}
	}
	auto copy = graph;
	const auto slope = graph.slope(n << 1, (n << 1) + 1);
	int max_flow = slope.back().first;
	for (auto i = 1; i < slope.size(); ++i) {
		const auto flow_diff = slope[i].first - slope[i - 1].first;
		const auto cost_diff = slope[i].second - slope[i - 1].second;
		if (max_cost * flow_diff < cost_diff) {
			max_flow = slope[i - 1].first;
			break;
		}
	}
	std::vector<std::string> result(n, std::string(n, '.'));
	const auto flow = copy.flow(n << 1, (n << 1) + 1, max_flow);
	for (const auto e : copy.edges()) {
		if (e.from >= n || e.to >= n + n) continue;
		if (e.flow == 0) continue;
		const auto r = e.from;
		const auto c = e.to - n;
		result[r][c] = 'X';
	}
	std::cout << flow.first * max_cost - flow.second << '\n';
	for (const auto& line : result) {
		std::cout << line << '\n';
	}
}


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

using namespace std;
int a[100005];
long long int fun(int n)
{
    long long int a,b=1,c;
    a=2;
    c=1000000007;
    while(n)
    {
        if(n%2==1) b=b*a%c;
        a=a*a%c;
        n/=2;
    }
    return b;
}
int main()
{
    int i,j,m,n,flag=1;
    long long int x;
    cin >> n;
    for(i=1;i<=n;i++)
    {
        cin >> m;
        a[m]++;
    }
    if(n%2==0)
    {
        for(i=1;i<=n-1;i+=2)
        {
            if(a[i]!=2)
            {
                flag=0;
            }
        }
        if(flag==0)
        {
            cout << 0 << endl;
        }
        else
        {
            x=fun(n/2);
            cout << x << endl;
        }
    }
    else if(a[0]==1)
    {
        for(i=2;i<=n-1;i+=2)
        {
            if(a[i]!=2)
            {
                flag=0;
            }
        }
        if(flag==0)
        {
            cout << 0 << endl;
        }
        else
        {
            x=fun(n/2);
            cout << x << endl;
        }
    }
    else
    {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 
 
#define PI 3.14159265
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
const ll limit = 2e9;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};
 
//const int mod = 998244353;
 
struct dsu{
	int parent[N];
	int cont;
	void make_set(int n){
		for(int i = 1; i <= n; i++)
			parent[i] = i;
		cont = n;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a); 
		b = find_set(b);	
		if(a != b){
			parent[b] = a;
			cont--;
		}
	}	
};


//~ map<int,int> h;
//~ int dp[2007];
//~ vector <int> arraySort(vector <int> v) {
	//~ vector<int> ans;
	//~ for(int i = 1; i <= (int)v.size(); i++){
		//~ dp[i] = 1;
	//~ }
	
	//~ for(int i = 1; i <= (int)v.size(); i++){
		//~ for(int j = 1; j < i; j++){
			//~ if(v[j-1] <= v[i-1]){ 
				//~ if(dp[i] < dp[j] + 1){
					//~ dp[i] = dp[j] + 1;
					//~ h[i] = j;
				//~ }
				//~ else if(dp[i] == dp[j] + 1){					
					//~ int index = h[i];
					//~ int val = v[index-1];
					//~ if(v[j-1] < val){
						//~ h[i] = j;
					//~ }
				//~ }
			//~ }
		//~ }
	//~ }
	//~ int index, maxi = 0, minval = inf;
	//~ for(int i = 1; i <= (int)v.size(); i++){
		//~ if(maxi <= dp[i] ){
			//~ maxi = dp[i];
		//~ }
	//~ } 
	
	//~ for(int i = 1; i<= (int)v.size(); i++){
		//~ if(maxi == dp[i]){
			//~ if(minval > v[i-1]){
				//~ minval = v[i-1];
				//~ index = i;
			//~ }
		//~ }
	//~ }
	
	//~ cout<<minval<<" "<<index<<endl;
	
	//~ int next = index;
	
	//~ while(next){
		//~ cout<<next<<" ";
		//~ next = h[next];
	//~ }
	//~ return ans;
//~ }

int v[4];
int main(){
	vector<char> v;
	bool reverted = false;
	int cont = 0;
	string s; cin>> s;
	for(char c: s)
		v.push_back(c);
	int q, t; cin>> q;
	while(q--){
		cin >> t;
		if(t == 1){
			reverted = reverted == true? false: true;
			cont++;
		}
		else{
			int f; char c;
			cin>> f >> c;
			if(reverted){
				if(f == 1)
					v.push_back(c);
					//~ s = s + c;
				else
					v.insert(v.begin(),c);
					//~ s = c + s;
			}
			else{
				if(f == 1)
					v.insert(v.begin(),c);
					//s = c + s;
				else
					v.push_back(c);
					//s = s + c;
			}
		}
		
	}
	if(cont % 2 == 0)
		for(char c: v)
		cout<<c;
	else{
		reverse(v.begin(),v.end());
		for(char c: v)
		cout<<c;
	}
	return 0;
}













Measured memory_bytes: 1272
def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: 
    return 0
  if n==0 or k==0: 
        return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*pow(b,p-2,p)*pow(c,p-2,p))%p

s = int(input())
mod = 10**9 + 7
n = s // 3
result = 0
for i in range(1, n+1):
    temp = s - i * 3
    result+= comb(temp + i - 1, i - 1, mod)
print(result % mod)

Measured memory_bytes: 75256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <limits>
#include <iomanip>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

	bool result = ((d + (s - 1)) / s) <= t;

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

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;



namespace Test1 {

    class ClassMain {

        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                string[] strs = line.Split(' ');
                int n0 = int.Parse(strs[0]);
                int n1 = int.Parse(strs[1]);
                if (n0 == 0 && n1 == 0) { break; }
                int[] uriage = new int[5];
                uriage[0] += n0 + n1;
                for (int i = 1; i <= 4; i++) {
                    strs = Console.ReadLine().Split(' ');
                    n0 = int.Parse(strs[0]);
                    n1 = int.Parse(strs[1]);
                    uriage[i] += n0 + n1;
                }

                //Judge
                int maxMise = -1;
                int maxUriage = -1;
                for (int i = 0; i < 5; i++) {
                    if (maxUriage < uriage[i]) {
                        maxUriage = uriage[i];
                        maxMise = i;
                    }
                }
                string miseName = "";
                switch (maxMise) {
                    case 0: miseName = "A"; break;
                    case 1: miseName = "B"; break;
                    case 2: miseName = "C"; break;
                    case 3: miseName = "D"; break;
                    case 4: miseName = "E"; break;
                }
                Console.WriteLine(miseName + " " + maxUriage);



            }
        }

    }

}

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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 200000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //int TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    ll n, W;
    cin >> n >> W;
    ll a[n][2];
    rep(i, 0, n)
        cin >> a[i][0] >> a[i][1];
    ll dp[n + 1][n + 1][n * 3 + 1];
    rep(i, 0, n + 1)
        rep(j, 0, n + 1)
            rep(k, 0, n * 3 + 1)
                dp[i][j][k] = -inf;
    dp[0][0][0] = 0;
    rep(i, 0, n)
        rep(j, 0, i + 1)
            rep(k, 0, n * 3 + 1)
                if (dp[i][j][k] != -inf)
                {
                    dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);
                    if (j * a[0][0] + k + a[i][0] <= W)
                        dp[i + 1][j + 1][k + a[i][0] - a[0][0]] = max(dp[i + 1][j + 1][k + a[i][0] - a[0][0]], dp[i][j][k] + a[i][1]);
                }
    ll ans = 0;
    rep(j, 0, n + 1)
        rep(k, 0, n * 3 + 1)
            if (j * a[0][0] + k <= W)
                ans = max(ans, dp[n][j][k]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 24192
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io, flush := NewIO()
	defer flush()

	n := io.ScanInt()
	nums := io.ScanInts(n)
	xor := 0
	for i := 0; i < n; i++ {
		xor = xor ^ nums[i]
	}
	for i := 0; i < n; i++ {
		fmt.Printf("%d ", xor ^ nums[i])
	}
}

// 1,2,3
// 2xor3, 1xor3, 1xor2
// 1xor2 xor 2xor3 xor 1xor3

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInt2() (int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt3() (int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt4() (int, int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 11812
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    string s;
    int ans = 0;
    cin >> s;
    for(int i=0;i<s.length();i++){
        if(i%2 == 0){
            if(s[i] == 'L'){
                ans = 1;
            }
        } else {
            if(s[i] == 'R'){
                ans = 1;
            }
        }
    }
    if(ans==1){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    ll M = 1 << N;
    AIN(ll, A, M);
    ll ans = 0;
    REP1(i, M - 1)
    {
        ll opt = 0;
        ll opt2 = 0;
        for (ll j = M - 1; j >= 0; --j)
        {
            j &= i;
            if (A[j] > opt)
            {
                opt2 = opt;
                opt = A[j];
            }
            else if (A[j] > opt2)
            {
                opt2 = A[j];
            }
        }
        CH(max, ans, opt + opt2);
        OUT(ans);
    }
}

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

int main(void) {
  long a, b, c, ans;
  cin >> a >> b >> c;

  ans = b;
  if (a + b + 1 < c)
    ans += a + b + 1;
  else
    ans += c;
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int n, x;
int m[101];
int cnt;
int main()
{
	cin >> n >> x;
	REP(i, 0, n) {
		cin >> m[i];
		cnt += m[i];
	}

	x -= cnt;
	sort(m, m + n);
	cout << n + x / m[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

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

template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'


const int MXN = 1e5 + 5;
int n, k, r, s, p;
string t;
vector<char> inds[MXN];


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	//ifstream cin("/Users/konwoo/input.txt");
	//ofstream cout("/Users/konwoo/output.txt");
	
	cin >> n >> k >> r >> s >> p >> t;
	F0R(i,n){
		inds[i % k].push_back(t[i]);
	}
	int ans = 0;
	F0R(i,k){
		vector<vi> dp;
		dp.assign(sz(inds[i]), vector<int>(3,0));
		F0R(j, sz(inds[i])){
			if (j == 0){
				if (inds[i][j] == 'r'){
					dp[j][0] = 0;
					dp[j][1] = p;
					dp[j][2] = 0;

				}
				else if (inds[i][j] == 's'){
					dp[j][0] = r;
					dp[j][1] = 0;
					dp[j][2] = 0;
				}
				else{
					dp[j][0] = 0;
					dp[j][1] = 0;
					dp[j][2] = s;
				}
			}
			else{
				if (inds[i][j] == 'r'){
					dp[j][0] = max(dp[j-1][1], dp[j-1][2]);
					dp[j][1] = p + max(dp[j-1][0], dp[j-1][2]);
					dp[j][2] = max(dp[j-1][0], dp[j-1][1]);
				}
				else if (inds[i][j] == 's'){
					dp[j][0] = r + max(dp[j-1][1], dp[j-1][2]);
					dp[j][1] = max(dp[j-1][0], dp[j-1][2]);
					dp[j][2] = max(dp[j-1][0], dp[j-1][1]);
				}
				else{
					dp[j][0] = max(dp[j-1][1], dp[j-1][2]);
					dp[j][1] = max(dp[j-1][0], dp[j-1][2]);
					dp[j][2] = s + max(dp[j-1][0], dp[j-1][1]);
				}
			}
		}
		ans += max(dp[sz(inds[i]) - 1][0], max(dp[sz(inds[i]) - 1][1], dp[sz(inds[i]) - 1][2]));
	}
	cout << ans << newl;












	return 0;
}


Measured memory_bytes: 8272
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;

 		
int main() {

int A,B;
cin>>A>>B;

vector<vector<char>> S(100);

doublece(100,100)

fx(100){
	fy(100){
		if((y==0||x%2==0)&&y!=99){
			pb(S.at(x),'.');
		}else{
			pb(S.at(x),'#');
		}
	}
}
int a=1,b=1;
for(int x=1;x<99;x+=3){
	for(int y=2;y<98;y+=2){
	if(x%2==1){
		if(b<B){
			S.at(x).at(y)='.';
			b++;
		}
	}else{
		if(a<A){
			S.at(x).at(y)='#';
			a++;
		}
	}
	}
}

fx(100){
	fy(100){
		cout<<S.at(x).at(y);
	}
	cout<<endl;
}


}

Measured memory_bytes: 256
from collections import deque
import copy
H, W = map(int, input().split())
 
route = []
for _ in range(H):
  route.append(input())
  
wall = set()
start = set()
for y, r in enumerate(route):
  for x, w in enumerate(r):
    if w == '.':
      start.add((x, y))

score = -1
ssize = [(-1,0),(0,-1),(1,0),(0,1)]
for xy in start:
  d = deque()
  d.append((xy+(0,)))
  step = 0
  can = copy.deepcopy(start)
  can.remove(xy)
  while len(d) > 0:
    now = d.popleft()
    step = now[2]
    for xs, ys in ssize:
      nxt = (now[0]+xs, now[1]+ys)
      if nxt in can:
        d.append(nxt+(step+1,))
        can.remove(nxt)
  score = max(step, score)
  
print(score)

Measured memory_bytes: 3572
#include<stdio.h>
#include<stdlib.h>

int main(void){
 
  int plen,cnum,width,cspace;
  char **line;
  char **output;
  int linenum,i,j,k,l,m,n,o;
  int f;

  line = (char**)malloc(sizeof(char)*1002);
  for(i=0;i<1002;i++)line[i] = (char*)malloc(sizeof(char)*1002);

  output = (char**)malloc(sizeof(char)*2002);
  for(i=0;i<2002;i++)output[i] = (char*)malloc(sizeof(char)*52);

  while(1){
    scanf(" %d ",&plen);
    if(!plen)break;
    scanf(" %d %d %d ",&cnum,&width,&cspace);

    linenum = 0;
    while(1){
      fgets(line[linenum],1000,stdin);
      if(line[linenum][0] == '?')break;
      linenum++;
    }

    i = 0;
    j = 0;
    f = 0;
    o = 0;
    while(1){
      l = 0;
      m = 0;
      while(1){
	for(k=0;k<plen;k++){
	  if(f){
	    i++;
	    j = 0;
	    f = 0;
	  }
	  while(1){
	    if(i >= linenum){
	      output[o+k][m+j%width] = '.';
	    }else if(!f && line[i][j] != '\n'){
	      output[o+k][m+j%width] = line[i][j];
	    }else if(line[i][j] == '\n'){
	      if(j!=0 && j%width == 0)f = 2;
	      else f = 1;
	    }
	    if(f == 2){
	      k--;
	      break;
	    }
	    if(f == 1)output[o+k][m+j%width] = '.';
	    j++;
	    if( j%width == 0)break;
	  }
	}
	l++;
	m += width;
	if(l==cnum){
	  for(k=0;k<plen;k++){
	    output[o+k][m] = '\0';
	  }
	  break;
	}else{
	  for(k=0;k<plen;k++){
	    for(n=0;n<cspace;n++){
	      output[o+k][m+n] = '.';
	    }
	  }
	}
	m += cspace;
      }

      o += plen;
      if(i == linenum-1 && (f || line[i][j] == '\n'))break;
      if(i >= linenum)break;
    }
    if(linenum>0){
      for(j=0;j<o;j++){
	printf("%s\n",output[j]);
	if( (j+1)%plen == 0)printf("#\n");
      }
    }
    printf("?\n");
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int n, g, i, j, w[110], val[110];
long long dp[110][100010];

inline int minim(int x, int y) {
    return (x < y ? x : y);
}

int main() {
    cin >> n >> g;
    for (i = 0; i < n; ++i) {
        cin >> w[i] >> val[i];
    }
    for (i = 1; i <= 100000; ++i) {
        dp[0][i] = (1 << 30);
    }
    dp[0][0] = 0;
    for (i = 1; i <= n; ++i) {
        for (j = 0; j <= 100000; ++j) {
            dp[i][j] = dp[i - 1][j];
            if (j >= val[i - 1]) {
                dp[i][j] = minim(dp[i - 1][j], dp[i - 1][j - val[i - 1]] + w[i - 1]);
            }
        }
    }
    for (i = 100000; i >= 0; --i) {
        if (dp[n][i] <= g) {
            cout << i << "\n";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 80128
import collections

def int_cards(N, cards, operations):
    col_cards = collections.deque(sorted(cards), N)
    operations.sort(reverse=True)
    for c, b in operations:
        for _ in range(b):
            if col_cards[0] >= c:
                break
            col_cards.popleft()
            col_cards.append(c)
            
    print(sum(col_cards))
    
N, M = map(int, input().split())
A = list(map(int,input().split()))
operations = []
for i in range(M):
    B, C = map(int, input().split())
    operations.append([C, B])
    
int_cards(N, A, operations)

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

int main() {
	
	long long n,i,j,k,sum=0,count=0,ans=0,l,r,x,y;
	string s;
	cin>>s;
	for(i=0;i<3;i++)
	{
	    if(s[i]=='7')
	    {
	        cout<<"Yes"; return 0;
	    }
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm> // sort
#include <iomanip>
#include <queue>
#include <map>
#include <bits/stdc++.h>

using namespace std;

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
typedef pair<int,int> pint;

const int MAX = 1000000007;
const int MOD = 1000000007;

int main(){

#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    int n,d,res;
    cin >> n;
    int c[100] = {};
    REP(i,n)
    {
        cin >> d;
        --d;
        ++c[d];
    }
    res = 0;
    REP(i,100)
    {
        if(c[i] > 0)++res; 
    }
    cout << res <<  endl;
    return 0;
}

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

int main(){
	int n;
	int a[100010];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	int cnt[3]={};
	for(int i=0;i<n;i++){
		if(a[i]&1)cnt[0]++;
		else if(a[i]&3)cnt[1]++;
		else cnt[2]++;
	}
	if(cnt[1]==0){
		if(cnt[0]<=cnt[2]+1)puts("Yes");
		else puts("No");
	}
	else {
		if(cnt[0]<=cnt[2])puts("Yes");
		else puts("No");
	}
}

Measured memory_bytes: 4024
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;   
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    double a,b,d=0,n,m,k,ans=0;
    string s,s2;
    cin >> n;
    VI c(n);

    for(int i=0; i<n; i++){
        cin >> c[i];
    }
    sort(ALL(c));
    rep(i,n-1){
        d += c[i];
    }
    if(c[n-1]<d){
        cout << "Yes"<<endl;
    }
    else 
        cout << "No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int d;
    scanf("%d",&d);
    if(d==22)
    {
        printf("Christmas Eve Eve Eve\n");
    }
    else if(d==23)
    {
        printf("Christmas Eve Eve\n");
    }
        else if(d==24)
    {
        printf("Christmas Eve\n");
    }
        else if(d==25)
    {
        printf("Christmas\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
	int N;
	int A[128];
	int sum[128];
	int i;
	int ok, ng;
	if (scanf("%d", &N) != 1) return 1;
	sum[0] = 0;
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
		sum[i] = sum[i - 1] + A[i];
	}
	ok = 0;
	ng = sum[N] + 1;
	while (ok + 1 < ng) {
		int mid = ok + (ng - ok) / 2;
		int dekiru = 1;
		for (i = 1; i <= N; i++) {
			if (sum[i] < mid * i) dekiru = 0;
		}
		if (dekiru) ok = mid; else ng = mid;
	}
	printf("%d\n", ok);
	return 0;
}



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

signed main(){

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

  constexpr int inf = 1<<28;
  auto chmax = [](auto& a,auto b){if(a<b)a=b;};
  // dp[i][j] := i番目 重さj 価値の最大
  vector<vector<int>> dp(N+1,vector<int>(1e5));
  for(int i=0;i<N;++i){
    for(int j=1;j<=W;++j){
      chmax(dp[i+1][j],dp[i][j]);
      chmax(dp[i+1][j],dp[i+1][j-1]);
      if(j>=w[i])chmax(dp[i+1][j],dp[i][j-w[i]]+v[i]);
    }
  }
  cout<<(dp[N][W])<<endl;


}


Measured memory_bytes: 42676
def solve(test):

    for i in range(len(test)):
        print("Case {0}: {1}".format(i+1,test[i]))

    
 

def answer():
    
    test =[]
    while True :
        n = input()
        if n=='0':
            break
        else:

            test.append(n)
    solve(test)


   

if __name__ =='__main__':
    answer()


Measured memory_bytes: 6248
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin>>N>>M;
  bool F=true;
  string D="aaa";
  for(int X=0;X<M;X++){
    int S,C;
    cin>>S>>C;
    if((D[S-1]!='a'&&(int)(D[S-1]-'0')!=C)||(N!=1&&S==1&&C==0)){
      F=false;
    }
    else{
      D[S-1]=(char)C+'0';
    }
  }
  if(F==false){
    cout<<-1<<endl;
  }
  else{
    for(int X=0;X<N;X++){
      if(D[X]=='a'){
        if(X==0&&N!=1){
          cout<<1;
        }
        else{
          cout<<0;
        }
      }
      else{
        cout<<D[X];
      }
    }
    cout<<endl;
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <math.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A;
  vector<int> B;
  vector<int> C;
  A.push_back(0);
  B.push_back(0);
  C.push_back(0);
  for(int i=0;i<3;i++){
    for(int j=0;j<N;j++){
      int tmp;
      cin >> tmp;
      if(i==0){
        A.push_back(tmp);
      }else if(i==1){
        B.push_back(tmp);
      }else{
        C.push_back(tmp);
      }
    }
  }
  int sum=0;
  for(int i=1;i<N+1;i++){
    sum=sum+B.at(A.at(i));
    if(i==0)continue;
    if(A.at(i)==A.at(i-1)+1){
      sum=sum+C.at(A.at(i-1));
  	}
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
inps = input().split()
lst = [int(i) for i in inps]
for idx in range(len(lst) - 1):
    for idx_next in range(idx+1, len(lst)):
        if lst[idx] > lst[idx_next]:
            tmp = lst[idx_next]
            lst[idx_next] = lst[idx]
            lst[idx] = tmp
print("{} {} {}".format(lst[0], lst[1], lst[2]))

Measured memory_bytes: 7728
import sys

def main():
    N = int(input())
    
    cnt = 0
    for i in range(1, N+1):
        if 1 <= i < 10:
            cnt += 1
        elif 100 <= i < 1000:
            cnt += 1
        elif 10000 <= i < 100000:
            cnt += 1
                    
    print(cnt)
main()

Measured memory_bytes: 3316