akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;
	static boolean f = true;
	static int[] v = {10, 50, 100, 500};

	static boolean solve() {
		int n = in.nextInt();
		if (n == 0) return false;

		int[] c = new int[4];
		int all = 0;
		for (int i=0; i<4; i++) {
			c[i] = in.nextInt();
			all += v[i]*c[i];
		}

		int r = all - n;
		int[] cnt = new int[4];
		for (int i=3; i>=0; i--) {
			cnt[i] = r/v[i];
			r = r%v[i];
		}


		if (!f) out.println();
		for (int i=0; i<4; i++) {
			if (c[i] - cnt[i] > 0) {
				out.println(v[i]+" "+(c[i] - cnt[i]));
			}
		}

		f = false;
		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 39528
import java.util.Scanner;

public class Main {

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

		String line1 = sc.nextLine();
		String[] array1 = line1.split(" ");
		int r = Integer.parseInt(array1[0]);
		int c = Integer.parseInt(array1[1]);

		String[][] h = new String[r][c];
		int[][] hyou = new int[r + 1][c + 1];
		for (int i = 0; i < r; i++) {
			String line2 = sc.nextLine();
			for (int j = 0; j < c; j++) {
				String[] string = line2.split(" ");
				h[i][j] = string[j];
				hyou[i][j] = Integer.parseInt(h[i][j]);
			}

		}

		for (int i = 0; i <= r; i++) {
			if (i == r) {
				for (int k = 0; k <= c; k++) {
					for (int p = 0; p <= r; p++) {
						if (p < r) {
							hyou[r][k] += hyou[p][k];
						}

					}
					if (k == c) {
						System.out.print(hyou[r][k]);

					} else {
						System.out.print(hyou[r][k] + " ");

					}

				}
				System.out.println();

			} else {
				for (int j = 0; j <= c; j++) {
					if (j < c) {
						hyou[i][c] += hyou[i][j];
					}
					if (j == c) {
						System.out.print(hyou[i][j]);

					} else {
						System.out.print(hyou[i][j] + " ");

					}

				}
				System.out.println();
			}
		}

	}

}

Measured memory_bytes: 65136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cout << "[" << #var << "] " << var << endl
const ll mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};



int main(){
    int n, m, k;
    cin >> n >> m >>k;
    mint ans(0);
    combination comb(n);

    if (m==1) {
        if (k==n-1) ans = mint(1);
        cout << ans.x << endl;
        return 0;
    }

    for (int i=0; i<=k; i++) {
        mint res(1);
        res *= comb(n-1, i);
        int num = n - i;
        res *= m;
        res *= mint(m-1).pow(num-1);
        ans += res;
    }
    
    
    
    cout << ans.x << endl;
    return 0;
}


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

int main() {
  char a,b,c;
  cin >> a >> b >> c;
  if ( a == '7' ) {
    cout << "Yes" << endl;
  }  
  else if ( b == '7' ) {
    cout << "Yes" << endl;
  }
  else if ( c == '7' ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3592
import java.lang.Math

fun main(args: Array<String>) {
    val inputN = readLine().orEmpty().toInt()
    val diagramC = mutableListOf<Int>()
    val diagramS = mutableListOf<Int>()
    val diagramF = mutableListOf<Int>()

    val ansList = mutableListOf<Int>()

    for(i in 0 until inputN - 1){
        val dia = readLine()?.split(" ").orEmpty()

        diagramC.add(dia[0].toInt())
        diagramS.add(dia[1].toInt())
        diagramF.add(dia[2].toInt())
    }
    ansList.add(0)
    var j = inputN - 2
    while(j >= 0){
        var time = diagramC[j] + diagramS[j]
        for(k in j + 1 until inputN - 1) {
            run loop@{
             for (l in Math.max(time, diagramS[k]) until Math.max(time, diagramS[k]) + diagramF[k]) {
                    if ((l - diagramS[k]) % diagramF[k] == 0) {
                       time = l + diagramC[k]
                        return@loop
                    }
             }
            }
        }
        ansList.add(time)
        j -= 1
    }


    val showList = ansList.reversed()
    showList.forEach{
        println(it)
    }

}

Measured memory_bytes: 41520
#include<stdio.h>
int main(void)
{
	int N, T,count=0;
	int t[101], c[101];
	int min = 1000;
	scanf("%d%d", &N, &T);
	for (int i = 0; i < N; i++) {
		scanf("%d", &c[i]); scanf("%d", &t[i]);
		if (t[i] <= T) {
			if (c[i] <= min) {
				min = c[i];
				count++;
			}
		}
	}
	if (count == 0) {
		printf("TLE");
	}
	else {
		printf("%d", min);
	}
	return 0;
}

Measured memory_bytes: 128
N, M = map(int, input().split())

Cakes = [tuple(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(1 << 3):
    Cake = [0] * N
    for j in range(3):
        if (i >> j) & 1 == 1:
            for c in range(N):
                Cake[c] += Cakes[c][j]
        else:
            for c in range(N):
                Cake[c] -= Cakes[c][j]
    Cake.sort(reverse=True)
    ans = max(ans, sum(Cake[:M]))


print(ans)


Measured memory_bytes: 74136
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 510000;
const int MOD =  998244353;
const int INV2 = (MOD+1)/2;


     signed main(){

        int n,h;
       
        cin>>n>>h;
        int a,b,c,d;
        pair<int,int> v[n];
        for(int i=0;i<n;i++){
          cin>>a>>b>>c>>d;
         v[i]=make_pair((c==0 ? a : -c),(d==0 ? -b: d));
        }
       map<int,int>mp,mp2;
       for(int i=0;i<n;i++){
         mp[v[i].first]++;
         mp[v[i].second]++;
       }
       int i0=0;
       for(auto i = mp.begin();i!=mp.end();i++){
         i->second=i0;
         i0++;
       }
       vector<int> p[i0];
       for(int i=0;i<n;i++){
         p[mp[v[i].first]].push_back(v[i].second);
         mp2[v[i].first]++;
         mp2[v[i].second]--;
         p[mp[v[i].second]].push_back(v[i].first);
       }
       bool used[i0]={},t;
       for(int i=0;i<n;i++){
         if(used[mp[v[i].first]])continue;
        t=false;
        queue<int> que;
        que.push(v[i].first);
        while(!que.empty()){
          int k=que.front();
          que.pop();
          if(used[mp[k]])continue;
          used[mp[k]]=true;
          if(mp2[k]*k<0){
            cout<<"NO"<<endl;
            return 0;
          }
          if(mp2[k]*k>0)t=true;
          for(auto&& itr :p[mp[k]]){
            if(!used[mp[itr]]){
            
              que.push(itr);
            }
          }
        }
        if(!t){
          cout<<"NO"<<endl;
          return 0;
        }
       }
       cout<<"YES"<<endl;
       return 0;

        
        return 0;

 




}


        


Measured memory_bytes: 5248
#include <iostream>
using namespace std;
int main(){
	while(1){
		
		int N;
		cin>>N;
		if(N==0)
			break;
	
		int count0=0;
		int count1=0; 
		
	for(int i=0;i<N;i++){
		int k;
		cin>>k;
		if(k==0)
			count0++;
		else if(k==1)
			count1++;
		if(count0+count1==N)
			cout<<"NA"<<endl;
	}
	if(count0+count1!=N)
		cout<<N-count0+1<<endl;
	}
	return 0;
}
	

Measured memory_bytes: 1160
import java.io.IOException
import java.io.InputStream
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val (a, b, k) = sc.nextInts(3)
    println(factors(gcd(a, b)).sorted().reversed()[k - 1])
}

fun gcd(n: Int, m: Int): Int = if (m == 0) n else gcd(m, n % m)

fun factors(n: Int): List<Int> = (1..n).filter { n % it == 0 }

class Scanner(private val `in`: InputStream) {
    private val buffer = ByteArray(1024)
    private var ptr = 0
    private var buflen = 0

    companion object {
        private fun isPrintableChar(b: Byte): Boolean = b in 33..126
        private fun isNumericChar(b: Byte): Boolean = b in 48..57
        private fun digit(b: Byte): Int = b - 48
    }

    fun hasNextByte(): Boolean {
        if (ptr < buflen) return true
        ptr = 0
        try {
            buflen = `in`.read(buffer)
        } catch (e: IOException) {
            e.printStackTrace()
        }
        return 0 < buflen
    }

    private fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1

    private fun skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++
    }

    fun hasNext(): Boolean {
        skipUnprintable()
        return hasNextByte()
    }

    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        return buildString {
            var b = readByte()
            while (isPrintableChar(b)) {
                appendCodePoint(b.toInt())
                b = readByte()
            }
        }
    }

    fun nextInt(): Int {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0
        var b = readByte()
        val minus = b.toChar() == '-'
        if (minus) b = readByte()
        if (!isNumericChar(b)) throw NumberFormatException()
        do {
            n *= 10
            n += digit(b)
            b = readByte()
        } while (isNumericChar(b))
        return if (minus) -n else n
    }

    fun nextInts(n: Int): Array<Int> = Array(n) { nextInt() }

    fun nextIntArray(n: Int): IntArray = IntArray(n) { nextInt() }

    fun nextIntArrays(n: Int, m: Int): Array<IntArray> {
        val arrays = Array(m) { IntArray(n) }
        repeat(n) { i -> repeat(m) { j -> arrays[j][i] = nextInt() } }
        return arrays
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var b = readByte()
        val minus = b.toChar() == '-'
        if (minus) b = readByte()
        if (!isNumericChar(b)) throw NumberFormatException()
        do {
            n *= 10
            n += digit(b)
            b = readByte()
        } while (isNumericChar(b))
        return if (minus) -n else n
    }

    fun nextLongs(n: Int): Array<Long> = Array(n) { nextLong() }

    fun nextLongArray(n: Int): LongArray = LongArray(n) { nextLong() }

    fun nextLongArrays(n: Int, m: Int): Array<LongArray> {
        val arrays = Array(m) { LongArray(n) }
        repeat(n) { i -> repeat(m) { j -> arrays[j][i] = nextLong() } }
        return arrays
    }

}

Measured memory_bytes: 33868
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= int(b); i++)
#define per(i, a, b) for (int i = (a); i >= int(b); i--)
#define fir first
#define sec second
#define tct template<class type>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int maxn = 1e5, mod = 1e9 + 7;
int n, m, u[maxn + 5], v[maxn + 5], d[maxn + 5], fa[maxn + 5];

inline void red(int &x) { x += x >> 31 & mod; }
tct inline void cmax(type &x, type y) { x < y ? x = y : 0; }
tct inline void cmin(type &x, type y) { x > y ? x = y : 0; }

int find(int x) {
	return fa[x] == x ? x : fa[x] = find(fa[x]);
}

int main() {
	scanf("%d %d", &n, &m);
	rep(i, 1, m) {
		scanf("%d %d", &u[i], &v[i]);
		d[u[i]]++, d[v[i]]++;
	}
	rep(i, 1, n) if (d[i] & 1) puts("No"), exit(0);
	rep(i, 1, n) if (d[i] >= 6) puts("Yes"), exit(0);
	int c = 0;
	rep(i, 1, n) c += d[i] == 4;
	if (c != 2) puts(c >= 3 ? "Yes" : "No"), exit(0);
	int x = 0;
	rep(i, 1, n) if (d[i] == 4) { x = i; break; }
	rep(i, 1, n) fa[i] = i;
	rep(i, 1, m) if (u[i] != x && v[i] != x) fa[find(u[i])] = find(v[i]);
	int y = 0;
	rep(i, 1, n) y += find(i) == i;
	puts(y == 3 ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 5196
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, m, u, v, ans = 0, cnt, now;
  scanf("%lld", &n);
  vector<ll> vec[n], num[n];
  for(i = 0; i < n - 1; ++i) {
    scanf("%lld%lld", &u, &v);
    vec[--u].push_back(--v);
    vec[v].push_back(u);
    num[u].push_back(i);
    num[v].push_back(i);
  }
  scanf("%lld", &m);
  vector<ll> a[m];
  ll b[n], c[n];
  for(i = 0; i < m; ++i) {
    scanf("%lld%lld", &u, &v);
    queue<ll> q;
    now = --u, --v;
    for(j = 0; j < n; ++j) b[j] = -1;
    b[now] = now;
    q.push(now);
    while(q.size()) {
      now = q.front(), q.pop();
      for(j = 0; j < vec[now].size(); ++j) if(b[vec[now][j]] == -1) b[vec[now][j]] = now, c[vec[now][j]] = num[now][j], q.push(vec[now][j]);
    }
    now = v;
    while(b[now] != now) a[i].push_back(c[now]), now = b[now];
  }
  bool flg[n];
  for(i = 0; i < (1 << m); ++i) {
    cnt = 0, now = 0;
    for(j = 0; j < n; ++j) flg[j] = true;
    for(j = 0; j < m; ++j) if((i >> j) & 1) {
      ++cnt;
      for(k = 0; k < a[j].size(); ++k) flg[a[j][k]] = false;
    }
    for(j = 0; j < n - 1; ++j) if(flg[j]) now++;
    ans += (1ll << now) * (cnt & 1 ? -1 : 1);
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line = reader.readLine();
        for (int i = 0; i < line.length(); i++) {
            System.out.print("x");
        }
        System.out.println();
    }
}

Measured memory_bytes: 23252
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int ans = 1, X;

  cin >> X;

  for(int i=2;i<=1000;i++){
    for(int q = i*i; q<=X; q*=i){
      ans = max(ans, q);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cstring>
#include<string>
#include<vector>
//#include<unordered_set>
#include<unordered_map>
#include<cmath>
using namespace std;

#define ull unsigned long long
#define ll long long
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1

typedef pair<int, int>pii;
typedef pair<ll, ll>pll;
typedef pair<double, double>pdd;

const double eps = 1e-6;
const int MAXN = 100005;
const int MAXM = 5005;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
const double FINF = 1e18;
int ans[MAXN],a[MAXN], sum[MAXN];
pii tmp1[55], tmp2[55];
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; ++i)scanf("%d%d", &tmp1[i].first, &tmp1[i].second);
	for (int i = 0; i < m; ++i)scanf("%d%d", &tmp2[i].first, &tmp2[i].second);
	ll pos, minn = LINF;
	for (int i = 0; i < n; ++i)
	{
		minn = INF;
		for (int j = 0; j < m; ++j)
		{
			if (abs(tmp1[i].first - tmp2[j].first)+1LL+
				+ abs(tmp1[i].second - tmp2[j].second) < minn)
			{
				minn = abs(tmp1[i].first - tmp2[j].first) + 1LL+
					+ abs(tmp1[i].second - tmp2[j].second);
				pos = j + 1;
			}
		}
		cout << pos << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
//***********//
int main() {
	cin >> N >> K;
	vl A(N);
	for (i = 0; i < N; i++) {
		cin >> A[i];
		A[i]--;
	}
	vl T;
	ll now = 0;
	ll next = 0;
	vl flag(N);
	for (i = 0; i < N; i++) {
		flag[i] = -1;
	}
	flag[0] = 0;
	vl P,Q;
	while (true) {
		next = A[now];
		if (flag[next]!=-1) {
			for (i = 0; i < flag[next]; i++) {
				P.push_back(T[i]);
			}
			for (i = flag[next]; i < T.size(); i++) {
				Q.push_back(T[i]);
			}
			Q.push_back(next);
			break;
		}
		//debug(now, next);
		T.push_back(next);
		flag[next] = T.size();
		if (next == 0) break;
		now = next;
	}
	ll p = P.size();
	ll q = Q.size();
	//debug(P, Q);
	if (K <= p) {
		cout << P[K - 1]+1 << endl;
	}
	else {
		K -= p;
		cout << Q[(K - 1) % q] + 1 << endl;
	}
}

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

vector<ll> freq;
vector<ll> balls;

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	ll n;
	cin>>n;
	freq.resize(n,0);
	balls.resize(n,0);
	for (ll i = 0; i<n; i++){
		cin>>balls[i];
		balls[i]--;
		freq[balls[i]]++;
	}
	ll total = 0;
	for (ll i = 0; i<n; i++){
		total+=freq[i]*(freq[i]-1)/2;
	}
	for (ll i = 0; i<n; i++){
		cout<<(total-(freq[balls[i]]*(freq[balls[i]]-1)/2)+((freq[balls[i]]-1)*(freq[balls[i]]-2)/2))<<endl;
	}
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int M;
    const int shokiNokorijikan = 48;   //12月30日0時から次の年への残り時間
    cin >> M;
    if(M < 1 || M > 23){
        return 0;
    }
    cout << shokiNokorijikan - M << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;

public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static int mod = (int) (1e9+7);
	static long cf = 998244353;
    static final int MAX = (int) 1e6;
    public static List<Pair>[] edges;
    public static int[][] parent;
    public static int col = 20;
    public static long[] Bit;
    public static long[] fac,inv;
    public  static int[] prime; 
    public static long[] dp;
	public static FastReader sc = new FastReader();
	public static void main(String[] args) {
	//	Scanner sc = new Scanner(System.in);
 
		 int n = sc.nextInt();
	       Pair[] p = new Pair[n];
	       for(int i=0;i<n;++i)
	    	   p[i] = new Pair(sc.nextInt(),i+1);
	       
	       Arrays.sort(p,new Comparator<Pair>() {

			@Override
			public int compare(Pair o1, Pair o2) {
				// TODO Auto-generated method stub
				return o1.x-o2.x;
			}
	    	   
	       });
	 for(Pair x : p) out.print(x.y+" ");
	       
	    
	 
		 
		out.close();
	}

	
	static class Pair{
		int x;
		int y;
		Pair(int x,int y){
			this.x = x;
			this.y = y;
		}
	}
	
}

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

using namespace std;

int main() {
  string a;
  cin >> a;
  int counter = 700, len1;
  len1 = a.size();
  if (len1 == 3){} ;
    if (a[0] == 'o') counter += 100 ;
    if (a[1] == 'o') counter += 100 ;
    if (a[2] == 'o') counter += 100 ;
  cout << counter << endl;
}




Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
int main()
{
  int x;
  cin>>x;
  if(x>=400&&x<=599)
    cout<<"8";
  if(x>=600&&x<=799)
    cout<<"7";
 if(x>=800&&x<=999)
    cout<<"6";              
 if(x>=1000&&x<=1199)
    cout<<"5"; 
    if(x>=1200&&x<=1399)
    cout<<"4";
       if(x>=1400&&x<=1599)
    cout<<"3";
          if(x>=1600&&x<=1799)
    cout<<"2";
             if(x>=1800&&x<=1999)
    cout<<"1";
  return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c,d,lcm;
    cin >> a >> b >> c >> d;
    int C=c ,D=d;
  
  while(D%C!=0){
   if(C<D) swap(C,D); 
    C%=D;
  }
  lcm=c*d/C;

    long long b_ans=b-b/c-b/d+b/lcm;
    long long a_ans=(a-1)-(a-1)/c-(a-1)/d+(a-1)/lcm;
    cout << b_ans-a_ans;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    private static final int MOD = (int) Math.pow(10, 9);

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        Set<Integer> set = new HashSet<>();
        int n = sc.nextInt();
        int[] nums = new int[n];

        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }

        for (int bit = 0; bit < (1 << n); bit++) {
            int sum = 0;
            for (int i = 0; i < n; i++) {
                if ((bit & (1 << i)) != 0) {
                    sum += nums[i];
                }
            }
            set.add(sum);
        }

        int q = sc.nextInt();

        for (int i = 0; i < q; i++) {
            int num = sc.nextInt();
            if (set.contains(num)) {
                System.out.println("yes");
            } else {
                System.out.println("no");
            }
        }

        System.exit(0);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}



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

#define REP(i,n) for(ll i=0; i < (n); ++i)
#define REPR(i,n) for(ll i=(n); i >= 0; --i)
#define FOR(i, m, n) for(ll i = (m); i < (n); ++i)

#define INF 1e9


int main(){
  int N;
  cin >> N;
  vector<int> B(N-1);
  REP(i, N-1){
    cin >> B[i];
  }
  int sum = B[0] + B[N-2];
  FOR(i, 1, N-1){
    sum += min(B[i-1], B[i]);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cassert>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));

int K;
int sum;
int ans = -INF;

void dfs(int num,int ceiling) {
	int keta = log10(num) + 1;
	if (keta == ceiling) {
		sum++;
		if (sum == K) {
			ans = num;
			return;
		}
	}
	else {
		int bottom = num % 10;
		for (int i = bottom - 1; i <= bottom + 1; i++) {
			if (i < 0 || i > 9)continue;
			int n = num * 10 + i;
			dfs(n, ceiling);
		}
	}
}

signed main() {
	cin >> K;
	int c = 1;
	while (1) {
		for (int i = 1; i <= 9; i++) {
			dfs(i, c);
		}
		if (ans != -INF) {
			cout << ans;
			return 0;
		}
		c++;
	}
}

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

int H, W, C[50][50];

void dfs(int a, int b) {
    C[a][b] = 0;
    for (int i = -1; i <= 1; ++i) {
        for (int j = -1; j <= 1; ++j) {
            int na = a + i, nb = b + j;
            if (na >= 0 && na < H && nb >= 0 && nb < W && C[na][nb] == 1) dfs(na, nb);
        }
    }
    return;
}

int main() {
    while (true) {
        cin >> W >> H;
        if (W == 0 && H == 0) break;
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) cin >> C[i][j];
        }

        int ans = 0;
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                if (C[i][j]) {
                    dfs(i, j);
                    ++ans;
                }
            }
        }

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


Measured memory_bytes: 3284
def main():
  N,A,B=map(int, input().split())
  if A==0:
    print(0)
    return

  if N%(A+B)==0:
    print(A*N//(A+B))
  else:
    if N%(A+B)>=A:
      print(A*(N//(A+B))+A)
    else:
      print(A*(N//(A+B))+N%(A+B))
main()

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

int main(void)

{
    int n;
    cin >> n;
    if (1000 - n % 1000 != 1000)
    {
        cout << 1000 - n % 1000 << endl;
    }
    else
    {
        cout << "0" << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <queue>
using namespace std;
int main(){

  int n,q;
  cin>>n>>q;
  queue <int> a[n];

  for(int i=0;i<q;i++){
    int n,t;
    cin>>n>>t;
    if(!n){
      int x;
      cin>>x;
      a[t].push(x);
    }
    else if(n==1 && !a[t].empty()) cout<<a[t].front()<<endl;
    else if(!a[t].empty()) a[t].pop();
  }

  return 0;

}



Measured memory_bytes: 4360
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    
    #0から他の頂点へ
    def BellmanFord(N, M, edges):
        #N頂点，M辺，edgesのリスト
        inf=10**20
        d = [inf] * N
        d[0] = 0

        for i in range(N-1):
            for (u, v, c) in edges:
                if to[u] and to[v] and rto[u] and rto[v]:
                    if d[u] + c < d[v]:
                        d[v] = d[u] + c

        
        #何処かの最短距離がまだ更新されるか確認
        for (u, v, c) in edges:
            if to[u] and to[v] and rto[u] and rto[v]:
                if d[u] + c < d[v]:
                    return None#負の閉路
                
        return d[N-1]
    
    N,M,P=MI()
    edges=[]
    adj1=[[]for _ in range(N)]
    adj2=[[]for _ in range(N)]
    for _ in range(M):
        a,b,c=MI()
        a-=1
        b-=1
        c-=P
        edges.append([a,b,-1*c])
        adj1[a].append(b)
        adj2[b].append(a)
        
    ################
    #BFSで使う点を選択．
    import queue
    q=queue.Queue()
    
    to=[0]*N
    to[0]=1
    rto=[0]*N
    rto[-1]=1
    
    q.put(0)
    while not q.empty():
        v=q.get()
        for nv in adj1[v]:
            if to[nv]==0:
                to[nv]=1
                q.put(nv)
                
    q.put(N-1)
    while not q.empty():
        v=q.get()
        for nv in adj2[v]:
            if rto[nv]==0:
                rto[nv]=1
                q.put(nv)
                
    can=[0]*N
    for i in range(N):
        can[i]=to[i] and rto[i]
        
    newE=[]
    for (a,b,c) in edges:
        if can[a] and can[b]:
            newE.append((a,b,c))
        
    
    ################
    
    ans=BellmanFord(N,M,newE)
    
    if ans==None:
        print(-1)
    elif ans>=10**10:
        print(-1)
    else:
        print(max(-1*ans,0))
    
        

main()


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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = fact[1] = 1;
    for(int i=2; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
}

void create_seq_inv_mod(int num){
    seq_inv[0] = seq_inv[1] = 1;
    for(int i=2; i<=num; i++) seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
}

void create_fact_inv_mod(int num){
    fact_inv[0] = fact_inv[1] = 1;
    for(int i=2; i<=num; i++) fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N+1);
    for(int i=0; i<N+1; i++) cin >> A[i];
    vector<int64_t> ans(N+2);

    create_mod_tables(N+1);
    for(int i=1; i<=N+1; i++) ans[i] = comb_mod(N+1, i);
    
    int side = 0;
    vector<int> pos(N+1, -1);
    for(int i=0; i<N+1; i++){
        if(pos[A[i]] >= 0){
            side = pos[A[i]] + N-i;
            break;
        }
        pos[A[i]] = i;
    }
    for(int i=0; i<=side; i++) add(ans[i+1], MOD - comb_mod(side, i));
    for(int i=1; i<=N+1; i++) cout << ans[i] << endl;
}


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

using namespace std;

int main()
{
	int N;
	int ans = 0;
	cin >> N;

	vector<int> p(N);
	vector<char> isSame(N);

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

		isSame[i] = (p[i] == i);
	}

	for (int i = 0; i < N; i++)
	{
		if (isSame[i])
		{
			ans++;
			i++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 768
import java.util.ArrayDeque;
import java.util.BitSet;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[] DY = { 1, 0, -1, 0 };
	static int[] DX = { 0, -1, 0, 1 };
	static int W, H;
	static char[][] mapL, mapR;
	static BitSet visited = new BitSet(1 << 24);

	public static void main(String[] args) {
		while (true) {
			W = sc.nextInt();
			H = sc.nextInt();
			if (W == 0) break;
			mapL = new char[H][];
			mapR = new char[H][];
			for (int i = 0; i < H; ++i) {
				mapL[i] = sc.next().toCharArray();
				mapR[i] = sc.next().toCharArray();
			}
			System.out.println(solve() ? "Yes" : "No");
		}
	}

	static boolean solve() {
		visited.clear();
		int pos = 0;
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (mapL[i][j] == 'L') {
					pos |= (i << 18) | (j << 12);
				}
				if (mapR[i][j] == 'R') {
					pos |= (i << 6) | j;
				}
			}
		}
		visited.set(pos);
		Queue<Integer> q = new ArrayDeque<Integer>();
		q.add(pos);
		while (!q.isEmpty()) {
			int p = q.poll();
			int y1 = p >> 18;
			int x1 = (p >> 12) & 0x3F;
			int y2 = (p >> 6) & 0x3F;
			int x2 = p & 0x3F;
			for (int i = 0; i < 4; ++i) {
				int ny1 = y1 + DY[i];
				int nx1 = x1 + DX[i];
				int ny2 = y2 + DY[i];
				int nx2 = x2 - DX[i];
				if (ny1 < 0 || H <= ny1 || nx1 < 0 || W <= nx1 || mapL[ny1][nx1] == '#') {
					ny1 = y1;
					nx1 = x1;
				}
				if (ny2 < 0 || H <= ny2 || nx2 < 0 || W <= nx2 || mapR[ny2][nx2] == '#') {
					ny2 = y2;
					nx2 = x2;
				}
				boolean goalL = mapL[ny1][nx1] == '%';
				boolean goalR = mapR[ny2][nx2] == '%';
				if (goalL && goalR) {
					return true;
				}
				if (!goalL && !goalR) {
					int np = (ny1 << 18) | (nx1 << 12) | (ny2 << 6) | nx2;
					if (!visited.get(np)) {
						visited.set(np);
						q.add(np);
					}
				}
			}
		}
		return false;
	}

}

Measured memory_bytes: 94308
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long LL;

const int maxn=1005;

int h,w;
char s[maxn][maxn];

int d[maxn*maxn][2],dis[maxn][maxn],fx[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
int main()
{
	scanf("%d %d",&h,&w);
	fo(i,1,h) scanf("%s",s[i]+1);
	
	int zbj=0;
	fo(i,1,h)
		fo(j,1,w) if (s[i][j]=='#') d[++zbj][0]=i, d[zbj][1]=j, dis[i][j]=1;
	for(int zbi=1; zbi<=zbj; zbi++)
	{
		fo(k,0,3)
		{
			int xx=d[zbi][0]+fx[k][0], yy=d[zbi][1]+fx[k][1];
			if (xx>0 && xx<=h && yy>0 && yy<=w && !dis[xx][yy])
			{
				d[++zbj][0]=xx, d[zbj][1]=yy;
				dis[xx][yy]=dis[d[zbi][0]][d[zbi][1]]+1;
			}
		}
	}
	
	int ans=0;
	fo(i,1,h)
		fo(j,1,w) ans=max(ans,dis[i][j]-1);
	printf("%d\n",ans);
}

Measured memory_bytes: 13056
#include<bits/stdc++.h>
#define ll long long int
#define INF 0x3f3f3f3f
#define pb push_back
#define se second
#define fi first
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plll;
const ll N=1e5+5;
ll n;
vector<plll> ed;
ll par[N];

ll root(ll x){
    while(par[x]!=x){
        par[x]=par[par[x]];
        x=par[x];
    }
    return x;
}

void merge(ll x,ll y){
    ll p = root(x);
    ll q = root(y);
    par[p] = par[q];
}

ll kruskal(){
    ll u,v,cost=0,mincost=0;
    for(int i=0;i<N;i++) par[i]=i;
    for(int i=0;i<ed.size();i++){
        u=ed[i].se.fi;
        v=ed[i].se.se;
        cost=ed[i].fi;
        if(root(u)!=root(v)){
            mincost+=cost;
            merge(u,v);
        }
    }
    return mincost;
}

struct point{
    ll x,y,id;
};
point px[N],py[N];

bool compx(point a,point b){
    return (a.x < b.x);
}

bool compy(point a,point b){
    return (a.y < b.y);
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>px[i].x>>px[i].y;
        px[i].id=i;
        py[i]=px[i];
    }
    sort(px+1,px+n+1,compx);
    sort(py+1,py+n+1,compy);
    for(int i=1;i<n;i++){
        int u=px[i].id;
        int v=px[i+1].id;
        ll cost=px[i+1].x-px[i].x;
        ed.pb(plll(cost,pll(u,v)));
    }
    for(int i=1;i<n;i++){
        int u=py[i].id;
        int v=py[i+1].id;
        ll cost=py[i+1].y-py[i].y;
        ed.pb(plll(cost,pll(u,v)));
    }
    sort(ed.begin(),ed.end());
    cout<<kruskal();
	return 0;
}

Measured memory_bytes: 13296
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,k,h[MAXN],dp[MAXN];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&h[i]);
    dp[1]=0;dp[2]=abs(h[2]-h[1]);
    for(int i=3;i<=n;i++)
    {
        dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
    }
    printf("%d\n",dp[n]);
    return 0;
}



Measured memory_bytes: 1024
void main()
{
    long n = rdElem;
    string[] s = n.rdCol!string;

    s.sort!"a < b";

    s.uniq.array.length.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 13948
<?php
  	fscanf(STDIN, '%d %d %d', $end, $min, $max);

	for($i = 1; $i <= $end; $i++){
      	$str = (String)$i;
      	$digits = str_split($str);
      	$digit_sum = array_sum($digits);
      	if($digit_sum >= $min && $digit_sum <= $max){
          	$result += $i;
        }
    }
	echo $result;

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

using namespace std;

int main()
{
    string s;cin>>s;
    int i=0,c=0,m=0,x=0;
    for(i=2;i<(s.size()-1);i++){
        if(s[i]=='C')
            c++;}
    for(m=0;m<s.size();m++){
        if(islower(s[m]))
            x++;}
    if(s[0]=='A'&&x==s.size()-2&&c==1)
        cout<<"AC";
    else
        cout<<"WA";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define ret return
using namespace std;
bool p[102]={false};
int main() {
	int x,n,num;
	cin>>x>>n;
	for(int i=0;i<n;i++){
		cin>>num;
		p[num]=true;
	}
	int diff=1e9;
	for(int i=0;i<=100;i++)
		if(!p[i])
			diff=min(diff,abs(x-i));
	int sol=1e9;
	for(int i=0;i<=100;i++)
		if(abs(x-i)==diff&&!p[i])
			sol=min(sol, i);

	if(abs(101-x)<diff){
		sol=101;
		diff=abs(101-x);
	}
	if(abs(x-(-1))<diff)
		sol=-1;
	
	cout<<sol<<endl;
}




Measured memory_bytes: 3608
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, M = map(int, input().split())
A = list(map(int, input().split()))

recipe = [2, 5, 5, 4, 5, 6, 3, 7, 6]
available =[]
dp = [-1] * (N + 1)

for i in range(M):
	available.append((A[i], recipe[A[i] - 1]))
	
available.sort(reverse = True)
dp[0] = 0

for i in range(1, N + 1):
	for j in range(M):
		k = i - available[j][1]
		if k >= 0 and dp[k] >= 0:
			if dp[k] + 1 > dp[i]:
				dp[i] = dp[k] + 1

cost = 0
ans = ''

for i in range(dp[N]):
	for j in range(M):
		if N - cost - available[j][1] >= 0 and dp[N - cost - available[j][1]] == dp[N - cost] - 1:
			cost += available[j][1]
			ans += str(available[j][0])
			break
	
print(ans)

Measured memory_bytes: 42092
from sys import stdin
import heapq
def main():
    #入力
    readline=stdin.readline
    n,k=map(int,readline().split())
    v=list(map(int,readline().split()))
    v_rev=list(reversed(v))

    m=min(n,k)
    ans=0
    for l in range(m+1):
        for r in range(m+1):
            if l+r>m:
                break

            minus=[]
            s=0
            for i in range(l):
                x=v[i]
                if x<0:
                    minus.append(x)
                s+=x

            for i in range(r):
                x=v_rev[i]
                if x<0:
                    minus.append(x)
                s+=x

            if l+r<k:
                minus.sort()
                for i in range(k-l-r):
                    if i>=len(minus):
                        break
                    s-=minus[i]

            ans=max(ans,s)

    print(ans)

if __name__=="__main__":
    main()

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

using namespace std;

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  int n;
  cin>>n;
  
  int arr[n];
  for(int i=0;i<n;i++)
  cin>>arr[i];
  
  sort(arr,arr+n);
  multiset<int>m;
  
  for(int i=0;i<n;i++)
  {
    for(int j=1;j*arr[i]<=arr[n-1];j++)
    {
      if(m.count(arr[i]*j)<2)
        m.insert(arr[i]*j);
    }
  }
  
  int ans=0;
  for(int i=0;i<n;i++)
  {
    if(m.count(arr[i])==1)
      ans++;
  }
    
  cout<<ans;
  
  return 0;
}

Measured memory_bytes: 94008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int n, p;
    string s;
    cin >> n >> p >> s;
    if (10 % p == 0) {
        ll ans = 0;
        for (int i = 0; i < n; i++) {
            if ((s[i] - '0') % p == 0) ans += i + 1;
        }
        cout << ans << endl;
        return 0;
    }
    ll t = 1, num = 0;
    vector<ll> nums(p, 0);
    nums[0] = 1;
    for (int i = n - 1; i >= 0; i--, t *= 10) {
        t %= p;
        num = (num + (s[i] - '0') * t) % p;
        nums[num]++;
    }
    ll ans = 0;
    for (auto x : nums) {
        ans += x * (x - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
a,b = map(int, input().split())
res = ''
if 0<a:
    res = 'Positive'
elif a*b < 0:
    res = 'Zero'
else:
    if (b-a)%2==0:
        res = 'Negative'
    else:
        res = 'Positive'
print(res)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
    int a, b, max;
    scanf("%d", &a);
    scanf("%d", &b);
    max = a + b;
    if(max < (a - b)){
        max = a - b;
    }
    if(max < a * b){
        max = a * b;
    }
    printf("%d\n", max);
    return 0;
}

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

long long N;
long long A[200005];

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

	if(false) {
		long long odd = 0;
		long long even = 0;
		for(long long i = 0; i < N; i++) {
			if(i%2 == 0) {
				even+=A[i];
			} else {
				odd+=A[i];
			}
		}
		cout << max(even, odd) << endl;
		return 1;
	} else {
		//  get count, max        1はskipしないといけない, 0はskipしなくていい
		map<long long, long long> dp[2];
		map<long long, long long> dpnext[2];


		dp[0][0] = 0;
		for(long long i = 0; i < N; i++) {
			long long mini = i/2 - 10;
			long long maxi = i/2 + 10;
			//cout << "i = " << i << endl;
			//cout << "dp[0]" << endl;
			//for(auto item: dp[0]) {
			//	cout << item.first << ", " << item.second << endl;
			//}
			//cout << "dp[1]" << endl;
			//for(auto item: dp[1]) {
			//	cout << item.first << ", " << item.second << endl;
			//}

			//取る
			for(auto item: dp[0]) {
				if(item.first > mini && item.first < maxi) {
					if(dpnext[1].count(item.first + 1) > 0) {
						dpnext[1][item.first + 1] = max(dpnext[1][item.first + 1], item.second + A[i]);
					} else {
						dpnext[1][item.first + 1] = item.second + A[i];
					}
				}
			}
			//撮らない
			for(auto item: dp[0]) {
				if(item.first > mini && item.first < maxi) {
					if(dpnext[0].count(item.first) > 0) {
						dpnext[0][item.first] = max(dpnext[0][item.first], item.second);
					} else {
						dpnext[0][item.first] = item.second;
					}
				}
			}
			for(auto item: dp[1]) {
				if(item.first > mini && item.first < maxi) {
					if(dpnext[0].count(item.first) > 0) {
						dpnext[0][item.first] = max(dpnext[0][item.first], item.second);
					} else {
						dpnext[0][item.first] = item.second;
					}
				}
			}
			swap(dp, dpnext);
			dpnext[0].clear();
			dpnext[1].clear();
		}


		long long ans = LONG_MIN;
		//cout << "i = " << N << endl;
		//cout << "dp[0]" << endl;
		for(auto item: dp[0]) {
			//cout << item.first << ", " << item.second << endl;
			if(item.first == N/2) {
				ans = max(ans, item.second);
			}
		}
		//cout << "dp[1]" << endl;
		for(auto item: dp[1]) {
			//cout << item.first << ", " << item.second << endl;
			if(item.first == N/2) {
				ans = max(ans, item.second);
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 5168
N = int(input())
A = [int(_) for _ in input().split()]
colors = [0] * 9
for a in A:
    c = a // 400
    if c < 8:
        colors[c] = 1
    else:
        colors[8] += 1
print(max(sum(colors[:8]), 1), sum(colors))


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

int main(){
    int x,y;
    cin >> x >> y;
    for(int i = 0; i <= x;i++){
        int j = x - i;
        if((2 * i + 4 * j) == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3632