akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n, x, t; cin >> n >> x >> t;
  cout << ((n - 1) / x + 1) * t << endl;


}








Measured memory_bytes: 3568
# ALDS1_6_A
def countingSort(a):
    j = max(a)
    c = [0 for _ in range(j + 1)]
    b = [None for _ in range(n)]
    for k in a: # 出現数を記録
        c[k] += 1
    for k in range(1, j+1): # bにおけるインデックスを記録
        c[k] += c[k - 1]
    for k in a[::-1]: # 逆順により安定なソート
        c[k] -= 1
        b[c[k]] = k
    return b

n = int(input())
a = list(map(int, input().split()))
print(*countingSort(a))


Measured memory_bytes: 224384
#include <iostream>
#define llint long long

using namespace std;

int n;
llint t[20][20];
llint dp[1<<16];

int main(void)
{
  while(1){
    cin >> n;
    if(n == 0) break;

    for(int i = 1; i <= n; i++){
      for(int j = 0; j <= n; j++){
        cin >> t[i][j];
      }
    }

    int N = 1<<n;
    for(int i = 0; i < N; i++) dp[i] = 1e18;
    dp[0] = 0;

    for(int i = 0; i < N; i++){
      for(int j = 1; j <= n; j++){
        if(i & (1<<(j-1))) continue;
        for(int k = 0; k <= n; k++){
          if(k > 0 && !(i & (1<<(k-1)))) continue;
          dp[i | (1<<(j-1))] = min(dp[i |(1<<(j-1))], dp[i] + t[j][k]);
        }
      }
    }
    cout << dp[N-1] << endl;
  }
  return 0;
}



Measured memory_bytes: 3508
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, k;
    cin >> n >> k;

    string s;
    cin >> s;

    s[k-1] = tolower(s[k-1]);
    cout << s << endl;
    
}

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

using namespace std;

int main() {

	int h, w, k;
	cin >> h >> w >> k;

	vector<string> s(h);
	int counter = 0;
	for (int i = 0; i < h; i++) {
		cin >> s[i];

		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				counter++;
			}
		}

	}
	int totalcount = counter;

	int res = 0;
	for (int i = 0; i < pow(2,h); i++) {
	
		for (int j = 0; j < pow(2, w); j++) {

			counter = 0;

			for (int ii = 0; ii < h; ii++) {
				for (int jj = 0; jj < w; jj++) {

					if (((i & (1 << ii)) || (j & (1 << jj))) && s[ii][jj]=='#') {
						counter++;
					}

				}
			}

			if (totalcount - counter == k) { res++; }
//			cout << i << " " << j << " " << counter << " " << res << endl;

		}
	}

	cout << res << endl;

	return 0;

}

Measured memory_bytes: 4044
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
int main()
{
    ll x,y,n,p,q,i,j,r,h,l,m,s;
    cin>>x>>y>>p>>q>>r;
    ll a[p],b[q],c[r];
    for(i=0;i<p;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<q;i++)
    {
        cin>>b[i];
    }
    for(i=0;i<r;i++)
    {
        cin>>c[i];
    }
    vector<pair<ll,ll>>v;
    h=0;
    for(i=0;i<p;i++)
    {
        v.push_back(make_pair(a[i],1));
        h++;
    }
    for(i=0;i<q;i++)
    {
        v.push_back(make_pair(b[i],2));
        h++;
    }
    for(i=0;i<r;i++)
    {
        v.push_back(make_pair(c[i],3));
        h++;
    }
    sort(v.begin(),v.end());
    vector<ll>u;
    s=0;
    l=x;
    m=y;
    for(i=h-1;i>=0;i--)
    {
        if(v[i].second==1&&l>0)
        {
            u.push_back(v[i].first);
            s++;
            l--;
        }
        else if(v[i].second==2&&m>0)
        {
            u.push_back(v[i].first);
            s++;
            m--;
        }
        else if(v[i].second==3)
        {
            u.push_back(v[i].first);
            s++;
            q--;
        }
        if(p==0&&q==0)
        {
            break;
        }
    }
    p=0;
    for(i=0;i<x+y;i++)
    {
        p=p+u[i];
    }
    cout<<p<<endl;
}
//=x-j+(y-1-(j+i+1))&&(y-1-(j+i+1))>x-1&&j+i+1<y-1

Measured memory_bytes: 16232
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main{
	static int n;
	static int w;
	static int[] value;
	static int[] weight;
	static long[][] dp;

	public static long solve(int i, int remw) {
		if (remw < 0)
			return -(int) 1e9;
		if (i == n)
			return 0;
		if (dp[i][remw] != -1)
			return dp[i][remw];
		return dp[i][remw] = Math.max(value[i] + solve(i + 1, remw - weight[i]), solve(i + 1, remw));

	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		n = sc.nextInt();
		w = sc.nextInt();
		dp = new long[n + 1][w + 1];
		for (long[] f : dp)
			Arrays.fill(f, -1);
		value = new int[n];
		weight = new int[n];

		for (int i = 0; i < n; i++) {
			weight[i] = sc.nextInt();
			value[i] = sc.nextInt();
		}
		pw.println(solve(0, w));

		pw.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}


Measured memory_bytes: 138628
n=int(input())
s=list(input())
f=0
b=-1
for d in range(1,n):
    c=0
    for i in range(n-d):
        if s[i]==s[i+d] and c<d:
            if b==-1:
                b=i
            c+=1
            f=max(f,c)
        else:
            c=0
            b=-1
print(f)

Measured memory_bytes: 43260
import itertools
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        A, B, C, D = map(int, list(input().rstrip()))
        op = ['+', '-']
        for op1, op2, op3 in itertools.product(op, op, op):
            AB = A + B if op1 == '+' else A - B
            ABC = AB + C if op2 == '+' else AB - C
            ABCD = ABC + D if op3 == '+' else ABC - D
            if ABCD == 7:
                print('{a}{op1}{b}{op2}{c}{op3}{d}=7'.format(a=A, b=B, c=C, d=D, op1=op1, op2=op2, op3=op3))
                exit()


# Run main
if __name__ == '__main__':
    AtCoder().main()

Measured memory_bytes: 38512
using System;
class Program
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    string[] H = Console.ReadLine().Split(' ');
    int buf = 0, max = 0;
    for (int i = 1; i < N; i++)
    {
      if (int.Parse(H[i - 1]) >= int.Parse(H[i]))
      {
        buf++;
      }
      else
      {
        buf = 0;
      }
      max = Math.Max(max, buf);
    }
    Console.WriteLine(max);
  }
}

Measured memory_bytes: 22620
import numpy as np

N, M = map(int, input().split())
S = tuple(map(int, input().split()))
T = np.array(input().split(), np.int64)
mod = 10 ** 9 + 7

dp = np.ones(M + 1, np.int64)
for i in S:
    tmp = (T == i)
    dp[1:] = (np.cumsum(tmp * dp[:-1]) + dp[1:]) % mod

print(dp[-1])


Measured memory_bytes: 12460
fun mPow(n: Long, ex: Long, m: Long): Long {
    var x = n
    var remain = ex
    var result = 1L
    while (remain > 0) {
        if (remain % 2L == 1L) {
            result = (result * x) % m
        }
        x = (x * x) % m
        remain /= 2
    }
    return result
}

fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val d = readLine()?.split(" ")?.map(String::toInt) ?: return
    val m = 998244353L
    if (d.first() != 0) {
        println("0")
        return
    }
    var count = 1L
    val map = d.groupBy { it }
    val max = d.max() ?: return
    if (map[0]?.size ?: 0 > 1) {
        println("0")
        return
    }
    1.until(max + 1).forEach { i ->
        val p = map[i - 1]?.size ?: 0
        val c = map[i]?.size ?: 0
        count = (count * mPow(p.toLong(), c.toLong(), m)) % m
    }
    println(count.toString())
}

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

long long n, t, s, a[200005];
int main() {
	int i;
	cin >> n >> t;
	for(i=0; i<n; i++) scanf("%lld", &a[i]);
	a[n] = 2e9;
	for(i=1; i<=n; i++) s += min(t, a[i] - a[i-1]);
	cout << s;
	return 0;
}

Measured memory_bytes: 1792
n, k = map(int, input().split())
cnt = [0] * (n + 1)
MOD = 10**9+7
l, r = 0, 0
for i in range(n + 1):
    l += i
    r += n-i
    #print(l, r)
    cnt[i] = (r - l + 1) % MOD
ans = 0
for i in range(k-1, n + 1):
    ans += cnt[i] % MOD

print(ans % MOD)


Measured memory_bytes: 16808
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,m,q;

int main(){
  ll ans=0;
  cin >> n >> m>>q;

  
  vi a(q),b(q),c(q),d(q);
  
  REP(i,q){
    cin>>a[i]>>b[i]>>c[i]>>d[i];
    a[i]--;
    b[i]--;
  }
  

  vi nums(n,1);

  for(ll i=0;i<10000000000;i++){
    ll score=0;
    
    for(ll j=0;j<q;j++){
      if ( (nums[n-1-b[j]]-nums[n-1-a[j]])==c[j] ){
        score+=d[j];
      }
    }

    ans=max(ans,score);


    for(ll j=0;j<n;j++){
      nums[j]++;
      if (nums[j]!=m+1){
        break;
      }else{
        nums[j]=0;
      }
    }
    if (nums[n-1]==0)break;
    for(ll j=n-2;j>=0;j--){
      if (nums[j]==0)nums[j]=nums[j+1];
    }


  }


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

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

// using mint = modint1000000007;
// using mint = modint998244353;

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

void solve() {
    Int n;
    cin >> n;
    vector<Int> x(n), y(n);
    for (Int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        Int nx = x[i] + y[i];
        Int ny = x[i] - y[i];
        x[i] = nx;
        y[i] = ny;
    }
    sort(all(x));
    sort(all(y));
    Int x_ma = abs(x.front() - x.back());
    Int y_ma = abs(y.front() - y.back());
    print(max(x_ma, y_ma));
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 6332
a,b,c= input().split()
x,y,z=(int(a),int(b),int(c))
sample_list = [x,y,z]
abs_list = [abs(x-y),abs(x-z),abs(y-z)]
abs_max = max(abs_list)
abs_min = min(abs_list)
print(abs_max)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
    int N;
    cin >> N;
    int *A = new int[N];
    int temp;
    priority_queue<int> pque;

    for (int i=0;i<N;i++){
        cin >> A[i];
        pque.push(A[i]);
    }

    for (int i=0;i<N;i++){
        if (A[i] == (temp = pque.top())){
            pque.pop();
            cout << pque.top() << endl;
            pque.push(temp);
        }else{
            cout << pque.top() << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
long long x[maxn];
long long color[maxn], size[maxn], acc[maxn];
vector<pair<long long*, long long> > snap[maxn];
long long a[maxn], b[maxn], vi[maxn];
int find(int x){
  if(color[x] == x) return x;
  return find(color[x]);
}
int main(){
  int n, m; cin >> n >> m;
  for(int i = 1; i <= n; i++) cin >> x[i];
  for(int i = 1; i <= n; i++) color[i] = i, size[i] = 1, acc[i] = x[i];
  for(int i = 1; i <= m; i++) cin >> a[i] >> b[i] >> vi[i];
  vector<int> od(m);
  iota(od.begin(), od.end(), 1);
  sort(od.begin(), od.end(), [&](int a, int b){
    return vi[a] < vi[b];
  });
  for(int v : od){
    int av = find(a[v]), bv = find(b[v]);
    if(color[av] != color[bv]){
      if(size[av] < size[bv]) swap(av, bv);
      if(size[av] == size[bv]){
        snap[v].push_back({&size[av], size[av]});
        size[av]++;
      }
      snap[v].push_back({&acc[av], acc[av]});
      acc[av] += acc[bv];
      snap[v].push_back({&acc[bv], acc[bv]});
      acc[bv] = 0;
      snap[v].push_back({&color[bv], color[bv]});
      color[bv] = av;
    }
  }
  reverse(od.begin(), od.end());
  int remove = 0;
  for(int v : od){
    int av = find(a[v]), bv = find(b[v]);
    assert(av == bv);
    if(acc[av] < vi[v]){
      remove++;
      for(auto it : snap[v]) *it.first = it.second;
    }
  }
  cout << remove << endl;
  return 0;
}
    


Measured memory_bytes: 16256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	char a[26];
	for(char c='A';c<='Z';c++) a[c-'A']=c;
	int n; cin>>n;
	string s; cin>>s;
	for(int i=0;i<s.length();i++)
	{
	    int pos = s[i]-'A';
	    pos = (pos+n)%26;
	    cout<<a[pos];
	}
	
	
	return 0;
}


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

int n;
int v[15];
int sum;
char T[4] = "-0+";

int main() {
	cin >> n;
	for (int i = 0; i < 531441; i++) {
		sum = 0;
		for (int j = 0; j < 12; j++) {
			v[j] = (i / (int)(pow(3, j))) % 3;
			sum += (v[j] - 1)*(int)(pow(3, j));
		}
		bool ok = false;
		if (sum == n) {
			for (int j = 11; j >= 0; j--) {
				if (v[j] >= 2) {
					ok = true;
				}
				if (ok == true) {
					cout << T[v[j]];
				}
			}
		}
	}
	cout << endl;
	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dump(x) cerr << #x " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define endl '\n'

#ifdef _DEBUG27_
    //#define STRESS 1
#endif

typedef long long llong;

const int INF = 2e9 + 999;
const llong LINF = 2e18 + 999;

void inv(bool e);
template<typename T> T sign(T a);
template<typename T> void die(T &a);
template<typename T> void umax(T &a, T b);
template<typename T> void umin(T &a, T b);

bool brute, alter;
int cnt_tests = 1;

// Improving csa rating

// Code below

int n;

map<llong, int> cnt;
void inp() {
    cin >> n;
    llong x;
    for (int i = 0; i < n; i++) {
        cin >> x;
        cnt[x]++;
    }
}

void solve() {
    vector<llong> lol;
    for (auto x = cnt.rbegin(); x != cnt.rend(); x++) {
        if (x->se < 2) {
            continue;
        }
        while (x->se >= 2 && sz(lol) < 2) {
            lol.pb(x->fi);
            x->se -= 2;
        }
    }
    cout << (sz(lol) < 2 ? 0 : lol[0] * lol[1]);
}

void stress() {

}

void naive() {

}

void run();
int main() {
    #ifdef _DEBUG27_
        if (1)
            freopen("input.txt", "r", stdin);
    #else
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (0) {
            freopen("palindrome.in", "r", stdin);
            freopen("palindrome.out", "w", stdout);
        }
    #endif
    srand(time(0));
    #ifdef STRESS
        brute = true;
    #else
        brute = false;
    #endif

    for (int i = 0; (i < cnt_tests); i++) {
        run();
    }
    cerr << endl << "Time: " << clock() / 1000.0 << " ms";
    return 0;
}

void run() {
    if (!brute) {
        inp();
    }
    else {
        stress();
    }
    solve();
    cout << endl;
}

template<typename T>
void die(T &a) {
    cout << a;
    exit(0);
}

template<typename T>
T sign(T a) {
    if (a == 0)
        return 0;
    if (a < 0)
        return -1;
    return 1;
}

template<typename T>
void umax(T &a, T b) {
    if (b > a)
        a = b;
}

template<typename T>
void umin(T &a, T b) {
    if (b < a)
        a = b;
}

void inv(bool e) {
    if (!e) {
        vector<int> a;
        a[-1] += 1;
    }
}

/** CLEARING BUFFER

    cout << VAL << flush;

    OR

    printf(VAL);
    fflush(stdout);
*/


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;

int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);

    ll N = 3e3 + 10, i, j, n;
    cin >> n;
    vector<ld> p(n + 1), dp(N, 0);
    for (i = 0; i < n; i++)
        cin >> p[i + 1];

    dp[0] = 1;
    for (i = 1; i <= n; i++)
        for (j = i; j >= 0; j--)
            dp[j] = dp[j] * (1 - p[i]) + (j == 0 ? 0 : dp[j - 1] * p[i]);

    //for (i = 0; i <= n; i++)
      //  cout << dp[i] << ' ';

    ld sum = 0;
    for (i = (n + 1) / 2; i <= n; i++)
        sum += dp[i];

    printf("%.12Lf\n", sum);

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <map>
#include <cstring>
using namespace std;
const int mod = 100000;

const int MAX_W = 101;
const int MAX_H = 101;
int dp[MAX_W][MAX_H][4];
int w, h;
// a ??? 0 ?????¨??????????????????
// a ??? 1 ?????¨??????????????£??????
// a ??? 2 ?????¨????¨?????????????
// a ??? 3 ?????¨????¨?????????£??????
// i????¨????j??????
int func(int i, int j, int a){
	if(i >= w || j >= h) return 0;
	if(dp[i][j][a] != -1) return dp[i][j][a];
	if(i == w - 1 && j == h - 1) return 1;
	int rec = 0;
	if(a == 0) rec = func(i, j + 1, 1);
	else if(a == 1) rec = func(i, j + 1, 1) + func(i + 1, j, 2);
	else if(a == 2) rec = func(i + 1, j, 3);
	else if(a == 3) rec = func(i, j + 1, 0) + func(i + 1, j, 3);
	return dp[i][j][a] = rec % mod;
	//return 0;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	
	while(cin >> w >> h && w != 0 && h != 0){
	memset(dp, -1, sizeof(dp));
	cout << (func(0, 1, 1) + func(1, 0, 3)) % mod << endl;
	}
}

Measured memory_bytes: 1364
#include <stdio.h>

/*long double myPow(double x,long n){
  if(n == 0) return 1;
  if(n % 2 == 0){
    return myPow(x*x,n/2);
  }else{
    return x*myPow(x,n-1);
  }
}

long myPow2(double x,long n){
  if(n == 0) return 1;
  else
    return x*myPow2(x,n-1);
}
*/

int main(){
  long int X,y=100,y1,i;
  scanf("%ld",&X);
  
  for(i=1;;i++){

    y1 = y/100;
    y += y1;
    if(y >= X){
      printf("%ld\n",i);
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 1736
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
        return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
        return readInts()[0];
}
auto readLongs() {
        return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
        return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

bool isA(string s) {
    if(s[0..2] != ">'") {
        return false;
    }
    if(s[$-1] != '~') {
        return false;
    }
    auto m = s[2..$-1];
    if(m.length % 2 == 0) {
        return false;
    }
    if(m.length <= 1) {
        return false;
    }
    if(m[$/2] != '#') {
        return false;
    }
    if(m.count!(a => a != '=') != 1) {
        return false;
    }
    return true;
}

bool isB(string s) {
    if(s[0..2] != ">^") {
        return false;
    }
    if(s[$-2..$] != "~~") {
        return false;
    }
    auto m = s[2..$-2];
    if(m.length % 2 == 1) {
        return false;
    }
    if(m.empty()) {
        return false;
    }
    while(!m.empty()) {
        if(m[0..2] != "Q=") {
            return false;
        }
        m = m[2..$];
    }
    return true;
}

void main(){
    auto n = readLong();
    foreach(i; iota(n)) {
        auto s = readln().chomp();
        if(isA(s)) {
            writeln("A");
        } else if(isB(s)) {
            writeln("B");
        } else {
            writeln("NA");
        }
    }
}

Measured memory_bytes: 2464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#define rep(i, n)  for (int i = 0; i <  (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const ll INF = ll(1e18)+1;

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

    ll N,M;
    cin >> N >> M;

    if(N==M) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
fun main() {
    val n = nextInt()
    val array = IntArray(100001)
    var sum = 0L
    repeat(n) {
        val a = nextInt()
        sum += a
        array[a]++
    }
    val q = nextInt()
    printString {
        repeat(q) {
            val (b, c) = next2Int()
            sum += (c - b) * array[b]
            array[c] += array[b]
            array[b] = 0
            appendln(sum)
        }
    }
}

val sc = java.util.Scanner(System.`in`)
fun next(): String = sc.next()
fun nextInt() = sc.nextInt()
fun next2Int() = Pair(nextInt(), nextInt())
fun next3Int() = Triple(nextInt(), nextInt(), nextInt())
fun nextIntArray(size: Int) = IntArray(size) { nextInt() }
fun nextLong() = sc.nextLong()
fun nextLine(): String = sc.nextLine()
fun nextList() = nextLine().split(" ")
fun printYesNo(isYes: Boolean) = println(if (isYes) "Yes" else "No")
fun printString(action: StringBuilder.() -> Unit) = println(buildString(action))


Measured memory_bytes: 62828
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<long long>a(N);
  long long c = 1;
    int b = 0;
  for(int i = 0; i < N ;i++){
    cin >> a.at(i);
    c = c * a.at(i);
      if(c == 0 && a.at(i) !=0){
          b++;
  }
      if(a.at(i) == 0){
          b=0;
          break;
      }
  }
  if(c > 1000000000000000000 || b>0 ){
    cout << -1 << endl;
  }    
  else{
    cout << c << endl;
  }
}

Measured memory_bytes: 4052
N,M = map(int,input().split())
A=[input() for _ in range(N)]
B=[input() for _ in range(M)]

ans="No"

for i in range(N-M+1):
    for j in range(N-M+1):
        flag = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l]!=B[k][l]:
                    flag = False
                    break
                    
        if flag:
            ans="Yes"
            break

print(ans)

Measured memory_bytes: 9068
#include <stdio.h>
#include <algorithm>
int main(){
  int n,m,cnt=0;
  scanf("%d",&n);
  scanf("%d",&m);
  int s[m],c[m],num[n];
  for(int i=0;i<n;i++) num[i]=10;
  for(int i=0;i<m;i++){
    scanf("%d",&s[i]);
    scanf("%d",&c[i]);
  }
  for(int i=0;i<m;i++){
    if(num[n-s[i]]==10||num[n-s[i]]==c[i]) num[n-s[i]]=c[i];
    else cnt++;
  }
  for(int i=0;i<n-1;i++) if(num[i]==10) num[i]=0;
  if(num[n-1]==10){
    if(n!=1){
      num[n-1]=1;
    }else num[n-1]=0;
  }
  if((num[n-1]==0&&n!=1)||cnt>0) printf("-1\n");
  else if(n==1&&num[n-1]==0&&cnt==0) printf("0\n");
  else{
    for(int i=1;i<=n;i++) printf("%d",num[n-i]);
    printf("\n");
  }
}
  


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

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int i = 0;
	int j = n - 1;
	int answer = 0;
	while (i < j) {
		while (i < j && s[i] == 'R') i++;
		while (i < j && s[j] == 'W') j--;
		if (i < j && s[i] == 'W' && s[j] == 'R') {
			answer++;
			i++;
			j--;
		}
	}
	cout << answer << endl;
}


Measured memory_bytes: 3748
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		List<Integer> sales=new ArrayList<>();
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		for(int i=0;i<n;i++) {
			int a=sc.nextInt();
		if(a==0) {
		int	 x=sc.nextInt();
		sales.add(x);
		}
		if(a==1) {
			int y=sc.nextInt();
			System.out.println(sales.get(y));
		}
		if(a==2) {
			sales.remove(sales.size()-1);
		}	
		}
	}
}



Measured memory_bytes: 140516
#include <iostream>
#include <vector>
#include <functional>
using namespace std;
using ll = long long;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

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

Measured memory_bytes: 256
#include <stdio.h>
int main(int argc, char const *argv[]) {
  int n,i,r[200001],min,max;

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

  min = r[0];
  max = r[1]-r[0];

  for(i=1;i<n;i++){
    if(max<r[i]-min) max = r[i]-min;
    if(min>r[i]) min = r[i];
  }
  printf("%d\n", max);
  return 0;
}

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

int main() {
  
  int n, a;
  cin >>n >>a ;
  
  	if(n%2==0 || a%2==0){
      cout << "Even"<< endl;
    }
  	else{
      cout << "Odd" << endl;
    }
}



Measured memory_bytes: 384
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0].split(' ')[0]-0;
  var strings=input.slice();
  strings.shift();
  strings=strings.map(e=>{
    return e.split('').sort().join('');
  });
  strings.sort();
  var temp=1;
  var ans=0;
  var previous=strings[0];
  for(var i=1;i<strings.length;i++){
    if(previous===strings[i]){
      temp++;
    }else{
      ans+=temp*(temp-1)/2;
      temp=1;
    }
    previous=strings[i];
  }
  ans+=temp*(temp-1)/2;
  console.log(ans);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 58656
#include <iostream>
using namespace std;
int fields[20][20],goal_y,goal_x;
int counter=0;
int recursive(int y,int x){
/*      for( int i=0 ; i<=goal_y ; i++ ){
                for( int j=0 ; j<=goal_x ; j++ ){
                        if( i==y && j==x )
                                cout << "#";
                        else cout << fields[i][j];
                }
                cout<< endl;
        }
        cout << endl;
*/
        if(fields[y+1][x]!=-1 and y<=goal_y )
                recursive(y+1,x);
        if(fields[y][x+1]!=-1 and x<=goal_x )
                recursive(y,x+1);
        if(y==goal_y && x==goal_x )
                counter++;
        return 0;
}
int main(){
        while(true){
                counter=0;
                int x,y,m;
                cin >> x >> y;
                if(x+y==0)      break;
                goal_y=y-1,goal_x=x-1;
                for( int i=0 ; i<y ; i++ )
                        for( int j=0 ; j<x ; j++ )
                                fields[i][j]=0;
                cin >> m;
                for( int i=0 ; i<m ; i++ ){
                        cin >> x >> y;
                        fields[y-1][x-1]=-1;
                }
                recursive(0,0);
                cout << counter << endl;
        }
        return 0;
}

Measured memory_bytes: 2992
#include <stdio.h>
#include <cmath>
using namespace std;

// 二分探索
int binarySearch(int *A, int n, int key) {
    int compare=int(n/2);
    float tmp=compare;
    while(tmp > 0) {
        if(key < A[compare]) {
            tmp = tmp/2;
            compare = compare - tmp;
        } else if(key > A[compare]) {
            tmp = tmp/2;
            compare = compare + tmp + 0.5;
        } else {
            return 1;
        }
    }
    return 0;
}

int main() {
    int n, q;
    scanf("%d", &n);
    int S[n];
    for(int i=0; i<n; i++) scanf("%d", &S[i]);
    scanf("%d", &q);
    
    int tmp, sum=0;
    for(int i=0; i<q; i++) {
        scanf("%d", &tmp);
        sum += binarySearch(S, n, tmp);
    }
    
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 3004
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int W = sc.nextInt();
		int[] w = new int[N];
		int[] v = new int[N];
		long[][] dp = new long[N+1][W+1];
		for(int i=0;i<N;i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}

		for(int i=0;i<N;i++) {
			for(int j=0;j<=W;j++) {
				if(j < w[i]) {
					dp[i+1][j] = dp[i][j];
				}else {
					dp[i+1][j] = Math.max(dp[i][j-w[i]] + v[i], dp[i][j]);
				}
			}
		}

		System.out.println(dp[N][W]);
	}
}


Measured memory_bytes: 128340
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
const int N = 605;

inline int input() {
	int x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

inline void chkmin(int &x, int y) { x = x < y ? x : y; }
template <class T> T sqr(T x) { return x * x; }

int n, m, D1, D2;
int ansx[N * N], ansy[N * N], tot;
bool col[N][N];

void work(int D) {
	int tmp = 0;
	while(D % 4 == 0) D >>= 2, ++tmp;
	if (D % 4 == 3) return void();
	if (D % 4 == 1) {
		for (int x = 0; x <= n; ++x)
			for (int y = 0; y <= n; ++y)
				if (((x >> tmp) + (y >> tmp)) & 1) col[x][y] = true;
	}
	if (D % 4 == 2) {
		for (int x = 0; x <= n; ++x)
			for (int y = 0; y <= n; ++y)
				if ((x >> tmp) & 1) col[x][y] = true;
	}
}

int main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
//	freopen("log", "w", stderr);
#endif
	ios::sync_with_stdio(false);

	cin >> n >> D1 >> D2;
	m = n, n = n * 2 - 1;

	work(D1), work(D2);

	for (int x = 0; x <= n; ++x)
		for (int y = 0; y <= n; ++y) {
			if (!col[x][y]) ansx[++tot] = x, ansy[tot] = y;
			if (tot == m * m) goto Get;
		}
Get:;

	for (int i = 1; i <= tot; ++i)
		printf("%d %d\n", ansx[i], ansy[i]);
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using p = pair<int, int>;

int n, m;
vector<p> v;

int solve();

int main() {
  cin >> n >> m;
  for(int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    v.push_back({b, a});
  }
  sort(v.begin(), v.end());
  cout << solve() << endl;
  return 0;
}

int solve() {
  int ans = 0, now = 0;
  for(int i = 0; i < m; ++i) {
    if(now <= v[i].se) {
      ++ans;
      now = v[i].fi;
    }
  }
  return ans;
}

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

using namespace std;

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if (x - r >= 0 && x + r <= W &&
        y - r >= 0 && y + r <= H) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long long g[1100][1100];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)for(int j=0;j<a;j++)g[i][j]=inf;
	for(int i=0;i<a;i++)g[i][i]=0;
	for(int i=0;i<b;i++){
		int p,q;
		long long r;
		scanf("%d%d%lld",&p,&q,&r);
		p--;q--;
		g[p][q]=-r;
	}
	for(int k=0;k<a;k++)for(int i=0;i<a;i++)for(int j=0;j<a;j++){
		g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
	}
	long long ret=-g[0][a-1];
	for(int i=0;i<a;i++){
		if(g[i][i]<0&&g[0][i]<1000000000000000LL&&g[i][a-1]<1000000000000000LL){
			printf("inf\n");return 0;
		}
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 8704
using System;

class TimeConvert{
      static void Main(string[] args){
      int t = int.Parse(Console.ReadLine());
      int h = t/3600;
      t -= 3600*h;
      int m = t/60;
      t -= 60*m;
      int s = t;
      Console.WriteLine("{0}:{1}:{2}",h,m,s);
      }
}

Measured memory_bytes: 9072
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

#define SIZE 100

char ret[SIZE][SIZE];

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

  ll A, B ; cin >> A >> B ;
  rep(i,SIZE){
    rep(j,SIZE){
      if(i < SIZE/2)
	ret[i][j] = '.';
      else
	ret[i][j] = '#';
    }
  }
  A--, B--;
  for(ll i = 0 ; i< SIZE/2; i+=2){
    for(ll j = 0; j< SIZE; j++){
      if((i%4 == 2) && (j%2 == 0) && (B>0)){
	ret[i][j] = '#';
	B--;
      }
      else if((i%4 == 0) && (j%2 == 1) && (B>0)){
	ret[i][j] = '#';
	B--;
      }
    }
  }

  for(ll i = SIZE-1; i>SIZE/2; i-=2){
    for(ll j = 0 ; j < SIZE; j++){
      if(((i+1)%4 == 2) && (j%2 == 0) && (A>0)){
	ret[i][j] = '.';
	A--;
      }
      else if(((i+1)%4 == 0) && (j%2 == 1) && (A>0)){
	ret[i][j] = '.';
	A--;
      }
    }
  }
  
  
  
  
  cout << "100 100" << endl;
  rep(i,SIZE){
    rep(j,SIZE){
      cout << ret[i][j] ;
    }
    cout << endl;
  }
  
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left

def main():
    n, k = map(int, input().split())
    x = list(map(int, input().split()))

    zero_ind = bisect_left(x, 0)
    
    if zero_ind == 0:
        print(x[k-1])
        exit()
    elif zero_ind == n:
        print(-x[-k])
        exit()

    if x[zero_ind] == 0:
        x.pop(zero_ind)
        n -= 1
        k -= 1
    
    ans = float('inf')

    # only go to left
    if zero_ind >= k:
        ans = -x[zero_ind - k]

    # only go to right
    if n - zero_ind >= k and ans > x[zero_ind + k - 1]:
        ans = x[zero_ind + k - 1]

    # go to left and go to right
    for i in range(max(0, zero_ind - k + 1), zero_ind):
        if k+i-1 < n and ans > -2 * x[i] + x[k+i-1]:
            ans = -2 * x[i] + x[k+i-1]

    # go to right and go to left
    for i in range(zero_ind, min(n, zero_ind+k)):
        if 0 <= i-k+1 and ans > 2 * x[i] - x[i-k+1]:
            ans = 2 * x[i] - x[i-k+1]

    print(ans)

main()

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

int fnc(long long x) { 
  long long balance = 100;
  int cnt = 0;

  do{
    balance *= 1.01;
    cnt++;
  } while (balance < x);

  return cnt;
}

int main() {
  long long x;

  cin >> x;

  cout << fnc(x) << endl;
}


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

struct Act {
	int y1, x1, y2, x2;
};

int main() {
	int h, w;
	cin >> h >> w;

	bool table[500][500];	//false:偶数　true:奇数

	int buf;

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> buf;
			table[i][j] = (buf % 2 == 1);
		}
	}

	int y = 0, x = 0;
	int vy = 1, vx = 0;
	bool flag = false;
	int count = 0;
	vector<Act> v;
	while (true) {
		if (w % 2 == 1 && x == w - 1 && y == h - 1) {
			break;
		}
		if (w % 2 == 0 && x == w - 1 && y == 0) {
			break;
		}
		if (table[y][x] == true) {
			flag = !flag;

		}
		if (vy == 1 && y == h - 1) {
			vx = 1;
			vy = 0;
		}
		if (vy == -1 && y == 0) {
			vx = 1;
			vy = 0;
		}
		y += vy;
		x += vx;
		if (flag == true) {
			v.push_back({ y - vy + 1 , x - vx+ 1 , y + 1, x + 1});
			count++;
		}
		if (vx == 1) {
			if (y == h - 1) {
				vy = -1;
			}
			if (y == 0) {
				vy = 1;
			}
			vx = 0;
		}

	}

	cout << count << endl;
	for (int i = 0; i < count; i++) {
		cout << v[i].y1 << " " << v[i].x1 << " " << v[i].y2 << " " << v[i].x2 << endl;
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int d[n];
    int i;
    for(i=0;i<n;i++)
        cin >> d[i];

    sort(d,d+n);
    int top=d[0],counter=1;
    for(i=1;i<n;i++){
        if(top<d[i]){
            counter++;
            top=d[i];
        }
    }
    cout << counter << endl;
}

Measured memory_bytes: 3616
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))

L = [0 for _ in range(N+1)]
R = [0 for _ in range(N+1)]

for i in range(1,N+1):
    L[i] = gcd(L[i-1],A[i-1])
for i in range(0,N)[::-1]:
    R[i] = gcd(R[i+1],A[i])
ans = 1
for i in range(N):
    val = gcd(L[i],R[i+1])
    if val > ans:
        ans = val
print(ans)


Measured memory_bytes: 16148
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define xx first
#define yy second
#define mp make_pair
const int N = 1000010;
typedef long long ll;
ll a[N];
ll n,k;
ll b[N];
int vis[N];
pii get_next(pii now)
{
    now.yy++;
    if(now.yy>n)
    {
        now.xx++;
        now.yy=now.xx;
    }
    if(now.xx>n)
        now.xx=-1;
    return now;
}
ll get_val(pii now)
{
    return a[now.yy]-a[now.xx-1];
}
int main()
{
    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        a[i]+=a[i-1];
    }
    pii r=mp(1,0);
    int b_len=0;
    while(1)
    {
        r = get_next(r);
        if(r.xx==-1)
            break;
        b[b_len++] = get_val(r);
    }

    ll answer=0;
    int now = 0;
    memset(vis,0,sizeof(vis));
    for(int j=40;j>=0;j--)
    {
        int num = 0;
        for(int i=0;i<b_len;i++)
        {
            if(vis[i]==now)
            {
                if((1ll<<j)&b[i])
                {
                    num++;
                }
            }
        }
        if(num>=k)
        {
            answer |= (1ll<<j);
            for(int i=0;i<b_len;i++)
            {
                if(vis[i]==now)
                {
                    if((1ll<<j)&b[i])
                    {
                        vis[i]++;
                    }
                }
            }
            now++;
        }
    }

    printf("%lld\n",answer);
    return 0;
}


Measured memory_bytes: 10496
import sys
import itertools
import math

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

while 1:
    S=readline().decode().rstrip()
    if S=='0':
        break
    ans=0
    for i in S:
        ans+=int(i)
    print(ans)




Measured memory_bytes: 5692
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static String[] a;
	static String[] b;
	static String temp;

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		a = scanner.nextLine().split(" ");
		b = scanner.nextLine().split(" ");
		char[] c = { 'E', 'E', 'E', 'N', 'W', 'W', 'W', 'S' };
		
		boolean flag = false;
		for(int i=0;i<3;i++){
			for(char d:c){
				roll(d);
				if(Arrays.equals(a, b)){
					flag=true;
					break;
				}
			}
		}
		if(flag)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

	public static void roll(char c) {
		switch (c) {
		case 'E':
			temp = a[0];
			a[0] = a[3];
			a[3] = a[5];
			a[5] = a[2];
			a[2] = temp;
			break;
		case 'N':
			temp = a[0];
			a[0] = a[1];
			a[1] = a[5];
			a[5] = a[4];
			a[4] = temp;
			break;
		case 'W':
			temp = a[0];
			a[0] = a[2];
			a[2] = a[5];
			a[5] = a[3];
			a[3] = temp;
			break;
		default:
			temp = a[0];
			a[0] = a[4];
			a[4] = a[5];
			a[5] = a[1];
			a[1] = temp;
			break;
		}
	}

}

Measured memory_bytes: 17328
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
ll n,ans;
void solve(){
	cin>>n;
	rep(i,1,n+1){
		string s = to_string(i);
		if(sz(s)&1)ans++;
	}
	cout<<ans;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





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

int main() {
int K,A,B;
cin >> K >> A >> B;
  int result = 0;
 for(int a = 1;a < 1001;a++){
  if(A <= a * K&&a * K <= B)result = 1;
 }
  if(result == 1)cout << "OK" << endl;
  if(result == 0)cout << "NG" << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

bool dis(string s) {
    string ss = s;
    reverse(s.begin(), s.end());
    if (s == ss) return true;
    else return false;
}

int main() {
    fast_io
    string s;
    cin >> s;
    int n = s.size();
    if (dis(s) && dis(s.substr(0,(n-1)/2)) && dis(s.substr((n+1)/2, (n-1)/2))) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
void trace(int A[],int N){
    for(int i=0;i<N;i++){
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}
void insertionSort(int A[],int N){
    for(int i=1;i<N;i++){
        int v=A[i];
        int j=i-1;
        while(j>=0 && v<A[j]){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        trace(A,N);
    }
}
int main() {
    int n;cin>>n;
    int A[n];
    rep(i,n) cin>>A[i];
    trace(A,n);
    insertionSort(A,n);
}


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

int main(){
    int n;
    scanf("%d",&n);
    string s;
    cin >> s;
    string ans;
    for(int i=0;i<s.length();i++){
        ans+=((int)s[i]-'A'+n)%26+'A';
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
ll inf=1e17;
//LLONG_MIN

//AC

int main(void){
	//+,-
	ll d[8][100010];
	ll N,M,x,y,z,sum,ans=0;
	cin>>N>>M;
	rep(i,N){
		cin>>x>>y>>z;
		d[0][i]=x+y+z;
		d[1][i]=x+y-z;
		d[2][i]=x-y+z;
		d[3][i]=x-y-z;
		d[4][i]=-x+y+z;
		d[5][i]=-x+y-z;
		d[6][i]=-x-y+z;
		d[7][i]=-x-y-z;
	}
	rep(i,8)sort(d[i],d[i]+N);
	rep(i,8){
		sum=0;
		irep(j,M){
			sum+=d[i][j];
		}
		ans=max(abs(sum),ans);
	}
	cout<<ans<<endl;
	return 0;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main(){
  ll n;
  cin >> n;
  vecll a(n);
  forll(i, 0, n)
	cin >> a[i];
  ll x = a[n-1];
  
  forll (i, 0, n-1){
	x = x ^ a[i];
  }
  if (x == 0)
	cout << "Yes" << endl;
  else
	cout << "No" << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
vector<vl> vect(100, vl(4, 0));
ll n, m, q;
ll ans=0;
void dfs(vl a)
{
    if(a.size()==1+n){
        ll now=0;
        forr(i, q)
        {
            if(a[vect[i][1]]-a[vect[i][0]]==vect[i][2])
            now+=vect[i][3];
        }
        ans=max(ans, now);
        return;
    }
    a.pb(a[a.size()-1]);
    while(a[a.size()-1]<=m)
    {
        dfs(a);
        a[a.size()-1]++;
    }
}
void solve()
{
    cin>>n>>m>>q;
    forr(i, q)
    {
        cin>>vect[i][0]>>vect[i][1]>>vect[i][2]>>vect[i][3];
    }
    vl a(1, 1);
    dfs(a);
    cout<<ans;
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 3652
from fractions import gcd
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


a,b=map(int,input().split())

c = collections.Counter(prime_factorize(gcd(a,b)))
print(len(c.keys())+1)

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

int main(){
    string s;
    cin >> s;
    vector<int> rl;
    vector<int> lr;
    lr.push_back(-1);
    for(int i = 0; i < s.length() - 1; i++){
        if(s[i] == 'R' && s[i + 1] == 'L') rl.push_back(i);
        else if(s[i] == 'L' && s[i + 1] == 'R') lr.push_back(i);
    }
    lr.push_back(s.length() - 1);
    int out[s.length()] = {};
    for(int i = 0; i < rl.size(); i++){
        int l = lr[i];
        int m = rl[i];
        int r = lr[i + 1];
        out[m] = (m - l + 1) / 2 + (r - m) / 2;
        out[m + 1] = (r - l) - out[m];
    }
    for(int i = 0;  i < s.length(); i++){
        cout << out[i] << '\n';
    }
}


Measured memory_bytes: 1532