akhauriyash/Code-Regression huggingface dataset:
from sys import stdin

if __name__ == '__main__':
    for line in stdin:
        if int(line) == 0:
            break

        isEmpty = True
        record = {}
        for _ in range(int(line)):
            employee = input().split(' ')
            total = int(employee[1]) * int(employee[2])

            if total >= 1000000:
                print(employee[0])
                isEmpty = False
            else:
                e_t = record.get(employee[0])

                if e_t:
                    e_t = record.get(employee[0]) + total
                    if e_t >= 1000000:
                        print(employee[0])
                        isEmpty = False
                    else:
                        record[employee[0]] = e_t

                else:
                    record[employee[0]] = total

        record.clear()

        if isEmpty:
            print('NA')

Measured memory_bytes: 7552
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX_P = 300000;

int main() {
  int X, Y; cin >> X >> Y;
  int ans = 0;
  if(X == 1 && Y == 1) ans += 400000;
  ans += max(MAX_P - 100000*(X-1), 0);
  ans += max(MAX_P - 100000*(Y-1), 0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define U [100005]={}
typedef long long L;using namespace std;map<L,L> path U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p,r;char s U;
L D(L a){Z[a]=1;for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){L d=I->first;if(d-P[a]){P[d]=a;E[d]=E[a]+1;C[d]=I->second;D(d);Z[a]+=Z[d];!H[a]|Z[H[a]]<Z[d]?H[a]=d:0;}}}
L G(L a){r=A[a]+A[P[a]]+C[a];return r%k?r:0;}
L M(L i){return i?B[i]+M(i-(i&-i)):0;}
//L M(L i){for(r=0;i;r+=B[i],i-=i&-i);return r;}
L S(L i,L x){for(x=G(x)-M(i+1)+M(i++);i<100005;B[i]+=x,i+=i&-i);}main(){for(cin>>n>>k;p<n-1;p++)cin>>a>>b>>c,path[a][b]=path[b][a]=c;D(0);for(c=p=0;p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;a=H[a])O[a]=c++,X[a]=p,S(O[a],H[a]);for(cin>>a;cin>>s>>a>>b;)if(*s&2){for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}else A[a]+=b,S(O[a],H[a]),a?S(O[a]-1,a):0;}

Measured memory_bytes: 31924
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<limits>
#include<tuple>
#include<utility>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n)  for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define INF 1e18
using ll = long long;
using namespace std;

int main(){
  int n,m;  cin >> n >> m;
  vi a(m);
  rep0(i,n){
    ll k;  cin >> k;
    rep0(j,k){
      ll a1;  cin >> a1;  a1--;
      a[a1]++;
    }
  }
  ll ans = 0;
  rep0(i,m){
    if(a[i] == n){
      ans++;
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int h = saori.saori_hayami();
		int w = saori.saori_hayami();
		if(h > 9 || w > 9){
			System.out.println(-1);
		} else{
			System.out.println(h*w);
		}
		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

int main() {
  int n; cin >> n;
  vector<vector<int>> a(n, vector<int>(n));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) cin >> a[i][j];
  }
  vector<vector<ll>> s(n + 1, vector<ll>(n + 1, 0));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) s[i + 1][j + 1] = s[i + 1][j] + a[i][j];
  }
  for (int j = 0; j < n; ++j) {
    for (int i = 0; i < n; ++i) s[i + 1][j + 1] += s[i][j + 1];
  }
  ll mx = -10000;
  for (int sx = 1; sx <= n; ++sx) {
    for (int sy = 1; sy <= n; ++sy) {
      for (int tx = sx; tx <= n; ++tx) {
        for (int ty = sy; ty <= n; ++ty) {
          ll sum = s[tx][ty] - s[sx - 1][ty] - s[tx][sy - 1] + s[sx - 1][sy - 1];
          mx = max(mx, sum);
        }
      }
    }
  }
  cout << mx << endl;
  return 0;
}



Measured memory_bytes: 3260
import java.util.Scanner;

public class Main{

public static void main(String[] args){

	Scanner sc = new Scanner(System.in);

	while(true){

		int a = sc.nextInt();
		String op = sc.next();
		int c = sc.nextInt();

		if (op.equals("?"))break;

		int ans = 0;

		switch(op){
		case "+":
			ans = a + c;
			break;
		case "-":
			ans = a - c;
			break;
		case "*":
			ans = a * c;
			break;
		case "/":
			ans = a / c;
			break;
		}

	System.out.println(ans);

	}
    }
}


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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    for(int i = 0; i < ty-sy; i++) {
        cout << "U";
    }
    for(int i = 0; i < tx-sx; i++) {
        cout << "R";
    }

    for(int i = 0; i < ty-sy; i++) {
        cout << "D";
    }
    for(int i = 0; i < tx-sx; i++) {
        cout << "L";
    }

    cout << "L";
    for(int i = 0; i < ty-sy+1; i++) {
        cout << "U";
    }
    for(int i = 0; i < tx-sx+1; i++) {
        cout << "R";
    }
    cout << "D";

    cout << "R";
    for(int i = 0; i < ty-sy+1; i++) {
        cout << "D";
    }
    for(int i = 0; i < tx-sx+1; i++) {
        cout << "L";
    }
    cout << "U" << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
string a,b;
cin>>a>>b;
if(a.size()>b.size()){
cout<<"GREATER"<<endl;
}
if(a.size()<b.size()){
cout<<"LESS"<<endl;
}
if(a.size()==b.size()){
for(int i=0;i<a.size();i++){
if(a[i]>b[i]){
cout<<"GREATER"<<endl;
break;
}
if(a[i]<b[i]){
cout<<"LESS"<<endl;
break;
}
if(a[a.size()]==b[b.size()]){
cout<<"EQUAL"<<endl;
break;
}
}
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main(){
    string s;
    cin>>s;
    for (int i = 0; i < s.size(); i++)
    {
        if(i%2==0){
            if(s[i]=='R' || s[i]=='U' ||s[i]=='D') continue;
            else {
                cout<<"No"<<endl;
                return 0;
            }
        }
         if(i%2==1){
            if(s[i]=='L' || s[i]=='U' ||s[i]=='D') continue;
            else {
                cout<<"No"<<endl;
                return 0;
            }
        }

    }
    cout<<"Yes"<<endl;
   
    return 0;
}

Measured memory_bytes: 256
DEBUG = False

N = int(input())
CSF = []
for i in range(N-1):
    csf = list(map(int, input().split()))
    CSF.append(csf)

if DEBUG:
    print("CSF: {}".format(CSF))

for i in range(N-1):
    ans = 0
    for j in range(i, N-1):
        if DEBUG:
            print("i: {}, j: {}, ans: {}".format(i, j, ans))
        c, s, f = CSF[j]
        if ans < s:
            ans = s
        elif ans  % f != 0:
            ans += f - ans % f
        else:
            pass
        ans += c
    if DEBUG:
        print("i: {}, j:{}, ans:{}".format(i, j, ans))
    print(ans)
print(0)


Measured memory_bytes: 3188
/* To Kaise Hain Aaplog*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) (x).begin(), (x).end()

void shuru_krte_hai_bina_kisi_bakchodi_ke()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
const ll m = 998244353;

const ll s = 1e6 + 2;
ll a[s];

int main()
{
   // shuru_krte_hai_bina_kisi_bakchodi_ke();

    /* long long yaad se daal de har jagah*/
    #define int long long

    int a,b;
    cin>>a>>b;
    cout<<a*b;
    return 0;
}

Measured memory_bytes: 3588
X = int(input())
while True:
  L = []
  for i in range(1, int(X ** 0.5) + 1):
    if X % i == 0:
      L.append(i)
      if i != X // i:
        L.append(X // i)
  if L == [1, X]:
    print(X)
    exit()
  else:
    X += 1

Measured memory_bytes: 3188
n,m = map(int,input().split())
H = list(map(int,input().split()))
a = [list(map(int,input().split())) for _ in range(m)]
flag = [0]*n
for i in range(m):
  if H[a[i][0]-1] > H[a[i][1]-1]:
    flag[a[i][1]-1] = 2
  elif H[a[i][0]-1] == H[a[i][1]-1]:
    flag[a[i][0]-1] = 2
    flag[a[i][1]-1] = 2
  else:
    flag[a[i][0]-1] = 2
cnt = 0
for j in range(n):
  if flag[j] == 0:
    cnt += 1
print(cnt)

Measured memory_bytes: 31948
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest-
#  Atcoder_Grand_Contest030-A
#  TODO https://atcoder.jp/contests/agc030/tasks/agc030_a

def  eatCountCookies(mazuiNoPoison,umaiNoPoison,umaiPoison):
	poisonLevel=umaiNoPoison-umaiPoison
	fukkatuLevel = abs(poisonLevel)-mazuiNoPoison
	if 1 < fukkatuLevel:
		resultPoison = umaiPoison-(fukkatuLevel-1)
		umaiCookie = umaiNoPoison+resultPoison
	else:
		umaiCookie = umaiNoPoison+umaiPoison
	answer = umaiCookie
	return answer


if __name__ == '__main__':
	A,B,C = map(int,input().strip().split(' '))
	solution=eatCountCookies(A,B,C)
	print("{}".format(solution))

Measured memory_bytes: 3060
import java.util.*;

class Main{
  public static void main(String args[]){
  	Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    class Inner{
      int inner(int x,int y){
        if(y == 0){
          return x;
        }else{
          return inner(y,x%y);
        }
      }
    }
    Inner in = new Inner();
    System.out.println(in.inner(x,y));
  }
}



Measured memory_bytes: 26168
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      int[] p = new int[n+1];
      for(int i = 1; i <= n; i++)
        p[i] = sc.nextInt();

      int[] root = new int[n + 1];
      for(int i = 1; i <= n; i++)
        root[i] = i;

      int[] size = new int[n+1];

      while(m-- > 0) {
        int u = sc.nextInt();
        int v = sc.nextInt();
        union(root, size, u, v);
      }
      // path compression one more time
      for(int i = 1; i <= n; i++)
        find(root, i);
        
      int cnt = 0;
      for(int i = 1; i <= n; i++) {
        if(p[i] == i || root[p[i]] == root[i]) {
          cnt++;
        }
      }

      System.out.println(cnt);
  }
 
  private static void union(int[] root, int[] size, int u, int v) {
    int rootU = find(root, u);
    int rootV = find(root, v);
    if(rootU == rootV) return;
    if(size[rootU] > size[rootV]) {
      root[rootV] = rootU;
      size[rootU] += size[rootV];
    } else {
      root[rootU] = rootV;
      size[rootV] += size[rootU];
    }
  }

  private static int find(int[] root, int node) {
    if(root[node] != node) {
      root[node] = find(root, root[node]);
    }
    return root[node];
  }
}

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


int main()
{
	long long int a, b;
	while (cin >> a >> b){
		long long int gcm = 1;
		bool flag = true;
		while (flag){
			for (int i = 2;; i++){
				if (a % i == 0 && b % i == 0){
					gcm = gcm * i;
					a = a / i;
					b = b / i;
					break;
				}
				if (i > min(a, b)){
					flag = false;
					break;
				}
			}
		}
		long long int lcm = gcm * a * b;
		cout << gcm << " " << lcm << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
a = input().split()
H1 = int(a[0])
M1 = int(a[1])
H2 = int(a[2])
M2 = int(a[3])
K = int(a[4])
time = (H2 * 60 + M2) - K
okiru = 60 * H1 + M1
print(time - okiru)


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);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;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  rep(i, 0, N) { cin >> h[i]; }
  vector<int>dp(N,INF);
  dp[0]=0;
  rep(i,0,N){
    rep(j,i+1,i+K+1){
      chmin(dp[j],dp[i]+abs(h[i]-h[j]));
    }
  }
  cout<<dp[N-1]<<endl;


  return 0;
}


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

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

  int v[n];
  int w[n];
  for(int i=0; i<n; i++){
    cin >> v[i] >> w[i];
  }

  int DP[n+1][W+1];
  for(int i=0; i<=W; i++){
    DP[0][i]=0;
  }

  for(int i=1; i<=n; i++){
    for(int j=0; j<=W; j++){
      if(j < w[i-1]){
        DP[i][j] = DP[i-1][j];
      }else{
        if((DP[i-1][j] > DP[i-1][j-w[i-1]]+v[i-1]) && (DP[i-1][j] > DP[i][j-w[i-1]]+v[i-1])){
          DP[i][j] = DP[i-1][j];
        }else if((DP[i-1][j-w[i-1]]+v[i-1] > DP[i-1][j]) && (DP[i-1][j-w[i-1]]+v[i-1] > DP[i][j-w[i-1]]+v[i-1])){
          DP[i][j] = DP[i-1][j-w[i-1]]+v[i-1];
        }else{
          DP[i][j] = DP[i][j-w[i-1]]+v[i-1];
        }
      }
    }
  }

  cout << DP[n][W] << endl;

  return 0;
}



Measured memory_bytes: 7040
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){
   unsigned long n,a,b;
   cin>>n>>a>>b;

   unsigned long ans=0;
    unsigned long c=a+b;
   unsigned long d=n/c;
   unsigned long e=n-d*c;
   if(e<=a) cout<<e+d*a;
   else cout<<a+d*a;

   
return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    w_lst = list(map(int, input().split()))
    difference_lst = []

    for i in range(1, n):
        s1 = 0
        s2 = 0

        for j in range(i):
            s1 += w_lst[j]
        for j in range(i, n):
            s2 += w_lst[j]

        difference_lst.append(abs(s1 - s2))

    minimum = min(difference_lst)
    print(minimum)


if __name__ == '__main__':
    main()

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> all_road(M*2,0);
  
  for(int i=0;i<all_road.size();i++){
    cin >> all_road.at(i);
  }
  for(int i=0 ; i<N ; i++){
    cout << std::count(all_road.begin(),all_road.end(),i+1) << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if (N >= 1000) {
            System.out.println("ABD");
        } else {
            System.out.println("ABC");
        }
        sc.close();
    }
}

Measured memory_bytes: 23252
#include<stdio.h>
int main()
{
  int n,tmp,co,min;
  int i;
  min=1000000001;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&tmp);
      co=0;
      while(tmp%2==0)
	{
	  co++;
	  tmp/=2;
	}
      if(co<min)
	{
	  min=co;
	}
 
    }
  printf("%d",min);
  return 0; 
}

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

int main() {
  int N;
  cin >> N;
 double sum=0;

  vector<double> math(N); 

  for (int i = 0; i < N; i++) {
   
    cin >> math.at(i);
   double a =1/math.at(i);
    sum=sum+a;
     
  }
cout<<1/sum<<endl;
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef pair<int, pii> iii;
//----
const int N=101010;
int dis[N];
bool vis[N];
vector<pii> G[N];
set<int> s[N];
int n, m;
int dij(){
	priority_queue<pii> q;
	q.push(mp(0, 0));
	memset(dis, 0x3f, sizeof(dis));
	while(sz(q)){
		pii c=q.top();q.pop();
		if(vis[c.se])continue;
		vis[c.se]=1;
		int d=-c.fi;
		rep(i, 0, sz(G[c.se])){
			int v=G[c.se][i].fi, cc=G[c.se][i].se, nd=d;
			if(!s[c.se].count(cc))nd++;
			if(nd>dis[v])continue;
			if(nd<dis[v]){
				dis[v]=nd;
				q.push(mp(-dis[v], v));
				s[v].clear();
			}
			s[v].insert(cc);
		}
	}
	return dis[n-1]==dis[n]?-1:dis[n-1];
}
int main(){
	scanf("%d%d", &n, &m);
	rep(i, 0, m){
		int u, v, c;
		scanf("%d%d%d", &u, &v, &c);
		u--, v--;
		G[u].pb(mp(v, c));
		G[v].pb(mp(u, c));
	}
	printf("%d\n", dij());
	return 0;
}
/*
3 3
1 2 1
2 3 1
3 1 2
1

8 11
1 3 1
1 4 2
2 3 1
2 5 1
3 4 3
3 6 3
3 7 3
4 8 4
5 6 1
6 7 5
7 8 5
2

2 0
-1
*/


Measured memory_bytes: 23540
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    ll INF = 1e9+7;
    ll MOD = 998244353;
    typedef pair<ll,ll> ii;
    #define f(i,a,b) for(long long i = a;i < b;i++)
    #define rf(i,a,b) for(long long i=a;i>=b;i--)
    #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define w(t) while(t--)
    #define c(n); cin>>n;
    #define p(n) cout<<n;
    #define pl(n) cout<<n<<endl;
    #define ps(n); cout<<n<<" ";
    #define F first
    #define S second
    #define pb(a) push_back(a)
    ///I hope I will get uprating and don't make mistakes
    ///I will never stop programming
    ///sqrt(-1) Love C++
    /// @TheofanisOrfanou Theo830
    ///AtCoder Beginner Contest 151
    int main(void){
        fastio;
        ll n,m;
        c(n);
        c(m);
        ll mp[n+1];
        f(i,0,n+1){
            mp[i] = 0;
        }
        ll pen[n+1];
        f(i,0,n+1){
            pen[i] = 0;
        }
        ll penalty = 0;
        ll ac = 0;
        f(i,0,m){
            ll p;
            string feed;
            c(p);
            c(feed);
            if(feed == "AC"){
                if(mp[p] == 0){
                    ac++;
                }
                mp[p] = 1;
            }
            else{
                if(mp[p] == 0)
                    pen[p]++;
            }
        }
        f(i,1,n+1){
            if(mp[i] == 1){
                penalty += pen[i];
            }
        }
        cout<<ac<<" "<<penalty;
    }


Measured memory_bytes: 1792
class BinaryIndexedTree:
    def __init__(self,n,default = 0):
        self.s = [default]*(n+1)
        self.n = n
    # idxは1-indexted
    def add(self,val,idx):
        while idx < self.n+1:
            self.s[idx] = self.s[idx] + val
            idx += idx&(-idx)
        return
    
    def get(self,idx):
        res = 0
        while idx > 0:
            res = res + self.s[idx]
            idx -= idx&(-idx)
        return res

n = int(input())
P = list(map(int,input().split()))

BIT = BinaryIndexedTree(n)
ans = 0
for p in P[::-1]:
    ans += (BIT.get(p) >= p-1)
    BIT.add(1,p)
print(ans)


Measured memory_bytes: 100088
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    string n;
    cin>>n;
    ll ans=0;
    for(int i=0;i<n.length();i++){
        ll x;
        char ch=n[i];
        x=ch-'0';
        ans+=x;
    }
    if((ans%9)==0) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3728
#define _GLIBCXX_DEBUG

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

int main(){
    int N, n;
    cin >> N;
    cin >> n;
    
    int min = 1000000001;
    int max = 0;
    int ans = -1000000001;

    if(n > max) max = n;
    if(n < min) min = n;

    rep(i, N - 1)
    {
        cin >> n;

        if(n - min > ans) ans = n - min;
        if(n > max) max = n;
        if(n < min) min = n;
    }

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


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

class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line;
		try {
			while ((line = br.readLine()) != null) {
				String[] v = line.split(" ");
				System.out.println(String.valueOf(Integer.parseInt(v[0]) + Integer.parseInt(v[1])).length());
			}
		} catch (Exception e) {
		}
	}
}

Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main() {
    ll h, w;
    cin >> h >> w;

    ll ans = 1e18;
    for (int i = 1; i < h; i++) {
        int wid = w / 2;
        ll mx = max(i * w, max((h - i) * wid, (h - i) * (w - wid)));
        ll mn = min(i * w, min((h - i) * wid, (h - i) * (w - wid)));
        ans = min(ans, mx - mn);
    }

    for (int i = 1; i < w; i++) {
        int hei = h / 2;
        ll mx = max(i * h, max((w - i) * hei, (w - i) * (h - hei)));
        ll mn = min(i * h, min((w - i) * hei, (w - i) * (h - hei)));
        ans = min(ans, mx - mn);
    }

    for (int i = 1; i < h; i++) {
        int hei = (h - i);
        ll mx = max(i * w, max((hei / 2) * w, (hei - (hei / 2)) * w));
        ll mn = min(i * w, min((hei / 2) * w, (hei - (hei / 2)) * w));
        ans = min(ans, mx - mn);
    }

    for (int i = 1; i < w; i++) {
        int wid = (w - i);
        ll mx = max(i * h, max(h * (wid / 2), h * (wid - (wid / 2))));
        ll mn = min(i * h, min(h * (wid / 2), h * (wid - (wid / 2))));
        ans = min(ans, mx - mn);
    }


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fort(i,n) for (int i = 1; i <= n; ++i)
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz size()
#define er erase
#define fr first
#define sc second
#define rc(x) return cout << x, 0
using namespace std;

int n,l[15],mx,s;

int32_t main()
{
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    fort (i,n)
        cin >> l[i], mx=max(mx,l[i]), s+=l[i];
    if (s>2*mx) rc("Yes");
    cout << "No";
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int z = sc.nextInt();
		int w = sc.nextInt();
		
		int[] cardArr = new int[n];
		
		for(int i = 0; i < n; i++) {
			cardArr[i] = sc.nextInt();
		}
		sc.close();
		
		if(cardArr.length == 1) {
			System.out.println(Math.abs(cardArr[0] - w));
			return;
		}
		
		
		int tail = cardArr[cardArr.length - 1];
		int semiTail = cardArr[cardArr.length - 2];
		
		if(Math.abs(tail - w) > Math.abs(tail - semiTail)) {
			System.out.println(Math.abs(tail - w));
		}else {
			System.out.println(Math.abs(tail - semiTail));
		}
	}
}


Measured memory_bytes: 25804
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;

int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;

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

	if (n < 0)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << n << endl;
	}



	return 0;
}

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

int n;
int a[100009];
int main(){
    int ans = 0;
    cin >> n;
    for(int i = 1; i <= n;++i){
        scanf("%d", &a[i]);
    }
    for(int i = 1 ; i <= n;++i){
        if(i == a[i]){
            ans++;
            i++;
        }
    }

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


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

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

	ll u = INF;
	for (int i = 0; i <= max(x,y); i++) {
		ll cc = c * i * 2;
		ll aa = max(0LL, (x - i)) * a;
		ll bb = max(0LL, (y - i)) * b;
		u = min(u, aa + bb + cc);
	}
	cout << u << endl;
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define lli long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// int const mod = 7340033;
int const mod = 1e9+7;
int power(int a,int b,int m){
    a %= mod;
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}
 
int inverse(int x){
    return power(x,mod-2,mod);
}

int const N = 2e5+5;
int const inf = 1e15;
int a[N];
int is[N];


void solve(){
    int i,j,l;
    int n,k,m;
    cin>>n>>m;
    for(i=0;i<=n;i++) is[i] = 0 , a[i] = 0;
    for(i=0;i<m;i++){
        int p;
        string s;
        cin>>p>>s;
        if(s == "AC"){
            is[p] = 1;
        }
        else{
            if(is[p] == 0){
                a[p]++;
            }
        }
    }

    int co = 0;
    int pen = 0;
    for(i=1;i<=n;i++) {
        co += is[i];
        if(is[i] == 1) pen += a[i];
    }
    cout<<co<<" "<<pen<<endl;
}

int32_t main(){
    IOS;
    int t;
    t = 1;  
    // pre();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}

/*

*/

Measured memory_bytes: 1792
#include <iostream>
#include <cassert>
#include <bits/stdc++.h>

using namespace std;

#define LL long long 

int main(int argc, char const *argv[])
{
	LL a, b, c;
	scanf("%lld%lld%lld", &a, &b, &c);
	if(c<a+b) {printf("No\n"); return 0;}
	if((c - a - b)*(c-a-b)>4*a*b)
		printf("Yes\n");
	else printf("No\n");
	return 0;
}



Measured memory_bytes: 256
#include <cctype>
#include <cstdio>
#include <cstring>

using namespace std;

char S[111][22]; int N, H, Q, R, T[111], P[111];

int main()
{
    scanf("%d %d", &N, &H);
    
    for(int i = 0; i < N; i++)
    {
        scanf("%s %d", S[i], &T[i]);
    }
    
    char F[2];
    
    for(int i = 0; i < N; i++)
    {
        int ptr = 0;
        
        while(ptr != strlen(S[i]))
        {
            printf("? %s\n", S[i]); fflush(stdout);
            
            scanf("%s", F); R++;
            
            if(tolower(S[i][ptr]) == tolower(F[0]))
            {
                S[i][ptr] = '_'; ptr++; Q++;
            }
            else
            {
                P[i]++;
                
                if(P[i] > T[i])
                {
                    H--; break;
                }
            }
        }
                   
        if(H <= 0)
        {
            printf("! Game Over\n"); return 0;
        }
    }
    
    int r = Q * 1000 / R;
    
    printf("! Game Clear %d.%d\n", r / 10, r % 10);
    
    return 0;
}

Measured memory_bytes: 3368
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <iomanip>
#include <unordered_map>
#include <string>
#include <unordered_set>
using namespace std;
typedef long long ll;
ll a, b, n;
int main(){
    cin >> a >> b >> n;
    if(n >= b) {
        cout << (b - 1)*a/b  << endl;
    } else {
        cout << n*a/b << endl;
    }
    return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
int b[4100];
long long sum[4100];
int dp[4100][4100];
int rev[4100][4100];
int ans[4100];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",b+i);
	for(int i=0;i<a;i++){
		sum[i+1]=sum[i]+b[i];
	}
	for(int i=0;i<a;i++)dp[0][i+1]=1;
	for(int i=1;i<a;i++){
		vector<pair<long long,int> >L;
		vector<pair<long long,int> >R;
		for(int j=0;j<i;j++)L.push_back(make_pair(sum[i]-sum[j],j));
		for(int j=i+1;j<=a;j++)R.push_back(make_pair(sum[j]-sum[i],j));
		std::sort(L.begin(),L.end());
		std::sort(R.begin(),R.end());
		int ind=0;
		int m=-99999999;
		int at=-1;
		for(int j=0;j<R.size();j++){
			while(ind<L.size()&&L[ind].first<R[j].first){
				if(m<dp[L[ind].second][i]){
					m=dp[L[ind].second][i];
					at=L[ind].second;
				}
				ind++;
			}
			dp[i][R[j].second]=m+1;
			rev[i][R[j].second]=at;
		}
	}
	//for(int i=0;i<a;i++)for(int j=i+1;j<=a;j++)printf("%d %d: %d\n",i,j,dp[i][j]);
	int ret=0;
	int at=0;
	for(int i=0;i<a;i++){
		if(ret<dp[i][a]){
			ret=dp[i][a];
			at=i;
		}
	}
	int last=a;
	printf("%d\n",ret);
	for(int i=0;i<ret;i++){
		ans[ret-1-i]=last;
		int to=rev[at][last];
		last=at;at=to;
	}
	for(int i=0;i<ret-1;i++){
		if(i)printf(" ");
		printf("%d",ans[i]);
	}
	printf("\n");
}

Measured memory_bytes: 132256
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    a: usize1,
    b: usize1,
  }
  let mut ans = vec![true; 3];
  ans[a] = false;
  ans[b] = false;
  for (i, &t) in ans.iter().enumerate() {
    if t {
      puts!("{}\n", i + 1);
    }
  }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define Clear(arr) memset(arr,0,sizeof arr)
#define oo 1000000000
#define inf 1000000000000000000
#define M 1000000007
#define M2 1000000009
#define pii pair<ll,ll>
using namespace std;
typedef long long ll;
const int N = 2e5+100;
const int SQRTN = 320;
const int LOGN = 20;
const double PI = acos(-1);
const double TAU = 2*PI;


inline void solve(){
    string s;
    cin >> s;
    s[0]++;
    cout << s << endl;

}

signed main() {
	int t=1;
	while(t--){
		solve();
	}
    return 0;
}


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

typedef unsigned uint;
typedef long long INT;
typedef unsigned long long UINT;
const int INF = 1001001001;
const INT INFLL = 1001001001001001001LL;

 int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
INT lin() { INT x; scanf("%lld", &x); return x; }
UINT luin() { UINT x; scanf("%llu", &x); return x;}


int main(){
    int a, b, c;
    double fa, fb, fc;
    char S[128], sa[128], sb[128], sc[128];
    // int N = in();
    // int K = in();
    // scanf("%s", S);

    int X = in();
    int N = in();

    // vector<pair<int, int>> Abs;
    // for (int i = 0; i < N; ++i) {
    //     int nA = in();
    //     Abs.push_back(make_pair(abs(nA - X), nA));
    // }
    // sort(Abs.begin(), Abs.end(), [](pair<int,int> lhs, pair<int, int>rhs) {
    //     return lhs.second < rhs.second;
    // });

    // bool bExist = false;
    // int tmp = 0;
    // for (int i = 0; i < Abs.size(); ++i) {
    //     if (Abs[i] - tmp > 1) {
    //         ++tmp;
    //         bExist = true;
    //         break;
    //     }
    //     tmp = Abs[i];
    // }

    // if (!bExist) {
    //     tmp = Abs[N-1] + 1;
    // }

    vector<int> vecInput;
    for (int i = 0; i < N; ++i) {
        int nA = in();
        vecInput.push_back(nA);
    }

        if (find(vecInput.begin(), vecInput.end(), X) == vecInput.end()) {
            printf("%d", X);
            return 0;
        }

    int nSub = 1;
    while(1) {
        int Ans1 = X - nSub;
        int Ans2 = X + nSub;

        if (find(vecInput.begin(), vecInput.end(), Ans1) == vecInput.end()) {
            printf("%d", Ans1);
            return 0;
        }
        if (find(vecInput.begin(), vecInput.end(), Ans2) == vecInput.end()) {
            printf("%d", Ans2);
            return 0;
        }
    ++nSub;
    }


    return 0;
}







Measured memory_bytes: 3796
n = int(input())
s,a,b = 0,0,0
f = True
for _ in [0]*n:
  t,x,y = map(int,input().split())
  p = t-s-(abs(x-a)+abs(y-b))
  if p%2 == 1 or p<0:
    f = False
print("Yes" if f else "No")

Measured memory_bytes: 3828
#include <cstdio>

using namespace std;

int main() {
    char a[4]={};
    int i, sum=0;
    scanf("%s", a);
    for(i=0;i<3;i++)
    {
        if(a[i]=='A')
            sum++;
    }
    if(sum%3)
        printf("Yes");
    else
        printf("No");
    
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 3010
using namespace std;

struct edge{int x, y, next;}a[N];
int n, w[N], l, p[N], x, y, d[N], du[N], op, cl, f[N];

inline void add(int x, int y){a[++l].x=x; a[l].y=y; a[l].next=p[x]; p[x]=l;}

int main(){
	scanf("%d", &n);
	for(int i=1; i<=n; i++)scanf("%d", &w[i]);
	l=0; memset(p, 0, sizeof(p)); memset(du, 0, sizeof(du));
	for(int i=1; i<=n-1; i++){
		scanf("%d%d", &x, &y);
		if(w[x]<w[y]){add(y, x); du[x]++;}
		if(w[x]>w[y]){add(x, y); du[y]++;}
	}
	op=cl=0;
	for(int i=1; i<=n; i++)if(!du[i])d[++cl]=i;
	while(op<cl){
		op++; x=d[op];
		for(int i=p[x]; i; i=a[i].next){
			du[a[i].y]--; if(!du[a[i].y])d[++cl]=a[i].y;
		}
	}
	for(int i=cl; i; i--){
		x=d[i]; f[x]=0;
		for(int j=p[x]; j; j=a[j].next)if(!f[a[j].y])f[x]=1;
	}
	for(int i=1; i<=n; i++)if(f[i])printf("%d ", i);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
const long long NR=4;
char s[NR];
int main()
{
	scanf("%s",s);
	if(s[0]=='A'&&s[1]=='A'&&s[2]=='A')
	{
		printf("No");
		return 0;
	}
	if(s[0]=='B'&&s[1]=='B'&&s[2]=='B')
	{
		printf("No");
		return 0;
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
string s;
cin >>s;
ll count=0;
for(ll i=0;i<3;i++){
if(s[i]=='o')
count++;
}
cout <<700+100*count;

return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,a,b;
    cin>>n>>a>>b;
    if(n>1&&b>=a||n==1&&a==b) cout<<(n-2)*(b-a)+1<<endl;
    else cout<<0<<endl;
    return 0;
} 

Measured memory_bytes: 256
from sys import exit
from collections import Counter
n = int(input())
A = tuple(map(int, input().split()))
C = Counter(A)
ans = [0 for _ in range(n)]
D = dict()
S = set(A)
if len(S) == 1:
    print(sum(A))
    for _ in range(n - 1):
        print(0)
    exit()
X = sorted(S, reverse=True)
for i, x in enumerate(X):
    D[x] = i

index = [n + 1 for _ in range(len(S))]
for i, a in enumerate(A):
    index[D[a]] = min(index[D[a]], i)

cnt = 0
x = n + 1

for i in range(1, len(S)):
    tmp = X[i - 1]
    nxt = X[i]
    cnt += C[tmp]
    x = min(x, index[D[tmp]])
    ans[x] += (tmp - nxt) * cnt

for i, a in enumerate(A):
    if a != 0:
        cnt += C[nxt]
        ans[i] += nxt * cnt
        break

for a in ans:
    print(a)


Measured memory_bytes: 126808
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    int k = sc.nextInt();
    int[][] c = new int[h][w];
    for(int i = 0;i<h;i++){
      String s = sc.next();
      for(int j = 0;j<w;j++){
        if(s.substring(j,j+1).equals("#")){
          c[i][j] = 1;
        }
      }
    }
    int count = 0;
    for(int i = 0;i<(1<<h);i++){
      List<Integer> lih = new ArrayList<Integer>();
      for(int bith = 0;bith<h;bith++){
        int bibih = i & (1<<bith);
        if(bibih == 0){
          lih.add(bith);
        }
      }

      for(int j = 0;j<(1<<w);j++){
        List<Integer> liw = new ArrayList<Integer>();
        for(int bitw = 0;bitw<w;bitw++){
          int bibiw = j & (1<<bitw);
          if(bibiw == 0){
            liw.add(bitw);
          }
        }
        int kuro = 0;
        for(int ki = 0;ki<lih.size();ki++){
          for(int kk = 0;kk<liw.size();kk++){
            if(c[lih.get(ki)][liw.get(kk)] == 1)kuro++;
          }
        }
        if(kuro == k)count++;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 36396
N,M=map(int,input().split())
H=[int(i) for i in input().split()]
ans=[1 for i in range(N)]
for a in range(M):
    A,B=map(int,input().split())
    if H[A-1]>H[B-1]:
        ans[B-1]=0
    elif H[A-1]==H[B-1]:
        ans[B-1]=0
        ans[A-1]=0
    else:
        ans[A-1]=0
print(sum(ans))

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

using namespace std;

#define MAX 16

int H,W,gp[MAX*MAX];
char field[MAX][MAX];
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};

struct State{
  int h,r[3];
};

inline bool check(const State &s){
  for(int i = 0 ; i < 3 ; i++){
    if(field[s.r[i]/W][s.r[i]%W] != '_'){
      return false;
    }
  }
  return true;
}

inline int canMove(const State &s,int &dir){
  if(field[s.h/W][s.h%W] == '#'){ return -1; }
  int idx = -1;
  for(int i = 0 ; i < 3 ; i++){
    if(s.h == s.r[i]){
      idx = i; break;
    }
  }
  if(idx == -1){ return 3; }
  int nx = s.h%W + dx[dir];
  int ny = s.h/W + dy[dir];
  if(field[ny][nx] == '#'){ return -1; }
  for(int i = 0 ; i < 3 ; i++){
    if(i == idx){ continue; }
    if(s.r[i]%W == nx && s.r[i]/W == ny){
      return -1;
    }
  }
  return idx;
}

bool visited[50][50][50][50];

int bfs(const State &S){
  queue<State> Q; Q.push(S);
  queue<int> step; step.push(0);
  const int dr[4] = {-1,-W,1,W};
  memset(visited,false,sizeof(visited));
  visited[gp[S.h]][gp[S.r[0]]][gp[S.r[1]]][gp[S.r[2]]] = true;

  while(!Q.empty()){
    State s = Q.front(); Q.pop();
    int st = step.front(); step.pop();
    if(check(s)){ return st; }
    for(int i = 0 ; i < 4 ; i++){
      s.h += dr[i];
      int r = canMove(s,i);
      if(r == -1){
        s.h -= dr[i];
        continue;
      }
      if(r == 3){
        if(!visited[gp[s.h]][gp[s.r[0]]][gp[s.r[1]]][gp[s.r[2]]]){
          visited[gp[s.h]][gp[s.r[0]]][gp[s.r[1]]][gp[s.r[2]]] = true;
          Q.push(s);
          step.push(st+1);
        }
      }else{
        s.r[r] += dr[i];
        if(!visited[gp[s.h]][gp[s.r[0]]][gp[s.r[1]]][gp[s.r[2]]]){
          visited[gp[s.h]][gp[s.r[0]]][gp[s.r[1]]][gp[s.r[2]]] = true;
          Q.push(s);
          step.push(st+1);
        }
        s.r[r] -= dr[i];
      }
      s.h -= dr[i];
    }
  }
  return -1;
}

int main(){
  while(cin >> W >> H,(W|H)){
    int r = 0,idx = 0;
    State start;
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
        cin >> field[i][j];
        if(field[i][j] == '@'){
          start.h = i*W+j;
        }else if(field[i][j] == '*'){
          start.r[r++] = i*W+j;
        }
        if(field[i][j] != '#'){
          gp[i*W+j] = idx++;
        }
      }
    }
    cout << bfs(start) << endl;
  }
  return 0;
}

Measured memory_bytes: 9232