akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
//#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
#define int long long

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
/*
#pragma comment(linker, "/STACK: 20000000005")
*/


using namespace std;

const int N = 200005, MOD = 998244353;



main()
{
    ios_base::sync_with_stdio(0);
    string s;
    cin >> s;
    string s1 = s;
    reverse (s1.begin(), s1.end());
    if (s1 != s){
        cout << "No" << endl;
        return 0;
    }
    int n = s.size();
    int k = n / 2;
    for (int i = 0; i < k; i++)
    if (s[i] != s[i + k + 1]){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forp(i,a,b) for (int i = (a); i <(b); i++)
#define forn(i,a,b) for (int i = (a); i >(b); i--)
#define mod 1000000007
#define multiple_testcases_t int t;cin>>t;while(t--){solve();}
#define single_testcase_t solve();
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;



// <----- Actual solve() function to print output -----> //
int tc=1;
void solve()
{
   ll n,k=0,z=0,ans=0;
   cin>>n>>k>>z;
   if(k*z>=n)
     cout<<"Yes";
  else
    cout<<"No";
 //  cout<<"\n";      //if t>1 uncomment this
}

// MAIN function --------------------------------------------------------------------------//
int main()
{
    fast_io
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);

  single_testcase_t
 // multiple_testcases_t
return 0;
}





Measured memory_bytes: 3652
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x,a;
    cin >> x >> a;
    if(x<a){
        cout << 0;
    }
    else{
        cout << 10;
    }

    return 0;
}

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

//for loop
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//abbreviati
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//constant
const int INF = 1<<30;
const ll INFLL = 1LL << 60;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***Snippet***************************************************
ifelse, isprime, torad, todeg, lcm, bfs,chmin,chmax
**************************************************************/

//adjacency list
vector<int> to[100005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x; cin >> x;
    if(x>=30) cout << "Yes" ENDL;
    else cout << "No" ENDL;
    
    return 0;
}

Measured memory_bytes: 5988
#include<iostream>
using namespace std;
int main(){
	long long int n,m,ans=1;
	cin>>n>>m;
	if(m-n >= 2 || n-m >= 2){
		cout<<"0"<<endl;
		return 0;
	}
	
	if(m==n){
		ans *= 2;
		for(int i=2; i<=n; i++){
			ans = ans*i%1000000007;
		}
		for(int i=2; i<=m; i++){
			ans = ans*i%1000000007;
		}
	}
	else{
		for(int i=2; i<=n; i++){
			ans = ans*i%1000000007;
		}
		for(int i=2; i<=m; i++){
			ans = ans*i%1000000007;
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int[] as = new int[N];
			
			for(int i = 0; i < N; i++) {
				as[i] = sc.nextInt();
			}
			
			
			long[] DP = new long[N];
			DP[0] = 1000;
			
			for(int to = 1; to < N; to++) {
				
				for(int from = 0; from < to; from++) {
					for(int x1 = from; x1 <= to; x1++) {
						for(int x2 = x1; x2 <= to; x2++) {
							//System.out.println(to + " " + as[x1] + " " + as[x2]);
							DP[to] = Math.max(DP[to], (DP[from] / as[x1]) * as[x2] + (DP[from] % as[x1]));
						}
					}
				}
				
				//System.out.println(Arrays.toString(DP));
			}
			
			System.out.println(DP[N - 1]);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


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

#define INF 100000000
#define MOD9(a) (a%1000000009)
#define MOD7(a) (a%1000000007)
#define ABS(a) (a<0?-(a):a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define REP(i,a) for(int i=0;i<a;i++) 

using namespace std;
int main(){
  string S[3];
  cin >> S[0] >> S[1] >> S[2];
  
  cout << S[0][0] << S[1][0] << S[2][0] << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
  ll n;
  cin >> n;
  ll a[n],b[n];
  FOR(i,0,n-1) cin >> a[i];
  FOR(i,0,n-1) cin >> b[i];

  ll cnt = 0;

  FOR(i,0,n-1){
    if(a[i]<b[i]){
      cnt += (b[i]-a[i])/2;
    }
    else if(b[i]<a[i]){
      cnt -= a[i] - b[i];
    }
  }

  if(cnt>=0) cout << "Yes" << endl;
  else cout << "No" << endl;
}



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

using ll = long long;

#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)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  map<char, string> s; std::cin >> s['a'] >> s['b'] >> s['c'];
  map<char, int> cursor;
  char turn = 'a';
  while (s[turn].size() != cursor[turn]) {
    int i = cursor[turn];
    cursor[turn]++;
    turn = s[turn][i];
  }
  std::cout << (char)(turn-('a'-'A')) << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){//最大公約数を求める
    if(a<b){
        swap(a,b);
    }

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a/g*b;
}


int main(){
    ll n,ans=1,x;//一番大きいTの 倍数を見たい→間に合わない
    cin >> n;
    vector<ll> v(n);
    for(ll i=0;i < n;i++){
        cin >> v.at(i);
        ans= lcm(ans,v.at(i));
    }
    cout << ans << endl;
}
/*二つの整数a,bに対して、
a*b = gcd * lcm が成立*/

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

int main(){
	static int n,t,s,a[3000+2],b[3000+2],dp[3000+2][3000+2];
	scanf("%d%d%d",&n,&t,&s);
	for(int i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);
	for(int i=0;i<n;i++){
		if(i==0){
			dp[0][0]=0;
			for(int j=1;j<=t;j++){
				if(j==b[i])dp[i][j]=a[i];
				else dp[i][j]=dp[i][j-1];
			}
		}
		else {
			dp[i][0]=0;
			for(int j=1;j<=t;j++){
				dp[i][j]=0;
				if(j>=b[i]&&((j<=s&&j-b[i]<=s)||(j>=s&&j-b[i]>=s)))dp[i][j]=dp[i-1][j-b[i]]+a[i];
				dp[i][j]=max(dp[i-1][j],max(dp[i][j],dp[i][j-1]));
			}
		}
	}
	printf("%d\n",dp[n-1][t]);
}

Measured memory_bytes: 36388
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
const ll INF=1e18+7;
const ll MOD=1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	deque<ll> deq;
	ll q;
	cin >> q;
	FOR(i,0,q){
		ll x,y,z;
		cin >> x >> y;
		if(x==0){
			cin >> z;
			if(y==0)deq.push_front(z);
			else deq.push_back(z);
		}
		if(x==1){
			cout << deq[y] << endl;
		}
		if(x==2){
			if(y==1)deq.pop_back();
			else deq.pop_front();
		}
	}
}



Measured memory_bytes: 6252
N = int(input())

primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997]
dic = {p:0 for p in primes}

for i in range(N):
    for j in primes:
        tmp = i + 1
        while(tmp % j == 0):
            tmp = tmp // j
            dic[j] += 1

res = 1
for v in dic.values():
    res = res * (v + 1)
    res = res % 1000000007

print(res)


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N;
  cin >> N;
  int K;
  cin >> K;
  int X;
  int Goukei = 0;
   for(int i = 0; i < N; i++){
     cin >> X;
    if( X * 2 < ( K - X ) * 2 ){
      Goukei +=  X * 2;
    }
     else{
       Goukei += ( K - X ) * 2;
     }
   }
  cout << Goukei << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>

int main()
{
  int n;
  int l;
  int i;
  int sum = 0, max = 0;
  
  scanf("%d",&n);

  for (i = 0; i < n; i++) {
    scanf("%d", &l);
    sum += l;
    if (max < l) {
      max = l;
    }
  }

  sum -= max;

  if (max < sum) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 10000000000000
#define int long long
int d[310][310];
int d2[310][310];
int d3[310][310];
bool need[310][310];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    rep(i, 310) rep(j, 310) d[i][j] = INF2;
    rep(i, n) {
        rep(j, n) {
            cin >> d[i][j];
        }
    }
    rep(i, n) {
        rep(j, n) {
            d2[i][j] = d[i][j];
        }
    }
    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
                d2[i][j] = min(d2[i][j], d[i][k] + d[k][j]); 
            }
        }
    }
    rep(i, n) {
        rep(j, n) {
            if(d[i][j] != d2[i][j]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    rep(i, n) rep(j, n) need[i][j] = true;
    int ans = 0;
    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
                if(i == k || j == k) continue;
                if (d[i][j] == d[i][k] + d[k][j]) need[i][j] = false;
            }
        }
    }
    rep(i, n) {
        rep(j, n) {
            if(need[i][j]) ans += d[i][j];
        }
    }
    cout << ans/2 << endl;

    

    return 0;
}


Measured memory_bytes: 1792
class UnionFind():
    def __init__(self,n):
        self.n = n
        self.parents = [-1]*n

    def find(self,x):
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return
        if self.parents[x]>self.parents[y]:
            x,y=y,x
        self.parents[x]+=self.parents[y]
        self.parents[y]=x
    #木の深さじゃなくxを含む集合の要素数
    def size(self,x):
        return -self.parents[self.find(x)]

    def same(self,x,y):
        return self.find(x)==self.find(y)

    def members(self,x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i)==root]

    def roots(self):
        return [i for i,x in enumerate(self.parents) if x>0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m,k= map(int,input().split())
u = UnionFind(n+1)
atodehiku = [0]*(n+1)

for i in range(m):
    a,b = map(int,input().split())
    u.union(a,b)
    atodehiku[a]+=1
    atodehiku[b]+=1
for i in range(k):
    c,d = map(int,input().split())
    if u.same(c,d):
        atodehiku[c]+=1
        atodehiku[d]+=1

for i in range(1,n+1):
    print(u.size(i)-atodehiku[i]-1)

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

using namespace std;

#pragma GCC optimize "-O3"

#define watch(x) cout << (#x) << " is " << (x) << endl

#define lli     long long int

#define max1 1000001    //10^6 + 1
#define max2 10000001   //10^7 + 1
#define max3 1000000007 //10^9 + 7
#define inf  1000000009 //10^9 + 9

const lli N = 1e5+5;

// std::vector<char> v;
vector<lli> edges[N];
lli in_degree[N];
lli dist[N];
bool visited[N];

void dfs(lli a){
	assert(!visited[a]);
	visited[a] = true;
	for(int b : edges[a]){
		dist[b] = max(dist[b], dist[a]+1);
		--in_degree[b];
		if(in_degree[b] == 0) dfs(b);
	}
}

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

    lli n,m;
    cin >> n >> m;
    lli x,y;
    
    for (lli i = 0; i < m; ++i)
    {
    	cin >> x >> y;
    	edges[x].push_back(y);
    	++in_degree[y];
    }

    for (int i = 1; i <= n; ++i)
    {
		if(!visited[i] && in_degree[i] == 0){
			dfs(i);
		}    	
    }

    lli ma = 0;
    for (lli i = 1; i <= n; ++i)
    {
    		ma = max(ma,dist[i]);
    }
    cout << ma << '\n';
    return 0;
}


Measured memory_bytes: 9984
//#include <ext/pb_ds/assoc_container.hpp> 
 //#include <ext/pb_ds/tree_policy.hpp>
// #include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power(((((a)%mod)*((a)%mod))%mod),b/2)%mod;
    else return (((a)%mod)*(power(((((a)%mod)*((a)%mod))%mod),b/2)%mod))%mod;
}
inline ll inverse(ll a,ll md) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}
  
  
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution
const int ce=1e9+7;
ll fast_mod(ll input)
{
    return input < ce ? input : input%ce;
}
#define pi acos(-1)
bool comp(pair<int,int> p,pair<int,int> p1)
{
    if(p.first!=p1.first)
    {
        return p.first>p1.first;
    }
    else
    {
        return p.second<p1.second;
    }
}
int32_t main()
{
    IOS
 
    int n;
    cin>>n;
    vector<pair<int,int>> v;
    int pre=0,pre1=0;;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        stack<char> s1;
        int c=0,c1=0;
        for(int j=0;j<s.length();j++)
        {
            if(s[j]==')')
            {
                if(int(s1.size())==0)
                {
                    c++;
                }
                else
                {
                    s1.pop();
                }
            }
            else
            {
                s1.push('(');
            }
        }
        while((int)s1.size())
        {
            c1++;
            s1.pop();
        }
        if(c1==0)
        {
            pre1+=c;
            continue;
        }
        if(c==0)
        {
            pre+=c1;
            continue;
        }
        v.push_back({c1-c,c});
    }
    sort(v.begin(),v.end(),comp);
    for(int i=0;i<v.size();i++)
    {
        if(pre<v[i].second)
        {
            cout<<"No"<<endl;
            return 0;
        }
        pre+=v[i].first;
    }   
    if(pre==pre1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}       
    

Measured memory_bytes: 7396
#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;

long long A[100000];
long long diff_A[100000];
long long x[100000];
long long y[100000];
int main(){
    int N;
    cin >> N;

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

    for(int i = 0; i < N; i++){
        diff_A[i] = A[(i + 1) % N] - A[i];
    }
    long long sum_A = accumulate(A, A + N, (long long) 0);
    long long sum_N = (long long) N * (long long)(N + 1) / 2;

    if((sum_A % sum_N) != 0){
        cout << "NO" << endl;
        return 0;
    }
    long long op_num = sum_A / sum_N;

    for(int i = 0; i < N; i++){
        if((op_num - diff_A[i]) < 0 || (op_num - diff_A[i]) % N != 0){
            cout << "NO" << endl;
            return 0;
        }
        y[i] = (op_num - diff_A[i]) / N;
        x[i] = op_num - y[i];
    }

    long long A0 = 0;
    for(int i = 0; i < N; i++){
        A0 += (N - i) * y[i];
    }
    if(A0 == A[0]){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 3328
def solve():
    S = input()
    T = input()
    
    s_counter = sorted([S.count(chr(i)) for i in range(ord('a'), ord('z') + 1)])
    t_counter = sorted([T.count(chr(i)) for i in range(ord('a'), ord('z') + 1)])
    if s_counter == t_counter:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3632
#include <cstdio>
#include <cmath>

int main(){
    int A, B, C, K;
    int max, ans;

    scanf("%d %d %d", &A, &B, &C);
    scanf("%d", &K);

    if(A < B){
        max = B;
    }else{
        max = A;
    }

    if(max < C)
        max = C;

    ans = max * pow(2, K) + A + B + C - max;
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll a,b;
  std::cin>>a>>b;

  std::cout<<std::max(a+b,std::max(a-b,a*b));

  return 0;
}

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


int main() {
  int64_t N;
  cin>>N;
  int64_t x,y;
  for(int i=0;i<sqrt(N);i++){
    int a=sqrt(N)-i;
    if(N%a==0) {
      x=a;
      y=N/a;
      break;
    }
  }  
  cout<<x+y-2<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    void go() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int size = a * b;
        int length = 2 * a + 2 * b;
        System.out.println(size + " " + length);
    }

    public static void main(String[] args) {
        Main cui = new Main();
        cui.go();
    }
}


Measured memory_bytes: 26176
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	var output string
	alfa := []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
	n := nextInt()
	for i := n; i != 0; i /= 26 {
		a := i % 26
		if a == 0 {
			a = 26
		}
		output += alfa[a-1]
		i -= a
	}
	fmt.Fprintf(out, "%s\n", reverse(output))
}

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


Measured memory_bytes: 1812
#include <iostream>
#include <vector>
#include <functional>


int dfs(std::vector<int> &A, int i, int N, int M, std::function<int(const std::vector<int>&)> pred)
{
    if (i == N) return pred(A);

    int max_point = 0;
    int prev = (i == 0) ? 1 : A[i-1];
    for (int j = prev; j <= M; j++)
    {
        A[i] = j;
        int p = dfs(A, i+1, N, M, pred);
        max_point = std::max(max_point, p);
    }
    return max_point;
}


int main()
{
    int N, M, Q;
    std::cin >> N >> M >> Q;
    std::vector<int> a(Q), b(Q), c(Q), d(Q);
    for (int i = 0; i < Q; i++)
        std::cin >> a[i] >> b[i] >> c[i] >> d[i];

    std::vector<int> A(N);

    int ans = dfs(A, 0, N, M,
    [&](const std::vector<int> &A)
    {
        int p = 0;
        for (int i = 0; i < Q; i++)
        {
            if (A[b[i]-1] - A[a[i]-1] == c[i])
                p += d[i];
        }
        return p;
    });

    std::cout << ans << std::endl;
}


Measured memory_bytes: 3620
N = int(input())
a_i = list(map(int, input().split(' ')))

x = []
y = []

if N%2==0:
    for j in range(int(N/2)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        y.append(max(a_i))
        a_i.remove(max(a_i))

else:
    for j in range(int((N/2)+1)):
        x.append(max(a_i))
        a_i.remove(max(a_i))
        if a_i == []:
            break
        y.append(max(a_i))
        a_i.remove(max(a_i))

X = sum(x)
Y = sum(y)


if X >= Y:
    print(X - Y)

else:
    print(Y - X)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
typedef vector<vector<ll>> Graph;
typedef vector<pii> vpii;


int main() {
  ll N; cin>>N;
  vi A(N); REP(i,N) cin>>A[i];
  ll ans=1;
  REP(i,N) ans*=3;
  ll x=1;
  REP(i,N) if(A[i]%2==0) x*=2;
  cout<<ans-x<<endl;

}


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

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

    vector<long long> a(n);
    for (auto& x : a) cin >> x;

    long long lcm = a[0];
    for (int i = 1; i < n; i++) {
        if (lcm % a[i]) {
            lcm = a[i] / __gcd(lcm, a[i]) * lcm;
        }
    }

    cout << lcm << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

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

#include <iostream>

int main()
{
	int x, y, z;
	cin >> x >> y >> z;

	cout << x * y / 2 << endl;
}

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

using namespace std;
using ll = long long;

vector<ll> runtable;

bool is_runnum(string s){
    ll t=stoll(s);
    int l=t%10;
    bool ok=true;
    while(t>0){
        if(t%10+1!=l&&t%10-1!=l&&t%10!=l){
            ok=false;
            break;
        }
        l=t%10;
        t/=10;
    }
    return ok;
}

void dfs(int k,string s) {
    if(s.size()>=11)return;
    runtable.push_back(stoll(s));
    for(int i = max(0,k-1);i <= min(9,k+1);++i) {
        dfs(i,s+to_string(i));
    }
}

int main() {
    runtable.resize(0);
    for(int i = 1;i < 10;++i) {
        dfs(i,to_string(i));
    }
    sort(runtable.begin(),runtable.end());
    int k;
    cin>>k;
    cout<<runtable[k-1]<<endl;
    return 0;
}


Measured memory_bytes: 2420
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x){
  S[++top] = x;
}

int pop() {
  top--;return S[top+1];
}

int main(){
  int a,b;
  top = 0;
  char s[100];

  while(scanf("%s",s) != EOF) {
    if(s[0] =='+'){
      a = pop();
      b = pop();
      push(a+b);
    }else if(s[0] == '-'){
      b = pop();
      a = pop();
      push(a-b);
    }else if(s[0] == '*'){
      a=pop();
      b=pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }

  printf("%d\n",pop());

  return 0;
}

Measured memory_bytes: 548
def main():
    a,b,c = map(int,input().split())
    if a==b==c:
        if a%2==0:
            print(-1)
        else:
            print(0)
    else:
        cnt = 0
        while 1:
            if a%2==1 or b%2==1 or c%2==1:
                print(cnt)
                exit()
            kari_a = (b+c)/2
            kari_b = (c+a)/2
            kari_c = (a+b)/2
            a,b,c = kari_a,kari_b,kari_c
            cnt += 1
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> A(N+2), d(N+2);
    for(int i=1; i<=N; i++) {
        cin >> A[i];
    }

    for(int i=1; i<=N+1; i++) {
        d[i] = abs(A[i-1] - A[i]);
    }
    partial_sum(d.begin(), d.end(), d.begin());
    for(int i=1; i<=N; i++) {
        cout << d[i-1] + abs(A[i-1] - A[i+1]) + d[N+1] - d[i+1] << endl;
    }
    return 0;
}


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

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			int a = Integer.parseInt(br.readLine());
			int b = Integer.parseInt(br.readLine());
			int c = Integer.parseInt(br.readLine());
			int d = Integer.parseInt(br.readLine());
			int e = Integer.parseInt(br.readLine());
			int k = Integer.parseInt(br.readLine());


			 System.out.println(e-a>k?":(":"Yay!");
		}
	}
}

Measured memory_bytes: 25128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	ll n,y;
	cin>>n>>y;
	y=y/1000;
	if(y<n||y>10*n){
		cout<<-1<<" "<<-1<<" "<<-1<<endl;
		return 0;
	}
	for(int i=0;i<=n;i++){
		if(y>=i*10)
		for(int j=0;j<=n-i;j++){
				if(i*10+j*5+n-i-j==y){
					cout<<i<<" "<<j<<" "<<n-i-j<<endl;
					return 0;
				}
		}
	}
	cout<<-1<<" "<<-1<<" "<<-1<<endl;


return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <functional>

using namespace std;

/*-------------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)					(a).begin(),(a).end()
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						(1000 * 1000 * 1000 * 2)
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
/* 約数の列挙 */
vector<ll> divisorExec(ll n)
{
	vector<ll> res;
    for(ll i = 1; i <= sqrt(n); i++){
		if ((n % i) == 0) {
			res.push_back(i);
			if ((i * i) != n) {
				res.push_back(n / i);
			}
		}
	}
	sort(res.begin(), res.end());
	return res;
}

/* 桁数を返す */
ll find_digits(ll n)
{
	ll digit = 0;

	while(n) {
		n /= 10;
		digit++;
	}
	return digit;
}

// メイン
int main()
{
	ll N;
	cin >> N;
	vector<ll> yakusu = divisorExec(N);

	ll ans = INF;
	for(ll i = 0; i <  yakusu.size(); i++) {
		for (ll j = yakusu.size() - 1; 0 <= j; j--) {
			if (N == yakusu[i] * yakusu[j]) {
				ll digitOne1 = find_digits(yakusu[i]);
				ll digitOne2 = find_digits(yakusu[j]);
				ll ansOne = max(digitOne1, digitOne2);
				ans = min(ans, ansOne);
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
from itertools import permutations
from math import sqrt, pow, factorial

def length(a, b):
    x1, y1 = a
    x2, y2 = b
    return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2))

N = int(input())
xy = []
for i in range(N):
    xy.append(list(map(int, input().split())))
    
ans = 0
for order in permutations(range(N)): # 経路全探索
    tmp = 0
    for i in range(1, N):
        tmp += length(xy[order[i]], xy[order[i - 1]])
    ans += tmp
    
ans /= factorial(N)
print(ans)

Measured memory_bytes: 3064
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
b = gets.chomp

if b == 'A'
  puts 'T'
elsif b == 'T'
  puts 'A'
elsif b == 'C'
  puts 'G'
elsif b == 'G'
  puts 'C'
end


Measured memory_bytes: 2300
w, h, q = map(int, input().split())

x_list = []
for i in range(w+1):
    x_list += [i]
    
y_list = []
for i in range(h+1):
    y_list += [i]  

for i in range(q):
    a, b, c = map(int, input().split())
    if (c == 1):
        x_list = [x for x in x_list if x >= a]
    elif (c == 2):
        x_list = [x for x in x_list if x <= a]
    elif (c == 3):
        y_list = [y for y in y_list if y >= b]
    elif (c == 4):
        y_list = [y for y in y_list if y <= b]

output = 0
if (x_list != [] and y_list != []):
    output = (max(x_list)-min(x_list)) * (max(y_list)-min(y_list))
    
print(output)

Measured memory_bytes: 38768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i,n) for(int i=0;i<n;i++)
#define chmax(x, y) x = max(x,y);

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

struct Edge
{
  int a, b, cost;

  // コストの大小で順序定義
  bool operator<(const Edge& o) const {
    return cost < o.cost;
  }
};




int main(){
  int n;
  cin>>n;
  vector <pair<ll,pair<ll,ll>>> a,b;
  vector <Edge> es;
  rep(i,n){
    ll x,y;
    cin>>x>>y;
    a.emplace_back(make_pair(x,make_pair(y,i)));
    b.emplace_back(make_pair(y,make_pair(x,i)));
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());


  for (ll i=1;i<n;i++){
    Edge e1,e2;
    e1.a=a[i-1].second.second;
    e1.b=a[i].second.second;
    e1.cost=a[i].first-a[i-1].first;
    es.emplace_back(e1);
    e2.a=b[i-1].second.second;
    e2.b=b[i].second.second;
    e2.cost=b[i].first-b[i-1].first;
    es.emplace_back(e2);

  }
  sort(es.begin(),es.end());
  UnionFind tree(n);
  ll ans=0;
  ll s=1;
  rep(i,es.size()){
    if (tree.same(es[i].a,es[i].b)) continue;
    ans+=es[i].cost;
    s+=1;
    tree.unite(es[i].a,es[i].b);
    if (s==n) break;

  }
  cout<<ans;



}


Measured memory_bytes: 11812
#include <iostream>
#include <set>
using namespace std;
int main(void){
    int N, a;
    set<int> s;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> a;
        decltype(s)::iterator it = s.find(a);
        if(it != s.end()){
            s.erase(a);
        }
        else{
            s.insert(a);
        }
    }
    
    cout << s.size() << std::endl;
}


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

const long long int ten[10]={1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000};

long long int coder(vector<int> &vec){
	long long int res=0;
	for(int i=0;i<vec.size();i++){
		res*=10;
		res+=vec[i];
	}
	return res;
}

long long int get(long long int val,int level){
	return (val/ten[level])%10;
}

void swapp(long long int &val,int lhs,int rhs){
	int lval=get(val,lhs);
	int rval=get(val,rhs);
	val=val-(lval*ten[lhs]+rval*ten[rhs])+(lval*ten[rhs]+rval*ten[lhs]);
	return;
}

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]--;
	}
	vector<int> object(n);
	iota(object.begin(),object.end(),0);
	long long int ob=coder(object);
	map<long long int,int> dp[2];
	for(int loop=0;loop<2;loop++){
		long long int first;
		if(loop==0) first=coder(a);
		else first=ob;
		dp[loop][first]=0;
		queue<pair<long long int,int>> q;
		q.push(make_pair(first,0));
		while(!q.empty()){
			auto state=q.front();
			q.pop();
			if(state.second>=4) continue;
			
			//odd
			for(int i=0;i<n;i++){
				auto b=state.first;
				for(int j=0;j<n;j++){
					if(!(0<=i-j && i+j<n)) break;
					swapp(b,i-j,i+j);
					if(!dp[loop].count(b)){
						dp[loop][b]=state.second+1;
						q.push(make_pair(b,state.second+1));
					}
				}
			}
			
			//else
			for(int i=0;i<n-1;i++){
				auto b=state.first;
				for(int j=0;j<n;j++){
					if(!(0<=i-j && i+j+1<n)) break;
					swapp(b,i-j,i+j+1);
					if(!dp[loop].count(b)){
						dp[loop][b]=state.second+1;
						q.push(make_pair(b,state.second+1));
					}
				}
			}


		}
	}
	int res=9;
	for(auto it=dp[0].begin();it!=dp[0].end();it++){
		if(!(dp[1].count(it->first))) continue;
		res=min(res,(it->second)+(dp[1].find(it->first)->second));
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 38844
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
//using namespace boost::multiprecision;  
//using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

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

    int n, q;
    cin >> n >> q;

    vector<int> a(n + 1);

    reps(i,n){
        cin >> a[i];
    }

    vector<tuple<int, int, int> > querys;

    rep(i,q){
        int l, r;
        cin >> l >> r;
        querys.emplace_back(r, l, i);
    }

    sort(all(querys));

    vector<int> v(n + 1), res(q);
    BinaryIndexedTree<int> bit(n + 5);

    int R = 1;
    for(auto &&[r, l, query_num] : querys){
        for(; R <= r; ++R){
            if(v[a[R]] != -1){
                bit.add(v[a[R]], -1);
            }
            v[a[R]] = R;
            bit.add(R, 1);
        }
        res[query_num] = bit.sum(r) - bit.sum(l-1);
    }

    for(auto &&e : res){
        cout << e << '\n';
    }

    return 0;
}



Measured memory_bytes: 31096
#include <bits/stdc++.h>
using namespace std;
int main(void){
	int x,y;
	scanf("%d%d",&x,&y);
	int z=x+y;
	int e=1;
	for(int i=0;i<z;i++){
		e*=2;
	}
	int a[z];
	int c,h,f;
	int xx,yy;
	for(int i=0;i<e;i++){
		c=i;
		h=0;
		for(int j=z-1;j>=0;j--){
			a[j]=c%2;
			c/=2;
		}
		for(int j=0;j<z;j++){
			if(a[j])h++;
		}
		if(h==y){
			f=1;
			xx=0;yy=0;
			for(int j=0;j<z;j++){
				if(a[j])xx++;
				else yy++;
				if(xx==5&&yy<=3&&j!=z-1)f=0;
				if(yy==5&&xx<=3&&j!=z-1)f=0;
			}
			if(f){
				for(int j=0;j<z;j++){
					if(a[j])printf("B");
					else printf("A");
				}
				printf("\n");
			}
		}
	}
}


Measured memory_bytes: 3156
#include <iostream>

using namespace std;

int main() {
  while (true) {
    int n, m;
    int map[21][21] = {};

    cin >> n;
    if (n == 0)
      break;

    for (int i = 0; i < n; ++i) {
      int x, y;
      cin >> x >> y;
      map[x][y] = 1;
    }

    int cx = 10;
    int cy = 10;
    map[cx][cy] = 0;

    cin >> m;
    for (int i = 0; i < m; ++i) {
      int dx, dy, d;
      char c;
      cin >> c >> d;

      for (int j = 0; j < d; ++j) {
        dx = (c == 'S' || c == 'N') ? 0 : (c == 'W') ? -1 : 1;
        dy = (c == 'E' || c == 'W') ? 0 : (c == 'S') ? -1 : 1;
        cx = ((cx + dx > 20) || (cx + dx < 0)) ? cx : (cx + dx);
        cy = ((cy + dy > 20) || (cy + dy < 0)) ? cy : (cy + dy);
        map[cx][cy] = 0;
      }
    }

    int cnt = 0;
    for (int i = 0; i < 21; ++i)
      for (int j = 0; j < 21; ++j)
        if (map[i][j])
          ++cnt;

    cout << ((cnt) ? "No" : "Yes") << endl;
  }
}


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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

int64 n, a[100010], b[100010], x[100010];

int64 s = 0;

int main()
{
	gi(n);
	for (int i = 1; i <= n; ++i) gi(a[i]), s += a[i];
	if (s % ((n + 1LL) * n / 2) != 0)
	{
		puts("NO");
		return 0;
	}
	s /= ((n + 1LL) * n / 2);
	int64 all = s, allx = s * (n - 1);
	for (int i = 1; i <= n; ++i)
	{
		if ((s + a[i] - a[i % n + 1]) % n != 0)
		{
			puts("NO");
			return 0;
		}
		int64 y = (s + a[i] - a[i % n + 1]) / n;
		int64 x = s - y;
		if (y > all || x > allx)
		{
			puts("NO");
			return 0;
		}
		all -= y;
		allx -= x;
		b[i % n + 1] = y;
	}
	if (all || allx) return puts("NO"), 0;
	int64 cnt = 0, tag = 0;
	for (int i = 1; i <= n; ++i)
	{
		cnt += b[i];
		tag += cnt;
		x[i] += tag;
		if (x[i] > a[i])
		{
			puts("NO");
			return 0;
		}
	}
	for (int i = 1; i <= n; ++i)
	{
		cnt -= b[i];
		tag += cnt;
		if (b[i]) tag -= n * (b[i]);
		x[i] += tag;
		//cerr << x[i] << endl;
		if (x[i] != a[i])
		{
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	return 0; 
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{

  vector<int> v(5);
  rep(i, 5) cin >> v[i];
  int k;
  cin >> k;
  sort(v.begin(), v.end());
  if (v[4] - v[0] <= k)
    pr("Yay!");
  else
    pr(":(");
  return 0;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

void solve() {
    ll a, b, n;
    cin >> a >> b >> n;

    ll x;
    if (n < b) {
        x = n;
    } else {
        x = b - 1;
    }

    cout << (floor(a * x / b)) << endl;
}

int main() {
    solve();

    return 0;
}


Measured memory_bytes: 3788