akhauriyash/Code-Regression huggingface dataset:
n = int(input())

taro_list=[]
hana_list=[]
alfa = list('abcdegfhijklmnopqrstuvwxyz')

while n>0:
  taro, hana = map(str,input().split())
  taro_list.append(taro)
  hana_list.append(hana)
  n = n - 1

a=0
b=0
for (ta, ha) in zip (taro_list, hana_list):
  if ta > ha:
    a = a + 3
  elif ta < ha:
    b = b + 3
  else:
    a = a + 1
    b = b + 1
    
print(a, b)


Measured memory_bytes: 5624
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long A, B;
  cin >> A >> B;
  if (B % A == 0) cout << A + B << endl;
  else cout << B - A << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
#include<unordered_map>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(int i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
/* Coding Space*/
int main(){
  ll n; cin >> n;
  vi a(n); rep(i,n) cin >> a[i];
  ll sum = 0; rep(i,n) sum += a[i];
  ll k = n * (n+1)/2;
  if(sum%k){
    cout << "NO" << endl;
    return 0;
  }
  k = sum/k;
  
  vector<ll> d(n);
  rep(i,n){
    if(i==0)
      d[0] = a[0] - a[n-1];
    else
      d[i] = a[i] - a[i-1];
  }
  rep(i,n)
    d[i] -= k;
  rep(i,n){
    if(d[i] > 0 || d[i] % n){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int D;
vll C, T;
vvll S;

inline ll calcScore() {
	vll last(26, -1);	
	ll score = 0;
	for (int i = 0; i < D; i++) {
		score += S[i][T[i]];
		last[T[i]] = i;
		for (int j = 0; j < 26; j++) {
			score -= (i-last[j])*C[j];
		}
	}
	return (score);
}

void Main() {
	cin >> D;
	C = makeVector(26, 0ll); cin >> C;
	S = makeVector(D, 26, 0ll); cin >> S;
	T = makeVector(D, 0ll);
	
	ll pp = -1;
	for (int i = 0; i < D; i++) {
		ll p = 0;
		if (pp == 0) p = 1;
		for (int j = 1; j < 26; j++) {
			if (j == pp) continue;
			if (S[i][p] < S[i][j]) p = j;
		}
		T[i] = p;
		pp = p;
	}

	//cout << calcScore() << endl;

	ll maxv = -LLINF;
	int M = 240000;
	for (int i = 0; i < M; i++) {
		int d = rand()%D;
		int q = rand()%26;
		ll tmp = T[d];
		T[d] = q;
		ll score = calcScore();
		if (score <= maxv) T[d] = tmp;
		else maxv = score;
	}
	
	for (int i = 0; i < D; i++) {
		cout << T[i]+1 << el;
	}
	//cout << maxv << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5;
const ll mod=1e9+7;
int n;
int a[105];
int main()
{
    while(cin>>n)
    {
        for(int i=1;i<=n;i++)
            cin>>a[i];
        int cnt=0;
        for(int i=2;i<=n;i++)
        {
            if(a[i]==a[i-1])
            {
                a[i]=-1;
                cnt++;
            }
        }
        printf("%d\n",cnt);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

using namespace std;

typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> pl;
typedef double db;

#define ini(x) int x; cin >> x
#define inl(x) ll x; cin >> x
#define ins(x) string s; cin >> x

#define out(x) cout << x;
#define outb(x) cout << x << ' ';
#define outn(x) cout << x << '\n';

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()

#define forn(i, s, e) for (int i = s; i < e; i++)
#define forr(i, s, e) for (int i = s; i >= e; i--) 
#define ford(i, s, e, d) for (int i = s; i < e; i += d)
#define fors(i, n) for (int i = 1; i*i <= n; i++)

string binary(int x) {
	string ret;
	while (x != 1) {
		ret += (x % 2) ? '1'  : '0';
		x /= 2;
	}
	ret += '1';
	reverse(all(ret));
	return ret;
}

int rn(string s) {
	int ret = 0;
	forn(i, 1, s.length()) if (s[i] == '1') ret++;
	return ret;
}

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

	ini(l);
	string b = binary(l);
	int n = b.length();
	outb(n);
	outn((n-1) * 2 + rn(b));
	int e = 1;
	forr(i, n, 2) {
		cout << i-1 << ' ' << i << ' ' << e << '\n';
		cout << i-1 << ' ' << i << ' ' << 0 << '\n';
		if (b[n-i+1] == '1') {
			e *= 2;
			cout << i-1 << ' ' << n << ' ' << e << '\n';
			e++;
		} else {
			e *= 2;
		}
	}
		
	return 0;
}


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

int main()
{
    int n,ans=0;
    cin>>n;
    int a[n];//c[100001]={};
    for(int i=0;i<n;i++)
        {
            cin>>a[i];
            //++c[a[i]];
        }
    sort(a,a+n);
    cout<<abs(a[n/2]-a[(n/2)-1]);
    return 0;
}



Measured memory_bytes: 3976
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

struct mint{
    static const long long MOD = 1000000007;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

mint operator*(long long l, mint r){ return r * l; }

std::ostream& operator<<(std::ostream& stream, const mint& m){
    stream << m.v;
    return stream;
}

int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vector<ll> num(27, 0);
    for(char c: s){
        num[c - 'a']++;
    }
    mint ans = 1;
    for(ll x : num){
        ans *= (x + 1);
    }
    ans -= 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n,a[222222];
int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		int x;
		scanf("%d",&x);
		a[x] = i;
	}
	int cnt = 0, res = 0;
	for(int i=1; i<=n; i++){
		if(a[i] > a[i-1])
			cnt ++;
		else
			cnt = 1;
		res = max(res, cnt);
	}
	printf("%d\n",n - res);
	return 0;
}


Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author kessido
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        B754 solver = new B754();
        solver.solve(1, in, out);
        out.close();
    }

    static class B754 {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            long x = in.NextLong();
            int min = Integer.MAX_VALUE;
            for (int i = 0; i <= 10; i++) {
                int x1 = (int) ((x / (long) Math.pow(10, i)) % 1000);
                min = Math.min(min, Math.abs(x1 - 753));
            }
            out.println(min);
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine(), " \t\n\r\f,");
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }

    static class OutputWriter extends PrintWriter {
        public OutputWriter(Writer out) {
            super(out);
        }

        public OutputWriter(File file) throws FileNotFoundException {
            super(file);
        }

        public OutputWriter(OutputStream out) {
            super(out);
        }

    }
}



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

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int go(string s)
{
	int n = SZ(s);
	vector<int> a(n);
	FOR(i, 0, n) a[i] = (int)s[i];
	
	while(SZ(a) > 1)
	{
		n = SZ(a);
		vector<int> c(n);
		c[0] = a[0];
		FOR(i, 1, n) c[i] = c[i - 1] ^ a[i];
		
		int lg = 0;
		while((1 << (lg + 1)) <= n) lg++;
		
		int r = n - (1 << lg);
		vector<int> na(r + 1);
		FOR(i, 0, r + 1)
		{
			na[i] = c[(1 << lg) + i - 1];
			if (i) na[i] ^= c[i - 1];
		}
				
		a = na;
	}
	
	return a[0];
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	string s;
	cin >> s;

	int cnt[3];
	FILL(cnt, 0);
	for(auto i: s) cnt[i - '1']++;
	
	string t;
	if (cnt[1] == 0)
	{
		FOR(i, 0, n) if (s[i] == '3') t += (char)1;
		else t += (char)0;
		
		cout << go(t) * 2 << endl;
	}
	else
	{
		FOR(i, 0, n) if (s[i] == '2') t += (char)1;
		else t += (char)0;
		
		cout << go(t) << endl;
	}
	
	
	
	
	
		
	//cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 13700
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

int ma[1 << 18][2];

int main()
{
  int n;
  cin >> n;
  vector<int> a(1 << n);

  for (int i = 0; i < (1 << n); ++i) scanf("%d", &a[i]);

  for (int i = 0; i < (1 << n); ++i) ma[i][0] = a[i];  

  for (int i = 0; i < n; ++i) for (int mask = 0; mask < (1 << n); ++mask) {
    if (mask & (1 << i)) {
      int mask2 = mask ^ (1 << i);
      for (int t : ma[mask2]) {
        if (t > ma[mask][0]) {
          ma[mask][1] = ma[mask][0];
          ma[mask][0] = t;
        } else if (t > ma[mask][1]) {
          ma[mask][1] = t;
        }
      }
    }
  }          

  int result = 0;
  for (int k = 1; k < (1 << n); ++k) {
    result = max(result, ma[k][0] + ma[k][1]);
    cout << result << endl;
  }

  return 0;
}


Measured memory_bytes: 6144
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf8");

let lines = [];
var reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on("line", line => {
  lines = line.split(/\s/).map(i => parseFloat(i));
});

reader.on("close", () => {
  let t = lines[0],
    x = lines[1];

  console.log((t / x).toFixed(6));
});


Measured memory_bytes: 21320
dec = {}
dec["a"] = 0
dec["b"] = 0
dec["c"] = 0
dec["d"] = 0
dec["e"] = 0
dec["f"] = 0
dec["g"] = 0
dec["h"] = 0
dec["i"] = 0
dec["j"] = 0
dec["k"] = 0
dec["l"] = 0
dec["m"] = 0
dec["n"] = 0
dec["o"] = 0
dec["p"] = 0
dec["q"] = 0
dec["r"] = 0
dec["s"] = 0
dec["t"] = 0
dec["u"] = 0
dec["v"] = 0
dec["w"] = 0
dec["x"] = 0
dec["y"] = 0
dec["z"] = 0
while True:
    try:
        for s in list(input()):
            if s.lower() in dec:
                dec[s.lower()] += 1
    except:
        break
for n in dec:
    print(f"{n} : {dec[n]}") 



Measured memory_bytes: 5576
///God is great

#include <bits/stdc++.h>
using namespace std;

/************************** definations *******************************/
#define pi              2*acos(0.0)
#define ll              long long int
#define llu             unsigned long long
#define sc(a)           scanf("%d",&a)
#define scc(a,b)        scanf("%d %d",&a,&b)
#define sccc(a,b,c)     scanf("%d %d %d",&a,&b,&c)
#define sc1(a)          scanf("%lld",&a)
#define sc2(a,b)        scanf("%lld %lld",&a,&b)
#define sc3(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define sc4(a,b,c,d)    scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define pf1(a)          printf("%lld\n",a)
#define pf2(a,b)        printf("%lld %lld\n",a,b)
#define Case(a)         printf("Case %d: ",a)
#define Casel(a)        printf("Case %lld: ",a)
#define mem(a,x)        memset(a,x,sizeof(a))
#define INF             1<<29
#define Inf             10000
#define inf             INT_MAX
#define INFL            1e18
#define XX              first
#define YY              second
#define PB              push_back
#define MP              make_pair
#define NL              cout << endl;
#define DONE            cerr << "Done" << endl
#define PAUSE           system("pause")
#define DEBUG(x)        cerr << #x << " = " << x << endl
#define READ            freopen("input.txt", "r", stdin)
#define WRITE           freopen("output.txt", "w", stdout)
#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pii             pair<int,int>
#define ii              pair<ll,int>
#define M               10000007
#define mod             100000007
#define Mod             1000000007
#define MAX             1001
#define qk              5000000
#define REP(i,x,m)      for(i=x;i<m;i++)
#define vi              vector<int>
/************************** definations *******************************/
int main()
{
    /*#ifndef ONLINE_JUDGE
    READ;
    WRITE;
    #endif*/
    FASTIO;
    llu i,k;
    cin >> k; k--;
    queue <llu> q;
    REP(i,1,10) q.push(i);
    while(k--){
        llu op = q.front(); q.pop();
      	llu m = op%10;
        if(m!=0) q.push(10*op + m - 1);
        q.push(10*op + m);
        if(m!=9) q.push(10*op + m + 1);
    }
    cout << q.front();
}

Measured memory_bytes: 1792
//abc137_a.cpp
//Sat Aug 10 20:49:38 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int a,b;
	cin >> a >> b;

	cout << max({a+b,a-b,a*b}) << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,i;
    cin>>a>>b;
    if(a>b)
    {
        for(i=0;i<a;i++)
        {
            cout<<b;
        }
    }
    else if(a<b)
    {
        for(i=0;i<b;i++)
        {
            cout<<a;
        }
    }
    else if(a==b)
    {
        for(i=0;i<a;i++)
        {
            cout<<a;
        }
    }

    return 0;

}


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

using namespace std;


int main() {
  // ---------------------
  // コーディング開始
  // ---------------------
  string s;
  cin >> s;
  bool fumi=true;

  for(int i=0;i<s.length();++i){
    if(i%2==1 && s[i]=='R') {
      fumi=false;
    }
    if(i%2==0 && s[i]=='L') {
      fumi=false;
    }
  }
  if(fumi){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


  return 0;
}








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


int main() {
	int n, k;
	cin >> n >> k;
	int d[10];
	for (int i = 0;i < k;i++)cin >> d[i];
	while (1) {
		int ans = n;
		int j = n;
		int flag = 1;
		while (j > 0) {
			for (int i = 0;i < k;i++) {
				if (j % 10 == d[i])flag = 0;
			}
			j /= 10;
		}
		if (flag) {
			cout << ans << endl;
			return 0;
		}
		n++;
	}
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
      Scanner sc =new Scanner(System.in);
      int N = sc.nextInt();
      int check =0;
      String[] W = new String[N];
	  for (int i=0; i<N; i++) {
        W[i] = sc.next();
      }
      for (int i=0; i<N-1; i++) {
        if (W[i].charAt(W[i].length()-1) != W[i+1].charAt(0)) {
          check++;
          break;
        }
        for (int j=i+1; j<N; j++) {
          if (W[i].equals(W[j])) {
            check++;
            break;
          }
        }
      }
      if (check != 0) {
        System.out.print("No");
      } else {
        System.out.print("Yes");
      }
    }
}

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

int main () {

    int N;
    cin >> N;

    string S;
    cin >> S;

    vector<int> array(N, 0);
    for (int i = 0; i < N; i++) {
        array[i] = ((S[i] == 'W')? -1 : 1);
    }

    for (int i = 1; i < N; i++) {
        array[i] += array[i-1];
    }

    int max_index = 0;
    int max_sum = array[0];
    for (int i = 1; i < N; i++) {
        if (max_sum < array[i]) {
            max_index = i;
            max_sum = array[i];
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if ((i < max_index && S[i] == 'W') || (i > max_index && S[i] == 'E')) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code
  int n;
    cin >> n;
  vector<int> l;
  inputVector(&l,n);
  sort(l.begin(),l.end());
  int ans = 0;
  rep(i,n - 2)
  {
    repd(j,i + 1,n - 1)
    {
      auto iter = lower_bound(l.begin(),l.end(),l[i] + l[j]);
      ans += distance(l.begin() + j + 1, iter);
    }
  }
  cout << ans;
}

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

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

using namespace std;

template <class T>
void printv(vector<T> v)
{
  cout << '[';
  for (auto vec: v)
  {
    cout << vec << ' ';
  }
  cout << ']' << endl;
}

int main()
{
  long long n, k;
  long long point = 0;
  cin >> n >> k;

  vector<pair<int, int>> v;
  vector<long long> result;

  rep(i, n)
  {
    int tmp, tmp2;
    cin >> tmp;

    tmp2 = tmp < 0 ? -1 : 1;
    if (tmp2 == -1) point++;

    v.push_back(make_pair(tmp, tmp2));
  }

  point--;
  rep(i, n - k + 1)
  {
    if (i + k - 1 == point)
    {
      result.push_back(abs(v[i].first));
    }
    else if (i == point + 1)
    {
      result.push_back(abs(v[i + k - 1].first));
    }
    else if ((i <= point && i + k -1 > point))
    {
      result.push_back(abs((v[i].first) * 2) + abs((v[i + k -1].first)));
      result.push_back(abs((v[i].first)) + abs((v[i + k -1].first) * 2));
    }
  }

  sort(result.begin(), result.end());
  cout << result[0] << endl;
}


Measured memory_bytes: 2548
s = input()
part_of_s = s[2:-1]
sub_s = s.replace('A','')
sub_s = sub_s.replace('C','')

if s[0] != 'A' or part_of_s.count('C') != 1 or sub_s != sub_s.lower():
    print('WA')
    exit()

print('AC')

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

int n;

struct Operator{
	string id, ope, a, b, c;
};

Operator mei[100];


map<string, int> opeLine;
int used[300];
int hen_id[300];
char rhen_id[300];

int main(){
	cin >> n;
	

	for(int i = 0;i < n;i++){
		string id, ope; cin >> id >> ope;
		opeLine[id] = i;
		if(ope == "ADD" || ope == "SUB"){
			cin >> mei[i].a >> mei[i].b >> mei[i].c;
			used[mei[i].a[0]] = 1;
			used[mei[i].b[0]] = 1;
			used[mei[i].c[0]] = 1;
		}else if(ope == "SET" || ope == "IF"){
			cin >> mei[i].a >> mei[i].b;
			used[mei[i].a[0]] = 1;
			used[mei[i].b[0]] = 1;		
		}
		mei[i].id = id;
		mei[i].ope = ope;
	}

	{
		int tmp = 0;
		for(int i = 'a';i <= 'z';i++){
			if(used[i] == 1){
				hen_id[i] = tmp;
				rhen_id[tmp] = i;
				tmp++;
			}
		} 
	}
	
	int i = 0;
	int cnt = 0;
	int a[5] = {};

	while(cnt < 60000000){
		if(i == n) break;
		if(mei[i].ope == "HALT") break;
		
		if(mei[i].ope == "ADD"){
			int x = hen_id[mei[i].a[0]];
			int y = hen_id[mei[i].b[0]];
			int tmp = 0;
			if('0' <= mei[i].c[0] && mei[i].c[0] <= '9'){
				tmp =a[y] + stoi(mei[i].c);
				if(tmp >= 16) break;
			}else{
				int z = hen_id[mei[i].c[0]];
				tmp = a[y] + a[z];
				if(tmp >= 16) break;
			}
			a[x] = tmp;
		}

		if(mei[i].ope == "SUB"){
			int x = hen_id[mei[i].a[0]];
			int y = hen_id[mei[i].b[0]];
			int tmp = 0;
			if('0' <= mei[i].c[0] && mei[i].c[0] <= '9'){
				tmp =a[y] - stoi(mei[i].c);
				if(tmp < 0) break;
			}else{
				int z = hen_id[mei[i].c[0]];
				tmp = a[y] - a[z];
				if(tmp < 0) break;
			}
			a[x] = tmp;
		}
	
		if(mei[i].ope == "SET"){
			int x = hen_id[mei[i].a[0]];
			int tmp = 0;
			if('0' <= mei[i].b[0] && mei[i].b[0] <= '9'){
				tmp = stoi(mei[i].b);
			}else{
				int z = hen_id[mei[i].b[0]];
				tmp = a[z];

			}
			a[x] = tmp;
		}
		
		if(mei[i].ope == "IF"){
			int x = hen_id[mei[i].a[0]];
			if(a[x] != 0){
				if(opeLine.find(mei[i].b) != opeLine.end()){
					i = opeLine[mei[i].b];
					i--;
				}else{
					break;
				}
			}
		}
		cnt++;
		i++;
	}

	if(cnt == 60000000) cout << "inf" << endl;
	else{
		for(int i = 0;i < 5;i++){
			if(rhen_id[i] != 0){
				cout << rhen_id[i] << "=" << a[i] << endl;
			}
		}
	}
	
	return 0;
}


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

using namespace std;
typedef pair<int, int> P;

#define r(i,n) for(int i=0; i<n; i++)
#define R(i,n) for(int i=0; i<=n; i++)
#define r1(i,n) for(int i=1; i<n; i++)
#define R1(i,n) for(int i=1; i<=n; i++)

const int INF=1e9;

int H, W;
int s[54][54];

int bfs(){
    queue<P> que;
    que.push(P(1, 1));

    int d[54][54];
    fill(&d[0][0],&d[52][52],INF);
    d[1][1]=0;

    int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
    while(que.size()){
        P p=que.front(); que.pop();
        if(p.first==H && p.second==W)break;

        r(i,4){
            int nx=p.first+dx[i], ny=p.second+dy[i];
            if(s[nx][ny]!=INF && d[nx][ny]==INF){
                que.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second]+1;
            }
        }
    }

    return d[H][W];
}



int main(){
    cin >> H >> W;
    fill(&s[0][0],&s[52][52],INF);

    int sharp_counter=0;
    R1(i,H)R1(j,W){
        char charS;  cin >> charS;
        if(charS=='#') sharp_counter++;
        else s[i][j]=0;
    }

    int bfs_result = bfs();
    if(bfs_result<INF) cout << H*W-bfs()-sharp_counter-1 << endl;
    else cout << "-1\n";

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N), b(N), c(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i) >> b.at(i) >> c.at(i);
  }
  
  vector<vector<int>> dp(N, vector<int>(3, -1));
  dp.at(0) = {a.at(0), b.at(0), c.at(0)};
  for (int i = 1; i < N; i++) {
    dp.at(i).at(0) = a.at(i) + max(dp.at(i - 1).at(1), dp.at(i - 1).at(2));
    dp.at(i).at(1) = b.at(i) + max(dp.at(i - 1).at(0), dp.at(i - 1).at(2));
    dp.at(i).at(2) = c.at(i) + max(dp.at(i - 1).at(0), dp.at(i - 1).at(1));
  }
  
  int ans = max(dp.at(N - 1).at(0), dp.at(N - 1).at(1));
  ans = max(ans, dp.at(N - 1).at(2));
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 6912
N = gets.chomp.chars.map(&:to_i).reverse
carry = 0
ans = 0
N.each_with_index do |digit, idx|
    next if (digit + carry) == 0
    if (digit + carry) % 10 < 5 || ((digit + carry) % 10 == 5 && (!N[idx+1] || N[idx+1] < 5))
        ans += (digit + carry) % 10
        carry = (digit + carry) / 10
    else
        puts "error!!!" if !(5..9).include?(digit + carry)
        ans += 10 - (digit + carry)
        carry = 1
    end
end
p ans + carry

Measured memory_bytes: 71332
#include<iostream>
#include<iostream>

using namespace std;

int main(){
 int a,b,c;
 cin>>a>>b>>c;

 if(a==5&&b==5&&c==7
     ||a==5&&b==7&&c==5
      ||a==7&&b==5&&c==5)cout<<"YES"<<endl;

 else cout<<"NO"<<endl;
 return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

    Map<Integer, Integer> map = new HashMap<>();
    map.put(a[n],n);

    while (n > 0) {
      n++;

      if (a[n-1]%2 == 0) {
        a[n] = a[n-1] / 2;
      } else if (a[n-1]%2 != 0) {
        a[n] = 3 * a[n-1] + 1;
      }

      if (map.containsKey(a[n])) {
        System.out.println(n);
        break;
      } else {
        map.put(a[n],n);
      }
    }


  }

}


Measured memory_bytes: 27092
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int n,m;
    scanf("%d%d", &n, &m);
    if(n>m) swap(n,m);
    if(n==1 && m==1) {
        printf("1\n");
    }
    else if(n>1 && m>1) {
        printf("%lld\n", (ll)(n-2)*(m-2));
    }
    else {
        printf("%d\n", m-2);
    }

    return 0;
}

Measured memory_bytes: 128
from sys import stdin, setrecursionlimit
input = stdin.readline
setrecursionlimit(10**8)

class Unionfind():
    def __init__(self,n):
        self.n = n
        self.parent = [-1]*n
    
    def find(self,x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return 0
        if self.parent[x] < self.parent[y]:
            x,y = y,x
        
        total_unite_island = self.parent[x] * self.parent[y]
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        return total_unite_island

N,M = map(int, input().split())
A = [0]*M; B = [0]*M
for i in range(M):
    A[i], B[i] = map(lambda x: int(x) - 1, input().split())

uf = Unionfind(N)
inconvenience = N * (N-1) // 2
inconvenience_list = [0]*M
inconvenience_list[M-1] = inconvenience
for i in range(M-1,0,-1):
    inconvenience -= uf.union(A[i],B[i])
    inconvenience_list[i-1] = inconvenience
for i in range(M):
    print(inconvenience_list[i])

Measured memory_bytes: 53612
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>
#include <map>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 
ll N;

int main(){

    map<string,string> mp;
    cin >> N;
    string S;
    ll cnt=0;
    rep(ni,N){
        cin >> S;
        auto itr = mp.find(S);  
        if( itr != mp.end() ) {
        } else {
            mp[S]=S;
            cnt++;
        }
    }
    cout << cnt << endl;    

}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    vector<int> adj[100100];
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    int ans = 0;
    rep(i, n) {
        bool good = true;
        for (int t : adj[i]){
            if(h[t] >= h[i]){
                good = false;
                break;
            }
        }
        if(good){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 8804
#include <stdio.h>

void bubbleSort(int A[], const int N)
{
    int i, j;
    int flag = 1, cnt = 0;

    for( i = 0; flag; ++i ){
        flag = 0;

        for( j = N-1; i < j; --j )
            if( A[j] < A[j-1] ){
                int tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;

                flag = 1;
                ++cnt;
            }
    }

    for( i = 0; i < N; ++i ){
        if( 0 < i ) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n%d\n", cnt);
}

int main()
{
    int i;

    int N;
    scanf("%d", &N);
    int A[N];
    for( i = 0; i < N; ++i )
        scanf("%d", &A[i]);

    bubbleSort(A, N);

    return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
	stack<char> s;
	string str;
	cin>>str;
	int n=str.size();
	for(int i=0;i<n;i++)
	{
		if(str[i]=='S')
		{
			if(i<n-1&&str[i+1]=='T')
				i++;
			else
				s.push('S');
		}
		else
		{
			if(!s.empty()&&s.top()=='S')
				s.pop();
			else s.push('T');
		}
	}
	cout<<s.size()<<"\n";

}

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

int main() {
  string A, B;
  cin >> A >> B;
  if (A.at(1)==B.at(1) && A.at(0)==B.at(2) && A.at(2)==B.at(0)) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main (){
	int n;
	int a;
	int i;
	scanf("%d",&n);
	for(i=0;a<=n;i++){
		a=(int)pow(2,(double)i);
		
    }
	printf("%d",a/2);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
double arr[n];
for(int i=0;i<n;i++)
    cin>>arr[i];
    double dp[n+1][n+1]={};
    /// i->head.
    dp[1][0]=arr[0];
    dp[0][1]=1-arr[0];
    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            int h=j;
            int t=i-j;

            if(h-1>=0)
                dp[h][t]=dp[h-1][t]*arr[i-1];

                if(t-1>=0)
                {


                dp[h][t]+=dp[h][t-1]*(1-arr[i-1]);
                }
        }
    }

    double ans=0;
    for(int i=0;i<=n;i++)
    {
         int h=i;
            int t=n-i;
            if(h>t)
            {
                ans+=dp[h][t];
            }

    }
    cout<<fixed<<setprecision(12)<<ans<<endl;

return 0;
}


Measured memory_bytes: 70656
n=int(input())
que=[]

for i in range(n):
    command=list(map(str,input().split()))
    if command[0]=="0":
        que.append(int(command[1]))
    elif command[0]=="1":
        print(que[int(command[1])])
    elif command[0]=="2":
        que.pop()


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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
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 main():
    a, b, c, d = LI()
    while True:
        c -= b
        if c <= 0:
            win = "Yes"
            break
        a -= d
        if a <= 0:
            win = "No"
            break
    print(win)
main()



Measured memory_bytes: 10964
H,W,D = map(int,input().split())
src = [list(map(int,input().split())) for i in range(H)]
Q = int(input())
qs = [tuple(map(int,input().split())) for i in range(Q)]

pos = [[None for i in range(D)] for j in range(H*W//D + 1)]
for y in range(H):
    for x in range(W):
        a = src[y][x]
        b,c = a//D, a%D
        pos[b][c] = (x,y)

cums = [[0] for i in range(D)]
for i in range(D):
    for j in range(H*W//D):
        if pos[j][i] is None or pos[j+1][i] is None:
            cums[i].append(cums[i][-1])
        else:
            x1,y1 = pos[j][i]
            x2,y2 = pos[j+1][i]
            dist = abs(x1-x2) + abs(y1-y2)
            cums[i].append(cums[i][-1] + dist)
            
for l,r in qs:
    d = l%D
    print(cums[d][r//D] - cums[d][l//D])


Measured memory_bytes: 39280
fun main(args: Array<String>) {
    var r: List<String?> = listOf("?","?","?")

    while( {r = readLine()?.split(" ")!!; r[1]}() != "?") {
        val result = when(r[1]) {
            "+" ->  r[0]?.toInt()!! + r[2]?.toInt()!!
            "-" -> r[0]?.toInt()!! - r[2]?.toInt()!!
            "*" -> r[0]?.toInt()!! * r[2]?.toInt()!!
            "/" -> r[0]?.toInt()!! / r[2]?.toInt()!!
            else -> 0
        }
        println(result)
    }
}


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

int cnt[1000001];
vector<bool> dp(1000001, true);

int main(){
    
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    
    ll a;
    for(int i = 0; i<n; i++){
        cin >> a;
        cnt[a]++;
    }
    
    int ans = 0;
    for(ll i = 1; i<= 1000001; i++){
        if(dp[i] && cnt[i] == 1){
            ans++;
        }
        if(cnt[i] > 0){
            for(int j = i+i; j < 1000001; j+= i){
                dp[j] = 0;
            }
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 7660
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
  int H, W;
  for (;;) {
    char c = '#';
    cin >> H >> W;
    if (H == 0 && W == 0)
      return 0;
    rep(i, H) {
      char d = c;
      rep(j, W) {
        cout << d;
        d = (d == '#') ? '.' : '#';
      }
      cout << endl;
      c = (c == '#') ? '.' : '#';
    }
    cout << endl;
  }
}


Measured memory_bytes: 3092
n = gets.chop.to_i
w = gets.split.map(&:to_i)

sum = w.inject(:+)
mid = sum/2

left = 0
right = 0
left2 = 0
right2 = 0
n.times do |i|
  if mid > left
    left += w[i]
  else
    right += w[i]
  end

  if mid > right2
    right2 += w[n-i-1]
  else
    left2 += w[n-i-1]
  end
end

puts (left-right).abs > (left2-right2).abs ? (left2-right2).abs : (left-right).abs


Measured memory_bytes: 3836
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Atcoder
{
    class aaaa
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            Console.WriteLine(N / 3);
        }
    }
}

Measured memory_bytes: 11092
S = list(input())

ans = 0
for i in range(len(S)-1):
    if S[i] != S[i+1]:
        pass
    else:
        x = S[i+1]
        if x == '0':
            S[i+1] = '1'
        else:
            S[i+1] = '0'
        ans += 1

print (ans)


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

int main(){
  int x,y;
  cin>>x>>y;
  string s;
  int z=0;
  for(int i=0;i<x;i++){
    cin>>s;
    for(int j=0;j<y;j++){
      if(s[j]=='#'){
        z++;
      }
    }
  }
  if(z==x+y-1){
    cout<<"P";
  }
  else{
    cout<<"Imp";
  }
  cout<<"ossible"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  long n,a,b;
  cin >> n >> a >> b;
  if((b - a) % 2 == 0){
    cout << (b-a)/2 << endl;
  }else{
    long ans1 = 0;
    long d1 = b - a;
    long t1 = a - 1;
    ans1 = t1 + 1 + (d1 - 1)/2;
    
    long t2 = n - b;
    long ans2 = t2 + 1 + (d1 - 1)/2;
    cout << min(ans1,ans2) << endl;
  }
}


Measured memory_bytes: 256
input = gets.to_s.split(" ").map(&:to_i)
sanka_n = input[0]
point_k = input[1]
answer_q = input[2]
seitou = []
ini_point = []
for i in 0..answer_q -1 do
  seitou[i] = gets.to_i
end

for i in 0..sanka_n-1 do
  ini_point[i] = point_k - answer_q
end

for i in 0..answer_q -1 do
  ini_point[seitou[i]-1] += 1
end

for i in 0..sanka_n-1 do
  if ini_point[i] <= 0
    puts "No"
  else
    puts "Yes"
  end
end


Measured memory_bytes: 4168
import collections
n = int(input())
l = list(map(int, input().split()))
a = int(input())
c = collections.Counter(l)
answer = sum(l)
for i in range(a):
    j,k =  map(int, input().split())
    save = c[j]
    del c[j]
    c[k] += save
    answer = answer + k*save - j*save
    print(answer)


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

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 ***/

int main(){
    double pai=3.141592653589;
    int n,q,ans=0;
    scanf("%d %d",&n,&q);
    queue<string> name;
    queue<int> time;
    for(int i=0;i<n;i++){
        char c[10];
        int j;
        scanf("%s %d",&c,&j);
        string s=c;
        name.push(s);
        time.push(j);
    }
    for(;;){
        if(name.empty()) break;
        int chk=time.front();
        string tmp=name.front();
        name.pop();
        time.pop();
        if(chk<=q){
            printf("%s %d\n",tmp.c_str(), ans+chk);
            ans+=chk;
        }else{
            ans+=q;
            chk-=q;
            name.push(tmp);
            time.push(chk);
        }
    }
    return 0;
}

Measured memory_bytes: 4020
fin_a = []
fin_b = []
while True:
    x = int(input())
    if x == 0:
        break
    a = 0
    b = 0
    for i in range(x):
        l = list(map(int, input().split()))
        if l[0] > l[1]:
            a += l[0] + l[1]
        elif l[0] < l[1]:
            b += l[0] + l[1]
        else:
            a += l[0]
            b += l[1]
    fin_a.append(a)
    fin_b.append(b)
    
for x, y in zip(fin_a, fin_b):
    print(x, y)

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<int, int>;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
template<typename T>
struct edge {
    int from, to; // クラスカル法に限って、fromもedgeに含めるといい
    T cost;
};
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
template<typename T>
T kruskal(vector<edge<T>> &edges, int V) {
    sort(edges.begin(), edges.end(), [](const edge<T> &a, const edge<T> &b) {
        return a.cost < b.cost;
    });
    UnionFind unionFind(V);
    T res = 0;
    for (edge<T> &e: edges) {
        if (unionFind.merge(e.to, e.from)) {
            res += e.cost;
        }
    }
    return res;
}
int n;
vector<double> x, y, z, r;
int main() {
  vector<double> ans;
  while(true) {
    cin >> n;
    if(n == 0) break;
    x.resize(n); y.resize(n); z.resize(n); r.resize(n);
    REP(i, n) {
      cin >> x[i] >> y[i] >> z[i] >> r[i];
    }
    vector<vector<double>> cost(n, vector<double>(n, 0.0));
    for(int i = 0; i < n; ++i) {
      for(int k = i; k < n; ++k) {
        if(i == k) continue;
        double line = sqrt(pow(x[i] - x[k], 2) + pow(y[i] - y[k], 2) + pow(z[i] - z[k], 2)) - r[i] - r[k];
        if(0 <= line) cost[i][k] = line;
        else cost[i][k] = 0;
      }
    }
    vector<edge<double>> tree;
    for(int i = 0; i < n; ++i) {
      for(int k = i; k < n; ++k) {
        edge<double> tmp; tmp.from = i; tmp.to = k; tmp.cost = cost[i][k];
        tree.push_back(tmp);
      }
    }
    ans.push_back(kruskal(tree, n));
  }
  REP(i, ans.size()) {
    cout << fixed << setprecision(3) << ans[i] << endl;
  }
}


Measured memory_bytes: 3356
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
struct rdr {
	int et; int ch;
};
int main()
{
	int n , c; scanf("%d%d",&n,&c);
	vector< pair< int , pair<int,int> > > v(n);
	vector<rdr> y(c);
	for(int i=0;i<n;i++) {
		scanf("%d%d%d",&v[i].f,&v[i].s.f,&v[i].s.s);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<c;i++) {
		y[i].et = y[i].ch = 0;
	}
	for(int i=0;i<n;i++) {
		int k = 0;
		while(v[i].s.s != y[k].ch && v[i].f <= y[k].et) k++;
		y[k].et = v[i].s.f , y[k].ch = v[i].s.s;
	}
	int ans = 0;
	for(int i=0;i<c;i++) if(y[i].et != 0) ans+=1;
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

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

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

int N;
vector<int> a;
int main() {
    cin >> N;
    a.resize(N);
    rep(i, N) cin >> a[i];
    set<int> s;
    map<int, int> m;
    rep(i, N) m[a[i]]++;
    if (m.size() > 2) {
        cout << "No" << endl;
        return 0;
    }
    if (m.size() == 1) {
        int t = a[0];
        if (t <= 2 || t <= N / 2 || t + 1 == N) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        return 0;
    }
    int t1 = *min_element(all(a));
    int t2 = *max_element(all(a));
    if (t2 - t1 != 1) {
        cout << "No" << endl;
        return 0;
    }
    int d = t2 - t1;
    int a = min(t1, N - t1 - 1);
    if (t1 - a + 1 <= m[t1] && m[t1] <= t1) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 5376
import java.util.*;
public class Main{
	public static int order(long a){
		int o=0;
		long d=1;
		while(d<=a){
			o++;d*=10;
		}
		return o;
	}
	public static int maxOrder(long a, long b){
		return Math.max(order(a), order(b));
	}
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long N =Long.parseLong(sc.next());
		int minF=order(N);
		for (long i=1;i*i<=N;i++){
			if(N%i==0){
				minF=Math.min(minF,maxOrder(i,N/i));
			}
		}
		System.out.println(minF);
	}
}


Measured memory_bytes: 22996