akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#include <iostream>

using namespace std;

int main() {

    int A, B, K;

    cin >> A >> B >> K;

    vector<int> as;

    for (int i = 1; i <= min(A, B); i++) {
        if (A % i == 0 and B % i == 0) {
            as.push_back(i);
        }
    }

    int k = 0;

    int result;

    for (int i = as.size() - 1; i >= 0; i--) {
        k += 1;
        if (k == K) {
            result = as[i];
            break;
        }
    }

    cout << result << "\n";


    return 0;
}

Measured memory_bytes: 256
S = input()

odd = set(S[0::2])
even = set(S[1::2])

okOfOdd = len(odd - set(['R', 'U', 'D']))
okOfEven = len(even - set(['L', 'U', 'D']))

if okOfOdd == 0 and okOfEven == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
# オイラーのφ関数。1からnまでの自然数のうち
# nと互いの素なものの個数。
require 'prime'
def eular_phi(n)
    primes = n.prime_division
    # n が p1^e1・p2^e2 … pk^ek と素因数分解できるとき、
    # φ(n) = N ( 1 - 1/p1 ) ( 2 - 1/p2 ) … ( 1 - 1/pk )
    ret = n
    primes.each do |prime|
        ret *= prime.first - 1
        ret /= prime.first
    end
    ret
end


N = gets.to_i
puts eular_phi(N)


Measured memory_bytes: 9032
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//------------------------------------------------------------------------------

int main(int argc, char const *argv[]) {
    string s;
    cin>>s;
    bool f=false;
    if(find(ALL(s),'N')!=end(s)) {
        if(find(ALL(s),'S')==end(s)) {
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(find(ALL(s),'S')!=end(s)) {
        if(find(ALL(s),'N')==end(s)) {
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(find(ALL(s),'W')!=end(s)) {
        if(find(ALL(s),'E')==end(s)) {
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(find(ALL(s),'E')!=end(s)) {
        if(find(ALL(s),'W')==end(s)) {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


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

int main()
{
  int N;
  bool check=false;
  cin >> N;
  if (N/10 == 9)
  {
    check = true;
  }
  else if(N%10 == 9)
  {
    check = true;
  }
  if(check)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
from collections import Counter
import sys
sys.setrecursionlimit(1000000)
N,M = map(int, input().split())
 
# 隣接リスト
l = [[] for i in range(N+1)] 
for i in range(M):
    a, b = list(map(int, input().split()))
    l[a].append(b)
    l[b].append(a)

nodes_color = {node:0 for node in range(1, N+1)}#set([a for ab in ab_list for a in ab])}

nibu = True
stack = [1]

nodes_color[1] = 1

while stack:
    node = stack.pop()
    for next_node in l[node]:
        if nodes_color[next_node]==0:
            stack.append(next_node)
            nodes_color[next_node] = - nodes_color[node]
        else:
            if nodes_color[next_node]==nodes_color[node]:
                nibu = False
                break
    if not nibu:
        break

if nibu:
    b,w = Counter(nodes_color.values()).values()
    print(int(b*w-M))
else:
    print(int(N*(N-1)/2-M))

Measured memory_bytes: 67052
#include <stdio.h>

int main(void)
{
        int i,n=0;
        char s[4];

        scanf("%s",s);

        for(i=0;i<2;i++){
                if(s[i]!=s[i+1]) n++;
        }
        if(n>0) printf("Yes\n");
        else printf("No\n");
        return 0;
}


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

using ll = long long;

void solve(long long K){
    int current = 0;
    vector<int> v(1e6+ 1);
    for(int i = 1;;i++){
        //cout<<i<<endl;;
        current *= 10;
        current += 7;
        current %= K;
        if(current == 0){
            cout<<i<<endl;
            return;
        }
        if(v[current] == 1){
            cout<<-1<<endl;
            return;
        }
        v[current] = 1;
    }
}

int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


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

using namespace std;

long int dp[13];
long int dp_n[13];
const long int mod = 1000000007;

long int n;
char s[100005];


int main(){

    cin >> s;
    n = strlen(s);
    
    for (int i = 0; i < 13; i++) {
        dp[i] = 0;
    }
    
    dp[0] = 1;
    
    
    /*
    for (int l = 0; l < 13; l++) {
        cout << dp[l] << " ";
    }
    cout << endl;
    */
    
    
    long int mo = 1;
    
    for (long int i = 0; i < n; i++) {
        
    
        long int c;
       
        
        //cout << mo << "a ";
        
        if (s[n-i-1] != '?') {
            
            c = s[n-i-1] - '0';
            
            //cout << c << "a ";
            
            for (long int j = 0; j < 13; j++) {
                dp_n[(j+(c*mo))%13] += dp[j];
            }
            
        }else{
            
            for (long int k = 0; k < 10; k++) {
                for (long int j = 0; j < 13; j++) {
                    dp_n[(j+(k*mo))%13] += dp[j];
                }
            }
            
        }
        
        for (long int l = 0; l < 13; l++) {
            dp[l] = (dp_n[l])%mod;
            //cout << dp[l] << " ";
            dp_n[l] = 0;
        }
        //cout << endl;
        
        mo *= 10;
        mo %= 13;
        
        
    }
    
    
    cout << dp[5] << endl;
    
    
}



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

typedef unsigned long long ull;

int main(void) {
	int N;
	std::vector<int> A;
	std::cin >> N;
	ull result = 0;
	for(int i = 0; i < N; ++i) {
		int t;
		std::cin >> t;
		A.push_back(t);
	}
	for(int i = 0; i < N; ++i) {
		if(i != 0) {
			if(A[i - 1] != 0 && A[i] != 0) {
				++result;
				--A[i];
			}
		}
		result += A[i] / 2;
		A[i] = A[i] % 2;
	}
	std::cout << result << '\n';
	return 0;
}



Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  ll two=0,four=0;
  for(auto &a:A){
    cin>>a;
    if(a%4==0){
      four++;
    }else if(a%2==0){
      two++;
    }
  }
  ll one=n-two-four;
  //  cout<<one<<" "<<two<<" "<<four<<endl;
  if(one-four<=0){
    cout<<"Yes"<<endl;
  }else if(one-four<=1&&two==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long ll;

int ans[500];
bool in[500];

int main() {
  ll n=0;
  scanf("%lld",&n);
  int cnt=0;
  while (n)
  	if (n&1) {
  		cnt++;
  		in[cnt]=0;
  		n>>=1;
	  }
	else {
	    cnt++;
	    in[cnt]=1;
	    n--;
	}
  int l=251,r=250;
  for(int i=cnt;i>0;i--)
    if (in[i]) ans[--l]=cnt-i+1; else ans[++r]=cnt-i+1;
  printf("%d\n",2*cnt);
  for(int i=l;i<=r;i++) printf("%d ",ans[i]);
  for(int i=1;i<=cnt;i++) printf("%d ",i);
  printf("\n");
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
   int a;
   scanf("%d", &a);
   int A[a];
   for (int i = 0; i < a; i++ ) {
      scanf("%d", &A[i]);
   }
   int light;
   int count = 1;
   for (light = A[0]; light != 2; count++) {
      if (count >= a ) {
         printf("-1");
         break;
      }
      light = A[light-1];
   }
   if (light == 2 ) {
      printf("%d\n", count);
   }
   return 0;
   



}

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

using namespace std;

/*
12
13 19 9 5 12 8 7 4 21 2 6 11
*/

int partition(int A[],int n){
    int index;
    int a=0;
    int k;
    for (int i = 0; i < n; i++) {
        if (A[i] <= A[n-1]) {
            k = A[i];
            A[i] = A[a];
            A[a] = k;
            index = a;
            a++;
        }
    }
    return index;
}


int main(){
    int A[100002];
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%d",&A[i]);
    }
    
    int index = partition(A,n);
    
    for (int i = 0; i < n; i++) {
        if (i != n-1) {
            if (i != index) {
                cout << A[i] << " ";
            }else{
                cout << "[" << A[i] << "]" << " ";
            }
        }else{
            if (i != index) {
                cout << A[i] << endl;
            }else{
                cout << "[" << A[i] << "]" << endl;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 1632
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

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

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N, K;
    scan(N, K);
    auto A = aryread();
    long[long] D;
    foreach (a; A)
    {
        D[a] = (a in D) ? D[a] + 1 : 1;
    }
    auto Key = D.keys;
    auto Val = D.values;
    zip(Val, Key).sort!"b<a"();
    writeln(N - Val.take(K).sum());
}


Measured memory_bytes: 26512
import java.util.*;

public class Main {

	public static void main(String[] args) {
		new Main().execute();
	}

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final long X = sc.nextLong();
		final long Y = sc.nextLong();
		
		long a = X;
		int len = 0;
		while(a <= Y) {
			a = a * 2;
			len++;
		}
		System.out.println(len);
		sc.close();
	}

}

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

public class Main {
    public static PrintWriter out;
    public static FastScanner in;

    private void solve(){
        List<Long> list = new ArrayList<>();

        long cb = 0;
        for(int i=0;cb<=1e9;i++){
            cb = ((long)i*(i+1))/2;
            list.add(cb);
        }

        long b = in.nextLong();
        for(int i=0;i<list.size();i++){
            if(list.get(i) >= b){
                out.print(i);
                return;
            }
        }
    }

    private void runIO() {
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }
    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

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

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

        private String nextLine() {
            String ret = "";
            try {
                ret = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}


Measured memory_bytes: 23764
import java.util.*;
import java.lang.*;
import java.io.*;
 class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	   // Scanner sc=new Scanner(System.in);
	    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	    int t=1;
	  //  t=sc.nextInt();
	    //int t=Integer.parseInt(br.readLine());
	    while(--t>=0){
	       String s=br.readLine();
	       if(s.charAt(s.length()-1)=='s')
	       System.out.println(s+"es");
	       else
	        System.out.println(s+"s");
	     
	        
	    }
	    
	}
}

Measured memory_bytes: 36380
import math
x1, y1, x2, y2 = map(int, input().split())
x2 -= x1
y2 -= y1
if x2 != 0:
    theta = math.atan2(y2,x2)
else:
    if y2 > 0:
        theta = math.pi / 2
    else:
        theta = 3 * math.pi / 2
if y2 == 0:
    if x2 < 0:
        theta = math.pi
    else:
        theta = 0

if theta < 0:
    theta += 2 * math.pi
#theta = theta % (2 * math.pi)

l = math.sqrt(x2**2 + y2**2)

x3 = math.cos(theta+math.radians(45))*l*math.sqrt(2)+x1
y3 = math.sin(theta+math.radians(45))*l*math.sqrt(2)+y1

x4 = math.cos(theta+math.radians(90))*l+x1
y4 = math.sin(theta+math.radians(90))*l+y1
print(round(x3), round(y3), round(x4), round(y4))

Measured memory_bytes: 3444
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  std::string S;
  std::cin >> S;
  std::sort(S.begin(), S.end());
  std::cout << (S == "abc" ? "Yes" : "No") << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    string s,t;
    cin >> s >> t;
    t.pop_back();
    bool ans = s == t;
    cout << (ans? "Yes" : "No") << endl;
}

Measured memory_bytes: 3132
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
#define PI 3.14159265
#define pb push_back
int x[100005];
int bit[(1<<17)+1];
void update(int i,int x)
{
	for(int j=i;j<=(1<<17);j+=j&-j)
	{
		bit[j] += x;
	}
}
int sum(int i)
{
	int res = 0;
	for(int j=i;j>0;j-=j&-j)
	{
		res += bit[j];
	}
	return res;
}
#define mod 1000000007
typedef long long ll;
ll f[100005];
int main()
{
	int n,r;
	f[0] = 1LL;
	for(int i=1;i<=100000;i++) f[i] = (f[i-1]*1LL*i)%mod;
	while(1)
	{
		cin >> n;
		if(n == 0) return 0;
		cin >> r;
		for(int i=1;i<=n;i++) x[i] = i,update(i,1);
		for(int i=0;i<r;i++)
		{
			int a,b;
			cin >> a >> b;
			swap(x[a],x[b]);
		}
		ll res = 0;
		for(int i=1;i<=n;i++)
		{
			int b = sum(x[i]);
			update(x[i],-1);
			res = (res + (b-1LL)*f[n-i]%mod)%mod;
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 2736
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int N = 16;
const int M = 1<<N;
const ll Inf = 1e18;


ll a[N][N];
ll Dp[M];
ll Cost[1<<N];
vector <int> Not_Taken[1<<N];

void Max_Self(ll& x,ll y)   {
    x = max(x,y);
}

void Rec(ll Mask,ll j,ll Mask2)
{
    if(j==Not_Taken[Mask].size())
        return Max_Self(Dp[Mask],Cost[Mask2]+Dp[Mask|Mask2]);

    Rec(Mask,j+1,Mask2);
    Rec(Mask,j+1,Mask2|(1<<Not_Taken[Mask][j]));
}

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

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            scanf("%lld",&a[i][j]);

    for(int Mask=0;Mask<(1<<n);Mask++)
        for(int i=0;i<n;i++)
            for(int j=i+1;j<n;j++)
                if( ( Mask&(1<<i) ) && ( Mask&(1<<j) ) )
                    Cost[Mask] += a[i][j];

    for(int Mask=0;Mask<(1<<N);Mask++)
        for(int i=0;i<N;i++)
            if(!(Mask&(1<<i)))
                Not_Taken[Mask].push_back(i);

    for(int i=0;i<M;i++)   Dp[i] = -Inf;

    Dp[(1<<n)-1] = 0;

    for( int Mask = (1<<n)-2 ; Mask >= 0 ; Mask-- )
        Rec(Mask,0,0);

    cout<<Dp[0];
}


Measured memory_bytes: 6656
import sys
import numpy as np
import functools
import operator
def II(): return int(input())
def LII(): return double(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N = II()
    #A = [0]*N
    ans = 1
    A= LI()
    
    if A.count(0)>0:
        print(0)
    else:
        for i in range(N):
            ans = ans*int(A[i])
            if ans-1000000000000000000>0:
                print(-1)
                break


        if ans-1000000000000000000<=0:
            print(ans)
    


    


if __name__ == "__main__":
	main()

Measured memory_bytes: 40260
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,l,i,j,c,a,b,o;
  int k[6]={};
  int bu[30]={};
  cin >> n >> l;
  while(l!=0){
    c=1;
    bu[0]=n;
    int f=0;
    while(f==0){
      j=1;
      for(i=0;i<l-1;i++) j*=10;
      for(i=0;i<l;i++){
	k[i]=bu[c-1]%(j*10)/j;
	j/=10;
      }
      sort(k,k+l);
      a=0;j=1;
      for(i=0;i<l;i++) {
	a+=k[i]*j;
	j*=10;
      }
      b=0;j=1;
      for(i=0;i<l;i++) {
	b+=k[l-1-i]*j;
	j*=10;
      }
      bu[c]=a-b;
      for(i=0;i<c;i++) {
	if(bu[c]==bu[i]) {
	  f=1;
	  o=i;
	}
      }
      c++;
    }
    cout << o << " " <<  bu[c-1] << " " << c-1-o << endl;
    cin >> n >> l;
  }
  return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vi a[111];

ll dist(vi a, vi b)
{
	ll sum=0;
	for(int i=0;i<a.size();i++)
	{
		sum+=(a[i]-b[i])*(a[i]-b[i]);
	}
	return sum;
}
bool issqrt(ll x)
{
	ld tmp = sqrt(double(x));
	for(ll i=tmp-1;i<=tmp+1;i++)
	{
		if(i*i==x) return true;
	}
	return false;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	int d; cin>>d;
	for(int i=0;i<n;i++)
	{
		a[i].resize(d);
		for(int j=0;j<d;j++)
		{
			cin>>a[i][j];
		}
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(issqrt(dist(a[i],a[j]))) ans++;
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <stdio.h>
#include <iomanip>
using namespace std;

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

#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()

int n, k, h, ans;

int main()
{
	cin >> n >> k;
	while (n--) {
		cin >> h;
		if (h >= k) ans++;
	}	
	cout << ans << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, ans = 111;

		n = sc.nextInt();

		for (int i = 1; i < 10; ++i) {
			int tmp = i * 100 + i * 10 + i;
			if (n <= tmp) {
				ans = tmp;
				break;
			}
		}

		System.out.println(ans);
		sc.close();
	}

}


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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {

	int n;
	string s;
	cin >> n >> s;
	int l = s.length();
	
	rep(i,l) {
		int t = s[i] - 'A';
		t = (t + n) % 26;
		char c = t + 'A';
		putchar(c);
	}
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string n;
  cin>>n;
  if(n[0]==n[2])
  {
  	cout<<"Yes"<<endl;
  	return 0;
	  }	
  else
    cout<<"No"<<endl;
  return 0;		  
}

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

int main()
{
	int n, m;
	
	scanf("%d%d", &n, &m);
	m /= 1000;
	for (int i = 0; i <= m && i <= n; i++) {
		int p = m - i;
		int q = n - i;
		int tmp = p - 5 * q;
		if (tmp >= 0 && tmp % 5 == 0 && q - tmp / 5 >= 0) {
			printf("%d %d %d\n", tmp / 5, q - tmp / 5, i);
			return 0;
		}
	}
	puts("-1 -1 -1");
}


Measured memory_bytes: 256
import itertools
S = input()
akihabara = ["AKIHABARA", \
             "KIHABARA", "AKIHBARA", "AKIHABRA", "AKIHABAR", \
             "KIHBARA", "KIHABRA", "KIHABAR", "AKIHBRA", "AKIHBAR", "AKIHABR", \
             "KIHBRA", "KIHBAR", "KIHABR", "AKIHBR", \
             "KIHBR"]

if S in akihabara:
    print("YES")
else:
    print("NO")



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
   cin >> n;
  string a;
cin>>a;
  int ans=0;
  int count =0;
    for(int p=0;p<10;p++){
      for(int q=0;q<10;q++){
        for(int r=0;r<10;r++){
          int b[3];
          b[0]=p;
          b[1]=q;
          b[2]=r;
          count=0;
          for(int i=0;i<n;i++){
            if(a[i]-48 ==b[count]){count++;}
            if(count ==3){ans++;
                         break;}
          }
      }
    }
}
  cout << ans << endl;
} 

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

#define ll long long 
using namespace std;



main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	map<ll,ll> mp;
	multimap<ll,ll>mp1;
	ll test,n,i,j,area,flag=0,a[100000*2],d=0,m,amt,r,a2[100000*2],x,y,k,K,I,m1,m2,m3,o,o1,o2,o3,dp[100000*2],dp2[100000*2];
	
	cin>>n;
	for(i=1;i<=n;++i)
		cin>>a[i];
	
	dp[1]=0;
	dp[2]=abs(a[1]-a[2]);
	
	for(i=3;i<=n;++i){
		dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));}
		
	cout<<dp[n]<<endl;
	
	}
		
	





Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include <map>
using namespace std;
int main(void){
    int N,M;
    cin >> N >> M;
    vector<int> K(N);
    vector<vector<int>> A(N,vector<int>(M));
    for(int i = 0; i < N; i++){
        cin >> K[i];
        int j = 0;
        while(j < K[i]){
            cin >> A[i][j];
            j++;
        }
    }
    map<int,int> mp;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < K[i]; j++){
            if(mp.count(A[i][j])) mp[A[i][j]]++;
            else mp[A[i][j]] = 1;
        }
    }
    
    int Count = 0;
    
    for(auto p : mp){
        if(N == p.second) Count++;
    }

    cout << Count << endl;
}    

Measured memory_bytes: 256
N, A, B = map(int, input().split())

target_total = 0
total_each_digit = 0
n_length = 0

for n in range(1, N + 1):
    total_each_digit = 0
    n_length = len(str(n))
    
    for i in range(n_length):
        total_each_digit += int(str(n)[i])
    if A <= total_each_digit <= B:
        target_total += n

print(target_total)

Measured memory_bytes: 3060
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    
    long i = 1;
    long j = 1;
    long a = 1;
    
    
    while(a<=n/a){
      if(n%a==0){
        i = a;
        j = n/i;
      }
      a++;
    }
    System.out.println(i+j-2);
  }
}

Measured memory_bytes: 35940
from collections import Counter

n = int(input())
A = [int(i) for i in input().split()]
A0 = []
A1 = []
for i in range(0, n, 2):
    A0.append(A[i])
    A1.append(A[i + 1])
    
C0 = Counter(A0).most_common()
C1 = Counter(A1).most_common()

if C0[0][0] != C1[0][0]:
    ans = n - C0[0][1] - C1[0][1]
else:
    if len(C0) == 1 and len(C1) == 1:
        ans = n // 2
    elif len(C0) != 1 and len(C1) != 1:
        ans = min(n - C0[0][1] - C1[1][1], n - C0[1][1] - C1[0][1])
    elif len(C0) != 1 and len(C1) == 1:
        ans = n // 2 - C0[0][1]
    else:
        ans = n // 2 - C1[0][1]
        
print(ans)

Measured memory_bytes: 21084
d = dict()
for i in range(26):
  d[chr(97+i)] = 0
h,w = map(int, input().split())
for _ in range(h):
  for x in input():
    d[x] +=1
cno = 0
cn2 = 0
for x in d:
  if d[x]%2:
    cno +=1
  elif d[x]%4:
    cn2 += 1
ans = ["No","Yes"]
print(ans[(cno<=(h*w%2))&(cn2<=((h%2)*w//2+(w%2)*h//2))])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define N 1401
using namespace std;
int mp[N][N];
int h,w;

struct dat{int h,i;};

int calc(int A[]){
  stack <dat> S;
  int res = 0;
  for(int i=0;i<=w;i++){
    int h = A[i];
    
    if(S.empty() || S.top().h < h) S.push((dat){h,i});
    else if(S.top().h == h);
    else {
      int ni = i;
      while(!S.empty() && S.top().h > h){
        dat t = S.top(); S.pop();
        ni = t.i;
        int area = (i - t.i) * t.h;
        res = max(res,area);
      }
      res = max(res,(i-ni)*h);
      S.push((dat){h,ni});
    }
    
  }
  return res;
}



int main(){

  cin>>h>>w;
  
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)cin>>mp[i][j],mp[i][j]=!mp[i][j];
  
  for(int j=0;j<w;j++)
    for(int i=1;i<h;i++)if(mp[i][j]) mp[i][j] = mp[i-1][j]+1;


  //cout<<endl;for(int i=0;i<h;i++){for(int j=0;j<w;j++)cout<<mp[i][j]<<" ";cout<<endl;}
  int ans = 0;
  for(int i=0;i<h;i++)ans = max(ans,calc(mp[i]));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 10716
#include<iostream>
#include<cstring>
#include<queue>
#include<deque>
#include<set>
#include<stack>2
#include<algorithm>
#include<bits/stdc++.h>

using namespace std;
typedef long long LL;

const int maxn = 1e5+17;
bool fig[maxn];
vector<int> vec[maxn];
deque<int> dq;

void alive()
{
	while(1)
    {
        int father = dq.front();
        bool son=true,desalive=true;
        for(vector<int>::iterator it=vec[father].begin();it!=vec[father].end();it++)son&=fig[*it];
        for(vector<int>::iterator it=vec[father].begin();it!=vec[father].end();it++)
        {
            if(son) break;
            if(!fig[*it])
            {
                fig[*it]=true;
                dq.push_front(*it);
                break;
            }
        }
        int tl=dq.back();
        for(vector<int>::iterator it=vec[tl].begin();it!=vec[tl].end();it++)desalive&=fig[*it];
        for(vector<int>::iterator it=vec[tl].begin();it!=vec[tl].end();it++)
        {
            if(desalive)break;
            if(!fig[*it])
            {
                fig[*it]=true;
                dq.push_back(*it);
                break;
            }
        }
        if(son&&desalive) break;
    }
}

int main()
{
    int n,m;
    cin>>n>>m;
    int start=-1,end=-1;
    for (int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        vec[u].push_back(v);
        vec[v].push_back(u);
        if(start==end)start=u,end=v;
    }
    dq.push_front(start);
    dq.push_back(end);
    fig[start]=fig[end]=true;
    alive();
    cout<<dq.size()<<endl;
    for(deque<int>::iterator it=dq.begin();it!=dq.end();it++)
        cout<<*it<<" ";
    cout<<endl;
    return 0;        
}

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

using namespace std;
#define int long long
const int INF = 1000000007;


signed main(){
    int n,m;
    cin>>n>>m;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
  
   int b,c;
   priority_queue<pair<int,int>> que;
   for(int i=0;i<m;i++){
       cin>>b>>c;
 
        que.push(make_pair(c,b));
   }
   pair<int,int> t;
   t=que.top();
       que.pop();
       c=t.first;b=t.second;
       cerr<<b;
   for(int i=0;i<n;i++){
  
       while(a[i]>=c||b==0){
           if(que.empty())break;
               t=que.top();
       que.pop();
       c=t.first;b=t.second;
       }
       if(a[i]>=c||b==0)break;
        a[i]=c;
        b--;
       
   }
   int ans=0;

   for(int i=0;i<n;i++)ans+=a[i];
   cout<<ans;
    return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 998244353
#define EPS 1e-7

typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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 > >;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a >= 9 || b >= 9)
	{
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 384
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    let (N, mut Y)=get!(isize,isize);
   // let (N,mut Y)=(9,45000);
Y/=1000;
let mut noans=true;
    'outer: for x in 0..N+1{
        for y in 0..N+1-x{
            let z=N-x-y;
            let s=x*10+y*5+z;
            if s==Y{println!("{} {} {}",x,y,z );noans=false;break 'outer;}
        }

    }

if(noans){println!("-1 -1 -1");}
    
}


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

int main() {
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << (i < b ^ j < a);
		}
		cout << endl;
	}
}


Measured memory_bytes: 1280
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
        a[i]--;
    }
    vector<ll> used(n,0);
    ll now=0;
    ll count=0;
    vector<ll> num(0);
    ll flag=k;
    ll cnt;
    while(flag>0){
        count++;
        num.push_back(now);
        used[now]=count;
        now=a[now];
        if(used[now]>0){
            cnt=count-used[now]+1;
            //cout<<cnt<<" "<<count<<" "<<used[now]<<endl;
            break;
        }
        flag--;
    }
    if(flag==0){
        cout<<now+1<<endl;
    }else{
        ll i=(k+1-used[now])%cnt+used[now]-1;
        cout<<num[i]+1<<endl;
    }
}

Measured memory_bytes: 8496
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;
int main()
{
    int X,Y,Z;
    cin >> X >> Y >> Z;
    swap(X, Y); 
    swap(X, Z);
    cout << X << ' ' << Y << ' ' << Z << endl;
    return 0;
}

Measured memory_bytes: 256
module Main where

import Control.Applicative
import Text.Printf

main :: IO ()
main = loop 1

loop :: Int -> IO()
loop i = do
  { [x] <- getInts
  ; if x == 0 then return ()
    else do
       { putStr $ printf "Case %d: %d\n" i x
       ; loop (i+1)
       }
  }

--

getInts :: IO[Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show




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

int main() {
    long long n;
    long long tr[5];

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

    long long bottle_neck = tr[0];
    for(int i = 1; i < 5; i++) {
        if(tr[i] < bottle_neck) {
            bottle_neck = tr[i];
        }
    }

    cout << (long long)ceil((double)n / (double)bottle_neck) + 4 << endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		int Q = sc.nextInt();
		boolean[][] m = new boolean[N][M];
		for(int i=0; i<N; i++) {
			char[] s = sc.next().toCharArray();
			for(int j=0; j<M; j++)
				m[i][j] = s[j]=='1';
		}
		short[][] hc = new short[N+1][M+1];
		short[][] vc = new short[N+1][M+1];
		int[][] t = new int[N+1][M+1];
		
		for(int i=0; i<N; i++) {
			for(int j=0; j<M; j++) {
				short hd = (short)((i>0 && m[i-1][j] && m[i][j]) ? 1 : 0);
				short vd = (short)((j>0 && m[i][j-1] && m[i][j]) ? 1 : 0);
				hc[i][j+1] = (short)(hc[i][j] + hd);
				vc[i+1][j] = (short)(vc[i][j] + vd);
				t[i+1][j+1] = t[i][j+1] + t[i+1][j] - t[i][j] + (m[i][j] ? 1 : 0) - hd - vd;
			}
		}
		
		for(int i=0; i<Q; i++) {
			int x1 = sc.nextInt()-1;
			int y1 = sc.nextInt()-1;
			int x2 = sc.nextInt();
			int y2 = sc.nextInt();
			int ans = t[x2][y2]-t[x1][y2]-t[x2][y1]+t[x1][y1] + vc[x2][y1]-vc[x1][y1] + hc[x1][y2]-hc[x1][y1];
			pw.println(ans);
		}
		
		sc.close();
		pw.close();
	}
}


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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){
	float a,b,t;
	cin >> a >> b >> t;

	int ans =0;
	for(int i = a; i < t+0.5; i += a){
		ans += b;
	}
	
	cout << ans;
    return 0;
}


Measured memory_bytes: 256
/*
 *  Author : H_Tatsuhiro ( Tatsuhiro Hashimoto )
 *  Created : 2020/08/29 21:14:55
 */

#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define FSP(n) cout << fixed << setprecision(n);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define ilMAX 2147483647;
#define llMAX 9223372036854775807;
#define ullMAX 18446744073709551615;
#define SORT(v) sort((v).begin(), (v).end());
#define REV(v) reverse((v).begin(), (v).end());
#define prepare cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);

void solve() {
    int D, T, S; cin >> D >> T >> S;
    if (T * S >= D) cout << "Yes" << endl;
    else cout << "No" << endl;
}   

signed main() {
    prepare
    solve();
}

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

const int MAXN = 1e5 + 5;
int book,n,a[MAXN],t,ans,T = 1,A[MAXN]; 

int main()
{
    cin>>n;
    for(int i=1;i<=n;++i) cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<=n;++i)
    {
        if(a[i]==book) A[T]++,A[T] %= 2;
        else book = a[i],A[++T]++;
    }
    for(int i=1;i<=T;++i) ans += A[i];
    cout<<ans<<endl;
    return 0; 
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String w = sc.next();
		
		char[] c = w.toCharArray();
		Arrays.parallelSort(c);
		
		int check = 0;
		for(int i=0;i<c.length;i++) {
			if(i%2 == 0) {
				check += c[i];
			}else {
				check -= c[i];
			}
		}
		
		if(check == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
		sc.close();
	}

}


Measured memory_bytes: 21588
N, M = gets.split.map(&:to_i)
broken = []
M.times do |i|
    broken[gets.to_i] = true
end
dp = Array.new(N+3, 0)
dp[0] = 1
MOD = 10**9+7
(1..N).each do |i|
    dp[i] = (dp[i-1] + dp[i-2]) % MOD unless broken[i]
end
puts dp[N]

Measured memory_bytes: 3780
// Author: Harshdeep Sharma , IIT  Indore
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
// #define MOD  998244353
#define ll long long
const double PI = atan(1.0) * 4;
// const ll INF = (int)1e9 ;
const int di[4] = { -1, 0, 1, 0} ;
const int dj[4] = {0, -1, 0, 1} ;
const ll INF = (ll)2e18 + 50;
const int maximum  = numeric_limits<int>::max();
const int minimum  = numeric_limits<int>::min();
// const int N = 1e5 + 5 ;
const int mod = 1e9 + 7 ;
// const int N = 1e5 + 5 ;

ll power(ll a , ll e) {
	ll res = 1LL ;
	while (e > 0) {
		if (e % 2 == 1) res = res * a;
		a =  a * a  ;
		e /= 2 ;
	}
	return res ;
}






int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t ;
	// cin >> t ;
	// while (t--) {
	int n , k ;
	cin >> n >> k  ;
	vector<int> h(n), dp(n , mod) ;
	for (int i = 0 ; i < n ; i++) {
		cin >> h[i] ;
	}
	dp[0] = 0 ;
	for (int i = 0 ; i < n ; i++) {
		for (int  j = 1 ; j <= k ; j++) {
			if (i + j < n ) {
				dp[i + j] = min(dp[i + j] , dp[i] + abs(h[i] - h[i + j])) ;
			}
		}


	}
	cout << dp[n - 1] <<  "\n";



// }



	return 0 ;
}





Measured memory_bytes: 3932
//Om Sree Sai Ram
#include "bits/stdc++.h"
using namespace std;

const long long mod = 1e9+7;
vector<pair<long long ,long long>> dp;
vector<bool> vis;

void mul_self(long long &a,long long b)
{
  a = a*b;
  a = a%mod;
}

void add_self(long long& a,long long b)
{
  a+=b;
  if(a>=mod)
    {
      a-=mod;
    }
}

pair<long long,long long> dfs(long long id,vector<vector<long long>>& adj)
{
  pair<long long,long long> ans;
   ans.first++;
   ans.second++;
  //bool flag = false;
  for(auto c:adj[id])
  {
    if(vis[c])
    {
      continue;
    }
    //flag = true;
    vis[c] = true;
    auto  tmp = dfs(c,adj);
    long long black = tmp.first;
    long long white = tmp.second;
    add_self(white,black);
    mul_self(ans.first,white);
    mul_self(ans.second,black);
  }
 //  if(!flag)
 //  {
 //  ans.first++;
 //  ans.second++;
 // }
  return ans;
}

int main() 
{

long long n;
cin>>n;
vector<vector<long long>> ar(n);
for(int i=0;i<n-1;i++)
{
  int a,b;
  cin>>a>>b;
  ar[a-1].push_back(b-1);
  ar[b-1].push_back(a-1);
}
dp.assign(n,make_pair(0,0));
//dp[i] represents, number of ways to fill the tree with root
// First element represents number of ways if the current element is filled with white
// Second elemetn represent number of ways if the current element is black
vis.assign(n,false);
vis[0] = true;
auto ans = dfs(0,ar);
//cout<<ans.first<<" "<<ans.second<<endl;
add_self(ans.second,ans.first);
cout<<ans.second<<endl;

}


Measured memory_bytes: 12800
t = int(input())
for _ in range(t):
    n = int(input())
    blocks = list(map(int, input().split()))
    ans = [0, 0]
    for i in range(1, n):
        ans[0] = max(ans[0], blocks[i] - blocks[i-1])
        ans[1] = max(ans[1], blocks[i-1] - blocks[i])
    print(*ans)


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
const int maxn=100100;
char a[maxn],b[maxn];
int main(){
	scanf("%s",b+1);
	int len=strlen(b+1);
	for(int i=1;i<=len;i++){
		a[i]=b[i];
		if(a[i]=='b') a[i]='d';
		else if(a[i]=='d') a[i]='b';
		else if(a[i]=='p') a[i]='q';
		else if(a[i]=='q') a[i]='p';
	}
	int flag=0;
	for(int i=1;i<=len;i++){
		if(b[i]!=a[len-i+1]){
			flag=1;
//			cout<<a[i]<<" "<<a[len-i+1];
			break;
		}
	}
	if(flag==1) cout<<"No";
	else cout<<"Yes";
	return 0;
} 

Measured memory_bytes: 384
function Main(input){
	var i = 0;
    var lastChar = input[0];
  	var count = 0;
  
	for ( i = 1; i < input.length ; i++ ){
		if (lastChar === input[i]) {
 			if (input[i] === "0") {
            	lastChar = "1";
            } else { 
            	lastChar = "0";
            }
            count += 1;
        } else { 
      		lastChar = input[i];
        }
    }
  	console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#22:21
#解説解答
t = int(input())
scale = 64
#scale = 4
double = [2**d for d in range(scale)]
double.reverse()
for _ in range(t):
    n = int(input())
    a = list(map(int,input().split()))
    s = input()
    base = [0 for _ in range(scale)]
    for i in range(n)[::-1]:
        now = a[i]
        for d in range(scale):
            if now & double[d]:
                if base[d]:
                    now ^= base[d]
                else:
                    base[d] = now
                    break
        else:
            continue
        if s[i] == '1':
            print(1)
            break
    else:
        print(0)

Measured memory_bytes: 9148
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int n,l;
  string str[105];
  cin>>n>>l;
  
  for(int i=0;i<n;i++){
    cin>>str[i];
  }
  
  sort(str,str+n);
  
  for(int i=0;i<n;i++){
    cout<<str[i];
  }
  cout<<endl;
  return(0);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int W,a,b;
    int result=0;
	cin >> W;
	cin >> a;
    cin >> b;
    if(a<b){
        if(a+W<b) result=b-a-W;
    }
    else{
        if(b+W<a) result=a-b-W;
    }
	cout << result << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N, M;
  cin >> N >> M;
  vector<lint> A(N);
  REP(i, N) cin >> A[i];
  sort(ALL(A));
  vector<lint> S(N);
  S[N-1] = A[N-1];
  IFOR(i, 0, N-1) S[i] = S[i+1] + A[i];
  lint l = -1;
  lint r = 2e5+1;
  while(r-l > 1) {
    lint x = (l+r) / 2;
    lint cnt = 0;
    REP(i, N) {
      lint ll = -1;
      lint rr = N;
      while(rr-ll > 1) {
        lint m = (ll + rr) / 2;
        if(A[i] + A[m] >= x) {
          rr = m;
        } else {
          ll = m;
        }
      }
      cnt += N-rr;
    }
    //cout << x << " " << cnt << " " << M << endl;
    if(cnt >= M) {
      l = x;
    } else {
      r = x;
    }
  }
  //cout << l << endl;
  lint ans = 0;
  lint cnt = 0;
  REP(i, N) {
    lint ll = -1;
    lint rr = N;
    while(rr-ll > 1) {
      lint m = (ll + rr) / 2;
      if(A[i] + A[m] > l) {
        rr = m;
      } else {
        ll = m;
      }
    }
    ans += A[i]*(N-rr);
    if(rr < N) ans += S[rr];
    M -= (N-rr);
  }

  ans += l*M;
  cout << ans << endl;

}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
 
int main() {
	int n, k;
	cin >> n >> k;
	long long ans = 0, d = 0;
	for (int i = 1;i <= n;i++) {
		if (k % 2 == 0) {
			if (i % k == 0)ans++;
			else if (i % (k / 2) == 0)d++;
		}
		else {
			if (i%k == 0)ans++;
		}
	}
	cout << ans * ans * ans + d * d*d << endl;
}


Measured memory_bytes: 256
import math
import itertools
#n = int(input())
#n, d = list(input().split())
#n, l = list(map(int, input().split()))


n = int(input())
a = []
b = []

for i in range(n):
    x,y = [int(j) for j in input().split()]
    a.append(x)
    b.append(y)


mN = -1
posi = -1

for i in range(n):
    if a[i] > mN:
        mN = a[i]
        posi = i

print(mN+b[posi])



Measured memory_bytes: 11116
import collections

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

c = collections.Counter(ai)

nbanned = {}

for it in c.items():
    nbanned[it[0]] = int(it[1] * (it[1] - 1) * 0.5)

s = sum(nbanned.values())

for num in ai:
    if nbanned[num] == 0 or nbanned[num] == 1:
        t = nbanned[num]
    else:
        u = c[num] - 1
        t = nbanned[num] - int(u * (u - 1) * 0.5) 

    print(s - t)

Measured memory_bytes: 32028
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int maxn=2e5+233;
int n,m;
int cnt[maxn],p[maxn];
char s[maxn];
int main()
{
	cin>>n;
	cin>>s+1;
	int c=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='#')
			c++;
		else
			cnt[c]++;
	}
	p[c+1]=0;
	for(int i=c;i>=1;i--)
		p[i]=p[i+1]+cnt[i];
	int ans=p[1];
	for(int i=1;i<=c;i++){
		ans=min(ans,i+p[i+1]);
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>

int main(){
  int A[100],N,temp,j,i,flag;
  int count=0;

  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&A[i]);
    flag = 1; // 逆の隣接要素が存在する
    while(flag){
           flag = 0;
       for(j=N-1;j>=1;j--){
	 if(A[j] < A[j-1]){
	   temp=A[j-1];
	   A[j-1]=A[j];
	   A[j]=temp;
	   count++;
	   
	   flag=1;
	 }
	 }
    }
  for(i=0;i<N-1;i++){
  printf("%d ",A[i]);
  }
  for(i=N-1;i<N;i++){
     printf("%d\n",A[i]);
  }
  printf("%d\n",count);
       
  return 0;
}



Measured memory_bytes: 2104