akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.Deque;
import java.util.ArrayDeque;

public class Main {
    public static void main(String[] args) 
    {
        Scanner scanner = new Scanner(System.in);
        Deque<Integer> stack = new ArrayDeque<>();
        int mochi_num = Integer.parseInt(scanner.nextLine());
        
        for(int i = 0; i < mochi_num; i++)
        {
            int mochi_size = Integer.parseInt(scanner.nextLine());
            if(!stack.contains(mochi_size))
            {
                stack.offer(mochi_size);
            }
        }
        
        System.out.println(stack.size());
    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if (a > b) {
    swap(a, b);
  }
  if (b > c) {
    swap(b,c);
  }
  if (a > b) {
    swap(a, b);
  }
  printf("%d %d %d\n", a, b, c);
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    long long a,b,c,d;
    cin >>a >>b >>c;
    if(a%2==0||b%2==0||c%2==0){
        cout << 0;return 0;
    }
    d =a*b;b*=c;c*=a;
    cout << min(min(d,b),min(b,c));
}




Measured memory_bytes: 3652
# Vi-Ci> 0である限り足していく
inputs = [input() for i in range(3)]
N = int(inputs[0])
V = inputs[1].split()
C = inputs[2].split()

TR = 0
for i in range(0,N):
    R = int(V[i]) - int(C[i])
    if R > 0:
        TR = TR + R

print(TR)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 long long int  div(long long int a,long long int b,long long int x)
{
    if (a%x==0) 
        return (b / x) - (a / x) + 1; 
    return (b / x) - (a / x); 
}

int main(){
    long long a,b,x,y;
    cin>>a>>b>>x;
    div(a,b,x);
    cout<<div(a,b,x)<<endl;
    return 0;
}


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

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

    vector <int> va_list(N),va_list2(N);

    for (int i = 0; i < N; i++) {
        cin >> va_list.at(i);
    }

    va_list2 = va_list;

    sort(va_list2.begin(),va_list2.end());
    int K, L, M;
    L = va_list2.at((N-1)/2);
    M = va_list2.at((N+1)/2);
    K = (L + M)/2;


    for (int i = 0;i < N; i++) {
        if(va_list.at(i) <= K) {
            cout << M << endl;
        }
        else {
            cout << L << endl;

        }
    }
}






Measured memory_bytes: 3712
#include<iostream>
#include<string>
using namespace std;
int main() {
	string S;
	cin >> S;
	if (S[0] == S[1] || S[1]==S[2]||S[2]==S[3]) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define MAX 101

void initialize(void);
int isEmpty(void);
int isFull(void);
void push(int);
int pop(void);

int top;
int S[MAX];
int main(){
  char s[300];
  int num=0,b=0,c=0,d=0;
  initialize();
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      b=pop();
      c=pop();
      d=c+b;
      push(d);
    }
    else if(s[0]=='-'){
      b=pop();
      c=pop();
      d=c-b;
      push(d);
    }
    else if(s[0]=='*'){
      b=pop();
      c=pop();
      d=c*b;
      push(d);
    }
    else{
      num=atoi(&s[0]);
      push(num);
    }
  }
  printf("%d\n",S[top]);
  
  return 0;
}

void initialize(void){
  top = 0;
}

int isEmpty(void){
  if(top == 0){
    return 1;
  }
  else return 0;
}

int isFull(void){
  if(top >= MAX-1){
    return 1;
  }
  else return 0;
}

void push(int x){
  if(isFull()==1){
    fprintf(stderr,"Over\n");
  }
  else{
    top++;
    S[top] = x;
  }
}

int pop(void){
  if(isEmpty()==1){
    fprintf(stderr,"Under\n");
  }
  else{
    top--;
    return S[top+1];
  }
}



Measured memory_bytes: 2084
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int ind = S.indexOf("ABC");
		int cnt = 0;
	    while(ind >= 0){
			++cnt;
			ind = S.indexOf("ABC", ind + 1);			
		}
	    System.out.println(cnt);
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,t,p;
    cin>>n;
    p=n;
    for(i=2;i<=p/2 ;i++){
        if(p%i==0){
            i=2;p++;
        }
    }
    cout<<p<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<algorithm>
int g[101][101],a[1000],b[1000],c[1000];
int const infty=10000000;
int main(){
  int n,m,answer=0;
  scanf("%d%d",&n,&m);
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      g[i][j]=infty;
    }
  }
  for(int i=0;i<m;i++){
  // コピペでfastest取ったら嫌なので
  std::cin >> a[i] >> b[i] >> c[i];
    g[a[i]][b[i]]=g[b[i]][a[i]]=c[i];
  }
  for(int k=1;k<=n;k++){
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
        g[i][j]=std::min(g[i][k]+g[k][j],g[i][j]);
      }
    }
  }
  for(int i=0;i<m;i++){
    bool use=false;
    for(int j=1;j<=n;j++){
      if(j==a[i]||j==b[i]){
        if(c[i]==g[a[i]][b[i]])use=true;
      // }else if(g[a[i]][j]==c[i]+g[b[i]][j])use=true;
      }
    }
    if(!use)answer++;
  }
  printf("%d",answer);
  return 0;
}


Measured memory_bytes: 256
local N, M = io.read("n", "n")
local lmax = 0
local rmin = math.floor(10^5)
for i=1, M do
    local l, r = io.read("n", "n")
    lmax = math.max(lmax, l)
    rmin = math.min(rmin, r)
end
local n = rmin - lmax + 1
if n < 0 then n = 0 end
print(n)


Measured memory_bytes: 888
s = input()
n = len(s)
k = int(input())

if len(set(s)) == 1:
    print(n * k // 2)

else:
    memo = []
    tmp = 1
    for i in range(n-1):
        if s[i] == s[i+1]:
            tmp += 1
        else:
            memo.append(tmp)
            tmp = 1
    memo.append(tmp)
    m = len(memo)

    if s[0] == s[-1]:
        ans = 0
        for i in range(m):
            if i == 0 or i == m-1:
                ans += memo[i] // 2
            else:
                ans += (memo[i] // 2) * k
        ans += ((memo[0] + memo[-1]) // 2) * (k-1)

    else:
        ans = sum(memo[i] // 2 for i in range(m)) * k

    print(ans)

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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair
using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  REP(i, a+1){
    REP(j, b+1){
      REP(k, c+1){
        int val = 500*i + 100*j + 50*k;
        if (val == x) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3600
import sys
class Dice:
    def __init__(self):
        self.front = '1'
        self.back = '6'
        self.top = '5'
        self.bottom = '2'
        self. right = '3'
        self.left = '4'
    def turnRight(self):
        temp = self.top
        self.top = self.left
        self.left = self.bottom
        self.bottom = self.right
        self.right = temp
        return self.top
    def turnLeft(self):
        temp = self.top
        self.top = self.right
        self.right = self.bottom
        self.bottom = self.left
        self.left = temp
        return self.top
    def turnFront(self):
        temp = self.top
        self.top = self.back
        self.back = self.bottom
        self.bottom = self.front
        self.front = temp
        return self.top
    def turnBack(self):
        temp = self.top
        self.top = self.front
        self.front = self.bottom
        self.bottom = self.back
        self.back = temp
        return self.top
    def __eq__(self, other):
        return (self.top, self.bottom, self.front, self.back, self.right, self.left) == other
    def __ne__(self, other):
        return (self.top, self.bottom, self.front, self.back, self.right, self.left) != other
def judge(obj1, obj2):
    if obj1 == obj2:
        print('Yes')
        sys.exit()
    else:
        return

A = Dice()
B = Dice()
A.top, A.front, A.right, A.left, A.back, A.bottom = input().split()
B.top, B.front, B.right, B.left, B.back, B.bottom = input().split()

for rot1 in range(4):
    for rot2 in range(4):
        judge(A, B)
        B.turnRight()
    B.turnFront()
B.turnRight()
B.turnFront()
for rot in range(4):
    judge(A,B)
    B.turnRight()
B.turnBack()
B.turnBack()
for rot in range(4):
    judge(A,B)
    B.turnRight()
print('No')

    

Measured memory_bytes: 7648
// AOJ ITP1_11_C Dice III
// 2018.5.2 bal4u

#include <stdio.h>
#include <string.h>

int rot[24][7] = {
	{ 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
	{ 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
	{ 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
	{ 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
	{ 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
	{ 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };
int assign[7];
char f[102];

int identical(int a[7], int b[7])
{
	int i, j;
	memset(f, 0, sizeof(f));
	for (i = 1; i <= 6; i++) f[a[i]]++;
	for (i = 1; i <= 6; i++) f[b[i]]--;
	for (i = 1; i <= 6; i++) if (f[b[i]]) return 0;

	for (j = 0; j < 24; j++) {
		if (b[1] == a[rot[j][1]]) {
			for (i = 2; ; i++) {
				if (i > 6) return 1;
				if (b[i] != a[rot[j][i]]) break;
			}
		}
	}
	return 0;
}

int main()
{
	int i;
	int a[7], b[7];

	for (i = 1; i <= 6; i++) scanf("%d", a+i);
	for (i = 1; i <= 6; i++) scanf("%d", b+i);
	puts(identical(a, b)? "Yes": "No");
	return 0;
}



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

int main() {
  int N, j=0;
  cin >> N;
  vector<int> p(N);
  for(int i=0; i<N; i++) {
    int a;
    cin >> a;
    p[i] = a;
  }
  for (int i=0; i<N; i++) {
    if((i+1)!=p[i])
      j++;
  }
  cout << (j<3?"YES":"NO") << endl;
}



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

int main() {
  int K, N;
  cin >> K >> N;
  vector<int> data(N);
  
  int b = 0;
  int x;
  for(int i=0;i<N;i++){

    cin >> x;
    data.at(i) = x - b;
    b = x;
  }
  
  data.at(0) += K - x;
 
  int sum = 0;
  int max = 0;
  for(int i =0;i<N;i++){
    sum += data.at(i);
    if (max < data.at(i)) {
      max = data.at(i);
    }
  }
  
  cout << sum - max << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 0x7ffffff;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	int ans = 0;
	while (1) {
		bool elf = false;
		bool flag = false;
		rep(i, n) {
			if (h[i] > 0) {
				flag = true;
				h[i]--;
				elf = true;
			}
			else {
				if (flag) ans++;
				flag = false;
			}
		}
		if (flag) ans++;
		if (!elf) break;
	}
	cout << ans << endl;
	return 0;
}


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

#define pb push_back
#define mp make_pair
#define ll long long int
int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);    

 	ll n;
 	cin >> n;
 	ll ans = (n*(n-1))/2;
 	cout << ans << endl;   

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//入力表示
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if(A>=13) {
		System.out.println(B);
		}else if (A<=12 && A>=6){
			System.out.println(B/2);
		}else{
			System.out.println(0);
		}
	}
}

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

ans = 0
if N == 1 and M == 1:
    ans = 1
elif N == 1:
    ans = M - 2
elif M == 1:
    ans = N - 2
else:
    ans = (N - 2) * ( M - 2)
print(ans)


Measured memory_bytes: 2940
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
        int i,v;
        for(;;){
            int h = scan.nextInt();
            int w = scan.nextInt();
            if(h == 0 && w == 0)
                break;
            for(i = 1; i <= h; ++i){
              for(v = 1; v <= w; ++v){
                  System.out.print("#");
                }
                  System.out.println("");
                }
                System.out.println("");
              }
  }
}

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void chmax(string &s, string &t) {
    if (s == "a" || s.size() < t.size()) {
        s = t;
        return;
    } else if (s.size() > t.size()) {
        return;
    }
    for (int i = 0; i < s.size(); i++) {
        if (s[i] < t[i]) {
            s = t;
            return;
        } else if (s[i] > t[i]) {
            return;
        }
    }
}

void solve() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    vector<int> C = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    for (int i = 0; i < M; i++) {
        cin >> A[i];
    }
    vector<string> dp(N + 1, "a");
    dp[0] = "";
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (dp[i] == "a") continue;
            if (i + C[A[j]] <= N) {
                string t = dp[i] + (char)('0' + A[j]);
                chmax(dp[i + C[A[j]]], t);
            }
        }
    }
    cout << dp[N] << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 37632
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		try {
			int x = scan.nextInt();
			x = x*x*x;
			System.out.println("" + x + "");
		} catch (InputMismatchException e) {
			System.out.println("??¨??????");
		}
	}
}
                      

Measured memory_bytes: 26340
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  ll n; cin >> n;
  ll ans = 0;
  for (int i=1; i<=n; i++) {
    for (int j=1; i*j<=n; j++) {
      ans += i*j;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624
import math

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

v = [i+1 for i in range(N)]

p = 0
for i in range(N):
  p += v.index(P[i]) * math.factorial(N-i-1)
  v.remove(P[i])

v = [i+1 for i in range(N)]

q = 0
for i in range(N):
  q += v.index(Q[i]) * math.factorial(N-i-1)
  v.remove(Q[i])

print(abs(p-q))

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

template <typename T1, typename T2>
inline bool chmin(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(const Args&... args) const { print(args...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(const T& head, const Tail&... tail) const { std::cout << head, print_rest(tail...); }
        template <class T, class... Tail>
        void print_rest(const T& head, const Tail&... tail) const { std::cout << sep << head, print_rest(tail...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

template <typename T>
class BIT {
private:
    int n;
    std::vector<T> vec;

public:
    BIT(int n) : n(n), vec(n + 1) {}
    void add(int i, const T& a) {
        for (++i; i <= n; i += i & (-i)) {
            vec[i] += a;
        }
    }
    T query(int i) const {
        T res = 0;
        for (; i >= 1; i -= i & (-i)) {
            res += vec[i];
        }
        return res;
    }
    T query(int i, int j) const {
        return query(j) - query(i);
    }
    size_t size() const noexcept {
        return n;
    }
    void reset() noexcept {
        std::fill(vec.begin(), vec.end(), static_cast<T>(0));
    }
};

void solve() {
    int N, Q;
    cin >> N >> Q;
    BIT<ll> fwt(N);
    for (ll i = 0; i < N; i++) {
        int a;
        cin >> a;
        fwt.add(i, a);
    }
    while (Q--) {
        int q;
        cin >> q;
        if (q == 0) {
            int a, b;
            cin >> a >> b;
            fwt.add(a, b);
        }
        else {
            int a, b;
            cin >> a >> b;
            prints()(fwt.query(a, b));
        }
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(nullptr), cout.tie(nullptr);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 8260
#include <bits/stdc++.h>
#include <cstring>
#include <ctype.h>
#include<stdlib.h>

#define flin            freopen("input.txt", "r", stdin); 
#define flout           freopen("output.txt", "w", stdout);
#define ll              long long
#define ull             unsigned long long
#define fastio          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl              '\n'
#define nll             '\0'
#define pb              push_back
#define bdyptb          return 0;
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define all(x)          x.begin(), x.end()
#define mset(a, b)      memset(a, b, sizeof(a));
#define testcase        ll t,tt; cin>>tt; for(t=1;t<=tt;t++)

#define pi acos(-1.00)   
#define mx 1000007

using namespace std;

int main()
{
    fastio;
    int n;
    cin>>n;
    int v[n],c[n];

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

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

    ll ans=0;
    
    for(int i=0; i<n; i++)
    {
        if(v[i]>c[i])ans+=v[i]-c[i];
        
    }

    cout<<ans<<nl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define _Pi 3.1415926535
using namespace std;
typedef long long ll;

int main(){
    int x,a,b;
    cin >> x >> a >> b;
    cout << (x-a)%b << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    string s;
    cin>>s;
    /*
    考察
    ・端が同一の文字の場合
    決着がつくときは奇数長の文字列しかありえない
    abaだとかaxaxaみたいなのしかありえない
    ABABABAB...Aみたいな構成以外だと絶対にとれるところがある
    左から全部三つ組みを作っていくんだけどその最初と最後が同じじゃなければそこからとれるので
    このことがいえる。
    片方のプレイヤーがこの盤面にして相手に渡せば勝ちなので初期盤面の長さの偶奇で勝敗が決まるもんだと思っていた

    ・端が同一の文字じゃない場合
    決着がつくときは逆にこっちは偶数長の文字列になる
    ababababとかabみたいな
    これもさっきと同じ理屈でこれが正しいと考えられる

    偶奇が勝敗を決するから
    お互い戦略的にやっても脳死でとれるところを取り続けても結果は変わらないと思うんだが

    じゃあなんでACじゃないんでしょうねぇ～～ちくしょ～～～～ｗｗｗｗ
    */
    if(s[0]==s[s.size()-1]){
        if(s.size()%2==0){
            cout<<"First"<<endl;
        }
        else{
            cout<<"Second"<<endl;
        }
    }
    else{
        if(s.size()%2){
            cout<<"First"<<endl;
        }
        else{
            cout<<"Second"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <climits>
#include <algorithm>

#define lson l, m, o << 1
#define rson m + 1, r, o << 1 | 1

const int N = 1e5 + 1;

int mn[N << 2];
int lazy[N << 2];

void up(int o) {
  mn[o] = std::min(mn[o << 1], mn[o << 1 | 1]);
}

void down(int o) {
  if (lazy[o] != -1) {
    mn[o << 1] = lazy[o];
    mn[o << 1 | 1] = lazy[o];
    lazy[o << 1] = lazy[o];
    lazy[o << 1 | 1] = lazy[o];
    lazy[o] = -1;
  }
}

void build(int l, int r, int o) {
  lazy[o] = -1;
  if (l == r) {
    mn[o] = INT_MAX;
    return;
  }
  int m = (l + r) >> 1;
  build(lson);
  build(rson);
  up(o);
}

void modify(int v, int L, int R, int l, int r, int o) {
  if (L <= l && R >= r) {
    lazy[o] = v;
    mn[o] = v;
    return;
  }
  down(o);
  int m = (l + r) >> 1;
  if (L <= m) modify(v, L, R, lson);
  if (R > m) modify(v, L, R, rson);
  up(o);
}

int query(int L, int R, int l, int r, int o) {
  if (L <= l && R >= r) {
    return mn[o];
  }
  down(o);
  int m = (l + r) >> 1;
  int res = INT_MAX;
  if (L <= m) res = std::min(res, query(L, R, lson));
  if (R > m) res = std::min(res, query(L, R, rson));
  return res;
}

int main() {
  int n, q;
  while (std::cin >> n >> q) {
    build(1, n, 1);
    while (q --) {
      int op;
      std::cin >> op;
      if (op == 0) {
        int l, r, v;
        std::cin >> l >> r >> v;
        l ++;
        r ++;
        modify(v, l, r, 1, n, 1);
      } else {
        int l;
        std::cin >> l;
        l ++;
        std::cout << query(l, l, 1, n, 1) << std::endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 5152
n = int(input())
s = input()
ans = 0
for d in range(1, n):
    count = 0
    for i in range(n-d):
        if s[i] == s[i+d]:
            count += 1
        else:
            count = 0
        ans = max(min(count, d), ans)
print(ans)


Measured memory_bytes: 42604
#C
mod=10**9+7
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
def f(x):
    b=1
    c=1
    if x==1 or x==0:
        return 1
    else:
        for i in range(x-1):
            b,c=(b+c)%mod,b
        return b
if m>=1:
    s=f(a[0]-1)
    for i in range(1,m):
        if a[i]-a[i-1]==1:
            print(0)
            break
        s=(s*f(a[i]-a[i-1]-2))%mod
    else:
        s=(s*f(n-a[m-1]-1))%mod
        print(s)
else:
    print(f(n))

Measured memory_bytes: 49112
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;


#include <math.h> 


int main() {



	char a;
	cin >> a;

	if (a > 90) {
		
		cout << 'a';
	}
	else {

		cout << 'A';

	}
	return 0;



}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
    x=0;char c=getchar();bool f=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return  x;
}
template<class t> inline void write(t x){
    if(x<0){putchar('-'),write(-x);}
    else{if(x>9)write(x/10);putchar('0'+x%10);}
}


int n;
map<int,int> a;



signed main(){
	read(n);
	for(int i=1,x;i<=n;i++){
		read(x);
		if(a[x]){
			puts("NO");
			return 0;
		}
		a[x]=1;
	}
	puts("YES");
}


Measured memory_bytes: 9600
/*Bismillahir Rahmanir Rahim*/



#include<bits/stdc++.h>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#define ll long long int
#define dd double
using namespace std;

int main()
{
   ll n,i,j,sum=0;
   cin>>n;
   for(i=1;i<=n;i++)
   {
      for(j=i;j<=n;j+=i)
      {
         sum+=j;
      }
   }
   cout<<sum<<endl;
}
//Apna Time Aayega :)

Measured memory_bytes: 3616
use std::io;
fn solve(a: usize, b: usize) -> usize {
    let q = (b - 1) / (a - 1);
    if q * (a - 1) < b - 1 {
        q + 1
    } else {
        q
    }
}

#[test]
fn test_solve() {
    assert_eq!(solve(4, 10), 3);
    assert_eq!(solve(8, 9), 2);
    assert_eq!(solve(8, 8), 1);
    assert_eq!(solve(8, 1), 0);
}

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let mut iter = input.split_whitespace();
    let a: usize = iter.next().unwrap().parse().unwrap();
    let b: usize = iter.next().unwrap().parse().unwrap();
    println!("{}", solve(a, b))
}


Measured memory_bytes: 4352
#include <cstdio>
using namespace std;
int N;
long long int a[100001];
long long int b[100001];
long long int ans=0;
int main(){
  scanf("%d",&N);
  for(int i=0;i<N;i++)scanf("%lld %lld",&a[i],&b[i]);
  for(int i=N-1;i>=0;i--){
    int x=(a[i]+ans)%b[i];
  if(x!=0)ans+=(b[i]-x);
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;



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

	if (n == 1 && m != 1) {
		cout << m * (m - 1) / 2;
	}
	else if (n != 1 && m == 1) {
		cout << n * (n - 1) / 2;
	}
	else {
		cout << m * (m - 1) / 2 + n * (n - 1) / 2;
	}
}


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

int N, K;
int e[3][100000];
vector<int> v[100000];

void solve_r(int vi, int c)
{
    int ci = 0;
    for(auto ei:v[vi]){
        if(ci == c){
            ci++;
        }
        if(e[2][ei] == -1){
            e[2][ei] = ci;
            if(e[0][ei] == vi){
                solve_r(e[1][ei], ci);
            } else {
                solve_r(e[0][ei], ci);
            }
            ci++;
        }
    }
}

void solve()
{
    int ci = 0;
    for(auto ei:v[0]){
        if(e[2][ei] == -1){
            e[2][ei] = ci;
            if(e[0][ei] == 0){
                solve_r(e[1][ei], ci);
            } else {
                solve_r(e[0][ei], ci);
            }
            ci++;
        } else {
            abort();
        }
    }
}

int main()
{
    cin >> N;
    for(int i=0; i<N-1; i++){
        cin >> e[0][i] >> e[1][i];
        e[0][i] -= 1;
        e[1][i] -= 1;
        e[2][i] = -1;
        v[e[0][i]].push_back(i);
        v[e[1][i]].push_back(i);
    }

    K = 0;
    for(int i=0; i<N; i++){
        K = max((unsigned long)K, v[i].size());
    }

    solve();
 
    cout << K << endl;
    for(int i=0; i<N-1; i++){
        cout << e[2][i]+1 << endl;
    }

	return 0;
}


Measured memory_bytes: 8832
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define C                  31
#define mod              1000000007
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  150
#define tmod             998244353
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<ll> &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
//bool P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n);

int main()
{
fast;
ll q=1,t;
//cin >> q;
while(q--)
{
    ll n,m,k,i,j,l,r,c=1,g,counter=0,u,v,d,e,p,x,y,flag=1;
    //n=m=i=j=l=r=a=t=b=c=u=v=w=p=x=y=0;
    cin >> k >> n; 
    vector<ll> A(n); CIN(A,0,n);
    ll ans = 0;
    for(i=0;i<n-1;i++) ans = max(ans,A[i+1]-A[i]);
    ans = max(ans,k-A[n-1] + A[0]);
    ans = k-ans;
    cout << ans;
    
}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}
/*
void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                P[j]=false;
            }
        }
    }

}

*/

Measured memory_bytes: 1792
n = int(input())
input_s = input()

final_ans = 0
temp_ans = 0
for s in input_s:

    if   s == 'I':
        temp_ans += 1
    elif s == 'D':
        temp_ans -= 1
    if final_ans < temp_ans:
        final_ans = temp_ans

print(final_ans)

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

vector<ll> a, b, c;
ll x, y, z, k;
vector<ll> ans0;
bool check(ll x0){
    ll ans = 0;
    rep(i, x)rep(j, y){
        if(a[i]+b[j]>x0){
            ans += z;
            continue;
        }
        ll ok = -1, ng = z;
        while(ng-ok>1){
            ll mid = (ok + ng)/2;
            if(a[i]+b[j]+c[mid]>x0)ok = mid;
            else ng = mid;
        }
        ans += ok+1;
        if(ans>=k) return false;
    }
    return ans<k;
}

void syukei(ll x0){
    rep(i, x)rep(j, y){
        ll ok = -1, ng = z;
        while(ng-ok>1){
            ll mid = (ok + ng)/2;
            if(a[i]+b[j]+c[mid]>=x0)ok = mid;
            else ng = mid;
        }
        rep(w, ok+1) ans0.push_back(a[i]+b[j]+c[w]);
    }
    sort(ans0.rbegin(), ans0.rend());
    return;
}

int main(){
    cin >> x >> y >> z >> k;
    a.resize(x); b.resize(y);c.resize(z);
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    sort(c.rbegin(), c.rend());

    ll ok = -1, ng = a[0]+b[0]+c[0]+1;

    while(ng-ok>1){
        ll mid = (ok+ng)/2;
        if(check(mid)) ng = mid;
        else ok=mid;
    }

    ans0={};
    syukei(ok);
    rep(i, k){
        cout << ans0[i] << endl;
    }
    return 0;
}

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

const ll mod = 1e9 + 7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n,m;
    cin >> n >> m;
    
    vector<ll> broken(n+1);
    rep(i,m){
        ll a;
        cin >> a;
        broken[a] = 1;
    }
    
    vector<ll> dp(n+2);
    dp[0] = 1;
    
    if(!broken[1]) dp[1] = 1;
    for(ll i = 2; i <= n; i++){
        if(broken[i]){
            dp[i] = 0;
            continue;
        }
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
int main(void){
  int a, h, x = 0;
  bool fail = false;
  cin >> h >> a;
  
  while(h>0){
    h-=a;
    x++;
  }
  cout << x << endl;
  
  return 0;
}

Measured memory_bytes: 256
/*                    */
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
lint gcd(lint a, lint b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
lint lcm(lint a, lint b) { return a * b / my::gcd(a, b); }
}  // namespace my
/*                    */

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (true) {
    c -= b;
    if (c <= 0) {
      cout << "Yes" << endl;
      break;
    }
    a -= d;
    if (a <= 0) {
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3620
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N+1];
        long[] B = new long[N];
        long result = 0;
        for(int i=0; i<=N; i++){
          A[i]=sc.nextLong();
        }
        for(int i=0; i<N; i++){
          B[i]=sc.nextLong();
        }
        for(int i=0; i<N; i++){
           long d1 = Math.min(A[i], B[i]);
           result += d1;
           A[i] -= d1;
           B[i] -= d1;
 
           long d2 = Math.min(A[i+1], B[i]);
           result += d2;
           A[i+1] -= d2;
           B[i] -= d2;
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 87604
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {
        int N;
        cin >> N;
        vector<int> A(N + 1);
        for (int i = 1; i <= N; ++i) {
            cin >> A[i];
        }

        vector<int> check(N + 1, 0);

        for (int i = N; i > 0; --i) {
            int cnt = 0;
            for (int j = 1 * i; j <= N; j += i) {
                if (check[j]) {
                    cnt++;
                }
            }
            if (cnt % 2 == A[i] % 2) {
                check[i] = 0;
            } else {
                check[i] = 1;
            }
        }
        vector<int> ans;
        for (int i = 1; i <= N; ++i) {
            if (check[i]) {
                ans.push_back(i);
            }
        }
        cout << ans.size() << endl;
        for (int i = 0; i < ans.size(); ++i) {
            cout << ans[i];
            if (i + 1 == ans.size()) {
                cout << endl;
            } else {
                cout << " ";
            }
        }
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

int h[10][10];

void solve() {
  int n; scanf("%d", &n);
  long long ans = 0;
  for (int i = 1, p = 1; i <= n; ++i) {
    if (i >= p*10) p *= 10;
    int l = i%10, f = i/p%10;
    
    ++h[f][l];
  }
  for (int i = 1; i < 10; ++i) {
    for (int j = 1; j < 10; ++j) {
      ans += (long long)h[i][j] * h[j][i];
    }
  }
  printf("%lld", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 256
H,W,M = map(int,input().split())
h = [0]*M
w = [0]*M

from collections import defaultdict
counter_h = defaultdict(int)
counter_w = defaultdict(int)

for i in range(M):
    h[i],w[i] = map(int, input().split())
    counter_h[h[i]] += 1
    counter_w[w[i]] += 1

MAX_h = max(counter_h.values())
h_list = [k for k, v in counter_h.items() if v == MAX_h]
MAX_w = max(counter_w.values())
w_list = [k for k, v in counter_w.items() if v == MAX_w]


ans = MAX_h+MAX_w
check = 0

for i in range(M):
    if counter_h[h[i]]==MAX_h and counter_w[w[i]]==MAX_w:
        check += 1

if len(h_list)*len(w_list)==check:
    ans -= 1

print(ans)


Measured memory_bytes: 218336
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <unordered_map>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin>>n;
	unordered_map<string,int> mp;
	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		sort(s.begin(),s.end());
		mp[s]+=1;
	}
	ll ans = 0;
	for(pair<string,int> p : mp) {
		ll tmp = p.second;
		ll tmp2 = (tmp*(tmp-1)/2);
		ans = (ans+tmp2);
	}
	cout << ans << endl;
}


Measured memory_bytes: 10660
#include<stdio.h>
#include<string.h>
int main()
{
	char s[8003];
	scanf("%s",s);
	int x,y;
	scanf("%d %d",&x,&y);
	int i,j,n=strlen(s);
	int v[2][2][20000];
	for(i=0;i<20000;i++)
		for(j=0;j<2;j++)
			v[0][j][i]=0;
	v[0][0][10000]=v[1][0][10000]=1;
	int k=0;
	j=0;
	int a,b=0;
	s[n]='T';
	for(i=0;i<=n;i++)
	{
		if(s[i]=='F')
			j++;
		else
		{
			for(a=0;a<20000;a++)
				v[k][1][a]=0;
			for(a=0;a<20000;a++)
			{
				if(v[k][0][a]>0)
				{
					if(b>0)
						v[k][1][a-j]=1;
					v[k][1][a+j]=1;
				}
			}
			j=0;
			for(a=0;a<20000;a++)
				v[k][0][a]=v[k][1][a];
			if(k==0)
				k=1;
			else
				k=0;
			b=1;
		}
	}
	if(v[0][0][x+10000]>0 && v[1][0][y+10000]>0)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 512
n, m = gets.split.map(&:to_i)
as = Array.new(n){ 0 }
m.times do
  a, b = gets.split.map{ |i| i.to_i - 1 }
  as[a] += 1
  as[b] += 1
end
as.each do |a|
  puts a
end


Measured memory_bytes: 1916
#include<iostream>
#include<algorithm>
using namespace std;
int a[200010];
int main()
{
    int k,n,i;cin>>k>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+1+n);
    int mmin=a[n]-a[1];
    for(i=2;i<=n;i++)
        mmin=min(mmin,a[n]-a[i]+k-a[n]+a[i-1]);
    cout<<mmin<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
 
int main(void)
{
  double x1,x2,x3,y1,y2,y3,r,xp,yp;
  int n,i;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);

    xp=((y2-y3)*(x1*x1+y1*y1)+(y3-y1)*(x2*x2+y2*y2)+(y1-y2)*(x3*x3+y3*y3))/(2*(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2)));
    yp=((x2-x3)*(x1*x1+y1*y1)+(x3-x1)*(x2*x2+y2*y2)+(x1-x2)*(x3*x3+y3*y3))/(2*(y1*(x2-x3)+y2*(x3-x1)+y3*(x1-x2)));

    r=sqrt((x1-xp)*(x1-xp)+(y1-yp)*(y1-yp));
    printf("%.3lf %.3lf %.3lf\n",xp,yp,r);
    
  }
  return 0;
}

Measured memory_bytes: 664
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int n;
	cin >> n;

  	if(n%10==9 || (n/10)%10==9){
		cout << "Yes" << endl;
    }else{
		cout << "No" << endl;
    }
	return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    for(i = 0;i < n;++i){
        cin >> a.at(i);
        sum += a.at(i);
    }
    ll ans = sum;
    ll tmp = 0;
    for(i = 0;i < n;++i){
        tmp += a.at(i);
        ll t = sum - tmp;
        ans = min(ans, abs(tmp - t));
    }
    cout << ans << endl;
    


    return 0;
}

Measured memory_bytes: 4848
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
int main(void) {
  int N,X;
  cin >> N >> X;
  vector<int> D(N+1);
  D.at(0) = 0;
  rep(i,N){
    int l;
    cin >> l;
    D.at(i+1) = D.at(i) + l;
  }
  int ans=0;
for(int i=0; i<=N; i++) {
  if(D.at(i) <=X) {
    ans++;
  }
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>

int main(void)
{
    int train[100];
    int now_train;
    int tmp = 0;
    
    while (scanf("%d", &now_train) != EOF){
        if (now_train != 0){
            train[tmp] = now_train;
            tmp++;
        }
        else {
            printf("%d\n", train[tmp - 1]);
            tmp--;
            train[tmp] = 0;
        }
    }
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007;
#define pi 3.14159265358979323846264
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vl vector <long long>
#define vpii vector <pair <int, int> >
#define ll long long
#define fi first
#define se second
int n, a[200005], k;
ll ans;
int main() {
    scanf("%d %d", &n, &k);
    for (int i=0;i<n;i++) scanf("%d", &a[i]);
    for (int i=1;i<n;i++) ans += min(a[i]-a[i-1], k);
    ans += k;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define lld long double
#define w(x) ll x;cin>>x;while(x--)
#define mod 1000000007
#define speed ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;

int main(){
    speed;
    char c; cin>>c;
    if(isupper(c))  cout<<'A'<<'\n';
    else cout<<'a'<<'\n';
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main()
{
    char c;
    cin>>c;
    switch(c)
    {
        case 'a':
            cout << "vowel";
            break;
        case 'e':
            cout << "vowel";
            break;
        case 'i':
            cout << "vowel";
            break;
        case 'o':
            cout << "vowel";
            break;
        case 'u':
            cout << "vowel";
            break;
        default:
            cout << "consonant";
    }
    return 0;
}


Measured memory_bytes: 888
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int
#define ld long double

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10
#define PI acos(-1LL)


int MOD = 1e9 + 7;

inline int mul(int a,int b,int mod=MOD){return ((a%mod)*(b%mod))%mod;}
inline int sum(int a,int b,int mod=MOD){return ((a%mod)+(b%mod))%mod;}
int power(int a,int n,int mod=MOD){int ans=1;while(n){if(n&1)ans=mul(ans,a,mod);a=mul(a,a,mod);n>>=1;}return ans;}
inline int sub(int a,int b,int mod=MOD){ return (((a) % mod)-((b) % mod) + mod) % mod; }
int inv[1000006];
void find_inverse(int m)  //m should be prime..
{
	inv[1] = 1;
	for(int i = 2; i < m; ++i)
    	inv[i] = (m - (m/i) * inv[m%i] % m) % m;
}

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	int n;
	cin>>n;

	vector<int>a(n);

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

	int ans=0;

	for(i=0;i<60;i++)
	{
		int cnt=0;
		for(j=0;j<n;j++)
		{
			if(a[j]&(1LL<<i))
			{
				cnt++;
			}
		}

		int one=cnt;
		int zero=n-cnt;

		ans=sum(ans,mul(power(2,i),mul(one,zero)));
	}

	cout<<ans<<endl;
	

}

Measured memory_bytes: 5500
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int k, a, b;
  cin >> k >> a >> b;
  if(b - a < 2) {
    cout << k+1 << endl;
    return 0;
  }

  // b - a >= 2;
  int d = k - a + 1;
  ll sum = 0;
  if(d <= 1){
    cout << k + 1 << endl;
    return 0;
  }

  if(d%2 == 0) sum = a + ((ll)(b - a) * (d/2));
  else sum =  a + ((ll)(b - a) * (d/2)) +1;

  cout << sum << endl;
  debug(sum);

  return 0;
}
/*
48518828981938099
12345678912345678
*/

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

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    vector<int> k(n);
    int count = 0;
    int i;
    for (i = 0; i < n; i++) {
      cin >> k[i];
      if (k[i] == 0) {
        count ++;
      }
    }
    sort(k.begin(), k.end());
    if (k[n - 1] < 2) {
      cout << "NA" << endl;
    } else {
      cout << n - count + 1 << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3172