akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_map>
# include <unordered_set>
# include <thread>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ui32 = unsigned int;
constexpr ll INFLL = 1e18;

#define CHECK_IMPL1(cond)              \
if (!(cond)) {                         \
    DEBUG("expected cond: " << #cond); \
    assert(cond);                      \
}

#define CHECK_IMPL2(cond, message)                                            \
if (!(cond)) {                                                                \
    DEBUG("expected cond: " << #cond << " failed with message: " << message); \
    assert(cond);                                                             \
}
#define CHECK_IMPL(_1, _2, NAME, ...) NAME
#define CHECK(...) CHECK_IMPL(__VA_ARGS__, CHECK_IMPL2, CHECK_IMPL1, CHECK_IMPL0)(__VA_ARGS__)

#ifdef __APPLE__
#define DEBUG(message) std::cerr << message << std::endl;
#else
#define DEBUG(message)
#endif

void solve() {
  int n, m;
  cin >> n >> m;

  vector<int> a(n, 1);
  vector<bool> can(n, false);
  can[0] = true;

  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;

    --x;
    --y;

    --a[x];
    if (can[x]) {
      can[y] = true;
    }
    if (!a[x]) {
      can[x] = false;
    }
    ++a[y];
  }

  int ans = 0;
  for (auto x : can) {
    ans += x;
  }

  cout << ans << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef __APPLE__
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,x,tmp=0;
  int a[100];
  scanf("%d %d %d",&n,&m,&x);
  for(int i=0;i<m;i++)
  {
    scanf("%d",&a[i]);
    if(a[i]<x)
	{
      tmp++;
    }
  }
  printf("%d\n",min(tmp,m-tmp));
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
#define MOD 1000000007
#define ull unsigned long long int
#define newline cout<<endl
 
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b)
{
   ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a);
        a=(a*a);
        b>>=1;
    }
    return res;
}
 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)     for (int i = 0; i < int(n); i++)
#define  forr(i, n)     for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)  
#define  deb(x)       cout << '>' << #x << ':' << x << endl;

void solve()
{
    string a,b;
    cin>>a>>b;
    cout<<b<<a<<endl;

}
int main()
{
    FastIO;
    ll t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>

using namespace std;

int main(){

	string s1;
	string s2;
	string s3;

	cin >> s1 >> s2 >> s3;

	s1[0] = toupper(s1[0]);
	s2[0] = toupper(s2[0]);
    s3[0] = toupper(s3[0]);

    cout << s1[0] << s2[0] << s3[0];

	return 0;

}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string, copy
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7
ans = inf
count = 0; pro = 1

d, g = map(int, input().split())
g //= 100
dp=[[inf]*(10**5*2) for i in range(11)]
dp[0][0]=0
for i in range(d):
    p,c=map(int,input().split());c//=100
    for j in range(10**5*2):
        if dp[i][j]!=inf:
            dp[i+1][j]=min(dp[i+1][j],dp[i][j])
            for k in range(1,p):
                dp[i+1][j+(i+1)*k]=min(dp[i+1][j+(i+1)*k],dp[i][j]+k)
            dp[i+1][j+(i+1)*p+c] = min(dp[i+1][j+(i+1)*p+c],dp[i][j]+p)
for i in range(g,10**5*2):
    ans=min(ans,dp[d][i])
print(ans)




# for i in range(1, d+1):
#     p, c = map(int, input().split())
#     c //= 100
#     # for key, value in tuple(D.items()):
#     #     print(D[key],p)
#     #     D[key+i*p+c//100] = min(D[key+i*p+c//100], D[key]+p)
#     S = D.copy()
#     for key, value in S.items():
#         for k in range(1, p):
#             # print(D[key+i])
#             D[key+i*k] = min(D[key+i*k], S[key]+k)
#         D[key+i*p+c] = min(D[key+i*p+c], S[key]+p)
# ans = inf
# for key, value in D.items():
#     # print(key,value)
#     if key >= g:
#         ans = min(ans, value)
# print(ans)


Measured memory_bytes: 114484
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  double da,db;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> a >> b;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------

  if(a<9 && b < 9) anss = "Yay!";
  else anss = ":(";

  cout << anss << endl;

}

Measured memory_bytes: 256
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		UINT64_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

int main()
{
	ll N = 0;
	ll max_len = 0;
	ll ret = 0;

	cin >> N;
	vector<ll> p(N);
	Rep(i, N) {
		cin >> p[i];
	}

	Rep(i, N - 1) {
		if (i + 1 == p[i]) {
			p[i + 1] = p[i];
			ret++;
		}
	}
	if (N == p[N - 1]) {
		ret++;
	}

	cout << ret << endl;

	return 0;
}





Measured memory_bytes: 1024
import java.util.Scanner;

class B {
    public static void main(String...args) {
        final Scanner sc = new Scanner(System.in);
        final char[] S = sc.next().toCharArray();
        int cnt = 0;
        for(char c : S)
            if(c == 'o')
                cnt++;
        System.out.println(15 - S.length + cnt >= 8 ? "YES" : "NO");
    }
}
public class Main {
    public static void main(String...args) {
        B.main();
    }
}


Measured memory_bytes: 23636
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int N, A, B, C, X;

int solve(vi &Y){
	int p=0;
	REP(i, 10001){
		 if(Y[p] == X) p++;
		 if(p == Y.size()) return i;
		 X = (A * X + B) % C;
	}
	return -1;
}

main(){
	while(cin >> N >> A >> B >> C >> X, N){
		vi Y(N);
		REP(i, N) cin >> Y[i];
		cout << solve(Y) << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
import java.util.Scanner;

/* Name of the class has to be "Main" only if the class is public. */

public class Main {
	
	

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int a[] = new int[n];

		for(int i=0;i<n;i++)
			a[i] = s.nextInt();
		
		int sum = 0;
		for(int i=0;i<n;i++) {
			for(int j=i+1;j<n;j++) {
				sum+=a[i]*a[j];
			}
		}
		System.out.println(sum);
	}
}

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

vector<long long int> a,b,c,mix,ans;

int X,Y,Z,K;
int main () {
    cin >> X >> Y >> Z >> K;
    for(int i=0; i<X; i++) {
        long long int x;
        cin >> x;
        a.push_back(x);
    }
    for(int i=0; i<Y; i++) {
        long long int x;
        cin >> x;
        b.push_back(x);
    }
    for(int i=0; i<Z; i++) {
        long long int x;
        cin >> x;
        c.push_back(x);
    }

    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    sort(c.rbegin(),c.rend());
    for(int i=0;i<X; i++) {
        for(int j=0; j<Y; j++) {
            mix.push_back( a[i] + b[j] );
        }
    }
    sort(mix.rbegin(),mix.rend());
    int z = mix.size();
    int l = min(3000,z);
    for(int i=0; i<min(3000,Z); i++) {
        for(int j=0; j<l;j++) {
            ans.push_back(mix[j] + c[i]);
        }
    }
    sort(ans.rbegin(),ans.rend());
    for(int i=0; i<K; i++) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 43256
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const N = parseInt(args[0][0], 10)
	const S = args[1][0]
	const t1 = Math.floor(N / 2)
	if (S.slice(0, t1) === S.slice(t1, N)) console.log('Yes')
	else console.log('No')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7496
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;

int main(){
  int N;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int A=0,B=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      A+=a.at(i);
    }else{
      B+=a.at(i);
    }
  }
  cout<<A-B<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
	char a[10]="Sunny";
	char b[10]="Cloudy";
	char c[10]="Rainy";
	char d[10];
	scanf("%s",&d);
	if(strcmp(a, d) == 0){
	printf("%s",b);
	}else if(strcmp(b, d) == 0){
		printf("%s",c);
	}else if(strcmp(c, d) == 0){
		printf("%s",a);
	}
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

ll prime_factor(ll n) {
  map<ll, int > ret;
  ll MAX = 0;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      MAX=max(MAX,i);
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1){
    ret[n] = 1;
    MAX=max(MAX,n);
  }
  return MAX;
}

int main()
{
  int N;
  cin >> N;
  int flag=0;
  FOR(i,1,3501){
    FOR(j,1,3501){
      if((4*i*j-N*j-N*i)!=0&&(N*i*j)%(4*i*j-N*j-N*i)==0&&(N*i*j)/(4*i*j-N*j-N*i)>0){
        cout << (N*i*j)/(4*i*j-N*j-N*i) << " " << i << " " << j << endl;
        flag=1;
        break;
      }
    }
    if(flag==1){
      break;
    }
  }
  // if(N%2==0){
  //   cout << N << " " << N << " " << N/2 << endl;
  // }else if(N%3==0){
  //   cout << N/3 << " " << N*2 << " " <<  N*2 << endl;
  // }else{
  //   int flag = 0;
  //   ll x=prime_factor(N);
  //   for(ll k = x;k<=3501;k+=x){
  //     FOR(i,N/4,3501){
  //       FOR(j,N/4,3501){
  //         if(4*k*i*j==N*(k*i+i*j+j*k)){
  //           cout << k << " " << i << " " << j << endl;
  //           flag=1;
  //           break;
  //         }
  //       }
  //       if(flag==1){
  //         break;
  //       }
  //     }
  //     if(flag==1){
  //       break;
  //     }
  //   }
  // }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	int n, s, count;
	int[][] ans = new int[11][331];
	ArrayDeque<Integer> q = new ArrayDeque<Integer>();
	
	void loop(int a, int b){
		if(a==11) return;
		for(int i=0;i<10;i++){
			if(q.contains(i)==false){
				q.push(i);
				ans[a][b+a*i]++;
				loop(a+1,b+a*i);
				q.pop();
			}
		}
	}
	
		
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		Main A = new Main();
		A.loop(1,0);
		
		while(sc.hasNext()){
			A.n = sc.nextInt();
			A.s = sc.nextInt();
			if(A.n<11 && A.s<331) System.out.println(A.ans[A.n][A.s]);
			else System.out.println(0);
		}
	}	
}

Measured memory_bytes: 21692
n = int(input())
l = list(map(int, input().split()))
f = 0
c = -1
while (f == 0):
  n = -1
  c = c + 1
  for i in l:
    n = n + 1
    if (i % 2) != 0:
      f = 1
      break
    else:
      l[n] = int(i / 2)
print(c)

Measured memory_bytes: 3060
/*input
14 10
1 4
5 7
7 11
4 10
14 7
14 3
6 14
8 11
5 13
8 3
8
8 6 2
9 7 85
6 9 3
6 7 5
10 3 1
12 9 4
9 6 6
8 2 3
*/
#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 int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

const int N = 1e5+1;
vector<int> adj[N];
int vis[N][11];
int color[N];
int n,m,q;
vector< pair< pair<int,int>,int> > nice; 

void solve(){
  	cin >> n >> m;
  	REP(i,m){
  		int a,b;cin >> a >> b;
  		adj[a].pb(b);
  		adj[b].pb(a);
  	}
  	cin >> q;
  	REP(i,q){
  		int v,d,c;cin >> v >> d >> c;
  		nice.pb({{v,d},c});
  	}
  	reverse(all(nice));
  	REP(i,q){
  		int v = nice[i].f.f;
  		int d = nice[i].f.s;
  		queue< pair<int,int> > q;
  		if(vis[v][d])continue;
  		vis[v][d] = 1;
  		q.push({v,d});
  		while(!q.empty()){
  			int u = q.front().f;
  			int dis = q.front().s;
  			q.pop();
  			if(!color[u])color[u] = nice[i].s;
  			for(int v:adj[u]){
  				if(dis == 0)continue;
  				if(!vis[v][dis-1]){
  					vis[v][dis-1] = 1;
  					q.push({v,dis-1});
  				}
  			}
  		}
  	}
  	RE(i,n)cout << color[i] << "\n";
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    string a = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
    for (int i=0; i<s.size(); i++){
        for(int j=0; j<26; j++){
            if(s.at(i)==a.at(j)){
                s.at(i)=a.at(j+n);
                break;
            }
        }
    }
    cout << s;
    return 0;   
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    
int t[4][14];
  int n, i,j,c;
  char m, d;
  for(i=0; i < 4; i++){
    for(j=0; j < 14; j++){
      t[i][j]=0;
    }
  }
 scanf("%d", &c);
  for(i = 0; i < c; i++){
    scanf("%c", &d);
    scanf("%c %d", &m, &n);
    if(m == 'S'){
      t[0][n] = 1;
    }
    else if(m == 'H'){
      t[1][n] = 1;
    }
    else if(m == 'C'){
      t[2][n] = 1;
    }
    else if(m == 'D'){
      t[3][n] = 1;
    }
  }
  for(j=1; j < 14; j++){
    if(t[0][j] != 1){
      printf("S %d\n", j);
    }
  }
 
 for(j=1; j < 14; j++){
    if(t[1][j] != 1){
      printf("H %d\n", j);
    }
  }
 
 for(j=1; j < 14; j++){
    if(t[2][j] != 1){
      printf("C %d\n", j);
    }
  }
 
 for(j=1; j < 14; j++){
    if(t[3][j] != 1){
      printf("D %d\n", j);
    }
  }
    
    
    
    
    return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
const int maxn=100000+10;
const int base=998244353;

int n;
int a[maxn],d[maxn];
long long gt[maxn];
long long kq;

int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) d[a[i]]++;
    int dmax=0;for(int i=1;i<=n;i++) dmax=max(dmax,a[i]);
    if (a[1]!=0 || d[0]==0 || d[0]>1) kq=0;
    else{
        gt[0]=1;for(int i=1;i<=n;i++) gt[i]=gt[i-1]*i;
        for(int i=0;i<=dmax;i++)
            if (d[i]==0){
                cout<<0;return 0;
            }
//        for(int i=0;i<=dmax;i++) cout<<d[i]<<" ";cout<<endl;
        //-----
        kq=1;
        for(int i=1;i<=dmax;i++){
            for(int j=1;j<=d[i];j++) kq=kq*d[i-1]%base;
        }
    }
    cout<<kq;
}


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

int prime[50000],size;

bool isPrime(int x){
	double to = sqrt(x);
	for(int i=0;i<size && prime[i]<=to;i++){
		if(x % prime[i] == 0) return false;
	}
	return true;
}

void mkPrime(void){
	prime[0] = 2;
	size = 1;
	for(int i=3;i<=500100;i+=2) if(isPrime(i)) prime[size++]=i;
}

int key(int x){
	int ans=0, t=0, max=-99999999, to=x/2+1;

	for(int i=0;prime[i]<=to;i++){
		if(x % prime[i] == 0){
			t++;
			ans -= prime[i];
			if(max < prime[i]) max = prime[i];
		}
	}

	switch(t){
	case 0: return x;
	case 1: return max;
	default: return ans + 2 * max;
	}
}

int main(void){
	int a,b;
	mkPrime();
	while(cin>>a>>b && (a||b)){
		if(key(a) > key(b)) cout<<"a\n";
		else cout<<"b\n";
	}
	return 0;
}

Measured memory_bytes: 1008
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define inf 1e9
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define r1 rt<<1
#define r2 rt<<1|1
#define ld long double
#define ri register int
#define rep(i,a,b) for(ri i=a;i<=b;++i)
#define rep2(i,a,b,c) for(ri i=a;i<=b;i+=c)
#define REP(i,a,b) for(ri i=a;i>=b;--i)
#define REP2(i,a,b,c) for(ri i=a;i>=b;i-=c)
using namespace std;

inline ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^'0'),c=getchar();
	return x*f;
}
inline void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10+'0');
}

const int N=1e5+5;
multiset<int> sa,sb;
map<int,int> fa;
int n,a[N],b[N];

inline int ff(int x){
	if(x!=fa[x]) fa[x]=ff(fa[x]);
	return fa[x];
}

int main()
{
	n=read();
	rep(i,1,n) a[i]=read(),a[n+1]^=a[i],sa.insert(a[i]);
	rep(i,1,n) b[i]=read(),b[n+1]^=b[i],sb.insert(b[i]);
	sa.insert(a[n+1]);sb.insert(b[n+1]);
	if(sa!=sb){
		puts("-1");return 0;
	}
	rep(i,1,n)
		if(a[i]!=b[i]) fa[a[i]]=a[i];
	fa[a[n+1]]=a[n+1];
	int s=-1;
	rep(i,1,n)
		if(a[i]!=b[i]) fa[ff(a[i])]=ff(b[i]),++s;
	map<int,int>::iterator it;
	for(it=fa.begin();it!=fa.end();++it)
		if(it->first==it->second) ++s;
	write(s);puts("");
	return 0; 
}

Measured memory_bytes: 17792
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

typedef pair<int,int> pii;

int main(){
	int num,ans,t,n,r=0;
	vector<vector<int> > rank(200);
	pii tp;
	char c;
	priority_queue<pii> data;

	while(cin>>num){
		cin>>c>>ans;
		if(!num && !ans) break;
		data.push(pii(ans,num));
	}

	tp=data.top();data.pop();
	t=tp.first;
	rank[0].push_back(tp.second);

	while(!data.empty()){
		tp=data.top();data.pop();
		if(t!=tp.first){
			r++;
			t=tp.first;
		}
		rank[r].push_back(tp.second);
		t=tp.first;
	}

	while(cin>>n){
		for(int i=0;i<rank.size();i++){
			if(find(rank[i].begin(),rank[i].end(),n) != rank[i].end()){
				cout<<i+1<<endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1220
w, h, x, y = gets.split.map(&:to_i)

if w.to_f / 2 == x && h.to_f / 2 == y
  puts "#{w.to_f * h.to_f / 2} 1"
else
  puts "#{w.to_f * h.to_f / 2} 0"
end

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n; cin >> n;
    vector<ii> el;
    if (n%2 == 0) {
        vector<int> v;
        FOR(i,1,n/2){
            for (auto u : v) {
                el.emplace_back(i, u);
                el.emplace_back(n-i+1, u);
            }
            v.push_back(i);
            v.push_back(n-i+1);
        }
    } else {
        vector<int> v = {1, n-1, n};
        el.emplace_back(1, n);
        el.emplace_back(n-1, n);
        FOR(i,2,1+(n-3)/2) {
            for (auto u : v) {
                el.emplace_back(i, u);
                el.emplace_back(n-i, u);
            }
            v.push_back(i);
            v.push_back(n-i);
        }
    }

    cout << SZ(el) << '\n';
    for (auto e : el) {
        cout << e.fi << ' ' << e.sc << '\n';
    }
}



Measured memory_bytes: 384
'use strict'
const main = (input) => {
  const el = input.trim().split(" ").map(el => el * 1)
  let ans = - 1
   for(let i = 0 ;i < 100000; i++){
  	if (Math.floor(0.08 * i)  == el[0] && Math.floor(0.1 * i) == el[1]) {
    	ans = i;
      	break;
    }
  }
    console.log(ans)
  
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 11596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll n,k;cin>>n>>k;
    vector<ll> cnt(200010);
    rep(i,n){
        ll a;cin>>a;
        cnt[a]++;
    }
    sort(cnt.begin(),cnt.end(),greater<ll>());
    cnt.push_back(0);

    ll ans=0;
    for(ll i=k;cnt[i]!=0;i++){
        ans+=cnt[i];
    }

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

Measured memory_bytes: 6408
n=int(input())
a = [0]*20
x=[[0 for i in range(20)]for j in range(20)]
y=[[0 for i in range(20)]for j in range(20)]
 
for i in range(n):
	a[i]=int(input())
	for j in range(a[i]):
		x[i][j], y[i][j] = map(int,input().split())
		x[i][j]-=1
 
ans=0
for bits in range(1<<n):
	isok=True
	for i in range(n):
		if (bits>>i)&1 == 0:
			continue
		for j in range(a[i]):
			if y[i][j]^((bits>>x[i][j])&1):
				isok=False
	if isok:
		tmp=bits
		an=0
		while(tmp):
			if tmp&1:
				an+=1
			tmp//=2
		ans = max(ans,an)
print(ans)

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

int main()
{
   int ans=0;
   char a[5];
   for(int i=0;i<3;i++)
   {
       cin>>a[i];
       if(a[i]=='1') ans++;
   }
   cout<<ans;

    return 0;
}


Measured memory_bytes: 764
x,y = map(int,input().split())
p = list(map(int,input().split()))

number = sum(p[0:y])
bigNumber = number

for i in range(x-y):

    number = number - p[i] + p[i+y]

    if number > bigNumber:
        bigNumber = number

print((bigNumber + y) / 2)


Measured memory_bytes: 25060
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    s = S()
    q = I()
    qa = [LS() for _ in range(q)]
    f = []
    l = []
    rf = False
    for qi in qa:
        if qi[0] == '1':
            rf = not rf
        else:
            if (qi[1] == '1') == rf:
                l.append(qi[2])
            else:
                f.append(qi[2])
    if rf:
        return JA(l[::-1] + [s[::-1]] + f, "")

    return JA(f[::-1] + [s] + l, "")


print(main())





Measured memory_bytes: 47536
n = int(input())
p = list(map(int, input().split()))
m = p[0]
count = 1
for i in range(1,n):
#  print(i, min(p[:i+1]), p[i])
  m = min(m, p[i])
  if m == p[i]:
    count += 1
print(count)
    

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

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

vector<int> p;
vector<int> r;

void init(int n) {
  p.reserve(n);
  r.reserve(n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
    r[i] = 0;
  }
}

int root(int x) { return p[x] == x ? x : p[x] = root(p[x]); }

bool same(int x, int y) { return root(x) == root(y); }

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y)
    return;

  if (r[x] < r[y])
    p[x] = y;
  else {
    p[y] = x;
    if (r[x] == r[y])
      r[x]++;
  }
}

int main() {
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  cout << max({A1, A2, A3}) - min({A1, A2, A3}) << endl;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,copy
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))

X = int(input())

if X < 30:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 69088
from collections import defaultdict

s = input()
t = input()

in_deg = defaultdict(set)
out_deg = defaultdict(set)

for es, et in zip(s, t):
    out_deg[es].add(et)
    in_deg[et].add(es)

in_deg_mx = max(map(len, in_deg.values()))
out_deg_mx = max(map(len, out_deg.values()))

if in_deg_mx <= 1 and out_deg_mx <= 1:
    ans = "Yes"
else:
    ans = "No"

print(ans)


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

int main() {
    int N;
    cin>>N;
    int h[N];
    for(int i=0;i<N;++i){
        cin>>h[i];
    }
    int DP[N];
    DP[0] = 0;
    DP[1] = abs(h[1] - h[0]);
    for(int i=2;i<N;++i){
        DP[i] = min(DP[i-1]+abs(h[i]-h[i-1]), DP[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<DP[N-1]<<endl;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll n=s.size();
    ll ans=0;
    map<ll,ll> mp;
    V<ll> a(n);
    ll cnt=0;
    ll g=2019;
    ll x=1;
    for(int i=n-1;i>=0;i--){
        
        cnt+=((ll)s[i]-'0')*x;
        mp[cnt%g]++;
        a[i]=cnt%g;
        x=(x*10)%g;
        //x%=g;
        
    }
    //ll x=1;
    V<ll> b(n);
    /*rep(i,n){
        b[i]=x%g;
        b*=10;
    }*/
    mp[0]++;
    for(auto p:mp){
        ans+=p.sc*(p.sc-1)/2;
        //cout<<p.sc<<endl;
    }
    //if(a[0]%g==0) ans++;
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え(=でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
*/

Measured memory_bytes: 6732
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			String input[] = br.readLine().split("\\s+");

			int N = Integer.parseInt(input[0]);
			int quantum = Integer.parseInt(input[1]);

			Queue<Process> Q = new ArrayDeque<Process>();

			for(int loop = 0; loop < N; loop++){
				input = br.readLine().split("\\s+");
				Q.add(new Process(input[0],Integer.parseInt(input[1])));
			}

			StringBuilder ans = new StringBuilder();
			Process tmp = new Process();

			int current_time = 0;

			while(!Q.isEmpty()){
				tmp = Q.peek();
				Q.poll();

				if(tmp.getTime() <= quantum){
					current_time += tmp.getTime();
					ans.append(tmp.getName()).append(" ").append(Integer.toString(current_time)).append("\n");
				}else{
					current_time += quantum;
					Q.add(new Process(tmp.getName(),tmp.getTime()-quantum));
				}
			}

			System.out.print(ans.toString());

		}catch (IOException e) {
			e.printStackTrace();
		}
	}
}

class Process{

	private String name;
	private int time;

	Process(){
		//Do nothing
	}

	Process(String arg_name,int arg_time){
		name = arg_name;
		time = arg_time;
	}

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getTime() {
		return time;
	}
	public void setTime(int time) {
		this.time = time;
	}
}


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

int A,B;

int main(){
	cin>>A>>B;
	for(int i=1;i<=100000;i++){
		if(int(i*0.08)==A&&int(i*0.1)==B){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define il inline 
#define R register int
#define ll long long
#define gc getchar
using namespace std;
il int rd()
{
    R x=0,flag=1;
	char ch=0;
    while((ch>'9'||ch<'0')&&ch!='-')ch=gc();
	if(ch=='-')flag=-1,ch=gc();
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=gc();
    return x*flag;
}
const int N=1000;
char a[N][N],b[N][N],c[N][N];
int n,m;
int main ()
{
	n=rd(),m=rd();
	for(R i=1;i<=n;i++)
		for(R j=1;j<=m;j++)
			b[i][j]=c[i][j]='.';
	
	for(R i=1;i<=n;i+=2)
		for(R j=1;j<m;j++)
			b[i][j]='#';
	
	for(R i=1;i<=n;i++)
		b[i][1]='#';

	
	for(R i=2;i<=n;i+=2)
		for(R j=2;j<=m;j++)
			c[i][j]='#';
	
	for(R i=1;i<=n;i++)
		c[i][m]='#';
	
	for(R i=1;i<=n;i++)
		for(R j=1;j<=m;j++)
		{

			cin>>a[i][j];
			if(a[i][j]=='#')
			{
				b[i][j]='#';c[i][j]='#';
			}
		}
	for(R i=1;i<=n;i++)
	{
		for(R j=1;j<=m;j++)
			cout<<b[i][j];
		cout<<endl;
	}
	cout<<endl;
	for(R i=1;i<=n;i++)
	{
		for(R j=1;j<=m;j++)
			cout<<c[i][j];
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 2304
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<complex>
#include<map>
using namespace std;

int main(){
  int n,now; cin >> n >> now;
  int mn = now, ans = -(1<<30);
  for(int i = 1; i < n; i++){
    cin >> now;
    ans = max(ans, now-mn);
    mn = min(mn, now);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
ll inf = 1e10;

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

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  ll s = 0;
  rep(i, n){cin >> a[i]; s += a[i];}
  ll x = 0, y = s;
  ll ans = inf;
  rep(i, n-1){
    x += a[i];
    y -= a[i];
    ans = min(ans, abs(x-y));
  }
  
  cout << ans << "\n";
}   

Measured memory_bytes: 1024
import sys
n=int(input())
d=list(map(int,input().split()))
if d[0]!=0:
    print(0)
    sys.exit(0)
if n==1:
    print(1)
    sys.exit(0)
for i in range(1,n):
    if d[i]==0:
        print(0)
        sys.exit(0)
dist=[0]*(n) 
for i in range(1,n):
    dist[d[i]]+=1
if dist[1]==0:
    print(0)
    sys.exit(0)
ans=1
mod=998244353
bef=dist[1]
total=dist[1]+1
for i in range(2,n):
    for j in range(dist[i]):
        ans=ans*bef
        ans=ans%mod
    total+=dist[i]
    bef=dist[i]
    if total==n:
        break
    if ans==0:
        break
print(ans)
#print(dist)

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

using namespace std;

int main()
 {
 long long int n,k,a;
 cin>>n>>k;
 if(n==0 ||n ==k)cout<<"0"<<endl;
 else if(n>k)cout<<min(n%k,abs(k-(n%k)))<<endl;
 else cout<<min(n,abs(n-k))<<endl;
 }


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

int main(){
  int X; cin>>X;
  int A,B; cin>>A>>B;
  cout<<X-A-((X-A)/B)*B<<endl;
  return 0;
}


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

int main(){
  ll x;
  ll t;
  ll r;
  int i;
  int f = 1;
  scanf("%lld", &x);

  i = 1;
  while(i <= x){
    t = i*(i + 1)/2;
    if(t >= x) break;

    i++;
  }

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

  return 0;
}


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
int A[110000];
char op[110000];

signed main() {
    cin >> N;
    cin >> A[0];
    for (int i = 1; i < N; i++)cin >> op[i] >> A[i];
    op[N] = '-'; A[N] = 0;

    int sum = A[0], total_minus = 0, cur_minus = 0, min_minus = LLONG_MAX;
    for (int i = 1; i <= N; i++) {
        if (op[i] == '+') {
            if (total_minus > 0)cur_minus += A[i];
        } else {
            if (total_minus > 0)min_minus = min(min_minus, total_minus + cur_minus);
            total_minus += A[i];
            cur_minus = 0;
        }
        sum += A[i];
    }
    if (min_minus == LLONG_MAX)min_minus = 0;
    cout << sum - 2 * min_minus;

}


Measured memory_bytes: 1152
#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;
template<typename key>
using ordered_set = tree<key, null_type, less<key>, rb_tree_tag, tree_order_statistics_node_update>;
#define F first
#define S second
#define T second.first
#define C second.second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
#define all(v) v.begin(),v.end()
#define OO 0x3f3f3f3fLL
#define INF 0x3f3f3f3f3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef pair<ll,pair<ll,ll>> piii;
const int N = 2e5+5, M= 20, mod = 1000000000;
const double EPS = 1e-10;

int main(){
    FIO
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int n;
    string s;
    cin>>n>>s;
    bool f= 0;
    int ans= 0, cnt = 0;
    for(int i=0; i<n; i++){
        if(s[i] == 'R')cnt++, ans++;
    }
    for(int i=0; i<cnt; i++){
        if(s[i] == 'R')ans--;
    }
    cout<<ans;
}


Measured memory_bytes: 3712
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String k = sc.next();
		int i = 0;
		char ans = '2';
		while(i < s.length()){
			ans = s.charAt(i);
			if(ans != '1')break;
			i++;
		}
		
		if(k.length()>3||Integer.parseInt(k)>i)System.out.println(ans);
		else System.out.println(1);
	}
}

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

if n == 0:
  print(x)
  exit()
  
p = list(map(int, input().split()))

for i in range(101):
  if not x-i in p :
    print(x-i)
    exit()
  elif not  x+i in p:
    print(x+i)
    exit()

Measured memory_bytes: 9208
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;

    int main(){
      int n;
      string a,b,c;
      cin >> n >> a >> b >> c;
      int ans=0;
      rep(i,n){
       int cnt=0;
       char x[3]={a[i],b[i],c[i]};
        sort(x,x+3);
        if(x[0]==x[2])cnt=0;
        else if(x[0]==x[1] || x[1]==x[2])cnt=1;
        else cnt=2;
        ans+=cnt;
      }
      cout << ans << endl;
      return 0;}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k,m;
    while(cin >> n >> k >> m,n){
        vector<int> v(n);
        iota(v.begin(),v.end(),1);
        v.erase(v.begin()+m-1);
        int now=m-1;
        while(v.size()!=1){
            now=(now+k-1)%v.size();
            v.erase(v.begin()+now);
        }
        cout << v[0] << '\n';
    }
}


Measured memory_bytes: 3136
from collections import Counter
import math
N = int(input())
Nso = []
Nruto = math.sqrt(N)
Nruto = math.floor(Nruto)
for i in range(2, Nruto+1):
    while N % i == 0:
        N = N//i
        Nso.append(i)
    if N == 1:
        break
    Nruto = math.sqrt(N)
    Nruto = math.floor(Nruto)
Nso.append(N)
if 1 in Nso:
    Nso.remove(1)
Nso = Counter(Nso)
ans = 0
for v in Nso.values():
    count = 0
    for i in range(1, v+1):
        if count+i > v:
            break
        else:
            count += i
            ans += 1

print(ans)


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << endl;
    // end

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int val[4] = {6000,4000,3000,2000};
  REP(i,4){
    int a,b;
    cin >> a >> b;
    --a;
    cout << (val[a]*b) << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<ctime>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;

char s[105], t[105];
bool cmp(char a, char b){
	return a > b;
}
int main()
{
	cin >> s >> t;
	sort(s, s + strlen(s));
	sort(t, t + strlen(t), cmp);
	if((string)s < (string)t) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
const int MAXN = 1e5+5;

int dp[MAXN][13];
string s;

int solve(int i, int sum) {
  if(i == s.size()) return sum == 5;
  if(dp[i][sum] != -1) return dp[i][sum];
  int res = 0;
  if(s[i] != '?') {
    int x = s[i] - '0';
    res = (res + solve(i+1, (sum*10+x) % 13)) % MOD;
  } else {
    for(int pos = 0;pos <= 9;pos++) {
      res = (res + solve(i+1, (sum*10+pos) % 13)) % MOD; 
    }
  }
  return dp[i][sum] = res;
}

int main() {
  cin>>s;
  memset(dp, -1, sizeof dp);
  cout<<solve(0,0)<<endl;
}

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

int main(){
	char serve[3][101];
	char latestServe;
	int APoint;
	int BPoint;
	bool isDeuce = false;
	while(true){
		cin >> serve[0];
		if(strlen(serve[0]) == 1){
			break;
		}
		cin >> serve[1] >> serve[2];
		APoint = 0;
		BPoint = 0;
		
		for(int i=0;i<3;i++){
			for(int j=1;j<101;j++){
				if(serve[i][j]=='A'){
					APoint++;
				}else if(serve[i][j]=='B'){
					BPoint++;
				}else if(serve[i][j]=='\0'){
					break;
				}
			  latestServe = serve[i][j];
				if(APoint == BPoint && APoint == 10){
					isDeuce = true;
				}
			}
			if(isDeuce){
				if(latestServe == 'A'){
					APoint++;
				}else{
					BPoint++;
				}
			}else{
				if(APoint > BPoint){
					APoint++;
				}else{
					BPoint++;
				}
			}
			isDeuce = false;
			cout << APoint << ' ' << BPoint << '\n';
			APoint = 0;
			BPoint = 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1140
#include<bits/stdc++.h>
using namespace std;
int freq1[26];
int freq2[26];
int main()
{
	string a,b;
	cin>>a>>b;
	int i,j;
	for(i=0;i<a.size();i++)
	freq1[a[i]-97]++;
	for(i=0;i<b.size();i++)
	freq2[b[i]-97]++;
	string s1,s2;
	s1="";
	s2="";
	for(i=0;i<26;i++)
	{
		for(j=0;j<freq1[i];j++)
		s1+=(i+97);
	}
	for(i=25;i>=0;i--)
	{
		for(j=0;j<freq2[i];j++)
		s2+=(i+97);
	}
	//cout<<s1<<","<<s2<<endl;
	if(s1<s2)
	cout<<"Yes";
	else
	cout<<"No";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false); cout.tie(NULL);
using namespace std;

int main()
{
	fastio;
	
	int n,a,b,i,j,mn=-1;
	cin>>n;
	vector<int> ar[n+1];
	vector<pair<int,int>> v;
	
	for(i=0;i<n-1;i++)
		cin>>a>>b , ar[a].pb(b) , ar[b].pb(a) , v.pb({a,b});
	
	for(i=1;i<=n;i++)
	{
		int tmp=ar[i].size();
		mn=max(mn,tmp);
	}
	
	int vis[mn+1];
	map<pair<int,int>,int> mp,ans;
	
	for(i=1;i<=n;i++)
	{
		memset(vis,0,sizeof(vis));
		for(auto el : ar[i])
		{
			if(ans.find({i,el})!=ans.end())
				vis[ans[{i,el}]-1]=1;
			else if(ans.find({el,i})!=ans.end())
				vis[ans[{el,i}]-1]=1;
		}
		for(auto el : ar[i])
		{
			if(mp.find({i,el})==mp.end() && mp.find({el,i})==mp.end())
			{
				for(j=0;j<ar[i].size();j++)
				{
					if(vis[j]==0)
					{
						ans[{i,el}]=ans[{el,i}]=j+1;
						vis[j]=1;
						mp[{el,i}]=mp[{i,el}]=1;
						break;
					}
				}
			}
		}
	}
	
	cout<<mn<<"\n";
	for(auto pair : v)
		cout<<ans[pair]<<"\n";
	return 0;
}


Measured memory_bytes: 34468
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        x: i128,
        k: i128,
        d: i128,
    }

    let x = x.abs();
    let quo = x / d;
    let rem = x % d;
    if quo > k {
        println!("{}", x - k * d);
        return;
    }
    let rk = k - quo;
    if rk % 2 == 0 {
        println!("{}", rem);
    } else {
        println!("{}", (rem - d).abs());
    }
}


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

using namespace std;

bool check(vector < string > &v, int &h, int &w, int &i, int &j){
	bool one = true, two = true;
	for(int k = 0; k < w; k++)
		if(v[i][k] == '#'){
			one = false;
			break;
		}
	for(int k = 0; k < h; k++)
		if(v[k][j] == '#'){
			two = false;
			break;
		}
	return one || two;
}

bool check_ans(vector < string > &v, int &h, int &w, int &i){
	for(int j = 0; j < h; j++)
		if(v[j][i] == '#')
			return false;
	return true;
}

int main(){
	int h, w, i, j;
	cin >> h >> w;
	vector < string > v(h);
	vector < pair < int, int > > ans;
	for(i = 0; i < h; i++)
		cin >> v[i];
	for(i = 0; i < h; i++){
		for(j = 0; j < w; j++){
			if(!check(v, h, w, i, j))
				ans.push_back({i,j});
		}
	}
	bool p;
	for(i = 0; i < h; i++){
		p = false;
		for(j = 0; j < w; j++){
			for(int k = 0; k < ans.size(); k++){
				if(ans[k].first == i && ans[k].second == j){
					cout << v[i][j];
					p = true;
					break;
				}
			}
		}
		if(p)
			cout << "\n";
	}		   
    return 0;
}

Measured memory_bytes: 512