akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    using Tup = tuple<string,int,int>;
    vector<Tup> P(n);
    rep(i,n){
        string s; int p;
        cin>>s>>p;
        P[i] = tie(s,p,i);
    }
    sort(all(P), [](Tup &x, Tup &y){
        string s1,s2; int p1,p2, idx1,idx2;
        tie(s1,p1,idx1) = x;
        tie(s2,p2,idx2) = y;
        if (s1 != s2){
            return s1 < s2;
        }else{
            return p1 > p2;
        }
    });
    rep(i,n){
        cout<<get<2>(P[i])+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] h = new int[n];
        for (int i=0;i<n;i++) {
            h[i] = sc.nextInt();
        }
        Set<Integer> hSet = new HashSet<>();
        for (int i=0;i<m;i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            if (h[a-1]>=h[b-1]) {
                hSet.add(b);
            }
            if (h[a-1]<=h[b-1]) {
                hSet.add(a);
            }
        }
        int hInt = hSet.size();
        System.out.println(n-hInt);

    }
}


Measured memory_bytes: 63776
word = []

while True:
    a = str(input())
    if a[:1] == '-':
        break
    n = int(input())
    
    for i in range(n):
        c = int(input())
        a = a[c:]+a[:c]

    word.append(a)

for i in range(len(word)):
    print(word[i])


Measured memory_bytes: 5600
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

    vector<int> a(n);
    int mcnt = 0;
    int mini = 1e9;
    int minindex = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] < 0) mcnt++;
        if(mini > abs(a[i])){
            mini = abs(a[i]);
            minindex = i;
        }
    }

    ll total = 0;
    for(int i = 0; i < n; i++){
        total += abs(a[i]);
    }

    if(mcnt % 2 == 0){
        cout << total << endl;
    } else {
        cout << total - abs(a[minindex]) - abs(a[minindex]) << endl;
    }

}


Measured memory_bytes: 640
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

//#define MAXN (1 << 4)

//ll a[MAXN][MAXN];
//ll f[MAXN];

#define MAXN (1 << 20)

ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}


ll x[MAXN];
mod a[MAXN];
mod f[MAXN];

int main() {
	cout << fixed << setprecision(12);	
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < n - 1; i++) {
		a[i] = x[i + 1] - x[i];
	}
	f[0] = 1;
	for (int i = 1; i <= n; i++) {
		f[i] = f[i - 1] * i;
	}
	mod ret(0);
	mod sum(0);
	for (int i = 1; i <= n - 1; i++) {
		mod c;
		c = f[n - 1] * mod(i).inv();
		sum += c;
		//cerr << c << " " << a[i - 1] << endl;
		ret += sum * a[i - 1];
	}
	cout << ret << endl;

/*	f[0] = 1;
	for (int i = 1; i < MAXN; i++) {
		f[i] = i * f[i - 1];
	}
	a[1][1] = 1;
	for (int i = 2; i < MAXN - 1; i++) {
		for (int j = 1; j < i; j++) {
			if (j == 1) {
				a[i][j] = f[i - 1];	
			} else {
				a[i][j] = f[i - 2] + j * a[i - 1][j - 1] + (i - 1 - j) * a[i - 1][j];
			}
			cerr << a[i][j] << " ";
		}
		cerr << endl;
	}*/
	return 0;
}



Measured memory_bytes: 20764
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
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 aps
 */
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);
        MCandies solver = new MCandies();
        solver.solve(1, in, out);
        out.close();
    }

    static class MCandies {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            Numbers number = new Numbers(1000000007);
            int n = in.nextInt(), k = in.nextInt();
            int[] a = new int[n + 1];
            long[][] dp = new long[n + 5][k + 5];

            for (int i = 1; i <= n; i++) a[i] = in.nextInt();
            dp[0][0] = 1;
            for (int i = 1; i <= n; i++) {
                for (int j = 0; j <= k; j++) {
                    if (j > 0) dp[i][j] = number.add(dp[i][j], dp[i][j - 1]);
                    int x = Math.max(0, j - a[i]);
                    if (x == 0) dp[i][j] = number.add(dp[i][j], dp[i - 1][j]);
                    else {
                        long num = number.sub(dp[i - 1][j], dp[i - 1][x - 1]);
                        dp[i][j] = number.add(dp[i][j], num);
                    }
                }
            }
            out.println(dp[n][k]);
        }

    }

    static class Numbers {
        public long mod;

        public Numbers(long MOD) {
            mod = MOD;
        }

        public long add(long a, long b) {
            a += b;
            if (a >= mod) a -= mod;
            return a;
        }

        public long sub(long a, long b) {
            a -= b;
            if (a < 0) a += mod;
            return a;
        }

    }

    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: 126420
import java.awt.Point;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x, y;
		x = sc.nextInt();
		y = sc.nextInt();
		while (x != 0) {
			char map[][] = new char[y][x];
			load(sc, map);
			Queue<Point> que = new LinkedList<Point>();
			for (int i = 0;i < map.length;i ++) {
				for (int j = 0;j < map[i].length;j ++) {
					if (map[i][j] == '@') {
						que.add(new Point(j, i));
					}
				}
			}
			
			int dx[] = {-1, 0, 1, 0};
			int dy[] = {0, 1, 0, -1};
			int count = 0;
			while(!que.isEmpty()) {
				Point p = que.poll();
				if (p.x < 0 || p.x >= x || p.y < 0 || p.y >= y) continue;
				if (map[p.y][p.x] == '#') continue;
				count ++;
				map[p.y][p.x]= '#'; 
				for (int i = 0;i < 4;i ++) {
					que.add(new Point(p.x + dx[i], p.y + dy[i]));
				}
			}
			System.out.println(count);
			x = sc.nextInt();
			y = sc.nextInt();
		}
	}
	
	public static char[][] load(Scanner sc, char[][] map) {
		for (int i = 0;i < map.length;i ++) {
			map[i] = sc.next().toCharArray();
		}
		return map;
	}
}



Measured memory_bytes: 42776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define dump(x) cerr << #x << " : " << x << '\n'

int main() {
    string S; cin >> S;
    int N = S.size();
    vector<int> L(N), R(N);
    queue<int> Q;
    rep(i, 0, N) {
        if(S[i] == 'R') Q.push(i);
        else {
            while(!Q.empty()) {
                int t = Q.front(); Q.pop();
                int d = t - i;
                if(d % 2 == 0) L[i]++;
                else L[i-1]++;
            }
        }
    }
    reverse(S.begin(), S.end());
    rep(i, 0, N) {
        if(S[i] == 'L') Q.push(i);
        else {
            while(!Q.empty()) {
                int t = Q.front(); Q.pop();
                int d = t - i;
                if(d % 2 == 0) R[i]++;
                else R[i-1]++;
            }
        }
    }
    reverse(R.begin(), R.end());
    rep(i, 0, N) {
        cout << L[i] + R[i] << " ";
    }
    cout << endl;
    return 0;
}


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

int main() {
	int a, b;

	while (1) {
		cin >> a >> b;
		if (cin.eof()) {
			break;
		}
		a = (int) log10((double) (a + b)) + 1;
		cout << a << endl;
	}

	return 0;
}

Measured memory_bytes: 1204
# coding: utf-8
# Your code here!

i=int(input())


lst = []
while i > 0:
    lst.append(i%10)
    i //= 10 
lst.reverse()
#print(lst)
if (len(lst) == 4):
    if (lst[0] == lst[1] or lst[1] == lst[2] or lst[2] == lst[3] ):
        print('Bad')
    else:
        print('Good')
elif (len(lst) == 3):
    if (lst[0] == lst[1] or lst[1] == lst[2]):
        print('Bad')
    else:
        print('Good')
elif (len(lst) == 2 or 1 or 0):
    print('Bad')    

Measured memory_bytes: 3064
#include <stdio.h>
int main() {
  int a[50];
  int b,n;
  b = 0;
  scanf("%d", &n);
  for(int i=0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for(int j=0; j < n; j++) {
    if(a[j] == j + 1) {
      b++;
    }
  }
  if (n - b <= 2) {
    printf("YES");
  } else {
    printf("NO");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string.h>
#include <algorithm>

using namespace std;

string a, b;

int main() {
  cin >> a >> b;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  cout << (a < b ? "Yes" : "No") << '\n';
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define mod 1000000007
#define pb(a) push_back((a))
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
//#define INF 931931114518101
using namespace std;
typedef pair<ll, ll> P;
typedef pair<ll, P> lP;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
  for (auto &i : arr) {
    fill_all(i, v);
  }
}
//------------------変数-----------------------//
ll h, w;
vector<ll> grid[301];
//-------------------関数----------------------//
ll f[305][305];
void floyd() {
  for (int k = 0; k < 10; ++k) //ここ、0か1かで注意！
  {
    for (int i = 0; i < 10; ++i) {
      for (int j = 0; j < 10; ++j) {
        f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
      }
    }
  }
  return;
}
// INFで初期化！
int main() {
  cin >> h >> w;
  fill_all(f, (ll)INF);
  REP(i, 10) {
    REP(j, 10) { cin >> f[i][j]; }
  }
  floyd();
  ll cnt = 0;
  REP(i, h) {
    REP(j, w) {
      ll a;
      cin >> a;
      if (a == -1) {
        continue;
      }
      cnt += f[a][1];
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    unordered_map<string,int>cnt;
    while(n--)
    {
        string s;
        cin>>s;
        ++cnt[s];
    }
    cout<<"AC x "<<cnt["AC"]<<endl;
    cout<<"WA x "<<cnt["WA"]<<endl;
    cout<<"TLE x "<<cnt["TLE"]<<endl;
    cout<<"RE x "<<cnt["RE"]<<endl;
}


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

using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back

int main(){
	fast;
	lli r;
	cin>>r;
	float pi=3.14159;
	double cir=2*pi*r;
	cout<<cir<<endl;
}

Measured memory_bytes: 3792
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY  1
#define BLACK 2
void dfs(void);
int dfs_visit(int);
int n,time;
int array[N][N],color[N],d[N],f[N];
int main()
{
  int i,j,v,w,x;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      for(j=0;j<N;j++)
	{
	  array[i][j]=0;
	}
    }
  
  for(i=0;i<n;i++)
    {
      scanf("%d%d",&v,&w);
      v--;               //27?????????????¬?????????????????´???????????????????
      for(j=0;j<w;j++)
	{
	  scanf("%d",&x);
	  x--;           //27?????????????¬?????????????????´???????????????????
	  array[v][x]=1; //v??¨x????????????????????????????????¨??§???0???????????????????????? 
	}
    }
  dfs();
  return 0;
}
void dfs(void) //???????????¨??±???????????¢?´¢???????????????????????¨???????????????
{
  int i;

  for(i=0;i<n;i++)
    {
      color[i]=WHITE;
    }
  time=0;
  
  for(i=0;i<n;i++)
    {
      if(color[i]==WHITE) dfs_visit(i);
    }

  for(i=0;i<n;i++)
    {
      printf("%d %d %d\n",i+1,d[i],f[i]);
    }
}
int dfs_visit(int u)
{
  int i;
  color[u]=GRAY;
  d[u]=++time;
  for(i=0;i<n;i++)
    {
      if(array[u][i]==0) continue;
      if(color[i]==WHITE) dfs_visit(i);
    }
  color[u]=BLACK;
  f[u]=++time;
}

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


int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(a>0 && c>0){
    c=c-b;
    if(c<=0){
      cout << "Yes" << endl;
      return 0;
    }
    a=a-d;
    if(a<=0){
      cout << "No" << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3568
from math import *
PI = 3.1415926535898
res = [0]*111
arr = []
ans = 0
while True:
	try:
		n = input()
		res[n] += 1
		arr.append(n)
	except EOFError:
		break
ma = max(res)
for i in range(101):
	if arr.count(i) == ma:
		print i

Measured memory_bytes: 6328
from collections import Counter
h,w=map(int,input().split())
a=""
for i in range(h):
    a+=input()
f,o=0,0
for i in Counter(a).values():
    f+=i//4
    o+=i%4%2
print("Yes" if f>=(h//2)*(w//2) and o<=(h%2)*(w%2) else "No")

Measured memory_bytes: 3316
K=int(input())
A=list(map(int,input().split()))
A=A[::-1]
#print(A)
if A[0]!=2:
    print(-1)
    exit()

M=3
m=2
import math
for i in range(1,K):
    if m%A[i]==0:
        Lm=m
    else:
        Lm=(m//A[i]+1)*A[i]
    #print(Lm)
    if Lm<m or M<Lm:
        print(-1)
        exit()
    LM=(M//A[i])*A[i]+A[i]-1
    if LM<Lm:
        print(-1)
        exit()
    M=LM
    m=Lm
print(m,M)
    

Measured memory_bytes: 63856
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  ll a;	cin>>a;
  cout << a + a*a + a*a*a << endl;
  return 0;
}


Measured memory_bytes: 3188
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

int main(){
  ll n,a[200020];
  cin>>n;
  REP(i,n)cin>>a[i];
  sort(a,a+n);
  bool flag=true;
  REP(i,n-1){
    if(a[i]==a[i+1]){
      flag=false;
      break;
    }
  }
  if(flag)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define INF 1000000000000007
using namespace std;

int main() {
    int n;
    long x;
    cin >> n >> x;
    long a[n];
    long b[n][n + 1];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        fill(b[i], b[i] + n + 1, INF);
        b[i][0] = INF;
    }
    long ans = INF;

    for (int k = 0; k < n; k++) {
        long min_k = 0;
        for (int i = 0; i < n; i++) {
            min_k += b[i][k + 1] = min(b[i][k], a[(n + i - k) % n]);
        }
        min_k += k * x;
        ans = min(ans, min_k);
    }
    cout << ans << endl;
    return 0;
}



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

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define WHITE 0  // 未訪問
#define BLACK 1  // 訪問ずみ

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 (a>b) { a=b; return 1; } return 0; }

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
const int N=100000;
//const ll M = 1000000000+7;

ll cnt = 0; 

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n, -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;
  }
  bool same(int x, int y) {return root(x)==root(y);}
  int size(int x) {return -d[root(x)];}
  int factor_size() {
    int ans=0;
    rep(i,d.size()){
      if (d[i]<0) {ans++;}
    }
    return ans;
  }
  
};
  
int main(){ 
  int n,m,k,q;
  cin >> n>>q;
  string S;

  cin >> S;

  int a[n+1];
  int s[n+1];
  rep(i, n){
    if(S[i]=='A' && S[i+1]=='C') a[i]=1;
    else a[i] = 0;
  }
  s[0] = 0;
  
  rep(i,n) s[i+1] = s[i]+a[i];

  int r,l;
  rep(i, q){
    cin >> l>>r;
    l--;r--;
    //cout<<s[0]<<s[1]<<s[2]<<s[3]<<s[4]<<s[5]<<s[6]<<s[7]<<endl;
    cout << s[r] - s[l] <<endl;
  }
  
}



Measured memory_bytes: 1792
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    unsigned int H,W;
    char s[51][51];
    string ans="Yes";

    cin >> H >> W;

    rep(i,H){
        rep(j,W) {
            cin >> s[i][j];
        }
    }
    int vx[4]={1,0,-1,0};
    int vy[4]={0,1,0,-1};
    rep(i,H){
        rep(j,W) {
            if(s[i][j]=='#'){
                bool flag=false;
                for(int k=0; k<4;k++){
                    int nx=j+vx[k];
                    int ny=i+vy[k];
                    if(nx>=0&&nx<=W-1&&ny>=0&&ny<=H-1){
                        if(s[ny][nx]=='#') flag=true;
                    }
                }
                if(!flag)ans = "No";
            }
        }
    }

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



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

string S[300];
int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> S[i];
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        bool is_good_grid = true;
        for(int j = 0; j < N; j++){
            for(int k = 0; k < N; k++){
                if(S[(j - i + N) % N][k] != S[(k - i + N) % N][j]){
                    //cout << i << " " << j << " " << k << endl;
                    //cout << (j + i) % N << " " << k << endl;
                    //cout << S[(j + i) % N][k] << " " << S[k][(j + i) % N] << endl;
                    is_good_grid = false;
                    break;
                }
            }
            if(!is_good_grid){
                break;
            }
        }
        if(is_good_grid){
            ans += N;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define LL long long 
using namespace std;
inline int read(){
    int x = 0; char c = getchar();
    while (!isdigit(c)) c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0',c = getchar();
    return x;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }
const int N = 100050;
int n,m,v,k,a[N],ans = 0; LL sum[N];
int main(){
	int i; 
	n = read(),m = read(),v = n-read(),k = read();
	for (i = 1; i <= n; ++i) a[i] = read();
	sort(a+1,a+n+1); reverse(a+1,a+n+1); 
	for (i = 1; i <= n; ++i) sum[i] = sum[i-1] + a[i];
	for (i = 1; i <= n; ++i){
		if (i<=k) {++ans; continue;}
		if (a[k]-m>a[i]) continue;
		if (i-k <= v){ ++ans; continue; }
		if (sum[i-1] - sum[k-1] - 1ll*(i-k)*a[i] <= 1ll*m*v) {++ans; continue; }
	}
	cout<<ans<<endl;
    return 0;
}


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

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

    int N;
    cin >> N;
    string S;
    cin >> S;
    int cnt = 0;
    char ch;
    for (int i = 0; i < N; i++) {
        if (i == 0) {
            ch = S[i];
            cnt++;
        } else {
            if (S[i] == ch) continue;
            ch = S[i];
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define endl '\n'
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;

int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    int n, right, left, x ;
    left=right=0 ;
    string s ;
    cin>> n >> s ;
    for(int i=0 ; i<s.length() ; i++)
      {
        if(s[i]=='(') left++ ;
        else right++ ;
        if(right>left)
          {
            x=right-left ;
            while(x--)
              {
                s='('+s ;
                i++ ;
              }
            right=left ;
          }
      }
    if(left>right)
      {
        x=left-right ;
        while(x--)
          s+=')' ;
      }
    cout<< s ;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define adj_list vector<vi>
#define endl "\n"
#define INF_INT 2e9
#define INF_LL 2e18
#define matmax 25
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define pl pair<ll, ll>
#define pll pair<ll, pair<ll, ll> >
#define vi vector<int>
#define vl vector<ll>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long int ll;

int lsone(int n)
{
	return (n&-n);
}

ll pow1(ll a, ll b)
{
	if (b == 0)
		return 1ll;
	else if (b == 1)
		return a;
	else
	{
		ll x = pow1(a, b/2);
		x *= x;
		x %= mod;
		if (b%2)
		{
			x *= a;
			x %= mod;
		}
		return x;
	}
}

ll n, arr[1100000], remf[1100000], remb[1100000], sum[1100000];

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

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

	for (int i = 1; i <= n; i++) {
		remf[i] = arr[i]-1;
		remf[i] += remf[i-1];
		sum[i] += arr[i];
		sum[i] += sum[i-1];
	}

	for (int i = n; i >= 1; i--) {
		remb[i] = arr[i]-1;
		remb[i] += remb[i+1];
	}

	ll ans = 1e18;

	for (int i = 1; i <= n; i++) {
		ll lef = sum[i];
		ll right = sum[n]-sum[i];

		ans = min(ans, max(lef, right)-min(lef, right));
	}

	cout<<ans<<"\n";

	return 0;
}


Measured memory_bytes: 12032
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6+7;
const int mod = 1e9+7;
typedef long long ll;
int n,m;

ll f[maxn], inv[maxn], sinv[maxn];
vector<int> g[maxn];
int s[maxn];
void dfs(int u, int p){
    s[u] = 1;
    for(int v : g[u]){
        if(v != p){
            dfs(v, u);
            s[u] += s[v];
        }
    }
}
ll ans[maxn];
void dfs2(int u, int p){
    for(int v : g[u]){
        if(v != p){
            ans[v] = ans[u] * s[v] % mod * inv[n - s[v]] % mod;
            dfs2(v, u);
        }
    }
}
int main()
{
    cin >> n;
    for(int i=1;i<n;i++){
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(1, 0);
    inv[0] = inv[1] = sinv[0] = 1;
    f[0] = 1;
    for(int i=2;i<maxn;i++)inv[i] = inv[mod % i] * (mod - mod / i) % mod;
    for(int i=1;i<maxn;i++)sinv[i] = sinv[i - 1] * inv[i] % mod, f[i] = f[i-1] * i % mod;
    ll res = f[n];
    for(int i=1;i<=n;i++){
        res = res * inv[s[i]] % mod;
    }
    ans[1] = res;
    dfs2(1, 0);
    for(int i=1;i<=n;i++)cout << ans[i] << "\n";
    return 0;
}


Measured memory_bytes: 63220
a = int(input())
b = int(input())
c = int(input())
d = int(input())
s = 0
if a < b:
    if c < d:
        s = a + c
    else:
        s = a + d
else:
    if c < d:
        s = b + c
    else:
        s = b + d
print(s)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define lla(s) s.rbegin(),s.rend()
#define pcnt(b) __builtin_popcount(b)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ll INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;string s,t;
    cin>>n>>s>>t;
    if(s==t){cout<<n<<endl;return 0;}
    rrep(i,n-1,0){
        string tmp = s + t.substr(i,n-i);
        if(tmp.substr(tmp.length()-n,n)==t){cout<<tmp.length()<<endl;return 0;}
    }
}

Measured memory_bytes: 256
// "for if God is with them who can be against them."
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define endl '\n'
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
#define watch(x) cout << (#x) << " is " << (x) << endl
int ans = 0;
int cnt[400004];
void solve() {
	int n, k, ans = 0;
	cin >> n >> k;
	int a[n];
	REP(i, 0, n - 1) {
		cin >> a[i];
	}
	sort(a, a + n);
	REP(i, 0, k - 1) {
		ans += a[i];
	}
	cout << ans;
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	IOS;
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}


#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
	return 0;
}

Measured memory_bytes: 3696
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a, b;
    cin >> a >> b;
    int c = atoi((a + b).c_str());
    REP(i, 500)if(c == i * i) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


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

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)

int dfs(int last, int left)
{
    if (last < 0 || last > 9)
    {
        return 0;
    }
    if (left <= 0)
    {
        return 1;
    }
    return dfs(last - 1, left - 1) + dfs(last, left - 1) + dfs(last + 1, left - 1);
}

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

    int k;
    cin >> k;

    int s = 0;
    int ans_first = -1, ans_digit;
    rep(digit, 1, 11)
    {
        rep(first, 1, 10)
        {
            int cnt = dfs(first, digit - 1);
            // cout << "digit=" << digit << " first=" << first << " cnt=" << cnt << el;
            if (s + cnt >= k)
            {
                ans_first = first;
                ans_digit = digit;
                k-=s;
                break;
            }
            s += cnt;
        }
        if (ans_first >= 0)
        {
            break;
        }
    }
    // cout << ans_digit << el;
    // printf("k=%d\n",k);
    cout << ans_first;
    int prev = ans_first;
    repi(digit,ans_digit-1,1) {
        int s = 0;
        rep(delta,-1,2) {
            int cnt = dfs(prev+delta,digit-1);
            // printf("cnt[%d,%d]=%d\n", prev+delta,digit-1,cnt);
            if (s + cnt >= k) {
                cout << prev + delta;
                prev+=delta;
                k-=s;
                break;
            }
            s += cnt;
        }
    }
}

Measured memory_bytes: 256
//#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

//ifstream cin("x.in"); ofstream cout("x.out");

typedef long long i64;

const int nmax = 1e5 + 5;
int dif[nmax + 1], v[nmax + 1], bagat[nmax + 1];

int m;
vector< int > pos[nmax + 1];

struct str {
    int x, dist;

    str() {}
    str (int _x, int _dist) {
        x = _x, dist = _dist;
    }

    inline bool operator < (const str &k) const {
        if (dist != k.dist) return (dist < k.dist);
        return (x < k.x);
    }
};
set< str > s;

inline int muta_de_la (int x, int y) {
    if (x <= y) return y - x;
    else        return y - x + m;
}

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

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

    i64 suma = 0, sb = 0;
    int catem = 0;

    for (int i = 1; i < n; ++ i) {
        dif[ i ] = muta_de_la(v[i - 1], v[ i ]);
        pos[ v[ i ] ].push_back( i );

        suma += min(dif[ i ], muta_de_la(1, v[ i ]) + 1);

        bagat[ i ] = dif[ i ] - (muta_de_la(1, v[ i ]) + 1);
        s.insert(str(i, bagat[ i ]));

        catem += (bagat[ i ] >= 0);
    }

    sb = suma;

    for (int i = 1; i <= m; ++ i) { /// constanta e i - 1
        if (suma < sb) {
            sb = suma;
        }

        //cout << suma << "\n";
        if (i == m) continue;

        for (auto j : pos[ i ]) { /// isi schimba mutatul
            set< str >::iterator it = s.find(str(j, bagat[ j ]));
            s.erase( it );
            suma -= min(dif[ j ], muta_de_la(i, v[ j ]) + 1);

            if (dif[ j ] >= muta_de_la(i, v[ j ]) + 1) {
                -- catem;
            }

            bagat[ j ] = dif[ j ] - (muta_de_la(i + 1, v[ j ]) + 1) - i; /// toate dif au crescut cu i
            s.insert(str(j, bagat[ j ]));

            suma += min(dif[ j ], muta_de_la(i + 1, v[ j ]) + 1);
            catem += (bagat[ j ] >= -i);
        }

        suma -= catem;
        /// care devin mai bune cu favorit decat dif[ i ]
        /// care acum au diferentele 0
        set< str >::iterator it = s.lower_bound(str(0, -i));
        while (it != s.end() && it -> dist == -i) {
            ++ catem;
            ++ it;
        }

    }
    cout << sb << "\n";

    return 0;
}

Measured memory_bytes: 10752
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double ans=a*a+b*b-2*a*b*cos(2*M_PI*((h+m/60)/12-m/60));
    printf("%.12lf\n",sqrt(ans));
    return 0;
}


Measured memory_bytes: 4216
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD 1000000007
#define INV_10 299473306
#define INF 1000000000
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	long long n;
	cin >> n;
	long long cu=100;
	int nb=0;
	while(cu < n)
	{
		nb++;
		cu=cu+cu/100;
	}
	cout << nb << '\n';
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

template <typename T>
T mod_expt(T a, std::int64_t n, T mod){
    T power {1};
    while(n > 0){
        if(n & 1){power = power * a % mod;}
        a = a * a % mod;
        n >>= 1;
    }
    return power;
}

constexpr ll MOD = 998244353ll;
int N, S;
int A[310];
ll dp[310][310*310], dp2[310][310*310];

ll rec(int i, int s){
    if(i == N){
        return (2 * s >= S) ? 1 : 0;
    }

    if(dp[i][s] != -1){
        return dp[i][s];
    }

    return dp[i][s] = (rec(i + 1, s + A[i]) + 2ll * rec(i + 1, s) % MOD) % MOD;
}

ll rec2(int i, int s){
    if(i == N){
        return (2 * s == S) ? 1 : 0;
    }

    if(dp2[i][s] != -1){
        return dp2[i][s];
    }

    return dp2[i][s] = (rec2(i + 1, s + A[i]) + rec2(i + 1, s)) % MOD;
}

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

    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> A[i];
    }

    S = std::accumulate(A, A + N, 0);

    memset(dp, -1, sizeof(dp));
    memset(dp2, -1, sizeof(dp));

    ll res = (mod_expt<ll>(3ll, N, MOD) + MOD - 3ll * rec(0, 0) % MOD + 3ll * rec2(0, 0)) % MOD;
    std::cout << res << std::endl;
}


Measured memory_bytes: 465792
//#pragma comment(linker, "/STACK:102400000,102400000") 手动扩栈
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
#include <queue>
#include<string>
#include <set> //插入时相同的不插，边插边排序，里面还有multiset可以重复
#include <algorithm>
#define foc(i,x,y) for(int i = x ; i <= y ; i ++)
#define rea(i,x,y) for(int i = x ; i >= y ; i --)
#define scf(a) scanf("%d",&a)
#define sca(a,b) scanf("%d%d",&a,&b)
#define pri(a) printf("%d\n",a)
#define pri_(a) printf("%d ",a)
#define prn printf("\n")
#define mem(a) memset(a,0,sizeof(a))
#define LL long long
using namespace std;
const double eps = 1e-9;
const int maxn = 1e6 + 10;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
struct node
{
    int a;
    int b;
}s[555555];
int t[1000][1000],ans = 0,cnt = 0,vis = 0;
void init()
{
    foc(i,2,1000)
    {
        int n = i*(i+1)/2;
        s[n].a = 1;
        s[n].b = i;
    }
    return ;
}
int main()
{
    init();
    int n;
    cin >> n;
    if(n==1)
    {
        cout << "Yes\n"  << "2\n1 1\n1 1\n"<< endl ;
        return 0;
    }

    if(s[n].a==1)
    {

        cout << "Yes" << endl;
         cout << s[n].b+1 << endl;
        ans = s[n].b;
        cnt = 1;
        vis = 0;
        while(vis<=s[n].b)
        {
            cout << s[n].b << " ";
            if(vis > 0)
            {
                int sss = vis;
                foc(i,0,vis-1)
                {
                    cout << t[i][sss] << " ";
                    sss -- ;
                }

            }
            int tt = 1;
            if(vis!=s[n].b)
            {
                foc(i,cnt,ans-1)
                {
                    cout << i << " ";
                    t[vis][tt] = i;
                    tt ++;
                }
                cout << ans << endl;
                t[vis][tt] = ans;
            }
            vis ++;
            cnt = ans + 1;
            ans += s[n].b - vis;
            //cout << vis << " " <<  cnt << " " << ans << endl;
        }
        cout << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
int main()
{
 	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='C')
		{
			for(int j=i;j<s.size();j++)
			{
				if(s[j]=='F')
				{
					cout<<"Yes";
					return 0;
				}
			}
		}
	}
	cout<<"No";
	return 0;
}

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

int sumof(int n){
  int sum = 0;
  int ret = n;
  while (ret > 0)
  {
    sum += ret % 10;
    ret /= 10;
  }
  return sum;
}

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

  for (int i = 1; i <= n; i++)
  {
    int ret = sumof(i);
    if (ret >= a && ret <= b){
      sum += i;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)

#define rdi(i) ll i; scanf("%lld", &i)
#define rds(s) string s; cin >> s

#define INF 10000000000

int main()
{
    rdi(a);
    rdi(b);
    rrepp(i, 1, 1000) {
        ll aa = i *  8 / 100;
        ll bb = i * 10 / 100;
        if (aa == a && bb == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(H: int, W: int, s: "List[str]"):
    m = [[0] * W for _ in range(H)]
    for j in range(H):
        for i in range(W):
            if s[j][i] == '#':
                if j < (H - 1) and s[j+1][i] == '#':
                    m[j][i] += 1
                    m[j+1][i] += 1
                if i < (W - 1) and s[j][i+1] == '#':
                    m[j][i] += 1
                    m[j][i+1] += 1
                if m[j][i] == 0:
                    return NO
    return YES


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    s = [ next(tokens) for _ in range(H)]  # type: "List[str]"
    result = solve(H, W, s)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5244
#include <iostream>

int main(int argc, char **argv){
	int S = 0;
	int h = 0;
	int m = 0;
	int s = 0;

	std::cin >> S;

	h = S / 3600;
	S -= 3600 * h;
	m = S / 60;
	S -= 60 * m;
	s = S;

	std::cout << h << ":" << m << ":" << s << std::endl;

	return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, q;
    cin >> n >> m >> q;
    vector<vector<int>> s(n+1, vector<int>(n+1));
    rep(i, m) {
        int l, r;
        cin >> l >> r;
        s[l][r]++;
    }
    rep(i, n) rep(j, n+1) s[i+1][j] += s[i][j];
    rep(i, n+1) rep(j, n) s[i][j+1] += s[i][j];
    auto get_sum = [&](int sy, int sx, int ty, int tx) {
        return s[ty][tx] - s[ty][sx] - s[sy][tx] + s[sy][sx];
    };
    rep(i, q) {
        int a, b;
        cin >> a >> b;
        cout << get_sum(a-1, a-1, b, b) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h> 
using namespace std; 
#include <stack>
#define ll long long 
const ll INF=1000000007;
#define vecpair vector<pair <ll,ll> >
#define pb push_back
#define mp make_pair
#define vel vector<ll>
#define endl "\n"
#define forl for(int i=0;i<n;i++)
const ll MAXN=1000001;
bool prime[1000001];
void SieveOfEratosthenes() 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true.  
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=1000000; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=1000000; i += p) 
                prime[i] = false; 
        } 
    } 
  
    
} 
ll bs(vel a,ll s,ll e,ll x){
	int l=s;
	int h=e;
	int m;
	while(l<=h){
		m=(l+h)/2;
		if(a[m]>x) h=m-1;
		else if(a[m]<x) l=m+1;
		else return m;
		}
		return -1;
	}

ll mex(vel a,int n){
	sort(a.begin(),a.end());
	int j=a[0];
	if(j!=0) return 0;
	else{
		for(int i=1;i<n;i++){
				if(a[i]!=a[i-1]){
					if(a[i]!=a[i-1]+1){
						return j+1;
						}else j++;
					}
			}
			return j+1;
		}
}

int spf[MAXN]; 
  
// Calculating SPF (Smallest Prime Factor) for every 
// number till MAXN. 
// Time Complexity : O(nloglogn) 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 

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

ll c(ll m,ll n){
	ll ans=1;
	for(int i=1;i<=n;i++){
		ans=(ans*(m-i+1))/i;
		}
		return ans;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll test;
test=1;
while(test--){
ll n;
cin>>n;
ll a[n];
for(int i=0;i<n;i++){
	cin>>a[i];
	}
	ll ans=0;
	for(int i=1;i<n;i++){
		if(a[i]<a[i-1]){
			ans+=a[i-1]-a[i];
			a[i]=a[i-1];
			}
		}
		cout<<ans<<endl;
}
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 0; i <= n; i++)
#define REp(i,n) for(ll i = 1; i < n; i++)
#define REP(i,n) for(ll i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

struct Point {
  int x;
  int y;
  int h;
};

int main(){
  int n;
  cin >> n;
  V<Point> v(n);
  Point p;
  rep(i,n) {
    cin >> v[i].x >> v[i].y >> v[i].h;
    if(v[i].h != 0) {
      p.x = v[i].x;
      p.y = v[i].y;
      p.h = v[i].h;
    }
  }
  Rep(i,100) {
    Rep(j,100) {
      int H = p.h + abs(p.x-i) + abs(p.y-j);
      bool ok = true;
      rep(k,n) {
        int tmp = max(H - abs(v[k].x-i) - abs(v[k].y-j), 0);
        if(tmp != v[k].h) ok = false;
      }
      if(ok) {
        cout << i << " " << j << " " << H << endl;
      }
    }
  }
}

Measured memory_bytes: 3608