akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class DKnight {
    long long modPow(long long a, long long x, long long p) {
        long long res = 1;
        while(x > 0) {
            if( x % 2 != 0) {
                res = (res * a) % p;
            }
            a = (a * a) % p;
            x /= 2;
        }
        return res;
    }

    long long modInverse(long long a, long long p) {
        //calculates the modular multiplicative of a mod m.
        //(assuming p is prime).
        return modPow(a, p-2, p);
    }
    long long combination(long long n, long long k, long long p) {
// calculates C(n,k) mod p (assuming p is prime).

        long long numerator = 1; // n * (n-1) * ... * (n-k+1)
        for (int i=0; i<k; i++) {
            numerator = (numerator * (n-i) ) % p;
        }

        long long denominator = 1; // k!
        for (int i=1; i<=k; i++) {
            denominator = (denominator * i) % p;
        }

        // numerator / denominator mod p.
        return ( numerator* modInverse(denominator,p) ) % p;
    }

public:
	void solve(std::istream& in, std::ostream& out) {
	    ll X, Y;
	    in >> X >> Y;
	    if ((X + Y) % 3 != 0 || (2 * X - Y) % 3 != 0) {
	        out << 0 << "\n";
	        return;
	    }
	    ll n = (X + Y) / 3;
	    ll r = (2 * X - Y) / 3;
        if (n < 0 || r < 0 || r > n) {
            out << 0 << "\n";
            return;
        }
	    out << combination(n, r, MOD) << "\n";
	}
};


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


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	dp := makeGrid(n<<1+5, k+5)
	dp[0][0] = 1
	for i := 0; i < n; i++ {
		for j := 0; j < i+1 && j < k+1; j++ {
			dp[i+1][j+1].addAs(dp[i][j])
			if j > 0 {
				dp[i+j][j].addAs(dp[i][j])
			}
		}
	}
	var ans mint
	for i := 0; i < k+1; i++ {
		ans.addAs(dp[n][i])
	}
	fmt.Fprintln(writer, ans)
}
func makeGrid(h, w int) [][]mint {
	index := make([][]mint, h, h)
	data := make([]mint, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

type mint int64

func (mt mint) mod() mint {
	m := mint(1e9 + 7)
	mt %= m
	if mt < 0 {
		return mt + m
	}
	return mt
}
func (mt mint) inv() mint {
	return mt.pow(mint(0).sub(2))
}
func (mt mint) pow(n mint) mint {
	p := mint(1)
	for n > 0 {
		if n%2 == 1 {
			p.mulAs(mt)
		}
		mt.mulAs(mt)
		n >>= 1
	}
	return p
}
func (mt mint) add(x mint) mint {
	return (mt + x).mod()
}
func (mt mint) sub(x mint) mint {
	return (mt - x).mod()
}
func (mt mint) mul(x mint) mint {
	return (mt * x).mod()
}
func (mt mint) div(x mint) mint {
	return mt.mul(x.inv())
}
func (mt *mint) addAs(x mint) *mint {
	*mt = mt.add(x)
	return mt
}
func (mt *mint) subAs(x mint) *mint {
	*mt = mt.sub(x)
	return mt
}
func (mt *mint) mulAs(x mint) *mint {
	*mt = mt.mul(x)
	return mt
}
func (mt *mint) divAs(x mint) *mint {
	*mt = mt.div(x)
	return mt
}



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

using namespace std;
using ll = long long;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    cout << (N/(A + B))*A + (N%(A + B) >= A)*A + (N%(A + B) < A)*(N%(A + B))<< endl;

    return 0;
}

Measured memory_bytes: 3648
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end
def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY
def bfs(g,s)
  $cost[s]=0
  queue=[]
  queue.push(s)
  until queue==[]
      curr=queue.shift
      next if g[curr].nil?
      g[curr].each do|v,c|
        next if $cost[v]!=INF
        $cost[v]=min($cost[v],$cost[curr]+c)
        queue.push(v)
      end
  end
end
N=gets.to_i
$cost=array(N,INF)
g=array(N)
(N-1).times do
  a,b,c=get_i
  a-=1
  b-=1
  g[a]=[] if g[a].nil?
  g[a].push([b,c])
  g[b]=[] if g[b].nil?
  g[b].push([a,c])
end
Q,K=get_i
bfs(g,K-1)
Q.times do|i|
    x,y=get_i
    x-=1
    y-=1
    puts $cost[x]+$cost[y]
end

Measured memory_bytes: 28924
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
#define fi first
#define se second
using namespace std ;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

void solve()
{
	string s,t;
	cin>>s>>t;
	lli ns=s.size(),nt=t.size();
	lli ani=INT_MAX;
	for(lli i=0;i<=ns-nt;i++){
		lli tem=0;
		for(lli j=0;j<nt;j++){
			if(t[j]!=s[i+j])tem++;
		}
		ani=min(ani,tem);
	}
	cout<<ani;
}
 
int main()
{
/////////////////////////////////////
    fastio;
    
/////////////////////////////////////  
    lli t,m;
    //cin>>t;
    t=1;
    while(t--)
    {
    	solve();  
    	m++;  
    	cout<<endl;
    }
}

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

using ll = long long;
using pll = pair<long long, long long>;

int main() {
    int n, m;
    cin >> n >> m;
    vector<pll> sv(n), cv(m);
    for(int i = 0; i < n; i++) cin >> sv[i].first >> sv[i].second;
    for(int i = 0; i < m; i++) cin >> cv[i].first >> cv[i].second;

    for(int i = 0; i < n; i++) {
        int mn = 1e9+1;
        int p;
        for(int j = 0; j < m; j++) {
            if(mn > abs(cv[j].first - sv[i].first) + abs(cv[j].second - sv[i].second)) {
                mn = abs(cv[j].first - sv[i].first) + abs(cv[j].second - sv[i].second);
                p = j;
            }
        }
        cout << p+1 << endl;
    }

    return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> A(N), a(N), b(N);
	for (int& i : A) cin >> i;
	for (int i = 1; i < N; ++i) a[i] = max(A[i - 1], a[i - 1]);
	for (int i = N - 2; i >= 0; --i) b[i] = max(A[1 + i], b[1 + i]);
	cout << b.front() << endl;
	for (int i = 1; i < N - 1; ++i) cout << max(a[i], b[i]) << endl;
	cout << a.back() << endl;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll inf = 1e18;
vector<int> arr[2 * 100005];
bool vis[2 * 100005];
int val;
void dfs(int i){
    if(vis[i])
        return ;
    vis[i] = 1;
    val++;
    for(int c : arr[i])
        if(!vis[c])
            dfs(c);
}
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    int m;
    cin >> m;
    for(int i = 0 ; i < m ; i++){
        int a , b;
        cin >> a >> b;
        arr[a].push_back(b);
        arr[b].push_back(a);
    }
    int ans = 0;
    for(int i = 1 ; i <= n ; i++){
        val = 0;
        if(!vis[i])
            dfs(i);
        ans = max(val ,  ans);
    }
    cout<<ans;
}


Measured memory_bytes: 20932
fn reduce_xor(n: u64) -> u64
{
    if n == 0 {
        return 0;
    }

    let mut result: u64 = 0;
    let digit = (n as f64).log(2.0).floor() as usize;

    for i in 0..digit+1 {
        let base = 1<<(i+1);

        let n_mod = n%base;
        let n_div = n/base;

        // 0->1になる境界
        let bound = base/2;

        let mut nth_bit1: u64 = n_div*bound;
        nth_bit1 += if n_mod < bound {0} else {n_mod - bound + 1};

        result |= (nth_bit1%2)<<i;
    }

    result
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a: u64 = iter.next().unwrap().parse().unwrap();
    let b: u64 = iter.next().unwrap().parse().unwrap();

    // let digit = (a as f64).log(2.0).floor() as usize;
    // println!("{}", digit);

    let xor_a = if a == 0 {0} else {reduce_xor(a-1)};
    let xor_b = reduce_xor(b);
    let result = xor_a ^ xor_b;

    println!("{}", result);
}


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

class Main{
    static long N = 0;
    static int count = 0;
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        N = sc.nextLong();
        System.out.println(dif("0"));
    }
    static int dif(String s){

        if(Long.parseLong(s) > N){
            return 0;
        }

        if(s.contains("3") && s.contains("5") && s.contains("7")){
            count += 1;
        }
        dif(s + "7");
        dif(s + "5");
        dif(s + "3");

        return count;
    }

}

Measured memory_bytes: 34900
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct dat{
	ll h,p;
	inline bool operator <(const dat&x)const{return h+p<x.h+x.p;}
}p[5005];
ll dp[5005];
int n;ll ans,inf;
int main(){
	cin>>n;
	for(int i=1;i<=n;++i)cin>>p[i].h>>p[i].p;
	sort(p+1,p+n+1);
	memset(dp,127,sizeof(dp));inf=dp[0],dp[0]=0;
	for(int i=1;i<=n;++i)for(int j=i;j;--j)if(dp[j-1]<=p[i].h)dp[j]=min(dp[j],dp[j-1]+p[i].p);
	for(int i=n;i;--i)if(dp[i]!=inf){
		cout<<i<<'\n';
		return 0;
	}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n){
        cin>>a[i];
    }
    int ans=a[0];
    for(int i=1; i<n; ++i){
        if(a[i]-a[i-1]>0)ans+=a[i]-a[i-1];
    }
    cout<<ans<<endl;
}


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

int main() {
    string s;
    cin >> s;
    if(s == "SUN")
        cout << 7 << endl;
    else if(s == "MON")
        cout << 6 << endl;
    else if(s == "TUE")
        cout << 5 << endl;
    else if(s == "WED")
        cout << 4 << endl;
    else if(s == "THU")
        cout << 3 << endl;
    else if(s == "FRI")
        cout << 2 << endl;
    else if(s == "SAT")
        cout << 1 << endl;
}


Measured memory_bytes: 256
import bisect
N = int(input())
A_list = sorted(list(map(int,input().split())))
B_list = sorted(list(map(int,input().split())))
C_list = sorted(list(map(int,input().split())))
ans = 0
for B in B_list:
    a_cnt = bisect.bisect_left(A_list,B)
    c_cnt = len(C_list) - bisect.bisect_right(C_list,B)
    ans += a_cnt * c_cnt
print(ans)


Measured memory_bytes: 23092
/// sultanov

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
using namespace __gnu_pbds;

template<typename T> 
using ordered_set = tree<T, null_type,   
less<T>, rb_tree_tag,
tree_order_statistics_node_update>;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

double f(pii x, pii y) {
    return sqrt((x.x - y.x) * (x.x - y.x) + (x.y - y.y) * (x.y - y.y));
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<pii> a(n);
    for (pii& x : a)
        cin >> x.x >> x.y;
    sort(a.begin(), a.end());
    double ans = 0;
    double cnt = 0;   
    do {
        double res = 0;
        for (int i = 1; i < n; i++) 
            res += f(a[i], a[i - 1]);
        ans += res;
        cnt++;
    } while (next_permutation(a.begin(), a.end()));
    cout << setprecision(10) << fixed << ans / cnt;
    return 0;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int M=2e5+10;
int fa[M];
int Size[M];
int get(int x)
{
    if(x==fa[x]) return x;
    return fa[x]=get(fa[x]);
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) fa[i]=i,Size[i]=1;
    while(m--)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        if(get(x)==get(y)) continue;
        int Sx=Size[get(x)],Sy=Size[get(y)];
        fa[get(x)]=get(y);
        Size[get(y)]=Sx+Sy;
    }
    int res=Size[get(1)];
    for(int i=1;i<=n;i++)
    {
        res=max(res,Size[get(i)]);
    }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 11428
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;

typedef pair<int,int> pii;
int dx[] = {0,0,1,-1,1,1,-1,-1};
int dy[] = {1,-1,0,0,-1,1,1,-1};

queue<pii> q;

int main(){
  int h,w,sand[1000][1000];
  int sond[1000][1000];
  scanf("%d %d",&h,&w);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      char c;
      scanf(" %c",&c);
      if(c=='.') sand[i][j] = -10;
      else sand[i][j] = c-'0';
      if(c=='.') sond[i][j] = -10;
      else sond[i][j] = c-'0';
    }
  }
  q.push(pii(h,w));
  for(int i=1;i<h-1;i++){
    for(int j=1;j<w-1;j++){
      for(int k=0;k<8;k++) if(sand[i+dx[k]][j+dy[k]]<=-10) sand[i][j]--;
      if(sand[i][j]<=0&&sand[i][j]>-10) q.push(pii(i,j));
    }
  }
  int ans = 0;
  while(q.size()>1){
    int x = q.front().first;
    int y = q.front().second;
    q.pop();
    if(x==h&&y==w){
      ans++;
      q.push(pii(x,y));
      continue;
    }
    for(int i=0;i<8;i++){
      int nx = x+dx[i];
      int ny = y+dy[i];
      if(nx>=0&&nx<h&&ny>=0&&ny<w&&sand[nx][ny]>0){
        sand[nx][ny]--;
        if(sand[nx][ny]==0){
          q.push(pii(nx,ny));
        }
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 6676
#include<stdio.h>

int main(void)
{
  long a=0, m=0, r=0, c=0, h=0;
  int i,num;
  long answer;
  scanf("%d", &num);
  char array[10];
  for(i=1; i<=num; i++)
  {
    scanf("%s", array);
    if(array[0]=='M')m++;
    if(array[0]=='A')a++;
    if(array[0]=='R')r++;
    if(array[0]=='C')c++;
    if(array[0]=='H')h++;
  }
  
   answer=m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*c*h+r*c*h+a*r*h;
   printf("%ld", answer);
  
  return 0;
}


Measured memory_bytes: 128
void main(){
	string s = readln().chomp();
	foreach(ch; s){
		if( s.count(ch) != 2){
			writeln("No");
			return;
		}
	}
	writeln("Yes");
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{

	cin.tie(0); ios_base::sync_with_stdio(false);
	int d, g; 
	cin >>d>>g;
	
	VI p(d), c(d);
	rep(i, d) cin >>p[i] >>c[i];
	ll ans = 1LL<<50;
	rep(i, 1<<d){
		ll sm = 0, smp=0;
		rep(j, d){
			if(i>>j & 1){
				sm += p[j];
				smp += p[j] * (j+1) *100;
				smp += c[j];
			}
		}
		repr(j, d-1, 0){
			if(i>>j &1) continue;
			if(smp >= g) break;
			int az = min<ll>(p[j], (g-smp + (j+1)*100 -1)/ ((j+1)*100));
			sm += az; smp += az * (j+1) *100;
		}
		//dbg(i, smp, sm);
		if(smp >= g) ans= min(ans, sm);
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 *
 */

/**
 * @author cthanh
 *
 */
public class Main {

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\?????????
		    String str = br.readLine();
		    double r =  Double.parseDouble( str);
		    double men = r *r *Math.PI;
		    double syu =  r*2* Math.PI;
		    //System.out.println(Math.PI);
		    System.out.printf( "%.6f %.6f", r *r *Math.PI , r*2* Math.PI );


	}
}

Measured memory_bytes: 24612
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>c;
	for(a=1;a<=9;a++)
		for(b=1;b<=9;b++)
			if(c==a*b)
			{
				cout<<"Yes"<<endl;
				return 0;
			}

	if(a==10)
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  cin >> N;
  cin >> S;

  ;
  ;
}
void solve() {
  if (N % 2 == 1) {
    cout << "No" << endl;
    return;
  }
  int n = N / 2;
  rep(i, 0, n - 1) {
    if (S[i] != S[i + n]) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    int d,t,s; cin >> d >> t >> s;
    if (d <= t*s) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 3648
def main():
    import sys
    input = sys.stdin.readline

    h,w = map(int,input().split())

    if (h == 1) or (w == 1):
        print(1)
    elif (h * w) % 2 == 0:
        print(int((h * w)//2))
    else:
        s1 = (((h-1) * w)//2)
        s2 = (w//2) + 1
        print(int(s1 + s2))


if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
N=int(input())
A=map(int, input().split())
P=1000000007
ans = 1
cnt = [3 if i == 0 else 0 for i in range(N + 1)]

for a in A:
  ans=ans*cnt[a]%P
  if ans==0:
    break
  cnt[a]-=1
  cnt[a+1]+=1

print(ans)

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

using namespace std;

int main() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    // m = n - 1
    // [a + kc - (m - k)d, a + kd - (m - k)c] contains b
    // a + kc - (m - k)d <= b <=> k(c+d) <= b - a + md = X
    // a + kd - (m - k)c >= b <=> k(c+d) >= b - a + mc = Y
    
    int m = n - 1;
    long long X = 1LL * m * d + b - a;
    long long Y = 1LL * m * c + b - a;
    if (c + d == 0) {
        if ((X >= 0) && (Y <= 0)) cout << "YES\n";
        else cout << "NO\n";
        return 0;
    }
    
    long long mink = 0, maxk = m;
    maxk = min(maxk, X / (c + d));
    mink = max(mink, Y / (c + d) + (Y % (c + d) != 0));
    if (mink <= maxk) cout << "YES\n"; else cout << "NO\n";
}

Measured memory_bytes: 256
def f(i, y, S):
    while i < y:
        if S[i + 2] == '.':
            i += 2
        elif S[i + 1] == '.':
            i += 1
        else:
            return False
    return True
def g(i, y, S):
    while i < y:
        if S[i + 2] == '.':
            i += 2
        elif S[i + 1] == '.':
            i += 1
        else:
            break
    return i
def dc(n, a, b, c, d, S):
    S = list(S)
    S[b] = 'B'
    while a < b:
        a = g(a, c, S)
        if b == d:
            return a >= c
        elif S[b + 1] == '.':
            S[b] = '.'
            b += 1
            S[b] = 'B'
        elif S[b + 2] == '.':
            S[b] = '.'
            b += 2
            S[b] = 'B'
        else:
            return a >= c
    return True
def solve():
    n, a, b, c, d = map(int, input().split())
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    S = input() + "##"
    if c < d:
        S = list(S)
        return f(b, d, S) and f(a, c, S)
    else:
        return dc(n, a, b, c, d, S)
    return True
print("Yes" if solve() else "No")


Measured memory_bytes: 4916
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,X,T;
  cin>>N>>X>>T;
  int oi=N/X;
  int un=N%X;
  if(un==0){
    cout <<oi*T;
  }
  else{
    cout <<(oi+1)*T;
  }
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

using ipair = pair<int,int>;

int INF = 1e9+7;

using ipair = pair<int,int>;
bool operator>(const ipair a,const ipair b){return a.first > b.first;}

int g[15][15];

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

  rep(i, N) rep(j, N) g[i][j] = -1;
  rep(i, N){
    int A;
    cin >> A;
    rep(j, A){
      int x, y;
      cin >> x >> y;
      x--;
      g[i][x] = y;
    }
  }

  // 数え上げ
  int ans = 0;
  rep(i, 1<<N){
    vector<int> d(N);
    rep(j, N){
      if(i >> j&1){
        d[j] = 1;
      }
    }

    bool ok = true;
    rep(j, N){
      if(d[j]==1){
        rep(k, N){
          if(g[j][k] == -1) continue;
          if(g[j][k] != d[k]) ok = false;
        }
      }
    }

    if(ok){
      ans = max(ans, __builtin_popcount(i));
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef long double ld;


int main(){
    ll N;
    cin >> N;
    
    vector<ll> ans(N,0);
    vector<ll> C(N - 1,0);
    vector<ll> S(N - 1,0);
    vector<ll> F(N - 1,0);
    rep(i, N - 1) cin >> C[i] >> S[i] >> F[i];
    rep(i,N - 1){
        ll now = 0;
        for(int j = i; j < N - 1; j++){
            if(now < S[j] || (now - S[j]) % F[j] != 0){
                while(now < S[j] || (now - S[j]) % F[j] != 0){
                    now++;
                }
            }
            now += C[j];
            
        }
        cout << now << endl;
    }

    cout << 0 << endl;

}


Measured memory_bytes: 3568
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()
n=I()
lisa=[input().rstrip() for i in range(n)]
m=I()
lisb=[input().rstrip() for i in range(m)]
u=Counter(lisa)
v=Counter(lisb)
mx=0
for j in u.keys():
    ans=u[j]-v[j]
    if ans>mx:
        mx=ans
print(mx)

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int k, s;
  cin >> k >> s;
  int res = 0;
  for(int i = 0; i <= k; i++){
    for(int j = 0; j <= k; j++){
      int x = s - i - j;
      if(x >= 0 && x <= k) res++;
    }
  }
  cout << res;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <iomanip>
#include <cassert>
#include <string.h>
#include <cstdio>
#include <complex>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<ll , ll> PLL;
typedef vector<int> VI;
typedef vector<PII> VPII;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
#define MP make_pair
#define pb push_back
#define X first
#define Y second
#define next fake_next

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-9;
const ll INF = 1e9;
const ll LINF = 1e18;
const ll mod = 1e9 + 7;
const ll MAX = 1 << 17;
int a[100000];
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//memset(dpT , -1 , sizeof dpT);
	int n , k;
	cin >> n >> k;

	cout << (n + k - 3) / (k - 1);


	return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

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

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	N := readInt()
	a := make([]int, N)
	for i := range a {
		a[i] = readInt()
	}
	x := 0
	for _, v := range a {
		x = x ^ v
	}
	if x == 0 {
		println("Yes")
	} else {
		println("No")
	}
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
string s;
int main(){
	cin>>s;
	if(s=="ABC")cout<<"ARC";
	else cout<<"ABC";
	return 0;
}


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

int main(int argc, char **argv)
{
	ll X; cin >> X;
	ll b{1}, p{2};

	if (X == 1 || X == 2 || X == 3)
	{
		std::cout << 1 << std::endl;
		return 0;
	}
	
	vector<ll> v;
	for (ll b = 2; b <= X; ++b)
	{
		for (ll p = 2; pow(b, p) <= X; ++p)
		{
			v.push_back(pow(b, p));
		}
	}
	sort(v.begin(), v.end());
	ll res{0};
	for (ll i = 0; i < v.size(); ++i)
	{
		if (v[i] > X) break;
		res = v[i];
	}
	std::cout << res << std::endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
const int MAXSIZE = 45;
int num_node;
int Pre_orider[MAXSIZE], In_Order[MAXSIZE], Post_Order[MAXSIZE];
int pre_position, post_position;
void Re_struct(int left, int right) {
	if (left >= right)	return;
	int value = Pre_orider[pre_position++];
	int  in_postition = -1;
	for (int i = 0; i < num_node; i++) {
		if (In_Order[i] == value) {
			in_postition = i; break;
		}
	}
	Re_struct(left, in_postition);
	Re_struct(in_postition + 1, right);
	Post_Order[post_position++] = value;
}
int main() {
	pre_position = post_position = 0;
	scanf("%d", &num_node);
	for (int i = 0; i < num_node; i++) {
		scanf("%d", &Pre_orider[i]);
	}
	for (int i = 0; i < num_node; i++) {
		scanf("%d", &In_Order[i]);
	}
	Re_struct(0, num_node);
	for (int i = 0; i < num_node; i++) {
		if (i) printf(" ");
		printf("%d",Post_Order[i]);
	}
	printf("\n");
	return 0;
}

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

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

template <class T>
void dump_vector(const vector<T> &v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

//---------------------------------------------------------------------------------------------------
template <class T>
int selection_sort(vector<T> &vec) {
    auto len = vec.size();
    int cnt  = 0;
    rep(i, 0, len) {
        auto minj = i;
        rep(j, i, len) {
            if (vec[j] < vec[minj]) {
                minj = j;
            }
        }
        if (i != minj) {
            swap(vec[i], vec[minj]);
            cnt++;
        }
    }
    return cnt;
}
//---------------------------------------------------------------------------------------------------

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, 0, N) {
        cin >> A[i];
    }
    auto ans = selection_sort(A);

    dump_vector(A);
    cout << ans << "\n";
}



Measured memory_bytes: 3184
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)


//[l,r)
//dat[r] = l
#define Left second
#define Right first
class SEGMENTS{
private:
    map<int,int> dat;
    bool isInclude(int li, int ri, int L, int R){ return (L<=li && ri<=R); }
    
public:
    void erase(int l, int r){
        while(true){
            auto it = dat.upper_bound(l);
            if(it==dat.end() || r<=it->Left)break;
            
            int li = it->Left, ri = it->Right;
            dat.erase(it);
            
            if( !isInclude(li,ri,l,r) ){
                if( isInclude(l,r,li,ri) ){
                    if(li!=l) dat[l] = li;
                    if(r!=ri) dat[ri] = r;
                }else{
                    if(li<=l&&l<ri) ri = l;
                    if(l<=li&&li<r) li = r;
                    if(li!=ri) dat[ri] = li;
                }
            }
        }
    }
    
    void insert(int l, int r){
        while(true){
            auto it = dat.upper_bound(l);
            if(it==dat.end() || r<=it->Left){    //含む区間なし
                dat[r] = l;
                break;
            }else{
                if( isInclude(it->Left,it->Right,l,r) ) dat.erase(it);
                else{
                    l = min(l,it->Left);
                    r = max(r,it->Right);
                }
            }
        }
    }
    
    //Not validated.
    // if nothing: return pii(-1,-1);
    pii getIncludesSegment(int p){
        auto it = dat.upper_bound(p);
        if(it==dat.end() or it->Left>p)return pii(-1,-1);
        else return pii(it->Left,it->Right);
    }
    
    //Not validated.
    bool isSameSegment(int p1, int p2){
        pii a = getIncludesSegment(p1);
        pii b = getIncludesSegment(p2);
        if(a==pii(-1,-1) or b==pii(-1,-1))return false;
        
        return a==b;
    }
    
    int size(){ return dat.size(); }
    
    void output(){ for(auto e:dat)cout<<e.Left<<" "<<e.Right<<endl;cout<<endl; }
};


struct event{
    int t,a,b;
    int num;
    
    bool operator < (event obj) const{
        return this->t < obj.t;
    }
};

int main(){
    int n,m,q;
    cin>>n>>m>>q;
    
    vector<event> v;
    rep(i,m){
        int d,a,b;
        cin>>d>>a>>b;
        v.pb(event{2*d+1,a,b,-1});
    }
    rep(i,q){
        int e,s,t;
        cin>>e>>s>>t;
        v.pb(event{2*e,s,t,(int)i});
    }
    
    sort(all(v));
    
    SEGMENTS st;
    vector<bool> ans(q);
    for(auto elm:v){
        if(elm.num==-1){
            st.insert(elm.a,elm.b+1);
        }else{
            if(elm.a>=elm.b)ans[elm.num] = true;
            else{
                ans[elm.num] = st.isSameSegment(elm.a,elm.b);
            }
        }
    }
    for(auto elm:ans){
        if(elm)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}




Measured memory_bytes: 7452
#include <iostream>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iomanip>

using namespace std;

int main()
{
	int n, sum, tmp;
	double avg, a;

	while(cin >> n, n)
	{
		vector<int> s;
		sum = 0;

		for (int i = 0; i < n; ++i) 
		{
			cin >> tmp;
			s.push_back(tmp);
			sum += tmp;
		}

		avg = (double) sum / n;

		a = 0.0;
		for (int i = 0; i < n; ++i)
			a += (s[i] - avg) * (s[i] - avg);

		cout << setprecision(8) << sqrt(a/n) << endl;
		s.clear();
	}

	return 0;
}

Measured memory_bytes: 1288
import bisect

n = int(input())
a = sorted(map(int, input().split()))
b = sorted(map(int, input().split()))
c = sorted(map(int, input().split()))

ans = 0
for bb in b:
    ai = bisect.bisect_left(a, bb)
    ci = bisect.bisect_right(c, bb)
    ans = ans + (ai * (n-ci))

print(ans)

Measured memory_bytes: 23360
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
typedef ModInt<1000000007> mint;

const int MAX_N = 1e5;
mint dp[MAX_N][2]; // dp[v][i] := 頂点vをiにした時のまだ埋めていない部分の埋め方
vector<int> G[MAX_N+1];
int N;

// 頂点vをcolorにした時の塗り方。
mint dfs(int v, bool color, int p = -1){
    if(dp[v][color] != 0) return dp[v][color];

    mint ans = 1;
    for(auto u: G[v]){
        if(u == p) continue;

        if(color == 0) ans *= dfs(u, 0, v) + dfs(u, 1, v);
        else ans *= dfs(u, 0, v);
    }
    return dp[v][color] = ans;
}

int main(){
    cin >> N;
    G[0].push_back(1);
    rep(i, 0, N-1){
        int x, y; cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    cout << dfs(0,0) << endl;
}

Measured memory_bytes: 14848
listA = []
listB = []
N, M = map(int, input().split())
for a in range(N):
    A = input()
    listA.append(A)
for b in range(M):
    B = input()
    listB.append(B)
kazu = N - M
answer=[]
number=0
suuji=0

while number<=kazu:
    for z in range(0, kazu + 1):
        count=0
        for y in range(0, M):
            for x in range(0, M):
                if listA[z + y][x+number]==listB[y][x]:
                    count+=1
        answer.append(count)
    number+=1
for v in answer:
    if v==M**2:
        print('Yes')
        break
    else:
        suuji+=1
if suuji==len(answer):
    print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);

int main() {
  string s; cin >> s;
  int K; cin >> K;
  int N = s.size();
  string ans;
  int M = min(N,K);
  set<string> a;
  for (int i = 1; i <= M; i++) {
    for (int j = 0; j < N-i+1; j++) {
      string b;
      for (int k = 0; k < i; k++) b = b + s[j+k];
      a.insert(b);
    }
  }
  
  int count = K;
  
  for (auto i : a) {
    ans = i;
    count--;
    if (count == 0) break;
  }
  
  cout << ans << endl;  
}

Measured memory_bytes: 1664
#include<stdio.h>
int main(void)
{
    int x;
    int i;
    int cnt = 0;
    int a[10]={1,2,4,8,16,32,64,128,256,512},check[10]={0};

    while(scanf("%d",&x)!=EOF){
        for(i = 9;i >= 0; i--){
            if(x >= a[i] && check[i] == 0){
                check[i] = 1;
                x -= a[i];
                if(cnt == 0)cnt = a[i];
            }
        }
        for(i = 0;i < 10; i++){
            if(check[i] == 1){
                printf("%d",a[i]);
                if(a[i] == cnt)printf("\n");
                else printf(" ");
            }
        }
        cnt = 0;
        for(i = 0;i < 10; i++)check[i] = 0;
    }
    return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
int dp[100001][3],a[100001][3];
int main()
{
	int n,i,j,k,max=-1;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			dp[i][j]=-1;
		}
	}
	for(i=0;i<3;i++) dp[0][i]=a[0][i];
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			for(k=0;k<3;k++){
				if(i+1<n&&k!=j&&dp[i][j]+a[i+1][k]>dp[i+1][k]){
					dp[i+1][k]=dp[i][j]+a[i+1][k];
				}
			}
		}
	}
	for(i=0;i<3;i++){
		if(dp[n-1][i]>max){
			max=dp[n-1][i];
		}
	}
	printf("%d\n",max);
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<char> D(N);
    vector<int> L(N);
    vector<bool> del(N);
    for(int i=0; i<N; ++i) {
        cin >> D[i] >> L[i];
    }
    int res = 0;
    while(true) {
        int idx = -1;
        for(int i=0; i<N; ++i) {
            if(D[i] == 'n' || del[i]) {
                continue;
            }
            if(idx == -1 || L[i] < L[idx]) {
                idx = i;
            }
        }
        if(idx == -1) {
            break;
        }
        res++;
        int l = idx-1, r = idx+1;
        while(0 < l && (del[l] || D[l] == 'y' || (D[l] == 'n' && L[l] < L[idx]))) {
            --l;
        }
        while(r < N-1 && (del[r] || D[r] == 'y' || (D[r] == 'n' && L[r] < L[idx]))) {
            ++r;
        }
        for(int i=l; i<=r; ++i) {
            if(D[i] == 'y') {
                del[i] = true;
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
  int N;
  cin >> N;
  int ans = 10000;
  for (int i = 1; i < N; i++){
    int sum = findSumOfDigits(i) + findSumOfDigits(N - i);
    ans = min(ans, sum);
  }
  cout << ans << endl;
}
    
  
  

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N,d[1000],a[1000]={},sunadatyan=0;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>d[i];
		a[d[i]]=1;
	}
	for(int i=0;i<1000;i++){
		if(a[i]==1){
			sunadatyan++;
		}
	}
	cout<<sunadatyan<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define po pop_back
#define mp make_pair
#define fi first
#define se second
#define hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007  
using namespace std;
bool comp(ll a,ll b){if(a>b)return true;else return false;}
int isP(ll n){if(n==1)return 0;if(n==2 || n==3)return 1;for(ll i=2;i<=sqrt(n);i++){if(n%i==0)return 0;}return 1;}
ll power(ll a,ll b){if(b==0)return 1;if(b==1) return a;ll t=power(a,b/2);if(b%2==1) return t*t*a;else return t*t;}
ll powMOD(ll x,ll y){if(y==0)return 1;if(y==1)return x;ll t=powMOD(x,y/2);if(y%2==1)return t*t%MOD*x%MOD;else return t*t%MOD;}
bool cmp(pair<ll,ll> p1,pair<ll,ll> p2){if(p1.fi>p2.fi) return true;if(p1.fi==p2.fi && p1.se>p2.se) return true;return false;}
 

ll pr[1000001]; 
ll hai[1000001];
ll cn[1000001];
int main()
{
    hello;
    
    ll t; 
//    cin>>t;
	t=1;
	while(t--){
		ll n;
		cin>>n;
		ll ar[n+1];
		for(ll i=1;i<=n;i++) cin>>ar[i],hai[ar[i]]=1,cn[ar[i]]++;
		bool foo=1;
		for(ll i=2;i<=1000000;i++){
			if(cn[i]>1){
				foo=0;
			}
		}
		if(foo){
			for(ll i=1;i<=1000000;i++) pr[i]=1;
			pr[1]=0;
			for(ll i=2;i<=1000000;i++){
				if(pr[i]==1){
					ll j=i+i;
					ll cnt=0;
					if(hai[i]) cnt++;
					while(j<=1000000){
						if(hai[j]){
							cnt++;
						}
						pr[j]=0;
						j+=i;
					}
					if(cnt>1) foo=0;
				}
				if(!foo) break;
			}
		}
		if(foo) cout<<"pairwise coprime\n";
		else{
			ll g=ar[1];
			for(ll i=2;i<=n;i++){
				g=__gcd(ar[i],g);
			}
			if(g==1) cout<<"setwise coprime\n";
			else cout<<"not coprime\n";
		}
	}
    
    return 0;  
} 

Measured memory_bytes: 34700
#include<iostream>
#include<string>
using namespace std;
int main() {
    string a,b;
    cin>>a>>b;
    int x=a.size(),y=b.size();
    if(x>y||(x==y&&a>b)) cout<<"GREATER\n";
    if(x==y&&a==b) cout<<"EQUAL\n";
    if(x<y||(x==y&&a<b)) cout<<"LESS\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] a = sc.next().toCharArray();
        char[] b = sc.next().toCharArray();
        char[] c = sc.next().toCharArray();

        String ans = String.valueOf(a[0]).toUpperCase() + String.valueOf(b[0]).toUpperCase() + String.valueOf(c[0]).toUpperCase();
        System.out.println(ans);
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


Measured memory_bytes: 23380