akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll l,k,i;
    string s,t;
    cin>>s;
    l=s.length();
    k=0;
    for(i=0;i<(l-1)/2;i++)
    {
        if(s[i]==s[l-i-1]){;}
        else{k=1;}
    }
    for(i=0;i<(l-1)/2;i++)
    {
        t=t+s[i];
    }
    l=t.length();
    for(i=0;i<(l);i++)
    {
        if(t[i]==t[l-i-1]){;}
        else{k=1;}
    }
    if(k==0){cout<<"Yes"<<"\n";}
    else
    {
        cout<<"No"<<"\n";
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args ) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int x = scanner.nextInt();
        while(n != 0 || x != 0) {
            System.out.println(combo(1, n, 0, x, 0));
            n = scanner.nextInt();
            x = scanner.nextInt();
        }
    }

    public static int combo(int index, int n, int sum, int x, int selected){
        if(index > n + 1)
            return 0;
        else{
            if(sum == x && selected == 3)
                return 1;
            else if(sum > x)
                return 0;
            else{
                if(selected > 3)
                    return 0;
                else
                    return combo(index + 1, n, sum + index, x, selected + 1) + combo(index + 1, n, sum, x, selected);
            }
        }
    }

}



Measured memory_bytes: 26456
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int []a = new int[N];
        for(int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
        }
        scan.close();
        long ans = mergeSort(a, N, 0, N);
        System.out.println(ans);
    }
    static long merge(int []A, int n, int left, int mid, int right) {
    	int i, j, k;
        long cnt = 0;
        int n1 = mid- left;
        int n2 = right - mid;
        int[] L = new int[n1+1];
        int[] R = new int[n2+1];
        for(i = 0; i < n1; i++) {
        	L[i] = A[left + i];
        }
        for(i = 0; i < n2; i++) {
            R[i] = A[mid + i];
        }
        L[n1] = 2000000000;           
        R[n2] = 2000000000;
        i = 0;
        j = 0;
        for(k = left; k < right; k++) {
            if(L[i] <= R[j]) {
                A[k] = L[i++];
            }else {
                A[k] = R[j++];
                cnt += n1 - i;
            }
        }
        return cnt;
    }
    static long mergeSort(int []A, int n, int left, int right) {
        int mid;
        long v1, v2, v3;
        if(left + 1 < right) {
            mid = (left + right) / 2;
            v1 = mergeSort(A, n, left, mid);
            v2 = mergeSort(A, n, mid, right);
            v3 = merge(A, n, left, mid, right);
            return v1 + v2 + v3;
        }else {
            return 0;
        }
    }
}


Measured memory_bytes: 74296
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
U_MAP mp;

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

  cin >> n >> k;
  rep(i, k) {
    cin >> m;
    rep(j, m) {
      cin >> a;
      a--;
      mp[a] = 1;
    }
  }
  rep(i, n) {
    if (mp[i]) continue;
    ans++;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 3668
n = int(input())
l = []
for _ in range(n):
  x,y = map(int, input().split())
  l.append([x+y,x-y])
l.sort()

temp = l[0][0]
count = n
i = 1
for i in range(1,n):
  if temp <= l[i][1]:
    temp = l[i][0]
  else:
    temp = min(temp,l[i][0])
    count -= 1
print(count)

Measured memory_bytes: 59160
#include<string>
#include<iostream>
using namespace std;
int main(){
	string s1,s2;
	cin>>s1>>s2;
	if(s1.length()>s2.length())printf(">\n");
	else if(s1.length()<s2.length())printf("<\n");
	else{
		if(s1>s2)printf(">\n");
		else if(s2>s1)printf("<\n");
		else printf("=\n");
	}
}

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

using namespace std;

using ll = long long;

const int MX = 107;

bool solve(int n, int x, int c, int d) {
    for (int i = 0; i <= n; i++) {
        ll v = ll(c) * i + ll(-d) * (n - i);
        if (x >= v && x <= v + ll(n) * (d - c)) {
            return true;
        }
    }
    return false;
}

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (solve(n - 1, b - a, c, d)) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int a, b; cin >> a >> b;
    int ans = 0;
    if (a == b) ans = a + b;
    else ans = 2 * max(a,b) - 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,red,blue;
  string str;
  cin>>str;
  n=str.size();
  red=0;
  blue=0;
  for(int i=0; i<n; i++){
    if(str.at(i)=='0'){
      red++;
    }
    else{
      blue++;
    }
  }
  cout<<2*min(red,blue);
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n;
    cin >> n;
    vector<vector<ll>> c(10, vector<ll>(10));
    for(int i = 1; i <= n; i++){
        int x = i;
        int a = x % 10;
        if(a == 0) continue;
        while(x >= 10){
            x /= 10;
        }
        int b = x;
        c[b][a]++;
    }
    ll 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;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]

cards = Counter()
for s in S:
    cards[s] += 1
for t in T:
    cards[t] -= 1
print(max(cards.most_common()[0][1], 0))

Measured memory_bytes: 3436
#include <iostream>
#include <set>
using namespace std;
int N, M;

int main(void) {
  cin >> N >> M;
  set<int> st;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    if (st.count(a))
      st.erase(a);
    else
      st.insert(a);
    if (st.count(b))
      st.erase(b);
    else
      st.insert(b);
  }
  if (st.empty())
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


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

map <int,int> Rep;

int main(){
	int aux;
	int dif=0;
	for (int i = 0; i < 3; ++i)
	{
		scanf("%d",&aux);
		Rep[aux]++;
		if (Rep[aux]==1) dif++;
	}
	cout << dif;
	return 0;
}

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

const int N = 100100;

char s[N];
int pre[N];

bool solve() {
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  if (s[1] == '0' || s[n] == '1') return false;
  for (int i = 1; i < n; ++i) {
    if (s[i] != s[n - i]) return false;
  }
  for (int i = 1; i <= n; ++i) pre[i] = i;
  for (int i = 2; i < n - 1; ++i) {
    if (s[i] == '0') pre[i + 1] = pre[i];
  }
  for (int i = 2; i <= n; ++i) {
    if (pre[i] == i) printf("%d %d\n", pre[i - 1], i);
    else printf("%d %d\n", pre[i], i);
  }
  return true;
}

int main() {
  if (!solve()) printf("-1\n");
  return 0;
}


Measured memory_bytes: 1920
L, R = map(int, input().split())
MOD = 2019

if R - L >= MOD - 1:
    print(0)
    exit()

if L % MOD < R % MOD:
    a = [n for n in range(L % MOD, R % MOD + 1)]
elif L % MOD > R % MOD:
    a = [n for n in range(L % MOD, MOD)] + [n for n in range(R % MOD + 1)]
else:
    a = list(range(MOD))

ans = MOD - 1
for i in range(len(a)):
    for j in range(i + 1, len(a)):
        ans = min(ans, (a[i] * a[j]) % MOD)

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
#define rep(i,s,n)for(int i=s;i<n;i++)
typedef long long ll;

int main() {
	ll r, D, x; cin >> r >> D >> x;

	rep(i, 0, 10) {
		cout << r * x - D << endl;
		x = r * x - D;
	}

	return 0;
}

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

char russia[52][52];

int main(){
	int n,m;
	cin>>n>>m;
	
	int c=n*m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>russia[i][j];
			}
		}
	
	int d=0;
	for(int i=1;i<n-1;i++){
		for(int j=1;j<n-i;j++){
			
			for(int p=0;p<i;p++){
				for(int l=0;l<m;l++){
					if(russia[p][l]!='W'){d++;}
					}
				}
				
			for(int p=i;p<i+j;p++){
				for(int l=0;l<m;l++){
					if(russia[p][l]!='B'){d++;}
					}
				}
				
			for(int p=i+j;p<n;p++){
				for(int l=0;l<m;l++){
					if(russia[p][l]!='R'){d++;}
					}
				}	
				
				if(c>d){c=d;}
				d=0;
			}
		}
		cout<<c<<endl;
		return 0;
	
	}

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

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

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll INF = (1LL<<60);

int main(){

    ll n; cin >> n;
    string s; cin >> s;

    rep(i, s.size()){
        s[i] = s[i] + n;
        if(s[i]>'Z') s[i]-=('Z'-'A'+1);
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
l = gets.chomp.to_i;
r_s = gets.chomp;

def next_a(n_2, n_1, n_1_r)
s = "S"
w = "W"
o = "o"
x = "x"
  return s if n_2 == s && n_1 == s && n_1_r == o
  return w if n_2 == s && n_1 == s && n_1_r == x
  return w if n_2 == s && n_1 == w && n_1_r == o
  return s if n_2 == s && n_1 == w && n_1_r == x
  return w if n_2 == w && n_1 == s && n_1_r == o
  return s if n_2 == w && n_1 == s && n_1_r == x
  return s if n_2 == w && n_1 == w && n_1_r == o
  return w if n_2 == w && n_1 == w && n_1_r == x
end

init = ['SS','SW',"WS","WW"]
result = ""
init.each do |str|
  result = str
  (l).times do|i|
    next if i < 2
    result << next_a(result[i-2], result[i-1], r_s[i-1])
  end
  if((next_a(result[-2], result[-1], r_s[-1]) == result[0]) &&
     next_a(result[-1], result[0], r_s[0]) == result[1])
    puts result
    exit 0
  end
end

puts "-1"


Measured memory_bytes: 2556
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
using namespace std;

int main(){
  int N;cin >> N;
  vector<int>L(N);
  for (auto& l :L)cin >> l;
  sort(L.begin(),L.end());
  int x = 0;
  for (int i = 0; i < N-1; i++){
    x += L[i];
  }
  if (L[N-1] < x)cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

int main(){

 int n,k;
  cin >> n >> k;
 
  string s;
  cin >> s;
  
  if(s[k-1]=='A'){
    s[k-1]='a';
  }
  else if(s[k-1]=='B'){
    s[k-1]='b';
  }
  else if(s[k-1]=='C'){
    s[k-1]='c';
  }
 
  cout << s << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,i,j, count;
  string S;
  cin >> S;
 
  if(S=="a"){
    cout << "vowel" <<endl;
  }	
  	else{
      if(S=="i"){
        cout<< "vowel" << endl;
      }
      	else{
          if(S=="u"){
            cout<<"vowel"<<endl;
          }
          	else{
              if(S=="e"){
                cout<<"vowel"<<endl;
              }
              	else{
                  if(S=="o"){
                    cout<<"vowel"<<endl;
                  }
                  	else{
                      cout<<"consonant"<<endl;
                    }}}}}
  
}

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

int main() {
  string s;
  cin >> s;

  vector<string> words = {"dream", "dreamer", "erase", "eraser"};

  reverse(s.begin(), s.end());
  rep(i, 4) reverse(words.at(i).begin(), words.at(i).end());

  bool canCreate = true;
  int start = 0;
  while (start < s.length()) {
    bool canDivide = false;
    for (int i = 0; i < 4; i++) {
      string word = words.at(i);
      if (s.substr(start, word.length()) == word) {
        start += word.length();
        canDivide = true;
        break;
      }
    }
    if (!canDivide) {
      canCreate = false;
      break;
    }
  }

  if (canCreate) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b,c,k;
string s,t;
signed main()
{
	cin>>a;
	while(1){
		int b=sqrt(a);
		rep(i,b-1){
			if(a%(i+2)==0){
				goto kr;
			}
		}
		cout<<a;
		return 0;
		kr:;
		a++;
	}
}

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

void Main()
{
    map<int, int> m;
    for (int i = 0; i < 3; i++)
    {
        int a;
        cin >> a;
        m[a]++;
    }
    for (auto a: m)
    {
        if (a.second == 2) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


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

int main() {
  int N, K, a;
  a = 1;
  cin >> N >> K;
  for (int i=0; i<N; i++) {
   if  (a + K < a * 2)
     a += K;
   else
     a *= 2;
  }
  cout << a << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int T = scan.nextInt();
		
		int c ;
		int min_c = 0;
		int t ;
		
		
		for (int i = 0 ; i < N ;i++){
			c = scan.nextInt();
			t = scan.nextInt();
			
			if(t <= T){
				if( min_c==0 || c < min_c){
					min_c = c;
				}
			}
		}
		
		if (min_c == 0){
			System.out.println("TLE"); 
		}
		else{
			System.out.println(min_c); 	
		}
	}
}

Measured memory_bytes: 23380
#include<stdio.h>
int main(){
	int a=0,i=0,sum=0,n=0,m=100;
	for(i=0;i<4;i++){
		scanf("%d",&a);
		sum+=a;
		if(a<m){
			m=a;
		}
	}
	sum-=m;
	m=100;
	for(i=0;i<2;i++){
		scanf("%d",&a);
		sum+=a;
		if(a<m){
			m=a;
		}
	}
	sum-=m;
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 1796
#include <string.h>
#include <ctype.h>
#include <stdio.h>

int main()
{
    int c = 0;
    char W[11];
    char s[1001];
    scanf("%s", W);
    while (1)
    {
        scanf("%s", s);
        if (strcmp(s, "END_OF_TEXT") == 0)
        {
            break;
        }
        for (int j = 0; s[j] != '\0'; j++)
        {
            s[j] = tolower(s[j]);
        }
        if (strcmp(s, W) == 0)
        {
            c += 1;
        }
    }
    printf("%d\n", c);
}


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

int main()
{
    int t;
    cin>>t;
    int ac=0,tle=0,wa=0,re=0;
    string s[t];
    for(int i=0;i<t;i++){cin>>s[i];
    } 
    for(int i=0;i<t;i++)
    {
        if(s[i]=="AC")
        {
            ac++;
        }
        else if(s[i]=="WA")
        {
            wa++;
        }
        else if(s[i]=="TLE")
        {
            tle++;
        }
        else
        {
            re++;
        }
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
    return 0;
}

Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
int main() {
     int N;
     cin >> N;
     vector<int> d(N);
     for(int i = 0; i < N; i++){
          cin >> d[i];
     }
     sort(d.begin(),d.end());
     int ans = 0;
     for(int j = 0; j < N - 1; j++){
          if(d[j] != d[j+1]) ans++;
     }
     cout << ans+1 << endl;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
if a == b == c:
    if a % 2 or b % 2 or c % 2:
        print(0)
    else:
        print(-1)
else:
    ans = 0
    while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
        A = a // 2
        B = b // 2
        C = c // 2
        a = B + C
        b = A + C
        c = A + B
        ans += 1
    print(ans)

Measured memory_bytes: 3064
n=int(input())
l=[0]*10**7
s=int(n**0.7)+10
for x in range(1,s):
    for y in range(1,s-x):
        for z in range(1,s-x-y):
            l[x*x+y*y+z*z+x*y+y*z+z*x-1]+=1
for i in range(n):
    print(l[i])

Measured memory_bytes: 147952
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
using namespace std;
ll n,W,w[101],dp[101][100001],v[101];
void solve()
{
	for (int i=n-1;i>=0;i--)
		for (int j=0;j<=W;j++)
			if (j<w[i]) dp[i][j]=dp[i+1][j];
			else dp[i][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
	cout<<dp[0][W];
}
int main()
{
	cin>>n>>W;
	for (int i=0;i<n;i++) cin>>w[i]>>v[i];
	solve();
	return 0;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1e9+7
using namespace std;
typedef long long ll;
const double pi=acos(-1);

int main(){
    string s;
    cin >> s;
    int num=s.size();
    if(s[num-1]!='s') s+='s';
    else s+="es";
    cout << s << endl;
}

Measured memory_bytes: 3628
#include<cstdio>

int main(){

	int count[26];
	for(int i = 0;i < 26;i++) {
		count[i] = 0;
	}
	char s[1300];
	while(fgets(s,1300,stdin) != NULL) {
        for(int i = 0;s[i] != '\0';i++) {
            if(s[i] >= 'A' && s[i] <= 'Z') {
                count[s[i] - 'A']++;
            }
            if(s[i] >= 'a' && s[i] <= 'z') {
                count[s[i] - 'a']++;
            }
        }
	}

	for(int i = 0;i < 26;i++) {
		printf("%c : %d\n",'a' + i,count[i]);
	}
	return 0;
}


Measured memory_bytes: 2712
/*input
async layered coding
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	string s,t;
	cin>>s>>t;
	reverse(ALL(t));
	if(s==t){
		cout<<"YES\n";
	}
	else cout<<"NO";
	return 0;
}


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

const string S[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

int main() {
	string s;
	cin >> s;
	int p = 0;
	for (int i = 0; i < 7; i++) {
		if (S[i] == s) {
			p = i;
			break;
		}
	}
	cout << 7 - p << endl;
	return 0;
}

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)
#define REP(i, n, m) for (long long i = (long long)(n); i < (long long)(m); i++)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll N;
  double ps[3030], dp[3030][3030];

  void init() {
    scanf("%lld", &N);
    rep(i, N) scanf("%lf", ps+i);
  }

  void solve() {
    dp[1][0] = 1.0 - ps[0];
    dp[1][1] = ps[0];
    rep2c(i, N) {
      dp[i][0] = dp[i-1][0] * (1.0 - ps[i-1]);
      REP(j, 1, i+1) {
        dp[i][j] = dp[i-1][j-1] * ps[i-1] + dp[i-1][j] * (1.0 - ps[i-1]);
      }
    }
    double ans = 0.0;
    rep0c(i, N) if(N/2 < i) ans += dp[N][i];
    printf("%.10f\n", ans);
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 70400
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin>>a;
	if(a%10==2||a%10==4||a%10==5||a%10==7||a%10==9)
	{
		cout<<"hon";
	}
	if(a%10==0||a%10==1||a%10==6||a%10==8)
	{
		cout<<"pon";
	}
	if(a%10==3)
	{
		cout<<"bon";
	}
	return 0;
}


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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL(x) memset(x,0,sizeof(x))


using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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


char maze[110][110];

int dp[110][110];

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

  for(int i=0; i<H; i++)
    for(int j=0; j<W; j++)
      cin >> maze[i][j];

  for(int i=0; i<H; i++)
    for(int j=0; j<W; j++)
      dp[i][j]=100000;

  dp[0][0]=0;

  
  for(int i=0; i<H; i++)
    for(int j=0; j<W; j++)
      {
	if(i+1<H)
	  {
	    if(maze[i+1][j]!=maze[i][j])
	      {
		if(maze[i][j]=='.')
		  {
		    chmin(dp[i+1][j], dp[i][j]+1);
		  }
		  else
		  {
		    chmin(dp[i+1][j], dp[i][j]);
		  }	  
	      }
	    else
	      {
		chmin(dp[i+1][j], dp[i][j]); 
	      }
	  }
	
	if(j+1<W)
	  {
	    if(maze[i][j+1]!=maze[i][j])
	      {
		if(maze[i][j]=='.')
		  {
		    chmin(dp[i][j+1], dp[i][j]+1);
		  }
		else
		  {
		    chmin(dp[i][j+1], dp[i][j]);
		  }
	      }
	    else
	      {
		chmin(dp[i][j+1], dp[i][j]);
	      }
	  }
      }


  

  /*
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++)
      {
	cout << dp[i][j] << " ";
      }
    cout << endl;
  }
  */
  if(maze[0][0]=='#')
    dp[H-1][W-1]++;
      

  
  cout << dp[H-1][W-1] << endl;
  
  return 0;
}


//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find
//vector.count



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[1001][1001],b[1001][1001],c[1001][1001];
int main(){
  int i,j;
  int m,n;
  cin>>m>>n;
  int k;
  cin>>k;
  for(i=0;i<m;++i){
    a[i][0]=b[i][0]=c[i][0]=0;
    for(j=0;j<n;++j){
      char p;
      cin>>p;
      if(false){
      }else if(p=='J'){
	a[i][j+1]=a[i][j]+1;
	b[i][j+1]=b[i][j];
	c[i][j+1]=c[i][j];
      }else if(p=='O'){
	a[i][j+1]=a[i][j];
	b[i][j+1]=b[i][j]+1;
	c[i][j+1]=c[i][j];
      }else if(p=='I'){
	a[i][j+1]=a[i][j];
	b[i][j+1]=b[i][j];
	c[i][j+1]=c[i][j]+1;
      }
    }
  }
  for(i=0;i<k;++i){
    int p,q,r,s;
    cin>>p>>q>>r>>s;
    --p;
    --q;
    int d=0,e=0,f=0;
    for(j=p;j<r;++j){
      d+=a[j][s]-a[j][q];
      e+=b[j][s]-b[j][q];
      f+=c[j][s]-c[j][q];
    }
    cout<<d<<' '<<e<<' '<<f<<endl;
  }
  return 0;
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main(){
	int a, b, c;
  	int tmp;
	scanf("%d %d %d", &a, &b, &c);
  
	tmp = a;
	a = b;
	b = tmp;
  
	tmp = a;
	a = c;
	c = tmp;
  
	printf("%d %d %d", a, b, c);
  
	return 0;
}

Measured memory_bytes: 128
n = int(input())
s = [list(map(int, input().split())) for _ in range(n - 1)]
for i in range(0, n):
    t = 0
    m = i
    if i != n - 1:
        t = s[i][0] + s[i][1]
        m += 1
    while True:
        if m == n - 1:
            break
        while True:
            if (t - s[m][1]) % s[m][2] == 0 and t < s[m][1]:
                t = s[m][1]
            if (t - s[m][1]) % s[m][2] == 0 and t >= s[m][1]:
                break
            t += 1
        t += s[m][0]
        m += 1
    print(t)

Measured memory_bytes: 43228
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let N = read int
    let xys = List.init N (fun _ -> reads int |> fun [x;y] -> (x,y))

    let vecs =
        List.collect (fun (x1, y1) ->
            List.map (fun (x2, y2) ->
                (x2 - x1, y2 - y1)
            ) xys
        ) xys
        |> List.filter ((<>) (0, 0))

    let len =
        List.map (fun (vx, vy) ->
            List.sumBy (fun (x1, y1) ->
                List.filter (fun (x2, y2) ->
                    vx = x2 - x1 && vy = y2 - y1
                ) xys
                |> List.length
            ) xys
        ) vecs

    if N = 1 then
        printfn "1"
    else
        printfn "%i" (N - List.max len)
    0

Measured memory_bytes: 18520
#include <stdio.h>

int main(){
    int Map[101][101];
    int N, u, k, temp;
    scanf("%d\n",&N);
    for (int ix = 0; ix < N; ix++)
        for (int jx = 0; jx < N; jx++)
            Map[ix][jx] = 0;
    for (int ix = 0; ix < N; ix++){
        scanf("%d %d",&u,&k);
        for (int kx = 0; kx < k; kx++){
            scanf("%d",&temp);
            Map[u-1][temp-1] = 1;
        }
    }
    for (int ix = 0; ix < N; ix++)
        for (int jx = 0; jx < N; jx++){
            if (jx == N-1) printf("%d\n",Map[ix][jx]);
            else printf("%d ",Map[ix][jx]);
        }
    return 0;
}


Measured memory_bytes: 2112
#include<iostream>
#include<vector>
#include<climits>
#include<cstring>
using namespace std;

const int INF = INT_MAX;

int node[9000000];
int h, w;

int enc(int i, int j){
    return i*(2*w-1)+j;
}

void init(int hsiz, int wsiz, vector<vector<int>> &v){
    for(int i = 0; i < hsiz; i++){
        for(int j = 0; j < wsiz; j++){
            node[enc(h-1+i,w-1+j)] = v[i][j];
        }
    }
    for(int i = 2*h-2; i > h-2; i--){
        for(int j = w-2; j >= 0; j--){
            node[enc(i,j)] = min(node[enc(i,2*j+1)], node[enc(i,2*j+2)]);
        }
    }
    for(int i = h-2; i >= 0; i--){
        for(int j = 0; j < 2*w-1; j++){
            node[enc(i,j)] = min(node[enc(2*i+1,j)], node[enc(2*i+2,j)]);
        }
    }
}

void seg2d(vector<vector<int>> &v){
    int hsiz = v.size(), wsiz = v[0].size();
    h = w = 1;
    while(h < hsiz)    h *= 2;
    while(w < wsiz)    w *= 2;
    int lim = enc(2*h, 2*w);
    for(int i = 0; i < lim; i++)    node[i] = INF;
    init(hsiz, wsiz, v);
}

int query_w(int lj, int rj, int l, int r, int i, int k){
    if(rj <= l || r <= lj)  return INF;
    if(lj <= l && r <= rj)  return node[enc(i,k)];
    int lx = query_w(lj,rj,l,(l+r)/2,i,2*k+1);
    int rx = query_w(lj,rj,(l+r)/2,r,i,2*k+2);
    return min(lx, rx);
}

int query_h(int li, int lj, int ri, int rj, int l, int r, int k){
    if(ri <= l || r <= li)  return INF;
    if(li <= l && r <= ri)  return query_w(lj, rj, 0, w, k, 0);
    int lx = query_h(li,lj,ri,rj,l,(l+r)/2,2*k+1);
    int rx = query_h(li,lj,ri,rj,(l+r)/2,r,2*k+2);
    return min(lx, rx);
}

int query(int li, int lj, int ri, int rj){
    return query_h(li, lj, ri, rj, 0, h, 0);
}

int main(){
    int r, c, q;
    while(cin >> r >> c >> q, r+c+q){
        vector<vector<int>> v(r, vector<int>(c));
        for(int i = 0; i < r; i++){
            for(int j = 0; j < c; j++){
                cin >> v[i][j];
            }
        }
        seg2d(v);
        while(q-- > 0){
            int li, lj, ri, rj;
            cin >> li >> lj >> ri >> rj;
            cout << query(li,lj,ri+1,rj+1) << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 65612
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

l = map(int, raw_input().split())
A = map(int, raw_input().split())

sm = l[2]
la = l[2]
while(True):
    if sm == 0:
        print 0
    if la == l[0]:
        print 0
    sm = sm - 1
    la = la + 1
    if sm in A and la in A:
    	ix = A.index(sm) + A.index(la)
        ix = ix / 2 + 0.5
        break
    if sm in A:
        ix = A.index(sm) + 0.5
	break
    if la in A:
	ix = A.index(la) - 0.5
	break
M = l[1] - ix - 1
if M > ix:
    print int(math.ceil(ix))
else:
    print int(math.ceil(M))


Measured memory_bytes: 2692
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
int n,m,t;
int table[1000];
int main(){
cin>>n>>m>>t;
rep(i,n)cin>>table[i];
int ans=0,now=0;

for(int i=0;i<n;i++){
	if(i==0&&table[i]>m)ans+=table[i]-m;
	else if((table[i]-table[i-1])>m*2)ans+=(table[i]-table[i-1])-m*2;
}
if(t-table[n-1]>m)ans+=t-table[n-1]-m;
cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3108
from functools import lru_cache

N=int(input())
K =int(input()) 

@lru_cache(None)
def dp(N, K):
  if N < 10:
    if K == 0:
      return 1
    if K == 1:
      return N
    return 0
  q, r = divmod(N, 10)
  ret = 0
  if K >= 1: # 下一桁が0でないときはKを1消化
    ret += dp(q, K-1) * r # 下一桁がr以下の時
    ret += dp(q-1, K-1) * (9-r) # 下一桁がrより上の時はq-1であれば成立
  ret += dp(q, K) # 下一桁が0のとき
  return ret

print(dp(N, K))

Measured memory_bytes: 39536
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<ll, ll>p;
struct edge { int to, cost; };

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
bool f = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
std::string abc = "abcdefghijklmnopqrstuvwxyz";

int main() {
	ll h, w, d, a[400][400], q, c[100000] = {0};
	p b[100000];
	std::cin >> h >> w >> d;
	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			std::cin >> a[i][j];
			b[a[i][j]] = std::make_pair(i, j);
		}
	}
	for (ll j = 1 + d;j <= h*w;j++) {
			ll e = abs(b[j - d].first - b[j].first) + abs(b[j - d].second - b[j].second);
			c[j] += c[j - d] + e;
		}
	std::cin >> q;
	for (int i = 0;i < q;i++) {
		ll l, r;
		std::cin >> l >> r;
		std::cout << c[r] - c[l] << std::endl;
	}
	}

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

int main()
{
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    vector<long long> A(X);
    for (int i = 0; i < X; i++)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    vector<long long> B(Y);
    for (int i = 0; i < Y; i++)
    {
        cin >> B[i];
    }
    sort(B.begin(), B.end());

    vector<long long> C(Z);
    for (int i = 0; i < Z; i++)
    {
        cin >> C[i];
    }
    sort(C.begin(), C.end());

    vector<int> num{X, Y, Z};
    vector<vector<long long>> deli{A, B, C};
    vector<vector<vector<bool>>> used(X, vector<vector<bool>>(Y, vector<bool>(Z, false)));

    priority_queue<pair<long long, vector<int>>> que;
    que.push(make_pair(
        A.back() + B.back() + C.back(),
        vector<int>{X - 1, Y - 1, Z - 1}));
    for (int i = 0; !que.empty() && i < K; i++)
    {
        int x = que.top().second[0];
        int y = que.top().second[1];
        int z = que.top().second[2];

        if (used[x][y][z])
        {
            que.pop();
            i--;
            continue;
        }
        else
        {
            used[x][y][z] = true;
        }

        long long cost = que.top().first;
        for (int j = 0; j < 3; j++)
        {
            vector<int> idx{x, y, z};
            if (idx[j] > 0)
            {
                idx[j]--;
                que.push(make_pair(
                    cost + deli[j][idx[j]] - deli[j][idx[j] + 1],
                    idx));
            }
        }
        cout << que.top().first << endl;
        que.pop();
    }
}


Measured memory_bytes: 180352
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        int ans[] = new int[n];
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt(), b = sc.nextInt();
            ans[a - 1] += 1;
            ans[b - 1] += 1;
        }
        for (Integer c:ans) System.out.println(c);
    }
}


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

signed main(){
  lint N, K; cin >> N >> K;
  vector<lint> a(N);
  lint ans = 1e18;
  for(lint i = 0; i < N; i++) cin >> a[i];
  
  for(lint bit = 0; bit < (1 << N - 1); bit++){
    lint counter = 0;
    for(lint i = 0; i < N - 1; i++){
      if(bit & 1 << i) counter++;
    }
    if(counter != K - 1) continue;
    lint ans1 = 0, bound = a[0];
    for(lint i = 0; i < N - 1; i++){
      if(bit & 1 << i){
        if(bound >= a[i + 1]){
          ans1 += bound - a[i + 1] + 1;
          bound++;
        }
        else bound = a[i + 1];
      }
      else{
        bound = max(bound, a[i + 1]);
      }
    }
    ans = min(ans, ans1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import math
import heapq
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
from math import ceil
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import Decimal #floatの高精度ver, 渡すのはstr型で
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########
class BIT:
    def __init__(self,n):
        self.n=n
        self.data= [0]*(n+1) #これがBIT
        self.el= [0]*(n+1) #これが元データ
    def sum(self,i):  #iまでの和
        s=0
        while i>0:
            s+=self.data[i]
            i-= i&(-i)
        return s
    def add(self,i,x):  #iにxを足す(x<0)
        self.el[i]+=x
        while i<= self.n:
            self.data[i]+= x
            i+= i&-i
    def get(self,i,j=None):  #iからjまでの和、iだけなら普通の要素iを取得(いる？)
        if j is None:
            return self.el[i]
        return self.sum(j)-self.sum(i)
    

n,q=map(int,input().split())
C=list(map(int,input().split()))
C=[i-1 for i in C]  #球の純粋配置
Q=[]
for i in range(q):
    l,r=map(int,input().split())
    l-=1;r-=1
    Q.append([i,l,r])
Q=sorted(Q, key=lambda x:x[2]) 
ANS=[-1]*q

B=BIT(n)
YOI=[-1]*n #色iの良い球の位置
# for i in range(Q[0][2],-1,-1):
#     if YOI[i]==-1:
#         YOI[C[i]]=i
#         B.add(i+1,1)
# 
# 
# ANS[Q[0][0]]= B.sum(Q[0][2]+1)- B.sum(Q[0][1])
# left=Q[0][1]; right=Q[0][2]
#print(B.data)
right=-1
for l in Q:
    newleft,newright=l[1],l[2]
    for i in range(newright,right,-1):
        if YOI[C[i]]==-1: #新種の色
            YOI[C[i]]=i
            B.add(i+1, 1)
        elif YOI[C[i]]>i:
            continue
        else:
            B.add(YOI[C[i]]+1, -1)
            YOI[C[i]]=i
            B.add(i+1, 1)
    ANS[l[0]]= B.sum(newright+1)- B.sum(newleft)
    right=newright
    #print(B.data)
for i in ANS:
    print(i)


Measured memory_bytes: 236824
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<int>   vi;
typedef vector<long long> vll;
typedef vector<pair<int,int> > vii;
#define ll long long
#define pb push_back
#define mp  make_pair
#define ff first
#define ss second
#define pq priority_queue
#define sf(x) scanf("%d",&x)
int inf = (1e9) + 7;



int n,m;
vi graph[200005];
void dfs(int start, int rem)
{
	if(start == n-1){
		printf("POSSIBLE\n");
		exit(0);
	}
	if(rem == 0)
		return;
	for(auto u: graph[start])
	{
		dfs(u,rem-1);
	}
}


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

	int a,b;
	for (int i = 0; i < m; ++i)
	{
		sf(a);
		sf(b);
		a--;
		b--;
		graph[a].pb(b);
		graph[b].pb(a);
	}


	dfs(0,2);
	printf("IMPOSSIBLE\n");
}


Measured memory_bytes: 12016
#include <iostream>

using namespace std;

long long int H;
int main(void) {

	int cnt = 0;
	cin >> H;
	while (H > 0) {
		H /= 2;
		cnt++;
	}

	long long int ans = 0;
	long long int num = 1;

	for (int i = 1; i <= cnt; i++) {
		ans += num;
		num *= 2LL;
	}

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

Measured memory_bytes: 256
#include<iostream>
#define ll long long
#include<algorithm>
#include<string>
#include<vector>
#include<unordered_set>
#include <iomanip>
using namespace std;
ll dp[400][400] = {0};
vector<ll> elements;


ll sum(int start, int last)
{
    ll ans = 0;
    for(int i = start; i<=last; ++i)
    {
        ans+=elements[i];
    }
    return ans;

}


ll check(int start, int last)
{
    //cout<<start<<"\t"<<last<<endl;
    if(start == last)
    {
        dp[start][start] = 0;
        return 0;
    }

    if(dp[start][last] != -1)
    {
        return dp[start][last];
    }

    ll ans = 1e18+5;
    ll x = sum(start, last);
    for(int i=start; i< last; ++i)
    {
       // cout<<ans<<" "<<" "<<start<<" "<<last<<endl;
        ans = min( (check(start, i) + check(i+1, last) + x),ans);
    }
    dp[start][last] = ans;
    return ans;


}


int main()
{

    ll n;
    cin>>n;
    for(int i=0; i<n; ++i)
    {
        for(int j=0; j<n; ++j)
        {
            dp[i][j] = -1;
        }
    }
    ll temp;
    for(ll i=0; i< n; ++i){
        cin>>temp;
        elements.push_back(temp);
    }
    ll ans  = check(0 , n-1);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
int main() {
    int d,g;
    cin >> d >> g;
    vector<int> p(d),c(d),s(d);
    for (int i=0;i<d;i++) {
        cin >> p[i] >> c[i];
        s[i]=p[i]*100*(i+1)+c[i];
    }
    int ans=1000;
    for (int bit=0;bit<(1<<d);bit++) {
        int u=0;
        int tans=0;
        for (int i=0;i<d;i++) {
            if (bit & (1<<i)) {
                u+=s[i];
                tans+=p[i];
            }
        }
        if (u<g) {
            for (int i=d-1;i>=0;i--) {
                if (!(bit & (1<<i))) {
                    if (u+p[i]*100*(i+1)>=g) {
                        tans+=(g-u)/(100*(i+1));
                        if ((g-u)%(100*(i+1))>0) tans++;
                        ans=min(ans,tans);
                    } 
                    break;
                }
            }
        } else {
            ans=min(ans,tans);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    int A, B; cin >> A >> B;

    if ((A * B) & 1) cout << "Odd" << endl;
    else cout << "Even" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;
//clang++ -std=c++11 -stdlib=libc++ 
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}

int main() {
  ll x,y; cin>>x>>y;
  if (x%y==0) cout << -1 << endl;
  else cout << x << endl;
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
  int n, a, x = 0, y = 0;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &a);
    x += a*a;
    y += a;
  }
  printf("%d\n", x + (n*(y/n + (y%n > n/2)) - 2*y)*(y/n + (y%n > n/2)));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        char c;
        cin >> c ;
        if(c == 'a' || c == 'i'  || c == 'u'  || c == 'e'  || c == 'o'  ) {
            cout << "vowel" << endl;
        }else{
            cout << "consonant" << endl;
        
        }
        
        
        return 0;
    }

Measured memory_bytes: 256
//by OIerC
//Forca Barcelona!
#include<cstdio>
#include<algorithm>
using namespace std;

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 2e3 + 5;

int a[N][N], b[N][N], left[N][N], right[N][N], up[N][N];
char s[N];

int main()
{
	int n = read();
	int m = read();
	int ans = max(n, m);
	
	for (int i = 1; i <= n; ++i)
	{
		scanf("%s", s + 1);
		for (int j = 1; j <= m; ++j)
			if (s[j] == '#') a[i][j] = 1;		
	}
	
	if (n == 2 && m == 2)
	{
		if ((a[1][1] + a[1][2] + a[2][1] + a[2][2]) % 2 == 0)
			printf("4\n");
		else
			printf("2\n");
		return 0;
	}
	
	for (int i = 1; i < n; ++i)
		for (int j = 1; j < m; ++j)
			if ((a[i][j] + a[i][j + 1] 
			+ a[i + 1][j] + a[i + 1][j + 1]) % 2 == 0)
			{
				b[i][j] = 1;
				left[i][j] = j;
				right[i][j] = j;
				up[i][j] = 1;
			}
	--n;
	--m;
	
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 2; j <= m; ++j)
			if (b[i][j] == b[i][j - 1] && b[i][j])
				left[i][j] = left[i][j - 1];
		
		for (int j = m - 1; j >= 1; --j)
			if (b[i][j] == b[i][j + 1] && b[i][j])
				right[i][j] = right[i][j + 1];
	}
	
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
		{
			if (i > 1 && b[i][j] == b[i - 1][j] && b[i][j])
			{
				left[i][j] = max(left[i][j], left[i - 1][j]);
				right[i][j] = min(right[i][j], right[i - 1][j]);
				up[i][j] = up[i - 1][j] + 1;
			}
			
			int x = right[i][j] - left[i][j] + 1;
			int y = up[i][j];
			
			ans = max(ans, (x + 1) * (y + 1));
		}
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 78592
#include <cmath>
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <limits>

int main() {
	int n; std::cin >> n;
	std::vector<std::string> S(n);
	std::pair<int, int> minid(0, std::numeric_limits<int>::max());

	for (int i = 0; i < S.size(); i++) {
		std::cin >> S[i];
		if (S[i].size() < minid.second) {
			minid.first = i;
			minid.second = S[i].size();
		}
	}

	std::string ans;
	for (int i = 0; i < S[minid.first].size(); i++) {
		char c = S[minid.first].at(i);
		bool check_word = true;
		for (int i = 0; i < S.size(); i++) {
			if (i == minid.first) continue;
			auto itr = S[i].find(c);
			if (itr == std::string::npos) {
				check_word = false;
				break;
			}
			else {
				S[i].erase(S[i].begin() + itr);
			}
		}
		if (check_word) ans += c;
	}
	
	std::sort(ans.begin(), ans.end());
	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 256
N,x = map(int,input().split())
a = [0] + list(map(int,input().split()))
import copy
tmpa = copy.deepcopy(a)

for i in range(N):
    if a[i] + a[i+1] > x:
            a[i+1] -= (a[i+1] + a[i] - x)

ans = 0
for i in range(N+1):
    ans += abs(a[i] - tmpa[i])
print(ans)

Measured memory_bytes: 14060
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    var h = sc.nextLong()
    var hits = 0L
    var monsters = 1L
    while (h > 0) {
        hits += monsters
        h /= 2
        monsters *= 2
    }
    println(hits)
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

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

const int N=2e5+100;
const int mod=1e9+7;
typedef long long ll;


typedef pair<int,int> pa;


int n,m;

struct line

{
    int l,r;
    bool operator < (const  line & x){
       return r<x.r;
    }
}p[N];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m;
    for(int i=1;i<=m;i++) {
         cin>>p[i].l>>p[i].r;
    }
    sort(p+1,p+1+m);

    int ans=0;
    int pos=1;
    while(pos<=m){
        ans++;
        int len=p[pos].r;
        int po=pos+1;
        while(len>p[po].l && po<=m){
            po++;
        }
        pos=po;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4412