akhauriyash/Code-Regression huggingface dataset:
import sys
import math

A,B = map(int,input().split())
# 四捨五入
if A * (100/8) - int(A * (100/8)) >=0.5:
    target_8  = math.floor(A * (100/8)) + 1
else:
    target_8  = math.floor(A * (100/8))

# 四捨五入
if A * (100/10) - int(A * (100/10)) >=0.5:
    target_10 = math.floor(B * (100/10)) + 1
else:
    target_10 = math.floor(B * (100/10))

if math.floor(target_8*0.1) == B :
    print(target_8)
    sys.exit()
elif math.floor(target_10*0.08) == A :
    print(target_10)
    sys.exit()
else:
    print('-1')
    sys.exit()

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
    int n, p;
    string s;
    cin >> n >> p >> s;

    long long res = 0;
    if (p == 2 || p == 5) {
        for (int i = 0; i < n; i++) {
            if ((s[i] - '0') % p == 0) {
                res += i + 1;
            }
        }
    } else {
        map<int, int> m;
        m[0] = 1;
        for (int i = n - 1, j = 1, k = 0; i >= 0; i--, j *= 10, j %= p) {
            k = ((s[i] - '0') * j + k) % p;
            res += m[k];
            m[k]++;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 900
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(void) {
	int i;
	int H, W;
	string tmp;
	vector<string> a;
	cin >> H >> W;
	for (i = 0; i < H; i++) {
		cin >> tmp;
		a.push_back(tmp);
	}
	cout << '#';
	for (i = 0; i < W; i++) {
		cout << '#';
	}
	cout << '#' << endl;
	for (i = 0; i < H; i++) {
		cout << '#';
		cout << a[i];
		cout << '#' << endl;
	}
	cout << '#';
	for (i = 0; i < W; i++) {
		cout << '#';
	}
	cout << '#';
	return 0;
}






Measured memory_bytes: 256
buttons = input().split(' ')
but1 = 0
but2 = 0
a = int(buttons[0])
b = int(buttons[1])

if a >= b:
    but2 = a - 1
else:
    but2 = b - 1


if a > b:
    print (a + but2) 
elif a == b:
    print(a + but2 + 1)
else:
    print(b + but2)

Measured memory_bytes: 3064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	int n,k;
	cin>>n>>k;
	
	vector<int> vec;
	
	for(int i = 0;i<n;i++)
	{
		int x;s(x);
		vec.push_back(x);		
	}
	
	for(int i = k;i<n;i++)
	{
		if(vec[i] > vec[i-k]) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;		
	}

	return 0;
}

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

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; }

using ll = long long;
using P = pair<ll,ll>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

ll dp[100005][2];

int main(){
    string S;
    cin>>S;
    int N = S.size();
    dp[0][0] = 0;
    dp[0][1] = 1;
    for(int i = 1; i <= N; i++){
        if(S[i-1] == '0'){
            dp[i][0] = (dp[i-1][0] * 3)%mod;
            dp[i][1] = dp[i-1][1];
        }
        else {
            dp[i][0] = (dp[i-1][0]*3 + dp[i-1][1])%mod;
            dp[i][1] = (dp[i-1][1] * 2)%mod;
        }
    }
    cout<<(dp[N][0]+dp[N][1])%mod<<endl;
}


Measured memory_bytes: 5288
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.PriorityQueue;

class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
//		System.out.println(" ");
	    InputStreamReader input = new InputStreamReader (System. in);
	    BufferedReader buffer = new BufferedReader(input);

	    PriorityQueue<Integer> quere = new PriorityQueue<Integer> (Collections.reverseOrder());
	    while(true){
		    String read = buffer.readLine();
		    String[] scan = read.split(" ");
	    	if(scan[0].equals("insert")){
	    		quere.add(Integer.parseInt(scan[1]));
	    	}
	    	if(scan[0].equals("extract")){
	    		System.out.println(quere.poll());
	    	}
	    	if(scan[0].equals("end")){
	    		break;
	    	}
	    }
	}
}

Measured memory_bytes: 231956
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String a=sc.next();
		String b=sc.next();
		int T = 0;
		for(int i=0;i<3;i++){
			if(a.charAt(i)==b.charAt(i)){
					T++;
			}
		}
		System.out.println(T);
	}
}


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

int main() {
  int a;
  int b;
  int c;
  int d = 0;
  
  cin >> a;
  cin >> b;
  cin >> c;
  d = 0;
  
  for (int i = a; i <= b; i++) {
    int e = i;
    if (e%c == 0) {
      d++; 
    }
  }
  
  cout << d;
   
  return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int H = 0;
		for(int a=1;a>0;a++){
			H = scan.nextInt();
			if(H != 0){
				System.out.println("Case "+a+": "+H);
			}else{
				break;
			}
		}
	}
}

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

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

    ll n;

    cin >> n;

    ll arr[n];

    for(ll i=0; i<n; i++)
    {
        cin >> arr[i];
    }

    ll sum = 0;

    for(ll i=0; i<n-1; i++)
    {
        if(arr[i] > arr[i+1])
        {
            sum += abs(arr[i] - arr[i+1]);

            //cout << abs(arr[i] - arr[i+1]) << " ";

            arr[i+1] += abs(arr[i] - arr[i+1]);
        }
    }

    cout << sum;
}


Measured memory_bytes: 5156
import * as fs from 'fs';

namespace AtCoder {
    export interface Paramable {
        readonly args: string[][];
    }

    export interface Task {
        main(this: Task): void;
    }
}

namespace AtCoder.abc001 {
    export class TaskA implements AtCoder.Task, AtCoder.Paramable {
        public constructor(public readonly args: string[][]) {
        }

        public main(this: TaskA): void {
            const n:number = +this.args[0][0];
            const a:number = +this.args[1][0];
            console.log(Math.pow(n,2) - a);
        }
    }

    const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(r => r.split(' '));
    const task: AtCoder.Task = new TaskA(args);
    task.main();
}



Measured memory_bytes: 7372
//
//  pertition.cpp
//  AtCoder
//
//  Created by A on 2018/06/01.
//  Copyright © 2018年 A. All rights reserved.
//

#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r){
    int x, i, j, t;
    x = A[r];
    i = p - 1;
    for(j=p; j<r; j++){
        if(A[j] <= x){
            i++;
            t = A[i]; A[i] = A[j]; A[j] = t;
        }
    }
    t = A[i+1]; A[i+1] = A[r]; A[r] = t;
    return i+1;
}

int main(){
    int i, q;
    
    scanf("%d", &n);
    for(i=0; i<n; i++) scanf("%d", &A[i]);
    
    q = partition(0, n-1);
    
    for(i=0; i<n; i++){
        if(i) printf(" ");
        if(i==q) printf("[");
        printf("%d", A[i]);
        if(i==q) printf("]");
    }
    printf("\n");
    
    return 0;
}



Measured memory_bytes: 3100
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define itn int
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=2e9;
const ll lnf=9e18;

pll qr(ll a,ll b){
  if(a>=0) return pll(a/b,a%b);
  if(a%b==0) return pll(a/b,0);
  if(b>0) return pll(a/b-1,a-(a/b-1)*b);
  else return pll(a/b+1,a-(a/b+1)*b);
}

int main(){
  itn n; cin >> n;
  string s;
  while(1){
    ll q,r;
    tie(q,r)=qr(n,(-2));
    //cout << q << " " << r << endl;
    s=to_string(r)+s;
    n=q;
    if(n==0) break;
  }
  cout << s << endl;
}

Measured memory_bytes: 3648
// AOJ 0648 Art Exhibition
// 2018.3.29 bal4u

#include <stdio.h>
#include <stdlib.h>

//#define getchar_unlocked()  getchar()
int in()	/* 整数値の入力 */
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

long long big()		/* long long 整数値の入力 */
{
	long long n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

#define INF 0x1010101010101010LL
typedef struct { long long a; int b; } T;
T tbl[500002];
long long s[500002];

int cmp(T *a, T *b) {
	if (a->a == b->a) return a->b - b->b;
	if (a->a < b->a) return -1;
	return 1;
}

int main()
{
	int N, i;
	long long t, min, max;

	N = in();
	for (i = 1; i <= N; i++) tbl[i].a = big(), tbl[i].b = in();
	qsort(tbl+1, N, sizeof(T), cmp);

	min = INF, max = -INF;
	for (i = 1; i <= N; i++) {
		t = s[i-1] - tbl[i].a;
		if (t < min) min = t;
		s[i] = s[i-1] + tbl[i].b;
		t = s[i] - tbl[i].a - min;
		if (t > max) max = t;
	}
	printf("%lld\n", max);
	return 0;
}



Measured memory_bytes: 17144
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)ull
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("NO"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

// Union find
struct uf {
  vi d;
  uf(){}
  uf(int mx):d(mx,-1){}
  int root(int x) {
    if(d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if(x == y) return false;
    if(d[x] > d[y]) swap(x,y);
    d[x] += d[y]; d[y] = x;
    return true;
  }
  int size(int x) { return -d[root(x)];}
};
//



int main() {
  int n, h;
  scanf("%d",&n);
  scanf("%d",&h);
  h += 3;

  int m = h*2;
  uf t(m);
  vi deg(m), used(m);
  rep(i,n) {
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    int u = 0, v = 0;
    if (c == 0) u = a;
    else u = h+c;
    if (d == 0) v = h+b;
    else v = d;
    deg[u]++; deg[v]--;
    used[u] = used[v] = 1;
    t.unite(u,v);
  }
  rep(i,h) if (deg[i] < 0) dame;
  rep(i,h) if (deg[h+i] > 0) dame;

  vi ok(m);
  rep(i,m) if (used[i]) {
    if (deg[i]) ok[t.root(i)] = INF; else ok[t.root(i)]--;
  }
  rep(i,m) if (ok[i] < 0) dame;
  puts("YES");
  return 0;
}






















Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

using namespace std;

int N;
long long int a[200005], S[200005];

int main(void) {

	cin >> N;

	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}

	for (int i = 1; i <= N; i++) {
		S[i] = S[i - 1] + a[i];
	}
	long long int ans = 1000000000000000;
	long long int tmp;
	for (int i = 1; i <= N - 1; i++) {
		tmp = abs(S[i] - (S[N] - S[i]));
		ans = min(ans, tmp);
	}

	cout << ans << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) vc<vc<T>> xs(n, vc<T>(m)); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n, m);
    vc<int> wa(n+1);
    vc<bool> ac(n+1);
    Rep(m){
        Cin(int, p);
        Cin(string, s);
        if(ac[p]) continue;

        if(s == "AC") ac[p] = true;
        else wa[p] ++;
    }
    
    int acs = 0, was = 0;
    for(int p = 1; p <= n; p ++){
        if(ac[p]) acs ++, was += wa[p];
    }
    Cout(acs, " ", was);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
double dp[3001][3001];
signed main(){
    int n;cin >> n;
    vector<double> a(n);
    rep(i,n)cin >> a[i];
    dp[0][0] = 1;
    rep(i,n)rep(j,n+1){
        dp[i+1][j+1] += dp[i][j]*a[i];
        dp[i+1][j] += dp[i][j]*(1-a[i]);
    }
    double ret = 0;
    rep(i,n+1){
        if(i > n-i)ret += dp[n][i];
    }
    printf("%.12lf\n",ret);

    return 0;
}

Measured memory_bytes: 74060
x,n = map(int,input().split())

if n==0:
  print(x)
  
else:
  a = list(map(int,input().split()))
  if x not in a:
    print(x)
  else:
    for i in range(200):
      if x-i not in a:
        print(x-i)
        break
      if x+i not in a:
        print(x+i)
        break
        


Measured memory_bytes: 9124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int[] nums = new int[5];

		for (int i=0; i<5; i++) {
			int c = sc.nextInt();
			nums[i] = c;
		}


		int index=1;
		for (int i=0; i<5; i++) {
			if (nums[i]==0) {
				index = i+1;
				break;
			}
		}
		System.out.println(index);
	}

}

Measured memory_bytes: 26880
n = int(input())
qs1 = list(map(int,input().split(" ")))
qs2 = list(map(int,input().split(" ")))
qs2.reverse()
ans = 1
MOD = 10** 9 + 7
num1 = 0
num2  = 0
qss = [[],[]]
for i,qs in enumerate([qs1,qs2]):
    qss[i].append((qs[0], 1))
    for t1,t2 in zip(qs[0:n-1],qs[1:n]):
        if t1 >t2:
            ans *= 0
        elif t1 == t2:
            qss[i].append((t2,0))
        else:
            qss[i].append((t2, 1))
# print(qss)
qss[1].reverse()
# print(qss)
for q1,q2 in zip(qss[0],qss[1]):
    qt1 = q1[1]
    qt2 = q2[1]
    num1 = q1[0]
    num2 = q2[0]
    if qt1 == 0 and qt2 == 0: #
        ans *= min(num1, num2)


    elif qt1 == 0 and qt2 == 1:
        if num1 >= num2:
            ans *= 1
        else:
            ans *= 0

    elif qt1 == 1 and qt2 == 0:
        if num2 >= num1:
            ans *= 1
        else:
            ans *= 0
    else:
        if num1 != num2:
            ans *= 0
    ans %= MOD
print(ans)

Measured memory_bytes: 100572
#include <stdio.h>
#define NUM 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
int m[NUM][NUM];
int n,tt;
int mark[NUM],d[NUM],f[NUM];

void search (void);
void visit (int u);
int main()
{
  int i,j,u,v,k;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  m[i][j]=0;
	}
    }
  for(i=0;i<n;i++)
    {
      scanf("%d %d",&u,&k);
      u--;

      for(j=0;j<k;j++)
	{
	  scanf("%d",&v);
	  v--;
	  m[u][v] =1;
	}
    }
  search();
  return 0;
}

void search (void )
{
  
  int u;
  for(u=0;u<n;u++)
    mark[u]=WHITE;
  tt =0;

  for(u=0; u<n;u++)
    {
      if(mark[u]==WHITE) visit(u);
    }
  for(u=0;u<n;u++){
    printf("%d %d %d",u+1,d[u],f[u]);
    printf("\n");
    
  }
}
void visit (int u)
{
  int v;
  mark[u] =GRAY;
  d[u]= ++tt;
  for(v=0;v<n;v++)
    {if(m[u][v]==0)continue;
      if (mark[v] == WHITE)
	{
	  visit(v);
	}
    }
    
  mark[u] =BLACK;
  f[u] =++tt;
}
  
    



Measured memory_bytes: 2048
#include<iostream>
using namespace std;
int main(){
  int n,d,x,a[110];
  cin>>n>>d>>x;
  int re=x;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++){
    if(d%a[i]==0)re+=d/a[i];
    else re+=d/a[i]+1;
  }
  cout<<re;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//for(int i = ; i < ; i++){}

int main(){
  int n,a;
  cin>>n>>a;
  if(n%500<=a)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	int N=sc.nextInt();
	String S=sc.next();
	String[] S2=S.split("");
	int ikanri[]=new int[10];
	int jkanri[]=new int[100];
	long[] hash=new long[1000];
	int karinum=0;
	int ans=0;
	int monban=0;
	for(int i=0;i<N-2;i++) {
		if(ikanri[Integer.parseInt(S2[i])]==1) {
			continue;
		}else {
			ikanri[Integer.parseInt(S2[i])]=1;
		}
		for(int j=i+1;j<N-1;j++) {
			if(jkanri[Integer.parseInt(S2[i])*10+Integer.parseInt(S2[j])]==1) {
				continue;
			}else {
				jkanri[Integer.parseInt(S2[i])*10+Integer.parseInt(S2[j])]=1;
			}
			for(int k=j+1;k<N;k++) {
				karinum=(Integer.parseInt(S2[i])*100+Integer.parseInt(S2[j])*10+Integer.parseInt(S2[k]));
				if(hash[karinum]==1) {
					continue;
				}else {
					ans++;
					hash[karinum]=1;
					monban++;
				}
				if(ans==1000) {
					System.out.println(ans);
					System.exit(0);
				}
				if(monban==10) {
					monban=0;
					break;
				}
			}
			monban=0;
		}
	}
	System.out.println(ans);
}
}

Measured memory_bytes: 33624
#include <iostream>
#include <string.h>
using namespace std;

int main() {
    int count;
    char a[1000];
    char b[1000];
    int tpoint, spoint;
    tpoint = 0;
    spoint = 0;

    cin >> count;
    for(int i = 0; i < count; i ++){
        memset(a, '\0', sizeof(a));
        memset(b, '\0', sizeof(b));
        cin >> a >> b;
        if (strcmp(a, b) > 0){
            tpoint += 3;
        }else if(strcmp(a, b) == 0){
            tpoint++;
            spoint++;
        }else{
            spoint += 3;
        }
    }
    cout << tpoint << " " << spoint <<endl;
	return 0;
}



Measured memory_bytes: 3020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

constexpr ll mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    vvec<int> A(N,vec<int>(M));
    for(int i=0;i<N;i++) for(int j=0;j<M;j++) cin >> A[i][j];
    vec<mint> pow2(max(N,M)+1,1);
    for(int i=1;i<=max(N,M);i++) pow2[i] = pow2[i-1]*2;
    int rank = 0;
    for(int j=0;j<M;j++){
        bool update = false;
        for(int i=rank;i<N;i++) if(A[i][j]){
            swap(A[i],A[rank]);
            update = true;
            break;
        }
        if(update){
            for(int i=0;i<N;i++) if(i!=rank && A[i][j]){
                for(int k=j;k<M;k++) A[i][k] ^= A[rank][k];
            }
            rank++;
        }
    }
    cout << pow2[N-1]*(pow2[M]-pow2[M-rank]) << "\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n,m;
  cin >> n >> m;
  int L=0, R=inf;
  rep(i,m){
    int a,b; cin >> a >> b;
    L = max(L,a);
    R = min(R,b);
  }
  int ans = R-L+1;
  if(ans<0) ans = 0;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;

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

    long long x1 = 0;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (i & 0x1) {
            x1 -= A[i];
        } else {
            x1 += A[i];
        }
    }

    long long ans = x1;
    cout << ans << ' ';

    for (int i = 0; i < N - 1; i++) {
        ans = 2L * A[i] - ans;
        cout << ans;
        if (i != N - 1) {
            cout << ' ';
        }
    }

    cout << endl;

    return 0;
}

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

int main() {
	string a, b, c; cin >> a >> b >> c;
	string ans;
	ans += (char)a[0] - 'a' + 'A';
	ans += (char)b[0] - 'a' + 'A';
	ans += (char)c[0] - 'a' + 'A';
	cout << ans << endl;

	return 0;
}


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

public class Main {

	Scanner sc;

	private Main(){
		sc = new Scanner( System.in );
	}

	private void run(){
		while( sc.hasNext() ){
			String str = sc.next();
			int[] cards = new int[ 5 ];
			String[] cardsStr = str.split( "," );
			for( int i = 0; i < cardsStr.length; i++ ){
				cards[ i ] = Integer.parseInt( cardsStr[ i ] );
			}
			int[] hist = new int[ 14 ];
			for( int i = 0; i < hist.length; i++ ){
				hist[ i ] = 0;
			}
			for( int card : cards ){
				hist[ card ] ++;
			}
			Arrays.sort( cards ); // Very Important!!!!!!

			/* four card */
			if( this.checkSameCard( hist, 4 ) ){
				System.out.println( "four card" );
				continue;
			}

			/* full house */
			if( this.checkFullHouse( cards ) ){
				System.out.println( "full house" );
				continue;
			}

			/* straight */
			if( this.checkStraight( cards ) ){
				System.out.println( "straight" );
				continue;
			}

			/* three card */
			if( this.checkSameCard( hist, 3 ) ){
				System.out.println( "three card" );
				continue;
			}

			/* two pair */
			if( this.checkTwoPair( hist ) ){
				System.out.println( "two pair" );
				continue;
			}

			/* one pair */
			if( this.checkSameCard( hist, 2 ) ){
				System.out.println( "one pair" );
				continue;
			}

			System.out.println( "null" );
		}
	}

	private boolean checkSameCard( int[] hist, int n ){

		for( int i = 1; i <= 13; i++ ){
			if( hist[ i ] == n ){
				return true;
			}
		}
		return false;
	}

	private boolean checkFullHouse( int[] cards ){
		if(
				cards[ 0 ] == cards[ 1 ] &&
				( cards[ 1 ] == cards[ 2 ] || cards[ 2 ] == cards[ 3 ] ) &&
				cards[ 3 ] == cards[ 4 ]
		){
			return true;
		}
		return false;
	}

	private boolean checkStraight( int[] cards ){
		if(
				( cards[ 0 ] + 1 == cards[ 1 ] || cards[ 0 ] + 9 == cards[ 1 ] ) &&
				cards[ 1 ] + 1 == cards[ 2 ] &&
				cards[ 2 ] + 1 == cards[ 3 ] &&
				cards[ 3 ] + 1 == cards[ 4 ]
		){
			return true;
		}
		return false;
	}

	private boolean checkTwoPair( int[] hist ){
		int counter = 0;
		for( int i = 1; i <= 13; i++ ){
			if( hist[ i ] == 2 ){
				counter++;
			}
		}
		return ( counter == 2 ) ? true : false ;
	}

	/* Application Main Entry Point. */
	public static void main( String[] args ){
		new Main().run();
	}
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fo(i, n) for(int i = 1; i <= n; ++i)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 200200;
const int mod = 1e9 + 7;
int n;
pair<int, pii> a[N];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	fo(i, n)
		cin >>a[i].F>> a[i].S.F>>a[i].S.S;
	sort(a+1,a+n+1);
	fo(i,n)
	{
		int delta = a[i].F-a[i-1].F;
		int dist = abs(a[i].S.F-a[i-1].S.F)+abs(a[i].S.S-a[i-1].S.S);
		if(dist <= delta && abs(a[i].S.F+a[i].S.S)%2==(abs(a[i-1].S.F+a[i-1].S.S)+delta)%2)
			continue;
		cout << "No";
		return 0;
	}
	cout << "Yes";

	return 0;            
}

Measured memory_bytes: 1408
//============================================================================
// Name        : CODEFESTIVAL2017qualB.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

inline int main1();
inline int main2();
inline int main3();
inline int main4();

int main() {

	main2();

	return 0;
}

inline int main1() {

	string s;

	cin >> s;

	cout << s.substr(0, s.length() - 8);

	return 0;
}

int compare_int(const void *a, const void *b) {
	return *(int*) a - *(int*) b;
}

inline int main2() {

	int i, j;
	int n, m;
	int temp;
	int *d, *t;
	bool flag;

	cin >> n;

	d = new int[n];

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

	cin >> m;

	t = new int[m];

	for (i = 0; i < m; i++)
		cin >> t[i];

	qsort(d, n, sizeof(int), compare_int);

	qsort(t, m, sizeof(int), compare_int);

	flag = false;

	for (i = 0; i < m; i++) {

		for (j = temp; j < n; j++)
			if (t[i] == d[j]) {
				d[j] = 0;
				flag = true;
				temp = j;
				break;
			} else if ((d[i] != 0) && (d[i] > t[i])) {
				break;
			}

		if (!flag) {
			cout << "NO";
			return 0;
		}

		flag = false;

	}

	cout << "YES";
	return 0;

}

Measured memory_bytes: 2580
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,m,k;
  cin>>n>>m>>k;
  
  bool ok=false;
  for(int i=0; i<=n; i++){
    for(int j=0; j<=m; j++){
      int ans=0;
      ans+=i*m;
      ans+=j*n;
      ans-=i*j*2;
      if(ans==k){
        ok=true;
        break;
      }
    }
  }
  if(ok){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int a,b;
    int d,r;
    double f;
    scanf("%d %d", &a, &b);
    d = a / b;
    r = a % b;
    f = (double) a / b;
    printf("%d %d %.5f\n", d, r, f);
    return 0;
}


Measured memory_bytes: 2704
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#include <cassert>
#include <numeric>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;

ll y[10000005];

int main() {
    int n; cin >> n;
    vector<ll> a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];

    ll sum = 0;
    for(int i = n-1; i >= 0; i--){
        a[i] += sum;
        if(!(a[i]%b[i])) continue;
        else {
            a[i] %= b[i];
            sum += b[i] - a[i];
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 4824
#include<stdio.h>
int main(void)
{
    int n,i,flg,j,x,a,flg2;
	
	while(1)	{
		scanf("%d",&n);
		if(n==0)	break;
		while(1)	{
			flg=1;
			for(i=2;i<n;i++){
				if(n%i==0){
					flg=0;
					break;
				}
			}
			
			if(flg==1){
				i=n-2;
				flg2=1;
				for(j=2;j<i;j++){
					if(i%j==0){
						flg2=0;
						break;
					}
				}
			}	
			if(flg==1 && flg2==1){
				break;
			}
			n--;
		}
		
		printf("%d %d\n",i,n);
	}
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int koji[17][17]={0};
int way_x=0,way_y=0;
int a,b,n;
int func(int way_x,int way_y);
int main(){
  int x,y;
  while(1){
    for(int i=0;i<17;i++){
      for(int j=0;j<17;j++){
	koji[i][j]=0;
      }
    }
    way_x=0;
    way_y=0;
    cin >> a >> b;
    koji[a-1][b-1]=2;
    if(a==0 && b==0){
      break;
    }
    cin >> n;
    for(int i=0;i<n;i++){
      cin >> x >> y;
      koji[x-1][y-1]=1;
    }
    cout << func(0,0) << endl;
  }
}
int func(int way_x,int way_y){
  if(koji[way_x][way_y]==2) return 1;
  if(koji[way_x][way_y]==1) return 0;
  if(way_x > a-1 || way_y > b-1) return 0;
  return func(way_x+1,way_y) + func(way_x,way_y+1);
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'

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

int main() {
    fastio;
    ll ans=0, N, M, Q;
    cin >> N >> M >> Q;
    vector<int> a(Q),b(Q),c(Q),d(Q);
    rep(i,Q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    int A[11];
    fill(begin(A), end(A), 1);

    while (true) {
        ll score = 0;
        rep(i,Q) {
            if (A[b[i]] - A[a[i]] == c[i]) {
                score += d[i];
            }
        }
        ans = max(ans, score);
        int pos = N;
        if (A[pos] == M) {
            int p = pos;
            while (A[p] == M) {
                if (p == 1) {
                    cout << ans << endl;
                    return 0;
                }
                --p;
            }
            A[p]++;
            for (int i=p+1; i <= N; ++i) {
                A[i] = A[p];
            }
        } else {
            A[pos]++;
        }
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  int ope = 0;
  for (int i = 0; i < N; i++) {
    if (A.at(i) < 0) {
      ope++;
    }
  }

  for (int i = 0; i < N; i++) {
    if (A.at(i) < 0) {
      A.at(i) *= -1;
    }
  }
  sort(A.begin(), A.end());

  long long sum = 0;
  if (ope % 2 == 0) {
    for (int i = 0; i < N; i++) {
      sum += A.at(i);
    }
  }
  else {
    sum -= A.at(0);
    for (int i = 1; i < N; i++) {
      sum += A.at(i);
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 640
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 2;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregion

void solve()
{
  int n, k;
  cin >> n >> k;
  vector<pll> v(n);

  rep(i, n)
  {
    cin >> v[i].second >> v[i].first;
  }
  sort(all(v), greater<pll>());
  ll sum = 0;
  bool used[100010] = {};
  smaller_queue<ll> que;
  ll kind = 0;
  rep(i, k)
  {
    sum += v[i].first;
    if (used[v[i].second])
    {
      que.push(v[i].first);
    }
    else
    {
      used[v[i].second] = true;
      kind++;
    }
  }

  ll Max = sum + kind * kind;
  REP(i, k, n)
  {
    if (que.empty())
      break;
    if (used[v[i].second])
      continue;
    sum += v[i].first;
    used[v[i].second] = true;
    sum -= que.top();
    que.pop();
    kind++;
    Max = max(Max, sum + kind * kind);
  }
  cout << Max << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  solve();
  return 0;
}


Measured memory_bytes: 2556
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int a,b;
    cin >> a >> b;
    if(a * b % 2){
        cout << "Odd" << endl;
    }else{
        cout << "Even" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
n = input()
nums = [int(i) for i in input().split(" ")]

def is_even(num_list):
  for num in num_list:
    if num % 2 != 0:
      return False
  return True

counter = 0
while(is_even(nums)):
  counter += 1
  nums = [n/2 for n in nums]
print(counter)


Measured memory_bytes: 9068
import Data.List
import Data.Array.IO

main = do
  getLine
  chan <- map cut . foldl1 connect . map (:[]) . sortBy compareC . map (readC . words) . lines <$> getContents
  let rr = newArray (0,200000) 0 :: IO (IOUArray Int Int)
  ss <- getElems =<< foldl reserveS rr chan
  tt <- getElems =<< foldl reserveT rr chan
  let table = zip ss tt
  putStrLn . show . maximum $ count 0 table

readC :: [String] -> (Int, Int, Int)
readC s = ((read :: String -> Int) (s !! 0), (read :: String -> Int) (s !! 1), (read :: String -> Int) (s !! 2))

compareC :: (Int, Int, Int) -> (Int, Int, Int) -> Ordering
compareC (s1, t1, c1) (s2, t2, c2) = if c1 /= c2 then compare c1 c2
                                                 else compare s1 s2

equalC :: (Int, Int, Int) -> (Int, Int, Int) -> Bool
equalC (_, _, c1) (_, _, c2) = c1 == c2

isConnect :: (Int, Int, Int) -> (Int, Int, Int) -> Bool
isConnect (_, t, _) (s, _, _) = t == s

connect :: [(Int, Int, Int)] -> [(Int, Int, Int)] -> [(Int, Int, Int)]
connect s@(x:xs) (y:_) = if equalC x y && isConnect x y
                    then (connect' x y):xs
                    else y:s

connect' :: (Int, Int, Int) -> (Int, Int, Int) -> (Int, Int, Int)
connect' (s, _, c) (_, t, _) = (s, t, c)

cut :: (Int, Int, Int) -> (Int, Int)
cut (s, t, _) = (s * 2 - 1, t * 2)

reserveS :: IO(IOUArray Int Int) -> (Int, Int) -> IO (IOUArray Int Int)
reserveS a (s, _) = f a s

reserveT :: IO(IOUArray Int Int) -> (Int, Int) -> IO (IOUArray Int Int)
reserveT a (_, t) = f a t

f :: IO (IOUArray Int Int) -> Int -> IO (IOUArray Int Int)
f a t = do
  aa <- a
  n <- readArray aa t
  writeArray aa t (n + 1)
  return aa

count :: Int -> [(Int, Int)] -> [Int]
count n []     = []
count n (x:xs) = let nn = n + (fst x - snd x)
                    in nn : count nn xs

Measured memory_bytes: 135036
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N = I()
S = str(input())

ans = 1
for i in range(1,N):
    if S[i]!=S[i-1]:
        ans += 1

print(ans)

Measured memory_bytes: 39920
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

template<ll mod, ll primitive_root>
class NTT {
  void bit_reverse(vector<ll>& a){
    int N = a.size();
    int i = 0;
    for(int j=1; j<N-1; j++){
      for(int k=N>>1; k>(i^=k); k>>=1);
      if(j < i) swap(a[i], a[j]);
    }
  }
  ll extgcd(ll a, ll b, ll &x, ll &y){
    ll d = a;
    if(b!=0){
      d = extgcd(b,a%b,y,x);
      y -= (a/b)*x;
    }else{
      x = 1; y = 0;
    }
    return d;
  }
  ll mod_inv(ll a){
    ll x, y;
    extgcd(a, mod, x, y);
    return (mod + x % mod) % mod;
  }
  ll mod_pow(ll x, ll n){
    if(n==0) return 1;
    ll res = mod_pow(x * x % mod, n / 2);
    if(n & 1) res = res * x % mod;
    return res;
  }
  
  void _calc(vector<ll>& a, int sign){
    int N = a.size();
    ll g = primitive_root;

    ll tmp = (mod - 1) * mod_inv(N) % mod;
    ll h = mod_pow(g, tmp);
    if(sign == -1) h = mod_inv(h);

    bit_reverse(a);
    
    for(int m=1; m<N; m<<=1){
      ll _base = mod_pow(h, N/(2*m));
      ll _w = 1;
      for(int x=0; x<m; x++){
        for(int s=x; s<N; s+=(2*m)){
          ll u = a[s];
          ll d = (a[s+m] * _w) % mod;
          a[s] = (u+d) % mod;
          a[s+m] = (u-d+mod) % mod;
        }
        _w = (_w * _base) % mod;
      }
    }
  }

  void ntt(vector<ll>& in){ _calc(in, 1); }
  void intt(vector<ll>& in){
    _calc(in, -1);
    ll n_inv = mod_inv(in.size());
    for(int i=0; i<in.size(); i++){
      in[i] = (in[i] * n_inv) % mod;
    }
  }

public:
  NTT(){}

  long long get_mod() const { return mod; }

  vector<ll> conv(const vector<ll>& a, const vector<ll>& b){
    vector<ll> _a = a, _b = b;
    int m = a.size() + b.size() - 1;
    int n = 1; while(n < m) n <<= 1;
    _a.resize(n, 0);
    _b.resize(n, 0);
    ntt(_a);
    ntt(_b);
    for(int i=0; i<n; i++) _a[i] = (_a[i] * _b[i]) % mod;
    intt(_a);
    _a.resize(m);
    return _a;
  }
};

NTT<998244353,3> ntt;

vector<ll> dfs(const vector<int>& v, int S, int l, int r){
  if(l+1 == r){
    vector<ll> x(min(v[l],S)+1,0);
    x[0] = 2;
    if(v[l]<=S) x[v[l]] = 1;
    return x;
  }

  int m = (l+r)/2;
  vector<ll> lhs = dfs(v, S, l, m);
  vector<ll> rhs = dfs(v, S, m, r);

  vector<ll> res = ntt.conv(lhs, rhs);
  if(res.size() > S){
    res.resize(S+1);
  }
  return res;
}

int main(){
  int N, S;
  cin >> N >> S;
  
  vector<int> v;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }
  //sort(ALLOF(v));

  vector<ll> ret = dfs(v, S, 0, N);
  
  cout << ret[S] << endl;

  return 0;
}



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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

vector<ll> vectorize(ll n){
    vector<ll> ret;
    while(n){
        ret.push_back(n % 10);
        n /= 10;
    }
    return ret;
}

ll toll(vector<ll> v){
    ll base = 10LL, ret = 0LL;
    for(ll x: v){
        ret += x * base;
        base *= 10;
    }
    return ret;
}

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin >> n;
    vector<ll> v = vectorize(n);

    ll anssum, ans;
    rep((int)v.size()){
        if(!i){
            anssum = accumulate(all(v), 0LL);
            ans = n;
            continue;
        }
        vector<ll> u(v);
        if(v[i] == 0){
            int j = i;
            while(u[j] == 0 && j < (int)u.size()) u[j++] = 9;
            if(j == (int)u.size()) continue;
            u[j]--;
            repp(k, i) u[k] = 9;
        }else{
            u[i]--;
            repp(k, i) u[k] = 9;
        }
        ll tmpsum = accumulate(all(u), 0LL);
        if(anssum < tmpsum){
            anssum = tmpsum;
            ans = toll(u);
        }
    }
    cout << anssum << endl;
}


Measured memory_bytes: 256