akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main()
{
	int a,b,c,k,i,max,res;
	
	scanf("%d %d %d", &a,&b,&c);
	scanf("%d", &k);
	
	max = (a>b)? ((c>a)? c:a):((c>b)? c:b);
	res = a+b+c-max;
	
	for(i=0; i < k; i++) max *= 2;
	res += max;
	
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
  ll n;
  cin>>n;
  
  ll a[n];
  
  for(ll i=0;i<n;i++)
  cin>>a[i];
  
  ll cur=1000;
  
  for(ll i=0;i<n-1;i++){
      if(a[i]<a[i+1]){
         cur= cur%a[i]+(cur/a[i])*a[i+1];
      }
  }
  
  cout<<cur<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     
//Start from Here.

  ll t;
  t=1;
 // cin>>t;
  while(t--)
  solve();
  
//Good Bye!
    return 0;
}

Measured memory_bytes: 3604
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
	int N,aun;
    public void solve() {
		N = nextInt();
		for(int i = 0;i < N;i++){
			String s = next();
			
			if(s.equals("A")){
				aun++;
			}else{
				if(aun - 1 < 0){
					out.println("NO");
					return;
				}else{
					aun--;
				}
			}
		}
		
		if(aun > 0){
			out.println("NO");
		}else{
			out.println("YES");
		}
    }
 
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}
		/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

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

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

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

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

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

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

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

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

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

using vb = std::vector<bool>;
using vi = std::vector<int>;

int main()
{
	int H, W;
	scanf("%d%d", &H, &W);
	std::vector<vb> black(H + 2, vb(W + 2));
	for (int i{1}; i <= H; i++)
		for (int j{1}; j <= W; j++)
		{
			char A;
			scanf(" %c", &A);
			black[i][j] = A == '#';
		}

	std::vector<vi> table[4];
	for (int i{}; i < 4; i++) table[i].resize(H + 2, vi(W + 2, 1 << 30));
	for (int i{1}; i <= H; i++)
		for (int j{1}; j <= W; j++)
		{
			table[0][i][j] = std::min(table[0][i - 1][j], table[0][i][j - 1]) + 1;
			if (black[i][j])
				table[0][i][j] = 0;
		}
	for (int i{H}; i > 0; i--)
		for (int j{1}; j <= W; j++)
		{
			table[1][i][j] = std::min(table[1][i + 1][j], table[1][i][j - 1]) + 1;
			if (black[i][j])
				table[1][i][j] = 0;
		}
	for (int i{1}; i <= H; i++)
		for (int j{W}; j > 0; j--)
		{
			table[2][i][j] = std::min(table[2][i - 1][j], table[2][i][j + 1]) + 1;
			if (black[i][j])
				table[2][i][j] = 0;
		}
	for (int i{H}; i > 0; i--)
		for (int j{W}; j > 0; j--)
		{
			table[3][i][j] = std::min(table[3][i + 1][j], table[3][i][j + 1]) + 1;
			if (black[i][j])
				table[3][i][j] = 0;
		}
	int max{};
	for (int i{1}; i <= H; i++)
		for (int j{1}; j <= W; j++)
		{
			int min{1 << 30};
			for (int k{}; k < 4; k++)
				min = std::min(min, table[k][i][j]);
			max = std::max(max, min);
		}
	printf("%d\n", max);

	return 0;
}

Measured memory_bytes: 16256
#include <stdio.h>
#include <math.h>

int main(void)
{
    long long n;
    long long ans = 0;
    scanf("%lld", &n);
    long long inf = sqrtl(n+1)-1;
    for (long long i = 1; i <= inf; i++)
    {
        if(n%i == 0)
        {
            ans +=  n/i - 1;
        }
    }

    printf("%lld\n", ans);
    
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main()
{
	int a,b,c,d;
	while(scanf("%d %d",&a,&b)!=EOF){
		d=1;
		c=a+b;
		while(c/10){
			c/=10;
			d++;
		}
		printf("%d\n",d);
	}
	return 0;
}

Measured memory_bytes: 1756
n,c,k=map(int,input().split())
t=[int(input()) for _ in range(n)]
t.sort()
cnt,now=0,0
while now<n:
    temp=t[now]+k
    a=now
    for i in range(c-1):
        if i+1+a>=n:
            break
        if t[i+1+a]>temp:
            break
        now+=1
    now+=1
    cnt+=1
print(cnt) 

Measured memory_bytes: 13272
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
const int maxn = 1e5 + 5;
int main()
{
    ios::sync_with_stdio(false);
    int n; cin >> n;
    cout << !n << endl;
    return 0;
}


Measured memory_bytes: 3636
use std::io;
fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf);
    buf
}


fn sixtennbit(x: &str) -> i32 {
    let res: i32 = match x {
        "A" => 10,
        "B" => 11,
        "C" => 12,
        "D" => 13,
        "E" => 14,
        "F" => 15,
        _ => 0,
    };
    res
}
fn main() {
    let text = read_line();
    let test: Vec<&str> = text.split_whitespace().map(|x| x.trim()).collect();
    match (sixtennbit(test[0]) - sixtennbit(test[1])) {
        0 => println!("="),
        x if x > 0 => println!(">"),
        x if x < 0 => println!("<"),
        _ => println!(""),
    }
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A.at(i);
    int Q;
    cin >> Q;
    vector<int> B(Q), C(Q);
    for(int i=0; i<Q; i++) cin >> B.at(i) >> C.at(i);
    vector<int64_t> dp(100001, 0);
    for(int i=0; i<N; i++) dp.at(A.at(i))++;
    int64_t sum = 0;
    for(int i=0; i<100001; i++) sum += (i * dp.at(i));
    for(int i=0; i<Q; i++){
        int64_t bi = B.at(i);
        int64_t ci = C.at(i);
        sum -= bi * dp.at(bi);
        sum += ci * dp.at(bi);
        dp.at(ci) += dp.at(bi);
        dp.at(bi) = 0;
        cout << sum << endl;
    }

}

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

#define F                   first
#define S                   second
#define int                 long long int
#define pb                  push_back
#define mp                  make_pair
#define pii                 pair<int,int>
#define vi                  vector<int>
#define mii                 map<int,int>
#define pqb                 priority_queue<int>
#define pqs                 priority_queue<int,vi,greater<int> >
#define mod                 1000000007
#define endl                '\n'
#define rep(i,a,b)            for(int i=a;i<b;i++)

void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
    c_p_c();
    int n;
    cin >> n;
    vector<double> p(n);
    rep(i, 0, n) {
        cin >> p[i];
    }
    vector<double> dp(n + 1, 0);
    dp[0] = 1;
    rep(i, 0, n) {
        for (int j = i + 1; j >= 0; j--) {
            dp[j] = (j == 0 ? 0 : (dp[j - 1] * p[i] ) ) + (dp[j] * (1 - p[i]));
        }
    }
    double ans = 0;
    for (int i = 0; i <= n; i++) {
        int t = n - i;
        if (i > t) {
            ans += dp[i];
        }
    }
    printf("%.10lf \n", ans);


    return 0;
}

Measured memory_bytes: 3872
a1 = [[0 for i in range(10)] for j in range(3)]
a2 = [[0 for i in range(10)] for j in range(3)]
a3 = [[0 for i in range(10)] for j in range(3)]
a4 = [[0 for i in range(10)] for j in range(3)]

n = int(input())
for i in range(0,n):
    x = [int (z) for z in input().split(' ')]
    if x[0] == 1:
        a1[x[1]-1][x[2]-1] += x[3]
    elif x[0] == 2:
        a2[x[1]-1][x[2]-1] += x[3]
    elif x[0] == 3:
        a3[x[1]-1][x[2]-1] += x[3]
    elif x[0] == 4:
        a4[x[1]-1][x[2]-1] += x[3]

for t in range(0,3):
    for i in a1[t]:
        print(" %d" % i, end='')
    print('')
print("####################")
for t in range(0,3):
    for i in a2[t]:
        print(" %d" % i, end='')
    print('')
print("####################")
for t in range(0,3):
    for i in a3[t]:
        print(" %d" % i, end='')
    print('')
print("####################")
for t in range(0,3):
    for i in a4[t]:
        print(" %d" % i, end='')
    print('')

Measured memory_bytes: 7840
#include <stdio.h>

int main(void)
{
	int i, hangar[50][2], flag, count;
	for (i = 0; ; i++) {
		scanf("%d %d", &hangar[i][0], &hangar[i][1]);
		if (hangar[i][0] == 0 && hangar[i][1] == 0)
			break;
	}
	count = i;
	for (i = 0; i < count; i++) {
		flag = 0;
		for (; hangar[i][0] < hangar[i][1]+1; hangar[i][0]++) {
			if ((hangar[i][0] % 4 == 0) && !(hangar[i][0] % 100 == 0 && hangar[i][0] % 400 != 0)) {
				printf("%d\n", hangar[i][0]);
				flag = 1;
			}
		}
		if (flag == 0)
			printf("NA\n");
		if (i != count - 1)
			printf("\n");
	}
	return 0;
}

Measured memory_bytes: 0
N, K = list(map(int, input().split()))

h = []

for i in range(N):
    H = int(input())
    h.append(H)

h.sort()

m = 9999999999999999999

for i in range(len(h)-K+1):
    if m > (h[i+K-1] - h[i]):
        m = (h[i+K-1] - h[i])

print(m)

Measured memory_bytes: 7392
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  string S, T;
  cin >> S >> T;
  string ans = "No";
  if (T.substr(0, S.length()) == S) ans = "Yes";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int n;
int t[1001][1001];
 
int main(){
  scanf("%d",&n);
  while(n--){
    int ax,ay,bx,by;
    scanf("%d %d %d %d",&ax,&ay,&bx,&by);
    t[ax][ay]++;
    t[ax][by]--;
    t[bx][ay]--;
    t[bx][by]++;
  }
 
  int ans=0;
  for(int i=0;i<1001;i++){
    for(int j=0;j<1001;j++){
      if(i)t[i][j]+=t[i-1][j];
      if(j)t[i][j]+=t[i][j-1];
      if(i&&j)t[i][j]-=t[i-1][j-1];
      ans=max(ans,t[i][j]);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 7120
//
//  main.cpp
//  三井住友_2019_B
//
//  Created by Joe Mori on 2020/05/27.
//  Copyright © 2020 Joe Mori. All rights reserved.
//

#include <iostream>

int main(int argc, const char * argv[]) {
    long long int a,b,c;
    std::cin>>a;
    b=a*100/108;
    c=(a+1)*100/108;
    b=b*1.08;
    c=c*1.08;
//    std::cout<<b<<" "<<c<<std::endl;
    if(b==a){
        b=b/1.08;
        std::cout<<b<<std::endl;
    }else if(c==a){
        c=c/1.08+1;
        std::cout<<c<<std::endl;
    }else
        std::cout<<":("<<std::endl;
    return 0;
}


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

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

  vector<int> a(n);
  for ( int i = 0; i < n; i++ ) cin >> a[i];

  vector<int> cum(a);
  cum[n-1] = a[n-1];
  for ( int i = n-2; i >= 0; i-- ) {
    cum[i] = max(a[i], cum[i+1]);
  }

  int ans = -1000000000;
  for ( int i = 0; i < n-1; i++ ) {
    ans = max(ans, cum[i+1]-a[i]);
  }

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



Measured memory_bytes: 4452
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, m;
vector<vector<i64>> g;
vector<bool> added;
vector<i64> ts, ord, par;

void tsort(i64 u) {
  if (added[u]) return;
  added[u] = true;
  for (i64 v : g[u]) tsort(v);
  ts.push_back(u);
}

int main() {
  cin >> n >> m;
  init_n(g, n + 1);
  for (i64 i = 1; i <= n - 1 + m; ++i) {
    i64 a, b;
    cin >> a >> b;
    g[a].push_back(b);
  }

  init_n(added, n + 1);
  for (i64 u = 1; u <= n; ++u) tsort(u);
  reverse(begin(ts), end(ts));
  
  init_n(ord, n + 1);
  for (i64 i = 0; i < n; ++i) {
    ord[ts[i]] = i;
  }

  init_n(par, n + 1);
  for (i64 u = 1; u <= n; ++u) {
    for (i64 v : g[u]) {
      if (par[v] == 0 || ord[u] > ord[par[v]]) par[v] = u;
    }
  }

  for (i64 u = 1; u <= n; ++u) {
    cout << par[u] << '\n';
  }
  return 0;
}



Measured memory_bytes: 12020
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
        
        if (N == M) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

int main() {
  vector<vector<int>> c(3,vector<int> (3));
  for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) cin >> c.at(i).at(j);
  const int c0 = c.at(0).at(0);
  
  for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) c.at(i).at(j) -= c0;

  if (c.at(1).at(0) + c.at(0).at(1) == c.at(1).at(1) && c.at(1).at(0) + c.at(0).at(2) == c.at(1).at(2) && c.at(2).at(0) + c.at(0).at(1) == c.at(2).at(1) && c.at(2).at(0) + c.at(0).at(2) == c.at(2).at(2)) {
    cout << "Yes" << endl;
  } else cout << "No" << endl;
}

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

const int MAX_N = 21, MOD = 1e9 + 7;
int n;
int table[MAX_N][MAX_N];
int dp[1 << MAX_N];

int _sum (int a, int b) {
	int c = a + b;
	if (MOD <= c)
		c -= MOD;
	
	return c;
}

int _mul (int a, int b) {
	int c = 1LL * a * b % MOD;
	return c;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> table[i][j];

	dp[0] = 1;
	for (int mask = 1; mask < (1 << n); mask++) {
		int cnt = __builtin_popcount(mask);
		for (int i = 0; i < n; i++)
			if (((mask >> i) & 1) && table[i][cnt - 1])
				dp[mask] = _sum(dp[mask], dp[mask ^ (1 << i)]);
	}

	cout << dp[(1 << n) - 1] << "\n";
	return 0;
}

Measured memory_bytes: 8448
#pragma region template

#include <bits/stdc++.h>

using namespace std;
#define ll long long 
#pragma region random

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> T randint(T a, T b) {
    return uniform_int_distribution<T>(a, b)(rng);
}

#pragma endregion

#pragma region debug
string to_string(string s) { return '"' + s + '"'; }

string to_string(const char *s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B> string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A> string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first)
            res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

#pragma endregion

#pragma endregion

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin>>n;
    string S;
    cin>>S;
    vector<vector<int> > dp(n,vector<int>(n,0));
    int ans = 0;
    for(int i=n-1;i>=0;i--)
    {
        for(int j=n-1;j>i;j--)
        {
            if(j==n-1)
            {
                if(S[i]==S[j])
                dp[i][j] = 1;
            }
            else
            {
                if(S[i]==S[j])
                dp[i][j] = min(j-i,dp[i+1][j+1]+1);
            }
            ans = max(ans,dp[i][j]);
        }
    }
    cout<<ans;
    return 0;
}

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


int main()
{
    vll vec(3);
    REP(i, 3) {
        cin >> vec.at(i);
    }

    int num5 = count(ALL(vec), 5);
    int num7 = count(ALL(vec), 7);

    if (num5 == 2 && num7 == 1) {
        cout << "YES" << endl;
        return 0;
    } else {
        cout << "NO" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
import numpy as np
X, N = map(int, input().split())
if N == 0:
    print(X)
else:
    l = list(map(int, input().split()))
    app = [x for x in range(X - int(N / 2) - 1, X + int(N / 2) + 1) if x not in l]
    print(app[np.argmin([abs(x - X) for x in app])])

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

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; }

bool chk(vector<pii> v){
	int n = v.size();

	int l = 0;
	rep(i, n){
		if(l - v[i].first < 0) return false;
		l += v[i].second;
	}

	return l >= 0;
}

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

	int n;
	cin >> n;

	vector<pii> v;
	vector<pii> w;

	int sml = 0;
	rep(i, n){
		string s;
		cin >> s;

		int m = s.size();
		int mn = 1e7;
		int l = 0;
		rep(i, m){
			if(s[i] == '('){
				l++;
			}else{
				l--;
			}
			chmin(mn, l);
		}
		sml += l;
		if(l >= 0){
			v.push_back({-mn, l});
		}else{
			w.push_back({-(mn - l), -l});
		}
	}

	if(sml != 0){
		cout << "No" << endl;
		return 0;
	}
	sort(v.begin(), v.end());
	sort(w.begin(), w.end());

	if(chk(v) && chk(w)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

}


Measured memory_bytes: 18896
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9 + 7;
const int maxn = 2001005;

void go() {
	int n, m;
	cin >> n >> m;
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	x1--, y1--, x2--, y2--;
	string s[n];
	f(n) {
		cin >> s[i];
	}
	int dis[n][m];
	memset(dis, 0x3f, sizeof(dis));
	dis[x1][y1] = 0;
	deque<pair<int,pair<int,int>>>dq;
	dq.push_back({0,{x1,y1}});
	int dx[] = {1,-1,0,0};
	int dy[] = {0,0,1,-1};
	while (dq.size()) {
		auto now = dq.front();
		dq.pop_front();
		if (dis[now.S.F][now.S.S] != now.F) {
			continue;
		}
		for (int i = 0 ; i < 4 ; i++) {
			int nx = now.S.F + dx[i];
			int ny = now.S.S + dy[i];
			if (nx < 0 || nx >= n || ny < 0 || ny >= m ||s[nx][ny] == '#') {
				continue;
			}
			if (dis[nx][ny] > now.F) {
              	dis[nx][ny] = now.F;
				dq.push_front({now.F, {nx,ny}});
			}
		}
		for (int i = -2 ; i <= 2 ; i++) {
			for (int j = -2 ; j <= 2 ; j++) {
				int nx = now.S.F + i;
				int ny = now.S.S + j;
				if (nx < 0 || nx >= n || ny < 0 || ny >= m||s[nx][ny] == '#') {
					continue;
				}
				if (dis[nx][ny] > now.F + 1) {
                  	dis[nx][ny] = now.F + 1;
					dq.pb({now.F + 1, {nx,ny}});
				}
			}
		}
	}
	if (dis[x2][y2] > 7475100) {
		dis[x2][y2] = -1;
	}
	cout << dis[x2][y2] << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
    
}

Measured memory_bytes: 8764
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#define cri const int
#define ll long long
#define int ll
using namespace std;
vector<int>to[52];
int is[52];
ll w[52],v[52],dp[125010];
void dfs(cri x){
	w[x]=1;
	for(int y:to[x]) dfs(y),w[x]+=w[y],v[x]+=v[y];
}
inline int as(cri x,cri y){ return w[x]*v[y]>w[y]*v[x]; }
signed main(){
	int n,X,d,sum=0;
	cin>>n>>X>>d>>v[1];is[1]=1;
	for(int i=2,x;i<=n;i++){
		cin>>v[i]>>x;is[i]=i;
		to[x].push_back(i);
	}
	dfs(1);
	sort(is+1,is+n+1,as);
	memset(dp,0x3f,sizeof dp);dp[0]=0;
	cri mn=min(d,n);
	for(int i=1;i<=n;i++){
		int lst=mn;
		for(int j=1;j<=lst;j<<=1){
			sum+=j*w[i];
			for(int k=sum;k>=j*w[i];k--) dp[k]=min(dp[k],dp[k-j*w[i]]+j*v[i]);
			lst-=j;
		}
		if(lst){
			cri j=lst;
			sum+=j*w[i];
			for(int k=sum;k>=j*w[i];k--) dp[k]=min(dp[k],dp[k-j*w[i]]+j*v[i]);
		}
	}//cout<<1<<endl;
	ll ans=0;
	for(int s=0;s<=sum;s++) if(dp[s]<=X){
		int lst=X-dp[s];ll tmp=s;
		for(int i=1;i<=n;i++){
			cri x=is[i],num=x==1?lst/v[x]:min((ll)d-mn,lst/v[x]);
			tmp+=num*w[x];lst-=num*v[x];
		}
		//cout<<tmp<<endl;
		ans=max(ans,tmp);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4148
//url:https://atcoder.jp/contests/dp/tasks/dp_d
//problem name:D - Knapsack 1

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
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;
}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long,long>>;

int N;
ll W;
vecl weight(110),value(110);
vector<vector<ll>> dp(110,vector<ll>(100010));

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];
    for (int i = 0; i < N; ++i) {
        for (int sum_w = 0; sum_w <= W; ++sum_w) {
            if (sum_w - weight[i] >= 0) {
                chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 87296
import collections
import sys
INF = 10**18
h,w = map(int,input().split())
li = [list(input()) for i in range(h)]
sx,sy,gx,gy = 0,0,h-1,w-1

def bfs(sy,sx):
    #頂点をINFで初期化
    d = [[INF]*w for i in range(h)]
    #移動４方向のベクトル
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    #スタート地点をキューにいれ、頂点を０にする
    que = collections.deque([])
    que.append((sy,sx))
    d[sy][sx] = 0
    #キューが空になるまでループ（行ける要素がなくなるまで）
    while que:
        # キューの先頭を取り出す
        p = que.popleft()
        # 取り出してきた状態がゴールなら探索をやめる
        # 移動4方向をループ
        for i in range(4):
            nx = p[1] + dx[i]
            ny = p[0] + dy[i]

            #壁との判定とすでに訪れたかどうかをチェック
            if 0<=nx and nx < w and 0 <= ny and ny < h:
                if li[ny][nx] != "#" and d[ny][nx] == INF:
                    #移動できる点なのでキューについか
                    que.append((ny,nx))
                    #前の点+1で移動できる
                    d[ny][nx] = d[p[0]][p[1]] + 1
    return d[-1][-1]
a = bfs(0,0)-1
if a + 1 == INF:
    print(-1)
    sys.exit()
maxgrid = h*w
cnt = 0
for i in range(h):
    for j in range(w):
        if li[i][j] == "#":
            cnt+=1
ans = maxgrid - cnt - a -2
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<double,int> P;

struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    // migi neji (not verified)
    if(c=='R'){
      b=s[1];
      s[1]=s[3];
      s[3]=s[4];
      s[4]=s[2];
      s[2]=b;
    }
    if(c=='L'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }
  }
  int top() {
    return s[0];
  }
  int hash(){
    int res=0;
    for(int i=0;i<6;i++) res=res*256+s[i];
    return res;
  }
};

int dp[1<<15],n,x[16],y[16];
string s[16];
set<P>st[16];

int main(){
    while(cin>>n,n){
        r(i,16)st[i].clear();
        Dice D[n];
        r(i,n){
            cin>>x[i]>>y[i];
            cin>>D[i].s[3]>>D[i].s[2]>>D[i].s[1]>>D[i].s[4]>>D[i].s[5]>>D[i].s[0];
            cin>>s[i];s[i]="@"+s[i];
            int X=x[i],Y=y[i];
            r(j,s[i].size()){
                if(s[i][j]=='R')X++;
                if(s[i][j]=='L')X--;
                if(s[i][j]=='B')Y++;
                if(s[i][j]=='F')Y--;
                st[i].insert(P(X,Y));
            }
        }
        memset(dp,0,sizeof(dp));
        for(int i=0;i<(1<<n);i++){
            for(int j=0;j<n;j++){
                if((1<<j)&i)continue;
                int sum=0,X=x[j],Y=y[j];
                Dice d=D[j];
                map<P,int>pre;
                for(int k=0;k<s[j].size();k++){
                    int flag=0;
                    if(s[j][k]=='R')X++,d.roll('E');
                    if(s[j][k]=='L')X--,d.roll('W');
                    if(s[j][k]=='B')Y++,d.roll('N');
                    if(s[j][k]=='F')Y--,d.roll('S');
                    r(l,n)if(l!=j&&((1<<l)&i)){
                        if(st[l].count(P(X,Y)))flag++;
                    }
                    if(flag)continue;
                    if(pre.count(P(X,Y)))sum-=pre[P(X,Y)];
                    pre[P(X,Y)]=d.s[5];
                    sum+=d.s[5];
                }
                dp[i|(1<<j)]=max(dp[i|(1<<j)],dp[i]+sum);
            }
        }
        cout<<dp[(1<<n)-1]<<endl;
    }
}


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

int main() {
  int K, S;
  cin >> K >> S;
  int count = 0;
  for (int X = 0; X <= K; X ++){
    for (int Y = 0; Y <= K; Y ++){
      for (int Z = 0; Z <= K; Z ++){
        if (X + Y + Z == S){
          count ++;
        }
      }
    }
  }
  cout << count << '\n';
}

Measured memory_bytes: 3168
module global_variables
  integer,parameter::max_n = 200
  integer,parameter::inf = 1000000000
  integer n
  integer::a(max_n)
end module global_variables
program main
  use global_variables
  implicit none
  integer i,res,tmp
  read *, n
  read *, (a(i),i=1,n)
  print '(i0)', minval(trailz(a))
end program main



Measured memory_bytes: 256
# ABC080C - Shopping Street
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    F = tuple(int(input().replace(" ", ""), 2) for _ in range(N))
    P = tuple(tuple(map(int, input().split())) for _ in range(N))
    ans = []
    for i in range(1, 2 ** 10):
        cnt = sum(p[bin(i & f).count("1")] for f, p in zip(F, P))
        ans += [cnt]
    print(max(ans))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << endl;}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int solve() {
	var(int, n, X);
	vec(int, x, n);
	sort(all(x));
	int min_x = 1e9;
	rep(i, 0, n) {
		chmin(min_x, abs(x[i] - X));
	}
	int t = 0;
	rep(i, 1, n) {
		t = abs(x[i] - x[i - 1]) % min_x;
		if (t > 0){
			chmin(min_x, t);
		}
	}
	return min_x;
}
int main() {
	print(solve());
	return 0;
}


Measured memory_bytes: 640
# ARC081C - Make a Rectangle
from collections import Counter


def main():
    n = int(input())
    lst = list(map(int, input().rstrip().split()))
    cnt = sorted(Counter(lst).most_common(), reverse=True)
    ans = []
    for i, j in cnt:
        if len(ans) >= 2:
            break
        if j >= 4:
            ans += [i] + [i]
        elif j >= 2:
            ans += [i]
    print(0 if ans == [] else ans[0] * ans[1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 21660
N=int(input())
s=[int(input()) for i in range(N)]
s.sort()
ans = sum(s)
if ans%10!=0:
    print(ans)
    exit()
else:
    for i in s:
        ans2 = ans-i
        if ans2%10!=0:
            print(ans2)
            exit()
print(0)

Measured memory_bytes: 9172
n = gets.to_i
data = {
    'S':[],
    'D':[],
    'C':[],
    'H':[],
}
num_set = [1,2,3,4,5,6,7,8,9,10,11,12,13]
n.times do |i|
    gara, num = gets.chomp.split
    data[gara.to_sym].push num.to_i
end
diff = num_set - data[:S]
diff.each{|d| puts "S #{d}"}
diff = num_set - data[:H]
diff.each{|d| puts "H #{d}"}
diff = num_set - data[:C]
diff.each{|d| puts "C #{d}"}
diff = num_set - data[:D]
diff.each{|d| puts "D #{d}"}


Measured memory_bytes: 8904
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
typedef __int128 ll;
int n;
ll xx;
void out(ll x)
{
	cout<<(long long)x<<endl;
}
ll s[200005];
ll pre[200005];
int main()
{
	read(n);
	read(xx);
	for(int i=1;i<=n;i++)
	{
		read(s[i]);
		pre[i]=pre[i-1]+s[i];
	}
	ll ans=pre[n]*5+n*xx;
	for(int k=1;k<=n;k++)
	{
		ll res=0;
		for(int j=1,i=n;i>0;i-=k,j++)
		{
			ll rt=max(5,2*j+1);
			int las=max(0,i-k);
			res+=rt*(pre[i]-pre[las]);
		}
		ans=min(ans,res+k*xx);
	}
	out(ans+n*xx);
	return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<cmath>

using namespace std;

int main()
{
	long long A,B,C,X,Y;
	long long ans = 0;

	cin >> A >> B >> C >> X >> Y;

	if(A+B >= 2*C)
	{
		ans = 2*C*min(X,Y);

		if(X > Y)
		{
			ans += min(2*C*(X-Y),A*(X-Y));
		}
		else
		{
			ans += min(2*C*(Y-X),B*(Y-X));
		}
		cout << ans << endl;
	}
	else
	{
		cout << A*X + B*Y << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
signed main()
{
    IOS
    int n; cin>>n;
    double arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    sort(arr,arr+n);
    double ans = arr[0];
    for(int i=1;i<n;i++)
    {
        ans = (arr[i] + ans)/2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll total=0;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        total=total^a[i];
    }
    vector<ll> ans(n);
    for(ll i=0;i<n;i++){
        ans[i]=total^a[i];
    }
    for(ll i=0;i<n;i++){
        cout<<ans[i]<<" ";
    }
    cout<<endl;

}

Measured memory_bytes: 6416
#include<stdio.h>
#define M -1000000000
int main()
{
	int a;
	int n,min,max=M;
	scanf("%d",&n);
	scanf("%d",&a); 
	min = a;
	for(int i=1;i<n;i++)
	{
		scanf("%d",&a);
		if(max<a-min)
		{
			max = a-min;
		}
		if(min>a)
		{
			min=a;
		}
		
	}
	printf("%d\n",max);
	return 0;
 } 


Measured memory_bytes: 2760
#include<bits/stdc++.h>
using namespace std;
int n,a,d,t[1000003],maxa=-1;
int gcd(int x,int y)
{
    if(!y)
		return x;
    return gcd(y,x%y);
}
void fj(int x)
{
    for(int i=2;i*i<=x;)
	{
        if(!(x%i))
		{
            ++t[i];
            while(!(x%i))
				x/=i;
        }
        else
			++i;
    }
    if(x>1)
		++t[x];
}
int main()
{
    cin>>n>>a;
    d=a;
    for(int i=2;i<=n;i++)
	{
        cin>>a;
        if(maxa<a)
			maxa=a;
        d=gcd(d,a);
        fj(a);
    }
    if(d==1)
	{
        for(int i=2;i<=maxa;i++)
            if(t[i]>1)
			{
				cout<<"setwise coprime"<<endl;
				return 0;	
			}
        cout<<"pairwise coprime"<<endl;
    }
    else
		cout<<"not coprime"<<endl;
    return 0;
}

Measured memory_bytes: 7428
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;
const int mod = 1e9 + 7;

ll dp[105][105][256];
ll fact[105];

int main()
{
    fact[0] = 1;
    for (int i = 1; i <= 100; ++i) {
        fact[i] = i * fact[i - 1];
        fact[i] %= mod;
    }

    int n, k; cin >> n >> k;

    vi a(n);

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

    dp[0][0][0] = 1;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= i; ++j) {
            for (int k = 0; k <= 255; ++k) {
                (dp[i + 1][j + 1][k ^ a[i]] += dp[i][j][k]) %= mod;
                (dp[i + 1][j][k] += dp[i][j][k]) %= mod;
            }
        }
    }

    ll ans = 0;

    rep(i, n + 1) {
        ans += (ll)dp[n][i][k] * fact[i];
        ans %= mod;
    }

    cout << ans << endl;
}

Measured memory_bytes: 10880
// ProblemURL : https://atcoder.jp/contests/abc127/tasks/abc127_c
// ---------------------------------------------
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	l := make([]int, m)
	r := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&l[i], &r[i])
		l[i]--
		r[i]--
	}

	idCard := make([]int, n+1)
	for i := 0; i < m; i++ {
		idCard[l[i]]++
		idCard[r[i]+1]--
	}
	for i := 1; i < len(idCard); i++ {
		idCard[i] += idCard[i-1]
	}

	ct := 0
	for i := range idCard {
		if idCard[i] == m {
			ct++
		}
	}
	fmt.Println(ct)
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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 digit(ll N) {
  int ret = 1;
  while(N>=10) {
    N = N/10;
    ++ret;
  }
  return ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<ull> A(N);
  rep(i,N) cin >> A[i];
  sort(A.begin(), A.end());

  ull ans = 1;
  rep(i,N) {
    if(digit(ans) + digit(A[i] - 1) > 19) {
      cout << -1 << endl;
      return 0;
    }
    ans *= A[i];
    if(ans > 1000000000000000000) {
      cout << -1 << endl;
      return 0;
    }
    if(ans == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
   cout << ans << endl;
}


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

using ll = long long;
const ll mod = 1e9 + 7;

void mkay(ll& a){
	if(a >= mod)
		a -= mod;
}

int main(){
	int n; cin >> n;
	int c[4] = {0, 0, 0, 0};
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		c[(s[0] == 'A' ? 0 : (s[0] == 'W' ? 1 : (s[0] == 'T' ? 2 : 3)))]++;

	}
	for(int i = 0; i < 4; i++){
		string s = (i == 0 ? "AC" : (i == 1 ? "WA" : (i == 2 ? "TLE" : "RE")));
		s += " x ";
		cout << s << c[i] << endl;
	}
}

Measured memory_bytes: 3648
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()


int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p.at(i);
    
    int cnt = 0;
    int mn=1001001001;
    for(int i = 0; i<n; i++){
        if(p.at(i)<mn) cnt++;
        mn=min(mn,p.at(i));
    }
    
    dunk(cnt);
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const int MAX = 100000;

int main() {
	ll n, sum = 0;
	cin >> n;
	vector<ll> A(n);
	int table[MAX+1] = {0};
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		sum += A[i];
		table[A[i]]++;
	}
	ll q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		ll b, c;
		cin >> b >> c;
		ll x = table[b];
		table[b] = 0;
		sum -= x * b;
		table[c] += x;
		sum += x * c;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 4256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
 
int main(){
    int n; cin>>n;
    int a[50],b[50];
    int m=INF,M=-INF;
    int mi,Mi;
    FOR(i,0,n){
        cin>>a[i];
        b[i]=a[i];
        if(M<a[i]){
            M=a[i];
            Mi=i;
        }
        if(m>a[i]){
            m=a[i];
            mi=i;
        }
    }
    vector<int> v;
    if(abs(m)>abs(M)){
        FOR(i,0,n){
            if(b[i]>0){
                v.PB(mi);
                v.PB(i);
            }
        }
        ROF(i,0,n-1){
            v.PB(i+1);
            v.PB(i);
        }
    }else{
        FOR(i,0,n){
            if(b[i]<0){
                v.PB(Mi);
                v.PB(i);
            }
        }
        FOR(i,0,n-1){
            v.PB(i);
            v.PB(i+1);
        }
    }
    int num=v.size()/2;
    cout<<num<<endl;
    FOR(i,0,num){
        cout<<v[2*i]+1<<" "<<v[2*i+1]+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRT(v) sort(v.begin(),v.end())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    string s;
    cin >> s;
  	int ans = 0;
    REP(i,0,3){
		if(s[i]=='a') ans += 1;
		if(s[i]=='b') ans += 10;
		if(s[i]=='c') ans += 100;
    }
    //処理
    //出力
    if(ans == 111) cout << "Yes" << ENT;
    else cout << "No" << ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int PrimeJudge(int);
#define N 10000
int main(){
  int i,n,flg,prime=0,num[N];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&num[i]);
    flg=PrimeJudge(num[i]);
    if(flg==0) prime++;
  }
  printf("%d\n",prime);
  return 0;
}
int PrimeJudge(int data){
  int i=3;
  if(data==2) return 0;
  if(data<2 || data%2==0) return -1;
  while(i<=sqrt(data)){
    if(data%i==0) return -1;
    i=i+2;
  }
  return 0;
}



Measured memory_bytes: 2104
#!/usr/bin/env python3
N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
for b in range(-1, 60)[::-1]:
    if b >= 0 and not K >> b & 1:
        continue
    tmp = 0
    for i in range(60)[::-1]:
        c = sum(x >> i & 1 for x in A)
        if i > b:
            tmp += (1 << i) * (N - c if K >> i & 1 else c)
        elif i == b:
            tmp += (1 << i) * c
        else:
            tmp += (1 << i) * max(c, N - c)
    ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 69740
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define Dd "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
LL A, B, C, D;
LL get(LL x, LL r) {
	return r / x;
}
LL get(LL x, LL l, LL r) {
	return get(x, r) - get(x, l - 1);
}
int main() {
	cin >> A >> B >> C >> D;
	cout << (B - A + 1ll) - (get(C, A, B) + get(D, A, B) - get(C * D / gcdl(C, D), A, B));
	return 0;
}

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

#define long long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define sz(x) (int)x.size()
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,v) memset(a,v,sizeof(a))
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define INF 0x3f3f3f3f//infinity for integers
#define JJ ios_base::sync_with_stdio(0); cin.tie(0)//input fast
#define MOD 1000000007
#define hash(n) unordered_map<int,int>mp(n)

 
int main() 
{ 
	JJ;
	int x,ans;
    FOR(i,1,6){
    	cin>>x;
    	if(x==0)
    		ans=i;
    }
     		cout<<ans<<endl;


    
} 

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    ll h,w,x;
    cin>>h>>w;
    x=h*w;
    if(h==1||w==1) cout<<1;
    else if(x%2==0) cout<<x/2;
    else cout<<x/2+1;
    cout<<endl;
    return 0;
}

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

int M, T, P, R;

struct Team{
  int cntWrongAns[10];
  int teamId, time, accepted;
  Team(int id){
    for(int i = 0; i < 10; i++) cntWrongAns[i] = 0;
    teamId = id;
    time = 0;
    accepted = 0;
  }
};

bool operator < (const Team &a, const Team &b){
  if(a.accepted == b.accepted){
    if(a.time == b.time) return a.teamId > b.teamId;
    return a.time < b.time;
  }
  return a.accepted > b.accepted;
}

bool operator == (const Team &a, const Team &b){
  return a.accepted == b.accepted && a.time == b.time;
}

int main(void){
  while(cin >> M >> T >> P >> R && M | T | P | R){
    vector<Team> v;
    for(int i = 0; i < T; i++) v.push_back(Team(i));

    for(int i = 0; i < R; i++){
      int m, t, p, j;
      cin >> m >> t >> p >> j;
      t--; p--;
      if(j == 0){
        for(int k = 0; k < v.size(); k++) if(v[k].teamId == t){
          v[k].accepted++;
          v[k].time += m;
          v[k].time += 20 * v[k].cntWrongAns[p];
          break;
        }
      }else{
        for(int k = 0; k < v.size(); k++) if(v[k].teamId == t){
          v[k].cntWrongAns[p]++;
          break;
        }
      }
    }
    
    sort(v.begin(), v.end());
    
    for(int i = 0; i < v.size(); i++){
      if(i) { bool flag = (v[i-1] == v[i]); cout << (flag ? "=" : ","); }
      cout << v[i].teamId + 1;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1208