akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBishop solver = new BBishop();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBishop {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            long h = s.nextInt(), wi = s.nextInt();
            if (h == 1 || wi == 1) {
                w.println(1);
                return;
            }
            w.println(((wi + 1) / 2) * ((h + 1) / 2) + (wi / 2) * (h / 2));
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

int const B = 10;

int main() {
    int D, G, S, N, k;
    int best = 0;
    bitset<B> b;
    cin >> D >> G;
    vector<int> p(D), c(D);
    for (int i = 0; i < D; i++) {
        cin >> p[i] >> c[i];
        best += p[i];
    }
    for (int i = 0; i < (1 << D) - 1; i++) {
        S = 0;
        N = 0;
        b = i;
        for (int j = 0; j < D; j++) {
            if (b.test(j)) {
                S += p[j] * (j+1) * 100 + c[j];
                N += p[j];
            }
        }
        k = D-1;
        while (b.test(k)) k--;
        if (S + (p[k]-1) * (k+1) * 100 < G) continue;
        while (S < G) {
            S += (k+1) * 100;
            N++;
        }
        if (N < best) best = N;
    }
    cout << best << endl;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n=int(input())
l=input().split(" ")
L=[]
for i in l:
    t=int(i)
    L.append(t)
ans=0
for i in range(n):
    k=0
    while(k<=i):
        if(L[i]<L[k]):
            break
        
        if(k==i):
            ans+=1
        k+=1
print(ans)
    


Measured memory_bytes: 3060
#include <iostream>
#include<queue>
#include<vector>
using namespace std;
vector<queue<long long>>v;
int main()
{
    int n,T,flag,t,x;
    cin>>n>>T;
    v.resize(n);
    while(T--)
    {
        cin>>flag>>t;
        switch(flag)
        {
        case 0:
            cin>>x;
            v[t].push(x);
            break;
        case 1:
            if(v[t].empty()!=true)
            cout<<v[t].front()<<endl;
            break;
        case 2:
            if(v[t].empty()!=true)
            v[t].pop();
            break;

        }
    }
    return 0;
}



Measured memory_bytes: 5124
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
#include<fstream>
using namespace std;
typedef long long LL;

int main(void)
{
	LL a,b,c,n;
	string s;
	cin >>n>>a;
	a*=2;
	a++;
	cout <<(n+a-1)/a<<endl;
	return 0;
}

Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
    int x;
void solve() {
    R(x);
    W(x^1);
}
void input() {
R(x);    
}
int main(){
#define MULTITEST 0
#if MULTITEST    
    CASET{
        input();
        solve();
    }
#else
    solve();
#endif
    return 0;
}


Measured memory_bytes: 3824
a,b,c = map(int, input().split())
l = sorted([a,b,c],reverse=True)
ans = 0
def all_same(items):
    return all(x == items[0] for x in items)

while not all_same(l):
    d = l[0] - l[1]
    l[1] += d
    l[2] += d
    ans += d
    d = l[1] - l[2]
    l[2] += 2 * (d//2)
    ans += d // 2
    if l[1] - l[2] == 1:
        l[2] += 2
        ans += 1
    l = sorted(l,reverse=True)    
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
using namespace std;

int main() {
    int n, m;
    while (cin >> n >> m && n) {
        vector<int> p(n);
        for (int i=0; i<n; ++i) {
            cin >> p[i];
        }
        sort(p.begin(), p.end());
        
        int res = accumulate(p.begin(), p.end(), 0);
        for (int i=n%m; i<n; i+=m) {
            res -= p[i];
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3012
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int point = getPoint(x) + getPoint(y);
		if (x == 1 && y == 1) {
		    point += 400000;
		}
		System.out.println(point);
   }
   
   static int getPoint(int score) {
       if (score == 1) {
           return 300000;
       } else if (score == 2) {
           return 200000;
       } else if (score == 3) {
           return 100000;
       } else {
           return 0;
       }
   }

}



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

using namespace std;

int main() {

    int a, b, c, r;
    cin >> a >> b >> c;

    if(a * c > b){

        r = b/a;
        
        cout << r << endl;

    }else if(a * c <= b) {

        cout << c << endl;
    }


}

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

class Problem0008
{
    static void Main(string[] args)
    {
        var sums = GetInputLines().Select(line => int.Parse(line));
        foreach (int sum in sums)
        {
            Console.WriteLine(GetPermutations(sum, 4).Count());
        }
    }

    static IEnumerable<int[]> GetPermutations(int sum, int length)
    {
        if (length == 1)
        {
            if (sum <= 9)
            {
                yield return new int[] { sum };
            }
        }
        else
        {
            int min = Math.Min(9, Math.Max(0, sum - (length - 1) * 9));
            int max = Math.Min(9, sum);
            foreach (int head in Enumerable.Range(min, max - min + 1))
            {
                foreach (int[] tail in GetPermutations(sum - head, length - 1))
                {
                    yield return (new int[] { head }).Concat(tail).ToArray();
                }
            }
        }
    }

    static IEnumerable<string> GetInputLines()
    {
        string line;
        while (!string.IsNullOrEmpty(line = System.Console.ReadLine()))
        {
            yield return line;
        }
    }
}

Measured memory_bytes: 9824
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int r=sc.nextInt();
        if(n < 10)
        {
            System.out.println(100*(10-n)+r);
        }
        else{
            System.out.println(r);
        }
	}
}


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

main()
{
  int a,b;
  string s;

  cin >> a >> b;
  cin >> s;
  int f=0;

  for(int i=0;i<a;i++){
    if(s[i]-'0'<0||s[i]-'0'>9)
      f=1;
  }
  for(int i=a+1;i<a+b;i++){
    if(s[i]-'0'<0||s[i]-'0'>9)
      f=1;
  }

  if(s[a]!='-')
    f=1;

  if(f==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return (0);
}
  

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder ans = new StringBuilder();
        int n = sc.nextInt();
        int[] A = new int[n];
        for(int i = 0; i < n-1; i++) A[Integer.parseInt(sc.next()) - 1]++;
        for(int a : A) ans.append(a).append("\n");
        System.out.print(ans);
    }
}


Measured memory_bytes: 59868
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 

int  A(int x){
    if(x>=0)return x;
    else return -x;
}



int main(void){
    ll k;
    cin>>k;
    vector<ll>a(k);
    for(ll i=0;i<k;i++){
        cin>>a[i];
    }
    ll mi = 0,ma = 0;
    for(ll i=k-1;i>=0;i--){
        if(i==k-1){
            if(a[i]!=2){
                cout<<-1<<endl;
                return 0;
            }
            else{
                mi = 2;
                ma = 3;
            }
        }
        else{
            if(a[i]>ma){
                cout<<-1<<endl;
                return 0;
            }
            ll tmp1 = 0,tmp2 = 0;
            if(mi%a[i]==0){
                tmp1 = mi/a[i];
                tmp1 = a[i]*tmp1;
            }
            else{
                tmp1 = mi/a[i];
                tmp1 = (tmp1+1)*a[i];
            }
            tmp2 = ma/a[i];
            tmp2 = a[i]*tmp2;
            if(tmp1>tmp2){
                cout<<-1<<endl;
                return 0;
            }
            mi = tmp1;
            ma = a[i]*(tmp2/a[i]+1)-1;
        }
        //cout<<mi<<" "<<ma<<endl;
    }
    cout<<mi<<" "<<ma<<endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
import fractions
import math
import re
from collections import defaultdict

sr = lambda: sys.stdin.readline().rstrip()
S = sr()
r = True
c = 0
ans = [0 for _ in range(len(S))]
r = 0
rll = [m.start() for m in re.finditer("RL", S)]
lrl = [m.start() for m in re.finditer("LR", S)]

for i in range(len(rll)):
    l = 0
    if i == len(rll) - 1:
        l = len(S) - 1
    else:
        l = lrl[i]
    all = l - r + 1
    if all % 2 == 1:
        if (l - rll[i]) % 2 == 1:
            ans[rll[i]] = all // 2
            ans[rll[i]+1] = all // 2 + 1
        else:
            ans[rll[i]] = all // 2 + 1
            ans[rll[i]+1] = all // 2
    else:
        ans[rll[i]] = all // 2
        ans[rll[i]+1] = all // 2
    r = l + 1
print(" ".join(map(str, ans)))

Measured memory_bytes: 16636
#include<bits/stdc++.h>
    #include <ext/pb_ds/tree_policy.hpp> 
    #include <functional> // for less 
    using namespace __gnu_pbds; 
    using namespace std;
    //typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;    
    #define ll            long long
    #define pb            push_back
    #define ppb           pop_back
    #define si            set <ll>
    #define endl          '\n'
    #define fr            first
    #define sc            second
    #define mii           map<ll ,ll >
    #define msi           map<string,ll >
    #define mis           map<ll , string>
    #define rep(i,a,b)    for(ll  i=a;i<b;i++)
    #define all(v)        v.begin(),v.end()
    #define sort(v)       sort(all(v))
    #define pii           pair<ll ,ll >
    #define vi            vector<ll >
    #define vii           vector<pair<ll , ll >>
    #define vs            vector<string>
    #define sz(x)         (ll)x.size()
    #define M             1000000007
    #define bs            binary_search
    #define rev(a)        reverse(all(a));
    #define sp(n)         setprecision(n)
    #define spl           " "
    #define arr(a,n)      rep(i,0,n) cin>>a[i]
    #define mod           998244353
    #define print_vector(a)  for(auto t:a) cout<<t<<" ";cout<<endl;
    #define print_arr(a,n)   rep(i,0,n) cout<<a[i]<<" "; cout<<endl;        
    #define show(a,n)     for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
    #define N             100000000
    #define debug(x)      cout << #x << " is " << x << endl;
    #define time          cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    #define INF           1ll<<31
    #define M_PI 3.14159265358979323846
    using namespace std;
    ll min(ll a,ll b)
    {
        return a>b?b:a;
    }
    ll max(ll a,ll b)
    {
        return a>b?a:b;
    }
    const ll maxn=2e5+500;
    void solve()
    {
      ll r;
      cin>>r;
      cout<<fixed<<sp(18);
      double rr=2*M_PI*r;
      cout<<rr<<endl;

    }
    signed main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        #ifndef ONLINE_JUDGE
        //freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
        #endif
        ll t=1;
        //cin>>t;
        while(t--) solve();
    }


Measured memory_bytes: 3800
import sys
my_input = sys.stdin.readline
from collections import deque
H, W = map(int, my_input().split())
Sh, Sw = map(int, my_input().split())
Sh, Sw = Sh - 1, Sw - 1
Gh, Gw = map(int, my_input().split())
Gh, Gw = Gh - 1, Gw - 1
G = [list(my_input()) for _ in range(H)]
INF = 10 ** 9

dist = [[INF] * W for _ in range(H)]
dist[Sh][Sw] = 0
que = deque([[Sh, Sw]])
directions = [(0, 1), (0, -1), (1, 0), (-1, 0)]
directions5 = []
for i in range(-2, 3):
    for j in range(-2, 3):
        directions5.append((i, j))


while que:
    nh, nw = que.pop()
    for dh, dw in directions:
        fh, fw = nh + dh, nw + dw
        if not ((0 <= fh < H) and (0 <= fw < W)):
            continue
        if G[fh][fw] == '#':
            continue
        if dist[fh][fw] <= dist[nh][nw]:
            continue
        dist[fh][fw] = dist[nh][nw]
        que.append([fh, fw])

    for dh, dw in directions5:
        fh, fw = nh + dh, nw + dw
        if not ((0 <= fh < H) and (0 <= fw < W)):
            continue
        if G[fh][fw] == '#':
            continue
        if dist[fh][fw] <= dist[nh][nw] + 1:
            continue
        dist[fh][fw] = dist[nh][nw] + 1
        que.appendleft([fh, fw])

print(dist[Gh][Gw] if dist[Gh][Gw] != INF else - 1)


Measured memory_bytes: 136416
def main():
	n = int(input())
	List = list(map(int,input().split()))
	# print(List)
	check = 0
	for i in range(n-1):
		if List[i+1] - List[i] < -1:
			print("No")
			check = 1
			break
		elif List[i+1] - List[i] == -1:
			List[i+1] += 1
			# print(List[i+1])
		else:
			continue
	
	if check == 0:
		print("Yes")

if __name__ == '__main__':
	main()

Measured memory_bytes: 63984
#include<bits/stdc++.h>
using namespace std;
int main()
{
	unsigned long long x,y,k,ans=0;
	cin>>x>>y;
	k=y/x;
	while(k>0)
	{
		k/=2;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string s, t;

int main() {
	cin >> s >> t;
	int sl = s.length(), tl = t.length();
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(all(t));
	if (s<t) cout << "Yes" << ln;
	else cout << "No" << ln;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int nxt(){int aaa;scanf("%d",&aaa);return aaa;}
typedef unsigned long long ull;
void solve()
{
    ull a;
    cin>>a;
    if(a%2==1) cout<<0<<endl;
    else{
        ull cnt=0;
        ull q=10;
        while(a>=q){
            cnt+=(a/q);
            q*=5;
        }
        cout<<cnt<<endl;
    }

}
int main()
{
    int tc=1;
    while(tc--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int i=1;
while(1){
int x=i;
if(x%3==0){
cout<<" "<<i;
}
else{
while(1){
if(x%10==3){
cout<<" "<<i;
break;
}
x/=10;
if(x==0) break;
}
}
if(++i>n) break;
}cout<<endl;
return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	static long mod=1000000007;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int place1=0;
		int place2=0;
		int[] a=new int[n];
		Arrays.fill(a,-1);
		for(int i=0; i<n+1; i++){
			int b=sc.nextInt()-1;
			if(a[b]==-1){
				a[b]=i;
			}else{
				place1=a[b];
				place2=i;
			}
		}
		long[] pow=new long[n+2];
		pow[0]=1;
		for(int i=1; i<=n+1; i++){
			pow[i]=pow[i-1]*i;
			pow[i]%=mod;
		}
		long[] mp=new long[n+2];
		mp[0]=1;
		for(int i=1; i<=n+1; i++){
			mp[i]=modpow(pow[i],mod-2);
		}
		int c=place2-place1+1;
		for(int i=1; i<=n+1; i++){
			long c1=(((pow[n+1]*mp[n+1-i])%mod)*mp[i])%mod;
			long c2=0;
			if(n+2-c-i>=0){
				c2=(((pow[n+1-c]*mp[n+2-c-i])%mod)*mp[i-1])%mod;
			}
			System.out.println((c1-c2+mod)%mod);
		}
	}
	static long modpow(long left,long right){
		long ans=1;
		while(right>0){
			if((right&1)==1){
				ans*=left;
			}
			right>>=1;
			left*=left;
			ans%=mod;
			left%=mod;
		}
		return ans;
	}
}


Measured memory_bytes: 60900
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  if (k & 1)
    cout << -(a - b) << endl;
  else
    cout << a - b << endl;
}


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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 1e9 + 7;
const ll MAXN = (ll) 2e5 + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-8;

ll cnt[30];

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	str s;
	cin >> s;
	ll ans = 1;
	for(auto x : s) cnt[x - 'a']++;
	for(int i =0; i < 30;i++) ans = ans * (cnt[i] + 1) % MOD;
	cout << (ans + MOD - 1) % MOD;

	return 0;
}


/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/


Measured memory_bytes: 512
#include <stdio.h>
int main(void){
  int m,n,c,i,t;
  while(scanf("%d",&m),m){
    scanf("%d",&n);
    c=0;
    for(i=m;i<=n;i++){
      t=i;
      while(t%2==0)
	t/=2;
      while(t%3==0)
	t/=3;
      while(t%5==0)
	t/=5;
      if(t==1)
	c++;
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 596
#include<iostream>
using namespace std;
#define R(i,n) for(int i=0;i<n;i++)
int n,a=1e9,c[2][20],p[1<<18][51];main(){cin>>n;R(i,n*2)cin>>c[i/n][i%n];fill(p[1],p[1<<n],1e9);R(B,1<<n){int o=0,d[n];R(i,n)d[i]=~B&1<<i?o++:0;R(i,n){int k=c[(i-n+o)&1][i],&t=p[B|1<<i][k];R(j,k+1)t=min(t,p[B][j]+d[i]);if((B|1<<i)==(1<<n)-1)a=min(a,t);}}cout<<(a>1e8?-1:a);}

Measured memory_bytes: 52480
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N, K := getInt(), getInt()
	h := getInts(N)
	cnt := 0
	for i := 0; i < N; i++ {
		if h[i] >= K {
			cnt++
		}
	}
	out(cnt)
}


Measured memory_bytes: 2868
#include<bits/stdc++.h>
using namespace std;
typedef long long l;
l m[401][401];
l arr[401];
l sum(l i, l j){
	l ans = 0;
	for(int k = i; k<=j; k++) ans += arr[k];
	return ans;
}

l mixtures(l i, l j){
	if(i == j) return 0;
	if(m[i][j] < 1000000000000001) return m[i][j];
	l count = 0;
	for(int k = i; k<j; k++){
		count = mixtures(i, k) + mixtures(k+1, j) + (sum(i, k) + sum(k+1, j));
		//cout << count << " and k " << k <<  " sum " << sum(i, k) << " " << sum(k+1, j) << endl;
		if(count < m[i][j]) m[i][j] = count;
	}
	return m[i][j];
}
int main(){
	int n; cin >> n;
	for(int i=0; i<n; i++) cin >> arr[i];
	for(int i=0; i<=n; i++)
		for(int j = 0; j<=n; j++) m[i][j] = 1000000000000001;
	l ans = mixtures(0, n-1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
using namespace std;
int main(){
  int mn = 10;
  int sm = 0;
  for(int i = 0; 5 > i; i++){
    int n;cin>>n;
    sm += n/10*10+(n%10?10:0);
    if(n%10){
      mn = min(mn,n%10);
    }
  }
  cout << sm-10+mn << endl;
}


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

int main()
{
    int n, h, m, d, guest[3], ok[3];
    char c;
    string s[3] = { "lunch", "dinner", "midnight" };

    while( cin >> n )
    {
        if( !n )
            break;

        guest[0] = guest[1] = guest[2] = 0;
        ok[0] = ok[1] = ok[2] = 0;

        for( int i = 0; i < n; i++ )
        {
            cin >> h >> c >> m >> d;
            int t = 3;
            if( 11 <= h && h <= 14 )
                t = 0;
            if( 18 <= h && h <= 20 )
                t = 1;
            if( 21 <= h && h <= 23 || h == 0 || h == 1 )
                t = 2;

            if( t == 3 )
                continue;
            
            guest[t]++;
            if( m > d )
                d += 60;

            if( d - m <= 8 )
                ok[t]++;
        }

        for( int i = 0; i < 3; i++ )
        {
            if( guest[i] == 0 )
                cout << s[i] << " no guest" << endl;
            else
                cout << s[i] << " " << 100 * ok[i] / guest[i] << endl;
        }

    }
    return 0;
}


Measured memory_bytes: 3128
#include<cstdio>
#include<cstring>
const int N=1<<20;
typedef long long ll;
int n;
char c[N];
int q;
int K[80];
int pD[N],pM[N],pC[N];
ll Mul[N];
void precalc(){
    for(int i=0;i<n;++i){
        pD[i+1]=pD[i];
        pM[i+1]=pM[i];
        pC[i+1]=pC[i];
        Mul[i+1]=Mul[i];
        if(c[i]=='D')++pD[i+1];
        if(c[i]=='M')++pM[i+1];
        if(c[i]=='C'){
            ++pC[i+1];
            Mul[i+1]+=pM[i];
        }
    }
}
ll ans[80];
int main(){
    scanf("%d%s%d",&n,c,&q);
    for(int i=0;i<q;++i)scanf("%d",&K[i]);
    precalc();
    for(int a=0;a<n;++a)if(c[a]=='D'){
        for(int i=0;i<q;++i){
            int mxc=a+K[i];
            if(mxc>n)mxc=n;
            ans[i]+=Mul[mxc]-Mul[a];
            ans[i]-=1LL*(pC[mxc]-pC[a])*pM[a];
        }
    }
    for(int i=0;i<q;++i)printf("%lld\n",ans[i]);
    return 0;
}

Measured memory_bytes: 21632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e6+5;
int num[N],nex[N][26],sum[N][26],cnt=1;
ll ans;
string s[N/5+5];
void add1(int x){
    int n=s[x].length();
    int now=1;
    for(int i=n-1;~i;i--){
        if(!nex[now][s[x][i]-'a'])
            nex[now][s[x][i]-'a']=++cnt;
        now=nex[now][s[x][i]-'a'];
    }
}
void add2(int x){
    int n=s[x].length();
    int now=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<26;j++){
            if(s[x][i]-'a'==j)sum[i][j]=(i>0?sum[i-1][j]:0)+1;
            else sum[i][j]=(i>0?sum[i-1][j]:0);
        }
    }
    for(int i=n-1;~i;i--){
        for(int j=0;j<26;j++)
            if(sum[i][j]&&nex[now][j])
                num[nex[now][j]]++;
        now=nex[now][s[x][i]-'a'];
    }
}
void finds(int x){
    int n=s[x].length();
    int now=1;
    for(int i=n-1;~i;i--)
        now=nex[now][s[x][i]-'a'];
    ans+=num[now]-1;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s[i];
        add1(i);
    }
    for(int i=1;i<=n;i++)
        add2(i);
    for(int i=1;i<=n;i++)
        finds(i);
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 213308
#!/usr/bin/env python

from fractions import gcd

N, M = map(int, input().split())
S = list(input())
T = list(input())

g = int(gcd(N, M))
l = N * M // g

for i, j in zip(S[::N//g], T[::M//g]):
    if i != j:
        print(-1)
        break
else:
    print(l)


Measured memory_bytes: 6628
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;

using namespace std;

int main() {
    string a, b;
    cin >> a >> b;
    a += b;
    int n = stoi(a);
    int rt = sqrt(n);
    if (rt * rt == n) {
        cout << "Yes"
             << "\n";
    } else {
        cout << "No"
             << "\n";
    }
    return 0;
}

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

using ll=long long;

int main() {
  int x1,x2,x3,x4,x5; cin >>x1 >>x2 >>x3 >>x4 >>x5;
  const int temp=1+2+3+4+5;
  int sum_val=x1+x2+x3+x4+x5;
  cout <<temp-sum_val <<endl;
  return 0;
}


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

// ford-fulkerson
struct edge {
    int to, cap, rev;
};

using edges = std::vector<edge>;
using graph = std::vector<edges>;

void add_edge(graph& g, int from, int to, int cap) {
    g[from].push_back(edge{to, cap, static_cast<int>(g[to].size())});
    g[to].push_back(edge{from, 0, static_cast<int>(g[from].size()-1)});
}

int dfs(graph& g, std::vector<bool>& used, int v, int t, int f) {
    if(v == t) {
        return f;
    }
    used[v] = true;
    for(int i=0; i<g[v].size(); ++i) {
        edge& e = g[v][i];
        if(!used[e.to] && e.cap > 0) {
            int d = dfs(g, used, e.to, t, std::min(f, e.cap));
            if(d > 0) {
                e.cap -= d;
                g[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(graph& g, int s, int t) {
    int flow = 0;
    int INF = 1e9;
    std::vector<bool> used(g.size(), false);
    while(true) {
        std::fill(used.begin(), used.end(), false);
        int f = dfs(g, used, s, t, INF);
        if(f == 0) {
            return flow;
        }
        flow += f;
    }

}

int main() {
    int V, E;
    cin >> V >> E;
    graph g(V);
    for(int i = 0; i < E; ++i) {
        int s, t, c;
        cin >> s >> t >> c;
        add_edge(g, s, t, c);
    }
    cout << max_flow(g, 0, V - 1) << endl;
}

Measured memory_bytes: 3156
N=int(input())
Q=list(map(int, input().split()))
M=int(input())
D = [list(map(int, input().split())) for i in range(M)]
for i in D:
    a=Q[i[0]-1]
    Q[i[0]-1]=i[1]
    print(sum(Q))
    Q[i[0]-1]=a

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int L = A + B;
		int R = C + D ;

		String ans = "";

		if ( L < R ) {
			ans = "Right";
		} else if ( R < L ) {
			ans = "Left";
		} else {
			ans = "Balanced";
		}

		System.out.println( ans );
	}
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

template<int um> class UF {
	public:
	vector<int> par,rank;
	UF() {rank=vector<int>(um,0); for(int i=0;i<um;i++) par.push_back(i);}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};
UF<2000> uf;

int in[2000];
int out[2000];

int N,H;


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>H;
	FOR(i,N) {
		int A,B,C,D,L,R;
		cin>>A>>B>>C>>D;
		if(C>0) L=C;
		else L=-A;
		if(D==0) R=B;
		else R=-D;
		
		out[L+1000]++;
		in[R+1000]++;
		uf(L+1000,R+1000);
	}
	
	for(i=-200;i<=-1;i++) {
		if(in[i+1000]>out[i+1000]) return _P("NO\n");
		if(in[i+1000]<out[i+1000]) uf(1000,i+1000);
	}
	for(i=1;i<=200;i++) {
		if(in[i+1000]<out[i+1000]) return _P("NO\n");
		if(in[i+1000]>out[i+1000]) uf(1000,i+1000);
	}
	
	for(i=1000-200;i<=1000+200;i++) if((in[i]||out[i]) && uf[i]!=uf[1000]) return _P("NO\n");
	_P("YES\n");
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define M 1000010
#define L 14

char Hash[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){
  return key % M;
}
int h2(int key){
  return 1 + (key % (M-1));
}
int h3(int key,int i){
  return (h1(key) + i * h2(key)) % M;
}

int find(char str[]){
  long long i,j,key;
  i = 0;
  key = getKey(str);
  while(1){
    j = h3(key,i);
    if(strcmp(Hash[j],str) == 0) return j;
    else if(strlen(Hash[j]) == 0 || i >= M) return 0;
    else i += 1;
  }
  return 0;
}

int insert(char str[]){
  long long i,j,key;
  i = 0;
  key = getKey(str);
  while(1){
    j = h3(key,i);
    if(strlen(Hash[j]) == 0){
      strcpy(Hash[j],str);
      return j;
    }
    else i += 1;
  }
    
  return 0;
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) Hash[i][0] = '\0';
    
  scanf("%d", &n);
    
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
	
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str) >= 1){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }

  return 0;
}



Measured memory_bytes: 15460
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using namespace boost::multiprecision;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
    int cnt[100000];
signed main(){
    int n,q;
    char s[100000];
    scanf("%d%d%s",&n,&q,s);
    rep(i,n-1){
        if(s[i]=='A'&&s[i+1]=='C')cnt[i+1]++;
        cnt[i+1]+=cnt[i];
    }
    rep(i,q){
        int l,r;
        cin>>l>>r;
        cout<<cnt[r-1]-cnt[l-1]<<"\n";
    }
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for(int i=s;i<e;i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(),(a).end()
typedef long long LL;
const LL mod = 1000000007;
int m[10][10];
int cnt;
int check(int a,int b,int c,int d,int e)
{
    return m[m[m[m[m[0][a]][b]][c]][d]][e];
}
int main(){
    cin.tie(0);
    for(int i=0;i<10;i++)for(int j=0;j<10;j++)cin>>m[i][j];
    for(int i=0;i<10000;i++)
    {
        int a=i/1000,b=i/100%10,c=i/10%10,d=i%10;
        int e=m[m[m[m[0][a]][b]][c]][d];
        bool flag=1;
        if(a!=b&&check(b,a,c,d,e)==0)flag=0;
        if(b!=c&&check(a,c,b,d,e)==0)flag=0;
        if(c!=d&&check(a,b,d,c,e)==0)flag=0;
        if(d!=e&&check(a,b,c,e,d)==0)flag=0;
        for(int j=0;j<10;j++)if(a!=j&&check(j,b,c,d,e)==0)flag=0;
        for(int j=0;j<10;j++)if(b!=j&&check(a,j,c,d,e)==0)flag=0;
        for(int j=0;j<10;j++)if(c!=j&&check(a,b,j,d,e)==0)flag=0;
        for(int j=0;j<10;j++)if(d!=j&&check(a,b,c,j,e)==0)flag=0;
        for(int j=0;j<10;j++)if(e!=j&&check(a,b,c,d,j)==0)flag=0;
        if(!flag)cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}




Measured memory_bytes: 3112
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s1 = sc.next();
    String s2 = sc.next();
    for(int i = 0; i < 3; i++){
      if(s1.charAt(i) != s2.charAt(2-i)){
        System.out.println("NO");
        System.exit(0);
      }
    }
    System.out.println("YES");
  }
}

Measured memory_bytes: 21844
use std::cmp::min;

const INF: u64 = 1 << 50;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let a: Vec<u64> = sc.vec(n);
    let mut graph = vec![vec![]; n];
    for _ in 1..n {
        let u = sc.read::<usize>() - 1;
        let v = sc.read::<usize>() - 1;
        graph[u].push(v);
        graph[v].push(u);
    }

    let mut memo = vec![INF; n + 2];
    memo[0] = 0;
    memo[1] = a[0];
    let mut ans = vec![0; n];
    ans[0] = 1;
    dfs(0, 0, &graph, &a, &mut memo, &mut ans);
    for ans in ans.into_iter() {
        println!("{}", ans);
    }
}

fn dfs(
    v: usize,
    p: usize,
    graph: &Vec<Vec<usize>>,
    a: &Vec<u64>,
    memo: &mut Vec<u64>,
    ans: &mut Vec<usize>,
) {
    for &next in graph[v].iter() {
        if p == next {
            continue;
        }
        let a_next = a[next];
        let prev = memo
            .binary_search_by_key(&(a_next * 2), |&m| m * 2 + 1)
            .err()
            .unwrap()
            - 1;
        assert!(memo[prev] < a_next);
        assert!(memo[prev + 1] >= a_next);

        let old = memo[prev + 1];
        memo[prev + 1] = min(memo[prev + 1], a_next);

        ans[next] = memo
            .binary_search_by_key(&(INF * 2), |&m| m * 2 + 1)
            .err()
            .unwrap()
            - 1;

        dfs(next, v, graph, a, memo, ans);
        memo[prev + 1] = old;
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 34784
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
}

use std::cmp;

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input!{
        source = src,
        h: usize,
        n: usize,
        magics: [(usize, usize); n],
    }

    let mut dp: Vec<usize> = vec![1001001001; h + 1];
    dp[0] = 0;
    
    for i in 0..n {
        for j in 0..h {
            let a = magics[i].0;
            let b = magics[i].1;
            let nj = cmp::min(j + a, h);
            dp[nj] = cmp::min(dp[nj], dp[j] + b);
        }
    }

    return dp[h].to_string();
}


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

int main(void){
    int a,b,x;
    cin >> a >> b >> x;

    if(a*a*b/2.0<=x){
        double tantheta = (double)2.0*(a*a*b-x)/(a*a*a);
        double ans = atan(tantheta)*180.0/3.1415926535;
        printf("%.10f\n", ans);
    }else{
        double tantheta = (double)a*b*b/(2.0*x);
        double ans = atan(tantheta)*180.0/3.1415926535;
        printf("%.10f\n", ans);
    }
    return 0;
}

Measured memory_bytes: 512
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int x, k, d;
        cin >> x >> k >> d;

        x = abs(x);
        int steps = x / d;
        if(steps % 2 != k % 2)
            steps--;
        steps = min(steps, k);
     
        int x1 = x - d * steps;
        int x2 = x - d * min(k, steps + 2);
        int ans = min(abs(x1), abs(x2));
        cout << ans << '\n';
    }
    
    return 0;
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
  string s,t,u;
  int a, b,c;
  //cin >> s;
  cin >> a >> b >> c;
  //cin >> s >> t >> u;
  
  cout << c << " " << a << " " << b << endl; 
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
char st[100005];
long long s0[100005],s1[100005], s2[100005], s3[100005];
int main(){
	scanf("%s",st + 1);
	int n = strlen(st + 1);
	s1[0] = s2[0] = s3[0] = 0;
	s0[0] = 1;
	for (int i = 1; i <= n; i++)
		if (st[i] == '?')
			s0[i] = s0[i - 1] * 3 % mod;
		else
			s0[i] = s0[i - 1];
	for (int i = 1; i <= n; i++)	
		if (st[i] == '?'){
			s1[i] = (s1[i - 1] * 3 + s0[i - 1]) % mod;
		} else {
			s1[i] = (s1[i - 1] + (st[i] == 'A') * s0[i - 1]) % mod;
		}
	for (int i = 1; i <= n; i++)	
		if (st[i] == '?'){
			s2[i] = (s2[i - 1] * 3 + s1[i - 1]) % mod;
		} else {
			s2[i] = (s2[i - 1] + (st[i] == 'B') * s1[i - 1]) % mod;
		}
	for (int i = 1; i <= n; i++)	
		if (st[i] == '?'){
			s3[i] = (s3[i - 1] * 3 + s2[i - 1]) % mod;
		} else {
			s3[i] = (s3[i - 1] + (st[i] == 'C') * s2[i - 1]) % mod;
		}
	printf("%d\n",(int)s3[n]);
}

Measured memory_bytes: 3456