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

public class Main {
	int Q;
	long r,l;
	public void solve() {
		Q = nextInt();
		r = 0;
		l = 0;
		for(int i = 0;i < Q;i++){
			long p = nextLong();
			String c = next();
			int n = nextInt();
			
			if(c.equals("(")){
				r += n;
			}else{
				l += n;
			}
			
			if(r == l){
				out.println("Yes");
			}else{
				out.println("No");
			}
		}
	}
 
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}
		/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 31532
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(a<b){
            for(int i = 0;i<b;i++){
                System.out.print(a);
            }
        }else{
            for(int i = 0;i<a;i++){
                System.out.print(b);
            }
        }


    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
using namespace std;
    
   
    
int main(){
    
    int n; 
    int r[1000],w[1000];
    int sum_r=0,sum_w=0,idx=0;
     
    while(scanf("%d",&n),n){
          
        sum_r=sum_w=idx=0;
        for(int i=0;i<n;i++){
            scanf("%d %d",&r[i],&w[i]);
            sum_r+=r[i];
            sum_w+=w[i];
            if(r[idx]<r[i]) idx=i;
        }
   
        int r0=r[idx],r=sum_r-r0;
        w[idx]=0;
  
        if(r0 <= r){
            cout<<sum_r+sum_w<<endl;
        }else{
   
            int res=2*r0;
            //vector<vector<bool> > dp(1001,vector<bool>(1000,false));
   
//          bool cur[1001]={};
            bool *cur = (bool*)malloc( r0-r+2 );
            cur[0]=true;
            for(int i=0;i<n;i++){
                bool *next = (bool*)malloc( r0-r+2 );
                for(int j=0;j<=r0-r;j++){
                    if(cur[j]){
                        next[j]=true; 
                        if(j+w[i]<=r0-r)
                            next[j+w[i]]=true; 
                    }
                }
                swap(cur,next);
            }
   
            int opt=r0-r;
            while(!cur[opt]) opt--;
   
            res+=sum_w-opt;
            printf("%d\n",res);
   
   
   
        }
           
           
    }
}

Measured memory_bytes: 4964
# coding: utf-8
# Your code here!
import itertools

A = int(input())
B = int(input())
C = int(input())
X = int(input())

num=0

for i, j, k in itertools.product(range(A+1), range(B+1), range(C+1)):
    if i*500 + j*100 + k*50 == X:
        num += 1
#        print(i,j,k)

print(num)
    


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;

int main(){
   int n,k;
   cin>>n>>k;
   ll ans=1001001001;
   rep(i,0,n+1){
      ll N=1;
      int a=i,b=n-i;
      rep(i,0,a) N*=2;
      rep(i,0,b) N+=k;
      ans=min(ans,N);
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    string s;
    cin >> s;
    vi dp(s.size() + 1);
    set<int> ss;
    int cnt = 0;
    priority_queue<i64, vi, greater<>> que[26];
    for (int i = s.size() - 1; i >= 0; i--) {
        ss.insert(s[i]);
        que[s[i] - 'a'].push(i + 1);
        dp[i + 1] = cnt;
        if (ss.size() == 26) {
            ss = set<int>();
            cnt++;
        }
    }
    dp[0] = cnt;
    
    string ans = "";
    int cur = 0;
    int target = dp[0];
    
    while (1) {
        for (int i = 0; i < 26; i++) {
            while (que[i].size() && que[i].top() < cur) {
                que[i].pop();
            }
            if (target == 0) {
                if (que[i].empty()) {
                    ans += 'a' + i;
                    cout << ans << endl;
                    return 0;
                }
            } else {
                if (dp[que[i].top()] < target) {
                    ans += 'a' + i;
                    cur = que[i].top();
                    target = dp[cur];
                    que[i].pop();
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 3972
#include<iostream>
#include<algorithm>
using namespace std;
int a[127]={};
char s[30];
int main(){
	cin >> s;
	int l=1;
	for(int i=0;s[i]!='\0';i++)	a[s[i]]=1,l++;
	for(int c='z';c>='a';c--)
		if(!a[c]) s[l++]=c;
	cout << ((next_permutation(s,s+l)) ? s : "-1") << endl;
}


Measured memory_bytes: 256
import sys
iN = int(input())
aList = [x.strip() for x in sys.stdin.readlines()]



dicList = {aList[0]:1}
for i in range(1,iN):
    if aList[i][0] != aList[i-1][-1] :
        print("No")
        exit()
    if aList[i] not in dicList :
        dicList[aList[i]] = 0
    else:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
	char*s[]={"black","blue","lime","aqua","red","fuchsia","yellow","white"},x;
	int n;
	while(scanf(" %c%x",&x,&n),x-'0')
		puts(s[((n>>16)>127)*4+((n&0xff00)>32767)*2+((n&255)>127)]);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

ll dp[100005][13];
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   string s;
   cin >> s;
   int n = s.size();
   reverse(s.begin(), s.end());

   ll mul = 1;
   dp[0][0] = 1;
   rep(i, 0, n) {
      if (s[i] == '?') {
         rep(j, 0, 10) {
            rep(k, 0, 13) {
               (dp[i + 1][(j * mul + k) % 13] += dp[i][k]) %= MOD;
            }
         }
      } else {
         int num = (int)(s[i] - '0');
         rep(j, 0, 13) { (dp[i + 1][(num * mul + j) % 13] += dp[i][j]) %= MOD; }
      }
      mul *= 10;
      mul %= 13;
   }
   cout << dp[n][5] << endl;
   return 0;
}

Measured memory_bytes: 10704
#include<iostream>
#include<queue>

using namespace std;
#define MAX 64

typedef pair<int,int> pi;

const int di[] = {-1,0,1,0};
const int dj[] = {0,1,0,-1};

bool isinside(pi pos, int H, int W){
  return 0<=pos.first && pos.first<H && 0<=pos.second && pos.second<W;
}
class State{
public:
  pi taka;
  pi kazu;
  int time;
  State( pi taka, pi kazu, int t ):taka(taka),kazu(kazu),time(t){}
};

int bfs(int sti, int stj, int ski, int skj, int H, int W, bool M[][MAX]){
  static bool vis[50][50][50][50];
  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){
      for(int k = 0; k < H; ++k){
	for(int l = 0; l < W; ++l){
	  vis[i][j][k][l] = false;
	}
      }
    }
  }

  State st(pi(sti,stj),pi(ski,skj),0);
  queue<State> qs;
  qs.push( st );
  vis[sti][stj][ski][skj]=true;
  while(!qs.empty()){
    State now = qs.front();
    qs.pop();
    //cout << now.taka.first << ' ' << now.taka.second << ' ' << now.kazu.first << ' ' << now.kazu.second << endl;
    if( now.taka.first == now.kazu.first && now.taka.second == now.kazu.second ){
      return now.time;
    }
    for(int k = 0; k < 4; ++k){
      pi ntaka( now.taka.first+di[k],       now.taka.second+dj[k] );
      pi nkazu( now.kazu.first+di[(k+2)%4], now.kazu.second+dj[(k+2)%4]);

      if( !isinside(ntaka,H,W ) ){
	ntaka = now.taka;
      }else{
	if( M[ntaka.first][ntaka.second] )
	  ntaka = now.taka;
      }

      if( !isinside(nkazu,H,W ) ){
	nkazu = now.kazu;
      }else{
	if( M[nkazu.first][nkazu.second] )
	  nkazu = now.kazu;
      }

      if( !vis[ntaka.first][ntaka.second][nkazu.first][nkazu.second] ){
	vis[ntaka.first][ntaka.second][nkazu.first][nkazu.second] = true;
      
	State next( ntaka, nkazu, now.time+1 );
	qs.push( next );
      }
    }
  }
  return -1;
}

int main()
{
  while(true){
    int H, W;
    
    cin >> H >> W;
    swap(H,W);
    if( H == 0 && W == 0 ) break;
    bool m[MAX][MAX];
    int tx,ty;
    int kx,ky;
    cin >> tx >> ty;
    cin >> kx >> ky;
    --tx;--ty;--kx;--ky;
    for(int i = 0; i < H; ++i){
      for(int j = 0; j < W; ++j){
	int t;
	cin >> t;
	if( t == 1 )
	  m[i][j] = true;
	else
	  m[i][j] = false;
      }
    }
    int ans = bfs( ty, tx, ky, kx, H, W, m);
    if( ans < 0 ){
      cout << "NA" << endl;
    }
    else{
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 7328
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

const int INF = pow(2, 31) - 1;
#define ll long long
#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  REP(i, N) {
    cin >> A[i];
  }
  REP(i, N) {
    cin >> B[i];
  }
  REP(i, N) {
    cin >> C[i];
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  ll ans = 0;
  REP(j, N) {
    vector<int>::iterator ita = lower_bound(A.begin(), A.end(), B[j]);
    vector<int>::iterator itb = upper_bound(C.begin(), C.end(), B[j]);
    ans += distance(A.begin(), ita) * (N - distance(C.begin(), itb));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
    #define ll long long
    #define mod 1000000007
    #define maxn 200005
    #define vi vector<int>
    #define vl vector<ll>
    #define mii map<int,int>
    #define mli map<ll,int>
    #define forit(it,v) for(auto it=v.begin();it!=v.end();++it)
    #define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
    using namespace std;
    void solve()
    {
        int n,r=0;
        string x;
        cin>>n>>x;
        for (int i = 0; i < n; ++i)
        {
            if (x[i]=='R')
            {
                r++;
            }
        }
        int o=0;
        for (int i = 0; i < r;i++)
        {
            if (x[i]=='W')
            {
                o++;
            }
        }
        cout<<o;
    }
    int main()
    {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
        fastIO;
        // sieve();
        int t=1;
        // int t;
        // cin>>t;
        while(t--)
        {
            solve();
        }
        return 0;
    }

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  int tmp = N;
  while (true) {
    sum += tmp % 10;
    tmp /= 10;
    if (tmp == 0) break;
  }
  if (N % sum == 0)
    cout << "Yes";
  else
    cout << "No";
}

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

int sx, sy, tx, ty;

int solve(){
	int column, row;
	row = tx - sx;
	column = ty - sy;

	for(int i=0; i<column; i++){
		cout << 'U';
	}
	for(int i=0; i<row; i++){
		cout << 'R';
	}
	for(int i=0; i<column; i++){
		cout << 'D';
	}
	for(int i=0; i<row; i++){
		cout << 'L';
	}
	cout << 'L';
	for(int i=0; i<column+1; i++){
		cout << 'U';
	}
	for(int i=0; i<row+1; i++){
		cout << 'R';
	}
	cout << 'D';
	cout << 'R';
	for(int i=0; i<column+1; i++){
		cout << 'D';
	}
	for(int i=0; i<row+1; i++){
		cout << 'L';
	}
	cout << 'U' << endl;
	return 0;

}


int main(){
	cin >> sx >> sy >> tx >> ty;

	solve();
	return 0;
}

Measured memory_bytes: 256
s = input().split()
A = int(s[0])
B = int(s[1])
C = int(s[2])
D = int(s[3])
 
a_c = max(A, C)
b_d = min(B, D)
 
if b_d - a_c > 0:
  print(b_d - a_c)
else:
  print("0")

Measured memory_bytes: 3064
n = int(input())
posdata = [list(map(int,input().split())) for i in range(n)]
nowpos = [0,0,0]

for i in range(n):
    diff = posdata[i][1] - nowpos[1] + posdata[i][2] - nowpos[2]
    l_parity = diff % 2
    t_parity = (posdata[i][0] - nowpos[0]) % 2
    
    if (posdata[i][0] - nowpos[0]) >= diff and l_parity == t_parity:
        nowpos = posdata[i]
    else:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 27300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  ll n;
  cin>>n;
  vector<ll> a(n), b(n);
  REP(i, n) { cin >> a[i] >> b[i]; }
  ll m=-1,t;
  REP(i, n) {
    if (a[i] > m){ t = i;m=a[i];}
  }
  cout <<  a[t]+b[t]<< endl;

  return 0;
}


Measured memory_bytes: 4824
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int X,Y,A,B,C;
MinHeap<LL> p1, p2;
MaxHeap<LL> p3;
vector<LL> AA,BB;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> X >> Y >> A >> B >> C;
    REP(i,A) {
        LL a;
        cin >> a;
        AA.push_back(a);
        p1.push(a);
    }

    REP(i,B) {
        LL a;
        cin >> a;
        BB.push_back(a);
        p2.push(a);
    }

    REP(i,C) {
        LL a;
        cin >> a;
        p3.push(a);
    }

    while(p1.size()>X) p1.pop();
    while(p2.size()>Y) p2.pop();
    


    while(p3.size()) {
        LL c=p3.top(); p3.pop();
        if( p1.top()==p2.top() ){
            LL x=p1.top();
            auto it1=upper_bound(ALL(AA),x);
            auto it2=upper_bound(ALL(BB),x);
            if( it1==AA.end() ){
                p1.pop();
                p1.push(c);
            } else if( it2==BB.end() ) {
                p2.pop();
                p2.push(c);
            } else if( *it1 < *it2 ) {
                p1.pop();
                p1.push(c);                
            } else {
                p2.pop();
                p2.push(c);
            }
        }
        else if(p1.top()<p2.top()) {
            if(c>p1.top()) {
                p1.pop();
                p1.push(c);
            }
        }
        else if(p1.top()>p2.top()) {
            if(c>p2.top()) {
                p2.pop();
                p2.push(c);
            }
        }
    }
    LL ans=0;
    while(p1.size()) {
        // cout << p1.top();
        ans+=p1.top(); p1.pop();
    }
    while(p2.size()) {
        // cout << p2.top();
        ans+=p2.top(); p2.pop();
    }
    cout << ans << '\n';
    return 0;
}

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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int main(){
	ios::sync_with_stdio(false);
	string a;
	cin>>a;
	int cnt=0,ans=0;
	string b=a;
	int n=a.size();
	if(a[0]!='1')ans++;
	for(int i=1;i<n;i++){
		if(a[i]==a[i-1]){
			ans++;
			a[i]=(a[i-1]=='1'?'0':'1');
		}
	}
	if(b[0]!='0')cnt++;
	for(int i=1;i<n;i++){
		if(b[i]==b[i-1]){
			cnt++;
			b[i]=(b[i-1]=='1'?'0':'1');
		}
	}	
	cout<<min(ans,cnt);
	return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
int N,C[30],V[30],ans;
int i,j;
int main(){
    scanf("%d", &N);
    fornum(i,0,N){
        scanf("%d", &V[i]);
    }
    fornum(i,0,N){
        scanf("%d", &C[i]);
        if(C[i]<V[i]){
            ans += V[i] - C[i];
        }
    }
    
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200009
using namespace std;
typedef long long LL;
const LL mod = 1e9+7;

vector<int> mp[N];
typedef pair<int, int> P;

void bfs(int n)
{
    queue<P> q;
    int vis[N];
    memset(vis, 0, sizeof(vis));
    vis[1] = 1; vis[n] = 2;
    int a = 0, b = 0;
    q.push(P{1, 1}); q.push(P{n, 2});
    while(!q.empty())
    {
        P cur = q.front(); q.pop();
        for(int j = 0; j < mp[cur.first].size(); j++)
        {
            int v = mp[cur.first][j];
            if(!vis[v])
            {
                q.push(P{v, cur.second});
                vis[v] = cur.second;
            }
        }
    }
    for(int i = 1; i <= n; i++)
    {
        if(vis[i] == 1) a++;
        if(vis[i] == 2) b++;
    }
    if(a > b) puts("Fennec");
    else puts("Snuke");
}

int main()
{
    int n, u, v;
    scanf("%d", &n);
    for(int i = 1; i < n; i++)
    {
        scanf("%d%d", &u, &v);
        mp[u].push_back(v);
        mp[v].push_back(u);
    }
    bfs(n);
    return 0;
}


Measured memory_bytes: 9088
using System;
using System.Linq;

namespace ABC072_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var b = new int[100001];
            for (int i = 0; i < N; i++)
            {
                b[a[i]]++;
            }

            var m = 0;
            for (int i = 1; i < 100000; i++)
            {
                var s = b[i] + b[i - 1] + b[i + 1];
                if (s > m) m = s;
            }
            Console.WriteLine(m);
        }
    }
}


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

/*------------------------------------------------------------------*/

#define ll long long int
#define mp make_pair
#define pb push_back
#define MOD 1000000007

bool isvowel(char c)
{
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
        return true;
        return false;
}
ll isprime(ll n)
{
    ll ans=1;
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            ans = i;
    }
    return ans;
}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    if(b==1)
        return a%m;
    ll temp=power(a,b/2,m);
    if(b%2==0)
        return ((temp%m)*(temp%m))%m;
    else
        return ((((temp%m)*(temp%m))%m)*a%m)%m;
}

/*-----------------------------------------------------------------------------*/

ll c(ll n, ll k)
{
    ll C[n + 1][k + 1];
    ll i, j;

    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= min(i, k); j++)
        {

            if (j == 0 || j == i)
                C[i][j] = 1;

            else
                C[i][j] = (C[i - 1][j - 1]%MOD +
                          C[i - 1][j])%MOD;
        }
    }
    return C[n][k]%MOD;
}
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {

        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;


        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;

    return x;
}
ll func(ll n)
{
    ll ans=0;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            if(i/10==0)
                ans+=1+func(i)*func(n/i);
            else
                ans+=func(i)*func(n/i);
        }
    }
    return ans;
}
ll dp[205][205][205];
ll check(ll red[],ll gre[],ll blu[],ll r,ll g,ll b,ll i,ll j,ll k)
{
   if(dp[i][j][k]!=-1)
    return dp[i][j][k]; 
   if(i<r&&j<g&&k<b)
   {
       return dp[i][j][k]=max(red[i]*gre[j]+check(red,gre,blu,r,g,b,i+1,j+1,k),max(gre[j]*blu[k]+check(red,gre,blu,r,g,b,i,j+1,k+1),blu[k]*red[i]+check(red,gre,blu,r,g,b,i+1,j,k+1)));
   }
   else if(i<r&&j<g) 
   {
       return dp[i][j][k]=red[i]*gre[j]+check(red,gre,blu,r,g,b,i+1,j+1,k);
   }
   else if(j<g&&k<b)
   {
       return dp[i][j][k]=gre[j]*blu[k]+check(red,gre,blu,r,g,b,i,j+1,k+1);
   }
   else if(i<r&&k<b)
   {
       return dp[i][j][k]=red[i]*blu[k]+check(red,gre,blu,r,g,b,i+1,j,k+1);
   }
   else
   {
       return 0;
   }
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    //freopen("1.txt","rt",stdin);
    //freopen("output.txt","wwt",stdout);

    ll t;
    t=1;
    //cin>>t;
    //ll t1=0;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        ll a[m];
        ll sum=0;
        for(ll i=0;i<m;i++)
        {
            cin>>a[i];
            sum+=a[i];
        }
        if(sum>n)
         cout<<"-1";
        else
         cout<<n-sum; 
    }
}


Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N, cnt = 0, ans = 0, tmp = 0;
    int x, y;
    cin >> x >> y;
    ans = x + y / 2;
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include<iostream>
#include <cstdio>
#include<cmath>
using namespace std;
signed main(void)
{
	int n,ans=0,num=0;
	cin>>n;
	for(int i=1;pow(10,i)<=n*10;i+=2)
		ans+=(pow(10,i)-pow(10,i-1));
	int x=n;
	while(x)
	{
		x/=10;
		num++;
	}
	if(num&1)
		ans-=(pow(10,num)-n-1);
	cout<<ans<<endl;
	return 0;
}


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

const ll infll=9223372036854775806;
const int inf=2147483646;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,v[20],c[20],ans=0,i;
	cin>>n;
	for (i=0;i<n;i++){
		cin>>v[i];
	}
	for (i=0;i<n;i++){
		cin>>c[i];
	}
	for (i=0;i<n;i++){
		if (c[i]<v[i]){
			ans+=v[i]-c[i];
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    string S;
    cin>>N>>S;
    int point=0;
    for(int i=0;i<S.size();i++){
        if(S[i]=='W'){point++;}
    }
    int M=1-N;
    for(int i=0;i<S.size();i++){
        if(S[i]=='W'){point--;}
        M=max(M,point);
        if(S[i]=='E'){point++;}
    }
    cout<<N-M-1<<endl;
}

Measured memory_bytes: 900
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define inf int(1e9)
#define half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int mod = 1000000007;

string s;

void solve() {
    ll ans = 0;
    stack<char> st;
    rep(i, s.length()) {
        if (st.empty()) st.push(s[i]);
        else if (st.top() == 'B' && s[i] == 'W') {
            ans += st.size();
        } else if (st.top() == 'B') st.push(s[i]);
        else if (st.top() == 'W') {
            st.pop();
            st.push(s[i]);
        }
    }
    cout << ans << endl;
}

int main() {
    cin >> s;
    solve();
    return 0;
}

Measured memory_bytes: 644
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		}
		
		// 計算
		long result = 0;
		int MOD = 1000000007; 
		Prime p = new Prime(1000000);
		HashMap<Integer, Integer> lcmMap = p.lcmMap(a);
		//System.out.println(lcmMap.toString());
		long lcm = 1;
		for(Integer key : lcmMap.keySet()){
		    lcm *= pow(key, lcmMap.get(key), MOD);
		    lcm %= MOD;
		}
		
		for(int i = 0; i < n; i++){
		    result += lcm*inv(a[i], MOD);
		    result %= MOD;
		}
		
		// 出力
		System.out.println(result);
	}

	public static long pow(long a, long n, long MOD) {
	    long res=1;
	    while (n>0) {
	        if ((n-n/2*2)==1) {
	            res=(res*a)%MOD;
	        }
	        a=(a*a)%MOD;
	        n>>=1;
	    }
	    return res%MOD;
	}

	public static long inv(long a, long MOD) {
	    return pow(a, MOD - 2, MOD);
	}
	
}

class Prime {
    int n;
    ArrayList<Integer> primes;
    int[] seive;
    
    public Prime(int n){
        this.n = n;
        int[] seive = new int[n+1];
        Arrays.fill(seive, -1);
        ArrayList<Integer> primes = new ArrayList<Integer>();
        for(int i = 2; i <= n; i++){
            if(seive[i] != -1) continue;
            primes.add(i);
            seive[i] = i;
            for(long j = (long)i*i; j <= n; j += i){
                if(seive[(int)j] == -1) seive[(int)j] = i; 
            }
        }
        this.seive = seive;
        this.primes = primes;
    }
    
    public boolean isPrime(int x){
        return seive[x] == x;
    }
    
    public HashMap<Integer, Integer> factorization(int x){
        HashMap<Integer, Integer> factorization = new HashMap<Integer, Integer>();
        ArrayList<Integer> factorList = factorList(x);
        if(factorList.size() == 0) return factorization;
        for(Integer i : factorList){
            int cnt = factorization.getOrDefault(i, 0);
            factorization.put(i, cnt + 1);
        }
        return factorization;
    }
    
    private ArrayList<Integer> factorList(int x){
        ArrayList<Integer> factorList = new ArrayList<Integer>();
        while(x != 1){
            factorList.add(seive[x]);
            x /= seive[x];
        }
        return factorList;
    }
    
    public HashMap<Integer, Integer> lcmMap(int[] array){
        HashMap<Integer, Integer> lcmMap = new HashMap<Integer, Integer>();
		for(int i = 0; i < array.length; i++){
		    HashMap<Integer, Integer> map = factorization(array[i]);
		    for(Integer key : map.keySet()){
		        lcmMap.put(key, max(lcmMap.getOrDefault(key, 0), map.get(key)));
		    }
		}
        return lcmMap;
    }
    
}



Measured memory_bytes: 46280
# -*- coding: utf-8 -*-
import math
N, K = map(int, input().split())
ans = 0

if N >= K - 1:
	ans = (N - K + 1) * (1 / N)

	for i in range(1, K):
		j = math.floor((math.log2((K - 1) / i)) + 1)
		ans += (1 / N) * (1 / 2) ** j

else:
	for i in range(1, N + 1):
		j = math.floor((math.log2((K - 1) / i)) + 1)
		ans += (1 / N) * (1 / 2) ** j

print(ans)

Measured memory_bytes: 3316
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long max, min, sum = 0;
    int a;
    if ( n == 0){
        return 0;
    }
     
    for (int i=0; i<n; i++){
        cin >> a ;
        sum = a + sum;
        if (i == 0){
            max = min = a;
        }
        if (max <= a){
            max = a;
        }
        if (min >= a){
            min = a;
        }
    
    }
    cout << min << " " << max << " " << sum <<endl;

    
    return 0;
}


Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		// 何行何列かを読み取る
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[][] A = new int[n][m];
		int[] b = new int[m];
		
		// 行列に要素を代入
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				A[i][j] = scan.nextInt();
			}
		}
		for (int i = 0; i < m; i++) {
			b[i] = scan.nextInt();
		}
		
		// 結果を出力
		int sum_i = 0; // 行ごとの結果
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				sum_i += A[i][j] * b[j];
			}
			System.out.println(sum_i);
			sum_i = 0;
		}
		scan.close();
	}
}

Measured memory_bytes: 31124
H,W = map(int,input().split())
A = [list(map(int,input().split())) for i in range(H)]
B = [list(map(int,input().split())) for i in range(H)]

C = [[] for i in range(H)]
for i,(arow,brow) in enumerate(zip(A,B)):
    for a,b in zip(arow,brow):
        d = abs(a-b)
        C[i].append(d)

ofs = (H+W)*100
dp = [0] * W
dp[0] = (1<<ofs)
for i,crow in enumerate(C):
    dp2 = [0] * W
    for j,(c,d) in enumerate(zip(C[i],dp)):
        dp2[j] |= (d<<c)
        dp2[j] |= (d>>c)
    for j,c in enumerate(C[i]):
        if j==0: continue
        dp2[j] |= (dp2[j-1]<<c)
        dp2[j] |= (dp2[j-1]>>c)
    dp = dp2

ans = ofs
l = len(bin(dp[-1]))
for i in range(l):
    if dp[-1] & (1<<i):
        ans = min(ans, abs(i-ofs))
print(ans)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define dump(x) cerr << #x << " => " << (x) << endl
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main()
{
    string dream = "dream";
    string dreamer = "dreamer";
    string erase = "erase";
    string eraser = "eraser";
    string S;
    cin >> S;
    int i = 0;
    i = S.size() - 1;
    while (i > 0)
    {
        if (S.at(i) == 'm')
        {
            if (i < 4 || S.substr(i - 4, 5) != "dream")
            {
                cout << "NO" << endl;
                exit(0);
            }
            i -= 5;
        }
        else if (S.at(i) == 'r')
        {
            if (i >= 6 && S.substr(i - 6, 7) == "dreamer")
            {
                i -= 7;
                continue;
            }
            if (i >= 5 && S.substr(i - 5, 6) == "eraser")
            {
                i -= 6;
                continue;
            }
            cout << "NO" << endl;
            exit(0);
        }
        else if (S.at(i) == 'e')
        {
            if (i < 4 || S.substr(i - 4, 5) != "erase")
            {
                cout << "NO" << endl;
                exit(0);
            }
            i -= 5;
        }
    }
    cout << "YES" << endl;
}

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

int main(){
    int n;
    cin >> n;
    int d[n];
    for(int i=0; i<n; i++) cin >> d[i];
    sort(d, d + n);
    cout << d[n/2] - d[n/2 - 1] << endl;
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int maxhappy(int a[][3],int n){
    int dp[3],m[3]={};
    int i;
    for(i=0;i<3;i++){
        dp[i]=a[0][i];
    }
    for(i=1;i<n;i++){
        m[0]=max(a[i][0]+dp[1],a[i][0]+dp[2]);
        m[1]=max(a[i][1]+dp[0],a[i][1]+dp[2]);
        m[2]=max(a[i][2]+dp[0],a[i][2]+dp[1]);
        dp[0]=m[0],dp[1]=m[1],dp[2]=m[2];
        m[0]=m[1]=m[2]=0;
    }
    sort(dp,dp+3);
    return dp[2];
}
int main(){
    int n,i,j,d;
    cin>>n;
    int a[n][3];
    for(i=0;i<n;i++){
        for(j=0;j<3;j++){
            cin>>a[i][j];
        }
    }
    d=maxhappy(a,n);
    cout<<d;
    return 0;
}

Measured memory_bytes: 1408
A, B, C, D, E, F = map(int, input().split())
water = set([])

for i in range(1, F // (100 * A) + 1):
    water1 = i * 100 * A
    for j in range((F - water1) // (100 * B) + 1):
        water2 = j * 100 * B
        water.add(water1 + water2)

ans = [100 * A, 0]
c = 0

for i in water:
    max_sugar = min(i // 100 * E, F - i)
    sugar = 0
    for j in reversed(range(max_sugar // C + 1)):
        for k in reversed(range((max_sugar - j * C) // D + 1)):
            sugar = max(sugar, j * C + k * D)
            if max_sugar == sugar:
                break
        else:
            continue
        break
    concentration = sugar / (i + sugar)
    if c < concentration:
        c = concentration
        ans = [i + sugar, sugar]

print(' '.join(map(str, ans)))

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

int main() {
  string S;
  vector<string> week = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}; 
  cin >> S;
  for (int i = 0; i < week.size(); i++) {
  	if (week[i] == S) {
      int result = 7 - i;
      cout << result << endl;
      break;
    }
  }

}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a[3],max,min;
	
	int i;
	
	for(i=0;i<3;i++) {
		scanf("%d",&a[i]);
		
		if(i==0||min>=a[i]) min=a[i];
		if(i==0||max<=a[i]) max=a[i];
	}
	
	printf("%d",max-min);
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        String[] d=new String[k];
        for (int i = 0; i < k; i++) {
            d[i]=sc.next();
        }
        int ans=n;
        while(true){
            int c=0;
            String s=String.valueOf(ans);
            for (int i = 0; i < k; i++) {
                if(s.contains(d[i])){
                    c=1;
                    break;
                }else{
                    c=0;
                }
            }
            if(c==0)break;
            ans+=c;
        }
        out.println(ans);
    }
}

Measured memory_bytes: 25424
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

int getMinMove(int n, const std::vector<int> &positions) {
  if (static_cast<int>(positions.size()) <= n) {
    return 0;
  }
  auto pos_sorted = positions;
  std::sort(pos_sorted.begin(), pos_sorted.end());
  std::vector<int> diffs(positions.size() - 1);
  for (int i = 0; i < static_cast<int>(diffs.size()); ++i) {
    diffs[i] = pos_sorted[i + 1] - pos_sorted[i];
  }
  std::sort(diffs.begin(), diffs.end());
  return std::accumulate(diffs.begin(), diffs.end() - (n - 1), 0);
}

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> positions(m);
  for (int i = 0; i < m; ++i) {
    std::cin >> positions[i];
  }
  std::cout << getMinMove(n, positions) << std::endl;
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll in()
{
    ll res=0,p=1;
    char c=getchar();
    while(c<'0'||c>'9') {if(c=='-') p=-1; c=getchar();}
    while(c>='0'&&c<='9') res=res*10+c-48,c=getchar();
    return p*res;
}
void out(ll x)
{
    if (x>9) out(x/10);
    putchar(x%10+48);
}
const int mod = 1e9 + 7, inf = 0x3f3f3f3f;
ll quickpow(ll x, ll k)
{
    ll res = 1;
    while(k){
        if(k & 1) res = (res * x) % mod;
        k >>= 1, x = (x * x) % mod;
    }
    return res;
}
const int maxn = 1e6 + 5;

int a[105];
int main()
{
    ll x, k, d;
    cin >> x >> k >> d;
    if (x > 0){
        ll z = x % d;
        ll m = (x - z) / d;
        if (k < m) cout << x - k * d << endl;
        else{
            if ((k - m) % 2 == 1) cout << abs(z - d) << endl;
            else cout << z << endl;
        }
    }else{
        ll z = (x % d + d) % d - d;
        ll m = (z - x) / d;
        if (k < m) cout << abs(x + k * d) << endl;
        else{
            if ((k - m) % 2 == 1) cout << z + d << endl;
            else cout << abs(z) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3632
<?php
$n = fgets(STDIN);
if($n >= 64){
echo 64;
}elseif($n >= 32){
echo 32;
}elseif($n >= 16){
echo 16;
}elseif($n >= 8){
echo 8;
}elseif($n >= 4){
echo 4;
}elseif($n >= 2){
echo 2;
}else{
echo 1;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  int n;
  cin >> n;
  vector<int> x(n);
  REP(i, n) cin >> x[i];
  int ans = INF;
  FORe(p, 1, 100){
    int sum = 0;
    REP(i, n) sum += (x[i]-p)*(x[i]-p);
    chmin(ans, sum);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s; cin>>s;
	if(s[2]==s[3]&&s[4]==s[5]) cout<<"Yes\n";
	else cout<<"No\n";
}


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

int main(){
  long long q,h,s,d,n; cin>>q>>h>>s>>d>>n;

  long long min1=min({4*q, 2*h, s});
  long long min2=min(2*min1, d);

  if(n%2==0)cout<<n/2*min2<<endl;
  else cout<<n/2*min2+min1<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int):
    quotient = N // (A+B)
    remainder = N % (A+B)
    return quotient * A + min(remainder, A)


def main():
    N, A, B = map(int, sys.stdin.readline().split())
    print(solve(N, A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        long sum = 0;
        
        int a = 0;
        int b = 0;
        
        while (n-- > 0) {
            b = sc.nextInt();
            sum += Math.min(b - a, t);
            a = b;
        }
        
        sum += t;
        
        System.out.println(sum);
    }
}


Measured memory_bytes: 62704
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  size_t n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  const auto acc = accumulate(begin(a), end(a), 0);
  if(acc % 10)
    cout << acc;
  else
  {
    sort(begin(a), end(a));
    for(const auto i: a)
      if(i % 10)
      {
        cout << acc - i;
        return 0;
      }
    cout << 0;
  }

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long x,sum=0;
	cin>>x;	
	if(x<=6) 
	{
		cout<<1;
		return 0;
	}
	if(x%11==0) sum+=x/11*2;
	if(x%11!=0&&x%11<=6) sum+=x/11*2+1;
	if(x%11!=0&&x%11>6) sum+=(x/11+1)*2; 
    cout<<sum;
    return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean flag = false;
        if(s.indexOf("C")>=0&&s.indexOf("C")<s.lastIndexOf("F")){
            flag = true;
        }
        if(flag){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }

 }

Measured memory_bytes: 9044
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    const int n = 9;
    const int time = 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2;
    int t;
    int a[n], b[n];

    cin >> t;
    while (t--) {
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
            sum += a[i];
        }
        for (int i = 0; i < n; ++i) {
            cin >> b[i];
            sum += b[i];
        }

        sum = (sum + 1) / 2;
        sort(a, a + n);
        sort(b, b + n);
        int win = 0;
        do {
            int a_s = 0;
            for (int i = 0; i < n; ++i) {
                if (a[i] > b[i])
                    a_s += a[i] + b[i];
                if (a_s >= sum)
                    break;
            }
            if (a_s >= sum)
                ++win;
        } while (next_permutation(b, b + n));

        printf("%.5lf %.5lf\n", (double)win / time, (double)(time - win) / time);
    }

    return 0;
}

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

int main() {

  int N, M;
  cin >> N >> M;

  int road[M][2];

  for (int i=0; i<M; i++) {
	for (int j=0; j<2; j++) {
	  cin >> road[i][j];
	}
  }

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

  int each[N];
  for (int k=1; k<=N; k++) {
	int cnt = 0;
	for (int i=0; i<M; i++) {
	  for (int j=0; j<2; j++) {
		if ( road[i][j] == k ) {
		  cnt++;
		}
	  }
	}
	each[k-1] = cnt;
  }

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

  for (int k=0; k<N; k++) {
	cout << each[k] << endl;
  }
}

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

using namespace std;

long long int gcd(long long int a,long long int b) {
	if (b == 0)
		return a;

	return gcd(b,a % b);
}

long long int lcm(long long int a, long long int b) {
	return  a * b / gcd(a, b);
}

int main()
{
	long long int a, b, c, d;
	long long int num1, num2, num3;
	long long int num4, num5, num6;
	long long int ans;

	cin >> a >> b >> c >> d;

	num1 = (a-1)/ c;
	num2 = (a-1)/d;
	num3 = (a-1)/lcm(c,d);

	num4 = b / c;
	num5 = b / d;
	num6 = b /lcm(c,d);

	//cout << num1 << num2 << num3 << num4 << num5 <<  num6 <<endl;
	
	ans = (b-a+1)-(num4+num5-num6) + (num1 + num2 - num3);

	cout << ans << endl;

	return 0;
}
//o   o   o   
//4 5 6 7 8 9
//4 5
//4 5 6
//4 5 6 7 8 9 10
//5 6 7 8 9 10 11   9 10 11 12 13 14 15
//2 4
//3 1 0
//7-4
  //        o           o     o
// 10 11 12 13 14 15 16 17 18 19 20


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int Maxn=105; 
int n,k,cnt;
struct edg
{
	int x,y;
}edge[Maxn*Maxn];
int main()
{
	scanf("%d%d",&n,&k);
	int ans=(n-2)*(n-1)/2;
	if(ans<k)
	{
		printf("-1");
		return 0;
	}
	for(int i=2;i<=n;i++)
		edge[++cnt]=(edg){1,i};
	k-=ans;
	for(int i=2;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(k) edge[++cnt]=(edg){i,j},k++;
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++)
		printf("%d %d\n",edge[i].x,edge[i].y);
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<int64_t> A(N),B(N);
  for(int i=0;i<N;++i){
    cin>>A[i];
    B[i] = -A[i]+i;
    A[i] += i;
  }
  
  sort(B.begin(),B.end());

  int64_t ans=0;
  for(int i=0;i<N;++i){
    ans += upper_bound(B.begin(),B.end(),A[i])-lower_bound(B.begin(),B.end(),A[i]);
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 6440
import javax.print.attribute.HashAttributeSet;
import java.io.*;

import java.math.BigInteger;
import java.util.*;

import java.util.ArrayList;

import java.util.Scanner;


public class Main {

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static final int mod = 1000000007;

    public static int gcd(int a, int b)
    {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s=sc.nextLine();
        String t=sc.nextLine();
        int f=1;
        for(int j=0;j<s.length();j++)
        {
            if(s.charAt(j)!=t.charAt(j))
            {
                f=0;
                break;
            }

        }
        if(f==1)
        {
            if(s.length()+1==t.length())
                System.out.println("Yes");
            else
                System.out.println("No");
        }
        else
            System.out.println("No");


    }
}









Measured memory_bytes: 35748
import itertools as ite

n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

ps = ite.permutations([i for i in range(1,n+1)])

for i,ele in enumerate(ps):
    if ele==p: a = i
    if ele==q: b = i

ans = abs(a-b)
print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

using namespace std;


int main()
{
    unsigned long long X;
    int a, b;

    scanf("%llu", &X);


    for( a = -1000; a <= 1000; a++){
        for( b = 1000; b >= -1000; b--){
            if((pow(a, 5) - pow(b, 5)) == X){
                printf("%d %d", a, b);
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 2556