akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define ll long long
typedef pair<int, int> pii;
ll mod=998244353;
ll p=1e9+7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    map<ll,ll> m1; map<ll,ll> m2;
    ll n; cin>>n;
    for(ll i=0; i<n; i++){
        ll x; cin>>x;
        m1[i+1-x]++;
        m2[i+1+x]++;
    }
    ll ans=0;
    for( auto p : m2 ){
        ans+= m1[p.first]*p.second;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 37964
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        System.out.println(s.nextInt()==s.nextInt()?"Yes":"No");


    }

}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25400
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            total = 500 * i + 100 * j + 50 * k
            if total == X:
                count +=1

print(count)    

        

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


using namespace std;

int main(){
    int N;
    cin >> N;
    int d[N];

    int ans = 0;

    for(int i = 0;i< N;i++){
        cin >> d[i];
    }

    sort(d,d+N);

    for(int i = 0; i < 100001; i++){
        auto itr = upper_bound(d, d+N, i);
        int num1 = itr - d;
        int num2 = (d+N) - itr;

        if(num1 == num2){
            ans++;
        } 


    }
    
    
    cout << ans <<endl;

    return 0;
}

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

int main() {
	int w;
	while(cin >> w, w >= 0) {
		int sum = 0;
		sum += 1150;
		sum += 125 * max(0,w-10);
		sum += 15 * max(0,w-20);
		sum += 20 * max(0,w-30);
		cout << 4280-sum << endl;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fs first
#define sn second
#define mp make_pair
typedef long long int ll;

template<typename T, typename U> static inline void amin(T &x, U y){if (y < x)x = y;}  
template<typename T, typename U> static inline void amax(T &x, U y){if (x < y)x = y;} 

const ll mod = 1e9+7; 

//void precomp(){}

void solve(){
    
    int n;ll w;cin>>n>>w;pair<ll, ll> p[n];
    for(auto& i: p){
    	cin>>i.fs>>i.sn;
    }
    vector<vector<ll>> dp(n,vector<ll>(w+1,0));
    for(int j=0;j<w+1;j++){if(p[0].fs<=j)dp[0][j]=p[0].sn;}
    for(int i=1;i<n;i++){
    	for(int j=0;j<w+1;j++){
            dp[i][j]=dp[i-1][j];
            if(j>=p[i].fs)amax(dp[i][j],dp[i-1][j-p[i].fs]+p[i].sn);
    	}
    }
    cout<<dp[n-1][w]<<"\n";
}

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

    //precomp();
	
	//int tc;cin>>tc;while(tc--)
    solve();

    return 0;
}

Measured memory_bytes: 82376
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
using namespace std;

ostream& operator << (ostream &out, vector<int> &v) { for(auto a:v) out << a<<" "; out<<endl; }

ll dp[3004][3004];
bool P[3004][3004];
int n,m;



int main()
{
  int n,m;
  cin >> n >> m;
  char c;
  for(int i=1;i<=n;i++) for(int j=1;j<=m;j++)
  {
    cin >> c;
    P[i][j]=(c=='.');
  }
  for(int i=n; i>=0; i--)
  {
    if(P[i][m]==0) break;
    dp[i][m]=1;
  }
  for(int i=m; i>=0; i--)
  {
    if(P[n][i]==0) break;
    dp[n][i]=1;
  }
  for(int i=n-1;i>=0;i--) for(int j=m-1;j>=0;j--)
  {
    if(P[i][j]==0) continue;
    dp[i][j]=(dp[i+1][j]+dp[i][j+1])%mod;
  }

  cout << dp[1][1]<<endl;
}


Measured memory_bytes: 28928
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL n;
    LL m;
    cin >> n >> m;
    vector<LL> x(n);
    vector<LL> y(n);
    vector<LL> z(n);
    for(LL i=0; i<n; i++){
        cin >> x[i] >> y[i] >> z[i];
    }

    LL ans=0;
    for(LL i=-1; i<=1; i+=2){
        for(LL j=-1; j<=1; j+=2){
            for(LL k=-1; k<=1; k+=2){
                vector<LL> d(n);
                for(LL l=0; l<n; l++){
                    d[l]=x[l]*i+y[l]*j+z[l]*k;
                }
                sort(d.begin(), d.end(), greater<LL>());
                LL tmp=0;
                for(LL l=0; l<m; l++){
                    tmp+=d[l];
                }
                ans=max(ans,tmp);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3540
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  int n,d;
  cin >> n >> d;

  cout << ceil((D)n / (2 * d + 1)) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n;
    int a,b,c;
    do{
        scanf("%d",&n);
    } while (n < 100 || n > 999);

    a=n/100;
    b=(n-a*100)/10;
    c=(n-a*100)-b*10;
    if(a==7||b==7||c==7)
        printf("Yes");
    else
        printf("No");
    
    return 0;
}


Measured memory_bytes: 1672
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
    int n,k;
    cin>>n>>k;
    V<ll> a(n);
    ll sum=0;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(all(a));
    for(int i=0;i<k;i++)sum+=a[i];
    cout<<sum<<"\n";
}


Measured memory_bytes: 3660
N = gets.to_i
primeNumbers = []
(1..1555).each do |i|
  next if i == 1

  if i == 2
    primeNumbers.push(i)
    next
  end

  judge = true
  primeNumbers.each do |number|
      if i % number == 0
        judge = false;
        break;
      end
  end
  primeNumbers.push(i) if judge
end
primeNumbers =  primeNumbers.select{|i| i%5 == 1}
puts primeNumbers[0..N-1].join(" ")



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


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

//long long  factorial(long long n) {
//    if (n > 0) {
//        return n * factorial(n - 1);
//    } else {
//        return 1;
//    }
//}
long long  factorial(long long n, long long depth) {
    if (n > 1) {
        depth++;
        return factorial(n / 2, depth);
    } else {
        return depth;
    }
}

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

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}



//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
  int  a, b, c, d, e, X, Y ,r;
//  unsigned long long  a, b, c, d, e, X, Y;
  //  double  c;
// long long  A[200003]={};
  int  A[200003]={};
  int  B[100003]={};
//  int  C[100003][100001]={};
  int  C[100003]={};

  int  flg=0;

//  char s[101][101]={};
  char s[100001]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p=0,q=0;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int min =100000001;
  int len=0;
  int l=0;
//  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  long long  ans=0;
  int ans_ac=0;
  int ans_wa=0;
  int max=0;
  long long sum=0;
  int addr=0;
  int ptn=0;
  int  tmp=0;
  double per=0; 
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%d %d", &a, &b);
  
  for(i=0;i<b;i++){
    scanf("%d",&A[i]);
  }
//  qsort(A, b, sizeof(int), compare_int);
  for(i=1;i<b;i++){
//    printf("%d\n",A[i]-A[i-1]);
    if(max<(A[i]-A[i-1])) max=A[i]-A[i-1];
  }
//    printf("%d\n",A[b-1]-A[0]);

  if(max<((a-A[b-1])+A[0])) max=(a-A[b-1])+A[0];
    printf("%d\n",a-max);
  
return 0;
}


Measured memory_bytes: 896
import sys
from collections import deque
input = sys.stdin.readline
N = int(input())
G = [[] for _ in range(N)]
ans = {}
queue = deque([])
e = []
for l in range(N-1):
    temp = list(map(int,input().split()))
    temp[0] -= 1
    temp[1] -= 1
    e.append(tuple(temp))
    ans[(temp[0],temp[1])] = 0
    ans[(temp[1],temp[0])] = 0
    G[temp[0]].append(temp[1])
    G[temp[1]].append(temp[0])
    if l == 0:
        queue.append(temp[0])
#使えない色
nuc = [[0] for _ in range(N)]
#使った色
auc = []
#答え
def bfs(x):
    k = 1
    for i in G[x]:
        if ans[(x,i)] ==0:
            queue.append(i)
            flag = 1
            while flag:
                if k not in nuc[x]:         
                    ans[(x,i)] = k
                    ans[(i,x)] = k
                    nuc[x].append(k)
                    nuc[i].append(k)
                    if k not in auc:
                        auc.append(k)
                    flag = 0
                else:
                    k += 1
                
while len(queue) > 0:
    next_ = queue.popleft()
    bfs(next_)
print(len(auc))
for m in e:
    print(ans[m])


Measured memory_bytes: 125088
n = int(input())
lis = []
for i in range(n):
    s,p = input().split()
    smal_lis = [s,int(p),i+1]
    lis.append(smal_lis)
lis.sort(key=lambda x:x[1],reverse=True)
lis.sort(key=lambda x:x[0])

for i in range(n):
    print(lis[i][2])


Measured memory_bytes: 3060
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

trait ChMinMax {
    fn chmin(&mut self, other: Self);
    fn chmax(&mut self, other: Self);
}
impl<T> ChMinMax for T
where
    T: PartialOrd,
{
    fn chmin(&mut self, other: Self) {
        if *self > other {
            *self = other
        }
    }
    fn chmax(&mut self, other: Self) {
        if *self < other {
            *self = other
        }
    }
}

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, h: usize, w: usize, m: usize);
    let mut row = vec![0usize; h];
    let mut col = vec![0usize; w];
    let mut targets = HashSet::new();
    for _ in 0..m {
        parse!(it, x: u1, y: u1);
        row[x] += 1;
        col[y] += 1;
        targets.insert((x, y));
    }
    let rowmax = *row.iter().max().unwrap();
    let mut rc: Vec<_> = row
        .iter()
        .enumerate()
        .filter(|(i, &x)| x == rowmax)
        .map(|(i, &x)| i)
        .collect();

    let colmax = *col.iter().max().unwrap();
    let mut cc: Vec<_> = col
        .iter()
        .enumerate()
        .filter(|(_, &x)| x == colmax)
        .map(|(i, _)| i)
        .collect();
    let ret = rowmax + colmax;
    if cc.len() * rc.len() > m {
        println!("{}", rowmax + colmax);
        return;
    }
    let mut flag = true;
    'outer: for &i in &rc {
        for &j in &cc {
            if !targets.contains(&(i, j)) {
                flag = false;
                break 'outer;
            }
        }
    }
    println!("{}", ret - if flag { 1 } else { 0 });
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


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

int calc(int x) {
    int ret = 0;
    while(x % 2 == 0) {
        ret++;
        x /= 2;
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += calc(a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int N;
  scanf("%d",&N);
  int h,ph;
  int ans=0;
  for (int i = 0; i < N; i++) {
    scanf("%d",&h);
    if (i != 0) {
      if (ph > h) {
        ans += ph-h;
      }
    }
    if (i == N-1) {
      ans += h;
    }
    ph = h;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int []a = new int[M];
		int []b = new int[M];
		for(int i = 0; i < M; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			if(b[i] > N) continue;
		}
		sc.close();
		Data []d = new Data[M];
		for(int i = 0; i < M; i++) {
			d[i] = new Data(a[i], b[i]);
		}
		Arrays.sort(d, new MyComparator());
		int cnt = 0;
		int s = 0;
		for(int i = 0; i < M; i++) {
			if(d[i].a > s) {
				s = d[i].b - 1;
				cnt++;
			}
		}
//		for(Data t : d) {
//			System.out.println(t.b);
//		}
		System.out.println(cnt);
	}
	static class Data{
		int a;
		int b;
		public Data(int a, int b) {
			this.a = a;
			this.b = b;
		}
	}
	static class MyComparator implements Comparator<Data>{
		 @Override
		 public int compare(Data d2, Data d1) {
			 if(d1.b == d2.b) {
				 return d2.a - d1.a;
			 }else {
				 return d2.b - d1.b;
			 }
		 }
	}
}

Measured memory_bytes: 82156
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  string S;
  cin >> S;
  int N;
  N = S.size();
  int count = 0;
  for(int i=0;i<N/2;i++)
  {
    if(S[i]!=S[N-i-1])
    {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


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

int main()
{
   int n, W;
   cin >> n >> W;
   vector<int> w(n);
   vector<ll> v(n);
   rep(i,n) cin >> w[i] >> v[i];
   //dp[i][j] i番目までで、重さWを選ぶ場合の最大価値
   vvl dp(n+1, vector<ll>(W+1, 0));

   for(int i = 0; i < n; i++)
   {
      for(int j = 0; j <= W ; j++)
      {
         if(j - w[i] >= 0) dp[i + 1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
         else dp[i+1][j] = dp[i][j];
      }
   }
   cout << dp[n][W] << endl;
}


Measured memory_bytes: 80256
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    string str;
    cin>>str;
    ll sum=0;
    for(ll i=0;i<str.size();i++)
    {
        sum+=str[i]-'0';
    }
    if(sum%9==0)
     cout<<"Yes"<<endl;
     else             
     cout<<"No"<<endl;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define ll long long
#define F(type, i, a, b) for(type i = a; i <= b; i ++)
#define RF(type, i, a, b) for(type i = a; i >= b;i --)
#define sz(a) sizeof(a)
#define deb(a) cerr<<" ["<<#a<<"->"<<a<<"] "
#define next_line cerr<<'\n'
#define all(a) a.begin(), a.end()
#define iter(it, s) for(auto it = s.begin(); it != s.end(); it ++)

using namespace std;

typedef pair<ll,ll> pii;
typedef pair<ll,ll> pll;

//       1
//      / \ -> Tree
//     2   3
vector<vector<ll> > Tree(100001);
ll mod = 1e9 + 7LL;
vector<bool> vis(100001, false);
vector<pll> dp(vector<pll>(100001, {-1, -1}));

ll NumberOfways(ll st, ll color)
{
    if((color == 0LL) && (dp[st].first != -1LL))
        return dp[st].first;
    if((color == 1LL) && (dp[st].second != -1LL))
        return dp[st].second;
    vis[st] = true;
    ll ans = 1LL;
    for(ll child: Tree[st]){
        if(vis[child])
            continue;
        if(color == 0LL)
            ans *= (NumberOfways(child, 0LL) + NumberOfways(child, 1LL));
        else
            ans *= NumberOfways(child, 0LL);
        ans %= mod;
    }    
    (color == 0LL)?(dp[st].first = ans):(dp[st].second = ans);
    vis[st] = false;
    return ans;
}
void solve()
{
    ll n;
    cin>>n;
    F(ll, v, 1, n - 1){
        ll x,y;
        cin>>x>>y;
        Tree[x - 1].push_back(y - 1);
        Tree[y - 1].push_back(x - 1);
    }
    ll ans = (NumberOfways(0, 0));
    ans += NumberOfways(0, 1);
    ans %= mod;
    cout<<ans<<'\n';
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        freopen("Debug.txt", "w", stderr);
    #else
    #endif
    solve();
}


Measured memory_bytes: 18480
N = int(input())
xu = [input().split() for _ in range(N)]

xu_list = []
for i in range(N):
    if xu[i][1] == "JPY":
        xu_list.append(float(xu[i][0]))
    elif xu[i][1] == "BTC":
        xu_list.append(float(xu[i][0])*380000.0)

print(sum(xu_list))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int a[n], pos[n + 1];
    REP(i,n){
        cin >> a[i];
        pos[a[i]] = i;
    }
    set<int> s;
    s.insert(-1);
    s.insert(n);
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        auto itr = s.upper_bound(pos[i]);
        int right = *itr;
        itr--;
        int left = *itr;
        ans += (ll)i * (ll)(pos[i] - left) * (ll)(right - pos[i]);
        s.insert(pos[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define orep(i,n) for(long long i = 1;i<(n);++i)
#define drep(i,n) for(long long i=n;i>=0;--i)
#define fi first
#define se second
#define emb emplace_back
#define fcout cout << fixed << setprecision(15)

using namespace std;
using ll = long long;
using P = pair<int,int>;

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

const int mx = 100008;
ll INF = 1e18l;
// dp[v]=min(w)
ll dp[mx];

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

  orep(i,mx) dp[i] = INF;

  rep(i,n) {
    int wi,vi;
    cin >> wi >> vi;
    drep(j,mx-vi) {
      dp[j+vi] = min(dp[j+vi],dp[j]+wi);
    }
  }

  int res=0;
  rep(i,mx) if(dp[i] <= w) res = max(res,i);
  cout << res << endl;

  return 0;
}


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

int a, b;

int main() {
    cin >> a >> b;
    for (int i = 1; i <= 20000; i++) {
        int x = i * 8 / 100, y = i * 10 / 100;
        if (x == a && y == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vi A(N);
  int ans = 0;
  rep(i,N) {
    cin >> A[i];
    ans += A[i];
  }
  sort(rng(A));
  
  rep(i,N) {
    if(ans%10!=0) {
      cout << ans << endl;
      return 0;
    }
    if(A[i]%10!=0) {
      ans -= A[i];
    }
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    // 準備
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int i_r = s.length();
    int hug = 0;

    // 文字列の両側から比較していって、一致しなかったらハグ
    for(int i_l=0; i_l<i_r/2; ++i_l) {
      if(s.charAt(i_l) != s.charAt(i_r-(1+i_l))) {
        ++hug;
      }
    }
    System.out.println(hug);
  }
}

Measured memory_bytes: 22868
#include<vector>
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  li n; cin >>n;
  vector<li> a(n);
  li m=0;
  for(li& x:a){
    cin >>x;
    m+=x;
  }
  li s=n*(n+1)/2;
  if(m%s){
    printf("NO");
    return 0;
  }
  m/=s;
  rep(i,n-1){
    if((a.at(i)-a.at(i+1)+m)%n or (a.at(i)-a.at(i+1)+m)/n<0){
      printf("NO");
      return 0;
    }
  }
  if((a.at(n-1)-a.at(0)+m)%n or (a.at(n-1)-a.at(0)+m)/n<0){
    printf("NO");
    return 0;
  }
  printf("YES");
}

/// confirm df==0 ///


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string>
#include<string.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int a;
	cin >> a;
	int ans = 0;
	while (a > 0) {
		if (a % 10 == 2) {
			ans++;
		}
		a /= 10;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a,b,c;
	int max,mid,min;
	int work;
	scanf("%d %d %d", &a, &b, &c);
	if(a<b){
		if(b<c){
			min=a;
			mid=b;
			max=c;
		}
		else{
			if(a<c){
				min=a;
				mid=c;
				max=b;
			}
			else{
				min=c;
				mid=a;
				max=b;
			}
		}
	}
	else{
		if(a<c){
			min=b;
			mid=a;
			max=c;
		}
		else{
			if(b<c){
				min=b;
				mid=c;
				max=a;
			}
			else{
				min=c;
				mid=b;
				max=a;
			}
		}
	}
	printf("%d %d %d\n", min,mid,max);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <string>

using namespace std;

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

	if (s == "SUN")ans = 7;
	if (s == "MON")ans = 6;
	if (s == "TUE")ans = 5;
	if (s == "WED")ans = 4;
	if (s == "THU")ans = 3;
	if (s == "FRI")ans = 2;
	if (s == "SAT")ans = 1;
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int N, K;

    scanf("%d %d", &N, &K);

    char S[N + 1];

    scanf("%s", S);

    for (int i = 0; i < N; ++i) {
        if (i == K - 1) {
            printf("%c", S[i] + +0x20);
        } else {
            printf("%c", S[i]);
        }
    }

    printf("\n");

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	string s;cin>>s;
	int n = s.length();
	int arr[n];
	for(int i=0;i<n;i++){
		arr[i] = int(s[i]);
	}
	bool flag = true;
	for(int i=0;i<n/2;i++){
		if(arr[i]!=arr[n-i-1]){
			flag = false;
			break;
		}
	}
	if(flag==true){
		int l = (n-1)/2;
		for(int i=0;i<l/2;i++){
			if(arr[i]!=arr[l-i-1]){
				flag = false; break;
			}
		}
		if(flag==true){
			int p = (n+3)/2;
			int l = (n-1)/2;
			for(int i=0;i<l/2;i++){
				if(arr[i+(p-1)]!=arr[n-i-1]){
					flag = false; break;
				}
			}
			if(flag==true){
				cout<<"Yes"<<endl;
			}
			else{
				cout<<"No"<<endl;
			}
		}
		else{
			cout<<"No"<<endl;
		}
	}
	else{
		cout<<"No"<<endl;
	}
} 

Measured memory_bytes: 256
R, G, B, N = map(int, input().split())
counter = 0
if R < G:
  R, G = G, R
if G < B:
  G, B = B, G
if R < G:
  R, G = G, R
r = 0
while r * R <= N:
  g = 0
  if B == 1:
    counter += (N - r*R)//G + 1
    r += 1
    continue
  while g * G <= N:
    b = (N - r*R - g*G)/B 
    if b < 0:
      break
    elif b == int(b):
      counter += 1
    g += 1
  r += 1
print(counter)

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  int low = max(a, c);
  int high = min(b, d);
  cout << max(0, high - low) << endl;
  
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define IN freopen("test.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2
#define sq(x)  ((x)*(x))

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

#define maxn 200005

int Next[maxn] , last[maxn] ;
int c[maxn] ;
int dp[maxn] ;

int main()
{
    int n ;

    scanf("%d",&n) ;
    for(int i=1 ; i<=n ; i++) scanf("%d",&c[i]) ;

    for(int i=1 ; i<maxn ; i++) last[i] = n+1 ;

    for(int i=n ; i>=1 ; i--)
    {
        Next[i] = last[ c[i] ] ;
        last[ c[i] ] = i ;
    }

    dp[n] = 1LL ;
    for(int i=n-1 ; i>=1 ; i--)
    {
        dp[i] = dp[i+1] ;
        if( Next[i] != i+1 && Next[i] <= n ) dp[i] = ( dp[i] + dp[ Next[i] ] )%mod ;
    }

    printf("%d\n",dp[1]) ;

    return 0 ;
}


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

int main() {
  int a,b;
  while(cin >> a >> b && (a!=0 || b!=0)) {
    int sum,max,ans=0;
    sum=max=a+b;
    for(int i=1; i<5; i++) {
      cin >> a >> b;
      sum=a+b;
      if(sum>max) {
	max=sum;
	ans=i;
      }
    }
    cout << (char)('A'+ans) << " " << max << endl;
  }
  return 0;
}


Measured memory_bytes: 1160
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }
const long long INF = 1LL << 60;

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

    int ans = 1;

    rep(i,n-1){
        if(s.at(i) != s.at(i+1)) ans++;
    }

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

Measured memory_bytes: 512
dimensions = raw_input()
h,w = int(dimensions.split(" ")[0]),int(dimensions.split(" ")[1])

matrix = []
for i in range(h):
	values = raw_input()
	matrix.append([int(i) for i in values.split(" ")])

trace = []
for i in range(h):
	start = 0 
	end = w
	step = 1
	if i%2!=0:
		start = w-1
		end = -1
		step = -1
	for j in range(start,end,step):
		trace.append([(i,j),matrix[i][j]])

moviments = []
for i in range(len(trace)-1):
	if trace[i][1]%2!=0:
		trace[i+1][1] += trace[i][1]
		moviments.append(str(trace[i][0][0]+1)+" "+str(trace[i][0][1]+1)+" "+str(trace[i+1][0][0]+1)+" "+str(trace[i+1][0][1]+1))
print(len(moviments))
for i in moviments:
	print(i)


Measured memory_bytes: 69036
import java.util.*
import kotlin.math.max
import kotlin.math.min

fun main() {
    val k = readInt()

    var ans = 0L
    for (a in 1..k) {
        for (b in 1..k) {
            for (c in 1..k) {
                ans += gcd(gcd(a, b), c)
            }
        }
    }
    println(ans)
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun gcd(p: Int, q: Int): Int {
    if (p % q == 0) return q
    return gcd(q, p % q)
}

fun gcd(list: List<Int>): Int {
    val stack = Stack<Int>()
    list.forEach { stack.push(it) }

    while (stack.size > 1) {
        val (a, b) = (0..1).map { stack.pop() }
        val push = stack.push(min(a, b))
        val r = max(a, b) % min(a, b)
        if (r > 0) stack.push(r)
    }
    return stack.pop()
}

Measured memory_bytes: 34704
h, n = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(n)]

#dp[i][j] := i番目までの物でjの価値を実現するのに必要な最小コスト
dp = [[0] * (h+1) for _ in range(n+1)]
for j in range(1, h+1):
    dp[0][j] = float("inf")

for i in range(n):
    for j in range(h+1):
        if j < items[i][0]:
            dp[i+1][j] = min(dp[i][j], items[i][1])
        else:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j-items[i][0]] + items[i][1])

print(dp[n][h])

Measured memory_bytes: 120028
#include <iostream>
#include <vector>
//https://atcoder.jp/contests/abc135/tasks/abc135_b
using namespace std;

int main() {
  int n;
  int count = 0;
  cin >> n;
  vector<int> p(n);
  for (int i=0; i<n; i++){
    cin >> p[i];
    if(p[i] != i+1){
      count += 1;
      if (count > 2)
      {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision


#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

namespace Problem{
using namespace std;
class Writer{
static ostringstream oss;
public:template<class T> void appendln(const vector<vector<T>> &ans,string spl=" ", string el="\n"){for(int i=0; i<(int)ans.size(); ++i){for(int j=0; j<(int)ans[i].size(); ++j){oss << ans[i][j];oss << (j==(int)ans[i].size()-1?el:spl);}}}
    template<class T> void appendln(const vector<T>& ans, string spl=" "){for(int i=0; i<(int)ans.size(); ++i){oss << ans[i] << (i==(int)ans.size()-1?"\n":spl);}}
    template<class T> void appendln(const T& answer){oss << answer << "\n";}
    template<class T> void append(const T& answer){oss << answer;}
    void appends(const string spl){oss.seekp((int)oss.tellp()-1);oss<<"\n";}
    template<class F, class... R>void appends(const string spl,const F& fi, const R&... rest){oss << fi << spl; appends(spl, rest...);}
    static void write(){cout << oss.str();}
    Writer(){static bool is_single =true;assert(is_single);is_single=false;};
};ostringstream Writer::oss;


class Solver{
public:
    int q;
    LL a,b;
    Solver(LL q):q(q){};

    void solve(){
        for(int i=0; i<q; ++i){
            cin >> a >> b;
            if(a>b)swap(a,b);
            LL ans = a-1;
            LL lb = a, ub = 2e9;
            while(ub-lb>1){
                LL mid = (lb+ub)/2;
                if((mid)*(mid+1)>a*b-1) ub = mid;
                else lb = mid;
            }
            DBG(lb,ub)
            //ub made
            ans += ub-a;
            ans += (int)ceil((a*b-1)/ub) -1 ;
            cout << ans <<"\n";

        }
    }
};
}

int main(){
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    long long q=0;
    std::cin >> q;
    Problem::Solver sol(q);
    sol.solve();
    Problem::Writer::write();
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;
using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353 

ll mod_pow(ll a,ll b,ll m) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2 , mod);
}

void solve()
{
	int n , m;
	
	cin >> n >> m;
	
	int dp[n + 5] {};
	
	for(int i = 0; i < m; ++i) {
		int l , r;
		
		cin >> l >> r;
		
		dp[l]++;
		dp[r+1]--;
	} 
	
	int res = 0;
	
	for(int i = 1; i <= n; ++i) {
		dp[i] += dp[i-1];
		
		res += (dp[i] == m);
	}
	
	cout << res;
	
}

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


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

void solve()
{
	int N,X,T;
	cin>>N>>X>>T;

	int time = 0,items = 0;

	if(N <= X)
		cout<<T<<endl;

	else
	{
		while(items < N)
		{
			time = time + T;
			items = items + X;
		}

		cout<<time<<endl;
	}
}

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

	solve();

	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>
#include <functional>
#include <memory>


long long int gcd(const long long int a, const long long int b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
long long int lcm(const long long int a, const long long int b) {
	return a / gcd(a, b) * b;
}
int main() {
	long long int a, b, c, d;
	std::cin >> a >> b >> c >> d;
	--a;
	std::cout << b - b / c - b / d + b / lcm(c, d) - a + a / c + a / d - a / lcm(c, d) << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };

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

double g(ll n) {
	return (double)n/ f(n);
}

int main()
{
	vector<ll> res;
	ll base = 1;

	for (int i = 0; i < 15; i++) {
		for (int j = 1; j < 150; j++) {
			res.push_back(base * (j + 1) - 1);
		}
		base *= 10;
	}

	sort(res.begin(), res.end());
	res.erase(unique(res.begin(), res.end()), res.end());

	for (ll i = 0; i < res.size(); i++) {
		for (ll j = i + 1; j < res.size(); j++) {
			if (g(res[i]) > g(res[j])) {
				res.erase(res.begin() + i--);
				break;
			}
		}
	}

	ll K;
	cin >> K;
	for (ll i = 0; i < K; ++i) {
		cout << res[i] << endl;
	}
}

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

signed main(){
  int A,B;
  string S,ans="No";
  cin>>A>>B>>S;
  int SS=S.size();
  if((A+B+1)!=SS){
    cout<<ans<<endl;
    return 0;
  }
  rep(i,SS){
    if(i!=A&&S[i]=='-'){
      cout<<ans<<endl;
      return 0;
    }
  }
  if(S[A]=='-')ans="Yes";
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int nx[4] = {1,0,-1,0};
int ny[4] = {0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(i,n){
        bool x[26] = {0},y[26] = {0};
        rep(j,i+1,n){
            x[s[j]-'a'] = 1;
        }
        rep(j,i+1){
            y[s[j]-'a'] = 1;
        }
        int c = 0;
        rep(i,26){
            if (x[i]&y[i]) c++;
        }
        chmax(ans,c);
    }
    PRINT(ans);
}


Measured memory_bytes: 256
N, D = map(int, input().split())
points = []
threshold = D * D
ans = 0
for i in range(N):
    point = input().split()
    points.append((int(point[0]), int(point[1])))

for p in points:
    if p[0] ** 2 + p[1] ** 2 <= threshold:
        ans += 1

print(ans)

Measured memory_bytes: 36040
<?php

while(1){

	$x=trim(fgets(STDIN));

	// 0?????¨?????????
	if($x==0){

		break;
	}

	// printf("%d%d%d\n",$m,$f,$r);

	printf("%d\n",MySum($x));


}

function MySum($a){

	$mysum=0;
	foreach(str_split($a) as $val){
		$mysum+=$val;

	}

	return $mysum;


}

Measured memory_bytes: 15392
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, r;
	cin >> n >> r;
	int ans;
	if (n >= 10) {
		ans = r;
	}
	else {
		ans = r + 1000 - 100 * n;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
  	static Scanner scanner = new Scanner(System.in);
 
	public static void main(String[] args) {
      	String s = scanner.next();
    	System.out.println(s.length() == 2 ? s : String.valueOf(new char[] {s.charAt(2), s.charAt(1), s.charAt(0)}));
    }
}

Measured memory_bytes: 21716
#include "bits/stdc++.h"

using namespace std;
using ll = long long int;

int main()
{
    string s;
    cin >> s;
    reverse(s.begin(), s.end());

    vector<ll> count(2019 + 5);
    int current = 0;
    int mult = 1;
    count[current]++;

    for (auto &c : s)
    {
        current = (current + mult * (c - '0')) % 2019;
        count[current]++;
        mult = (mult * 10) % 2019;
    }

    ll ans = 0;
    for (auto &i : count)
    {
        ans += i * (i - 1) / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3716
b, c = map(int, input().split())
chk = {"a":0}
for i in range(b):
        lst = list(map(int, input().split()))
        for j in lst[1:]:
                if(j in chk.keys()):
                        chk[j] += 1
                else:
                        chk[j] = 1
ans = 0
for i in chk.values():
        if i == b:
                ans += 1
print(ans)

Measured memory_bytes: 3064
// Aizu Vol-1 0117: A reward for a Carpenter
// 2017.8.8

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

#define INF 10000000
#define MAX 20
char visited[MAX + 2];
int cost[MAX+2][MAX+2], total[MAX + 2];
int n;

int search(int s, int g);

int main(void)
{
	int m, s, g, V, P;
	int a, b, c, d;
	int i;

	memset(cost, -1, sizeof(cost));
	scanf("%d%d", &n, &m);
	for (i = 0; i < m; i++) {
		scanf("%d,%d,%d,%d", &a, &b, &c, &d);
		cost[a][b] = c, cost[b][a] = d;
	}
	scanf("%d,%d,%d,%d", &s, &g, &V, &P);
	if (s == g) printf("%d\n", V - P);
	else printf("%d\n", V - P - search(s, g) - search(g, s));
	return 0;
}

int search(int s, int g)
{
	int  i, j, next, min;

	for (i = 1; i <= n; i++) visited[i] = 0, total[i] = INF;
	total[s] = 0, next = s;
	do {
		i = next, visited[i] = 1, min = INF;
		for (j = 1; j <= n; j++) {
			if (visited[j]) continue;
			if (cost[i][j] >= 0 && total[i] + cost[i][j] < total[j]) {
				total[j] = total[i] + cost[i][j];
			}
			if (total[j] < min) min = total[j], next = j;
		}
	} while (min < INF);
	return total[g];
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  ll n, a, b;
  cin >> n >> a >> b;
  n--, a--, b--;

  ll ans;
  if (a%2 == b%2) {
    ans = (b-a)/2;
  }
  else {
    ll ans1 = n-b+1 + (n-(a+(n-b+1)))/2;
    ll ans2 = a-0+1 + ((b-(a-0+1))-0)/2;
    ans = min(ans1, ans2);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256