akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;
using Graph = vector<vector<int>>;

#define INF (1 << 21);
typedef long long ll;

int main(){
  int N, M, K;cin >> N >> M >> K;
  Graph G(N);
  for(int i = 0;i < M;++i){
    int a, b;cin >> a >> b;
    --a;--b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  Graph Bad(N);
  for(int i = 0;i < K;++i){
    int a, b;cin >> a >> b;
    --a;--b;
    Bad[a].push_back(b);
    Bad[b].push_back(a);
  }
  int color[100000],countcolor[100000];
  for(int i = 0;i < N;++i){
    color[i] = -1;
  }
  for(int i = 0;i < N;++i){
    countcolor[i] = 0;
  }
  for(int i = 0;i < N;++i){
    queue <int>Q;
    Q.push(i);
    while(!Q.empty()){
      int q = Q.front();Q.pop();
      if(color[q] == -1){
        color[q] = i;
        countcolor[i] += 1;
      }
      for(int v : G[q]){
        if(color[v] == -1){
          color[v] = i;
          Q.push(v);
          countcolor[i] += 1;
        }
      }
    }
  }

  for(int i = 0;i < N;++i){
    int ans = 0, Badcount = 0;
    for(int v : Bad[i]){
      Badcount += ((color[v] == color[i]) ? 1 : 0);
    }
    ans = countcolor[color[i]] - Badcount - G[i].size() - 1;
    cout << ans << ' ';
  }
}


Measured memory_bytes: 13048
#include "bits/stdc++.h"
#include <cmath>

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int N;
int counter(int x){
    if(x == 0) return 0;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        if(x & (1 << i)) cnt++;
    }
    return cnt;
}
int main() {
    cin >> N;
    vector<vector<pair<int, int>>> A(N);
    for (int i = 0; i < N; i++) {
        int A1;
        cin >> A1;
        A[i].resize(A1);
        for (int j = 0; j < A1; j++) {
            cin >> A[i][j].fi >> A[i][j].se;
        }
    }
    int max_n = 0;
    for (int bit = 0; bit < (1 << N); bit++) {
        bool ok = true;
        for (int i = 0; i < N; i++) {
            if (!(bit & (1 << i))) continue;
            for (int j = 0; j < (int) A[i].size(); j++) {
                if(((bit >> (A[i][j].fi - 1)) & 1) ^ A[i][j].se) ok = false;
            }
        }
        if(ok) max_n = max(max_n, counter(bit));
    }
    cout << max_n << endl;
}

Measured memory_bytes: 256
import java.util.*;


class Main{
    static long mod = 1000000007;
    public static void main(String argv[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        n = n-k;

        int dp_index=2001;
        long[][] dp = new long[dp_index][dp_index];
        dp = make_combi(dp_index);
        for(int i=1;i<=k;i++){
            System.out.println(((dp[n+1][i]%mod)*(dp[k-1][i-1])%mod)%mod);
        }
    }

    public static long[][] make_combi(int a) {
        long[][] d = new long[a][a];
        d[0][0] = 1;
        d[1][0] = 1;
        d[1][1] = 1;
        for(int i=2;i<a;i++){
            d[i][0]=1;
            d[i][1]=i;
            for(int j=2;j<i;j++){
                d[i][j] = (d[i-1][j] + d[i-1][j-1])%mod;
            }
            d[i][i] = 1;
        }
        return d;
    }
}

Measured memory_bytes: 131668
a, b = input().split(" ")
c, d, e = input().split(" ")
str = input()

b = int(b)
c = int(c)
d = int(d)
e = int(e)
score = 0
last_data = []
count = 0
for char in str:
  if(count // b < 1):
    if char == "r":
      score += e
    if char == "s":
      score += c
    if char == "p":
      score += d
    last_data.append(char)
  else:
    mod = count % b
    if char == last_data[mod]:
      last_data[mod] = "a"
    else:
      if char == "r":
        score += e
      if char == "s":
        score += c
      if char == "p":
        score += d
      last_data[mod] = char
  count += 1
  
print(score)

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

using namespace std;

class Dice {
public:
	int num[6];

	void Move(const char &dir) {
		int i = num[0];
		switch (dir){
		case 'N':
			num[0] = num[1];
			num[1] = num[5];
			num[5] = num[4];
			num[4] = i;
			break;
		case 'S':
			num[0] = num[4];
			num[4] = num[5];
			num[5] = num[1];
			num[1] = i;
			break;
		case 'E':
			num[0] = num[3];
			num[3] = num[5];
			num[5] = num[2];
			num[2] = i;
			break;
		case 'W':
			num[0] = num[2];
			num[2] = num[5];
			num[5] = num[3];
			num[3] = i;
			break;
		default:
			break;
		}
	}
};

int main()
{
	Dice dice;
	string dir;

	for (int i = 0; i < 6; i++) {
		cin >> dice.num[i];
	}

	cin >> dir;
	for (unsigned int i = 0; i < dir.length(); i++) {
		dice.Move(dir[i]);
	}

	cout << dice.num[0] << endl;

	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
int main() {
	int N, cnt = 0;
	cin >> N;
	vector<int> p(N);
	for (auto& i : p) cin >> i;
	for (int i = 0; i < N; i++) {
		if (p[i] == i + 1) {
			swap(p[i], (i == N - 1 ? p[i - 1] : p[i + 1]));
			cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,x,t;
	cin>>n>>x>>t;
	int ans=n/x;
	if(n%x) ans++;
	cout<<ans*t<<endl;
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    long double N; cin>>N;
    long double goal = 4.0/N;
    long double h = 1, n = 1;
    for(h=1.0;h<=3500;h++){
        for(n=1.0;n<=3500;n++){
            long double x = N*h*n/(4.0*h*n - N*h - N*n);
            if(x>0&&x<=3500){
                int y = x; long double z = y;
                if(y==x) {cout<<h<<' '<<n<<' '<<x; return 0;}
            }
        }
    }
}


Measured memory_bytes: 384
import java.util.Scanner;
 
public class Main {
 
    static class P{
        String name;
        int time;
    }
 
    static int len = 100001;
    static P[] Q = new P[len];
 
    static int head = 0;
    static int tail = 0;
 
    static boolean isEmpty(){
        return head == tail;
    }
 
    static boolean isFull(){
        return head == (tail + 1) % len;
    }
 
    static void enqueue(P p){
        if(isFull()){
            throw new IndexOutOfBoundsException();
        }
        Q[tail] = p;
 
        tail = (tail + 1) % len;
    }
 
    static P dequeue(){
        if(isEmpty()){
            throw new IndexOutOfBoundsException();
        }
        P temp = Q[head];
 
        head = (head + 1) % len;
        return temp;
    }
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        P p = null;
        int n = 0;
        int q = 0;
        int index = 0;
        String[] temp = null;
        while (sc.hasNextLine()){
            if(n == 0){
                temp = sc.nextLine().split(" ");
                n = Integer.valueOf(temp[0]);
                q = Integer.valueOf(temp[1]);
            }else{
                temp = sc.nextLine().split(" ");
                p = new P();
                p.name = temp[0];
                p.time = Integer.valueOf(temp[1]);
                enqueue(p);
                index ++;
                if(index == n){
                    break;
                }
            }
        }
 
        int sumTime = 0;//当前总运行时间
 
        P curr = null;
        while (head != tail){
            curr = dequeue();
            int c = min(q,curr.time);
            curr.time -= c;
            sumTime += c;
            if(curr.time > 0){
                //如果当前任务有剩余时间 则加入队列
                enqueue(curr);
            }else{
                System.out.println(curr.name + " " + sumTime);
            }
        }
    }
 
 
    static int min(int a,int b){
        return a > b ? b : a;
    }
}


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

ll n,p[100005],rez;

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

    cin>>n;
    for(ll i=1;i<=n;i++)
        cin>>p[i];

    for(ll i=1;i<=n;i++)
    {
        if(p[i]==i)
        {
            if(i==n)
                rez++;
            else
            {
                ll x=p[i];
                p[i]=p[i+1];
                p[i+1]=x;
                rez++;
            }
        }
    }

    cout<<rez<<endl;

    return 0;
}


Measured memory_bytes: 4432
#include <iostream>

using namespace std;

int main()
{
 string x;
    cin>>x;
    int a=0,b=0;
    for(int i=0;i<3;i++){
        if(x.at(i)=='A'){
            a++;
        }
        else{
            b++;
        }
    }
    if(a==0|| b==0){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }

    return 0;
}


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

int func(int x) {
  if(x%2 != 0) {
    return 0;
  }
  return func(x/2) + 1;
}
int main(void) {
  int N;
  cin >> N;
  int ans = 0;
  for(int i=0; i<N; i++) {
    int a;
    cin >> a;
    ans += func(a);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int main(){
  string s;cin >> s;
  ll K;cin >> K;
  repeat(i,s.length()){
    ll dif = ('z'-s[i]+1)%26;
    if(dif<=K){
      s[i] = 'a';
      K -= dif;
    }
  }
  K %= 26;
  s.back() += K;
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n,k;
    cin >> n >> k;
    int a[n];
    int p[200001] = {};
    for(int i = 0; i < n; i++){
        cin >> a[i];
        p[a[i]]++;
    }
    int count = 0;
    for(int i = 0; i < 200000; i++){
        if(p[i] > 0){
            count++;
        }
    }
    
    if(count <= k){
        cout << 0 << endl;
        return 0;
    }

    sort(p,p+200001);
    for(int i = 0; i < k; i++){
        n -= p[200000-i];
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define x first
#define y second
typedef pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x,T y){x<y?x=y:T();}
template <typename T> void chkmin(T &x,T y){x>y?x=y:T();}
template <typename T> void readint(T &x)
{
	x=0;int f=1;char c;
	for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=x*10+c-'0';
	x*=f;
}
const int MOD=998244353;
inline int dmy(int x){return x>=MOD?x-MOD:x;}
inline void inc(int &x,int y){x=dmy(x+y);}
int qmi(int x,int y)
{
	int ans=1;
	for(;y;y>>=1,x=1ll*x*x%MOD)
		if(y&1)ans=1ll*ans*x%MOD;
	return ans;
}
const int MAXN=200005;

int n,k,a[MAXN],pw[MAXN],ipw[MAXN];
int c[MAXN];
void add(int x,int d){for(;x<=n;x+=(x&-x))inc(c[x],d);}
int query(int x){int s=0;for(;x;x-=(x&-x))inc(s,c[x]);return s;}

int main()
{
	#ifdef LOCAL
	freopen("code.in","r",stdin);
//	freopen("code.out","w",stdout);
	#endif
	readint(n),readint(k);
	for(int i=1;i<=n;++i)readint(a[i]);
	pw[0]=ipw[0]=1,pw[1]=dmy(1+MOD-qmi(k,MOD-2)),ipw[1]=qmi(pw[1],MOD-2);
	for(int i=2;i<=n;++i)pw[i]=1ll*pw[i-1]*pw[1]%MOD,ipw[i]=1ll*ipw[i-1]*ipw[1]%MOD;
	int ans=0,cnt=0;
	for(int i=1;i<=n;++i)
		inc(cnt,query(n)-query(a[i])),
		add(a[i],1);
	memset(c,0,sizeof(c));
	for(int i=1;i<=n;++i)
	{
		int u=max(i,k);
		int sn=query(n),si=query(a[i]);
		inc(ans,1ll*dmy(dmy(si<<1)-sn+MOD)*pw[u]%MOD);
		add(a[i],ipw[u]);
	}
	ans=(cnt+1ll*ans*qmi(2,MOD-2))%MOD;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6824
#include <iostream>
#include<stdio.h>
#include<algorithm>

#define N 10

using namespace std;

int more(int a,int b){
    if(a>b) return a;
    else return b;
}


int main(void){
    // Your code here!
    char str[N];
    int seq=0;
    int max_d=0;
    scanf("%s",str);
    //if(str[0]==
    for(int i=0; i<3; i++){
        if( str[i]=='R' ) seq++;
        else seq=0;
        
        max_d=max( max_d, seq ); 
    }
    printf("%d\n",max_d);
    
    return 0;
}


Measured memory_bytes: 3808
import java.io.*;
import java.util.*;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int M = in.i();

        UnionFind uf = new UnionFind(N);
        for (int i = 0; i < M; i++) {
            uf.unite(in.i() - 1, in.i() - 1);
        }
        System.out.println(uf.ncc - 1);
    }
}

class UnionFind {
    private final int N;
    int[] parent;
    int[] rank;
    int[] size;
    int ncc;

    UnionFind(int n) {
        N = n;
        parent = new int[N];
        Arrays.setAll(parent, i -> i);
        size = new int[N];
        Arrays.fill(size, 1);
        rank = new int[N];
        ncc = n;
    }

    boolean isRoot(int x) {
        return x == parent[x];
    }

    int root(int x) {
        return isRoot(x) ? x : (parent[x] = root(parent[x]));
    }

    boolean same(int x, int y){
        return root(x) == root(y);
    }

    int size(int x) {
        return size[root(x)];
    }

    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x != y) {
            if (rank[x] < rank[y]) {
                parent[x] = y;
                size[y] += size[x];
            } else {
                parent[y] = x;
                size[x] += size[y];
                if (rank[x] == rank[y]) {
                    rank[x]++;
                }
            }
            ncc--;
        }
    }

    int ncc() {
        return ncc;
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


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

int main() {
  int x,n;
  cin >> x >> n;
  vector<bool> arr(102);
  
  for(int i=0; i<n; i++){
    int value;
    cin >> value;
    arr[value] = true;
  }
  
  vector<int> numbers;
  for(int i=0; i<102; i++){
    if(arr[i] == false){
      numbers.push_back(i);
    }
  }
  
  
  
  
  
  int min = abs(numbers[0] - x);
  int answer = numbers[0];
  for(int i=1; i<numbers.size(); i++){
    if(abs(numbers[i]-x) < min || (abs(numbers[i]-x) < min && numbers[i] < answer) ){
      min = abs(numbers[i]-x);
      answer = numbers[i];
    }
  }
  
  cout << answer << endl;
       
}

Measured memory_bytes: 3640
# -*- coding: utf-8 -*-
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())

print(a[k-1])

Measured memory_bytes: 38384
#include <stdio.h>
/*133 abc c*/

int main(void)
{
  int L, R;
  int l, r;
  int mod;
  int min;
  int minL, minR;

  scanf("%d%d", &L, &R);
  for (size_t i = L; i <= R; i++) {
    if (i % 2019 == 0) {
      printf("0\n");
      return 0;
    }
  }
  min = 2019;

  for (size_t i = L; i <= R; i++) {
    for (size_t j = L; j <= R; j++) {
      if (i == j) continue;
      mod = (i * j) % 2019;
      if (mod < min) min = mod;
    }
  }

  printf("%d\n", min);
  return 0;
}


Measured memory_bytes: 128
N = int(input())
A_B = [[0 for _ in range(2)] for _ in range(N)]
total = 0
res = 'Yes'
for i in range(N):
  A_B[i][0], A_B[i][1] = map(int, input().split(' '))
A_B.sort(key=lambda x: x[1])
for i in range(N):
  total += A_B[i][0]
  if total > A_B[i][1]:
    res = 'No'
    break
print(res)

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

#define MAXN 100005

using namespace std;

int n, m;
int f[MAXN], fa[MAXN], anc[MAXN], dep[MAXN], s = 1, t;
vector<int> g[MAXN];

int read() {
    char c = getchar();
    int x = 0;
    while (!isdigit(c))
        c = getchar();
    while (isdigit(c)) {
        x = (x << 3) + (x << 1) + c - '0';
        c = getchar();
    }
    return x;
}

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

void DFS(int u, int pre, int type) {
    f[u] = type;
    fa[u] = pre;
    dep[u] = dep[pre] + 1;
    for (int i = 0; i < (int)g[u].size(); ++i) {
        int v = g[u][i];
        if (v == pre)
            continue;
        DFS(v, u, -type);
        f[u] += f[v];
    }
}

int main() {
//    freopen("1.in", "r", stdin);
    n = read();
    m = read();
    for (int i = 1; i <= n; ++i)
        anc[i] = i;
    for (int i = 1; i <= m; ++i) {
        int u = read(), v = read();
        if (find(u) == find(v)) {
            s = u;
            t = v;
            continue;
        }
        anc[find(u)] = find(v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    DFS(s, 0, 1);
    if (m == n - 1) {
        if (f[s] != 0) {
            puts("-1");
            return 0;
        }
        int res = 0;
        for (int i = 1; i <= n; ++i)
            res += abs(f[i]);
        printf("%d\n", res);
    }
    else if (dep[t] & 1) {
        int minus = f[s], res = 0;
        if (minus & 1) {
            puts("-1");
            return 0;
        }
        res += abs(minus >> 1);
        f[s] = 0;
        for (int i = t; i != s; i = fa[i])
            f[i] -= (minus >> 1);
        for (int i = 1; i <= n; ++i)
            res += abs(f[i]);
        printf("%d\n", res);
    }
    else {
        if (f[s] != 0) {
            puts("-1");
            return 0;
        }
        vector<int> circle;
        for (int i = t; i != s; i = fa[i]) {
            circle.push_back(f[i]);
            f[i] = 0;
        }
        circle.push_back(0);
        sort(circle.begin(), circle.end());
        int v = circle[((circle.size() + 1) >> 1) - 1], res = 0;
        for (int i = 0; i < (int)circle.size(); ++i)
            res += abs(circle[i] - v);
        for (int i = 1; i <= n; ++i)
            res += abs(f[i]);
        printf("%d\n", res);
    }
}


Measured memory_bytes: 15740
#include<bits/stdc++.h>                          
using namespace std;
int n,num,ans,f[30],a[30];
string s;
int main(){
    cin>>n>>s;
    for(int i=1;i<n-1;i++)
    {
    	num=0;
    	for(int j='a';j<='z';j++) f[j]=0;
    	for(int j=0;j<i;j++) f[s[j]]=1;
    	for(int j='a';j<='z';j++) a[j]=0;
    	for(int j=i;j<n;j++) a[s[j]]=1;
    	for(int j='a';j<='z';j++)
    	    if(f[j]==1&&a[j]==1) num++;
    	ans=max(ans,num);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
def testcase_ends():
    n = int(input())
    if n == 0:
        return 1

    n = oct(n)[2:]
    print(*['01235789'[int(i)] for i in n], sep='');
    return 0

def main():
    while not testcase_ends():
        pass

if __name__ == '__main__':
    main()



Measured memory_bytes: 5620
package main

import (
	"fmt"
)

func main() {
	var W, H, x, y, r int
	fmt.Scan(&W, &H, &x, &y, &r)
	if x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



Measured memory_bytes: 1156
import itertools

n = int(input())
A = list(map(int, input().split()))
for i in range(n):
    A[i] -= i+1

A.sort()
psum = list(itertools.accumulate(A))
# print(A, psum)

right = max(A)
left = min(A)
min_val = float("inf")
for i in range(n):
    low = A[i]*i - psum[i-1] if i > 0 else 0
    high = psum[-1] - psum[i] - A[i]*(n-i-1) if i < n-1 else 0
    min_val = min(min_val, low+high)
    # print(i, low, high, low+high, min_val)

print(min_val)



Measured memory_bytes: 98256
k, s = map(int, input().split())

if s <= k:
    print((s + 2) * (s + 1) // 2)
else:
    ans = 0
    for x in range(k + 1):
        for y in range(min(k + 1, s - x + 1)):
            if 0 <= s - x - y <= k:
                #print(x, y, s-x-y)
                ans += 1
    print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int n,k;
   cin >> n >> k;
   string s;
   cin >> s;

   s[k-1] = s[k-1] + 32;

   cout << s << endl; 





   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define ll long long
//#define file
using namespace std;

int a[200001],n,i,j,k,l,L,R,Mid,tot;
map<int,int> mp;
map<int,int> :: iterator I;

bool pd(int t)
{
	mp.clear(),tot=0;
	fo(i,1,n)
	{
		if (a[i]>tot)
		mp[a[i]]=0,tot=a[i];
		else
		{
			I=mp.end(),--I;
			while ((I->first)>tot)
			mp.erase(I),I=mp.end(),--I;
			tot=a[i];
			
			j=a[i];
			while (j)
			{
				I=mp.find(j);
				if (I==mp.end()) {mp[j]=1;break;}
				else
				{
					if ((I->second)<t-1) {++mp[j];break;}
					else
					mp[j]=0,--j;
				}
			}
			if (!j) return 0;
		}
	}
	return 1;
}

int main()
{
	#ifdef file
	freopen("agc029C.in","r",stdin);
	#endif
	
	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&a[i]);
	fo(i,2,n) if (a[i-1]>=a[i]) break;
	if (i>n) {printf("1\n");return 0;}
	
	L=2;R=n;
	while (L<R)
	{
		Mid=(L+R)/2;
		if (!pd(Mid))
		L=Mid+1; else R=Mid;
	}
	printf("%d\n",L);
	
	fclose(stdin);
	fclose(stdout);
	return 0;
}

Measured memory_bytes: 7156
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll N,K;
  cin>>N>>K;
  VL A(N);
  rep(i,N) cin>>A[i];
  sort(all(A));
  ll ok=A[N-1];
  ll ng=0;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    ll sum=0;
    rep(i,N) sum+=(A[i]+mid-1)/mid-1;
    if(sum>K) ng=mid;
    else ok=mid;
  }
  cout<<ok<<endl;
}



Measured memory_bytes: 4828
#include<stdio.h>

int main(){
	int H, W;
	int i, j;
	while (1){
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0)break;
		for (i = 0; i < H; i++){
			for (j = 0; j < W; j++){
				
				if ((i + j) % 2 == 0){
					printf("#");
				}
				if ((i + j) % 2 == 1){
					printf(".");
				}
			}
			printf("\n");
		}
                printf("\n");
	}
	return 0;
}


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    string S[3];
    cin >> S[0] >> S[1] >> S[2];
    int len[3] = {S[0].length(), S[1].length(), S[2].length()};
    int id[3] = {};
    int turn = 0;
    while(true){
        if(id[turn] == len[turn]) break;
        int next = S[turn][id[turn]] - 'a';
        id[turn]++;
        turn = next;
        //cout << id[0] << " " << id[1] << " " << id[2] << endl;
    }
    cout << char ('A' + turn) << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node{
  struct node* parent;
  struct node* left;
  struct node* right;
  int key;
};

typedef struct node* node;

void insert(int);
void inorder(node);
void preorder(node);

node tree;

int main(){
  int a,b,i;
  char hairetu[10];
  
  scanf("%d",&a);

  for(i=0;i<a;i++){
    scanf("%s",hairetu);
    if(hairetu[0]=='i'){
      scanf("%d",&b);
      insert(b);
    }
    else if(hairetu[0]=='p'){
      inorder(tree);
      printf("\n");
      preorder(tree);
      printf("\n");
    }
  }

  return 0;
}

void insert(int k){
  
  node y = NIL;
  node x = tree;
  node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y=x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }

  z->parent = y;

  if(y==NIL){
    tree=z;
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else{
    y->right = z;
  }
}

void inorder(node tree){
  if(tree != NIL){
    inorder(tree->left);
    printf(" %d",tree->key);
    inorder(tree->right);
  }
}

void preorder(node tree){
  if(tree != NIL){
    printf(" %d",tree->key);
    preorder(tree->left);
    preorder(tree->right);
  }
}

Measured memory_bytes: 24040
#include <iostream>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    int sum = 0;
    for (int i = 0; i < m; i++)
    {
        int val;
        cin >> val;
        sum += val;
    }
    if (sum > n)
        cout << "-1\n";
    else
    {
        cout << n - sum << "\n";
    }
    return 0;
}

Measured memory_bytes: 3628
def fastio():
    import sys
    from io import StringIO 
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))

n, k = I()
l = I()
ans = [MOD]*(n + 10)
ans[0] = 0
ans[1] = abs(l[1] - l[0])
for i in range(2, n):
    for j in range(max(i - k, 0), i):
        ans[i] = min(ans[i], ans[j] + abs(l[i] - l[j]))
print(ans[n-1])

Measured memory_bytes: 76460
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 5e6 + 17;

struct pt
{
	int x, y;
	pt() { }
};

int H[maxn], F[maxn], used[maxn];

struct hash_table
{
	hash_table() { }

	int getpos(int h) const
	{
		int i = h % maxn;
		for (; used[i] && H[i] != h; ++i) if (i + 1 == maxn) i = -1;
		return i;
	}

	int& operator[](int h)
	{
		int i = getpos(h);
		H[i] = h;
		used[i] = 1;
		return F[i];
	}
};

struct fenwick
{
	int n;
	hash_table F;

	fenwick() { n = inf; }

	void upd(int i, int x)
	{
		for (; i < n; i |= i + 1)
			F[i] = max(F[i], x);
	}

	int get(int i)
	{
		int res = 0;

		for (; i >= 0; i &= i + 1, --i)
			res = max(res, F[i]);

		return res;
	}
};

int n;
pt s, f;
pt p[maxn];

bool read()
{
	if (scanf("%d %d %d %d %d", &s.x, &s.y, &f.x, &f.y, &n) != 5)
		return false;

	forn (i, n)
		scanf("%d %d", &p[i].x, &p[i].y);

	return true;
}

bool cmp(pt a, pt b) { return make_pair(a.x, a.y) < make_pair(b.x, b.y); }

void solve()
{
	if (s.x > f.x)
		swap(s, f);

	if (s.y > f.y)
	{
		f.y = 2 * s.y - f.y;

		forn (i, n)
			p[i].y = 2 * s.y - p[i].y;
	}

	vector<pt> pp;

	forn (i, n)
		if (s.x <= p[i].x && p[i].x <= f.x && s.y <= p[i].y && p[i].y <= f.y)
			pp.push_back(p[i]);

	sort(pp.begin(), pp.end(), cmp);
	fenwick dp;

	forn (i, size(pp))
		dp.upd(pp[i].y, dp.get(pp[i].y) + 1);

	int lis = dp.get(inf);
	long double ans = 0;

	if (lis != min(f.y - s.y, f.x - s.x) + 1)
		ans = 100.0 * (f.y - s.y + f.x - s.x) - 20.0 * lis + 5 * M_PI * lis;
	else
		ans = 100.0 * (f.y - s.y + f.x - s.x) - 20.0 * lis + 5 * M_PI * (lis - 1) + 10 * M_PI;

	printf("%.15f\n", (double) ans);
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 62320
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();

        for (int x = 0; x <= 1000000; x++)
        {
            int t = x * 108 / 100;
            if (n == t)
            {
                Console.WriteLine(x);
                return;
            }
        }

        Console.WriteLine(":(");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

#define debug(x) cout << "> " << #x << " = " << x << endl;
#define debug_at(arr, at) cout << "> " << #arr << "[" << at << "] = " << arr[at] << endl;
#define debug_pair(p) cout << "> " << #p << " = (" << p.first << ", " << p.second << ")" << endl;

using namespace std;

typedef long long ll;

const int N = 60;
ll dp[N][N];

ll f(int n, int k) {
    if(k == 0 or k == n) return 1;
    ll &ans = dp[n][k];
    if(ans == -1) {
        ans = f(n - 1, k) + f(n - 1, k - 1);
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);

    int n, p;
    cin >> n >> p;
    int odd = 0;
    fori(i, 0, n) {
        int val;
        cin >> val;
        if(val & 1) {
            ++odd;
        }
    }
    int even = n - odd;
    ll two = 1LL << even;
    ll ans = 0;
    memset(dp, -1, sizeof dp);

    if(p) {
        for(int i = 1; i <= odd; i += 2) {
            ans += (f(odd, i) * two);
        }
    }
    else {
        for(int i = 0; i <= odd; i += 2) {
            ans += (two * f(odd, i));
        }
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define mod 998244353
#define maxn 100010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
char s[3*maxn];
int n;
int main()
{
	n=read();
	scanf("%s",s);
	int cntr=0,cntg=0,cntb=0;
	ll ans=1;
	for(int i=0;i<3*n;i++){
		int A=cntr,B=cntg,C=cntb;
		if(A<B)std::swap(A,B);
		if(A<C)std::swap(A,C);
		if(B<C)std::swap(B,C);
		if(s[i]=='R'){
			if(cntr==A)ans=ans*(n-A)%mod;
			else if(cntr==B)ans=ans*(A-B)%mod;
			else ans=ans*(B-C)%mod;
			++cntr;
		}
		else if(s[i]=='G'){
			if(cntg==A)ans=ans*(n-A)%mod;
			else if(cntg==B)ans=ans*(A-B)%mod;
			else ans=ans*(B-C)%mod;
			++cntg;
		}
		else if(s[i]=='B'){
			if(cntb==A)ans=ans*(n-A)%mod;
			else if(cntb==B)ans=ans*(A-B)%mod;
			else ans=ans*(B-C)%mod;
			++cntb;
		}
	}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main()
{
	long long n,m,x,total=0,sum=0;
	cin>>n>>m>>x;
	long long a[m];
	for (int i=1;i<=m;i++)  cin>>a[i];
	for (int i=1;i<=n;i++)
	{
		sum=0;
		long long b[m];
		for (int j=1;j<=m;j++)
		{
			cin>>b[j];
			sum+=b[j]*a[j];
		}  
		sum+=x;
		if (sum>0)  total++;
	}
	cout<<total<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

Int digsum(Int N){
    Int res = 0;
    while(N > 0){
        res += N % 10;
        N /= 10;
    }
    return res;
}
int main(){
    Int N; cin >> N;
    Int S = digsum(N);

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

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

int n;
int MAXIMUM=100;
int M[100][100];
int INF = 123456789;
// W:未訪問
// G:訪問する候補
// B:訪問済み
int W=0,G=1,B=2;
int dijkstra(){
  int u,minv;
  int d[MAXIMUM],color[MAXIMUM];
  // d[n]:Tに属する頂点と V - T に属する頂点をつなぐ辺の中で重みが最小の辺の重みを記録
  // p[i]: 頂点iからコスト最小となる親の頂点
  //初期化
  for(int i=0;i<n;i++){
    d[i]=INF;
    color[i]=W;
  }

  d[0]=0;
  color[0] = G;

  while (1) {
    minv = INF;
    u = -1;
    //訪問済みでない頂点の中で最もコストが低い辺を探す
    for(int i=0;i<n;i++){
      if(minv>d[i] && color[i]!=B){
        u=i;
        minv=d[i];
      }
    }
    // 頂点が見つからなかったら終了
    if(u==-1) break;
    // 頂点を訪問済に
    color[u] = B;
    //訪問済みでないかつ辺がつながっている頂点の中でコストが最小の辺を選択
    for(int v=0;v<n;v++){
      if(color[v]!=B && M[u][v]!=INF){
        if(d[v]>M[u][v] + d[u]){
          d[v] =M[u][v]+d[u];
          color[v]=G;
        }
      }
    }
  }

  for(int i=0;i<n;i++){
    if(d[i]!=INF) cout<<i<<" "<<d[i]<<endl;
    else cout<<i<<" "<<-1<<endl;
  }
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      M[i][j]=INF;
    }
  }

  for(int i=0;i<n;i++){
    int u,k;
    cin>>u>>k;
    for(int j=0;j<k;j++){
      int v,c;
      cin>>v>>c;
      M[u][v]=c;
    }
  }

  dijkstra();

}



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

int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
  
  	int ans = 0;
	int total = X - Z;
  
  	while(total >= Y + Z){
      total -= Y + Z;
      ans ++;
    }
cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		double D = scanner.nextDouble();
		double T = scanner.nextDouble();
		double S = scanner.nextDouble();
		
		scanner.close();
		
		double tmp = D / S;
		
		if (tmp <= T) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 28764
#include <stdio.h>
int main(){
    int n,now,k,top=0;
    char a[1000],temp[1000];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
    for(int j=0;j<1000;j++)a[j]=temp[j]='\0';
    for(int m=0;m<2;m++){
       scanf("%s",temp);
        top=k=now=0;
        while(temp[now]!='\0')now++;
        for(int j=now-1;j>=0;j--){
            if(a[now-j-1]=='\0')a[now-j-1]+='0';
            a[now-j-1]+=temp[j]+k-'0';
            k=0;
            if(a[now-j-1]-'0'>9){
                a[now-j-1]-=10;
                k++;
            }
        }
        while(k!=0){
            if(a[now]=='\0')a[now]+='0';
            a[now]+=k;
            k=0;
            if(a[now]-'0'>9){
                a[now]-=10;
                k++;
            }
            now++;
        }
        }
        while(a[top]!='\0')top++;
        if(top>80)printf("overflow\n");
        else{
            for(int i=top-1;i>=0;i--)printf("%c",a[i]);
            printf("\n");
        }
    }
    }

Measured memory_bytes: 2508
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll dp[60][60][2600];  // dp[i+1][j][k] : i番目(iは0-index)まででj枚選んで合計kになる選び方の数

int main() {
    ll n, a;
    cin >> n >> a;
 
    vl x(n);
    ll sum = 0;
    rep(i, n) {
        cin >> x[i];
        sum += x[i];
    }
 
    dp[0][0][0] = 1;
    rep(i, n) {
        rep(j, n+1) {
            rep(k, sum+1) {
                dp[i+1][j][k] += dp[i][j][k];
                if(j >= 1 && k >= x[i]) {
                    dp[i+1][j][k] += dp[i][j-1][k - x[i]];
                }
            }
        }
    }
    
    ll ans = 0;
    exrep(j, 1, n) {
        if(j*a <= sum) {
            ans += dp[n][j][j*a];
        }
    }
 
    out(ans);
    re0;
}

Measured memory_bytes: 62464
#S=input()
#N=int(input())
H,W=map(int,input().split())
a=[]
for i in range(H):
    ai=input()
    if ai=="."*W:
        continue
    a.append(ai)
h=len(a)
def tenti(a):
    b=[]
    h=len(a)
    w=len(a[0])
    for i in range(w):
        bi=[]
        for j in range(h):
            bi.append(a[j][i])
        b.append(bi)
    return b
b=tenti(a)
h=len(b)
w=len(b[0])
c=[]
for i in range(h):
    if b[i]==["."]*w:
        continue
    c.append(b[i])
d=tenti(c)
for i in range(len(d)):
    for j in range(len(d[0])):
        if j==len(d[0])-1:
            print(d[i][j])
            break
        print(d[i][j],end="")
    

Measured memory_bytes: 43240
#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 rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define lli long long int
#define pii pair<int,int>
#define vii vector<pii>
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v)  v.begin(),v.end()
#define mod 1000000007
#define vi vector<int>
#define vl vector<lli>
#define vll vector<pair<lli,lli>>
#define pll pair<lli,lli>
#define vvi vector<vector<int>>
#define vvl vector<vector<lli>>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define tk(args...) take(args);
#define posLSB(X) __builtin_ctz(X)
#define num1bit(X) __builtin_popcount(X)
#define numlead0(X) __builtin_clz(X)
#define umreserve(X) X.reserve(32768); X.max_load_factor(0.25);
void err(istream_iterator<string> it) {} template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cout << *it << " = " << a << "\n"; err(++it, args...);}
void take() {} template<typename T, typename... Args> void take( T & a, Args & ... args ) { cin>>a; take(args...); }
template<class T>
void printvec(vector<T> &a){
	for(T &x:a){
		cout<<x<<" ";
	}
	cout<<endl;
}
template<class T>
void printarr(T a[],lli n){
	for(lli i=0;i<n;i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};

#define endl "\n"

lli add(lli a, lli b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

lli mul(lli a, lli b) {
	return a * 1ll * b % mod;
}

inline bool setmin(lli &x, lli y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(lli &x, lli y) { return (y > x) ? x = y, 1 : 0; }

lli power_mod(lli a,lli x){if(x==0) return 1;lli y=power_mod(a,x/2);lli ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
lli inv(lli a){return power_mod(a,mod-2);}
lli power(lli a, lli x){ if(x==0) return 1; lli y= power(a,x/2); lli ans=(y*y); if(x%2) ans*=a; return ans;}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<vector<int>> c(10,vector<int>(10));
	for(int i=0;i<=n;i++){
		int d=i%10;
		int z=i;
		while(z>=10){
			z/=10;
		}
		c[z][d]++;
	}
	lli ans=0;
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			ans+=c[i][j]*c[j][i];
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
#N = I()
#A = [LI() for _ in range(N)]

a, b = LI()

if a > 0:
    print('Positive')
elif a <= 0 and b >= 0:
    print('Zero')
else:
    if (a+b)%2 == 0:
        print('Negative')
    else:
        print('Positive')

Measured memory_bytes: 12196
#include <bits/stdc++.h>
using namespace std;
 
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;
 
#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
 
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
 
struct E{
  int l, r;
  LL ld, rd, w;
 
  E(){}
  E(int l, int r, LL ld, LL rd) :
	l(l), r(r), ld(ld), rd(rd), w(0)
  {
  }
};
 
LL gcd(LL x, LL y){
  return (y==0? x: gcd(y, x%y));
}
LL lcm(LL x, LL y){
  return x / gcd(x, y) * y;
}
 
void dfs(vector<E>& G, int u){
  if(G[u].l != -1) dfs(G, G[u].l);
  if(G[u].r != -1) dfs(G, G[u].r);
 
  LL wl = (G[u].l == -1? 1: G[G[u].l].w);
  LL wr = (G[u].r == -1? 1: G[G[u].r].w);
  LL lm = lcm(G[u].ld * wl, G[u].rd * wr);
  G[u].w = lm / G[u].ld + lm / G[u].rd;
}
 
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
 
  int N;
while(
  cin >> N,N){
  vector<E> G;
  REP(i,N){
	int c, d;
	LL a, b;
	cin >> a >> b >> c >> d;
	LL g = gcd(a, b);
	--c;
	--d;
	G.EB(c,d,a/g,b/g);
  }
 
  vector<bool> used(N);
  REP(i,N){
	if(G[i].l != -1) used[G[i].l] = true;
	if(G[i].r != -1) used[G[i].r] = true;
  }
  int rt = -1;
  REP(i,N) if(!used[i]) rt = i;
 
  dfs(G, rt);
  cout << G[rt].w << endl;
 }
  return 0;
}

Measured memory_bytes: 3152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

			String in = br.readLine();
			String chr[] = in.split("");
			String inp = br.readLine();
			String chrp[] = inp.split("");
			System.out.println(chr[0].equals(chrp[2])
							  &&chr[2].equals(chrp[0])
							  &&chr[1].equals(chrp[1])?"YES":"NO");

		}
	}
}

Measured memory_bytes: 25456
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()

bool power10(int num) {
    int p = 10;
    while (num > p)
        p *= 10;
    return num == p;
}

int sum_digit(int num) {
    int ret = 0;
    while (num > 0) {
        ret += num % 10;
        num /= 10;
    }
    return ret;
}

int main() {
    int N, A[100001] = {};
    cin >> N;

    if (power10(N)) cout << 10 << endl;
    else cout << sum_digit(N) << endl;
    return 0;
}

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

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

void code() {
    int n;
    cin>>n;
    int ans1=0, ans2=0, ans3=0, ans4=0;
    vector<string> A(n);
    for(int i=0; i<n; i++) {
        cin>>A[i];
        if(A[i]=="AC")
            ans1++;
        if(A[i]=="WA")
            ans2++;
        if(A[i]=="TLE")
            ans3++;
        if(A[i]=="RE")
            ans4++;
    }

    cout << "AC x " << ans1 << "\n";
    cout << "WA x " << ans2<< "\n";
    cout << "TLE x " << ans3 << "\n";
    cout << "RE x " << ans4 << "\n";
}

signed main() {
    std::ios_base::sync_with_stdio(false);
    int t=1;
    for(int i=0; i<t; i++) {
        code();
    }
}


Measured memory_bytes: 6428