akhauriyash/Code-Regression huggingface dataset:
import heapq
 
"""
https://juppy.hatenablog.com/entry/2019/02/18/%E8%9F%BB%E6%9C%AC_python_%E3%83%97%E3%83%A9%E3%82%A4%E3%82%AA%E3%83%AA%E3%83%86%E3%82%A3%E3%82%AD%E3%83%A5%E3%83%BC%28heapq%29%E3%82%92%E7%94%A8%E3%81%84%E3%81%9F%E3%83%97%E3%83%AA%E3%83%A0%E6%B3%95
"""
 
def dijkstra_heap(s,edge):
    #始点sから各頂点への最短距離
    d = [10**10]*n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d
 
################################
N = int(input())
n = N
w = N
 
edge = tuple([] for i in range(n))
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(w-1):
    a,b = map(int,input().split())
    edge[a-1].append([1,b-1])
    edge[b-1].append([1,a-1])

dist_zero = dijkstra_heap(0,edge)
dist_n = dijkstra_heap(N-1,edge)
"""
print(dist_zero)
print(dist_n)
"""
b = 0
w = 0

for black,white in zip(dist_zero,dist_n):
    if black > white:
        w += 1
    else:
        b += 1

if b > w:
    print("Fennec")
else:
    print("Snuke")  

Measured memory_bytes: 91756
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
from collections import Counter
import bisect
from functools import reduce

def main():
    H = I()
    cnt = 0
    while H > 1:
        H //= 2
        cnt += 1
    ans = pow(2, cnt + 1) - 1
    print(ans)


if __name__ == "__main__":
    main()



Measured memory_bytes: 74644
# encoding: utf-8
A, B, C, X, Y = map(int, input().split())

candidate = [0] * 3

# all A or B
candidate[0] = A * X + B * Y

# either is replaced into AB
if X < Y: candidate[1] = (2 * C) * X + B * (Y - X)
else: candidate[1] = (2 * C) * Y + A * (X - Y)

# both is replaced into AB
candidate[2] = (2 * C) * max((X, Y))

print(min(candidate))

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


int main()
{
    int N;
    cin >> N;
    vector<pair<int,int>> R(N), B(N);
    for( int i = 0; i < N; i++ ) cin >> R[i].first >> R[i].second;
    for( int i = 0; i < N; i++ ) cin >> B[i].second >> B[i].first;
    
    // pair の場合、まず first が小さい順にソートされ、
    // さらにその中で second の小さい順にソートされる
    sort( R.begin(), R.end(), greater<pair<int,int>>() );  // y 座標の大きい順にソート
    sort( B.begin(), B.end() );                            // x 座標の小さい順にソート
    
    int ans = 0;

    for( int i = 0; i < N; i++ ){
        for( int j = 0; j < (int) R.size(); ++j ){
            if( B[i].first > R[j].second && B[i].second > R[j].first ){
                R.erase( R.begin() + j );
                ans++;
                break;
            }
        }
    }

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

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

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int cnt=0;
    for(int i=0; i<n-1; i++){
        if(s[i]==s[i+1])
            cnt++;
    }

    cout << min(n-1, cnt+2*k) << endl;
}


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

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] h = new int[n + 1];
            for (int i = 1; i < n + 1; i++) {
                h[i] = in.nextInt();
            }
            int[] dp = new int[n + 1];
            Arrays.fill(dp, Integer.MAX_VALUE);
            dp[1] = 0;
            for (int i = 2; i < n + 1; i++) {
                for (int j = Math.max(1, i - k); j < i; j++) {
                    dp[i] = Math.min(dp[i], dp[j] + Math.abs(h[i] - h[j]));
                }
            }
            out.println(dp[n]);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}

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

int main()
{
    int N, sum=0;
    cin >> N;
    vector<int> Vn(N);
    vector<int> Cn(N);
    vector<int> Sn(N);

    for (int i = 0; i < N;i++){
        cin >> Vn.at(i);
    }
    for (int i = 0; i < N; i++)
    {
        cin >> Cn.at(i);
    }
    for (int i = 0; i < N;i++){
        if (Vn.at(i) - Cn.at(i)>=0)
            sum += Vn.at(i) - Cn.at(i);
    }

    if(sum<0){
        cout << "0" << endl;
    }
    else{
        cout << sum << endl;
    }


    /* 
    for (int i = 0; i < N;i++){
        cout << Sn.at(i) << endl;
    }
    */
}



Measured memory_bytes: 256
s=list(map(int, list(input())))
if 0<s[0]*10+s[1]<=12:
    if 0<s[2]*10+s[3]<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0<s[2]*10+s[3]<=12:
        print('YYMM')
    else:
        print('NA')

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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
#define dpair pair<double,double>

template <typename Val>
Val gcd(Val a, Val b) {
//use ll or int for gcd
    if (b==0) return a;
    else return gcd(b, a%b);
}
template <typename Val>
Val vec_max(vector<Val> v){
  return *max_element(v.begin(),v.end());
}
template <typename Val>
Val vec_min(vector<Val> v){
  return *min_element(v.begin(),v.end());
}
template <typename Val>
void show_vec(vector<Val> *v){
  cout<<endl;
  rep(i,v->size()){
    cout<<v->at(i)<<" ";
  }
  cout<<endl;
}
//---------------------------------------------------------------
int main(){
  int N;
  cin>>N;
  ll ans = 1;
  rep(i,N){
    ll A;
    cin>>A;
    if(A>1000000000000000000)ans = -1;
    if(A == 0)ans = 0;
    ll K = to_string(ans).size()+to_string(A).size()-2;

    if(K>18)ans = -1;
    else if(K==18){
    	if(A*ans==1000000000000000000)ans = 1000000000000000000;
        else ans = -1;
    }else{
    if(ans>0)ans*=A;
    if(ans>1000000000000000000)ans = -1;
    }
    
    
  }

  cout<<ans<<endl;

}


Measured memory_bytes: 3692
//@sakshjha
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define ld long double
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pi 3.14159265358979
const ll MOD =1000000007;
const ll N=1000005;
ll pow (ll x, ll y, ll m);
int main()
{
    IOS
    ll t,i,j;
    //cin>>t;
    t=1;
    while(t--)
    {
       ll n,m,x,k;
       cin>>n>>m>>x;
       ll cost[n];
       ll val[n][m];
       for(i=0; i<n; i++)
       {
           cin>>cost[i];
           for(j=0; j<m; j++)
            cin>>val[i][j];
       }
       ll ans=1e15;
       for(i=1; i<(1<<n); i++)
       {
           ll val1[m]={0},cos=0;
           for(j=0; j<n; j++)
           {
               if(i&(1<<j))
               {
                   cos+=cost[j];
                   for(k=0; k<m; k++)
                    val1[k]+=val[j][k];
               }
           }
          for(j=0; j<m; j++)
          {
              if(val1[j]<x)
                break;
          }
          if(j==m)
            ans=min(ans,cos);
       }
       if(ans==1e15)
        ans=-1;
       cout<<ans;
    }
    return 0;
}


/*ll pow (ll x, ll y, ll m)
{
    ll res=1;
    x=x%m;
    if(x==0)
        return 0;
    while(y>0)
    {
        if(y&1)
        {
            res*=x;
            res%=m;
        }
        y=y/2;
        x=(x*x)%m;
    }
    return res;
}*/


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll gcd(ll n,ll x){
    if(!(n%x)) return n*2-x;
    return n/x*x*2+gcd(x,n%x);
} 
int main(){
    ll n,x; cin>>n>>x;
    cout<<gcd(n-x,x)+n<<endl;
    return 0;
}

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

using namespace std;

#ifdef LOCAL
#define DBG_MACRO_NO_WARNING
#include <dbg.h>
#else
#define dbg(...) 0
#endif

using ll = long long;
using ull = unsigned long long;

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

#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

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

  if (m < n) {
  	puts("No");
   
  } else {
  	puts("Yes");
  }

  return 0;
}

Measured memory_bytes: 256
(* O(2^d d) *)
let kInf = 1 lsl 60
let d, g = Scanf.scanf " %d %d" @@ fun a b -> a, b
let pcs = Array.init d @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> a, b
let rec find r acc i bits =
  if r <= 0 then acc
  else if i < 0 then kInf
  else
    if bits lsr i land 1 = 0 then
      let pt = 100 * (i + 1) in
      let m = min (r / pt) @@ fst pcs.(i) - 1 in
      find (r - m * pt) (acc + m) (i - 1) bits
    else find r acc (i - 1) bits
let rec f sum acc i bits =
  if i >= d then find (g - sum) acc (d - 1) bits
  else
    let p, c = pcs.(i) in
    min (f sum acc (i + 1) bits) @@ f (sum + p * (i + 1) * 100 + c) (acc + p) (i + 1) (bits + 1 lsl i)
let _ = f 0 0 0 0 |> Printf.printf "%d\n"

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    ll n;
    cin>>n;
    vi v(n+1);
    rep(i,0,n)cin>>v[i+1];
    ordered_set s;
    rep(i,1,n+1)s.insert(i);
    ll ans=0;
    ll cur_max=v[1];
    rep(i,1,n+1)
    {
        if(cur_max>=v[i])
        {
            ans++;
        }
        cur_max=min(cur_max,v[i]);
    }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 14304
var k:Int = Int(readLine()!)!
var c:Int = 1
if k % 2 == 0 || k % 5 == 0 {
  c = -1
} else {
  k = (k % 7 == 0 ? k/7:k)
  var m1:Int = 1
  while m1 % k != 0 {
    let m2 = m1 % k
    m1 = (10*m2 + 1)%k
    c += 1
  }
}
print(c)

Measured memory_bytes: 7716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const int INF = 1<<29;

int H, W;

char field[1005][1005];
int dist[1005][1005];

int d1[4] = {-1, 0, 1, 0};
int d2[4] = {0, 1, 0, -1};

queue<pair<int, int>> q;

void bfs(){
    
    pair<int, int> point;
    int s, t;
    while(!q.empty()){
        point = q.front(); q.pop();
        s = point.first;
        t = point.second;
        for(int i=0; i<4; i++){
            if(field[s+d1[i]][t+d2[i]] == '.' && dist[s+d1[i]][t+d2[i]] > dist[s][t]+1){
                dist[s+d1[i]][t+d2[i]] = dist[s][t]+1;
                q.push({s+d1[i], t+d2[i]});
            } 
        }
    }
}

int main(){
    cin >> H >> W;
    
    vector<pair<int, int>> black;
    for(int i=0; i<1005; i++) for(int j=0; j<1005; j++){
        dist[i][j] = INF;
        field[i][j] = '0';
    }
    
    for(int i=1; i<=H; i++){
        for(int j=1; j<=W; j++){
            char c; cin >> c;
            field[i][j] = c;
            if(c == '#'){
                dist[i][j] = 0;
                q.push({i, j});
            }
        }
    }

    bfs();

    int ans = 0;
    for(int i=1; i<=H; i++){
        for(int j=1; j<=W; j++){
            if(field[i][j] == '#') continue;

            else ans = max(ans, dist[i][j]);
        }
    }

    cout << ans << endl;
}

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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    string a;
    cin >> a;
    for(int i=0;i<(1<<3);i++){
        int total=a[0]-'0';
        for(int j=0;j<3;j++){
            if(i&(1<<j)){
                total+=a[j+1]-'0';
            }else{
                total-=a[j+1]-'0';
            }
        }
        if(total==7){
            cout << a[0];
            for(int j=0;j<3;j++){
                if(i&(1<<j)){
                    cout << '+' << a[j+1];
                }else{
                    cout << '-' << a[j+1];
                }
            }
            cout << "=7" << endl;
            return 0;
        }
    }
    
    return 0;
}











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

int main() {
  int N,K;
  cin>>N>>K;
  int r=1;
  for(int i=0;i<N;i++) {
    if(r<K) r*=2;
    else r+=K;
  }
  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define REP(i,n) for (int i=0;i<(n);i++)

using namespace std;

const int N = 1e7;
int p[N];
void Eratosthenes(){
	fill(p,p + N,1);
	p[0] = p[1] = 0;
	for(int i = 2; i*i <= N; i++)
		if(p[i] == 1)
			for(int j = i*i; j <= N; j+=i)
				p[j] = 0;
}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	Eratosthenes();
	int a;
	while(cin >> a,a){
		int leftp = 0,rightp = 0;
		int i;
		for(i = 0;i <= a;i++){
			if(p[i] == 0)continue;
			leftp = i;
		}
		for(;;i++){
			if(p[i] == 1){
				rightp = i;
				break;
			}
		}
		if(leftp == a)cout << 0 << endl;
		else cout << rightp - leftp << endl;
	}
  return 0;
}

Measured memory_bytes: 42256
mod=10**9+7
s=input()
n=len(s)
dp=[[0]*4 for _ in range(n+1)]
abc="ABC"
dp[n][3]=1
for i in range(n-1,-1,-1):
    for j in range(4):
        if j==3:
            m=0
            if s[i]=="?":
                m=3
            else:
                m=1
            dp[i][j]=(m*dp[i+1][j])%mod
        else:
            m1=0
            m2=0
            if s[i]=="?":
                m1=3
                m2=1
            else:
                m1=1
                if s[i]==abc[j]:
                    m2=1
                else:
                    m2=0
            dp[i][j]=(m1*dp[i+1][j]+m2*dp[i+1][j+1])%mod
print(dp[0][0])


Measured memory_bytes: 54124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    vector<int> a(3);
    rep (i, s.size()) a[s[i] - 'a']++;
    eprintf("%d %d %d\n", a[0], a[1], a[2]);
    if (abs(a[0] - a[1]) <= 1 && abs(a[1] - a[2]) <= 1 && abs(a[2] - a[0]) <= 1) {
        cout << "YES\n";
    } else cout << "NO\n";
    return 0;
}

Measured memory_bytes: 3688
#include<stdio.h>
int main(void){
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a!=1&&b!=1){
		printf("1\n");
	}else if(a!=2&&b!=2){
		printf("2\n");
	}else{
		printf("3\n");
	}
	return 0;
}

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

int main(){
	string s,s1;
	while(cin >> s >> s1){
		int sum = 0;
		for(int i = 0; i < 3; i++)
			if(s[i] == s1[i])
				sum++;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  Select
//
//  Created by ptyuan on 2018/10/17.
//  Copyright © 2018 YY. All rights reserved.
//

#include <iostream>
using namespace std;
int globacount = 0;
void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
    globacount++;
}



void selectionSort(int *array, int n) {
    for (int i = 0; i < n; i++) {
        int min = i;
        for (int j = i + 1; j < n; j++) {
            if (array[j] < array[min]) {
                min = j;
            }
        }
        if (min != i) {
            swap(&array[min], &array[i]);
        }
        
    }
}

int main(int argc, const char * argv[]) {
    int n = 0;
    cin >> n;
    int array[100];
    for (int i = 0; i < n; i++) {
        cin >> array[i];
    }
    
    selectionSort(array, n);
    for (int i = 0; i < n; i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << array[i];
        
    }
    cout << endl << globacount << endl;
    
    
    return 0;
}



Measured memory_bytes: 3132
_, *hs = map(int, open(0).read().split())
cou = 0
tmp = 0
naw = hs[0]
for next in hs[1:]:
  if naw < next:
    cou = max(cou, tmp)
    tmp = 0
  else:
    tmp += 1
  naw = next
cou = max(cou, tmp)
print(cou)

Measured memory_bytes: 14092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n , x) for (int i = (int)(x); i < (int)(n); ++i)
#define repB(i, n) for (int i = n; i >= 1; --i)
#define repBX(i, n , x) for (int i = (int)(n); i >= int(X); --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    string S,T;
    cin >> S >> T;
    cout << T << S << endl;
    
    return 0;
}

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

double pi = 3.141592653589;
int main(void) 
{
    int a,b,ans;
    char op;
    while(1) {
        cin >> a >> op >> b;
        if(op == '?') {
            return 0;
        }
        switch(op) {
            case '+':
            ans = a + b;
            break;
            case '-':
            ans = a - b;
            break;
            case '*':
            ans = a * b;
            break;
            case '/':
            ans = a / b;
            break;
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3080
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  l,r,a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,t:Integer;
  //l:array of Integer;
  s,s123,s1,s2,s3:string;
  tf:Boolean;
  //nyu:TStringList;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(n);

    sum:=0;
    for i := 0 to n - 1 do begin
      Read(l);
      Readln(r);
      sum:=sum+r-l+1;
    end;
    Writeln(sum);
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 128
#include <cstdio>
#include <vector>
using namespace std;
int a[60], b[60];
long long can[60][60];
vector<int> v[60];
long long ans = 0;
int go(int l, int n) {
	int s = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < v[i].size(); j++) {
			if (v[i][j] == b[i]) {
				s++;
				break;
			}
		}
	}
	if (s == n) return 1;
	for (int i = 1; i < l; i++) {
		long long ma = (1ll << (i+1)) - 1;
		int f = 1;
		for (int j = 0; j < n; j++) {
			int g = 0;
			for (int k = 0; k < v[j].size(); k++) {
				if (can[v[j][k]][b[j]] & ma) {
					g = 1;
				}
			}
			f &= g;
		}
		if (!f) {
			continue;
		}
		for (int j = 0; j < n; j++) {
			vector<int> w;
			long long bb = 0;
			for (int k = 0; k < v[j].size(); k++) {
				if (v[j][k] % i >= b[j]) {
					bb |= 1ll << (v[j][k] % i);
				}
				bb |= 1ll << v[j][k];
			}
			for (int k = 0; k <= 50; k++) {
				if (bb >> k & 1) {
					w.push_back(k);
				}
			}
			v[j] = w;
		}
		ans |= 1ll << i;
		return go(i, n);
	}
	return 0;
}
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		v[i].push_back(a[i]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &b[i]);
	}
	for (int i = 0; i <= 50; i++) {
		can[i][i] = 1;
		for (int j = 0; j <= i; j++) {
			for (int k = 1; k < 50; k++) {
				if (can[i][j] || can[i%k][j]) {
					can[i][j] |= 1ll << k;
				}
			}
		}
	}
	if (go(50, n)) {
		printf("%lld\n", ans);
	} else {
		puts("-1");
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
int main(){
	string str;
	string ans[10];
	ans[0]="black";ans[1]="blue";ans[2]="lime";ans[3]="aqua";ans[4]="red";
	ans[5]="fuchsia";ans[6]="yellow";ans[7]="white";
	while(true){
		cin >> str;
		if(str[0] == '0')break;
		int r[]={0,0,0,0,255,255,255,255};
		int g[]={0,0,255,255,0,0,255,255};
		int b[]={0,255,0,255,0,255,0,255};
		char ch[]={"0123456789abcdef"};
		int best = -1;
		int x=10000000;
		int R=0,G=0,B=0;
		
		for(int i = 0; i < 16; i++){
			if(str[1] == ch[i])R += i*16;
			if(str[2] == ch[i])R += i;
		}
		for(int i = 0; i < 16; i++){
			if(str[3] == ch[i])G += i*16;
			if(str[4] == ch[i])G += i;
		}
		for(int i = 0; i < 16; i++){
			if(str[5] == ch[i])B += i*16;
			if(str[6] == ch[i])B += i;
		}
		//cout << R << ":"<< G <<":"<< B << endl;
		for(int i = 0; i < 8; i++){
			int k = (R-r[i])*(R-r[i])+(G-g[i])*(G-g[i])+(B-b[i])*(B-b[i]);
			if(k < x){
				best = i;
				x = k;
			}
		}
		cout << ans[best] << endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include <iostream>

using namespace std;

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

	int money = 100000;

	for (int i = 0; i < n; ++i) {
		int next = money * 105 / 100;
		if (next % 1000) next += 1000;
		money = next / 1000 * 1000;
	}

	cout << money << endl;
}

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str[] = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);

		str = br.readLine().split(" ");
		int h[] = new int[n];

		int max = 0;
		for (int i = 0; i < n; i++) {
			h[i] = Integer.parseInt(str[i]);
			max = Math.max(h[i], max);
		}

		if (n == 1)
			System.out.println("Yes");
		else if (max - 2 >= h[n - 1])
			System.out.println("No");
		else {
			for (int i = n - 1; i > 0; i--) {
				if (h[i - 1] - h[i] >= 2) {
					System.out.println("No");
					System.exit(0);
				} else if (h[i - 1] > h[i]) {
					h[i - 1]--;
				}
			}
			System.out.println("Yes");
		}
	}
}

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

typedef pair<int,int> pi;
typedef vector<int> vi;
 
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define pb push_back

template<typename T> void max_self(T &a, T b) { a = max(a,b); return;}
template<typename T> void min_self(T &a, T b) { a = min(a,b); return;}
 
const int nax = 1e5 + 5;
const int mod = 1e9 + 7;

int solve(int a,int b,int c){
	
	a = a % c;	
	if(b == 0) return 1;
	else if((b % 2) == 0) return solve((a * a) % c,b / 2,c) % c;
	else return (a * solve((a * a) % c,b / 2,c) % c) % c;
}

int n;
vector<int> adj[nax];

pair<int,int> dfs(int index,int par){
	
	if(index != 1 && adj[index].size() == 1){
		pair<int,int> ans;
		ans.first = 2;
		ans.second = 1;
		return ans;
	}
	
	pair<int,int> ans = {1,1};
	for(auto u : adj[index]){
		if(u == par) continue;
		pair<int,int> temp = dfs(u,index);
		ans.first = (ans.first * temp.first) % mod;
		ans.second = (ans.second * temp.second) % mod;
	}
	
	ans.first = (ans.first + ans.second) % mod;
	ans.second = (ans.first - ans.second + mod) % mod;
	return ans;
}

signed main(){
	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int t = 1;
	//cin >> t;
	while(t--){
		cin >> n;
			
		int x,y;
		for(int i = 0; i < n - 1; ++i){
			cin >> x >> y;
			adj[x].push_back(y);
			adj[y].push_back(x);
		}
		
		if(n == 1) cout << "2";
		else cout << dfs(1,-1).first;	
	}
	
	return 0;
}


Measured memory_bytes: 15988
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
using namespace std;
 
int main() {
  ll A, B, C, D, E, F, G;
  cin >> A >> B >> C >> D;
  
  if(C >= D) {
    E = C;
    F = D;
  }
  else {
    F = C;
    E = D;
  }
  
  ll tmp = 0;
  
  while(1){
    if(F % E == 0) break;
    else {
      tmp = F;
      F = E;
      E = tmp % E;
    }
  }
  
  G = C * D / E;
  
  cout << B - A + 1 - ((B / C - (A - 1) / C) + (B / D - (A - 1) / D) - (B / G - (A - 1) / G)) << endl;
  
}

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

using namespace std;

//#define FILE_IO

const int mod = 1e9 + 7;
int N, C;
int A[405], B[405];
int dp[405][405];
int pw[405][405];
int sum[405][405];

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d", &N, &C);
    for(int i = 1; i <= N; i++)
        scanf("%d", &A[i]);
    for(int i = 1; i <= N; i++)
        scanf("%d", &B[i]);

    for(int i = 1; i <= 400; i++)
    {
        pw[i][0] = 1;
        sum[i][0] = (1 + sum[i - 1][0]) % mod;
        for(int j = 1; j <= 400; j++)
        {
            pw[i][j] = (1LL * pw[i][j - 1] * i) % mod;
            sum[i][j] = (sum[i - 1][j] + pw[i][j]) % mod;
        }
    }

    dp[0][0] = 1;
    for(int i = 1; i <= N; i++)
        for(int j = 0; j <= C; j++)
            for(int k = 0; k <= j; k++)
            {
                int prd = ( sum[ B[i] ][k] - sum[ A[i] - 1 ][k] + mod ) % mod;
                int pans = (1LL * prd * dp[i - 1][j - k]) % mod;
                dp[i][j] = (dp[i][j] + pans) % mod;
            }

    printf("%d\n", dp[N][C]);

    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define IOS   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp    make_pair
#define pb    push_back
#define F     first
#define pi 	  3.14159265358979323846
#define S     second
#define ll    long long
#define ld    long double
#define sz(s) (ll)s.size() 
#define vl    vector < ll >
#define pll   pair < ll, ll >
#define ml    map < ll, ll >
#define mod   1000000007
#define qe	  998244353
#define MAXN  100005
#define mx    10000005
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define inv(i,a,b)  for(i=a;i>=b;i--)
#define all(a)  (a).begin(),(a).end()
using namespace std;
int main(){
//	#ifndef ONLINE_JUDGE
//    if (fopen("input.txt", "r"))
//    {
//        freopen("input.txt", "r", stdin);
//        freopen("output.txt", "w", stdout);
//    }
//	#endif
	IOS;
	ll t,n,l,l1;
	ll i,j,m,mn,q,d,x,y,sum=0,r,p,k,c;
	string s,s1;
//	cin>>t;
//	while(t--){
    cin>>n>>p;
	ll a[n],ans=0;
//	for(i=0;i<n;i++)cin>>a[i];
	ll w,b;
	vl dp(p+1,0);
//	dp[0]=0;
	rep(i,0,n){
		cin>>w>>b;
		inv(j,p-w+1,0)dp[j+w]=max(dp[j+w],dp[j]+b);
	}
	rep(i,0,p+1)ans=max(ans,dp[i]);
	cout<<ans;
//	}
}


Measured memory_bytes: 3976
//Heaplax
//别让自己后悔
#include<bits/stdc++.h>
#define N 100001
#define int long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int sum,w;
int n,a[N];
main()
{
	re(n);
	for(int i=1;i<=n;++i)
		re(a[i]),sum+=a[i];
	w=n*(n+1ll)/2;
	if(sum%w)
	{
		puts("NO");
		return 0;
	}
	sum/=w;
	a[0]=a[n];
	for(int i=n;i;--i)a[i]-=a[i-1];
	for(int i=1;i<=n;++i)
	{
		int x=sum-a[i];
		if(x<0 || x%n)
		{
			puts("NO");
			return 0;
		}
	}
	puts("YES");
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, m;
vi adj[N];
int vis[N];

void input()
{
	cin >> n >> m;
	//REMEMBER: update N
	FOR (i, 1, m)
	{
		readb(x, y);
		adj[x].pb(y);
		adj[y].pb(x);
	}
}

void bfs ()
{
    queue<int> q;
    vector<bool> used(n + 1);
    vector<int> p(n + 1);
    int s = 1;
    
    q.push(s);
    used[s] = true;
    p[s] = -1;
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int u : adj[v]) {
            if (!used[u]) {
                used[u] = true;
                q.push(u);
                p[u] = v;
            }
        }
    }
    
    cout << "Yes\n";
    FOR (i, 2, n) cout << p[i] << endl;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
	input();
	bfs();
}
















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


class Dice{
	int dn[6];
	int up, front;
	string qu;

public:
	Dice(int d1, int d2, int d3, int d4, int d5, int d6){
		dn[0] = d1;
		dn[1] = d2;
		dn[2] = d3;
		dn[3] = d4;
		dn[4] = d5;
		dn[5] = d6;
	}

	void Result(string m){
		int w;
		qu = m;

		for (int i = 0; i < qu.size(); i++){
			switch (qu[i]){
			case 'E':
				w = dn[0];
				dn[0] = dn[3];
				dn[3] = dn[5];
				dn[5] = dn[2];
				dn[2] = w;
				break;

			case 'N':
				w = dn[5];
				dn[5] = dn[4];
				dn[4] = dn[0];
				dn[0] = dn[1];
				dn[1] = w;
				break;

			case 'S':
				w = dn[0];
				dn[0] = dn[4];
				dn[4] = dn[5];
				dn[5] = dn[1];
				dn[1] = w;
				break;

			case 'W':
				w = dn[0];
				dn[0] = dn[2];
				dn[2] = dn[5];
				dn[5] = dn[3];
				dn[3] = w;
				break;
			}
		}
//		return dn[0];
	}

	string Dice2(int a,int b){
		up = a;
		front = b;
		string qq;

		if (up == dn[0]){
			if (front == dn[2]){
				qq = "WSE";
			}
			else if (front == dn[3]){
				qq = "ESW";
			}
			else if (front == dn[4]){
				qq = "WSSE";
			}
		}
		else if (up == dn[1]){
			if (front == dn[0]){
				qq = "SEE";
			}
			else if (front == dn[2]){
				qq = "WSEE";
			}
			else if (front == dn[3]){
				qq = "ESWW";
			}
			else if (front == dn[5]){
				qq = "N";
			}
		}
		else if (up == dn[2]){
			if (front == dn[0]){
				qq = "SW";
			}
			else if (front == dn[1]){
				qq = "W";
			}
			else if (front == dn[4]){
				qq = "SSW";
			}
			else if (front == dn[5]){
				qq = "NW";
			}
		}
		else if (up == dn[3]){
			if (front == dn[0]){
				qq = "SE";
			}
			else if (front == dn[1]){
				qq = "E";
			}
			else if (front == dn[4]){
				qq = "SSE";
			}
			else if (front == dn[5]){
				qq = "NE";
			}
		}
		else if (up == dn[4]){
			if (front == dn[0]){
				qq = "S";
			}
			else if (front == dn[2]){
				qq = "WS";
			}
			else if (front == dn[3]){
				qq = "ES";
			}
			else if (front == dn[5]){
				qq = "WWS";
			}
		}
		else if (up == dn[5]){
			if (front == dn[1]){
				qq = "WW";
			}
			else if (front == dn[2]){
				qq = "SWS";
			}
			else if (front == dn[3]){
				qq = "ESE";
			}
			else if (front == dn[4]){
				qq = "NN";
			}
		}

		return qq;

	}

	int get_right(){
		return dn[2];
	}
};

int main()
{
	int dnum[6];
	int qno, ue, mae;
	string q;

	for (int i = 0; i < 6; i++){
		cin >> dnum[i];
	}

	Dice d(dnum[0], dnum[1], dnum[2], dnum[3], dnum[4], dnum[5]);
	
	cin >> qno;
	for (int i = 0; i < qno; i++){
		cin >> ue >> mae;
		q = d.Dice2(ue, mae);
		d.Result(q);
		cout << d.get_right() << endl;
	}

	return 0;
}



Measured memory_bytes: 3216
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
ll a[maxn],b[maxn];
ll gcd(ll x,ll y)
{
	return y?gcd(y,x%y):x;
}
int main()
{
	ll n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[i]=a[i]/2;
	}
	//ll ans=a[1],bans=b[1];
	ll lcm,blcm;
	lcm=a[1];
	blcm=b[1];   
	for(int i=2;i<=n;i++)
	{
		lcm=lcm*a[i]/gcd(lcm,a[i]);
		//ans=lcm;
		blcm=blcm*b[i]/gcd(blcm,b[i]);
		if(blcm>m)
		{
			cout<<0<<"\n";
			return 0;
		}
	}
	for(int i=1;i<=n;i++)
	{
		ll cnt=blcm/b[i];
		if(cnt%2==0)
		{
			cout<<0<<"\n";
			return 0;
		}
	}
	//ll ans=m/blcm;
	//if(ans&1) ans=ans/2+1;
	//else ans=ans/2;
	//if(blcm>m) cout<<0<<"\n";
	//else 
	cout<<(m-blcm)/lcm+1<<"\n";
	//cout<<ans<<"\n";
	return 0; 
}

Measured memory_bytes: 4744
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

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

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

void solve() {
  ini(H, W);
  vector<string> a(H);
  rep(i, H) cin >> a[i];

  rep(i, W + 2) cout << "#";
  out();
  rep(i, H) out("#" + a[i] + "#");
  rep(i, W + 2) cout << "#";
  out();
}


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

int main(){
  const string c = "CODEFESTIVAL2016";
  string s;
  cin >> s;
  int cnt = 0;
  for(int i = 0; i < s.length(); i++){
    if(c[i] != s[i])
      cnt++;
  }

  cout << cnt << endl;
}


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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll gcd(ll a, ll b){
  return a == 0 ? b : gcd(b % a, a);
}

int main() {
  ll a, b;
  while(cin >> a >> b) {
    ll g = gcd(a, b);
    ll l = a * b / g;
    printf("%lld %lld\n", g, l);
  }
}

Measured memory_bytes: 3096
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 21 21:41:43 2018
ABC103D
@author: maezawa
"""

n, m = list(map(int, input().split()))

w = []
cnt = 1

for i in range(m):
    ai, bi = list(map(int, input().split()))
    w.append([ai, bi])

w.sort(key = lambda x: x[1])
#print(*w)

cnt = 1
icut = w[0][1]-1 
for bs in w:
    if bs[0] > icut:
        cnt += 1
        icut = bs[1]-1

print(cnt)




Measured memory_bytes: 21788
#include <bits/stdc++.h>
namespace my_std {
using namespace std;
#define reg register
#define Rint register int
#define FOR(i, a, b) for (register int i = (a), ed_##i = (b); i <= ed_##i; ++i)
#define ROF(i, a, b) for (register int i = (a), ed_##i = (b); i >= ed_##i; --i)
#define FORit(templ, arr, i, a, b) \
for (register templ *i = (arr) + (a), *ed_##i = (arr) + (b) + 1; i != ed_##i; ++i)
#define ROFit(templ, arr, i, a, b) \
for (register templ *i = (arr) + (a), *ed_##i = (arr) + (b)-1; i != ed_##i; --i)
#define GO(x, p, e, i, v) for (register int i = p[x].head, v; i; i = e[i].link)
#define MEM(x, v) memset(x, v, sizeof(x))
#define pb push_back
typedef long long i64;
#define Templ(T) template <typename T>
inline int read() {
    reg int ans = 0, f = 1;
    reg char c = getchar();
    while (!isdigit(c)) f ^= (c == '-'), c = getchar();
    for (; isdigit(c); c = getchar()) ans = (ans << 1) + (ans << 3) + (c ^ 48);
    return f ? ans : -ans;
}
Templ(_Tp) inline int chkmin(_Tp &x, _Tp y) { return x > y ? x = y, 1 : 0; }
Templ(_Tp) inline int chkmax(_Tp &x, _Tp y) { return x < y ? x = y, 1 : 0; }
#define mod 998244353
inline void inc(int &x, const int &y) { x += y; if (x >= mod) x -= mod; }
inline void dec(int &x, const int &y) { x -= y; if (x < 0) x += mod; }
inline void qmo(int &x){ x += (x >> 31) & mod; }
} // namespace my_std
using namespace my_std;

#define N 100010
#define BN 610
const i64 V = i64(1e18) % mod;

int n;
struct Graph{
    vector<int> E[N];
    int sg[N], n, m, val[BN], mxsg;
    inline void build(){
        n = ::n, m = read();
        Rint u, v;
        FOR(i, 1, m){
            u = read(), v = read();
            if(u > v) u ^= v ^= u ^= v;
            E[u].pb(v);
        }
    }
    inline void topo(){
        int *c = new int[BN];
        mxsg = 0;
        memset(c, 0, sizeof(int) * BN);
        ROF(u, n, 1){
            for(Rint v: E[u]) c[sg[v]] = 1;
            Rint t(0);
            while(c[t]) ++t;
            chkmax(mxsg, sg[u] = t);
            for(Rint v: E[u]) c[sg[v]] = 0;
        }
        delete c;
        Rint x(V);
        FOR(i, 1, n){
            qmo(val[sg[i]] += x - mod);
            x = V * x % mod;
        }
    }
}G[3];

int main() {
    n = read();
    FOR(i, 0, 2) G[i].build(), G[i].topo();
    Rint ans(0);
    FOR(i, 0, G[0].mxsg) FOR(j, 0, G[1].mxsg){
        qmo(ans += ((i64)G[0].val[i] * G[1].val[j] % mod
            * G[2].val[i ^ j] % mod) - mod);
    }
    printf("%d", ans);
    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int main() {
    string s; cin >> s;
    vector<ll> alph(26, 0);
    rep(i, s.size()) alph[s[i]-'a'] += 1;

    ll ans = 1 + (s.size() * (s.size()-1))/2 ;

    rep(i, 26) {
        ans -= (alph[i] * (alph[i]-1))/2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define count_ones __builtin_popcountl
#define all(a) a.begin(), a.end()
#define gcd(a, b) __gcd(a, b)
#define lca(a, b) a / __gcd(a, b) * b
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    
    ll n;
    cin>>n;
    cout<<n*n*n;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

class BipartiteMatching {
private:
  int n;
  vector<vector<int>> graph;
  vector<int> match;
  vector<bool> used;
  bool dfs(int v){
    used[v] = true;
    for(int u : graph[v]){
      int w = match[u];
      if(w<0 || (!used[w] && dfs(w))){
        match[v] = u;
        match[u] = v;
        return true;
      }
    }
    return false;
  }
public:
  BipartiteMatching(int _n) : n(_n){
    graph.resize(n);
    match.resize(n);
    used.resize(n);
  }
  void add_edge(int u, int v){ // 0-indexed
    graph[u].pb(v);
    graph[v].pb(u);
  }
  int matching(){ // matching size
    int res = 0;
    fill(begin(match), end(match), -1);
    rep(v, n){
      if(match[v] < 0){
        fill(begin(used), end(used), false);
        if(dfs(v)) res++;
      }
    }
    return res;
  }
};

int main(){
  int n,a,b;
  cin>>n>>a>>b;

  vector<int> c(n);
  vector<bool> used(n, false);
  rep(i,n){
    int x,y;
    cin>>x>>y;
    c[i] = x-y;
  }

  auto ok = [&](int x){
    x = abs(x);
    return x<=a || (b<=x && x<=2*a);
  };

  int ans = 0;
  rep(i,n) if(ok(c[i])) {
    ans++;
    used[i] = true;
  }

  BipartiteMatching match(n);
  rep(i,n) if(!used[i]) rep(j,i+1,n) if(!used[j]){
    if(ok(c[i]+c[j])) match.add_edge(i,j);
  }
// dbg(ans);
  cout << ans + match.matching() << endl;

  return 0;
}



Measured memory_bytes: 3312
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pb push_back
#define fastcin() ios_base::sync_with_stdio(false); cin.tie(0)
using namespace std;
typedef pair<int, int> ii;

int Ceil(int a, int b) { return (a + b - 1) / b; }

int m;
signed main()
{
	int s = 0, dig = 0; 
	cin >> m; 
	for(int i = 1; i <= m; i++) 
	{
		int d, c; cin >> d >> c; 
		dig += c;
		s += c * d; 
	}
	cout << (dig - 1) + Ceil(s-9, 9); 
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
 
using namespace std;

char str[10];

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    ll cnt[10][10]={0};
    int i;
    for(i=1; i<=n; i++) {
        sprintf(str, "%d", i);
        int len1=strlen(str);
        int t0=str[0]-'0';
        int t1=str[len1-1]-'0';
        cnt[t0][t1]++;
    }
    ll ans=0;
    int j;
    for(i=1; i<=9; i++) {
        for(j=1; j<=9; j++) {
            ans+=cnt[i][j]*cnt[j][i];
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>

//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define All(a) (a).begin(),(a).end()

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

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

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}


int main()
{
	int n,h[100000];
	int pre=INF+1;
	cin >> n;
	REP(i, n) {
		cin >> h[i];
	}
	int ans = 0, cnt = 0;
	pre = h[0];
	REPS(i, n-1) {
		if (h[i] <= pre) {
			cnt++;
		}
		else {
			chmax(ans, cnt);
			cnt = 0;
		}
		pre = h[i];
		if (i == n - 1)chmax(ans, cnt);
		//cout <<i<<" : "<< ans<< "  " << cnt<<endl;
	}
	
	cout << ans;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
	int R;
    cin >> R;
    float R_ = (float)R;
    float ans;
    ans = 2 * R_ * M_PI;

	cout << ans << endl; 

}

Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct P {
  int H, W;
  P(int w, int h) : H(h), W(w) {}
  P(){}

  bool operator < (const P &a) const
  {
    return H*W < a.W*a.H;
  }
};

int main()
{
  int N, W, H;
  while (cin>>N>>W>>H, N||W||H) {
    vector<P> piece;
    piece.emplace_back(W, H);
    
    for (int i=0; i<N; i++) {
      int p, s; cin>>p>>s;
      
      p--; 
      int PW = piece[p].W, PH = piece[p].H;
      s %= 2*(PW+PH);

      if (0 < s && s < PW) {
        piece.emplace_back(PW-s, PH);
        piece.emplace_back(s, PH);
      } else if (PW < s && s < PW+PH) {
        s -= PW;
        piece.emplace_back(PW, PH-s);
        piece.emplace_back(PW, s);
      } else if (PW+PH < s && s < 2*PW+PH) {
        s-= PW+PH;
        piece.emplace_back(PW-s, PH);
        piece.emplace_back(s, PH);
      } else {
        s -= 2*PW+PH;
        piece.emplace_back(PW, PH-s);
        piece.emplace_back(PW, s);
      }
      
      sort(piece.end()-2, piece.end());
      piece.erase(piece.begin()+p);
    }
    
    sort(piece.begin(), piece.end());
    for (int i=0; i<piece.size(); i++) {
      if (i>0) cout << " ";
      cout << piece[i].W*piece[i].H;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1200