akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define N	 100
void solve(){
	char a, b, c, d;
	cin>>a>>b>>c>>d;
	if((a==b && b== c) || (b==c && c==d)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  ll n, T;
  cin >> n >> T;
  vll t(n);
  rep(i,n) cin >> t[i];
  
  ll ans = 0;
  rep(i,n-1) {
    ans += min(t[i+1]-t[i], T); 
  }
  ans += T;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
void Main()
{
    ll X;
    cin >> X;

    vector<ll> v5(1000);
    repi(i, 1000) {
        v5[i] = i * i * i * i * i;
        if (i >= 1 && v5[i] - v5[i - 1] > X) {
            break;
        }
    }

    rep(i, v5.size()) {
        rep(j, v5.size()) {
            if (v5[i] - v5[j] == X) {
                cout << i << " " << j << endl;
                return;
            }

            if (v5[i] + v5[j] == X) {
                cout << i << " " << -j << endl;
                return;
            }
        }
    }
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3616
bit=[0 for i in xrange(200)]
n=int(raw_input().strip())
class dig:
    def __init__(self,val,id):
        self.val=val
        self.id=id
    def __gt__(self,other):
        return self.val<other.val


def sum(i):
    s=0
    i=int(i)
    while i>0:
        s+=bit[i]
        i-=i&(-i)
    return s
def add(i,x):
    i=int(i)
    while i<=n:
        bit[i]+=x
        i+=i&-i


def sort2(lst):
    lens=len(lst)
    sm=0
    for i in xrange(lens):
        for j in xrange(i+1,lens):
            if lst[i]>lst[j]:
                sm+=1
    return sm
lst=map(int,raw_input().strip().split())
vals=[]
lens=len(lst)
for i in xrange(lens):
    vals.append(dig(lst[i],i+1))
vals.sort()
ans=0
for i in vals:
    #print i.val,i.id
    ans+=sum(i.id)
    add(i.id,1)
ans=sort2(lst)
lst.sort()
print " ".join(str(pp) for pp in lst)
print ans




Measured memory_bytes: 4708
n = int(input())
a = list(reversed([int(input()) for i in range(n+1) ]))

prime = [2,3]

for i in range(5,100000):
    f = True
    for p in prime:
        if(p*p > i):break
        if i % p == 0 :
            f = False
            break
    if f :prime.append(i)

def gcd(x,y):
    if(x < y): x,y = y,x
    if(y == 0): return x
    return gcd(y,x % y)

def isprime(x):
    f = True
    for p in prime:
        if(p*p > x):break
        if x % p == 0:
            f = False
            break
    return f

g = 0
for i in a:
    g = gcd(abs(i),g)



for p in prime:
    if (p > n+1):break
    m = [0 for i in range(p-1)]
    if a[0] % p != 0:continue
    for i in range(n+1):
        m[i % (p-1)] += (a[i] % p)
    f = True
    for i in m:
        if i % p > 0 :
            f = False
            break    
    if f:print(p)




for p in prime:
    if g == 1:break
    if(g % p == 0):
        g //= p
        if (p > n+1):print(p)

if(g != 1):
    if isprime(g):print(g)

Measured memory_bytes: 53848
import java.util.*;
import java.lang.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer k = Integer.parseInt(scanner.next());
        Integer n = Integer.parseInt(scanner.next());

        Integer[] total = new Integer[n];
        for(int i = 0; i < n; i++) {
            total[i] = Integer.parseInt(scanner.next());
        }


        List<Integer> kyori = new ArrayList<Integer>();
        for(int i = 0; i < n-1; i++) {
            kyori.add(Math.abs(total[i] - total[i+1]));
        }

        kyori.add(Math.abs((k - total[n-1]) + total[0]));
        Collections.sort(kyori);
        kyori.remove(kyori.size() - 1);


        int sum = 0;
        for(int i = 0; i < kyori.size(); i++) {
            sum += kyori.get(i);
        }

        System.out.println(sum);
    }
}


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

int main(){
  int n, k, count = 0;
  cin >> n >> k;
  int tmp;
  for (int i = 0; i < n; i++){
    cin >> tmp;
    if (tmp >= k){
      count += 1;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
}; 

int main(){
    Stream io;
    
    int A, B, K;
    io.read(A, B, K);
    set<int> st;
    for(int i = A; i <= min(A + K - 1, B); i++){
        st.insert(i);
    }
    for(int i = max(A, B - K + 1); i <= B; i++){
        st.insert(i);
    }
    for(auto i = st.begin(); i != st.end(); i++){
        cout << *i << '\n';
    }
    return 0;
}

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


int main() {
  int n, k;
  cin >> n >> k;
  if (n%k == 0) cout << 0 << endl;
  else cout << 1 << endl;
  
  return 0;
}

Measured memory_bytes: 256
import re

def main():
  a,b = map(int,input().split())
  s = input()
  target = r'^[0-9]{%d}-[0-9]{%d}$' % (a, b)
  postal_code = re.compile(target)
  
  if postal_code.match(s) is not None:
    print('Yes')
  else:
    print('No')

if __name__ == "__main__":
  main()

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

using namespace std;

short dp[1<<24];

int main()
{
  int n;
  int x[25], y[25], r[25], c[25], b[25];
  while(cin >> n, n) {
    for(int i = 0; i < n; i++) {
      cin >> x[i] >> y[i] >> r[i] >> c[i]; b[i] = 0;
      for(int j = 0; j < i; j++) {
	if((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]) < (r[i]+r[j])*(r[i]+r[j])) b[i] |= (1<<j);
      }
    }
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    for(int i = 0; i < (1<<n); i++) {
      if(!~dp[i]) continue;
      for(int j = 0; j < n-1; j++) {
	if(((i >> j) & 1) == 0 && (i & b[j]) == b[j]) {
	  for(int k = j+1; k < n; k++) {
	    if(c[j] == c[k] && ((i >> k) & 1) == 0 && (i & b[k]) == b[k]) {
	      dp[i|(1<<j)|(1<<k)] = max(dp[i|(1<<j)|(1<<k)], (short)(dp[i]+2));
	    }
	  }
	}
      }
    }
    cout << *max_element(dp, dp + (1<<n)) << endl;
  }
  return 0;
}

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

int main(){

  int a,b,d=0;

  while(cin >> a >> b){

    int count=0;

    if(a==0 && b==0)break;
    if(d==1) cout << endl;

    for(int i=a;i<=b;i++){
      if(i%400==0){
	cout << i << endl;
	count=1;
      }

      else if(i%100!=0 && i%4==0){
	cout << i << endl;
	count=1;
      }
    }

    if(count==0) cout << "NA" << endl;

    d=1;
  }
}

Measured memory_bytes: 1160
#include<stdio.h>

int main(){
    int n;scanf("%d",&n);
    int num = 0;
    int a[100]={0};
    int b;
    while(n--){
        scanf("%d",&b);
        if(b>=1&&b<=399) a[0]++;
        else if(b>=400&&b<=799) a[1]++;
        else if(b>=800&&b<=1199) a[2]++;
        else if(b>=1200&&b<=1599) a[3]++;
        else if(b>=1600&&b<=1999) a[4]++;
        else if(b>=2000&&b<=2399) a[5]++;
        else if(b>=2400&&b<=2799) a[6]++;
        else if(b>=2800&&b<=3199) a[7]++;
        else if(b>=3200&&b<=4800) num++;
    }
    int min = 0;
    for(int i = 0; i < 8; i++)
        if(a[i]>0) min++;
        
        
    
    if(!min&&num){
        printf("1 %d\n",num);
    }
    else{
        printf("%d ",min);
        
        printf("%d\n",min+num);
    }



    return 0;
}


Measured memory_bytes: 128
def main():
    S = input()
    strs = str(S)
    width = len(strs)
    num = 0
    
    for i in range(width, 0, -1):
        if width > i + 1:
            num += adding_first(strs, i) * 2 ** (width - i -1)
            strs = strs[1:]
        else:
            num += adding_first(strs, i)
            strs = strs[1:]
    print(num)

def adding_first(x, y):
    addition = 0
    for i in range(1, y + 1):
        a = x[0:int(i)]
        b = x[int(i):y + 1]
        if len(b) != 0:
            addition += int(a) * 2 ** (len(b)-1)
        else:
            addition += int(a)


    return addition

main()


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
#define mod 10000
int set[101],dp[101][4][4],n,k;
int solve(int today,int mae,int maemae){ //今日の日付,昨日の服,一昨日の服
  if( today == n ) return 1;
  if( dp[today][mae][maemae] ) return dp[today][mae][maemae];
  if( set[today] ){
    if( mae == maemae && mae == set[today]) return 0;
    else return solve(today+1,set[today],mae) % mod;
  }
  int rec = 0;
  for(int i = 1 ; i < 4 ; i++ ){
    if(mae == maemae && mae == i) continue;
    rec += solve(today+1,i,mae) % mod;
  }
  return dp[today][mae][maemae] = rec % mod;
}
int main(){
  cin >> n >> k;
  for(int i = 0 ; i < k ; i++ ){
    int a,b;
    cin >> a >> b;
    set[--a] = b;
  }
  cout << solve( 0, 0, 0) << endl;
}

Measured memory_bytes: 1172
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cstring>
const int MAXN=1e7;
using namespace std;
int cost[MAXN],f[MAXN];
int cnt;
int main()
{
	int now;
	cost[++cnt]=1;
	now=6;
	cost[++cnt]=6;
	while(now<100000)
	{
		now*=6;
		cost[++cnt]=now;
	}
	now=9;
	cost[++cnt]=9;
	while(now<100000)
	{
		now*=9;
		cost[++cnt]=now;
	}
	int n;
	int ans=0;
	memset(f,0x7f7f7f,sizeof(f));
	sort(cost+1,cost+cnt+1);
	scanf("%d",&n);
	f[0]=0;
	for(int i=0;i<=n;i++)
	{
		for(int k=1;k<=cnt && cost[k]<=i;k++)
		{
			if(i-cost[k]<0) break;
			f[i]=min(f[i],f[i-cost[k]]+1);
		}
	}
	printf("%d",f[n]);
	return 0;
} 

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

using namespace std;

const int N = 1e5 + 5;

int n, a[N], c[N], Index;
long long ans = 0;

map <int, int> M;

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> c[i], a[i] = c[i];
    sort(a + 1, a + n + 1);
    for(int i = 1; i <= n; i++) M[a[i]] = i;
    for(int i = 1; i <= n; i += 2) if(M[c[i]] % 2 == 0) ans++;
    cout << ans << endl;
}

//如何避免假做法???

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

int main(){
    const double PI = 3.14159265358979323846;
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    
    double theta_a, theta_b;
    theta_a = 2 * PI * (60 * H + M) / (60 * 12);
    theta_b = 2 * PI * M / 60;
    
    double ans;
    ans = sqrt(A*A + B*B - 2*A*B*cos(theta_a - theta_b));
    
    cout << scientific << setprecision(10) << ans << endl;
}


Measured memory_bytes: 4288
let input = ''

process.stdin.resume()
process.stdin.setEncoding('utf8')
process.stdin.on('data', function(chunk) {
  input += chunk
})
process.stdin.on('end', function() {
  input = input.trim().split('\n')
  main()
})

function main() {
  for (i=0; i< input.length; i++) {
      let prime_count = 0
      let num = parseInt(input[i])+1
      for (j=0;j<num;j++) {
          if(isPrime(j)===true) {
              prime_count+=1
          }
      }
      console.log(prime_count)
      prime_count = 0
  }
}


function isPrime(n){
    if(false===Number.isInteger(n)){
        return false;
    }
    if(n<=1){
        return false;
    }
    if(2===n){
        return true;
    }
    if(0===n%2){
        return false;
    }
    var square_root = Math.floor(Math.sqrt(n));
    for(var i=3; i<=square_root; i+=2){
        if(0===n%i){
            return false;
        }
    }
    return true;
}


Measured memory_bytes: 17200
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

const int A = 'a' - 'A';

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    printf("%c%c%c\n", a[0] - A, b[0] - A, c[0] - A);
}


Measured memory_bytes: 256
#n: id card
#m: gate
n, m = map(int, input().split())
data = [0 for i in range(n+1)]

for i in range(m):
    l, r = map(int, input().split())
    data[l-1] += 1
    data[r] -= 1

for i in range(n):
    data[i+1] += data[i]

print(data.count(m))

Measured memory_bytes: 7080
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


void appendNext(vector<vector<LL>>& match, vector<LL>& cur, LL i, vector<pair<LL,LL>>& q){
    if(cur[i] >= match[i].size()) return;
    LL e = match[i][cur[i]];
    if(cur[e] >= match[e].size()) return;
    LL o = match[e][cur[e]];
    if(o == i){
        q.emplace_back(i, e);
    }
}

int main(){
    LL n;
    cin >> n;
    vector<vector<LL>> match(n, vector<LL>(n-1));
    vector<LL> cnt(n);
    for(LL i = 0; i < n; ++i){
        for(LL j = 0; j < n-1; ++j){
            cin >> match[i][j];
            match[i][j] -= 1;
        }
    }
    vector<LL> cur(n);
    vector<pair<LL,LL>> q;
    for(LL i = 0; i < n; ++i){
        if(match[i][0] < i) continue;
        appendNext(match, cur, i, q);
    }
    LL day = 0;
    while(!q.empty()){
        vector<pair<LL,LL>> q2;
        for(auto p: q){
            cerr << "day=" << day << " " << p << endl;
            cur[p.first] += 1;
            cur[p.second] += 1;
            appendNext(match, cur, p.first, q2);
            appendNext(match, cur, p.second, q2);
        }
        day += 1;
        q2.swap(q);
    }
    for(LL i = 0; i < n; ++i){
        if(cur[i] < n-1){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << day << endl;
    return 0;
}



Measured memory_bytes: 10176
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;


#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

ll count(vector<P>& v, ll a, ll a1, ll b, ll b1){
    ll c = 0;
    for(auto p : v){
        if (a <= p.first && p.first <= a1 && b <= p.second && p.second <= b1) c++;
    }
    return c;
}

ll d_try(vector<P>& v, ll K, ll a, ll a1, ll b, ll b1){
    ll c = count(v, a, a1, b, b1);
    if (c >= K) return (a1 - a) * (b1 - b);
    return (ll)(4 * 1e18 + 100);
}

int main() {
    ll N, K;
    cin >> N >> K;
    vector<P> v(N);
    REP(i, N) cin >> v[i].first >> v[i].second;
    ll ans = 4 * (1e18) + 100;
    REP(i, N)REP(j, N)REP(k, N)REP(l, N){
        ll a = min(v[i].first, v[j].first);
        ll a1 = max(v[i].first, v[j].first);
        ll b = min(v[k].second, v[l].second);
        ll b1 = max(v[k].second, v[l].second);
        if (a == a1 && b == b1){
            ans = min(ans, d_try(v, K, a, a1+1, b, b1+1));
            ans = min(ans, d_try(v, K, a, a1+1, b-1, b1));
            ans = min(ans, d_try(v, K, a-1, a1, b, b1+1));
            ans = min(ans, d_try(v, K, a-1, a1, b-1, b1));
        }else if(a == a1){
            ans = min(ans, d_try(v, K, a, a1+1, b, b1));
            ans = min(ans, d_try(v, K, a-1, a1, b, b1));
        }else if (b == b1){
            ans = min(ans, d_try(v, K, a, a1, b, b1+1));
            ans = min(ans, d_try(v, K, a, a1, b-1, b1));
        }else{
            ans = min(ans, d_try(v, K, a, a1, b, b1));
        }

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


Measured memory_bytes: 256
N = int(input())
TA = [[int(i) for i in input().split()] for _ in range(N)]

taka = 1
aoki = 1

for T,A in TA:
    tmp = max((taka + T - 1) // T, (aoki + A - 1) // A)
    taka = tmp * T
    aoki = tmp * A

print(taka + aoki)

Measured memory_bytes: 3188
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int A = sc.nextInt();
        int B = sc.nextInt();
        int c = (A + B) % 24;
        _out.println(c);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  while(a >= b)b *= 2,k--;
  while(b >= c)c *= 2,k--;
  if(k >= 0)cout << "Yes" << endl;
  else cout << "No" << endl;



  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	string s; cin >> s;
	vector<int> cnt(s.size(), 0);
	if (s[0] == 'A' || s[0] == 'C' || s[0] == 'G' || s[0] == 'T') cnt[0] = 1;
	for (int i = 1; i < s.size(); ++i) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
			cnt[i] = cnt[i - 1] + 1;	
		}
		else {
			cnt[i] = 0;
		}
	}
	int ans = 0;
	for (int i = 0; i < cnt.size(); ++i) {
		ans = max(ans, cnt[i]);
	}
	cout << ans << endl;
	return;
}

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

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

int main() {
    int N;
    int a[110]; 
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> a[i];
    sort(a, a + N);
    int type = 1; 
    for (int i = 0; i < N-1; ++i)
    {if(a[i] != a[i+1]) type++;
    }
    cout << type << endl;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<string> vs(N);
    for (auto& i : vs) cin >> i;

    int i = 0;
    int j = 0;
    while (i < N) {
        while (j+1 < M && vs[i][j+1] == '#') j++;
        if (i+1<N && vs[i+1][j] != '#') {
            cout << "Impossible" << endl;
            return 0;
        }
        for (int k = j + 2; k < M; k++) {
            if (vs[i][k] == '#') {
                cout << "Impossible" << endl;
                return 0;
            }
        }
        for (int k = 0; i+1 < N && k < j; k++) {
            if (vs[i+1][k] == '#') {
                cout << "Impossible" << endl;
                return 0;
            }
        }
        i++;
    }

    if (i == N && j == M-1) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <stack>
#include <limits>
#include <climits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <ciso646>
#include <set>
#include <array>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf 0x3f3f3f3f
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second
#define SETUP cin.tie(0), ios::sync_with_stdio(false), cout << setprecision(15)

namespace {
	struct input_returnner {
		int N; input_returnner(int N_ = 0) :N(N_) {}
		template<typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); }
		template<typename T> operator T() const { T res; cin >> res; return res; }
		template<typename T> T operator - (T right) { return T(input_returnner()) - right; }
		template<typename T> T operator + (T right) { return T(input_returnner()) + right; }
		template<typename T> T operator * (T right) { return T(input_returnner()) * right; }
		template<typename T> T operator / (T right) { return T(input_returnner()) / right; }
		template<typename T> T operator << (T right) { return T(input_returnner()) << right; }
		template<typename T> T operator >> (T right) { return T(input_returnner()) >> right; }
	};
	template<typename T> input_returnner in() { return in<T>(); }
	input_returnner in() { return input_returnner(); }
	input_returnner in(int N) { return std::move(input_returnner(N)); }
}

void solve();
/// ---template---
signed main(void) {
	SETUP;
	solve();
	return 0;
}

const ull MOD = 1e9 + 7;

void solve() {
	int N; cin >> N;
	vector<int> T(N), A(N);
	REP(i, N) cin >> T[i];
	REP(i, N) cin >> A[i];

	if (T[N - 1] != A[0]) {
		cout << 0 << endl;
		return;
	}

	ull res = 1;
	FOR(i, 1, N - 1) {
		if (T[i - 1] < T[i]) {
			if (A[i] < T[i]) {
				cout << 0 << endl; return;
			}
			else {
				continue;
			}
		}
		if (A[i + 1] < A[i]) {
			if (T[i] < A[i]) {
				cout << 0 << endl;
				return;
			}
			else {
				continue;
			}
		}
		res = (res * min(T[i], A[i]))%MOD;
	}
	cout << res << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include<string>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<map>
using namespace std;

int main() {
	unsigned long N, A, B;
	unsigned long C,D,E,F;
	cin >> N >> A >> B;
	C = A + B;
	D = N / C;
	E = N % C;
	if (E <= A) {
		F = E;
	}
	else {
		F = A;
	}

	cout << D * A +F << endl;


	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a,c = [],[]
for _ in range(n):
    a.append(list(map(int,input().split())))
for _ in range(m):
    c.append(list(map(int,input().split())))
li = []
for i in range(n):
    min_distance = 1000000000000
    min_j = 0
    for j in range(m):
        if abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1]) < min_distance:
            min_distance = abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1])
            min_j = j+1
    li.append(min_j)
for i in range(n):
    print(li[i])

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>

using namespace std;

int main() {
    int N;
    string S;
    int K;

    cin >> N;
    cin >> S;
    cin >> K;

    char c = S[K-1];

    string ret = "";
    for (int i = 0; i < N; i++) {
        if (S[i] == c) ret += S[i];
        else ret += "*";
    }

    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
calc :: Int -> Int -> Int -> Int
calc a b c = (div b c) - (div (a-1) c)

main = do
    [a, b, c, d] <- map read . words <$> getLine :: IO [Int]
    print $ (b - a + 1) - (calc a b c) - (calc a b d) + (calc a b (lcm c d))


Measured memory_bytes: 508
import sys


def solve(N: int, Y: int):
    for i in range(0,N+1): ##10000円
        for j in range(N-i+1):
            k = N-i-j
            if 10000*i+5000*j+1000*k == Y:
                print(i,j,k)
                return 

    print(-1,-1,-1)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(N, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		long r = scn.nextInt();
		long D = scn.nextInt();
		long x = scn.nextInt();
		for(int i = 0;i < 10;i++) {
			x = r * x - D;
			System.out.println(x);
		}
	}

}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main()
{
  int x;
  cin>>x;
  if(x>399 && x<600)
    cout<<8<<endl;
  else if(x>599 && x<800)
    cout<<7<<endl;
  else if(x>799 && x<1000)
    cout<<6<<endl;
  else if(x>999 && x<1200)
    cout<<5<<endl;
  else if(x>1199 && x<1400)
    cout<<4<<endl;
  else if(x>1399 && x<1600)
    cout<<3<<endl;
  else if(x>1599 && x<1800)
    cout<<2<<endl;
  else if(x>1799 && x<2000)
    cout<<1<<endl;
  return 0;
}

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

int main(){
	int arg=90;
	double x=0, y=0; 
	
	while(1){
		int a, b;
		 scanf(" %d,%d", &a, &b);
		if(a==0 && b==0) break;
		x+=a*cos(arg*2*M_PI/360);
		y+=a*sin(arg*2*M_PI/360);
		arg-=b;
	}
	
	printf("%d\n%d\n", (int)x, (int)y); 
	return 0;
}

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

int memo[100004][4];
int arr[100004][3];
int n;

int solve(int, int);

int main(){
    memset(memo, -1, sizeof(memo));
    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=1;j<=3;j++)
            arr[i][j]=0;
    for(int i=0;i<n;i++)
        for(int j=1; j<=3;j++)
            cin>>arr[i][j];

    int ans = solve(0,0);
    cout<<ans<<"\n";
    return 0;
}

int solve(int day, int flag){
    if(day==n)
        return 0;

    if(memo[day][flag]!=-1) return(memo[day][flag]);

    int maxi = 0;

    if(flag==0){
        maxi = max(maxi, arr[day][1] + solve(day+1, 1));
        maxi = max(maxi, arr[day][2] + solve(day+1, 2));
        maxi = max(maxi, arr[day][3] + solve(day+1, 3));
    }

    else if(flag==1){
        maxi = max(maxi, arr[day][2] + solve(day+1, 2));
        maxi = max(maxi, arr[day][3] + solve(day+1, 3));
    }

    else if(flag==2){
        maxi = max(maxi, arr[day][1] + solve(day+1, 1));
        maxi = max(maxi, arr[day][3] + solve(day+1, 3));
    }

    else if(flag==3){
        maxi = max(maxi, arr[day][1] + solve(day+1, 1));
        maxi = max(maxi, arr[day][2] + solve(day+1, 2));
    }

    return(memo[day][flag]=maxi);

}


Measured memory_bytes: 14108
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] dice = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            string order = Console.ReadLine();

            for (int i = 0; i < order.Length; i++)
            {
                int dir;
                switch (order[i].ToString())
                {
                    case "N": dir = 1;   break;
                    case "W": dir = 2;   break;
                    case "E": dir = 3;  break;
                    default: dir = 4;   break;
                }
                    int d0 = dice[0];

                    dice[0] = dice[dir];
                    dice[dir] = dice[5];
                    dice[5] = dice[5-dir];
                    dice[5 - dir] = d0;
            }
            Console.WriteLine(dice[0]);
        }
    }
}


Measured memory_bytes: 18420
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);  
      	int a = scan.nextInt();
      	int b = scan.nextInt();
      	scan.close();
      	int c = a * b;
      	if(c % 2 == 0){
        System.out.print("Even");
        }
      	else{
        System.out.print("Odd");
        }      
    }
}

Measured memory_bytes: 22608
import java.util.Scanner;
import java.util.ArrayList;

class Main{
    public static void main(String[] args){
        ArrayList<String> room=new ArrayList<String>();
        for(int i=0;i<120;i++){
            room.add(Integer.toString(0));
        }
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int b,f,r,v;
        for(int j=0;j<n;j++){
            b=sc.nextInt();
            f=sc.nextInt();
            r=sc.nextInt();
            v=sc.nextInt();
            
            int place=(b-1)*30+(f-1)*10+r;
            
            room.set(place-1,Integer.toString(v+Integer.parseInt(room.get(place-1))));
        }
        int count=0;
        for(int k=0;k<12;k++){
            if(k!=0 && k%3==0){
                System.out.println("####################");
            }
            for(int l=0;l<10;l++){
                System.out.print(" "+room.get(count));
                if(l==9){
                    System.out.println();
                }
                count++;
                
            }
        }
    }
}


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

#define ll long long
#define endl '\n'
#ifndef _WINDOWS
// no getchar_unlocked on Windows so just call getchar
#define getchar getchar_unlocked
#endif

template <typename Func>
inline void loop(int e, Func&& f) {
    for (int i = 0; i < e; i++) {
        std::forward<Func>(f)(i);
    }
}
template <typename Func>
inline void loop(int s, int e, Func&& f) {
    for (int i = s; i < e; i++) {
        std::forward<Func>(f)(i);
    }
}
template <typename T>
inline void scanpn(T& num) {
    int c;
    num = 0;
    c = getchar();
    // bool negative = false;
    // if (c == '-') {
    // 	negative = true;
    // 	c = getchar();
    // }
    for (; (c > 47 && c < 58); c = getchar()) num = num * 10 + c - 48;
    // if (negative)
    //     number = -number;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] != t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3636
n=int(input())
a=list(map(int,input().split()))
b=0
for x in a:
    if x%2==0:
        if x%3==0:
            b+=0
        elif x%5==0:
            b+=0
        else:
            b+=1
            break
if b==0:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 3060
#include <cstdio>

using namespace std;
int a[200001];

int main(){
    
    int n;
    
    scanf("%d",&n);
    
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    int last = 0;
    for(int i=n;i>1;i-=2){
        printf("%d ",a[i]);
        last = i;
    }
    printf("%d ",a[1]);
    int next = (last==3) ? 2 : 3;
    for(int i=next;i<n;i+=2){
        printf("%d ",a[i]);
    }
    
    
    return 0;
}

Measured memory_bytes: 2816
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
a=LI()
print(max(a)-min(a))
    


Measured memory_bytes: 3444
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;

int main(){
    
    int N,M;
    cin>>N>>M;
    vector<int> x,y;
    for(int i=0;i<M;i++) {int X,Y;cin>>X>>Y;x.push_back(X);y.push_back(Y);}
    vector<int> box;
    vector<bool> line;
    for(int i=0;i<N;i++) box.push_back(1);
    for(int i=0;i<N;i++) line.push_back(false);
    line[0]=true;
    for(int i=0;i<M;i++) {
        box[x[i]-1]=box[x[i]-1]-1;
        box[y[i]-1]=box[y[i]-1]+1;
        if(line[x[i]-1]==true){
            if(box[x[i]-1] == 0) line[x[i]-1]=false;
            line[y[i]-1]=true;
            
        }
        //cout<<i<<"i"<<endl;
        //for(int i=0;i<line.size();i++) cout<<line[i]<<endl;

    }


    //for(int i=0;i<N;i++) cout<<"box"<<i<<" "<<box[i]<<endl;
    //for(int i=0;i<line.size();i++) cout<<line[i]<<endl;
    int answ=0;
    for(int i=0;i<N;i++) {if(line[i]==true){answ++;}}
    cout<<answ<<endl;
    return 0;
};




Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
const int MOD = 1000000007;
int N, D, X;
int psum[2001][2001];
int tmp[2001][2001];
int extgcd(int a, int b, int &x, int &y) {
  int d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1; y = 0;
  }
  return d;
}
int mod_inv(int a, int m) {
  int x, y;
  extgcd(a, m, x, y);
  return (m + x % m) % m;
}
int combination(int n, int k) {
  if(n < k) return 0;
  int ans = 1;
  for(int i = 0; i < k; ++i) {
    ans *= (n - i) % MOD;
    ans %= MOD;
    ans *= mod_inv(k - i, MOD);
    ans %= MOD;
  }
  return ans;
}
signed main() {
  ios::sync_with_stdio(false);
  while(true) {
    cin >> N >> D >> X;
    if(N == 0 && D == 0 && X == 0) break;
    memset(tmp, 0, sizeof(tmp));
    for(int i = 1; i < X; ++i) {
      tmp[1][i] = 1;
    }
    for(int i = 1; i < 2001; ++i) {
      psum[1][i] = psum[1][i - 1] + tmp[1][i];
      psum[1][i] %= MOD;
    }
    for(int d = 2; d < 2001; ++d) {
      for(int i = 1; i < 2001; ++i) {
        int add = psum[d - 1][max<int>(0, i - 1)];
        int sub = psum[d - 1][max<int>(0, i - X)];
        tmp[d][i] = add - sub;
        tmp[d][i] = (MOD + tmp[d][i] % MOD) % MOD;
      }
      for(int i = 1; i < 2001; ++i) {
        psum[d][i] = psum[d][i - 1] + tmp[d][i];
        psum[d][i] %= MOD;
      }
    }
    //for(int d = 1; d <= 5; ++d) {
    //  cerr << "d = " << d << ":";
    //  for(int n = 0; n <= 10; ++n) {
    //    cerr << " " << tmp[d][n];
    //  }
    //  cerr << endl;
    //}
    int ans = 0;
    for(int d = 1; d <= N; ++d) {
      ans += combination(D, d) * tmp[d][N];
      // cerr << "comb " << D << " " << d << " = " << combination(D, d) << endl;
      // cerr << "tmp[" << d << "][" << N << "] = " << tmp[d][N] << endl;
      ans = (MOD + ans % MOD) % MOD;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 63756
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << ' ' << y << ' ' << z << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <cmath>

using namespace std;

struct Point {
    double x, y;
    Point() {}
    Point(double x, double y) : x{x}, y{y} {}

    Point operator - (const Point& p) const {
        return Point(x - p.x, y - p.y);
    }
};

struct Circle : Point {
    double r;
    Circle() {}
    Circle(double x, double y, double r) : Point(x, y), r{r} {}
};

double dot(const Point& a, const Point& b)
{
    return a.x * b.x + a.y * b.y;
}

double cross(const Point& a, const Point& b)
{
    return a.x * b.y - b.x * a.y;
}

double norm(const Point& p)
{
    return dot(p, p);
}

double abs(const Point& p)
{
    return sqrt(norm(p));
}

int mem[1145];

bool contain(const Point& p, const Circle& c)
{  
    return (sqrt(pow(p.x - c.x, 2) + pow(p.y - c.y, 2)) < c.r);
}

bool intersect(const Circle& a, const Circle& b)
{
    double d = abs(a - b);
    return (d <= a.r + b.r && d >= abs(a.r - b.r));
}

int solve(int v, const vector<int>& n, const vector<Circle>& c)
{
    int& res = mem[v];
    if (res != -1) return res;
    res = 0;
    for (int i = 0; i < (int)n.size(); i++) {
        if (n[i] == v) continue;
        if (!intersect(c[v], c[n[i]]) && c[v].r > c[n[i]].r) {
            res = max(res, solve(n[i], n, c) + 1);
        }
    }    
    return res;
}

int main()
{
    int N;
    while (cin >> N, N > 0) {
        Point s, t;     
        cin >> s.x >> s.y >> t.x >> t.y;
        vector<int> n[2];
        vector<Circle> c(N + 2);
        for (int i = 0; i < N; i++) {
            cin >> c[i].x >> c[i].y >> c[i].r;
            bool in[] = {contain(s, c[i]), contain(t, c[i])};
            if (in[0] + in[1] == 1) {
                for (int j = 0; j < 2; j++) {
                    if (in[j]) n[j].emplace_back(i);
                }
            }
        }

        n[0].emplace_back(N);
        n[1].emplace_back(N + 1);
        c[N] = Circle(s.x, s.y, 0);
        c[N + 1] = Circle(t.x, t.y, 0);

        memset(mem, -1, sizeof(mem));
        
        int res = 0;
        for (auto& i : n[0]) {
            for (auto& j : n[1]) {
                if (intersect(c[i], c[j])) continue;
                res = max(res, solve(i, n[0], c) + solve(j, n[1], c));
            }
        }
        cout << res << endl;
    }        
    return 0;
}

Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// DAME:
int gcd(ll x, ll y){
    if(x<y){
        swap(x, y);
    }
    if(y==0){
        return x;
    }
    return gcd(y, x%y);
}

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    ll ans = 0;
    for(int i=0; i<n; i++){
        ans = gcd(ans, a[i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const ld Pi=acos(-1);
int main(){
  string str;
  cin>>str;
  if(str.size()%2==0){
    for(ll i=0;i<((ll)str.size()/2);i++){  
      if(str.at(2*i)!='h' || str.at(2*i+1)!='i'){break;}
      if(i==((ll)str.size()/2-1)){cout<<"Yes"<<endl;return 0;}
    }
  }
  cout<<"No"<<endl;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

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

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const ll INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int fact[100010];

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    int n, p; cin >> n >> p;
    string s; cin >> s;
    reverse(all(s));

    ll ans = 0;
    if(p == 2 || p == 5){
        rep(i,n){
            if((s[i] - '0') % p == 0){
                ans += n - i;
            }
        }
    }else{
        vi sum(n+1), base(n+1);
        base[0] = 1;
        rep(i,n) base[i+1] = base[i] * 10 % p;
        rep(i,n) sum[i+1] = (sum[i] + (s[i] - '0') * base[i]) % p;
        map<ll, ll> mp;
        mp[0] = 1;
        REP(i,1,n+1){
            int x = sum[i];
            if(mp.count(x)) mp[x]++;
            else mp[x] = 1;
        }
        for(auto pa : mp){
            ans += pa.se * (pa.se - 1) / 2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2580
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

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

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    n %= 1000;
    if (n == 0) cout << 0 << '\n';
    else cout << 1000-n << '\n';
    return 0;
}

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

using namespace std;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + (c ^ 48), c = getchar();
	return f * x;
}

int n, m, k, mm;

int main()
{
	n = gi(), m = gi(), k = gi();
	mm = max(n, m);
	if (k % mm == 0) cout << k / mm << endl;
	else cout << k / mm + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>

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

using namespace std;

typedef pair <int, int> P;

int main() {
    int N, M;
    cin >> N >> M;
    vector <P> a(N);
    rep(i, N) cin >> a[i].first >> a[i].second;
    sort(a.begin(), a.end());
    long cost = 0;
    int num = 0;
    int i = 0;
    while (num < M) {
        if (a[i].second + num <= M) {
            num += a[i].second;
            cost += (long)a[i].second * a[i].first;
        }   
        else {
            cost += (long)a[i].first * (M - num);
            num += M - num;
        }   
        i++;
    }   
    cout << cost << endl;
}


Measured memory_bytes: 1024