akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		char[] wk;

		try {
			scanner = new Scanner(System.in);
			wk = scanner.nextLine().toCharArray();

			int res = 0;
			for (int i = 0; i < wk.length; i++) {
				if (wk[i] == '1') {
					res++;
				}
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private int divide(int[] wk) {
		boolean divide = true;
		int res = 0;
		for (int i = 0; i < wk.length; i++) {
			if (wk[i] % 2 == 0) {
				wk[i] = wk[i] / 2;
			} else {
				divide = false;
			}
		}
		if (divide) {
			res = divide(wk) + 1;
		}
		return res;
	}

	private void solveB() {
		Scanner scanner = null;
		int n = 0;

		try {
			scanner = new Scanner(System.in);
			n = scanner.nextInt();

			int[] wk = new int[n];

			for (int i = 0; i < wk.length; i++) {
				wk[i] = scanner.nextInt();
			}

			System.out.println(divide(wk));

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

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

int main() {
    ll N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    vector<vector<ll>> dp(N+1, vector<ll>(W+1, 0));
    for(ll i=0; i<N; i++) {
        for(ll j=0; j<=W; j++) {
            if(w[i] > j) dp[i+1][j] = dp[i][j];
            else dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
        }
    }

    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 80256
{-# LANGUAGE BangPatterns #-}
import Control.Applicative((<$>))
import Control.Monad
import Data.Map ((!))
import qualified Data.Map as M
-- import Data.IntMap ((!))
-- import qualified Data.IntMap as M
import qualified Data.List as L
import Data.Maybe (catMaybes)
-- import qualified Data.Char as C
-- import qualified Data.IntSet as I
import Debug.Trace
--------------------------------------------
readInt    = read :: String -> Int
getInt     = readInt <$> getLine
getIntList = map readInt . words <$> getLine
int2bin 0 =  []
int2bin n =  n `mod` 2 : int2bin (n `div` 2)
----------------------------------------------

howManyChoco d a = aux 1 1
  where
    aux day count
      | day + a <= d = aux (day + a) (count + 1)
      | otherwise    = count

main :: IO ()
main = do
  n <- getInt
  [d, x] <- getIntList
  as <- replicateM n getInt
  print $ x + sum (map (howManyChoco d) as)


Measured memory_bytes: 892
//AtCoder ABC090 A - Diagonal String
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    string c[3];
    for(auto&& ci:c){
        cin>>ci;
    }
    cout<<c[0][0]<<c[1][1]<<c[2][2]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define f(a,b,c) for(int i=a;i<=b;i+=c)
#define d(a,b,c) for(int i=a;i>=b;i-=c)  
using namespace std;
int a,b,c;
int main(){
	cin>>a>>b>>c;
	cout<<max(a+b*10+c,max(a+b+10*c,a*10+b+c))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef vector<vector<int>> Graph;
void add_edge(Graph& g, int from, int to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } else return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } else return false; }


struct UnionFind {
	UnionFind(int n) {
		par = new int[n + 1];
		size = new int[n + 1];
		height = new int[n + 1];
		for (int i = 0; i <= n; ++i) {
			par[i] = i;
			size[i] = 1;
			height[i] = 1;
		}
	}

	void unite(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b) return;
		if (height[a] < height[b]) {
			par[a] = b;
			size[b] += size[a];
		}
		else {
			par[b] = a;
			size[a] += size[b];
			if (height[a] == height[b]) {
				height[a]++;
			}
		}

	}

	int root(int a) {
		return par[a] == a ? a : par[a] = root(par[a]);
	}

	int getSize(int a) {
		return size[root(a)];
	}

	bool isSame(int a, int b) {
		return root(a) == root(b);
	}

	int* size;
	int* height;
	int* par;
};


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

  ll n,m; cin >> n >> m;
	//vector<ModInt> a(n); rep(i,n) {ll b ; cin >> b; a[i] = b;}

	UnionFind uf(n);
	rep(i, m) {
		int a,b;
		cin >> a >> b;
		a--;b--;
		uf.unite(a,b);
	}

	ll ans = 0;

	rep(i,n) {   chmax(ans,(ll) uf.getSize(i));}

	cout << ans << endl;
}



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

int main(){

    int n;
    cin >> n;

    vector<string> s(n);

    rep(i,n)cin >> s[i];

    int ab=0,a=0,b=0;

    int ans=0;

    rep(i,s.size()){
        rep(j,s[i].size()-1){
            if(s[i][j]=='A'&&s[i][j+1]=='B'){
                ans++;
            }
        }
        if(s[i][0]=='B'&&s[i].back()=='A'){
            ab++;
        }else if(s[i][0]=='B'){
            b++;
        }else if(s[i].back()=='A'){
            a++;
        }
    }

    ans+=max(0,ab-1);
    if(a>0&&ab>0){
        ans++;
        a--;
    }
    if(b>0&&ab>0){
        ans++;
        b--;
    }
    ans+=min(a,b);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 768
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  string str;
  char prev;
  long ii,cnt=0;
  cin >> str;

  prev = str[0];
  for(ii=1;ii<str.size();ii++){
    if(prev == str[ii]){
      cnt++;
      if(str[ii] == '0'){
	prev = '1';
      }
      else{
	prev = '0';
      }
    }
    else{
      prev = str[ii];
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
 
int main() {
	string x;
	cin >> x;
	int n = x.size();
	
	int ans = n;
	int rem = 0;
	char flag = 'S';
	int tcnt = 0, scnt = 0;
	rep(i,n) {
		if (x[i] == 'S') {
			while (x[i] == 'S' && i < n) 
			{
				scnt++; 
				i++;
			}
			while (x[i] == 'T' && i < n)
			{
				tcnt++;
				i++;
			}
			if (i != n) i--;
			ans -= 2*min(scnt, tcnt);
			
			if (scnt > tcnt) {
				rem = scnt-tcnt;
				scnt = rem;
				tcnt = 0;
			} else {
				scnt = tcnt = 0;
			}
			//cout << scnt << ' ' << tcnt << ' ' << i << endl;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3720
v = int(input())
G= [[int(i) for i in input().split()] for i in range(v)]
        
def prim(G, v):
    Vn = set([1])
    En = set([])
    V = set(range(1, v+1))
    while Vn != V:
        m = float('inf')
        for u in Vn:
            for v in V - Vn:
                if G[u - 1][v - 1] == -1:continue
                if G[u - 1][v - 1] < m:
                    m = G[u - 1][v -1]
                    k = (u,v)
        Vn.add(k[1])
        En.add(k)
    return En

print(sum(G[u - 1][v -1] for u,v in prim(G, v)))

Measured memory_bytes: 7992
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1616&lang=jp
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <numeric>
#include <functional>
using ll = long long;
using namespace std;

int const MOD = 1e9 + 7;

int main(void)
{
    ll n;
    while (cin >> n, n)
    {
        vector<ll> v(n);
        for (int i = 0; i < n; ++i)
            cin >> v[i];

        ll sum = accumulate(v.begin(), v.end(), 0);
        ll ave = sum / n;

        int ans = 0;
        for (int i = 0; i < n; ++i)
            if (ave >= v[i])
                ans++;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3176
#include<stdio.h>
int main()
{
	int a[100], num, i;

	scanf("%d", &num);

	for(i=0; i<num; i++)
	{
		scanf("%d", &a[i]);
	}

	for(i=num-1; i>=0; i--)
	{
		printf("%d", a[i]);
		
		if(i != 0)
		{
			printf(" ");
		}
	}

	printf("\n");

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
int a[2][230];
//int t[100005] , x[100005] , y[100005];
int main(){
	dhoom;
	string s;
	cin >> s;
	if(s[0] =='7' || s[1] == '7' || s[2] =='7')
		cout << "Yes" << endl;
	else 
		cout << "No" << endl;
	return 0;
}


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

bool primeNumber(int n){
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    return true;
}

int main(){
    int x;
    cin >> x;
    while(true){
        if(primeNumber(x)){
            cout << x << endl;
            return 0;
        }
        x++;
    }
}

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

int n;
vector<int> p;

string solve();

int main() {
  cin >> n;
  p.assign(n, 0);
  for(int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    p[--a] = i;
  }
  cout << solve() << endl;
  return 0;
}

string solve() {
  int now = 0, nows = 0;
  string ans;
  stack<int> st;
  while(st.size() > 0 || nows < n) {
    if(nows < n) st.push(p[nows++]);
    ans += '(';
    while(st.size() > 0 && now == st.top()) {
      ans += ')';
      ++now;
      st.pop();
    }
    if(st.size() > 0 && nows >= n) return ":(";
  }
  return ans;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
  
using namespace std;

/********** TEMPLATE STARTS HERE ***********/
  
#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define test int t; cin >> t; while(t--)
#define skip continue
#define stop break
#define sz(v) v.size()
#define endl '\n'
#define PI 3.1415926535897932384626433832795
#define EPS 1e-9
#define gcd __gcd 
#define FO(i, a) for(auto & i : a)
#define debug(a) cout << #a << ": " << a << endl
#define debug1(a, l, r) FR(i, l, r) cout << a[i] << " "; cout << endl
#define SET(a, b) memset(a, b, sizeof(a));
#define refresh fflush(stdout);
  
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pii> vii;
typedef vector <pll> vll;
  
const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;
  
template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
 
/*********** TEMPLATE ENDS HERE *************/

main()
{
	IOS
	int n;
	cin >> n;
	int odd = n / 2;
	int even = n / 2 + n % 2;
	cout << odd * even;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
  int dish[5];
  for(int i = 0; i < 5; i++) cin >> dish[i];

  int idx;
  int trade = 9;
  for(int i = 0; i < 5; i++){
    if(dish[i] % 10 != 0 && trade > dish[i]%10){
      idx = i;
      trade = dish[i] % 10;
    }
  }
  int temp = dish[idx];
  dish[idx] = dish[4];
  dish[4] = temp;

  for(int i = 0; i < 4; i++){
    if(dish[i] % 10 != 0){
      dish[i] = (1+dish[i]/10)*10;
    }
  }

  int sum = 0;
  for(int i = 0; i < 5; i++){
    sum += dish[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define MOD 1000000007
#define int long long
signed main(){
  int N,M;
  cin>>N>>M;
  vector<pair<int,int>> A(N);
  rep(i,0,N) cin>>A.at(i).first>>A.at(i).second;
  sort(A.begin(),A.end());
  int ans=0;
  rep(i,0,N){
    if(A.at(i).second<M){
      M-=A.at(i).second;
      ans+=A.at(i).first*A.at(i).second;
    }
    else{
      ans+=A.at(i).first*M;
      break;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

vector<string> split(const string &s,char c='T'){
    vector<string> ret;
    stringstream ss(s);
    string t;
    while(getline(ss,t,c)){
        ret.push_back(t);
    }
    return ret;
}

bool dp[16020], tmp[16020];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    int x, y;
    cin >> s >> x >> y;
    vector<string> vs = split(s);
    vector<int> dx, dy;
    rep(i, 0, vs.size()){
        if(i % 2 == 0){
            dx.push_back(vs[i].size());
        }else{
            dy.push_back(vs[i].size());
        }
        // cout << vs[i].size() << endl;
    }
    bool ans = true;
    dp[8010 + dx[0]] = true;
    rep(i, 1, dx.size()){
        rep(j, 0, 16020) tmp[j] = false;
        rep(j, 0, 16020){
            if(dp[j] == true){
                tmp[j + dx[i]] = true;
                tmp[j - dx[i]] = true;
            }
        }
        swap(dp, tmp);
    }
    ans &= dp[8010 + x];
    rep(i, 0, 16020) dp[i] = false;
    dp[8010] = true;
    rep(i, 0, dy.size()){
        rep(j, 0, 16020) tmp[j] = false;
        rep(j, 0, 16020){
            if(dp[j] == true){
                tmp[j + dy[i]] = true;
                tmp[j - dy[i]] = true;
            }
        }
        swap(dp, tmp);
    }
    ans &= dp[8010 + y];
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

typedef long long int64;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int counter(int x) {
  if (x == 0)
    return 0;
  return counter(x >> 1) + (x & 1);
}

int main() {
  int N;
  int A[20];
  int x[20][20], y[20][20];

  std::cin >> N;
  for (int i = 1; i <= N; i++) {
    std::cin >> A[i];
    for (int j = 1; j <= A[i]; j++) {
      std::cin >> x[i][j] >> y[i][j];
    }
  }

  int maxv = 0;
  for (int bits = 1; bits < (1 << N); bits++) {
    bool ok = true;
    for (int i = 1; i <= N; i++) {
      if (!(bits & (1 << (i - 1))))
        continue;
      for (int j = 1; j <= A[i]; j++) {
        if (((bits >> (x[i][j] - 1)) & 1) ^ y[i][j])
          ok = false;
      }
    }
    if (ok)
      maxv = max(maxv, counter(bits));
  }

  std::cout << maxv << std::endl;
  return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>

int main(){
    int a, b, c, d, x, y;

    scanf("%d %d %d %d", &a, &b, &c, &d);

    x = a + b;
    y = c + d;

    if(x > y)
        printf("Left\n");
    else if(x < y)
        printf("Right\n");
    else
        printf("Balanced\n");
    
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string.h>
#define N 120000
using namespace std;
long long s[N],t[N],a[N];
long long ans,n,m;
long long add(long long x,long long y,long long l,long long r){
	if(x==0)x=m;
	if(y==0)y=m;
	l%=m;
	r%=m;
//	printf("%lld %lld %lld %lld\n",x,y,l,r);
	t[x]+=l-1;
	t[y+1]-=r;
	s[x]+=1;
	s[y+1]-=1; 
}
int main(){
	scanf("%lld%lld",&n,&m);
	for(long long i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(long long i=1;i<=n;i++){
		a[i]+=a[i-1]/m*m;
		while(a[i]<a[i-1])a[i]+=m;
	}
	for(long long i=1;i<n;i++){
		if(a[i+1]-a[i]<2)continue;
		if((a[i])/m==(a[i+1]-1)/m){
			add((a[i]+1)%m,(a[i+1])%m,0,a[i+1]-a[i]-1);
		}else{
			long long o=m-(a[i]+1)%m; 
			add((a[i]+1)%m,m,0,o);
			add(1,a[i+1]%m,o+1,(o+a[i+1]%m)%m);
		}
	}
	for(long long i=1;i<=m;i++)s[i]+=s[i-1];
	for(long long i=1;i<=m;i++)s[i]+=s[i-1];
	for(long long i=1;i<=m;i++)t[i]+=t[i-1];
	for(long long i=1;i<=m;i++)s[i]+=t[i];
	for(long long i=1;i<=m;i++)ans=max(ans,s[i]);
	printf("%lld\n",a[n]-a[1]-ans);
}

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

int n;

int z,w;
int a[2010];

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

	for(int i = 0;i<n;i++)
	{
		cin >> a[i];
	}
	if(n == 1)
	{
		cout << abs(a[n - 1] - w) << endl;
		return 0;
	}
	cout << max(abs(a[n - 1] - w) , abs(a[n - 1] - a[n - 2])) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)


LL dp[50][500][500];


int main(){
    int N;cin >> N;
    int ma,mb;cin >> ma >> mb;
    vector<int> a(N);
    vector<int> b(N);
    vector<int> c(N);
    rep(i,N)cin >> a[i] >> b[i] >> c[i];


    rep(i,50)rep(j,500)rep(k,500)dp[i][j][k] = INF;
    dp[0][0][0] = 0;

    rep(i,N)rep(j,500)rep(k,500){
        if(dp[i][j][k] >= INF)continue;
        // 使うとき
        chmin(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k] + c[i]);
        // 使わないとき
        chmin(dp[i+1][j][k],dp[i][j][k]);
    }

    LL ans = INF;
    for(int j = 1;j < 500;++j)for(int k = 1;k < 500;++k){
        if(ma * k != mb * j)continue;
        chmin(ans,dp[N][j][k]);
    }
    if(ans == INF)cout << -1 << endl;
    else cout << ans << endl;
}


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

int main(){
    int n;
    long long ans=0;
    cin>>n;
    for(int i=1; i<=n; i++){
        if(i % 3 !=0 && i % 5 != 0){
            ans+=i;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3628
S = input()
first = int(S[:2])
second = int(S[2:])
if((first>12 or first==0) and (second>12 or second==0)):
    print("NA")
elif(first<=12 and (second>12 or second==0)):
    print("MMYY")
elif(second<=12 and (first>12 or first==0)):
    print("YYMM")
else:
    print("AMBIGUOUS")

Measured memory_bytes: 3060
from collections import Counter
N = int(input())
s = []
cnt = 0
for _ in range(N):
  a = str(input())
  alist = sorted(list(a))
  s.append(str(''.join(alist)))
  
l = Counter(s)
for i in l.values():
  if i > 1:
    cnt += (i - 1) * i / 2
print(int(cnt))

Measured memory_bytes: 19828
#include <stdio.h>
#include <string.h>
#include<algorithm>
using namespace std;
char b[2005][2005];
int w1[2005][2005];
int h1[2005][2005];
int main()
{
    int h,w;
    scanf("%d%d",&h,&w);
    for(int x=0; x<h; x++)
    {
        scanf("%s",b[x]);
    }
    int sum;
    int biao;
    for(int x=0; x<h; x++)
    {
        sum=0;
        biao=-1;
        for(int y=0; y<w; y++)
        {
            if(b[x][y]=='#'&&y==0)
            {
                w1[x][y]=0;
                biao=y;
            }
            else if(b[x][y]=='#'&&y!=0)
            {
                w1[x][y]=0;
                for(int v=biao+1; v<y; v++)
                {
                    w1[x][v]=sum;
                }
                sum=0;
                biao=y;
            }
            if(b[x][y]=='.'&&y!=w-1)
            {
                sum++;
            }
            else if(b[x][y]=='.'&&y==w-1)
            {
                sum++;
                for(int v=biao+1; v<=y; v++)
                {
                    w1[x][v]=sum;
                }
            }
        }
    }
    for(int x=0; x<w; x++)
    {
        sum=0;
        biao=-1;
        for(int y=0; y<h; y++)
        {
            if(b[y][x]=='#'&&y==0)
            {
                h1[y][x]=0;
                biao=y;
            }
            else if(b[y][x]=='#'&&y!=0)
            {
                h1[y][x]=0;
                for(int v=biao+1; v<y; v++)
                {
                    h1[v][x]=sum;
                }
                sum=0;
                biao=y;
            }
            if(b[y][x]=='.'&&y!=h-1)
            {
                sum++;
            }
            else if(b[y][x]=='.'&&y==h-1)
            {
                sum++;
                for(int v=biao+1; v<=y; v++)
                {
                    h1[v][x]=sum;
                }
            }

        }
    }
    int ans=0;
    for(int x=0; x<h; x++)
    {
        for(int y=0; y<w; y++)
        {
            if(w1[x][y]+h1[x][y]>ans)
            {
                ans=w1[x][y]+h1[x][y];
            }
        }
    }
    printf("%d\n",ans-1);
    return 0;
}


Measured memory_bytes: 35456
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();

		cost = new int[n];
		effect = new int[n][m];
		used = new boolean[n];
		for(int i = 0; i < n; i++){
			cost[i] = sc.nextInt();

			for(int j = 0; j < m; j++){
				effect[i][j] = sc.nextInt();
			}
		}

		int result = dfs(0, n, m, x);
		System.out.println(result != Integer.MAX_VALUE ? result : -1);
	}

	static int cost[];
	static int effect[][];
	static boolean used[];

	static int dfs(int depth, int n, int m, int x){
		if(depth == n){
			int result[] = new int[m];
			int total = 0;
			for(int i = 0; i < n; i++){
				if(used[i]){
					for(int j = 0; j < m; j++){
						result[j] += effect[i][j];
					}

					total += cost[i];
				}
			}

			for(int i = 0; i < m; i++){
				if(result[i] < x){
					return Integer.MAX_VALUE;
				}

			}

			return total;
		}

		int result = Integer.MAX_VALUE;
		used[depth] = false;
		result = Math.min(result, dfs(depth + 1, n, m, x));
		used[depth] = true;
		result = Math.min(result, dfs(depth + 1, n, m, x));

		return result;
	}

}



Measured memory_bytes: 29648
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String buffer;
		try {
			while ((buffer = reader.readLine())  != null) {
				Integer W = Integer.valueOf(buffer.substring(0, buffer.indexOf(" ") == -1 ? buffer.length() : buffer.indexOf(" ")));
				buffer = buffer.substring(buffer.indexOf(" ") + 1);
				Integer H = Integer.valueOf(buffer.substring(0, buffer.indexOf(" ") == -1 ? buffer.length() : buffer.indexOf(" ")));
				buffer = buffer.substring(buffer.indexOf(" ") + 1);
				Integer x = Integer.valueOf(buffer.substring(0, buffer.indexOf(" ") == -1 ? buffer.length() : buffer.indexOf(" ")));
				buffer = buffer.substring(buffer.indexOf(" ") + 1);
				Integer y = Integer.valueOf(buffer.substring(0, buffer.indexOf(" ") == -1 ? buffer.length() : buffer.indexOf(" ")));
				buffer = buffer.substring(buffer.indexOf(" ") + 1);
				Integer r = Integer.valueOf(buffer.substring(0, buffer.indexOf(" ") == -1 ? buffer.length() : buffer.indexOf(" ")));
				if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) {
					System.out.println("Yes");
				}
				else {
					System.out.println("No");
				}
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}

Measured memory_bytes: 24296
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func minInt(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minUint(a, b uint) uint {
	if a < b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func minUint64(a, b uint64) uint64 {
	if a < b {
		return a
	}
	return b
}

func maxInt(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxUint(a, b uint) uint {
	if a < b {
		return b
	}
	return a
}
func maxInt64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func maxUint64(a, b uint64) uint64 {
	if a < b {
		return b
	}
	return a
}

func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()

	s := readString()
	a := make([]bool, 26)
	for _, r := range s {
		a[r-'a'] = true
	}
	for i := range a {
		if !a[i] {
			s := string([]rune{'a' + rune(i)})
			println(s)
			return
		}
	}
	println("None")

}


Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
 
using namespace std;
 
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
 
typedef vector<int> vi;
typedef pair<int,int> pii;
 
int main(void) {
  int i,j;
  ll a,b,x;
  cin>>a>>b>>x;
  if(x==1){
    cout<<(b-a+1)<<endl;
    return 0;
  }
  ll ans=b/x;
  if(a)
    ans-=(a-1)/x;
  else ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  long n, m;
  cin >> n >> m;
  vector<long>a;
  vector<long>b;
  a.push_back(-1);
  for(long i = 0; i < m; i++){
    long x;
    cin >> x;
    a.push_back(x);
  }
  a.push_back(n+1);
  for(long i = 0; i < m + 1; i++){
    long d = a[i+1] - a[i] - 2;
    if(d < 0){
      cout << 0;
      return 0;
    }
    b.push_back(d);
  }
  long mn = *max_element(b.begin(),b.end()) + 1;
  vector<long>dp(mn);
  dp[0] = 1;
  dp[1] = 1;
  for(long i = 2; i < mn; i++){
    dp[i] = dp[i-2] + dp[i-1];
    dp[i] %= 1'000'000'007;
  }
  long ans = 1;
  
  for(auto x : b){
    ans *= dp[x];
    ans %= 1'000'000'007;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 1400
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=200200;
int i,j,k,n,m,l,r,mid,ch,ff;
int a[N];
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
bool check(int x) {
	int lt,l,r,i;
	lt=a[n]>x;
	for (i=1;i<n;i++) {
		l=a[n-i]>x;
		r=a[n+i]>x;
		if (l==lt || r==lt) return lt;
		lt=l;
	}
	return lt;
}
int main() {
	R(n);
	for (i=1;i<2*n;i++) R(a[i]);
	l=1;r=2*n-1;
	while (l<r) {
		mid=(l+r-1)>>1;
		if (check(mid)) l=mid+1;
		else r=mid;
	}
	printf("%d\n",l);
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;
int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  vll num(26, 0);
  re(i, s.size()) num[s[i]-'a']++;
  for(int i=0;i<26;i++){
    if(num[i]==0){
      char c = 'a'+i ;
      std::cout << c << '\n';
      return 0;
    }
  }
  std::cout << "None" << '\n';
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, m;
    cin >> n >> m;

    vl v(n);  // v[i] : 箱iに赤いボールが入っている可能性があるなら1
    vl cnt(n, 1);  // cnt[i] : 箱iのボールの個数
    v[0] = 1;
    rep(loop, m) {
        ll x, y;
        cin >> x >> y;
        x--;  y--;
        if(v[x]) {
            v[y] = 1;
        }
        cnt[x]--;
        cnt[y]++;
        if(cnt[x] == 0) {
            v[x] = 0;
        }
    }

    ll ans = 0;
    rep(i, n) {
        if(v[i]) {
            ans++;
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 1792
#include <cmath>
#include <iomanip>
#include <iostream>

using namespace std;

int main()
{
    double x1, y1, x2, y2, d;

    cin >> x1 >> y1 >> x2 >> y2;

    d = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));

    cout << fixed << setprecision(15) << d << endl;

    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
const ll INF=1e18+7;
const ll MOD=1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N;
	cin >> N;
	ll x4=0,x2=0,xo=0;
	FOR(i,0,N){
		ll a;
		cin >> a;
		if(a%4==0){
			x4++;
		}else if(a%2==0){
			x2++;
		}else{
			xo++;
		}
	}
	if(x4>=(N-x2+min(1ll,x2))/2 ) {
		cout << "Yes" << endl;
	}else{
		cout << "No"  << endl;
	}
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

#ifdef DEBUG
#else
    #define cerr if (false) cerr
#endif

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int x;
    cin >> x;
    cout << 1 - x;
    return 0;
}

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

public class Main{
	public static void main(String[] arg) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int w = Integer.parseInt(br.readLine());
		
		br.close();
		
		System.out.println( (n*n) - w);
	}
}

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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>
#define all(a) a.begin(),a.end()

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

    vector<int> sub(n);
    sub[0] = 0;
    for(int i=1; i<(int)s.length(); ++i){
        if(s[i-1]=='A' && s[i]=='C'){
            sub[i] = 1+sub[i-1];
        }
        else
            sub[i] = sub[i-1];
    }

    while(q--){
        int l, r;
        cin >> l >> r;
        --l, --r;
        cout << sub[r]-sub[l] << endl;
    }
}

Measured memory_bytes: 3824
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0

for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500 *i + 100 *j + 50 *k == X:
        count += 1

print(count)


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

int main(){
  int a[5],sum=0;
  for(int i=0;i<5;i++){
    cin >> a[i];
    if(a[i]%10!=0)
    sum += (a[i]/10+1)*10;
    else
    sum += a[i];
  }
  for(int i=0;i<5;i++){
   if(a[i]%10!=0)
   	a[i] = 10-a[i]%10;
   else
    a[i]=0;
  }
  sort(a,a+5);
  cout << sum-a[4] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define N 100
int main()
{
     long int    n,m,s,x;
     scanf("%ld%ld",&n,&m);
     if(2*n>=m)
     {
         s=m/2;
     }
    else
    {
        x=m-2*n;
        s=n+x/4;
    }
    printf("%ld",s);
    return 0;
}

Measured memory_bytes: 128
def main():
  n = int(input())
  nums = list(map(int, input().split()))
  result = 1
  if 0 in nums:
    print(0)
    return
  else:
    for i in nums:
      result *= i
      if result > 1000000000000000000:
        print(-1)
        return
    print(result)
    return


if __name__ == "__main__":
  main()

Measured memory_bytes: 21524
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
//const ll MOD=(ll)1e9+7;
const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);
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; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

void solve(int ca){
    int N; cin>>N;
    long long cnt[100010]={0};
    //vector<int> cnt(100010,0);
    ll ans=0ll;
    for (int i = 0; i < N; ++i) {
        ll a;
        cin>>a;
        cnt[a]++;
        ans+=(ll)a;
    }

    int Q; cin>>Q;
    for (int i = 0; i < Q; ++i) {
        ll b,c; cin>>b>>c;
        ans+=(ll)cnt[b]*(c-b);
        cnt[c]+=cnt[b];
        cnt[b]=0;
        cout<<ans<<endl;
    }

}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 4404
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int n;

    cin >> n;

    int min = 3000000;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        if (p < min) {
            ans++;
            min = p;
        }
    }
    cout << ans << 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;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  string n;
  cin >> n;
  string ans = "No";
  rep(i,n.size())if(n[i] == '9')ans = "Yes";
  cout << ans << endl;
}


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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

#include <boost/range/algorithm.hpp> // boost::sort(arr)


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

  int n, m;
  cin >> n >> m;
  vector<tuple<int, int, int>> pref_year_city;
  rep(i, m) {
    int p, y;
    cin >> p >> y;
    pref_year_city.emplace_back(p, y, i);
  }
  boost::sort(pref_year_city);
  unordered_map<int, pair<int, int>> city_pref_cnt;
  int cnt = 0;
  int prev_p = 0;
  for(auto & pyc : pref_year_city) {
    int p, y, c;
    tie(p, y, c) = pyc;
    if (p == prev_p) {
      ++cnt;
    } else {
      cnt = 1;
    }
    prev_p = p;
    city_pref_cnt[c] = make_pair(p, cnt);
  }
  rep(i, m) {
    cout << setfill('0') << setw(6) << city_pref_cnt[i].first;
    cout << setfill('0') << setw(6) << city_pref_cnt[i].second << endl;
  }
}


Measured memory_bytes: 6772
import java.util.Scanner;

public class Main {
	private int[] card;
	private int[] temp;

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		card = new int [2 * n];
		temp = new int [n];
		
		for (int i = 0; i < 2 * n; i++) {
			card[i] = i + 1;
		}
		
		int m = scan.nextInt();
		int command;
		for (int i = 0; i < m; i++) {
			command = scan.nextInt();
			if (command == 0) {
				reFull(n);
			}else {
				cut(command, n);
			}
			//disp(n);
		}
		
		disp(n);
	}
	
	private void reFull(int n) {
		cardTemp(n, n);
		for (int i = n - 1; i > -1; i--) {
			card[i * 2] = card[i];
		}
		for (int i = 0; i < n; i++) {
			card[i * 2 + 1] = temp[i];
		}
	}
	
	private void cut(int k, int n) {
		if (k <= n) {
			cardTemp(0, k);
			k--;
			for (int i = 0; i < 2 * n - k - 1; i++) {
				card[i] = card[i + k + 1];
			}
			for (int i = 0; i < k + 1; i++) {
				card[2 * n - 1 - k + i] = temp[i];
			}
		}else {
			cardTemp(k, 2 * n - k);
			k--;
			for (int i = 0; i < k + 1; i++) {
				card[2 * n - 1 - i] = card[2 * n - 1 - i - (2 * n - k - 1)];
			}
			for (int i = 0; i < 2 * n - 1 - k; i++) {
				card[i] = temp[i];
			}
		}
		
	}
	
	private void cardTemp(int begin, int k) {
		for (int i = begin; i < k + begin; i++) {
			temp[i-begin] = card[i];
		}
	}
	
	private void disp(int n){
		for (int i = 0; i < 2 * n; i++) {
			System.out.println(card[i]);
		}
	}

}

Measured memory_bytes: 21508
#include<bits/stdc++.h>
using namespace std;
int n,a[300001];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	multiset<int> s(a,a+n);
	int ans=0;
	while(!s.empty())
	{
		int x=*s.rbegin();s.erase(--s.end());
		for(int i=(1<<30);i;i>>=1)
			if(s.count(i-x))
			{
				ans++;
				s.erase(s.find(i-x));
				break;
			}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 12416
#include <iostream>
using namespace std;
int main() {
    int h,w,i,j,k;
    string a[101],b[205];
    cin>>h>>w;
    for (i=0;i<h;i++){
        cin>>a[i];
        for (j=0;j<w;j++){
            for (k=0;k<2;k++){
                b[2*i+k]+=a[i][j];
            }
        }
    }
    for (i=0;i<2*h;i++){
        cout<<b[i]<<endl;
    }  
    return 0;
}

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

int Data[300];

int main() {
	int n, x;

	while (cin >> n >> x && n != 0 || x != 0) {
		memset(Data, 0, sizeof(Data));
		for (int i = 1; i <= n - 2; ++i) {
			for (int i2 = i + 1; i2 <= n - 1; ++i2) {
				for (int i3 = i2 + 1; i3 <= n; ++i3) {
					Data[i + i2 + i3]++;
					if (i + i2 + i3 > x) {
						break;
					}
				}
			}
		}

		cout << Data[x] << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <random>
#include <queue>
using namespace std;
typedef long long int ll;

int cnt[101];
int cnt1[101];
int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	int ans=0;
	for(int i=0;i<3;i++){
		int m; cin >> m;
		if(i==0){
			for(int j=0;j<m;j++){
				int x; cin >> x;
				cnt[x]--;
			}
		}
		else if(i==1){
			for(int j=0;j<m;j++){
				int x; cin >> x;
				cnt1[x]++;
			}
		}
		else{
			for(int j=0;j<m;j++){
				int x; cin >> x;
				if(cnt[x]==0||cnt1[x]==1){
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}


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

using namespace std;

int main() {
	int H , W;

	cin >> H >> W;
	vector<string> a;

	for (int i = 0; i < H;i++) {
		string s;
		cin >> s;
		bool is_space = true;
		for (char c : s) {
			if (c == '#') {
				is_space = false;
				break;
			} 
		}
		if (is_space == true) {
			continue;
		}
		a.push_back(s);
	}

	int new_h = a.size();

	vector<string> result(new_h);

	for(int x = 0; x < W; x++) {
		bool is_space = true;
		for (int y = 0; y < new_h; y++) {
			if (a[y].at(x) =='#') {
				is_space = false;
				break;
			}
 
		}
		if (is_space == true) {
			continue;
		}
		for (int y = 0; y < new_h; y++) {
			result[y] += a[y].at(x);
		}

	}

	for (int y = 0; y < new_h; y++) {
		cout << result[y] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
using namespace std;
 
int main(){
   int n;
   while(cin>>n){
       int ans;
       ans=n%39;
if(ans==0) ans=39;
       if(ans<10) cout<<"3C0"<<ans<<endl;
       else cout<<"3C"<<ans<<endl;
   }
    return 0;
}


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

int main(void) {
    int64_t A,B,K;
    cin >> A >> B >> K;

    if(A< K) {
        B -= (K-A);
        A = 0;
        if(B < 0) B = 0;
    } else {
        A -= K;    
    }

    cout << A << " " <<  B << "\n";
    return 0;
}


Measured memory_bytes: 256
S = input()
A = ["R", "U", "D"]
B = ["L", "U", "D"]
for i in range(len(S)):
    if i % 2 == 0:
        if not S[i] in A:
            print("No")
            exit()

    else:
        if not S[i] in B:
            print("No")
            exit()

print("Yes")

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

int N, K;
int H[1000000];

int main(){

	cin >> N >> K;

	vector<int> H(N);

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

	sort(H.begin(), H.end());

	ll ans = 0;

	for (int i=0; i<N-K; i++) {
		ans += H[i];
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
    int64_t l1 = 2;
    int64_t l2 = 1;
    int64_t l3;
    int n;
    cin >> n;
    if (n == 1){
        cout << 1 << endl;
    }
    else{
        for (int i = 0;i < n-1; i++){
            l3 = l1 + l2;
            l1 = l2;
            l2 = l3;
        }
    cout << l3 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(ll i = a; i <= (n); ++i)
#define repD(i, a, n) for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (long long) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define MAXN 5000000
const long double PI = 3.141592653589793238462643383;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<double> vd;
typedef vector<pii> vii;
const long long mod = 998244353;
int Ceil(int a, int b){
    if(a%b==0) return a/b;
    else return (a/b)+1;
}

ll power(ll a,ll b){
    ll ans = 1;
    while(b){
        if(b&1)
            ans*= a;
        ans%=mod;
        a*= a;
        a%=mod;
        b/=2;
    }
    return ans;
}
int main(){
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);   
    freopen("output.txt", "w", stdout);
    #endif
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int n;
    cin>>n;
    set<string> s;
    for(int i = 0;i<n;i++){
        string v;
        cin>>v;
        s.insert(v);
    }
    cout<<s.size();
    return 0;
}

Measured memory_bytes: 19288
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
  int n, x, y, b, p;
  int t1, t2;

  cin >> n;
  for(int i = 0;i < n; i++){
    cin >> x >> y >> b >> p;
    t1 = x * b + y * p;
    if(b < 5) b = 5;
    if(p < 2) p = 2;
    t2 = x * b + y * p;
    cout << min(t1, (int)(t2 * 0.8)) << endl;
  }
}


Measured memory_bytes: 1160
#include <stdio.h>
#include <math.h>
typedef long long ll;

int main()
{
	ll k;
	ll n;
	scanf("%lld %lld",&n,&k);
	ll ans=1;
	while(n/k!=0){
		ans++;
		n=n/k;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1700