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

using namespace std;

int main() {
	char c;
	cin >> c;
	if (c >= 'A' && c <= 'Z') cout << "A" << endl;
	else cout << "a" << endl;

	return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>

char fie[9][9];
const char *dat="ox";
int dx[8]={0,1,0,-1,1,1,-1,-1};
int dy[8]={1,0,-1,0,1,-1,1,-1};

int check(int x,int y,int t){
	int cnt=0;
	for(int i=0;i<8;i++){
		int nx=x+dx[i],ny=y+dy[i];
		int cc=0;
		while(nx>=0 && nx<8 && ny>=0 && ny<8){
			if(fie[nx][ny]=='.')break;
			if(fie[nx][ny]==dat[t]){
				cnt+=cc;
				break;
			}
			if(fie[nx][ny]==dat[1-t]){
				cc++;
			}
			nx+=dx[i];
			ny+=dy[i];
		}
	}
	return cnt;
}

void flip(int x,int y,int t){
	fie[x][y]=dat[t];
	for(int i=0;i<8;i++){
		int nx=x+dx[i],ny=y+dy[i];
		while(nx>=0 && nx<8 && ny>=0 && ny<8){
			if(fie[nx][ny]=='.')break;
			if(fie[nx][ny]==dat[t]){
				for(int j=x+dx[i],k=y+dy[i];j!=nx || k!=ny;j+=dx[i],k+=dy[i]){
					fie[j][k]=dat[t];
				}
				break;
			}
			nx+=dx[i];
			ny+=dy[i];
		}
	}
}

int main(void){
	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++){
			scanf("%c",&fie[j][i]);
		}
		scanf("%*c");
	}
	int turn=0,pass=0;
	while(pass<2){
		int nx=-1,ny=-1;
		int nc=0;
		if(turn==0){
			for(int i=0;i<8;i++){
				for(int j=0;j<8;j++){
					if(fie[j][i]=='.'){
						int cc=check(j,i,turn);
						if(cc>nc){
							nx=j;
							ny=i;
							nc=cc;
						}
					}
				}
			}
		}else{
			for(int i=7;i>=0;i--){
				for(int j=7;j>=0;j--){
					if(fie[j][i]=='.'){
						int cc=check(j,i,turn);
						if(cc>nc){
							nx=j;
							ny=i;
							nc=cc;
						}
					}
				}
			}
		}
		if(nc==0){
			pass++;
		}else{
			flip(nx,ny,turn);
			pass=0;
		}
		turn=1-turn;
	}
	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++){
			printf("%c",fie[j][i]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 936
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    private const int MOD_N = 1000000000 + 7;

    public static void Main()
    {
        var list = Console.ReadLine().Split(' ');
        var n = int.Parse(list[0]);
        var m = int.Parse(list[1]);
        var ass = new int[m];
        for (int i = 0; i < ass.Length; ++i)
            ass[i] = int.Parse(Console.ReadLine());

        int pp = 1;
        int prev = 0;
        int current = 0;

        int ai = 0;
        var a = ai < ass.Length ? ass[ai] : -1;

        if (a == 1)
        {
            prev = 0;
            ++ai;
            if (ai < ass.Length)
                a = ass[ai];
        }
        else
        {
            prev = pp;
        }

        for (int i = 2; i <= n; ++i)
        {
            if (i == a)
            {
                current = 0;
                ++ai;
                if (ai < ass.Length)
                    a = ass[ai];
            }
            else
            {
                current = prev + pp;
                current %= MOD_N;
            }
            pp = prev;
            prev = current;
        }

        Console.WriteLine(prev);
    }

    private static int Comb(int m, int n)
    {
        var t = m - n;
        if (n > t)
            n = t;

        long numerator = 1;
        for (int i = 0; i < n; ++i)
        {
            numerator *= m - i;
            numerator %= MOD_N;
        }
        long denominator = 1;
        for (; n != 0; --n)
        {
            denominator *= n;
            denominator %= MOD_N;
        }

        var inv_denominator = ModInv((int)denominator, MOD_N);
        var ret = (int)(numerator * inv_denominator % MOD_N);

        return ret >= 0 ? ret : ret + MOD_N;
    }

    private static int ModInv(int a, int m)
    {
        int b = m, x = 1, y = 0;
        while (b != 0)
        {
            var t = a / b;
            a -= t * b;
            Swap(ref a, ref b);
            x -= t * y;
            Swap(ref x, ref y);
        }
        x %= m;
        return x >= 0 ? x : x + m;
    }

    private static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
}


Measured memory_bytes: 13280
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3;
const lli INF = 1e18;
const lli MOD = 1e9+7;

vi m;
vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	m = vi(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

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

// ---- コーディングはここから！ ('-')7

void solve(){
	int h,w,k; cin>>h>>w>>k;
	map<ii,int>q;
	vl row(h,0), col(w,0);
	fore(i,0,k){
		int a,b; cin>>a>>b;
		a--,b--;
		q[{a,b}]++;
		row[a]++; col[b]++;
	}
	auto b=*max_element(all(row));
	auto a=*max_element(all(col));
	lli mx=a+b-1;
	vi best;
	int can=0;
	fore(i,0,h)if(row[i]==b)best.pb(i);
	fore(i,0,w)if(col[i]==a){
		for(auto &j:best)if(!q.count({j,i})){can=1;break;}
		if(can)break;
	}
	
	cout<<mx+can<<ENDL;
}

int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


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

ll gcd(ll a,ll b){
  if(b%a==0) return a;
  else return gcd(b,a%b);
}

int main(){
  ll x,y;
  cin >> x >> y;
  if(x%y==0) cout << -1 << endl;
  else{
    if(gcd(x,y)!=2) cout << x*3 << endl;
    else cout << x*2 << endl;
  }
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll X;
    cin >> X;
    FOR(A, -2e3, 2e3) {
        FOR(B, -2e3, 2e3) {
            if (pow(A, 5) - pow(B, 5) == X) {
                cout << A << " " << B << "\n";
                return 0;
            }
        }
    }
}


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

int main()
{
  string s;
  cin >> s;
  
  if (s[0] != 'A')
  {
    cout << "WA" << endl;
    return 0;
  }
  int c = 0;
  for (int i = 1; i < s.size(); ++i)
  {
    if (s[i] <= 'Z' && s[i] >= 'A')
    {
      if (s[i] == 'C' && i < s.size() - 1 && i > 1) ++c;
      else
      {
        cout << "WA" << endl;
        return 0;
      }
    }
  }
  cout << (c == 1 ? "AC" : "WA") << endl;
}

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

int main(int argc, char *argv[]) {
  std::string s;
  std::cin >> s;
  int q;
  std::cin >> q;
  bool rev = false;
  for (int i = 0; i < q; ++i) {
    int cmd;
    std::cin >> cmd;
    if (cmd == 1)
      rev = !rev;
    if (cmd == 2) {
      char c;
      int f;
      std::cin >> f >> c;
      bool front = true;
      if (f == 2)
        front = false;
      if ((front && !rev) || (!front && rev))
        s.insert(s.begin(), c);
      else
        s.push_back(c);
    }
  }
  if (rev)
    std::reverse(s.begin(), s.end());
  std::cout << s << std::endl;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    ll n;cin>>n;
    ll a[n];for(ll i=00;i<n;i++)cin>>a[i];
    ll ans = LLONG_MAX;
    for(ll pos=1;pos<=100;pos++){
        ll  cur=0;
        for(ll i=0;i<n;i++)cur+=(pos-a[i])*(pos-a[i]);
        ans=min(ans,cur);
    }
    cout<<ans;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>

#define mp make_pair
#define pb push_back
#define FI first
#define SI second


#ifdef _MSC_VER
    #define ALIGN(x) __declspec(align(x))
#else
    #define ALIGN(x) __attribute__((aligned(x)))
#endif


using namespace std;

typedef long long ll;

const int maxn = 503;

int a[maxn][maxn];
int t[maxn][maxn];
int c[maxn];

int main() {
    int n;
    scanf("%d", &n);
    bool never = true;
    for (int i = 0; i < n; ++i) {
        getchar();
        for (int j = 0; j < n; ++j) {
            a[i][j] = (getchar() == '#') ? 1 : 0;
            if (a[i][j] == 1) never = false;
        }
    }
    if (never) {
        printf("-1\n");
        return 0;
    }
    int c = 0;
    for (int j = 0; j < n; ++j) {
        bool white = false;
        for (int i = 0; i < n; ++i) 
            if (a[i][j] == 0)
                white = true;
        if (white) ++c;
    }
    int best = (int)1e9;
    for (int j = 0; j < n; ++j) {
        int cur = 0;
        bool allWhite = true;
        for (int i = 0; i < n; ++i)
            if (a[i][j] == 1)
                allWhite = false;
        if (allWhite) ++cur;
        for (int i = 0; i < n; ++i)
            if (a[j][i] == 0) ++cur;
        best = min(cur, best);
    }
    printf("%d\n", c + best);
    return 0;
}

Measured memory_bytes: 1280
from sys import stdin
def ip(): return [int(i) for i in stdin.readline().split()]
def sp(): return [str(i) for i in stdin.readline().split()]


n = int(input())
row = False
cnt = 0
for _ in range(n):
    x,y = ip()
    if x == y: cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        row = True

if row: print("Yes")
else: print("No")

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

string tapDance(string s)
{
	for (int i = 0; i < s.length(); i++)
	{
		switch (s[i])
		{
		case 'U':
		case 'D':
			break;
		case 'R':
			if (i % 2) return "No";
			break;
		case 'L':
			if (i % 2 == 0) return "No";
			break;
		default:
			return "No";
			break;
		}
	}
	return "Yes";
}

int main()
{
	string S;
  	cin >> S;
  	cout << tapDance(S) << endl;
	return 0;
}

Measured memory_bytes: 256
// B - Five Dishes
#include <bits/stdc++.h>
using namespace std;
#define idev_up(a,b) (((a)-(b)-1)/(b))

int main(){
	int time = 0, max_dif = 0;
	for(int i=0; i<5; ++i){
		int a; cin>>a;
		int dif = ((a+9)/10) * 10 - a;
		if(max_dif<dif) max_dif = dif;
		time += a + dif;
	}
	cout<< time - max_dif <<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.ABC057
{
    class MaximumAverageSets
    {
        static long Factorial(int n)
        {
            return (n == 0) ? 1 : n * Factorial(n - 1);
        }
        static long Combination(int n, int r)
        {
            long res = 1;
            for (var i = 1; i <= r; ++i)
            {
                res = res * (n - i + 1) / i;
            }
            return res;
        }
        public static void Main()
        {
            var nab = ReadLine().Trim().Split(' ').Select(i => int.Parse(i)).ToArray();
            var n = nab[0]; var a = nab[1]; var b = nab[2];
            var values = ReadLine().Trim().Split(' ').Select(v => long.Parse(v)).OrderBy(v => -v).ToArray();
            long sum = 0;
            var last = 0;
            for (; last < a; ++last)
                sum += values[last];
            var average = (double)sum / a;
            WriteLine(average.ToString(".00000000"));
            var lastFirst = 0;
            for (; values[lastFirst] != values[last]; ++lastFirst) ;
            var lastCount = values.Where(i => values[last] == i).Count();
            var lastEnd = lastFirst + lastCount;
            var minChoice = a - lastFirst;
            if (average == values[last])
            {
                var maxChoice = ((b > lastEnd) ? lastEnd : b) - lastFirst;
                long res = 0;
                for (var i = minChoice; i <= maxChoice; ++i)
                    res += Combination(lastCount, i);
                WriteLine(res);
            }
            else
            {
                WriteLine(Combination(lastCount, minChoice));
            }
        }
    }
}


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

using namespace std;
int main()
{
  int n,k;
  string s;
  cin >> n;
  cin >> s;
  cin >> k;
  
  char check = s[k-1];
  for (int i=0; i<s.size(); ++i) {
    if (s[i] != check) {
      s[i] = '*';
    }
  }
  
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
while True:
	try:
		code = raw_input()
	except EOFError:
		break
	
	a,b = map(str,code.split("+"))
	b,c = map(str,b.split("="))
	num = [a,b,c]
	
	judge = True
	for i in xrange(10):
		if len(num[0]) > 1 and num[0][:1] == "X" and i == 0:
			continue
		if len(num[1]) > 1 and num[1][:1] == "X" and i == 0:
			continue
		if len(num[2]) > 1 and num[2][:1] == "X" and i == 0:
			continue
		if int(num[0].replace("X", str(i))) + int(num[1].replace("X", str(i))) == int(num[2].replace("X", str(i))):
			judge = False
			print i
			
	if judge:
		print "NA"

Measured memory_bytes: 6528
N, M = map(int, input().split())
A = sorted([int(i) for i in input().split()], reverse=True)

# xを作るために使うマッチの本数
h = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}

# dp[i] = i 本のマッチ棒を使って、条件を満たす整数を作るときの最大桁数
dp = [-1] * (N + 1)
dp[0] = 0

for i in range(N + 1):
    for a in A:
        if i - h[a] < 0: continue
        dp[i] = max(dp[i-h[a]] + 1, dp[i])

digit = dp[N]
ans = ''

n = N
for d in range(digit):
    for a in A:
        if n - h[a] < 0:continue
        if dp[n - h[a]] == digit - 1:
            ans += str(a)
            n -= h[a]
            digit -= 1
            break
print(ans)

Measured memory_bytes: 3388
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (int i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<double, double>  iidb;
#define iii pair<ii, nodo*>
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9+7;
const double PI = acos(-1);
#define initseg ll new_nodo=(pnodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 3000
#define offset 3000
#define ptr nodo*
const int MOD=1e9+7;

using namespace std;

int main()
{	
	int n;
	cin>>n;
	map<int,int> m;
	forr(i,0,n)
	{
		int valor;
		cin>>valor;
		m[valor-1]++;
		m[valor+1]++;
		m[valor]++;
	}
	ii maxx={0,0};
	for(auto par:m)
	{
		maxx=max(maxx,{par.se,par.fi});
	}
	cout<<maxx.fi<<endl;
}

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

using namespace std;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}


int main(){

    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    //freopen("input.txt", "r", stdin);

    int n, zero = 1, parity = 0;
    long long s = 0, lowest = 2e9;

    cin >> n;

    for(int i = 0; i < n; ++i){
        long long j;
        cin >> j;
        if(j < 0LL){
            parity ^= zero;
        } else if(j == 0LL){
            zero = 0;
            parity = 0;
        }
        lowest = min(lowest, (j < 0LL ? -j : j));
        if(j > 0)
            s += j;
        else
            s -= j;
    }

    if(parity == 1)
        s -= lowest * 2;

    cout << s;

    return 0;
}


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

using namespace std;
 
// macro
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define MOD 1000000007
#define M_PI 3.14159265358979323846
#define ll long long
#define ull unsigned long long
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define SORT(ary) sort(begin(ary), end(ary))
#define VL vector<ll>
#define VVL vector<VL>
#define PL pair<ll, ll>
 
// Factorial
// need init
ll factorial_memo[5001];
ll factorial(ll n) {
  factorial_memo[0] = 1;
  if(factorial_memo[n] != -1) return factorial_memo[n];
  factorial_memo[n] = (factorial(n-1) * n) % MOD;
  return factorial_memo[n];
}
 
// Combination(nCr)
// need init
ll nCr_memo[5001][5001];
ll nCr(ll n, ll r) {
  if(r*2 > n) r = n-r;
  if(r == 1) return n;
  if(r == 0) return 1;
  if(nCr_memo[n][r] != -1) return nCr_memo[n][r];
  nCr_memo[n][r] = (nCr(n-1, r) + nCr(n-1, r-1)) % MOD;
  return nCr_memo[n][r];
}

ll dfs(VVL& g, vector<PL>& res, ll v, ll& count, ll from, VL& low, VL& pre) {
  pre[v] = count++;
  low[v] = pre[v];
  for(auto to:g[v]) {
    if (pre[to] == -1) {
      low[v] = min(low[v], dfs(g, res, to, count, v, low, pre));
      if(low[to] == pre[to]) res.push_back(make_pair(v, to));
    } else {
      if(from == to) continue;
      low[v] = min(low[v], low[to]);
    }
  }
  return low[v];
}

vector<PL> bridges(VVL& g, ll N) {
  vector<PL> res;
  if (N > 0) {
    VL low(N, -1);
    VL pre(N, -1);
    ll count = 0;
    dfs(g, res, 0, count, -1, low, pre);
  }
  return res;
}

void solve() {
  ll N,M,a,b;
  cin >> N >> M;
  VVL path(N, vector<ll>(0));
  REP(i, M) {
    cin >> a >> b;
    a--;
    b--;
    path[a].push_back(b);
    path[b].push_back(a);
  }
  vector<PL> bs = bridges(path, N);
  cout << bs.size() << "\n";
}



int main() {
  // init
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
  int n;
  cin>>n;
  double a[n][2];
  rep(i,n){cin>>a[i][0]>>a[i][1];}
  double l=0;
  rep(i,n){for(int j=i+1;j<n;j++){
  {l+=sqrt((a[i][0]-a[j][0])*(a[i][0]-a[j][0])+
           (a[i][1]-a[j][1])*(a[i][1]-a[j][1]));}}}
  cout << setprecision(15) <<2*l/n<<endl;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int n;
    cin >> n;
    vector<ll> t(n);
    for(int i = 0; i < n; i++){
        cin >> t[i];
    }
    int m;
    cin >> m;
    vector<pair<int,ll>> d(m);
    for(int i = 0; i < m; i++){
        int p;
        ll x;
        cin >> p >> x;
        d[i] = make_pair(p, x);
    }
    for(int i = 0; i < m; i++){
        ll ans = 0;
        for(int j = 0; j < n; j++){
            if(d[i].first - 1 == j) ans += d[i].second;
            else ans += t[j];
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
# coding: utf-8
# Your code here!

for i in range(4):
    t,n=map(int,input().split())
    K = int()
    if t==1:
        K = 6000*n
    elif t==2:
        K = 4000*n
    elif t==3:
        K = 3000*n
    else:
        K = 2000*n
    print(K)


Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main() {
  string str;
  cin >>  str;
  int S =0;
  for ( int i = 0; i < str.length(); i++ ) {
    S += str[i] - '0';
  }
  int output;
  stringstream ss;
  ss << str;
  ss >> output;

  if ( output % S == 0 ) cout << "Yes" << endl;
   else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#####segfunc#####
def segfunc(x, y):
    return max(x, y)
#################

#####ide_ele#####
ide_ele = float('-inf')
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

N, K = map(int,input().split())
a = [0] * 300001
seg = SegTree(a, segfunc, ide_ele)
ans = 0
for _ in range(N):
    x = int(input())
    tmp = seg.query(max(0, x - K), min(300001, x + K + 1))
    ans = max(ans, tmp + 1)
    seg.update(x, tmp + 1)
print(ans)

Measured memory_bytes: 106844
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
x = I()
ans = 2*(x//11)+1
x %= 11
if x == 0:
    ans -= 1
if x > 6:
    ans += 1
print(ans)
"""

#D
n = I()
a = LI()
d = defaultdict(int)
for i in a:
    d[i] += 1
l = list(d.values())
k = len(l)+sum(l)
for i in d.keys():
    d[i] = 1
ans = sum(list(d.values()))
ans -= 1 if k%2 else 0
print(ans)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 63120
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int gcd(int x, int y)
{
    if (y == 0) return x;
    return gcd(y, x % y);
}

int a, b;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b;
    int tmp = gcd(a, b);
    long long ans = a*1LL*b;
    ans /= gcd(a, b);
    cout << ans << E;
    //system("pause");
    return 0;
}

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

const int INF = 1e9;
int N, M, R;
int r[10];
int dist[210][210]; // 最短距離を格納する二次元配列
bool used[10]; // 深さ優先探索において、町を訪問済みかどうかを格納する
int ans = INF;

// n: 訪問済みの町の数、p:
void dfs(int n, int p, int d) {
  if (n == R) {
    ans = min(ans, d);
    return;
  }

  for (int i = 0; i < R; i++) {
    if (!used[i]) {
      used[i] = true;
      if (p == -1) dfs(1, r[i], 0);
      else dfs(n + 1, r[i], d + dist[p][r[i]]);
      used[i] = false;
    }
  }
}

int main() {
  // 入力
  cin >> N >> M >> R;
  for (int i = 0; i < R; i++) {
    cin >> r[i];
    r[i]--;
  }

  // 初期化
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      dist[i][j] = (i == j ? 0 : INF);
    }
  }

  int a, b, c;
  for (int i = 0; i < M; i++) {
    cin >> a >> b >> c;
    a--; b--;
    dist[a][b] = dist[b][a] = c;
  }

  // Nが最大200と小さいので、ワーシャルフロイドで全2頂点間の最短距離を求める
  for (int k = 0; k < N; k++) { // 経由頂点
    for (int i = 0; i < N; i++) { // 開始頂点
      for (int j = 0; j < N; j++) { // 終了頂点
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }

  // Rはmin(8, N)なので、順列を全て試せる（深さ優先探索で試す）
  dfs(0, -1, 0);

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
main = do
        _ <- getLine
        as <- map read . words <$> getLine
        let s = sum as
        print . minimum $ f as (0, s)
 
dist (x, y) = abs (x - y)
 
f [_] _ = []
f (a:as) (x, y) =
         dist (x + a, y - a) : f as (x + a, y - a)

Measured memory_bytes: 59772
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func count(starts, ends []int) int {
	sort.Ints(ends)
	sort.Ints(starts)
	num := ends[0] - starts[len(starts)-1] + 1
	if num < 0 {
		num = 0
	}
	return num
}
func main() {
	_, m := nextInt(), nextInt()
	starts := make([]int, m)
	ends := make([]int, m)

	for i := 0; i < m; i++ {
		starts[i] = nextInt()
		ends[i] = nextInt()
	}
	r := count(starts, ends)
	fmt.Println(r)
}


Measured memory_bytes: 3328
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[200005];
long long dp[5][2050]={0};
int main(){
	long long i,j,n,ans=0;
	scanf(" %s",str);
	for(i=0;str[i];i++){
		for(j=0;j<2019;j++)
			dp[i&1][j]=0;
		for(j=0;j<2019;j++)
			dp[i&1][(j*10+str[i]-'0')%2019]+=dp[(i&1)^1][j];
		dp[i&1][str[i]-'0']++;
		ans+=dp[i&1][0];
	}
	printf("%lld\n",ans);
}

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



long long int f(string s){
	if(s.length()==0) return 0;
	int d[s.length()];
	int n = s.length();
	memset(d,0,sizeof(d));
	for(int i=1;i<n;i++){
		if(s[i]==s[i-1]){
			if(i>=2)
				d[i]=1+d[i-2];
			else d[i]=1;
		}
		else{
			d[i]=d[i-1];
		}
	}
	return d[n-1];
}


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

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif

	string s;
	long long int k;
	cin >> s >> k;
	long long int cnt1=f(s),cnt2=f(s+s),cnt3=f(s+s+s),cnt4=f(s+s+s+s);
	long long int del;
	if(k%2==0){
		del = cnt4-cnt2;
		cout << cnt2+((k-2)/2)*del;
	}
	else{
		del = cnt3-cnt1;
		cout << cnt1+((k-1)/2)*(del);
	}

}


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

constexpr D EPS = 1e-8;

int main(){
  int n, testcase = 0;
  while(cin >> n, n){
    ++testcase;
    vector<D> X, Y;
    vector<D> X_, Y_, R_;
    for(int i = 0; i < n; ++i){
      D x, y, r;
      cin >> x >> y >> r;
      X_.push_back(x);
      Y_.push_back(y);
      R_.push_back(r);
      X.push_back(x-r);
      X.push_back(x+r);
      Y.push_back(y-r);
      Y.push_back(y+r);
    }
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    vector<vector<int>> A(2*n+1,vector<int>(2*n+1,0));
    for(int i = 0; i < n; ++i){
      D x = X_[i], y = Y_[i], rr = R_[i];
      int l = -1, r = -1, t = -1, b = -1;
      for(int j = 0; j < 2*n; ++j){
        if(abs(x-rr-X[j]) < EPS) l = j;
        if(abs(x+rr-X[j]) < EPS) r = j;
      }
      for(int j = 0; j < 2*n; ++j){
        if(abs(y-rr-Y[j]) < EPS) t = j;
        if(abs(y+rr-Y[j]) < EPS) b = j;
      }
      ++A[l][t];
      --A[l][b];
      --A[r][t];
      ++A[r][b];
    }
    for(int i = 0; i < 2*n; ++i){
      for(int j = 0; j < 2*n; ++j){
        A[i][j+1] += A[i][j];
      }
    }
    for(int i = 0; i < 2*n; ++i){
      for(int j = 0; j < 2*n; ++j){
        A[i+1][j] += A[i][j];
      }
    }
    D ans = 0;
    for(int i = 0; i < 2*n; ++i){
      for(int j = 0; j < 2*n; ++j){
        if(A[i][j] <= 0) continue;
        ans += (X[i+1]-X[i])*(Y[j+1]-Y[j]);
      }
    }
    printf("%d %.2f\n",testcase,ans);
  }
}



Measured memory_bytes: 3304
fun main(args: Array<String>) {
    val S = next()
    val C = mutableMapOf<Char, Int>()
    C['0'] = 0; C['1'] = 0
    S.forEach { C[it] = C[it]!! + 1 }
    println(2 * Math.min(C['0']!!, C['1']!!))
}
fun next() = readLine()!!

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define vuni(v) v.erase(unique(v.begin(), v.end()), v.end());
#define mins(m, s) m.insert(make_pair(s, 1));
#define mfin(m, s) m.find(s) != m.end()

#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

int main(){
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

using P = pair<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++) {
        cin >> b[i];
    }
    int ans = INF;
    for(int bit = 0; bit < (1 << n); bit++) {
        // 表なら1、裏なら0
        vector<int> c;
        vector<P> pOdd, pEven, need(51);
        for(int i = 0; i < n; i++) {
            if(bit & (1 << i)) {
                c.push_back(a[i]);
                if(i % 2) {
                    need[a[i]].second++;
                    pOdd.push_back(P(a[i], i));
                } else {
                    need[a[i]].first++;
                    pEven.push_back(P(a[i], i));
                }
            } else {
                c.push_back(b[i]);
                if(i % 2) {
                    need[b[i]].first++;
                    pEven.push_back(P(b[i], i));
                } else {
                    need[b[i]].second++;
                    pOdd.push_back(P(b[i], i));
                }
            }
        }
        sort(ALL(c));
        vector<P> v(51);
        for(int i = 0; i < n; i++) {
            if(i % 2) {
                v[c[i]].second++;
            } else {
                v[c[i]].first++;
            }
        }
        if(need != v) {
            continue;
        }
        sort(ALL(pOdd));
        sort(ALL(pEven));
        vector<int> sorted;
        for(int i = 0; i < max(pOdd.size(), pEven.size()); i++) {
            if(i < pEven.size()) {
                sorted.push_back(pEven[i].second);
            }
            if(i < pOdd.size()) {
                sorted.push_back(pOdd[i].second);
            }
        }
        int cnt = 0;
        vector<int> num(n);
        for(int i = 0; i < n; i++) {
            for(int j = sorted[i]; j < n; j++) {
                cnt += num[j];
            }
            num[sorted[i]]++;
        }
        chmin(ans, cnt);
    }
    cout << (ans == INF ? -1 : ans) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;

const ll mod=1e9+7;
const ll min_max = 1e12;

ll gcd(ll a, ll b){
    ll r;
    while((r =a%b)){
        a = b;
        b = r;
    }
    return b;
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


//単純な素数か素数じゃないかの問題ではない。
int main(){

  int a;
  int b;
  double x;
  double w = 0.0;
  double ans = 0.0;
  cin >> a >> b >> x;

  if( x >= a*a*b/2.0 ){
    w = x * 2.0 / a / a - 2.0 * b;
    ans = atan2((double)a, w) * 180.0 / 3.141592653589793 - 90.00000;
  }else{
    w = x * 2.0 / b / a ;
    ans = 90.000000 - atan2(w, (double)b) * 180.0 / 3.141592653589793;
  }

  std::cout << std::setprecision(11) << ans << endl;

  return 0;

}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second


int n, a[51], b[51];
ll fact[51], ans = 0;
vector<P>v[51];
bool t[51], node[51];

void bfs(int no) {
	for (P u:v[no]) {
		if (!t[u.sc])continue;
		if (!node[u.fr]) {
			node[u.fr] = 1;
			bfs(u.fr);
		}
	}
	return;
}

int main() {
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	for (int i = 0;i < n;i++) {
		cin >> b[i];
	}
	fact[0] = 1;
	for (int i = 1;i <= 50;i++) {
		fact[i] = fact[i - 1] * 2;
		t[i] = 1;
	}
	for (int i = 1;i <= 50;i++) {
		for (int j = 1;j <= 50;j++) {
			if (i == i % j)continue;
			v[i].eb(P(i%j, j));
		}
	}
	for (int i = 50;i >= 0;i--) {
		bool ng = 0;
		for (int j = 0;j < n;j++) {
			for (int k = 0;k <= 50;k++) {
				if (a[j] == k)node[k] = 1;
				else node[k] = 0;
			}
			bfs(a[j]);
			if (!node[b[j]] && i == 50) {
				cout << -1 << endl;
				return 0;
			}
			else if (!node[b[j]]) {
				ng = 1;
			}
		}
		if (ng) {
			t[i + 1] = 1;
			t[i] = 0;
		}
		else {
			t[i] = 0;
		}
	}
	for (int i = 1;i <= 50;i++) {
		if (t[i])ans += fact[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n;
  scanf("%d", &n);
  long long int arr[n], max=1e18, prod=1, flag=0, zero=0;
  for(int i=0; i<n; i++){
    scanf("%lld", &arr[i]);
    flag = (arr[i]>max)? 1:flag;
    prod *= arr[i];
    (arr[i]) ? max /=arr[i] :zero=1;
  }

  (zero)?puts("0"):((flag)? puts("-1") :printf("%lld \n", prod));
  return 0;
}


Measured memory_bytes: 2512
def solve(n, k, h):
    h.sort()
    diff = [h[i]-h[i-k+1] for i in range(k-1, n)]
    return min(diff)


if __name__ == "__main__":
    n, k = map(int, input().split())
    h=[]
    for _ in range(n):
        h.append(int(input()))
    print(solve(n, k, h))


Measured memory_bytes: 11288
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, k;
string s;

int main(){
    cin >> n >> s >> k;
    k--;
    REP(i, n){
        if(s[i] != s[k])s[i] = '*';
    }
    cout << s << endl;
}

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

#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define ll long long int
#define vec vector
#define forn(a) for(ll a=0; a<n; a++)
#define all(x) x.begin(), x.end()
#define deb(x) cerr<<#x<<" = "<<x<<endl

using namespace std;

int main() {
    IOS;

    int n; cin>>n;
    int cont = 0;
    for(int i=1; i<=n; i++){
        int digits = 0;
        int nr = i;
        while(nr!=0){
            digits++;
            nr/=10;
        }
        if(digits%2==1) cont++;
    }

    cout<<cont<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <cstring>
#include<map>
#include<string>
#include<stack>
#include <sstream>
#include<vector>
using namespace std;


int main(){
	int n;
	while(cin>>n)
	{
		if(n==0)break;
		while(n--)
		{
			int ei,suu,koku;
			cin>>suu>>ei>>koku;
			if( suu==100 || ei==100 || koku==100 ) puts("A");
			else if( (suu+ei)/2 >= 90 ) puts("A");
			else if( (suu+ei+koku)/3 >=80 ) puts("A");
			else if( (suu+ei+koku)/3 >=70 ) puts("B");
			else if( (suu+ei+koku)/3 >=50  && (suu>=80 || ei>=80 ) ) puts("B");
			else puts("C");
		}
	}
	return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX =  1e3+3;
char s[MAX], t[MAX];

int main(int argc, char ** argv) {
	scanf(" %s %s", s, t);
	int S = strlen(s);
	int T = strlen(t);
	int ans = S;
	rep(i, 0, S) {
		int cur = 0;
		rep(j, 0, T) {
			if(i+j >= S) { cur = S; break; }
			cur += (s[i+j] != t[j]);
		}
		ans = min(ans, cur);
	}
	printf("%d\n", ans);
	return 0;
}


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

typedef pair<int, int> P;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;



signed main(){
    int N, M;
    while( cin >> N >> M, N | M ){
        vector<int> a( N );
        REP( i, N ) cin >> a[i];

        int ans = 0;
        REP( i, N - 1 ){
            FOR( j, i + 1, N ){
                if( a[i] + a[j] <= M ){
                    chmax( ans, a[i] + a[j] );
                }
            }
        }
        if( ans ) cout << ans << endl;
        else cout << "NONE" << endl;
    }
}



Measured memory_bytes: 3096
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  long long sum = 0;
  for (int i = 0; i < k; i++) {
    int x;
    cin >> x;
    sum += x;
  }
  if (sum >= n) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int maxn=3e5+7;
int n,m,f[maxn];
int fin(int x);
void bing(int x,int y);
int main(){
    scanf("%d %d",&n,&m);
    
    for(int i=1;i<=n;i++){
        f[i]=i;
    }
    
    for(int i=1;i<=m;i++){
        int u,v;
        scanf("%d %d",&u,&v);
        bing(u,v);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(fin(i)==i) ans++;
    }
    printf("%d\n",ans-1);
}
void bing(int x,int y){
    int f1=fin(x);
    int f2=fin(y);
    //cout<<"f1="<<f1<<" f2="<<f2<<endl;

    if(f1==f2) return;
    f[f1]=f2;
}
int fin(int x){
    return f[x]==x? x:f[x]=fin(f[x]);
}
/*
6 4
1 3
1 2
2 3
4 5
*/

Measured memory_bytes: 4220
#include<stdio.h>
int main(void)
{
	int n[10],i,j,a=0;
	for(i=0;i<10;i++) scanf("%d",&n[i]);
	for(i=0;i<10-1;i++){
		for(j=i+1;j<10;j++){
			if(n[i]<n[j]){
				a=n[i];
				n[i]=n[j];
				n[j]=a;
			}
		}
	}
	for(i=0;i<3;i++) printf("%d\n",n[i]);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  while (true) {
    int r0, w0, c, r;
    cin >> r0 >> w0 >> c >> r;
    if (r0 == 0) return;

    int x = (w0 * c - r0 + r - 1) / r;
    if (x < 0) x = 0;
    cout << x << '\n';
  }
}



Measured memory_bytes: 3148
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
N, M, *ABC = [int(_) for _ in open(0).read().split()]
ABC = np.array(ABC)
F = floyd_warshall(
    csr_matrix((ABC[2::3], (ABC[::3], ABC[1::3])), (N + 1, N + 1)), 0)
print(np.sum(F[ABC[::3], ABC[1::3]] != ABC[2::3]))


Measured memory_bytes: 37680
// inputに入力データ全体が入る
function Main(input) {
	
	input = input.split(" ");
	
	//文字列から10進数に変換するときはparseIntを使います
	var N = parseInt(input[0], 10);
	var A = parseInt(input[1], 10);
  var B = parseInt(input[2], 10);
 
    var D = A * N
    if ( D <= B ){
        console.log(D);
        }else { console.log(B)}
                  
               
     }
    
	
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372