akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int n, m, c[10][10], c2[10][10], a[200][200];
int main() {
  cin >> n >> m;
  for(int i = 0; i < 10; ++i)
    for(int j = 0; j < 10; ++j)
      cin >> c[i][j];
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < m; ++j)
      cin >> a[i][j];
  for(int k = 0; k < 10; ++k)
    for(int i = 0; i < 10; ++i)
      for(int j = 0; j < 10; ++j)
        if(c[i][j] > c[i][k] + c[k][j])
          c[i][j] = c[i][k] + c[k][j];
  int cnt = 0;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < m; ++j)
      if(a[i][j] == -1)
        continue;
      else
        cnt += c[a[i][j]][1];
  cout << cnt << endl;
}

Measured memory_bytes: 384
// Aizu Vol-5 0557: A First Grader
// 2017.9.1 bal4u@uu

#include <stdio.h>

int d[103];
long long p[2][21];

int main()
{
	int n, s, i, j, k1, k2;

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", d + i);
	p[0][d[0]] = 1; s = d[--n];
	for (k1 = 0, k2 = 1, i = 1; i < n; i++, k1 = k2, k2 = !k2) {
		int x = d[i];
		for (j = 0; j <= 20; j++) p[k2][j] = 0;
		for (j = 0; j <= 20-x; j++) p[k2][j+x] += p[k1][j];
		for (j = x; j <= 20; j++)   p[k2][j-x] += p[k1][j];
	}
	printf("%lld\n", p[k1][s]);
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define mp make_pair
#define PII pair<ll,ll>
#define PLL pair<long long,long long>
#define pq priority_queue
#define M map
#define UM unordered_map
#define graph unordered_map<ll,vector<ll>>
#define graphw unordered_map<ll,vector<pair<ll,ll>>>
#define V vector
#define mod 1000000007
#define inf 3000000000000000007ll
#define P pair
#define Fast ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) signed(a.size())
#define FIXED cout << fixed << setprecision(12)
#define L list
#define D deque
#define ld long double
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define deb(x) cout<<#x<<" "<<x<<endl;
using namespace std;
// pair operation
template<class T, class U>istream& operator>>(istream& in, pair<T, U> &rhs) {in >> rhs.first; in >> rhs.second; return in;}
template<class T, class U>ostream& operator<<(ostream& out, const pair<T, U> &rhs) {out << rhs.first; out << " "; out << rhs.second; return out;}
template<class T, class U>pair<T, U> operator+(pair<T, U> &a, pair<T, U> &b) {return pair<T, U>(a.first + b.first, a.second + b.second);}
template<class T, class U>pair<T, U> operator-(pair<T, U> &a, pair<T, U> &b) {return pair<T, U>(a.first - b.first, a.second - b.second);}
// Linear STL
// VECTOR
template<class T>istream& operator>>(istream& in, vector<T> &a) {for (auto &i : a)cin >> i; return in;}
template<class T>ostream& operator<<(ostream& out, const vector<T> &a) {for (auto &i : a)cout << i << " "; return out;}
// SET
template<class T>ostream& operator<<(ostream& out, const set<T> &a) {for (auto &i : a)cout << i << " "; return out;}
template<class T>ostream& operator<<(ostream& out, const unordered_set<T> &a) {for (auto &i : a)cout << i << " "; return out;}
template<class T>ostream& operator<<(ostream& out, const multiset<T> &a) {for (auto &i : a)cout << i << " "; return out;}
// MAP
template<class T, class U>ostream& operator<<(ostream& out, const map<T, U> &a) {for (auto &i : a)cout << "(" << i.first << ", " << i.second << "(\n"; return out;}
template<class T, class U>ostream& operator<<(ostream& out, const unordered_map<T, U> &a) {for (auto &i : a)cout << "(" << i.first << ", " << i.second << "(\n"; return out;}
 
 
void judge() {
#ifndef ONLINE_JUDGE
	FILE_READ_IN
	FILE_READ_OUT
#endif
}
 
 
 
int main() {
	Fast;
	ll t = 1;
	judge();
	// cin >> t;
	while (t--) {
		ll n, m;
		cin >> m >> n;
		ll a[n];
		ll sum = 0;
		for (ll i = 0; i < n; i++) {
			cin >> a[i];
			sum += a[i];
		}
		// cout << sum << endl;
		ll ans = m - sum;
		if (ans < 0)ans = -1;
		cout << ans << endl;
 
	}
}

Measured memory_bytes: 3688
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <stack>

using namespace std;

#define Getsign(n) ((n > 0) - (n < 0))
#define QWERTYR(c) (c == 'y' || c == 'u' || (c >= 'h' && c <= 'p') ?	true : false)
typedef vector<int> Ivec;
typedef pair<int, int> Pos;

int main() {
	int n, l;
	vector<int> rope;

	scanf("%d %d", &n, &l);

	for (int i = 0; n > i; i++) {
		int a;
		scanf("%d", &a);

		rope.push_back( a );
	}
	bool possible = false;
	stack<int> how_to;
	for (int i = 0; rope.size()-1 > i; i++) {
		if (rope[i]+ rope[i + 1] >= l) {
			printf("Possible\n");
			possible = true;
			rope[i] += rope[i + 1];
			rope.erase(rope.begin()+i+1);
			int core_num = i+1;
			how_to.push(core_num);
			for (int j = core_num-1; 0 < j; j--)
				how_to.push(j);
			for (int j = core_num + 1; n > j; j++)
				how_to.push(j);
			while (!how_to.empty()) {
				printf("%d\n", how_to.top());
				how_to.pop();
			}

			return 0;
		}
	}
	if (!possible) {
		printf("Impossible\n");
		return 0;
	}


	return 0;
}

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

ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}

int main(){
  string a,b;
  cin>>a>>b;
  int c,d;
  cin>>c>>d;
  string e;
  cin>>e;
  if(a==e){
    c--;
  }
  if(b==e){
    d--;
  }
  cout<<c<<" "<<d;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(n) for(int i=0;i<n;i++)
#define For(i,n) for(int i=0;i<n;i++)
#define ll long long
ll mob=1000000007;
int main()
{ll h;
cin>>h;
ll i=0;
while(h/2 >0)
{
    h/=2;
    i++;
    
}
cout<<fixed<<(ll)pow(2,i+1)-1;

return 0;
}

Measured memory_bytes: 256
n = gets.to_i
x = gets.split(" ").map(&:to_f)[0,n]
y = gets.split(" ").map(&:to_f)[0,n]
4.times do |i|
  k = (i + 1).to_f
  puts ((k == 4.0) ? [x,y].transpose.map{|c| c.inject(:-).abs}.max : [x,y].transpose.map{|c| c.inject(:-).abs**(k)}.inject(:+)**(1/k)).round(6)
end

Measured memory_bytes: 8796
#include <iostream>
#include <vector>
using namespace std;
int main(void){
   int a;
   cin>>a;
   int b=0;
   vector<int> vec(a);
        for (int i = 0; i < a; i++) {
        cin >> vec.at(i);
      } 
  int i=0;
  for(i;i<a-1;i++){
    for(int l=i+1;l<a;l++){
      b+=vec.at(i)*vec.at(l);
    }
  }
   cout<<b<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int A; string S;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> A >> S;
	if (3200 <= A) cout << S << endl;
	else cout << "red" << endl;
}







Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  long long int n;
  cin>>n;
  string s;
  cin>>s;
  long long int E=0;
  long long int W=0;
  for(long long int i=0; i<n; i++){
    if(s[i]=='E'){
      E++;
    }else{
      W++;
    }
  }
  long long int currentE=0;
  long long int currentW=0;
  long long int ans=n;
  for(long long int i=0; i<n; i++){
    long long int pre=E-currentE+currentW;
    if(s[i]=='E'){
      pre--;
    }
    ans=min(ans,pre);
    if(s[i]=='E'){
      currentE++;
    }else{
      currentW++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 900
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=[int(input()) for _ in range(n)]
maze=[["*" for i in range(3)] for _ in range(3)]
for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i]==a[j][k]:
                maze[j][k]="#"
for i in range(3):
    f=1
    for j in range(3):
        if maze[i][j]!="#":
            f=0
            break
    if f:
        print("Yes")
        exit()
for i in range(3):
    fc=1
    for j in range(3):
        if maze[j][i]!="#":
            fc=0
            break
    if fc:
        print("Yes")
        exit()
for i in range(3):
    fa=1
    if maze[i][i]!="#":
        fa=0
        break
if fa:
    print("Yes")
    exit()
for i in range(3):
    fe=1
    if maze[i][2-i]!="#":
        fe=0
        break
if fe:
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 3064
/**
 *　　　　　　　　┏┓　　　┏┓+ +
 *　　　　　　　┏┛┻━━━┛┻┓ + +
 *　　　　　　　┃　　　　　　　┃
 *　　　　　　　┃　　　━　　　┃ ++ + + +
 *　　　　　　 ████━████ ┃+
 *　　　　　　　┃　　　　　　　┃ +
 *　　　　　　　┃　　　┻　　　┃
 *　　　　　　　┃　　　　　　　┃ + +
 *　　　　　　　┗━┓　　　┏━┛
 *　　　　　　　　　┃　　　┃
 *　　　　　　　　　┃　　　┃ + + + +
 *　　　　　　　　　┃　　　┃　　　　Code is far away from bug with the animal protecting
 *　　　　　　　　　┃　　　┃ + 　　　　神兽保佑,代码无bug
 *　　　　　　　　　┃　　　┃
 *　　　　　　　　　┃　　　┃　　+
 *　　　　　　　　　┃　 　　┗━━━┓ + +
 *　　　　　　　　　┃ 　　　　　　　┣┓
 *　　　　　　　　　┃ 　　　　　　　┏┛
 *　　　　　　　　　┗┓┓┏━┳┓┏┛ + + + +
 *　　　　　　　　　　┃┫┫　┃┫┫
 *　　　　　　　　　　┗┻┛　┗┻┛+ + + +
 */
/*--------- Hongjie ----------*/
// #include<bits/stdc++.h>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<deque>
#include<cmath>
#include<cstdio>
#include<bitset>
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

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

const int INF  = 0x3f3f3f3f;
const int MAXN = 1e5+7;
int a[10] = {0,9,0,900,0,90000};

int main(){
        // freopen("../in.txt","r",stdin);
        // freopen("../out.txt","w",stdout);
        ios::sync_with_stdio(0);
        cin.tie(0);
        int n;
        while(cin>>n) {
                int m = n;
                int len = 0;
                while(m) {
                        m/=10;
                        len++;
                }
                int ans = 0;
                for(int i=0;i<len;++i)
                        ans += a[i];
                if(len==1)        ans += n;
                else if(len%2)    ans += n-(int)(pow(10,len-1)+0.5)+1;
                cout<<ans<<endl;
        }


        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define MOD 998244353

using namespace std;
long long table[3001][3001];
int main() {
    int N, S;
    int A[3000];
    cin >> N >> S;
    for (int i=0; i<N; i++) {
        cin >> A[i];
    }
    
    for (int i=0; i<3001; i++) {
        table[i][0] = i+1;
    }
    for (int i=1; i<=N; i++) {
        for (int j=1; j<=3000; j++) {
            table[i][j] = table[i-1][j];
            if (j-A[i-1] >= 0) table[i][j] += table[i-1][j-A[i-1]];
            table[i][j] %= MOD;
        }
    }

    long long answer = 0;
    for (int i=1; i<=N; i++) {
        answer = (answer + table[i][S]) % MOD;
    }
    cout << answer <<endl;
    return 0;
}



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

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  
  int A[n];
  int ans = 0;
  
  rep(i,n){
    A[i] = i+1;
    int count = 0;
    
    while(true){
      count += A[i]%10;
      if(A[i]/10 == 0) break;
      A[i] = A[i]/10;
    }

    if(count >=a && count <= b) ans += i+1; 
  }
  
  cout << ans << endl;
  return 0;
}
    


Measured memory_bytes: 256
seat=[list(map(int,input().split())) for _ in range(3)]
n = int(input())
for i in range(n):
    x = int(input())
    for j in range(3):
        if x in seat[j]:
            seat[j][seat[j].index(x)]=0
#print(seat)

f = False
for i in range(3):
    if seat[i][0]==0 and seat[i][1]==0 and seat[i][2]==0:
        f = True
    if seat[0][i] == 0 and seat[1][i] == 0 and seat[2][i] == 0:
        f = True
if seat[0][0]==0 and seat[1][1]==0 and seat[2][2]==0:
    f = True
if seat[0][2]==0 and seat[1][1]==0 and seat[0][2]==0:
    f = True

if f:print("Yes")
else: print("No")

Measured memory_bytes: 3064
class UF:
    def __init__(self, N):
        self.uf = [-1]*N
        self.n = N

    def find(self, x):
        if self.uf[x]<0: return x
        self.uf[x] = self.find(self.uf[x])
        return self.uf[x]

    def size(self, x):
        return -self.uf[self.find(x)]

    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x==y: return
        if self.size(x) > self.size(y): x, y = y, x
        self.uf[y] += self.uf[x]
        self.uf[x] = y
        self.n -= 1

import sys
input = sys.stdin.readline

N = int(input())
P = [tuple(map(int, [i]+input().split())) for i in range(N)]

uf = UF(N)

Px = sorted(P, key=lambda p:p[1])
Py = sorted(P, key=lambda p:p[2])

E = []
for i in range(N-1):
    E.append((Px[i+1][1]-Px[i][1], Px[i][0], Px[i+1][0]))
    E.append((Py[i+1][2]-Py[i][2], Py[i][0], Py[i+1][0]))
E = sorted(E)

ans = 0
for c, p1, p2 in E:
    if uf.find(p1)!=uf.find(p2):
        ans += c
        uf.union(p1, p2)

print(ans)

Measured memory_bytes: 47356
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(1000005);
    rep(i,n)cin>>a[i];
    rep(i,n){
        ll k=1;
        ll j=k*a[i];
        if(b[j]!=0){
            b[j]=2;
            continue;
        }
        while(j<=1000000){
            ++b[j];
            ++k;
            j=k*a[i];
        }
    }
    ll ans=0;
    rep(i,n){
        if(b[a[i]]==1)ans++;
    }
    cout<<ans<<endl;

    return 0;
}

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

int main() {
    int n;cin>>n;
    int mx;cin>>mx;
    int f=1;
    for (int i=1;i<n;i++) {
        int a;cin>>a;
        f&=a>=mx-1;
        mx=max(mx,a);
    }
    if (f)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VI A(n);
  INPUT(A);
  REPx(x, A)
  {
    if (x % 2 == 0 && (x % 3 != 0 && x % 5 != 0))
    {
      cout << "DENIED";
      return 0;
    }
  }
  cout << "APPROVED";

  return 0;
}


Measured memory_bytes: 256
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define rev reverse
#define all(x) x.begin(), x.end()
#define ub upper_bound
#define lb lower_bound
#define ll long long
#define endl '\n'
#define ull unsigned long long
#define sz(x) (int)x.size()

template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll inf = 1e9+7;
const ll N = 1e5+1;
const ll mod = 1e9+7;
const ll P = 31;

int main() {
    IOS
    bool ok = 0;
    ll x;
    cin >> x;
    for(int i = -10000; i <= 1000; i++) {
        ll y = pow(i, 5);
        for(int j = -1000; j <= 1000; j++) {
            if(y - pow(j,5) == x) {
                cout << i << " " << j << endl;
                ok = 1;
                break;
            }
        }
        if(ok == 1)
        break;
    }
    return 0;
}


Measured memory_bytes: 4244
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0106&lang=jp
"""
import sys


def solve(amount):
    """
    :param amount: ?????\???????????°?????????
    :return: ?????????
    """
    best_price = (amount + 199) // 200 * 380
    for a in range(amount // 200 + 1):
        for b in range(amount // 300 + 1):
            for c in range(amount // 500 + 1):
                for a1 in range(amount // 1000 + 1):
                    for b1 in range(amount // 1200 + 1):
                        for c1 in range(amount // 1500 + 1):
                            if a*200 + b*300 + c*500 + a1*1000 + b1*1200 + c1*1500 == amount:
                                price = a*380 + b*550 + c*850 + a1*1520 + b1*1870 + c1*2244
                                if price < best_price:
                                    best_price = price
    return best_price


def solve2(amount):
    """
    ???????¨???????????????¨?????????????????§???
    """
    packages = [(0, 0), (2, 380), (3, 550), (5, 850), (10, 1520), (12, 1870), (15, 2244)] # 1?¢??????????(100g??????)??¨??????????????¢l
    # dp??¨???2?¬??????????????¨?????????????(100g??????)?????????????????¨??§??????packages????¨????
    # 999999...??????INF??¨?????? (phthon 3.5??\??????????????????math.inf????????¨??§??????)
    cart = [[99999999] * (amount//100 + 1) for _ in range(len(packages))]
    for i in range(len(packages)):
        cart[i][0] = 0          #  0g???????????\????????´??????0???????????????

    for i in range(1, len(packages)):
        for j in range(1, len(cart[0])):
            w = packages[i][0]  #  ??????
            p = packages[i][1]  #  ??????
            if j < w:
                cart[i][j] = cart[i-1][j]
            else:
                # ???????????????????????????????????????????????????????????????????????????????¨????
                cart[i][j] = min(cart[i-1][j], cart[i-1][max(0, j-w)]+p, cart[i][max(0, j-w)]+p)
    return cart[-1][-1]


def main(args):
    while True:
        amount = int(input())
        if amount == 0:
            break
        #result = solve(amount)
        #print(result)
        result = solve2(amount)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7920
/*
 * main.c
 *
 *  Created on: 2020/07/27
 *      Author: 113896
 */
#include <stdio.h>

int main() {

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

	printf("%d %d %.6lf", a/b, a%b, (double)a/b);

	return 0;
}




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

int main(){
	ll n;
	ll k;
	cin >> n>>k;

	if(n>= k) n %= k;
	while(n>k/2.0){
		n = min(k-n,n);
	}
	cout << n << endl;

	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Here your code !

n = int(input())

while n!=0 :
    #1??????????????¨?????????
    pointA=0
    pointB=0
    for i in range(n):
        x = list(map(int, input().split()))
        if x[0] == x[1]:
            pointA += x[0]
            pointB += x[1]
        elif x[0] > x[1]:
            pointA += x[0] + x[1]
        else:
            pointB += x[0] + x[1]
    
    print(pointA, pointB)
    n = int(input())

Measured memory_bytes: 7476
#include <iostream>
#include <string>
#include <queue>

using namespace std;

int main(int argc, char* argv[]) {
  string s;
  cin >> s;

  int Q;
  cin >> Q;

  deque<char> q;
  for (int i = 0; i < s.size(); ++i)
    q.push_back(s[i]);

  bool flip = false;
  for (int i = 0; i < Q; ++i) {
    int t;
    cin >> t;
    if (t == 1) {
      flip = !flip;
    } else if (t == 2) {
      int f;
      cin >> f;
      char c;
      cin >> c;
      if (f == 1) {
        if (flip) {
          q.push_back(c);
        } else {
          q.push_front(c);
        }
      } else if (f == 2) {
        if (!flip) {
          q.push_back(c);
        } else {
          q.push_front(c);
        }
      }
    }
  }

  if (!flip) {
    for (int i = 0; i < q.size(); ++i) {
      cout << q[i];
    }
  } else {
    for (int i = q.size() - 1; i >= 0; --i) {
      cout << q[i];
    }
  }

  cout << endl;

  return 0;
}

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

int main() {
  string s,ans="Yes";
  int i;

  cin >> s;

  for(i=0; i<s.length(); i++) {
    if(i%2==0) {
      if(s[i]=='L') {ans = "No";}
    }
    else if(i%2!=0) {
      if(s[i]=='R') {ans = "No";}
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    ll N;
    cin >> N;

    string key[] = {"AC", "WA", "TLE", "RE"};
    int c[4] ={};

    for(int i = 0; i < N; i++){
        string S;
        cin >> S;
        for(int j = 0; j < 4; j++){
            if(S == key[j]){
                c[j]++;
                break;
            }
        }
    }

    for(int i = 0; i < 4; i++){
        cout << key[i] << " x " << c[i] << endl;
    }
}


Measured memory_bytes: 3656
#!venv/bin/python
#from collections import defaultdict 
from itertools import combinations
from collections import defaultdict
from pprint import pprint
import math
import datetime
import sys
import fcntl
import time

#N = int(input())
#H = [int(x) for x in input().split()]

S = input()

r_odd = 0
r_even = 0
l_odd = 0
l_even = 0
last_is_R = True
ans = [0] * len(S)
roop_R_x = 0
for i,s in enumerate(S):
    # 仮に座標が奇数のものを odd にしておく
    if last_is_R:
        if s == 'R':
            if i % 2 == 0:    
                r_even += 1
            else:
                r_odd += 1
        if s == 'L':
            last_is_R = False
            roop_R_x = i - 1
            if roop_R_x % 2 == 1:
                r_odd, r_even = r_even, r_odd
            l_odd += 1
    else:
        if s == 'R':
            ans[roop_R_x] += (r_even + l_even)
            ans[roop_R_x + 1] += (r_odd + l_odd)
            r_odd = r_even = l_odd = l_even = 0
            last_is_R = True
            if i % 2 == 0:
                r_even += 1
            else:
                r_odd += 1
        elif s == 'L':
            if (i - roop_R_x) % 2 == 0:
                l_even += 1
            else:
                l_odd += 1

ans[roop_R_x] += (r_even + l_even)
ans[roop_R_x + 1] += (r_odd + l_odd)
r_odd = r_even = l_odd = l_even = 0
last_is_R = True

print(" ".join(map(str, ans)))


Measured memory_bytes: 11504
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;

struct  Node{
    int key;
    Node *right, *left ,*parent;
};

Node *NIL,*root=NIL;

void insert(int k){
    Node *y=NIL,*x=root,*z;
    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;

    while(x!=NIL){
        y=x;
        if(k < x->key){
            x=x->left;
        }
        else x=x->right;
    }

    z->parent=y;
    if(y==NIL) root = z;
    else{
        if(z->key <y->key) y->left=z;
        else y->right=z;
    }
}

bool find(int x){
    Node *y=root;
    bool ans=false;
    while(y!=NIL){
        if(y->key==x){
            ans=true;
            break;
        }
        else if(x<y->key) y=y->left;
        else y=y->right;
    }
    return ans;
}


int main(){
    int n,a;
    bool ans=true;
    cin>>n;
    REP(i,n){
        cin>>a;
        if(!find(a)) insert(a);
        else{
            ans=false;
            break;
        }
    }
    if(ans) cout<<"YES";
    else cout<<"NO";
    cout<<endl;
}

Measured memory_bytes: 9600
if __name__ == '__main__':
	N, W = map(int, input().split())
	items = []
	for i in range(N):
		items.append(list(map(int, input().split())))

	dp = [0] * (W + 1)
	
	for item in items:
		v, w = item
		for i in reversed(range(W - w + 1)):
			if dp[i + w] < dp[i] + v:
				dp[i + w] = dp[i] + v
	print(max(dp))



Measured memory_bytes: 5920
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int main() {
    int n, c = 0;
    cin >> n;
    vector<int> h(n);
    for (size_t i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    for (size_t i = 0; i < n; i++)
    {
        int flag = 1;
        for (size_t j = 0; j < i; j++)
        {
            if(h[j] > h[i]) {
                flag = 0;
            }
        }
        if(flag) {
            c++;
        }
    }
    cout << c << endl;
}


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

int main()
{
	int h, w;
	cin >> h >> w;
	char c[h+1][w+1];
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			cin >> c[i][j];
		}
	}

	for(int i=1; i<h; i++){
		for(int j=1; j<w-1; j++){
			if((c[i][j] == '#') && (c[i][j] != c[i-1][j]) && (c[i][j] != c[i+1][j]) && (c[i][j] != c[i][j-1]) && (c[i][j] != c[i][j+1])){
				printf("No");
				return 0;
			}
		}
	}
	printf("Yes");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int>pi;
#define elif else if
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define Rep(x,y) for(int k=x;k<y;k++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define vint vector<int>
#define vvint vector<vector<int>>
#define vtr vector<string>
#define vouble vector<double>
#define vvtr vector<vector<string>>
#define vhar vector<char>
#define vvhar vector<vector<char>>
#define mis map<int,str>
#define msi map<str,int>
#define mid map<int,double>
#define mod 100000007
#define elif else if
#define str string
int digitsum(int a){
  int b=0;
  while(a){
    b+=a%10;
    a/=10;
  }
  return b;
}
signed main(){
  int N,M,c=0,c2=0;
  string S,T;
  char C;
  double D;
  cin>>N>>S;
  if(S.size()>N){
    rep(N,S.size())S.erase(i);
    S+="...";
    cout<<S<<endl;
  }
  else cout<<S<<endl;
}


Measured memory_bytes: 3624
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_SLIME_MAX		2000									// 最大スライム数

// 内部変数
static FILE *szpFpI;											// 入力
static int siSCnt;												// スライム数
static int siMagic;												// 魔法時間
static long long sl2Time[D_SLIME_MAX + 5][D_SLIME_MAX];			// 確保時間[スライム][魔法回数]

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
#endif

// 小さい値を取得
long long
fGetLtl(
	long long plVal1			// <I> 値１
	, long long plVal2			// <I> 値２
)
{
	if (plVal1 < plVal2) {
		return plVal1;
	}
	else {
		return plVal2;
	}
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// スライム数・魔法時間 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &siSCnt, &siMagic);

	// 確保時間[スライム][魔法0] - 取得
	for (i = 1; i <= siSCnt; i++) {
		fscanf(szpFpI, "%lld", &sl2Time[i][0]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 確保時間[スライム][魔法回数] - セット
	int liSNo, liMCnt;
	for (liSNo = 1; liSNo <= siSCnt; liSNo++) {
		for (liMCnt = 1; liMCnt < siSCnt; liMCnt++) {

			// 確保スライム
			int liCNo = (liSNo - liMCnt - 1 + siSCnt) % siSCnt + 1;

			// 小さい確保時間をセット
			sl2Time[liSNo][liMCnt] = fGetLtl(sl2Time[liSNo][liMCnt - 1], sl2Time[liCNo][0]);
		}
	}

	// 最小時間 - 取得
	long long llMin = LLONG_MAX;
	for (liMCnt = 0; liMCnt < siSCnt; liMCnt++) {
		long long llSum = (long long)siMagic * (long long)liMCnt;
		for (liSNo = 1; liSNo <= siSCnt; liSNo++) {
			llSum += sl2Time[liSNo][liMCnt];
		}

		// 最小時間 - 更新
		if (llMin > llSum) {
			llMin = llSum;
		}
	}

	// 結果 - セット
	sprintf(lc1Out, "%lld\n", llMin);

	// 結果 - 表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 31488
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <ll, ll> P;

const ll MOD=1000000007;
ll s[100000],t[100000],x[100000];
int A,B,Q;
P shorts(ll x){
    if(x<=s[0]){
        return P(abs(s[0]-x),s[0]);
    }
    else if(x>=s[A-1]){
        return P(abs(s[A-1]-x),s[A-1]);
    }
    else {
        if(*lower_bound(s,s+A,x)-x<=x-*(lower_bound(s,s+A,x)-1)){
            return P(*lower_bound(s,s+A,x)-x,*lower_bound(s,s+A,x));
        }
        else return P(x-*(lower_bound(s,s+A,x)-1),*(lower_bound(s,s+A,x)-1));
    }
}
P shortt(ll x){
    if(x<=t[0]){
        return P(abs(t[0]-x),t[0]);
    }
    else if(x>=t[B-1]){
        return P(abs(t[B-1]-x),t[B-1]);
    }
    else {
        if(*lower_bound(t,t+B,x)-x<=x-*(lower_bound(t,t+B,x)-1)){
            return P(*lower_bound(t,t+B,x)-x,*lower_bound(t,t+B,x));
        }
        else return P(x-*(lower_bound(t,t+B,x)-1),*(lower_bound(t,t+B,x)-1));
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>A>>B>>Q;
    rep(i,0,A) cin>>s[i];
    rep(i,0,B) cin>>t[i];
    rep(i,0,Q){
        cin>>x[i];
        ll ng=0, ok=2e10;
        while(ok-ng>1){
            ll mid=(ng+ok)/2;
            bool T=false;
            if(x[i]<=s[0]||x[i]>=s[A-1]){
                if(shorts(x[i]).fr+shortt(shorts(x[i]).sc).fr <= mid) T=true;
            }
            else {
                ll pos=*lower_bound(s, s+A, x[i]);
                if(abs(pos-x[i])+shortt(pos).fr <= mid) T=true;
                pos=*(lower_bound(s, s+A, x[i])-1);
                if(abs(pos-x[i])+shortt(pos).fr <= mid) T=true;
            }
            if(x[i]<=t[0]||x[i]>=t[B-1]){
                if(shortt(x[i]).fr+shorts(shortt(x[i]).sc).fr <= mid) T=true;
            }
            else {
                ll pos=*lower_bound(t, t+B, x[i]);
                if(abs(pos-x[i])+shorts(pos).fr <= mid) T=true;
                pos=*(lower_bound(t, t+B, x[i])-1);
                if(abs(pos-x[i])+shorts(pos).fr <= mid) T=true;
            }
            if(T) ok=mid;
            else ng=mid;
        }
        cout <<ok<<"\n";
    }
}

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

const int _ = 1e5 + 7;
struct permutation{
	int arr[_];
	void input(int len){arr[0] = len; for(int i = 1 ; i <= len ; ++i) cin >> arr[i];}
	int& operator [](int x){return arr[x];}
	permutation reverse(){
		permutation temp; temp[0] = arr[0];
		for(int i = 1 ; i <= arr[0] ; ++i) temp[arr[i]] = i;
		return temp;
	}
	friend permutation operator *(permutation p , permutation q){
		permutation temp; for(int i = 1 ; i <= p[0] ; ++i) temp[i] = p[q[i]];
		temp[0] = p[0]; return temp;
	}
	permutation pow(int x){
		bool vis[_] = {}; permutation now; now[0] = arr[0];
		if(x == 0) for(int i = 1 ; i <= arr[0] ; ++i) now[i] = i;
		else
			for(int i = 1 ; i <= arr[0] ; ++i)
				if(!vis[i]){
					int dis = 0 , tmp = i; vector < int > pot;
					do{++dis; vis[tmp] = 1; pot.push_back(tmp); tmp = arr[tmp];}while(tmp != i);
					for(int i = 0 ; i < pot.size() ; ++i) now[pot[i]] = pot[(i + x % pot.size()) % pot.size()];
				}
		return now;
	}
	void output(){for(int i = 1 ; i <= arr[0] ; ++i) cout << arr[i] << ' ';}
}arr[6] , tmp; int N , K;

int main(){
	int N; cin >> N >> K; arr[0].input(N); arr[1].input(N); --K;
	for(int i = 2 ; i < 6 ; ++i) arr[i] = arr[i - 1] * arr[i - 2].reverse();
	tmp = (arr[1] * arr[0].reverse() * arr[1].reverse() * arr[0]).pow(K / 6);
	(tmp * arr[K % 6] * tmp.reverse()).output();
	return 0;
}

Measured memory_bytes: 12516
#include <iostream>
#include <vector>

using namespace std;

unsigned long long gcd(unsigned long long a, unsigned long long b) {
    unsigned long long c;
    if(a<b) {
        c = a;a = b; b = c;
    }

    while(b>0uLL) {
        c = b; b = a%b; a = c;
    }
    return a;
}

int main(int argc, char const *argv[])
{
    int n; cin >> n;
    vector<unsigned long long> a(n,0uLL);
    vector<unsigned long long> l(n+1,0uLL);
    vector<unsigned long long> r(n+1,0uLL);
    for(int i=0;i<n;++i) {
        cin >> a[i];
    }
    l[0] = 0uLL;
    for(int i=1;i<n;++i) {
        l[i] = gcd(l[i-1], a[i-1]);
    }
    r[n-1] = 0uLL;
    for(int i=n-2;i>=0;--i) {
        r[i] = gcd(r[i+1], a[i+1]);
    }
    unsigned long long m = 0uLL;
    for(int i=0;i<n;++i) {
        // cout << i << " " << l[i] << " " << r[i] << " " << gcd(l[i], r[i]) << endl;
        m = max(m, gcd(l[i], r[i]));
    }
    cout << m << endl;
    
    
    return 0;
}


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

int main(void) {

  long h,w,ch,cw,dh,dw;
  scanf("%ld %ld\n%ld %ld\n%ld %ld", &h, &w, &ch, &cw, &dh, &dw);
  char **s;
  long **warp;
  s = (char **)malloc(sizeof (char*) * h);
  warp = (long **)malloc(sizeof (long*) * h);
  for (long i = 0; i < h; i++) {
  	s[i] = (char *)malloc(sizeof (char) * (w+1));
    warp[i] = (long *)malloc(sizeof (long) * w);
    scanf("%s", s[i]);
  }
  long **visited,size = h*w;
  visited = (long **)malloc(sizeof (long*) * size);
  for (long i = 0; i < size; i++) {
    visited[i] = (long *)malloc(sizeof (long) * 2);
  }
  long cur = 0,head,tail,start,end,sq_h,sq_w;
  for (long i = 0; i < h; i++) {
    for (long j = 0; j < w; j++) {
      warp[i][j] = -1;
      if (s[i][j] == '#') {
        visited[cur][0] = i;
        visited[cur][1] = j;
        cur++;
      }
    }
  }
  warp[ch-1][cw-1] = 0;
  visited[cur][0] = ch-1;
  visited[cur][1] = cw-1;
  head = cur;
  start = cur;
  end = cur;
  cur++;
  int flag;
  while (cur < size) {
    flag = 0;
    for (long i = start; i <= end; i++) {
      sq_h = visited[i][0];
      sq_w = visited[i][1];
      if (sq_h != 0 && s[sq_h-1][sq_w] == '.' && warp[sq_h-1][sq_w] == -1) {
        warp[sq_h-1][sq_w] = warp[sq_h][sq_w];
        visited[cur][0] = sq_h-1;
        visited[cur][1] = sq_w;
        cur++;
        flag = 1;
      }
      if (sq_h != h-1 && s[sq_h+1][sq_w] == '.' && warp[sq_h+1][sq_w] == -1) {
        warp[sq_h+1][sq_w] = warp[sq_h][sq_w];
        visited[cur][0] = sq_h+1;
        visited[cur][1] = sq_w;
        cur++;
        flag = 1;
      }
      if (sq_w != 0 && s[sq_h][sq_w-1] == '.' && warp[sq_h][sq_w-1] == -1) {
        warp[sq_h][sq_w-1] = warp[sq_h][sq_w];
        visited[cur][0] = sq_h;
        visited[cur][1] = sq_w-1;
        cur++;
        flag = 1;
      }
      if (sq_w != w-1 && s[sq_h][sq_w+1] == '.' && warp[sq_h][sq_w+1] == -1) {
        warp[sq_h][sq_w+1] = warp[sq_h][sq_w];
        visited[cur][0] = sq_h;
        visited[cur][1] = sq_w+1;
        cur++;
        flag = 1;
      }
    }
    if (flag == 1) {
      start = end+1;
      end = cur-1;
    } else {
      tail = cur-1;
      for (long i = head; i <= tail; i++) {
        sq_h = visited[i][0];
        sq_w = visited[i][1];
        for (long j = sq_h-2; j <= sq_h+2; j++) {
          for (long k = sq_w-2; k <= sq_w+2; k++) {
            if (j >= 0 && j < h && k >= 0 && k < w && s[j][k] == '.' && warp[j][k] == -1) {
              warp[j][k] = warp[sq_h][sq_w]+1;
              visited[cur][0] = j;
              visited[cur][1] = k;
              cur++;
              flag = 1;
            }
          }
        }
      }
      if (flag == 0) {
        break;
      }
      head = tail+1;
      start = head;
      end = cur-1;
    }
  }
  printf("%ld\n", warp[dh-1][dw-1]);

  return 0;
}

Measured memory_bytes: 49564
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;

int main()
{
    while (true) {
        uint h, w;
        cin >> h >> w;

        if (!h && !w) {
            break;
        }

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                putchar('#');
            }
            putchar('\n');
        }
        putchar('\n');
    }
}



Measured memory_bytes: 3080
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int k = stdIn.nextInt();
		int[] ans = new int[10];
		int index = 0;
		
		while( n != 0 || k != 0 ){
			int sum = 0;
			int[] num = new int[n];
			for(int i = 0; i < k; i++){
				num[i] = stdIn.nextInt();
				sum += num[i];
			}
			for(int i = k; i < n; i++){
				num[i] = stdIn.nextInt();
			}
		
			int max = sum;
			for(int i = 0; i < n-k; i++){
				sum = sum-num[i]+num[i+k];
				if( sum > max ){
					max = sum;
				}
				
			}
			ans[index] = max;
			index++;
			n = stdIn.nextInt();
			k = stdIn.nextInt();
		}
		for(int i = 0; i < index; i++){
			System.out.println(ans[i]);
		}
	}
}

Measured memory_bytes: 13000
S = gets.chomp.chars
Q = gets.to_i
QList = []
Q.times{ QList << gets.chomp }

reverse = false
QList.each do  |query|
  ch = query.split
  if ch[0].to_i == 1
    reverse = !reverse
  elsif ch[1].to_i == 1 && reverse || ch[1].to_i == 2 && !reverse
    S << ch[2]
  else
    S.unshift(ch[2])
  end
end

if reverse
  S.reverse!
end

puts S.join


Measured memory_bytes: 39164
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			int n = sc.nextInt();
			char[] s = sc.next().toCharArray();
			int num = 0;
			
			for(int i=1;i<n;i++) {
				if(s[i]=='E') {
					num++;
				}
			}
			
			int numi = num;
			
			for(int i=1;i<n;i++) {
				
				if(s[i-1]=='W') {
					numi++;
				}
				if(s[i]=='E') {
					numi--;
				}
				
				num = Math.min(num, numi);
				
			}
			
			System.out.println(num);
			
	    }
				
	}
	


Measured memory_bytes: 43304
import java.util.*;

class Main{

    String[] shape = {"Rock", "Fire", "Scissors", "Snake", "Human", "Tree", "Wolf", "Sponge", "Paper", "Air", "Water", "Dragon", "Devil", "Lightning", "Gun"};

    void solve(){
	Scanner sc = new Scanner(System.in);

	while(true){
	    int n = sc.nextInt();
	    if(n==0) break;

	    String[] hands = new String[n];
	    for(int i=0; i<n; i++){
		hands[i] = sc.next();
	    }

	    boolean[] win = new boolean[n];
	    boolean[] lose = new boolean [n];
	    for(int i=0; i<n; i++){
		int index = 0;
		for(int j=0; j<shape.length; j++){
		    if(hands[i].equals(shape[j])){
			index = j;
			break;
		    }
		}
		for(int j=1; j<=7; j++){
		    String losehand = shape[(index+j)%shape.length];
		    for(int k=0; k<hands.length; k++){
			if(hands[k].equals(losehand)){
			    win[i] = true;
			    lose[k] = true;
			}
		    }
		}
	    }

	    ArrayList<String> winner = new ArrayList<String>();
	    for(int i=0; i<n; i++){
		if(win[i] && !lose[i]){
		    if(!winner.contains(hands[i]))winner.add(hands[i]);
		    if(winner.size()>=2) break;
		}
	    }

	    if(winner.size()==1){
		System.out.println(winner.get(0));
	    }else{
		System.out.println("Draw");
	    }
	}
    }

    public static void main(String[] args){
	new Main().solve();
    }
}

Measured memory_bytes: 12000
def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))
    # 式 f の末尾に "+" を追加するかしないかして次の数字を追加
    return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1])

s = input()
n = len(s)

print(dfs(0, s[0]))


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

using namespace std;
#define ll long long
const long long mod=1e9+7;
const int maxn=1e6+7;
ll a[maxn],b[maxn];

//int dp[maxn][maxn];

int main (){
	int n;cin>>n;
    map<ll,ll>mp;
    ll sum=0;
    for(int i=1;i<=n;i++){
			cin>>a[i];
			sum^=a[i];
    }
    for(int i=1;i<=n;i++){
			cout<<(a[i]^sum)<<endl;
    }
	return 0;
}


Measured memory_bytes: 5188
N=int(input())
st=input().split()
a=[]
for i in range(N):
    a.append(int(st[i]))
dig=[i for i in range(-100,101)]
cost = []
for i in range(len(dig)):
    x=[]
    for j in range(len(dig)):
        x.append((dig[i]-dig[j])**2)
    cost.append(x)
result=0
for d in range(len(dig)):
    now=0
    for i in range(N):
        now+=cost[d][a[i]+100]
    if d==0:result=now
    elif now<result:result=now
print(result)

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

void call(int n) {
  for (int i = 1; i <= n; i++) {
    int x = i;
    // 3の倍数
    if (x % 3 == 0) {
      cout << " " << i;
    } else {
      // あるいは、いずれかの桁の数に3を含む
      while (x) {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
        x = x / 10;
      }
    }
  }
  cout << endl;
}

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

  call(n);
  return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n, d, x;
    cin >> n >> d >> x;
    int ans = x;
    rep(i, n) {
        int a;
        cin >> a;
        ans += (d+a-1) / a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
S = [input() for i in range(h)]

ans = [[0 for i in range(w)] for j in range(h)]


def dfs(x, y):
    s = S[x][y]
    if s == '#':
        ans[x][y] = '#'
        for dx in range(-1, 2):
            for dy in range(-1, 2):
                nx = x + dx
                ny = y + dy
                if 0 <= nx < h and 0 <= ny < w and S[nx][ny] != '#':
                    ans[nx][ny] += 1


for i in range(h):
    for j in range(w):
        dfs(i, j)

for a in ans:
    print(*a, sep='')

Measured memory_bytes: 3444
x,k,d = map(int,input().split())
if x >= 0:
    a = abs(x) % d
    b = abs(x) // d
    if k <= b:
        print(abs(x-d*k))
        exit()
    if (k - b) % 2 == 0:
        print(abs(a))
    else:
        print(abs(a-d))
else:
    a = -(abs(x) % d)
    b = abs(x) // d
    if k <= b:
        print(abs(x+k*d))
        exit()
    if (k - b) % 2 == 0:
        print(abs(a))
    else:
        print(abs(a+d))

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n);++i)
const int INF =1001001001;
using ll=long long;
using P = pair<int,int>;
using Graph =vector<string>;
Graph field;
queue<P> q;

int main() {
  ll ans,d,t,s;
  ans=0;
  cin>>d>>t>>s;
  ans=d/s;
  if(d%s)ans++;
  if(ans<=t){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

}



Measured memory_bytes: 3584
using System;

class Modulo
{
    private const int MOD = 1000000007;
    private readonly int[] m_facs;
    public int Mul(int a, int b) => (int)(Math.BigMul(a, b) % MOD);
    public Modulo(int n)
    {
        m_facs = new int[n + 1];
        m_facs[0] = 1;
        for (int i = 1; i <= n; ++i)
            m_facs[i] = Mul(m_facs[i - 1], i);
    }
    public int Fac(int n) => m_facs[n];
    public int Pow(int a, int m)
    {
        switch (m)
        {
            case 0:
                return 1;
            case 1:
                return a;
            default:
                int p1 = Pow(a, m / 2);
                int p2 = Mul(p1, p1);
                return ((m % 2) == 0) ? p2 : Mul(p2, a);
        }
    }
    public int Div(int a, int b) => Mul(a, Pow(b, MOD - 2));
    public int Ncr(int n, int r)
    {
        if (n < r) return 0;
        if (n == r) return 1;
        int res = Fac(n);
        res = Div(res, Fac(r));
        res = Div(res, Fac(n - r));
        return res;
    }
}

public class Hello
{
    public static int MOD = 1000000007;
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, long.Parse);
        var asum = 0L;
        var a2sum = 0L;
        for (int i = 0; i < n; i++)
        {
            asum += a[i];
            asum %= MOD;
            a2sum += a[i] * a[i];
            a2sum %= MOD;
        }
        var ans = asum * asum;
        ans %= MOD;
        ans -= a2sum;
        if (ans < 0) ans += MOD;
        ans %= MOD;
        var md = new Modulo(100);
        ans = md.Div((int)ans, 2);
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 47252