akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(int i = K; i < N; i++)
#define ll long long int
using namespace std;
int main() {
ll x;cin >> x;
if(x%11 == 0)cout << 2*(x/11);
if(x%11 >= 1 && x%11 <= 6)cout << (x/11)*2 + 1;
if(x%11 > 6)cout << (x/11)*2 + 2;
}

Measured memory_bytes: 3580
#include <stdio.h>
#include <string.h>
int main(void) {
    char st[202];
    int i,n;

    scanf("%s", st);
    
    n = strlen(st);

    for (i = n - 2 ; i ; i -= 2) {
        if(strncmp(st, st  + i/2 , i/2 ) == 0) {
            printf("%d\n",i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class AABC333 {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int a, b;
	    in >> a >> b;
	    if(a%2 == 0 || b%2 == 0) ans(false, out);
	    else ans(true, out);
	}
};


int main() {
	AABC333 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

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

typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x)
{
  while( x->left != NIL )
    {
      x = x->left;
    }
  return x;
}

Node treeMaximum(Node x)
{
  while( x->right != NIL )
    {
      x = x->right;
    }
  return x;  
}

Node treeSearch(Node u, int k)
{
  if( u == NIL || k == u->key )
    {
      return u;
    }
  if( k < u->key )
    {
      return treeSearch(u->left,k);
    }
  else return treeSearch(u->right,k);
  
}

Node treeSuccessor(Node x)
{
  Node y;
  if( x->right != NIL )
    {
      return treeMinimum(x->right);
    }

  y = x->parent;
  while( y != NIL && x == y->right )
    {
      x = y;
      y = y->parent;
    }

  return y;
}

void treeDelete(Node z)
{
  Node y; // node to be deleted
  Node x; // child of y

  if( z->left == NIL || z->right == NIL ) y = z;
  else y = treeSuccessor(z);
    
  if( y->left != NIL ) x = y->left;
  else x = y->right;
    
  if( x != NIL ) x->parent = y->parent;

  if( y->parent == NIL ) root = x;
  else if( y == y->parent->left ) y->parent->left = x;
  else y->parent->right = x;

  if( y != z ) z->key = y->key;
 
}

void insert(int k)
{
  Node y = NIL;
  Node x = root;
  Node z;

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

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

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

void inorder(Node u)
{ 
  if( u == NIL ) return;

  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
 
void preorder(Node u)
{ 
  if( u == NIL ) return;

  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


int main()
{
  int n, i, x;
  char com[20];
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ )
    {
      scanf("%s", com);
      if ( com[0] == 'f' )
	{
	  scanf("%d", &x);
	  Node t = treeSearch(root, x);
      
	  if ( t != NIL ) printf("yes\n");
	  else printf("no\n");
	}
      else if ( com[0] == 'i' )
	{
	  scanf("%d", &x);
	  insert(x);
	}
      else if ( com[0] == 'p' )
	{
	  inorder(root);
	  printf("\n");
	  preorder(root);
	  printf("\n");
	}
      else if ( com[0] == 'd' )
	{
	  scanf("%d", &x);
	  treeDelete(treeSearch(root, x));
	}
    }
  
  return 0;
}
 



Measured memory_bytes: 20480
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;
import java.util.TreeSet;
import java.util.Stack;

public class Main{
       
	public static void main(String[] args) {
		
            Scanner sdf = new Scanner(System.in);
            int t=1;
            next: while(t-->0){
                long n=sdf.nextLong();
                long a=sdf.nextLong();
                long b=sdf.nextLong();
               long bb=(n/(a+b))*a ;
               long rem=n%(a+b);
               bb=bb+Math.min(a, rem);
                System.out.println(bb);
            }
        }

        
}

Measured memory_bytes: 23124
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    h,w,k=map(int,input().split())
    S=[input() for _ in range(h)]
    ANS=[[0]*w for _ in range(h)]
    cunt=0
    for i,s in enumerate(S):
        for j,ss in enumerate(s):
            if ss=='#':
                cunt+=1
                ANS[i][j]=cunt
            elif j>=1 and ANS[i][j-1]>0:
                ANS[i][j]=ANS[i][j-1]
        color=0
        if ANS[i][-1]!=0:
            for j in range(w-2,-1,-1):
                if ANS[i][j]==0:
                    ANS[i][j]=ANS[i][j+1]
    for i in range(h-2,-1,-1):
        if ANS[i][0]==0:
            for j,ans in enumerate(ANS[i+1]):
                ANS[i][j]=ans
    for i in range(h):
        if ANS[i][0]==0:
            for j,ans in enumerate(ANS[i-1]):
                ANS[i][j]=ans
    for ans in ANS:
        print(*ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 7548
#include<stdio.h>
#include<stdlib.h>

int Sum(int h[],int n)
{
	int sum=0;
	int i;
	for(i=0;i<n;i++) sum+=h[i];
	return sum;
}

int main()
{
	int n,i,x=0;
	int *h;
	short flag=0;	// T1 F0

	scanf("%d",&n);
	h=(int *)malloc(n*sizeof(int));

	for(i=0;i<n;i++)	scanf("%d",&h[i]);

	do
	{
		for(i=0;i<n;i++)
		{
			if(h[i]>0)
			{
				h[i]--;
				if(!flag) x++;
				flag=1;
			}
			else
			{
				flag=0;
			}
		}
		flag=0;
	}while(Sum(h,n)>0);

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

	free(h);
	return 0;
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 200007;

int n,val[_],stk[_]={0},top=0,xl[_],xr[_];

int main()
{
	n=ty();
	for(int i=1;i<=n;i++)val[i]=ty(),xl[i]=1,xr[i]=n;

	top=0,stk[top]=0;
	for(int i=1;i<=n;i++)
	{
		while(top && val[stk[top]]>val[i])top--;
		xl[i]=stk[top]+1,stk[++top]=i;
	}
	top=0,stk[top]=n+1;
	for(int i=n;i>=1;i--)
	{
		while(top && val[stk[top]]>val[i])top--;
		xr[i]=stk[top]-1,stk[++top]=i;
	}

	lint ans=0;
	for(int i=1;i<=n;i++)ans=ans+1ll*val[i]*(i-xl[i]+1)*(xr[i]-i+1);
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main() 
{
	int N, n, d;
	while(cin >> N && N)
	{
		vector<int> x(N,0);
		vector<int> y(N,0);

		int dx[4] = {-1, 0, 1, 0};
		int dy[4] = {0, -1, 0, 1};
		
		REP(i,1,N)
		{
			cin >> n >> d;	
			x[i] = x[n] + dx[d];
			y[i] = y[n] + dy[d];
			
		}

		int width=0, height=0;

		width = *max_element(ALL(x)) - *min_element(ALL(x)) + 1;
		height = *max_element(ALL(y)) - *min_element(ALL(y)) + 1;

		cout << width << " " << height << endl;
	}
	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int c = 0, ans = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == 'R') c++;
        else c = 0;
        ans = max(c, ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  string s1,s2;
  cin >> s1;
  cin >> s2;
  int i = 0;
  long ans = 1;
  long mod = 1000000007;
  int mae = 0;//0:: = 1::|
  for(i=0;i<n;i++){
    if(i==0){
      if(s1[i]==s2[i]){
        ans *= 3;
        mae = 0;
      }else{
        ans *= 6;
        mae = 1;
        i++;
      }
    }else{
      if(s1[i]==s2[i]){
        if(mae==0){
          ans *= 2;
          ans %= mod;
        }
        mae = 0;
      }else{
        if(mae==0){
          ans *= 2;
          ans %= mod;
        }else{
          ans *= 3;
          ans %= mod;
        }
        mae = 1;
        i++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/08/20 03:55:25
// -----------------------------------

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using ll = long long;

using mint = atcoder::modint998244353;
using mon = pair<mint, int>;
mon op(mon a, mon b) { return {a.first + b.first, a.second + b.second}; }
mon e() { return {0, 1}; }
using mact = pair<mint, mint>;
mon act(mact x, mon a) {
  return {a.first * x.first + x.second * a.second, a.second};
}
mact comp(mact g, mact f) {
  return {g.first * f.first, g.first * f.second + g.second};
}
mact id() { return {1, 0}; }
using Rars = atcoder::lazy_segtree<mon, op, e, mact, act, comp, id>;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);

  int n,q; cin>>n>>q;
  vector<mon> A(n);
  for (auto& a:A) {
    int v; cin>>v;
    a = {v, 1};
  }
  Rars rars(A);

  while (q--) {
    int t; cin>>t;
    if (t == 0) {
      int l,r,b,c; cin>>l>>r>>b>>c;
      rars.apply(l, r, {b, c});
    } else {
      int l,r; cin>>l>>r;
      cout << rars.prod(l, r).first.val() << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 19552
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int n;
vector <pair<ll,ll>> v(15,make_pair(0,0));
vector <ll> p(15,0);
vector <ll> ans(16);
vector <ll> v1;
void calc(int i,int ctr,ll val[15]){
    if(ctr==n||i==2*n)
        return;
    else{
            ll v2[15];
            ll ans1=0ll;
            for(int j=0;j<n;j++){
                v2[j]=min(val[j],abs(v1[i]-v[j].ff)*p[j]);
                ans1+=v2[j];
            }
            ans[ctr+1]=min(ans[ctr+1],ans1);
            calc(i+2,ctr+1,v2);
            ll v3[15];
            for(int j=0;j<n;j++)
                v3[j]=val[j];
            calc(i+2,ctr,v3);
            ll v4[15];
            ans1=0ll;
            for(int j=0;j<n;j++){
                v4[j]=min(val[j],abs(v1[i+1]-v[j].ss)*p[j]);
                ans1+=v4[j];
            }
            ans[ctr+1]=min(ans[ctr+1],ans1);
            calc(i+2,ctr+1,v4);
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        cin>>n;
        ll ans1=0;
        ll v2[15];
        for(int i=0;i<n;i++){
            cin>>v[i].ff>>v[i].ss>>p[i];
            v2[i]=min(abs(v[i].ff),abs(v[i].ss))*p[i];
            ans1+=v2[i];
            v1.push_back(v[i].ff);
            v1.push_back(v[i].ss);
        }
        for(int i=0;i<=n;i++)
            ans[i]=ans1;
        calc(0,0,v2);
        for(int i=0;i<=n;i++)
            cout<<ans[i]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>

using namespace std ;
int main () {
  int A,B,C,X;
  int sum,tmp,cnt;
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> X;
  bool flag = false;
  for(int i=0;i<A+1;i++) {
    for(int j=0;j<B+1;j++) {
      for(int k=0;k<C+1;k++) {
        tmp = 500*i+100*B+50*C;
        if(X>tmp) {
          flag = true;
        }
        else {
          sum = 500*i+100*j+50*k;
          if(X==sum) {
            cnt = cnt+1;
          }
        }
        if(flag) break;
      }
      if(flag) break;
    }
    flag = false;
  }
  cout << cnt << endl ;
  return(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

void shiftchar(char& ch)
{
	if (isalpha(ch)) {
		if (ch == 'z') {
			ch = 'a';
		} else {
			ch = ch + 1;
		}
	}
}

int main()
{
	string input;
	while (getline(cin, input)) {

		string decoded = input;
		for (int i = 0; i < 26; ++i) {
			for_each(decoded.begin(), decoded.end(), shiftchar);
			if (decoded.find("the") != string::npos ||
				decoded.find("this") != string::npos ||
				decoded.find("that") != string::npos) {
				break;
			}
		}

		cout << decoded << endl;
	}

	return 0;
}

Measured memory_bytes: 1188
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();      
        int N = r.i();
        int a = 0,
            b = 0,
            c = 0,
        count = 0;
        for(int i = 0; i < N; i++){
            String s = r.s();
            int len = s.length();
            for(int j = 0; j < len-1; j++){
                if(s.charAt(j) == 'A'){
                    if(s.charAt(j+1) == 'B'){
                        count++;
                    }
                }
            }
            int state = 0;            
            if(s.charAt(0) == 'B'){
                state++;
            } 
            if(s.charAt(len-1) == 'A'){
                state += 2;
            }
            switch(state){
                case 1:
                b++;
                break;
                case 2:
                a++;
                break;
                case 3:
                c++;
                break;                    
            }
        }
        if(c > 0){
            count += c-1;
            a++;
            b++;
        }
        count += Math.min(a, b);
        if(c > 0 && a == 1 && b == 1){
            count--;
        }
        print(count);        
    }
    static void print(Object o){
        System.out.println(o.toString());
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }

        String s() throws IOException{
            return readLine();
        }

        String[] ss() throws IOException{
            return s().split(" ");
        }

        int Int(String s){
            return Integer.parseInt(s);
        }

        int i() throws IOException{
            return Int(s());
        }

        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
    }
}

Measured memory_bytes: 24020
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 1000005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 998244353;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    while (cin >> n >> m) {
        vector<int>v(n);
        int tot = 0;
        for (auto &i : v) {
            cin >> i;
            tot += i;
        }
        int cnt = 0;
        for (auto &i : v) {
            if (i * 4 * m >= tot) {
                cnt++;
            }
        }
        if (cnt >= m) {
            cout << "Yes\n";
        }
        else {
            cout << "No\n";
        }
    }
    
}


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

int ac(string str){
  int n = str.size();
  int count = 0;
  rep(i,n-1){
     if(str[i]=='A'){
       if(str[i+1] == 'C') count++; 
     }
  }
  return count;
}

void solve(){
  int n,q;
  string s;
  cin >> n >> q;
  cin >> s;
  vector<pair<int,int>> vec;
  rep(i,q){
    int tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    vec.emplace_back(make_pair(tmp1, tmp2)); 
  }
  /*
  rep(i,q){
    int a,b;
    a = vec[i].first;
    b = vec[i].second;
    string sub = s.substr(a, b-a);
    cout << ac(sub) << endl;
  
  */
  vector<int> v;
  int count = 0;
  rep(i,n-1){
     if(s[i]=='A'&&s[i+1]=='C') {
       count++;
     }
     v.emplace_back(count);
     //cout << i << ":" << count << v[i] << endl;
  }
  v.emplace_back(count);
  rep(i,q){
    int a,b;
    a = vec[i].first;
    b = vec[i].second;
    //cout << v[6] << endl; 
    //cout << "v[" << b-1 << "]:" << v[b-1] << " v[a]:" << v[a-1] << endl;
    cout << v[b-2] - v[a-2] << endl;
  }
  
}

int main(){
  solve();
  return 0;
}
  


Measured memory_bytes: 2676
#include <cstdio>
#include <cstring>
using namespace std;

int map[22][22];
int st[2],gl[2];
int n,m,ans;
int move[4][2]={{0,1},{0,-1},{1,0},{-1,0}};

void dfs(int x,int y,int z){
    if(z>=ans)return;
    for(int i=0;i<4;i++){
        int xx=x,yy=y;
        if(map[x+move[i][0]][y+move[i][1]]!=0&&map[x+move[i][0]][y+move[i][1]]!=3)continue;
        for(int j=0;map[xx][yy]==0;j++){
            xx+=move[i][0];
            yy+=move[i][1];
            if(map[xx][yy]==3){
                ans=z;
                return;
            }
        }
        if(map[xx][yy]==1){
            map[xx][yy]=0;
            dfs(xx-move[i][0],yy-move[i][1],z+1);
            map[xx][yy]=1;
        }
    }
}
int main(){
    scanf("%d%d",&m,&n);
    while(n*m!=0){
        for(int i=0;i<=n+1;i++){
            map[i][0]=-1;
            map[i][m+1]=-1;
        }
        for(int i=0;i<=m+1;i++){
            map[0][i]=-1;
            map[n+1][i]=-1;
        }
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++){
                scanf("%d",&map[i][j]);
                if(map[i][j]==2){
                    st[0]=i;st[1]=j;
                    map[i][j]=0;
                }
            }
        ans=11;
        dfs(st[0],st[1],1);
        if(ans>10)ans=-1;
        printf("%d\n",ans);
        scanf("%d%d",&m,&n);
    }
    
    return 0;
}

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

inline void InitRand(){
    srand((unsigned int)time(NULL));
}

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

    for(int i = 0; i < n; i++){
        if(t[i] < x[i] + y[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    for(int i = 0; i < n-1; i++){
        if(x[i] == x[i+1] && y[i] == y[i+1]){
            cout << "No" << endl;
            return 0;
        }
    }

    for(int i = 0; i < n-1; i++){
        InitRand();
        if(abs(t[i]-t[i-1]) < abs((x[i] + y[i])-(x[i+1] + y[i+1])) && rand() % 2 + 1 == 1){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1408
#define _[2<<17]
n,i;A _,B _,T _,F _;long M,D _,P _,R _;
//s(u,i,p){i?s(u,T[i],p),R[i]=R[T[i]]*-~(B[i]-p?s(B[i],F[B[i]],u),D[u]=D[u]*-~D[B[i]]%M,D[B[i]]:0)%M:(D[u]=1);}
//s(u,i,p,I){i?s(u,T[i],p),I=B[i],R[i]=R[T[i]]*-~(I-p?s(I,F[I],u),D[u]=D[u]*-~D[I]%M,D[I]:0)%M:(D[u]=1);}
s(u,i,p,I){i?s(u,I=T[i],p),R[i]=R[I]*-~((I=B[i])-p?s(I,F[I],u),D[u]=D[u]*-~D[I]%M,D[I]:0)%M:(D[u]=1);}
S(u,x,p,i,I){for(i=F[u];I=B[i];I-p?S(I,R[i]*x%M+1,u,0,0),x=x*-~D[I]%M:0)i=T[i];P[u]=x%M;}
main(u,v){for(;~scanf("%d%d",&u,&v);)i++?A[i-1]=B[i]=u,B[i-1]=A[i]=v,i++:(n=u,M=v);for(;--i;F[A[i]]=i)T[i]=F[A[i]];
	s(*R=1,F[1],0);
	for(S(1,1,0);i++<n;)printf("%d ",P[i]);
}

Measured memory_bytes: 15360
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//約数列挙
//昇順
//#include <vector>
//#include <cmath>
std::vector<long long> div(long long n) {
	std::vector<long long> v(1, 1);
	if (n == 1) return v;
	for (long long i = 2; i <= sqrt(n); i++) {
		if (n % i == 0) v.push_back(i);
	}
	if (sqrt(n) == (long long)sqrt(n)) {
		for (long long i = v.size() - 2; i >= 0; i--) v.push_back(n / v[i]);
	}
	else {
		for (long long i = v.size() - 1; i >= 0; i--) v.push_back(n / v[i]);
	}
	return v;
}

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;
	vll v = div(n);
	ll ans = inf;
	for (ll i = 0; i < v.size(); i++) {
		ll a = v[i], b = n / v[i];
		ll subans = max(to_string(a).size(), to_string(b).size());
		ans = min(ans, subans);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
using namespace std;

#define rep(i, e) for (int i = 0; i < e; i++)
#define repp(i, s, e) for (int i = s; i < e; i++)
#define N_Max 100
#define Card_Max 36
#define p(a) printf("%d\n", a);
#define ll long long

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

const long long INF = 1LL << 60;

int main()
{
    string s;
    cin >> s;
    rep(i,s.size()){
        if(i%2==0 && s[i]== 'L') {
            cout << "No" << endl;
            return 0;
        }

        if(i%2==1 && s[i]=='R'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

LL x[200001];
LL y[200001];
vector<LL>v,w;
int main(){
	cin>>N;
	REP(i,N){
		cin>>x[i]>>y[i];
		v.push_back(x[i]+y[i]);
		w.push_back(x[i]-y[i]);
	}
	sort(v.begin(),v.end());
	sort(w.begin(),w.end());
	cout<<max(v[N-1]-v[0],w[N-1]-w[0])<<endl;
	return 0;
}

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

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

ll const mod = 1e9+7;


int main() {
  int N;
  ll cnt = 0;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) {
    cin >> A[i];
  }
  rep(i,N) {
    if (A[i]%2==1 && A[i+1]>0 && i<N-1) {
      A[i+1]--;A[i]++;
    }
    cnt += A[i]/2;
  }
  cout << cnt <<  endl;
}

Measured memory_bytes: 1024
from bisect import bisect_left, bisect_right

n, k, c = map(int, input().split())
s = input()

work = [i for i, e in enumerate(s, 1) if e == "o"]
INF = 10 ** 9

work_l = []
prev = -INF
for e in work:
    if e - prev > c:
        work_l.append(e)
        prev = e

work_r = []
prev = INF
for e in work[::-1]:
    if prev - e > c:
        work_r.append(e)
        prev = e

work_r = work_r[::-1]

ans = []
mx_r = len(work_r)
for e in work:
    l = bisect_left(work_l, e)
    r = mx_r - bisect_right(work_r, e)
    if l + r < k:
        ans.append(e)

print(*ans, sep="\n")


Measured memory_bytes: 20528
import java.util.*;
public class Main{
  public static void main(String []args){
  Scanner sc = new Scanner(System.in);

  int n = sc.nextInt();
  int k = sc.nextInt();
  int[] p  =new int[n];
  double exp[] = new double[n];
  double data[] = new double[n];

  for (int i = 0;i<n ;i++ ) {
    p[i] = sc.nextInt();
    exp[i] = (double)(1+p[i])/2;
  }

  data[0]=exp[0];
  for (int i = 1;i<n ;i++ ) {
    data[i] = data[i-1]+exp[i];
  }

  int t = 0;
  double max = data[k-1];
  for (int i = k;i<n ;i++ ) {
    max = Math.max(max,data[i]-data[t]);
    t++;
  }
  System.out.println(max);


}
}


Measured memory_bytes: 87564
#include <stdio.h>
int n, c, r;
int main() {
	while (~scanf("%d", &n)) {
		if (n == 0) break; r = 0;
		for (int i = 0; i < n * (n - 1) / 2; i++) scanf("%d", &c), r += c;
		printf("%d\n", r / (n - 1));
	}
	return 0;
}

Measured memory_bytes: 2596
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;

int dp[4001][4001];

int main()
{
  string a, b;
  while(cin >> a >> b)
  {
    int ans = 0;
    for(int i = 0; i < a.length(); i++)
    {
      for(int j = 0; j < b.length(); j++)
      {
        if(a[i] == b[j])
          ans = max(dp[i + 1][j + 1] = dp[i][j] + 1, ans);
        else
          dp[i + 1][j + 1] = 0;
      }
    }
    
    cout << ans << endl;
  }
}

Measured memory_bytes: 63728
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<cstdlib>
#include<list>
#include<set>
#include<numeric>

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

int P[10010],C[10010],E[10010];
int dp[10010],sum[10010];
const int INF = 1000000000;

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

	for (int i = 0; i < M; i++) {
		cin >> P[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> C[i] >> E[i];
	}

	sort(P,P+M,greater<int>());
	for (int i = 0; i < M; i++) {
		sum[i + 1] = sum[i] + P[i];
	}

	for (int i = 0; i <= M; i++)dp[i] = INF;

	dp[0] = 0;

	for (int i = 0; i < N; i++) {
		for (int j = M; j >= 0; j--) {
			if (dp[j] > dp[max(j - C[i], 0)] + E[i]) {
				dp[j] = dp[max(j - C[i], 0)] + E[i];
			}
		}
	}
	int ans = 0;
	for (int i = 0; i <= M; i++) {
		if (ans < sum[i] - dp[i])
			ans = sum[i] - dp[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
int main(){
	double a, b, c, d, e, f;
	while (cin >> a >> b >> c >> d >> e >> f) {
		double x = (c*d - a*f) / (b*d - a*e);
        double ans1 = (1000*((c - b*x) / a))/1000;
        double ans2 = (1000*x)/1000;
		cout << fixed << setprecision(3) << ans1 << " " << ans2 << endl;
	}
	return 0;
}


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

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int n;
const int MAX_N = 200000;
int a[MAX_N];

int main(){
  cin >> n;
  REP(i, n) cin >> a[i];
  int b[n + 1];
  REP(i, n) b[a[i]] = i + 1;

  set<int> s;
  s.insert(0);
  s.insert(n + 1);

  ll ans = 0;
  for(ll i = 1; i <= n; i++) {
    auto itr = s.lower_bound(b[i]);
    int r = *itr;
    itr--;
    int l = *itr;
    ans += i * (r - b[i]) * (b[i] - l);
    s.insert(b[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11136
import sys
n = int(sys.stdin.readline())
li = list(map(int, sys.stdin.readline().split()))
if 0 in li:
    print(0)
    exit()
res = 1
for i in range(n):
    res *= li[i]
    if res > 1000000000000000000:
        print(-1)
        exit(0)
print(res)

Measured memory_bytes: 87568
#include<bits/stdc++.h>
using namespace std;
char masu[50+5][50+5];
int ans[50+5][50+5]={};
int H,W,c=0;
int main(){
  cin >> H >> W;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cin >> masu[i][j];
    }
  }

  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      c=0;
      if(masu[i][j]=='#'){
        ans[i][j]=114514;
      }
      else{
        for(int k=i-1;k<=i+1;k++){
          for(int l=j-1;l<=j+1;l++){
            if(masu[k][l]=='#') c++;
          }
        }
        ans[i][j]=c;
      }
    }
  }

  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      if(ans[i][j]>=114514) cout << "#";
      else cout << ans[i][j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int main(){
    int A,B;
    cin >> A >> B;
    int ans = 0;
    int stat = 1;
    while(stat < B) {
        ans++;
        stat+=(A-1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class ABeginning {
public:
	void solve(std::istream& in, std::ostream& out) {
        set<int> n;
        int nn;
        rep(i, 4){
            in >> nn;
            n.insert(nn);
        }

        if(n.find(1) != n.end()
        && n.find(7) != n.end()
        && n.find(9) != n.end()
        && n.find(4) != n.end()){
            out << "YES" << endl;
        }else{
            out << "NO" << endl;
        }
	}
};


int main() {
	ABeginning solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main() {
	int n;
	cin >> n;
	VEP ord(n);
	REP(i, n) {
		cin >> ord[i].first;
		ord[i].second = i + 1;
	}
	sort(ord.begin(), ord.end());
	REP(i, n) {
		cout << ord[i].second <<" ";
	}
	return 0;
}


Measured memory_bytes: 1536
N = int(input())
Prices = [int(input()) for n in range(N)]

ans =  -float("inf")
minprice = Prices[0]

for i in range(1,N):
    p = Prices[i] - minprice
    ans = max(ans,p)
    minprice = min(minprice, Prices[i])

print(ans)


Measured memory_bytes: 13620
#include <algorithm>
#include <vector>
#include <functional>
#include <stdio.h>

int main(){
    int input_N, input_d;
    std::vector<int> vector_d;

    scanf("%d", &input_N);
    for(int count = 0; count < input_N; count++){
        scanf("%d", &input_d);
        vector_d.push_back(input_d);
    }

    std::sort(vector_d.begin(), vector_d.end());

    printf("%d", vector_d[input_N/2] - vector_d[input_N/2 - 1]);
    return(0);
}

Measured memory_bytes: 892
#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 <iomanip>

  using namespace std;
   

//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ
  typedef long long ll;
  typedef long double lld;
  typedef string str;
  typedef unsigned long long ull;
  ll INF = INT_MAX;
  // ll mod = 998244353;
  lld PI = 3.141592653;

// const int N = 2e5 + 5;

// int a[N];
// int n,k;



// void solve(){

// string s;
// cin>>s;


// }
 


  int main()
  {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
      
     
     ll n;
     cin>>n;
     ll now = 26;
     ll cnt = 1;
     while (n-now>0){
      n-=now;
      now*=26;
      cnt++;
     }
     n--;
     string s;
     string help = "abcdefghijklmnopqrstuvwxyz";
     while (n>0){
      int last = n%26;
      n/=26;
      s = help[last] + s;
     }
     while(s.length()<cnt){
      s = 'a'+s;
     }
     cout<<s<<"\n";

}



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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const int N = 2e5 + 10, mod = 1e9 + 7;
int fact[N], invfact[N];
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (((ll) x) * y) % mod;}
inline int powr(int a, ll b){
	int x = 1 % mod;
	while(b){
		if(b & 1) x = mul(x, a);
		a = mul(a, a);
		b >>= 1;
	}
	return x;
}
inline int inv(int a){ return powr(a, mod - 2);}
void pre(){
	fact[0] = invfact[0] = 1;
	for(int i = 1;i < N; i++) fact[i] = mul(i, fact[i - 1]);
	invfact[N - 1] = inv(fact[N - 1]);
	for(int i = N - 2; i >= 1; i--) invfact[i] = mul(invfact[i + 1], i + 1);
	assert(invfact[1] == 1);
}

inline int C(int n, int k){
	if(n < k || k < 0) return 0;
	return mul(fact[n], mul(invfact[k], invfact[n - k]));
}

int main(){
	pre();
	int n, a, b, c;
	sd(n); sd(a); sd(b); sd(c);
	a = mul(a, inv(100));
	b = mul(b, inv(100));
	c = mul(c, inv(100));

	a = mul(a, inv(sub(1, c)));
	b = mul(b, inv(sub(1, c)));

	int x = 0;
	for(int i = n; i < 2 * n; i++){
		int t = mul(C(i - 1, n - 1), mul(powr(a, n), powr(b, i - n)));
		t = add(t, mul(C(i - 1, n - 1), mul(powr(a, i - n), powr(b, n))));
		x = add(x, mul(i, t));
	}
	printf("%d\n", mul(inv(sub(1, c)), x));
}

Measured memory_bytes: 1792
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x: u32,
        y: u32,
    }
    println!("{}", x + y / 2);
}


Measured memory_bytes: 4352
#!/usr/bin/env python3

N, M = [int(x) for x in input().split()]
ABs = []
for n in range(N):
    ABs.append([int(x) for x in input().split()])
CDs = []
for m in range(M):
    CDs.append([int(x) for x in input().split()])
for a, b in ABs:
    dists = [abs(a - c) + abs(b - d) for c, d in CDs]
    print(dists.index(min(dists)) + 1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(void){

    long long n,k;
    cin >> n >> k;
    vector<int> a(n);
    int i = 0;
    for(i = 0;i<n;i++){
        cin >> a[i];
    }
    int count = 0;
    for(i=0;i<n;i++){
        if(a[i] >= k){
            count ++;
        }
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ar array
#define endl '\n'
#define ll long long
#define in insert
#define pb push_back
#define vt vector
#define P_Q(x) priority_queue<x>
#define p_q(x) priority_queue<x, vector<x>, greater<x>>
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(ll i=a;i>=b;i--)
#define FOR(m) Rep(i,1,m)
#define For(m) Rep(i,0,m-1)
#define Rbl(x,a) for(auto &x : a)
#define FIO ios::sync_with_stdio(0);   cin.tie(0);
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpii vector<pii>
#define vpll vector<pll>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
const ll INF = 0x3f3f3f3f3f3f3f3fll;
#define mod 1000000007
 
const int mxN = 1e5 + 1;
ll n;
vt<ll> adj[mxN];
vector<array<ll, 2>> dp(mxN, {1, 1});

void dfs(int u, int p = -1)
{
    for(int v: adj[u])
    {
        if(v == p)
            continue;
        dfs(v, u);
        dp[u][0] *= (dp[v][0] + dp[v][1]) % mod;
        dp[u][1] *= dp[v][0];
        dp[u][0] %= mod;
        dp[u][1] %= mod;
    }
}
 
 
int main()
{
FIO
 
    cin >> n;
    ll u, v;
    For(n-1)
    {
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    dfs(1);

    cout << (dp[1][0] + dp[1][1]) % mod ;
}

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

int main(){

	int n, m;
	cin >> n >> m;

	int l[m], r[m];
	int lmax = -1;
	int rmin = n+1;

	for(int i=0; i<m; i++){
		cin >> l[i] >> r[i];
	 	lmax = (lmax < l[i] ? l[i] : lmax);
	 	rmin = (rmin > r[i] ? r[i] : rmin);
	}

  	int ans = rmin - lmax + 1;
  	if(ans < 0) ans = 0;
  
	cout << ans << endl;
  	return 0;
}



Measured memory_bytes: 1024
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();

        while (n > 0) {

            int t[] = new int[n];
            for (int i = 0; i < n; i++) {
                t[i] = scan.nextInt();
            }
            for (int h = 0; h < n - 1; h++) {
                for (int j = 0; j < n - 1 - h; j++) {
                    if (t[j] < t[j + 1]) {
                        int temp = t[j];
                        t[j] = t[j + 1];
                        t[j + 1] = temp;
                    }
                }
            }
            int m = 1000000000;
            for (int i = 0; i < n - 1; i++) {
                if (t[i] - t[i + 1] < m) {
                    m = t[i] - t[i + 1];
                }
            }
            System.out.println(m);
            n = scan.nextInt();
        }
    }
}



Measured memory_bytes: 47972
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;

int main() {
	int h, w, a, b;
	cin >> h >> w >> a >> b;

	vector<ll> facto(h + w + 1);
	facto[0] = 1;
	for (int i = 1;i < h + w + 1;i++) {
		facto[i] = (i* facto[i - 1]) % MOD_CONST;
	}

	vector<ll> inv_mod(h + w + 1);
	inv_mod[1] = 1;
	for (int i = 2; i < h + w + 1;i++) {
		inv_mod[i] = (MOD_CONST - (inv_mod[MOD_CONST %i] * (MOD_CONST / i)) % MOD_CONST) % MOD_CONST;
		
	}

	vector<ll> inv_facto(h + w + 1);
	inv_facto[0] = 1;
	for (int i = 1; i < h + w + 1;i++) {
		inv_facto[i] = (inv_mod[i] * inv_facto[i - 1]) % MOD_CONST;
	}

	

	ll ans = 0;
	for (int i = 0;i < h - a;i++) {
		ll cnt1 = facto[i+ b-1];
		cnt1 = (cnt1 * inv_facto[i]) % MOD_CONST;
		cnt1 = (cnt1 * inv_facto[b-1]) % MOD_CONST;
		

		ll cnt2 = facto[w - b - 1 + h - i - 1];
		cnt2 = (cnt2 * inv_facto[w - b - 1])%MOD_CONST;
		cnt2 = (cnt2 * inv_facto[h - i - 1])%MOD_CONST;
		

		ll cnt = (cnt1 * cnt2) % MOD_CONST;
		
		ans = (ans + cnt) % MOD_CONST;
	}

	cout << ans << endl;

}

Measured memory_bytes: 4992
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    getLine
    ws <- getIntList
    let ls = scanl (+) 0 ws
    let rs = scanr (+) 0 ws
    print . minimum $ zipWith (\l r -> abs (l - r)) ls rs

Measured memory_bytes: 508
#include<stdio.h>
int main(void){
    int K[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k=0;
    scanf("%d",&k);
    printf("%d",K[k-1]);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  int c=0;
  cin>>a;
  if(a[0] == '1'){
    c++;
  }
  if(a[1] == '1'){
    c++;
  }
  if(a[2] == '1'){
    c++;
  }
  cout<<c<<'\n';
  return 0;
}


Measured memory_bytes: 3624
w = gets.to_i
swaps = []
gets.to_i.times { swaps << gets.split(",").map {|x| x.to_i - 1 } }
def swap(xs, i, j)
  tmp = xs[i]
  xs[i] = xs[j]
  xs[j] = tmp
  xs
end
puts swaps.reduce((1..w).to_a) {|acc, x| swap(acc, x[0], x[1]) }

Measured memory_bytes: 6100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
    	int N, K;
    	long ans = 0;
    	
        void solve(InputReader in, PrintWriter out) {
        	N = in.nextInt();
        	K = in.nextInt();
        	
        	for (int b = K + 1; b <= N; ++b) {
        		int an = (b - K)*(N/b);
        		if (N % b >= K) an += N % b - (K > 0 ? (K - 1) : K);
        		ans += an;
        	}
        	
        	out.println(ans);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

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

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}


Measured memory_bytes: 23508
import sys

if sys.version[0] == '2':
    range, input = xrange, raw_input

from collections import defaultdict
N = int(input())
S = input()
first, second = S[:N], S[N:]

s_set = defaultdict(int)

def make_str(bit, s):
    red = []
    blue = []
    for i in range(N):
        if bit >> i & 1:
            red.append(s[i])
        else:
            blue.append(s[i])
    return ''.join(red), ''.join(blue[::-1])

for bit in range(1 << N):
    s_set[make_str(bit, second)] += 1

ans = 0
for bit in range(1 << N):
    red, blue = make_str(bit, first)
    ans += s_set[blue, red]
print(ans)


Measured memory_bytes: 158476
object Main{
  def comparision(a:Int,b:Int,c:Int):Unit={
    if(a < b && b < c)println("Yes")
    else println("No")
  }
  def main(args:Array[String]){
    var sc = new java.util.Scanner(System.in)
    var a = sc.nextInt
    var b = sc.nextInt
    var c = sc.nextInt
    comparision(a,b,c)
  }
} 

Measured memory_bytes: 44972
#include <stdio.h>

int main()
{
  int W, a, b;
  int ans;
  scanf("%d %d %d", &W, &a, &b);
  if(a < b) {
    if(a+W >= b) {
      ans = 0;
    } else {
      ans = b - a - W;
    }
  } else {
    if(b+W >= a) {
      ans = 0;
    } else {
      ans = a - b - W;
    }
  }

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


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

int main() {
  int n, q, cnt = 0;
  cin >> n;
  vector<int> S(n);
  for (size_t i = 0; i < n; i++) {
    cin >> S.at(i);
  }

  cin >> q;
  vector<int> T(q);
  for (size_t i = 0; i < q; i++) {
    cin >> T.at(i);
  }

  for (auto t : T) {
    if (binary_search(S.begin(), S.end(), t)) {
      cnt++;
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 3264