akhauriyash/Code-Regression huggingface dataset:
N,Q = [int(i) for i in input().split()]
S = input()
q_list = []
for i in range(Q) :
    q_list.append([int(i) for i in input().split()])


## No.5
# n番目までに何回ACって出るか調べたらO(N)で済むのでは？
c = 0
ac_list = []
for i in range(len(S)) :
    # Cの位置を基準にする
    if (S[i] == "C" and i > 0 and S[i-1] == "A") :
        c += 1
        ac_list.append(c)
    else :
        ac_list.append(c)

for item in q_list :
    # XXXXA | C だったケースは除外するので、右端は-1する
    ac_count = ac_list[item[1]-1] - ac_list[item[0]-1]
    print(ac_count)



## No.4
# a_indexes = []
# # 下処理として、Aの場所だけ覚えておく
# for i in range(len(S)) :
#     if (S[i] == "A") :
#         a_indexes.append(i)

# # 幅に応じて、Aの次がCかどうかを判定する
# for item in q_list :
#     from_index = item[0]
#     to_index = item[1]
#     # 次の文字がCであることを調べるので、toは1文字手前にする
#     target_indexes = [i for i in a_indexes if i >= from_index-1 and i < to_index-1]
#     ac_count = 0
#     for index in target_indexes :
#         if (S[index+1] == "C") :
#             ac_count += 1
    
#     print(ac_count)


## No.1  もちろんTLE。。。
# for item in q_list :
#     from_index = item[0]
#     to_index = item[1]
#     search_str = S[from_index-1:to_index]
#     find_index = 0
#     ac_count = 0
#     while(find_index != -1) :
#         find_index = search_str.find("AC",find_index)
#         if (find_index != -1) :
#             ac_count += 1
#             find_index += 1
#     print(ac_count)

## No.2,3
# for item in q_list :
#     from_index = item[0]
#     to_index = item[1]
#     search_str = S[from_index-1:to_index]
    # print(search_str.replace("AC","X").count("X"))
    # print(search_str.count("AC"))
        


Measured memory_bytes: 24464
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int x = (A+D-1)/D;
    int y = (C+B-1)/B;
    if(y<=x) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define debugaar(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[y][x]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007ll
void printbit(int u) { if (u == 0)cout << 0; else { int s = 0, k = 0; for (; 0<u; u >>= 1, k++)s = (s << 1) | (u & 1); for (; 0<k--; s >>= 1)cout << (s & 1); } }

#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

namespace {
    std::chrono::system_clock::time_point t;
    void tic() { t = TIME; }
    void toc() { fprintf(stderr, "TIME : %lldms\n", MILLISEC(TIME - t)); }
    std::chrono::system_clock::time_point tle = TIME;
    void safe_tle(int msec) { assert(MILLISEC(TIME - tle) < msec); }
}

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

int width, height;
int m, n, c, kei;

int te[100010];

int main() {
    int i, j, k;
    int x, y, a, b;

    cin >> n >> c >> kei;

    for (i = 0; i < n; ++i) {
        scanf("%d",te + i);
    }
    
    sort(te,te+n);

    int bus = 0;
    int left = 0;
    for (int right = 0; right < n; ++right) {
        if (right - left + 1 > c) { // too many
                fprintf(stderr,"A: %d %d %d\n",left,right,te[left]);
            ++bus;
            left = right;
        }
        else {
            if (te[left] + kei < te[right]) { // tle
                fprintf(stderr,"B: %d %d %d\n",left,right,0);
                ++bus;
                left = right;
            }
        }
    }
    if (left < n) ++bus;

    cout << bus << endl;


    return 0;
}

Measured memory_bytes: 640
import sys
from collections import Counter

input = sys.stdin.readline


def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    c = Counter(A)
    M = len(c)
    n_even_v = 0
    for v in c.values():
        if v % 2 == 0:
            n_even_v += 1
    
    if n_even_v % 2 == 0:
        ans = M
    else:
        ans = M - 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 22128
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
  string s;
  cin>>s;
  int n=s.size(),i,j,k,l=0;
  for(i=0;i<n;i++)
  {
    l+=(s[i]-'0');
  }
  if(l%9==0) cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 3668
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b;cin>>a>>b;
  if(a<10&&b<10)cout<<a*b;
  else cout<<-1;
}


Measured memory_bytes: 27040
import java.util.Scanner;

public class Main {
	static long []p;
	static long []l;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long X = sc.nextLong();
		sc.close();
		p = new long[N + 1];
		l = new long[N + 1];
		p[0] = 1;
		l[0] = 1;
		for(int i = 1; i <= N; i++) {
			p[i] = 2 * p[i - 1] + 1;
			l[i] = 2 * l[i - 1] + 3;
		}
		long ans = rec(N, X);
		System.out.println(ans);
	}
	static long rec(int n, long x) {
		if(n == 0) {
			return 1;
		}
		if(x <= 1) {
			return 0;
		}else if(x < l[n - 1] + 1) {
			return rec(n - 1, x - 1);
		}else if(x == l[n - 1] + 1) {
			return p[n - 1];
		}else if(x == l[n - 1] + 2){
			return p[n - 1] + 1;
		}else if(x < l[n]){
			return rec(n - 1, x - (l[n - 1] + 2)) + p[n - 1] + 1;
		}else {
			return 2 * p[n - 1] + 1;
		}
	}
}

Measured memory_bytes: 23124
n, w = [int(i) for i in input().split(" ")]
vw = []
for i in range(n):
  vw.append([int(i) for i in input().split(" ")])

dp = [[0 for j in range(w+1)] for i in range(n+1)]
for i in range(n):
  for j in range(w+1):
    if j-vw[i][0] >= 0:
      dp[i+1][j] = max(dp[i][j], dp[i][j-vw[i][0]] + vw[i][1])
    else:
      dp[i+1][j] = dp[i][j]
print(dp[n][w])

Measured memory_bytes: 171528
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define PI          3.14159265358979323846
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ld          long double
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;
void tc(){
    string s;
    cin >> s;
    int n = SZ(s);
    vector<int> pre(n, 0), suff(n, 0);
    pre[0] = 1;
    suff[n - 1] = 1;
    for(int i = 1; i <= n; i++){
        if(s[i] == 'R')
            pre[i] = pre[i - 1] + 1;
    }
    for(int i = n - 2; i >= 0; i--){
        if(s[i] == 'L'){
            suff[i] = suff[i + 1] + 1;
        }
    }
    for(int i = 0; i < n; i++){
        if(s[i] == 'R' && s[i + 1] == 'L'){
            int d = pre[i] + suff[i + 1];
            if(d & 1){
                if(pre[i] & 1){
                    cout << d / 2 + 1 << ' ';
                }else{
                    cout << d / 2 << ' ';
                }
            }else{
                cout << d / 2 << ' ';
            }
        }else if(s[i] == 'L' && s[i - 1] == 'R'){
            int d = pre[i - 1] + suff[i];
            if(d & 1){
                if(suff[i] & 1){
                    cout << d / 2 + 1 << ' ';
                }else{
                    cout << d / 2 << ' ';
                }
            }else{
                cout << d / 2 << ' ';
            }
        }else{
            cout << 0 << ' ';
        }
    }
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int t = 1;
    // cin >> t;
    while(t--) tc();
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 1488
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        
        AtCoder problem = new AtCoder(sc);
        problem.solve(out);
        
        out.flush();
    }
    
}

class AtCoder {
    final int N;
    AtCoder(FastScanner sc) {
        N = sc.nextInt();
    }

    void solve(PrintWriter out) {
        double cnt = IntStream.rangeClosed(1, N).filter(i -> i % 2 != 0).count();
        out.println(cnt / N);
    }
    
}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {
    
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    
    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }
    
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }
    
    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    
    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 26324
#include <bits/stdc++.h>
#define in freopen("input.txt", "r" ,stdin)
#define out freopen("output.txt", "w" , stdout)
#define ll long long
#define inf 200005
#define fr first
#define  sc second
#define pb push_back
#define p_b pop_back
#define mp make_pair
#define N 100100
using namespace std;
ll n , k;
ll dp[N+5];

int main (){
//in;out;
ios_base::sync_with_stdio(0);

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

for (int i = 1; i <=n; i++) {
     int x , y;
     cin >> x >> y;
     for (int j = N-1; j >= y; j--) {
         dp[j] = min (dp[j] , dp[j - y] + x);
     }
}

ll rez = 0;
for (int i = 1; i < N; i++) {
     if (dp[i] <= k) {
            rez= i;
     }
}
cout << rez;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define reps(i, a, n) for (int i = (a); i < (n); ++i)
#define int long long

signed main(void)
{
	int n, ans = 0, num[20][20] = {0};
	cin >> n;
	while (n--)
	{
		double x; cin >> x;
		int tmp = x * 1e9 + 0.5;
		int n2 = 0, n5 = 0;
		while (tmp % 2 == 0) {n2++; tmp /= 2;}
		while (tmp % 5 == 0) {n5++; tmp /= 5;}
		if (n2 > 18) n2 = 18;
		if (n5 > 18) n5 = 18;
		reps (i, 18 - n2, 19)
		{
			reps (j, 18 - n5, 19)
			{
				ans += num[i][j];
			}
		}
		num[n2][n5]++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define cin_fit() cin.tie(nullptr);ios::sync_with_stdio(false)
#define rep(i, N) for(int i=0; i<(N); i++)
#define reps(i, N) for(int i=1; i<=(N); i++)
#define rrep(i, N) for(int i=(int)(N)-1; i>=0; i--)
#define rreps(i, N) for(int i=(int)(N); i>=1; i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long;
using V = vector<ll>;
using P = pair<ll, ll>;
constexpr int inf = 1e9;
constexpr int mod = 1e9+7;
ll gcd(ll a, ll b) { return b? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}

ll n, m;
ll a[100010];
ll ans[100010];

int main() {
    cin_fit();
    cin >> n >> m;
    rep(i, m) {
        ll t; cin >> t;
        a[t] = 1;
    } 
    ans[0] = 1;
    rep(i, n) {
        if(a[i] == 0) {
            ans[i+1] = (ans[i] + ans[i+1]) % mod;
            ans[i+2] = (ans[i] + ans[i+2]) % mod;
        }
    }
    cout << ans[n] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};
vector<vector<ll>> dist(15,vector<ll>(15,INF));
vector<vector<vector<ll>>> dp(15,vector<vector<ll>>(15,vector<ll>((1<<16),-1)));
ll V,E;


ll rec(ll st, ll v, ll bit){
    //cout << v<< endl;
    if(dp[st][v][bit] != -1){
        return dp[st][v][bit];
    }

    if(st == v && bit == (1<<V)-1){
        //cout << "OK"<< endl;
        return dp[st][v][bit] = 0;
    }

    ll res = INF;
    rep(i,V){
        if(i != v&& !((bit>>i)&1)){
            chmin(res,rec(st,i,bit | (1<<i))+dist[v][i]);
            
        }
    }
    return dp[st][v][bit] = res;


    
}

int main() {
    cin >> V>>E;

    rep(i,E){
        ll a,b,c;
        cin >>a>>b>>c;
        dist[a][b] = c;
        //dist[b][a] = c;
    }

    ll ans = INF;
    rep(i,V){
        chmin(ans,rec(i,i,0));
    }
    if(ans >= INF){
        ans = -1;
    }
    cout <<ans<<endl;
    
    return 0;
    

}



Measured memory_bytes: 127060
#include<stdio.h>

int main(){
  int i,j,n,A[100000],x,r,p,q,temp;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  r=n-1;/*rは配列Aの最後の要素を指す添字*/
  p=0;
  x=A[r];
  i=-1;
  for(j=p;j<=r-1;j++){
    if(A[j]<=x){
      i++;
      temp=A[i];
      A[i]=A[j];
      A[j]=temp;
    }
  }
  temp=A[i+1];
  A[i+1]=A[r];
  A[r]=temp;
  q=i+1;
  for(i=0;i<n;i++){
    if(i>0)printf(" ");
    if(i==q)printf("[");
    printf("%d",A[i]);
    if(i==q)printf("]");
  }
  printf("\n");
  return 0;
}
  
      
  



Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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; }
 
ll MOD = 1000000007;
ll INF =1<<30;
ll dp[110][100100];
 
 
int main(){
    int n;
    cin >>n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    deque<int>deq;
    rep(i,n){
         if(i%2==0)deq.push_back(a[i]);
         else deq.push_front(a[i]);
    }
    vector<int>ans;
    for(auto x:deq) ans.push_back(x);
    if(n%2!=0){
         reverse(ans.begin(),ans.end());
         rep(i,ans.size()) cout<<ans[i]<<' ';
    }
    else{
         rep(i,ans.size()) cout << ans[i]<<' ';
    }
}

Measured memory_bytes: 5856
from sys import stdin
from operator import attrgetter
readline = stdin.readline


def norm(a):
    return a.real * a.real + a.imag * a.imag


def closest_pair(p):
    if len(p) <= 1:
        return float('inf')
    m = len(p) // 2
    d = min(closest_pair(p[:m]), closest_pair(p[m:]))
    p = [pi for pi in p if p[m].imag - d < pi.imag < p[m].imag + d]
    return brute_force(p, d)

def brute_force(p, d=float('inf')):
    p.sort(key=attrgetter('real'))
    for i in range(1, len(p)):
        for j in reversed(range(i)):
            tmp = p[i] - p[j]
            if d < tmp.real:
                break
            tmp = abs(tmp)
            if d > tmp:
                d = tmp
    return d


def main():
    n = int(readline())
    p = [map(float, readline().split()) for _ in range(n)]
    p = [x + y * 1j for x, y in p]

    p.sort(key=attrgetter('imag'))
    print('{:.6f}'.format(closest_pair(p)))
main()

Measured memory_bytes: 65644
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main(void){

  char word[300];
  int i, len;

  while(scanf("%[a-zA-Z .]", word)!=EOF){
    getchar();
    len = strlen(word);
    for(i=0; i<len; i++){
      if('a'<= word[i] && word[i] <= 'z'){
	word[i] = toupper(word[i]);
      }
      else if('A'<=word[i] && word[i]<='Z'){
	word[i] = tolower(word[i]);
      }
    }

    printf("%s\n", word);
    
  }

  return(0);
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

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

    int h, w, n;
    cin >> h >> w >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    vector<vector<int>> graph(h, vector<int>(w, 0));
    
    int x = 0, y = 0, i = 0;
    while(a[n-1] > 0){
        graph[y][x] = i+1;
        a[i]--;
        if(a[i] == 0) i++;
        if(y % 2 == 0){
            x++;
            if(x >= w) y++, x = w-1;
        }else{
            x--;
            if(x < 0) y++, x = 0;
        }
    }
    REP(i, h) {
        REP(j, w){
            cout << graph[i][j];
            if(j != w-1) cout << " ";
    }
        cout << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair < ll, ll > PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll N = 1000002;
const ll INF = 1000000007ll*1000000007ll;
ll n, m;
ll l, r, d;
vector<ll> ans(N, INF);
bool mark[N];
vector<vector<pair<ll, ll>>> g(N);
void dfs(int v) {
  mark[v] = true;
  for (int i = 0; i < g[v].size(); ++i) {
    ll to = g[v][i].first, len = g[v][i].second;
    if (ans[to] == INF) {
      ans[to] = ans[v] + len;
    }
    if (ans[to] != ans[v] + len) {
      cout << "No" << endl;
      exit(0);
    }
    if (!mark[to]) {
      dfs(to);
    }
  }
}
int main() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> l >> r >> d;
        g[l].push_back({r, d});
        g[r].push_back({l, -d});
    }
    for (int i = 1; i <= n; ++i) {
        if (!mark[i]) {
            ans[i] = 0;
            dfs(i);
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 44672
<?php
list($n) = ints();
list($s) = strs();
list($k) = ints();
--$k;
for ($i = 0; $i < $n; ++$i)
    if ($s[$i] !== $s[$k]) $s[$i] = '*';
echo $s;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16260
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;

int main() {

    int A,B,y=1,tm;
    string S;
    cin >>A>>B>>S;
    if(S[A]!='-') y=0;
    for(int i=0;i<A+B+1;i++) {
        if(i!=A) {
            tm=(int)S[i];
            if((tm>=48)&&(tm<=57)) {
            }else{
                y=0;
            }
        }
    }
    
    if(y==0) cout <<"No";
    if(y==1) cout <<"Yes";

    return 0;
}

Measured memory_bytes: 256
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	int n;
	cin >> n;
	int ans = n * n * n;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main () {
	int N,M;
	int S[10][11];
	int p[10];
	scanf ("%d %d", &N ,&M);
	for (int i=0; i<M; i++) {
		scanf ("%d", S[i]);
		for (int k=1; k<=S[i][0]; k++) {
			scanf ("%d", S[i]+k);
			S[i][k] --;
		}
	}
	for (int m=0; m<M; m++)
		scanf ("%d", p+m);

	int ans = 0;
	for (int i=0; i<(1<<N); i++) {
		int flag = 1;
		for (int j=0; j<M; j++) {
			int c=0;
			for (int k=1; k<=S[j][0]; k++)
				if ((i >> S[j][k]) & 1)
					c++;
			c %= 2;
			if (c != p[j])
				flag = 0;
		}
		if (flag)
			ans ++;
	}
	printf ("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    N=ii()
    a=lmis()
    print(sum(a[i]&1 for i in range(0, N, 2)))






main()



Measured memory_bytes: 9988
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int n;
    cin >> n;
    set<int>st;
    int cnt = 0;
    for(int i=0;i<n;i++){
        int k;
        cin >> k;
        if(k<3200)st.insert(k/400);
        else cnt++;
    }
    int m = st.size();
    if(m==0){
        cout << 1 << " " << cnt << endl;
    }else{
        cout << m << " " << m+cnt << endl;
    }
    return 0;
}

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

typedef long long int lli;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef priority_queue <int, vector <int>, greater <int> > min_pq;

const int MOD	= 1e9 + 7;

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define init(a)         memset(a,0,sizeof(a))    
#define pb              push_back  
#define all(a)          a.begin(),a.end()  
#define loop(i,n)       for(int i=0;i<n;i++)  
#define loops(i,s,n)    for(int i=s;i<n;i++)
#define rloop(i,n)      for(int i=n-1;i>=0;i--)
#define rloops(i,s,n)   for(int i=n-1;i>=s;i--)

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }


double tick(){static clock_t oldt,newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt=newt;return diff;}
//---------------------------------------------------------------------------------------------


int main(){
    fastio;


    int h, n;
    cin>> h>> n;
    int a[n], b[n];
    loop(i,n){
        cin>>a[i] >> b[i];
    }
    int dp[n+1][h+1];
    loop(i, h+1){
        dp[0][i] = INT_MAX;
    }
    loops(i,0,n+1){
        dp[i][0] = 0;
    }
    loops(i,1,n+1){
        loops(j,1,h+1){
            dp[i][j] = min(dp[i-1][j], dp[i][max(j-a[i-1],0)] + b[i-1]);
        }
    }
    cout<<dp[n][h]<<endl;
    // cout<<"Execution time : "<<tick()<<"\n";

    return 0;
}

Measured memory_bytes: 39424
#include<stdio.h>

int main(void){
	int S,h,m,s;
	scanf("%d",&S);
	h=S/3600;
	m=(S-h*3600)/60;
	s=S-h*3600-m*60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}


Measured memory_bytes: 2144
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int mod = 1000000007;
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
        sum %= mod;
    }
 
    long ans = 0;
 
    //i について全探索する
    for (int i = 0; i < N; i++)
    {
        //A[i+1] ... A[N] の値を更新する
        sum -= A[i];
        if (sum < 0) sum += mod;
 
        ans += A[i] * sum;
        ans %= mod;
    }
 
    cout << ans << endl;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ll a,b,t;
    cin >> a >> b >> t;
    ll ans = t/a*b;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;
    if(u == s) cout << a-1 << " "<< b<< endl;
    else        cout <<a <<" " <<  b-1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m,x,y;
  cin >> n >> m >> x >> y;
  vector<int> listA(n);
  vector<int> listB(m);
  for(int i=0; i<n; i++) {
    cin >> listA.at(i);
  }
  for(int i=0; i<m; i++) {
    cin >> listB.at(i);
  }
  sort(listA.begin(),listA.end());
  sort(listB.begin(),listB.end());
  if(listA.back() < listB.at(0)) {
    int s=listA.back()+1;
    int e=listB.at(0);
    for(int i=s; i<=e; i++) {
      if(x < i && i <= y) {
        cout << "No War" << endl;
        return 0;
      }
    }
  }
  cout << "War" << endl;
}

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

int main(){
  ll N, T;
  cin >> N >> T;
  vector<ll> t(N);
  for(int i=0;i<N;i++){
    cin >> t[i];
  }
  ll ans=0;
  for(ll i=0;i<N-1;i++){
    if (t[i]+T<t[i+1]){
      ans += T;
    }else{
      ans += (t[i+1]-t[i]);
    }
  }
  cout << (ans+T) << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <iterator>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

vector<vector<int>> shift(vector<vector<int>> C, int s){
    int n = (int)C.size();
    vector<vector<int>>  ret(n, vector<int>(n));
    rep(i, n){
        rep(j, n){
            ret[i][j] = C[j][(i + s * j) % n];
        }
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    int N = 38;
    vector<vector<int>>  A(N * N - N + 1, vector<int>(N));
    vector<vector<int>>  B(N - 1, vector<int> (N - 1));
    int cur = 1;
    rep(i, N){
        A[i][0] = 1;
        rep(j, 1, N){
            A[i][j] = cur + 1;
            cur++;
        }
    }
    rep(i, 1, N){
        rep(j, 1, N){
            B[i - 1][j - 1] = A[i][j];
        }
    }
    
    int ind = N;
    rep(i, N - 1){
        int t = i + 2;
        auto tmp = shift(B, i);
        rep(j, N - 1){
            A[ind][0] = t;
            rep(k, N - 1){
                A[ind][k + 1] = tmp[j][k];
            }
            ind++;
        }
    }
    
    cout << cur << " " << N << endl;
    rep(i, N * N - N + 1){
        voutput(A[i]);
    }
    
    return 0;
}


Measured memory_bytes: 768
#include<iostream>

using namespace std;

int main(){
  int n,x;
  int ans = 1;
  int l;

  int d = 0;
  cin >> n >> x;
  for(int i =0; i <n; i++){
    cin >> l ;
    d += l;
    if(d > x)break;
    else ans++;
  }
  cout << ans << endl;


}


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

int p[1000000],size;

bool isPrime(int x){
	for(int i=0;p[i]*p[i]<=x;i++){
		if(x % p[i] == 0) return false;
	}
	return true;
}

void mkPrime(int n){
	size = 0;
	p[size++] = 2;
	for(int i=3;i<=n;i+=2){
		if(isPrime(i)){
			p[size++] = i;
		}
	}
}


int main(void){
	mkPrime(1000020);

	int n;	
	while(cin>>n){
		int ans = 0;
		for(int i=0;p[i]<=n;i++){
			ans++;
		}
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 1052
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>

using namespace std;

int main(void) {
    set<string> se;
    string s;
    int n;
    cin >> n;
    while(n--) {
        cin >> s;
        se.insert(s);
    }
    if (se.size()==3) {
        cout << "Three" << endl;
    } else {
        cout << "Four" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b;
    cin>>a>>b;
    
    cout1(a+b/2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
const int mod = 1e9 + 7;

ll mpow(ll x, ll n) {
  ll res = 1;
  while (n) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n /= 2;
  }
  return res;
}

vi fac(2e7 + 1, 1);
vi invfac(fac.size(), 1);

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  for (int i = 2; i < fac.size(); ++i) {
    fac[i] = fac[i-1] * (ll)i % mod;
  }
  invfac.back() = mpow(fac.back(), mod - 2);
  for (int i = invfac.size() - 1; i > 0; --i) {
    invfac[i-1] = invfac[i] * (ll)i % mod;
  }
  int n, m, k;
  while (cin >> n >> m >> k) {
    ll res = 2;
    ll nm = n * (ll)m % mod;
    for (int t = 2; t <= k; ++t) {
      res = (res + 1 + t + nm * fac[n + m - 2] % mod * invfac[n + m] % mod * fac[t] % mod * invfac[t-2] % mod) % mod;
    }
    cout << (res % mod * fac[n + m] % mod * invfac[n + m - k] % mod + mod) % mod << endl;
  }
  return 0;
}

Measured memory_bytes: 156544
s , t  = map(str,input().split()) #input()はstrで取る。よってintで方指定する。
a , b  = map(int,input().split()) #input()はstrで取る。よってintで方指定する。
u = input()

if u in s:
    a = a -1
elif u in t:
    b = b -1


print(a,b)

Measured memory_bytes: 2940
n = int(input())
card = [list(range(1,14)) for i in range(4)]
for i in range(n):
    a,b=input().split()
    if a == "S":
        card[0].remove(int(b))
    elif a ==  "H":
        card[1].remove(int(b))
    elif a ==  "C":
        card[2].remove(int(b))
    elif a ==  "D":
        card[3].remove(int(b))

for i in range(4):
    for j in card[i]:
        if i == 0:
            print("S",j)
        elif i == 1:
            print("H",j)
        elif i == 2:
            print("C",j)
        else:
            print("D",j)


Measured memory_bytes: 5612
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

using ll = long long int;

int main(int argc,char *argv[])
{
	ll n;
	std::cin >> n;

	while (n > 0)
	{
		if (n%10 == 7) { std::cout << "Yes" << std::endl; return 0; }
		n /= 10;
	}

	std::cout << "No" << std::endl;

	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N, K;
  cin >> N >> K;
  vector<long> x(N);
  for (int i = 0; i < N; i++)
    cin >> x[i];
  long ans = 1e18;
  for (int i = 0; i < N - K + 1; i++)
  {
    int left = i;
    int right = i + K - 1;
    long tmp = min(abs(x[left]), abs(x[right])) + abs(x[left] - x[right]);
    if (tmp < ans)
      ans = tmp;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        int n = sc.nextInt();
        String s = sc.next();
        String ans = "";
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            int idx = str.indexOf(c) + n;
            if (str.length() <= idx) {
                idx -= str.length();
            }
            ans += str.charAt(idx);
        }
        System.out.println(ans);

        sc.close();
    }
}

Measured memory_bytes: 147960
#include<cmath>
#include<iostream>
using namespace std;
const int MAXN = 51;
int a[MAXN], b[MAXN], c[MAXN], d[MAXN];
inline int dist(int x1, int y1, int x2, int y2) {
	return abs(x1-x2) + abs(y1-y2);
}
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		cin >> a[i] >> b[i];
	}
	for (int j = 1; j <= M; j++) {
		cin >> c[j] >> d[j];
	}
	for (int i = 1; i <= N; i++) {
		int min_dist = dist(a[i], b[i], c[1], d[1]);
		int id = 1;
		for (int j = 2; j <= M; j++) {
			int cur_dist = dist(a[i], b[i], c[j], d[j]);
			if (cur_dist < min_dist) {
				min_dist = cur_dist;
				id = j;
			}
		}
		cout << id << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import math
n, d, a = map(int,input().split())
e = [[] for i in range(n)]
for i in range(n):
    x, h = map(int,input().split())
    e[i] = [x,h]
num = 0

e.sort()
sd = [0 for i in range(n)]
l = [i for i in range(n)]
for i in range(n):
    for j in range(l[i-1],i):
        if e[i][0]-e[j][0] <= 2*d:
            l[i] = j
            break

for i in range(n):
    res = e[i][1] - sd[i-1] + sd[l[i]-1]
    if res < 0:
        sd[i] = sd[i-1]
    else:
        k = math.ceil(res/a)
        sd[i] = sd[i-1]+k*a
        num += k

print(num)


Measured memory_bytes: 54356
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fast std::ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);

 /*ll solve(ll n )
 {
     if(n<12)
        return n;
     if(mp[n]==0)
            mp[n]=max(solve(n/2)+solve(n/3)+solve(n/4),n);
     return mp[n];
        
 }
 */

int main()
{
    ll n;
    cin>>n;
    if(n%1000)
        cout<<1000-n%1000;
    else
        cout<<"0";
    
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    int N = 0;
    for (int i = 0; i < 4; i++){
        if (S.at(i) == '+') N++;
        else if(S.at(i) == '-') N--;
    }
    cout << N << endl;
}

Measured memory_bytes: 256
cnt[9999];
main(T,N,i,j,r,p,f){for(scanf("%d",&T);T--;printf("%d\n",r)){
	memset(cnt,0,sizeof(cnt));
	scanf("%d",&N),getchar();
	for(i=0;i<2*N;i++)if(getchar()=='Y')cnt[(i+1)/2]|=1;
	for(i=0;i<2*N;i++)if(getchar()=='Y')cnt[(i+1)/2]|=2;
	getchar();
	for(r=p=f=i=0;!p&&i<N+1;i++,r++){
		if(cnt[i]&2)r+=2,p=1,f=0;
		else if(cnt[i]&1)r+=1,p=1,f=1;
	}
	for(;i<N+1;i++,r++){
		if(cnt[i]==3)r+=2,f=1;
		else if(cnt[i])r+=1,f=(cnt[i]&1);
	}
	if(!p)r--;
	if(f)r--;
}exit(0);}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	string O, E; cin >> O >> E;
    string ans;
    int o = 0, e = 0;
    for(int i = 0; i < O.size() + E.size(); i++) {
        if(i % 2 == 0) {
            ans += O[o];
            o++;
        }
        else {
            ans += E[e];
            e++;
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(N):
  dec = A[i]
  ans += dec
  for j in range(i+1,N):
    if A[j] == 0:
      break
    dec = min(dec, A[j])
    A[j] -= dec
  
print(ans)

Measured memory_bytes: 3064
using System;
namespace ConsoleApplication1{
    class Program{
        static void Main(string[] args){
            int angle = 0;
            double px = 0.0;
            double py = 0.0;
            while(true){
                String xy=Console.ReadLine();
                if(xy.Equals("0,0")){
                    break;
                }else{
                    String[] xyArr=xy.Split(',');
                    double x=int.Parse(xyArr[0]);
                    double y=int.Parse(xyArr[1]);
                    px+=x*Math.Sin(angle*Math.PI/180);
                    py+=x*Math.Cos(angle*Math.PI/180);
                    angle+=(int)y;
                }
            }
        Console.WriteLine((int)px);
        Console.WriteLine((int)py);
        }
    }
}

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

using namespace std;

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

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

	vector<vector<int> > G(n);
	for(int i = 0; i < m; ++i) {
		int x, y;
		cin >> x >> y;
		--x; --y;
		G[x].emplace_back(y);
		G[y].emplace_back(x);
	}

	vector<bool> vis(n);
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		if(!vis[i]) {
			queue<int> q;
			q.emplace(i);
			vis[i] = true;
			ans += 1;
			while(!q.empty()) {
				int u = q.front();
				q.pop();
				for(int v : G[u]) {
					if(!vis[v]) {
						q.emplace(v);
						vis[v] = true;
					}
				}
			}
		}
	}

	cout << ans - 1 << '\n';

	return 0;
}


Measured memory_bytes: 8472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)

vector<ll> fact(ll a){
    vector<ll>ans;
    vector<ll> hoge;
    for(ll i = 1;i*i<=a;i++){
        if(a%i==0) {
            ans.push_back(a/i);
            if(i*i!=a) hoge.push_back(i);
        }
    }
    rep(i,hoge.size()){
        ans.push_back(hoge[hoge.size()-1-i]);
    }
    return ans;
}

bool check(ll *A,ll val,int N,ll K){
    ll sum = 0;
    vector<ll> vec;
    rep(i,N){
        vec.push_back(A[i]-(A[i]/val)*val);
        sum+=A[i]-(A[i]/val)*val;
    }
    ll num = sum/val;
    sort(vec.begin(),vec.end());
    ll hoge=0;
    for(int i = vec.size()-1;num!=0;i--){
        num--;
        hoge += val - vec[i];
    }
    if(hoge<=K) return true;
    else return false;
}

int main(){
    int N;
    ll K;
    cin>>N>>K;
    ll A[500];
    ll sum = 0;
    rep(i,N) {cin>>A[i];sum+=A[i];}
    vector<ll> vals = fact(sum);
    rep(i,vals.size()){
        ll val = vals[i];
        if(check(A,val,N,K)){
            cout<<val<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int t;
	float breakvalue,n,y;

	while(scanf("%f",&breakvalue) != EOF){
		n = breakvalue / 9.8;
		y = 4.9 * n * n;
		for(t = 0;5 * t - 5 < y;t ++){
		}
		printf("%d\n",t);
	}
	return 0;
}

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

#define _REP(i,a,b) for(int i = (a) ; i >= (int)(b) ; --i )
#define REP(i,a,b) for(int i = (a) ; i <= (int)(b) ; ++i )
#define UREP(i,u) for(int i = p[(u)] ; i + 1 ; i = edge[i].next)
//iterator: for(int u:x),x is container
#define x(p) (p).first
#define y(p) (p).second
#define pii pair<int,int>
#define mp(x,y) make_pair((x), (y))
#define ll long long
#define inf 0x3f3f3f3f
#define mem(x,v) memset((x), (v), sizeof (x))
#define ri1(x) scanf("%d", &(x))
#define ri2(x,y) scanf("%d%d", &(x), &(y))
#define ri3(x,y,z) scanf("%d%d%d", &(x), &(y), &(z))
#define ri4(a,b,c,d) scanf("%d%d%d%d", &(a), &(b), &(c), &(d))
#define pi1(a) printf("%d\n", (a))
#define pi2(a,b) printf("%d%d\n", (a), (b))

#ifdef kinesis
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

const int maxn = 1e5 + 5;
int n,a[maxn];
map<int,int> m1,m2;

int main()
{
    ri1(n);
    REP(i,1,n) ri1(a[i]);
    int max1=0,c1=0,max2=0,c2=0;
    int p1=-1,p2=-1,w1,w2;
    for(int i=1;i<=n;i+=2){
        c1++;
        m1[a[i]]++;
    }
    for(pair<int,int> x:m1){
        if(max1<x.second){
            w1 = x.first;
            p1 = max1;
            max1 = x.second;
        }
        else if(p1<x.second) p1 = x.second;
    }
    for(int i=2;i<=n;i+=2){
        c2++;
        m2[a[i]]++;
    }
    for(pair<int,int> x:m2){
        if(max2<x.second){
            w2 = x.first;
            p2 = max2;
            max2 = x.second;
        }
        else if(p2<x.second) p2 = x.second;
    }
    //printf("%d %d %d %d\n",c1,c2,p1,p2);
    if(w1!=w2) printf("%d\n",c1-max1+c2-max2);
    else printf("%d\n",min(c1-p1+c2-max2,c1-max1+c2-p2));
    return 0;
}


Measured memory_bytes: 5376
A,B,K = map(int,input().split())

while True:
  A -= A&1
  A,B = A//2, B+A//2
  K -= 1
  if K == 0:
    break
  B -= B&1
  B,A = B//2, A+B//2
  K -= 1
  if K == 0:
    break
  
print(A,B)

Measured memory_bytes: 3060