akhauriyash/Code-Regression huggingface dataset:
#[allow(unused)]
use std::io::Write;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let (h, w, k): (usize, usize, usize) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        let mut ws = s.split_whitespace();
        let a = ws.next().unwrap().parse().unwrap();
        let b = ws.next().unwrap().parse().unwrap();
        let c = ws.next().unwrap().parse().unwrap();
        (a, b, c)
    };

    let mut v: Vec<Vec<char>> = Vec::new();
    for _ in 0..h {
        let v_i: Vec<char> = {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            let s = s.trim_right().to_owned();
            s.chars().collect()
        };
        v.push(v_i)
    }

    let mut ans = vec![vec![0; w]; h];

    // いちごが乗っている箇所に番号をつける
    let mut count = 1;
    for i in 0..h {
        for j in 0..w {
            if v[i][j] == '#' {
                ans[i][j] = count;
                count += 1;
            }
        }
    }

    // 横方向にコピー
    for i in 0..h {
        let mut current = 0;
        for j in 0..w {
            if ans[i][j] == 0 {
                ans[i][j] = current;
            } else {
                current = ans[i][j];
            }
        }

        let mut current = 0;
        for j in (0..w).rev() {
            if ans[i][j] == 0 {
                ans[i][j] = current;
            } else {
                current = ans[i][j];
            }
        }
    }

    // 縦方向にコピー
    for i in 0..w {
        let mut current = 0;
        for j in 0..h {
            if ans[j][i] == 0 {
                ans[j][i] = current;
            } else {
                current = ans[j][i];
            }
        }

        let mut current = 0;
        for j in (0..h).rev() {
            if ans[j][i] == 0 {
                ans[j][i] = current;
            } else {
                current = ans[j][i];
            }
        }
    }

    // print answer
    for i in 0..h {
        println!("{}", ans[i].iter().map(|&c| c.to_string()).collect::<Vec<String>>().join(" "));
    }
}


Measured memory_bytes: 4860
N = int(input())
S = input()

def f(n):
    n = str(n).zfill(3)
    # print(n)
    found = False
    for i in range(len(S)):
        if S[i] == n[0]:
            found = True
            break
    if found == False:
        return 0
    
    found = False
    for j in range(i+1, len(S)):
        if S[j] == n[1]:
            found = True
            break
    if found == False:
        return 0

    found = False
    for k in range(j+1, len(S)):
        if S[k] == n[2]:
            found = True
            break
    if found:
        return 1
    return 0

ans = 0
for i in range(1000):
    ans += f(i)

print(ans)




Measured memory_bytes: 41004
#include <iostream>                                                             
                                                                                
using namespace std;                                                            
                                                                                
int main (void) {                                                               
  int a, b, c;                                                                  
  int count=0;                                                                  
  cin >> a >> b >> c;                                                           
  for (int i=a; i<=b; i++) {                                                    
    if (c%i==0) {                                                               
      count++;                                                                  
    }                                                                           
  }                                                                             
  cout << count << endl;                                                        
}                                                                               
                            

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)


int main() {
	int S,W;
  	cin>>S>>W;
  
  	if(S<=W) cout<<"unsafe"<<endl;
  	else cout<<"safe"<<endl;
  
}

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

int main() {
  long long n, m;
  long long cnt = 0;
  
  cin >> n >> m;
  
  if(n == 1 && m == 1) cout << 1;
  else if(n == 1 || m == 1) cout << n * m -2;
  else cout << n*m - (2 * (m+n) - 4);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var s = Console.ReadLine();
		long wa = 0;
		for(int i = 0; i < n-1; i++)
		{
			if(s[i]!=s[i+1])
				wa++;
		}
		wa++;
		Console.WriteLine(wa);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}

Measured memory_bytes: 13140
S = input()
a, b = int(S[: 2]), int(S[2:])
if a == 0 and b == 0:
	print("NA")
elif a >= 13 and b >= 13:
	print("NA")
elif a == 0 and b >= 13:
	print("NA")
elif a >= 13 and b == 0:
	print("NA")
elif 1 <= a <= 12 and 1 <= b <= 12:
	print("AMBIGUOUS")
elif 1 <= a <= 12 and b == 0:
	print("MMYY")
elif 1 <= a <= 12 and b >= 13:
	print("MMYY")
elif a == 0 and 1 <= b <= 12:
	print("YYMM")
else:
	print("YYMM")


Measured memory_bytes: 3064
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int n,k;
int phi[max_n];
int main(){
    scanf("%d",&k);
    n=3;
    for(int i=1;i<=k;i++)phi[i]=i;
    for(int i=1;i<=k;i++){
        for(int j=i*2;j<=k;j+=i)phi[j]-=phi[i];
    }
    int ans=0;
    for(int i=1;i<=k;i++)ans=Add(ans,Mul(phi[i],Pow(k/i,n)));
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3820
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int fibonacci (int n) {
    if (n < 2) return n;
    else return fibonacci(n - 2) + fibonacci(n - 1);
}

void printSmile () {
    cout << ":)" << endl;
}

void printVectorBool (vector<bool> b) {
    for (int i = 0; i < b.size(); i++) {
        if (i == b.size() - 1)
            cout << b[i] << endl;
        else
            cout << b[i] << " ";
    }
    b['e' - 'a'] = false;
}

int pow (int base, int exp) {
    int r = 1;
    for(int i = 0; i < exp; i++){
        r *= base;
    
    }
return r;
}

int main () {
    int n;
    cin >> n;
    int r = 0;
    vector<int> t (n);
    for (int i=0; i < n; i++){ 
        cin >> t[i];
        for (int j = 0; j < i; j++){
            r += t[i]*t[j];
        }
    }
    cout << r << endl;
}

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

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

  vector<int> num(N);

  rep(i, M) {
    int a, b;
    cin >> a >> b;
    num.at(a - 1)++;
    num.at(b - 1)++;
  }

  rep(i, N) { cout << num.at(i) << endl; }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
int a[20];

int main(){
	int i, c = 0, t = 10;
	for(i = 0; i < 5; i++){
		cin >> a[i];
		if(a[i] % 10 != 0){
			t = min(t, a[i] % 10);
		}
	}
	for(i = 0; i < 5; i++){
		if(a[i] % 10 == 0)
			c += a[i];
		else
			c += (a[i]/10 + 1) * 10;
	}
	if(t != 10)
		c -= (10 - t);
	cout << c;
	return 0;
} 


Measured memory_bytes: 384
#include<iostream>
#include<vector>
using namespace std;
int n,a[100];
vector<pair<int,int>> ans;
int main()
{
	cin>>n;
	int Max=0,maxp=0,Min=0,minp=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(Max<a[i]){Max=a[i];maxp=i;}
		if(Min>a[i]){Min=a[i];minp=i;}
	}
	if(Max==Min){cout<<0<<endl;return 0;}
	if(Max>-Min)
	{
		ans.emplace_back(maxp,n);
		ans.emplace_back(maxp,n);
		a[n]+=a[maxp];a[n]+=a[maxp];
		for(int i=2;i<=n;i++)
		{
			ans.emplace_back(n,i);
			ans.emplace_back(n,n);
			a[i]+=a[n];
			a[n]+=a[n];
		}
	}
	else
	{
		ans.emplace_back(minp,1);
		ans.emplace_back(minp,1);
		a[1]+=a[minp];a[1]+=a[minp];
		for(int i=n;i>1;i--)
		{
			ans.emplace_back(1,i);
			ans.emplace_back(1,1);
			a[i]+=a[1];
			a[1]+=a[1];
		}
	}
	cout<<ans.size()<<endl;
	for(int i=0;i<ans.size();i++)cout<<ans[i].first<<' '<<ans[i].second<<endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	ps := make([]int, n)
	r := 0
	for i := range ps {
		fmt.Scan(&ps[i])
		r += ps[i]
	}
	sort.Sort(sort.Reverse(sort.IntSlice(ps)))
	r -= ps[0] / 2
	fmt.Println(r)
}


Measured memory_bytes: 512
import sys
L = sys.stdin.readlines()
for line in L:
	A = line.split()
	a, b, c, d, e, f = [float(A[i]) for i in range(6)]
	x = (b * f - c * e) / (b * d - a * e)
	y = (c * d - a * f) / (b * d - a * e)
	print("{:.3f} {:.3f}".format(x+0, y+0))

Measured memory_bytes: 7404
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String s = sc.next();
		int max = 0;
		for (int i = 1; i < n - 1; i++) {
			int count = 0;
			for (char c = 'a'; c <= 'z'; c++) {
				if (s.substring(0, i).contains(String.valueOf(c))
						&& s.substring(i).contains(String.valueOf(c))) {
					count++;
				}
			}
			if (count > max) {
				max = count;
			}
		}

		System.out.println(max);

		sc.close();
	}
}


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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;

int main()
{
	scanf("%d",&N);
	vector<int> A(N);
	FOR(i,0,N){
		scanf("%d",&A [i]);
	}

	int cnt = 0;
	FOR(i,0,N){
		cnt += A [i] % 2;
	}
	if(cnt % 2 == 0){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}

	return 0;
}


Measured memory_bytes: 640
HW = input().split()
H = int(HW[0])
W = int(HW[1])

while H != 0 or W != 0:
    for i in range(H):
        for j in range(W):
            print("#", end = "")
        print("")
    HW = input().split()
    H = int(HW[0])
    W = int(HW[1])
    print("")

Measured memory_bytes: 8936
import java.awt.*;import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int n,i,j,t;(n=s.nextInt())>0;){double[][]a=new double[++n][n];int[][]b=new int[n][n];Point[]p=new Point[n];for(i=1;i<n;++i){p[s.nextInt()]=new Point(s.nextInt(),s.nextInt());Arrays.fill(a[i],Float.MAX_VALUE);a[i][i]=0;}for(i=1;i<n;++i)for(j=1;j<n;++j)if(p[i].distance(p[j])<=50){a[i][j]=p[i].distance(p[j]);b[i][j]=i;}for(t=1;t<n;++t)for(i=1;i<n;++i)for(j=1;j<n;++j)if(a[i][j]>a[i][t]+a[t][j]){a[i][j]=a[i][t]+a[t][j];b[i][j]=b[t][j];}for(t=s.nextInt();t-->0;){String r="";i=s.nextInt();j=s.nextInt();for(r+=j;i!=j;r=j+" "+r){j=b[i][j];if(j<1){r="NA";break;}}System.out.println(r);}}}}

Measured memory_bytes: 13000
#include<stdio.h>
#include<ctype.h>
int main(void)
{
	char s1[10],s2[10],s3[10];
	scanf("%s%s%s",s1,s2,s3);
	s1[0] = toupper(s1[0]);
	s2[0] = toupper(s2[0]);
	s3[0] = toupper(s3[0]);
	printf("%c%c%c",s1[0],s2[0],s3[0]);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}
void solve(){
	ll l,r;
	cin>>l>>r;
	ll pro=1e18;
	for(ll int i=l;i<=min(l+2018,r);i++){
		for(ll int j=i+1;j<=min(l+2018,r);j++){
			pro=min(pro,(ll)((i*j)%2019));
		}
	}
	cout<<pro;
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 256
n = int(input())
votes = []

for i in range(n):
    votes.append(input())

dic = {}    
for vote in votes:
    if vote in dic:
        dic[vote] += 1
    else:
        dic[vote] = 0

maxv = 0        

for value in dic:
    maxv = max(maxv,dic[value])

results =[]    
for value in dic:
    if dic[value] == maxv:
        results.append(value)
        
results.sort()

for result in results:
    print(result)

Measured memory_bytes: 35216
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
  
    int cnt = 0;
    for (int i = 0; i < 1000; i++)
    {
      string num = to_string(i);
      if(num.size()==1) num = "00" + num;
      if(num.size()==2) num = "0" + num;
        int itr = 0;
        int keta = 0;
        while(itr<N){
            
            if(num[keta] == S[itr]){
                if(keta == 2){cnt++; break;}
                keta++;
            }
            itr++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
// Remeber Choose Compiler: GCC9
#include <bits/stdc++.h>

using namespace std;

// Debug Output Utility
#ifdef LOCAL
#define dbg(args...)             \
    do {                         \
        cout << #args << " -> "; \
        err(args);               \
    } while (0)
void err() { std::cout << std::endl; }
template <typename T, typename... Args>
void err(T a, Args... args) {
    std::cout << a << ' ';
    err(args...);
}
template <template <typename...> class T, typename t, typename... A>
void err(const T<t> &arg, const A &... args) {
    for (auto &v : arg)
        std::cout << v << ' ';
    err(args...);
}
#else
#define dbg(...)
#endif

// Macro Definitions:
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

// Type Alias:
using int64 = long long;
using PII   = pair<int, int>;

// Global Const Variable
const int64 INF  = 0x3f3f3f3f3f3f3f3f;
const int MOD  = 1000000007;
const int MAXN = 200005;
const int M = 1000005;
const int dir[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};

int a[MAXN], b[MAXN];

void run() {
    int n,k;
    cin >> n >> k;
    for(int i=0;i<n;i++) cin >> a[i];
    while(k--) {
        memset(b,0,sizeof(b));
        for(int i=0;i<n;i++) {
            int l = max(0,i-a[i]), r = min(n-1,i+a[i]);
            b[l]++;
            if(r!=n-1) b[r+1]--;
        }
        for(int i=1;i<n;i++) b[i] += b[i-1];
        int up = n;
        for(int i=0;i<n;i++) a[i] = b[i], up = min(up, a[i]);
        if(up>=n) break;
    }
    for(int i=0;i<n;i++) cout << a[i] << " ";
    cout << endl;
}

// Debug Input Redirection
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    run();
}

Measured memory_bytes: 5232
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
//#include<>
using namespace std;

#define rep(i,j) for(i=0;i<j;(i)++)

int main()
{
  string line;
  getline(cin,line);
  int ans;
  cin>>ans;

  int ans_M=0,ans_L=0;
  int i;
  for(i=0;i<line.size();i++){
    //L計算
    if(i==0)ans_L+=atoi(&line[i]);
    else if(line[i]=='+'){
      ans_L+=atoi(&line[i+1]);
      i++;
    }
    else if(line[i]=='*'){
      ans_L*=atoi(&line[i+1]);
      i++;
    }
  }
  int val=0;
  for(i=0;i<line.size();i+=2){
    val=atoi(&line[i]);
    while(i+1<line.size() && line[i+1]=='*'){
      i+=2;
      val*=atoi(&line[i]);
    }
    ans_M+=val;
  }
  //cout<<ans_L<<" "<<ans_M<<endl;
  if(ans_L==ans && ans_M==ans)cout<<"U"<<endl;
  else if(ans_L==ans)cout<<"L"<<endl;
  else if(ans_M==ans)cout<<"M"<<endl;
  else cout<<"I"<<endl;
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
 
int main(){
	fast;
	lli h, n;
	cin>>h>>n;
	lli sum=0, temp;
	for(int i=0; i<n; i++){
	    cin>>temp;
	    sum+=temp;
	}
	if(h<=sum) cout<<"Yes"<<"\n";
	else cout<<"No"<<"\n";
	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = new int[n];
		int[] q = new int[n];
		int[] array = new int[n];
		for (int i = 0; i < p.length; i++) {
			p[i] = sc.nextInt();
		}
		for (int i = 0; i < q.length; i++) {
			q[i] = sc.nextInt();
		}
		for (int i = 0; i < array.length; i++) {
			array[i] = i + 1;
		}
		int num = 0;
		int pNum = -1;
		int qNum = -1;
		do {
			num++;
			if (Arrays.equals(array, p)) {
				pNum = num;
			} 
			
			if (Arrays.equals(array, q)) {
				qNum = num;
			}
		} while (nextPermutation(array));
		System.out.println(Math.abs(pNum - qNum));
		sc.close();
	}

	//順列全列挙
	//nが10を超えてくると間に合わなくなる
	static boolean nextPermutation(int[] array) {
		// Find longest non-increasing suffix
		int i = array.length - 1;
		while (i > 0 && array[i - 1] >= array[i])
			i--;
		// Now i is the head index of the suffix

		// Are we at the last permutation already?
		if (i <= 0)
			return false;

		// Let array[i - 1] be the pivot
		// Find rightmost element that exceeds the pivot
		int j = array.length - 1;
		while (array[j] <= array[i - 1])
			j--;
		// Now the value array[j] will become the new pivot
		// Assertion: j >= i

		// Swap the pivot with j
		int temp = array[i - 1];
		array[i - 1] = array[j];
		array[j] = temp;

		// Reverse the suffix
		j = array.length - 1;
		while (i < j) {
			temp = array[i];
			array[i] = array[j];
			array[j] = temp;
			i++;
			j--;
		}

		// Successfully computed the next permutation
		return true;
	}
}

Measured memory_bytes: 36480
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

using Graph = V<V<int>>;

map<P<int>,int> m;
int ss[100000];

V<bool> seen;
void dfs(const Graph &G, int v, int p)
{
    seen[v] = true;
    int c = 0;
    for (auto next_v : G[v])
    {
        if (seen[next_v]) continue;
        ++c;
        if (c == p) ++c;
        int kk = m[make_pair(v < next_v ? v : next_v, v < next_v ? next_v : v)];
        ss[kk] = c;
        dfs(G, next_v, c);
    }
}

void solve()
{
    IN(n);
    Graph g(n);
    rep(i, n-1)
    {
        IN(a, b);
        g[a-1].push_back(b-1);
        g[b-1].push_back(a-1);
        m[make_pair(a-1, b-1)] = i;
    }
    seen.assign(n, false);
    dfs(g, 0, -1);
    int mx = 0;
    rep(i, n-1)
    {
        chmax(mx, ss[i]);
    }
    cout << mx << endl;
    rep(i, n-1)
    {
        cout << ss[i] << endl;
    }
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 13824
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<cstdlib>
#define lson l,mid,o<<1
#define rson mid + 1,r,o<<1|1
#define sc(x) scanf("%d",&x);
#define For(i,a,b)  for(i = a; i <= b; i++)
typedef long long LL;
typedef unsigned long long uLL;
const int INF = 0x3f3f3f3f;
const LL MAX_N = 1e3 + 5;
const LL mod = 1e9 + 7;
const double PI = acos(-1);
using namespace std;


int main()
{
    LL x;
    cin>>x;
    LL l=0,r=100000,mid;
    while(l<r){
        mid=(l+r)>>1;
        if(mid*(mid+1)>=(x*2))  r=mid;
        else l=mid+1;
    }
    cout<<l<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int i,j,n,siai;
  int a,b,x,y,t1,t2;
  int t[150][3];
  scanf("%d",&n);
  for(i=0;i<150;i++){
     t[i][0]=0;//勝ち点
     t[i][1]=i;//チーム番号
	 t[i][2]=0;//順位
  }
  siai=n*(n-1)/2;
  for(i=0;i<siai;i++){
     scanf("%d %d %d %d",&a,&b,&x,&y);
     if(x>y)t[a][0]+=3;
     else if(x<y)t[b][0]+=3;
     else if(x==y){
              t[a][0]++;
              t[b][0]++;
     }
  }
   
  for(i=1;i<n;i++)
    for(j=i+1;j<n+1;j++){
       if(t[i][0]<t[j][0]){
          t1=t[i][0];
          t[i][0]=t[j][0];
          t[j][0]=t1;

		  t1=t[i][1];
          t[i][1]=t[j][1];
          t[j][1]=t1;
       }
    }
  t[1][2]=1;
  for(i=2;i<n+1;i++){
      t[i][2]=i;
	  if(t[i][0]==t[i-1][0]){t[i][2]=t[i-1][2];}
  }
  
  for(i=1;i<n;i++){
    for(j=i+1;j<n+1;j++){
       if(t[i][1]>t[j][1]){
          t1=t[i][1];
          t[i][1]=t[j][1];
          t[j][1]=t1;

		  t2=t[i][2];
          t[i][2]=t[j][2];
          t[j][2]=t2;
       }
    }
  }
  
  for(i=1;i<n+1;i++)
     printf("%d\n",t[i][2]);
  
  return 0;
}

Measured memory_bytes: 1032
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int A = sc.nextInt();
	int B = sc.nextInt();
	if((A==1 && B==2)||(A==2 && B==1)) System.out.print(3);
	else if((A==1 && B==3)||(A==3 && B==1)) System.out.print(2);
	else System.out.print(1);
    }
}


Measured memory_bytes: 21716
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#define lld long long int
#define DBG1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define DBG2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define DBG3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// freopen("input.txt", "r", stdin);  
	string s1,s2,s3;
	cin >> s1 >> s2 >> s3;
	int a=0,b=0,c=0;
	int f;
	if(s1[0]=='a')
		f=1;
	else if(s1[0]=='b')
		f=2;
	else
		f=3;
	a++;
	while(1)
	{
		if(f==1)
		{
			if(a>=s1.size())
				break;
			if(s1[a]=='a')
				f=1;
			else if(s1[a]=='b')
				f=2;
			else
				f=3;
			a++;
		}
		else if(f==2)
		{
			if(b>=s2.size())
				break;
			if(s2[b]=='a')
				f=1;
			else if(s2[b]=='b')
				f=2;
			else
				f=3;
			b++;
		}
		else
		{
			if(c>=s3.size())
				break;
			if(s3[c]=='a')
				f=1;
			else if(s3[c]=='b')
				f=2;
			else
				f=3;
			c++;
		}
	}
	if(f==1)
		cout << "A";
	else if(f==2)
		cout << "B";
	else
		cout << "C";
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


int main(){
  ll n, k, q;
  cin >> n >> k >> q;
  vector<ll> a(q);
  rep(i, q) cin >> a[i];


  vector<ll> memo(n, k);
  rep(i, n) memo[i] -= q;
  rep(i, q) memo[a[i]-1]++;

  rep(i, n){
    cout << ((0 < memo[i])? ("Yes"):("No")) << endl;
  }
  

  return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
 #define MAX 1000000
int N, M, Q;
int A[MAX];
int V[MAX];
void simulate(){
 list<int> l;
 for ( int i = 0; i < N; i++ ) l.push_back(i);
 list<int>::iterator it = l.begin();
 for ( int i = 0; i < M; i++ ){
 int a = A[i];
 if ( a % 2 == 0 ) {
 for ( int c = 0; c < a; c++ ){
it++;
if ( it == l.end() ) it = l.begin();
 }
 } else {
 for ( int c = 0; c < a; c++ ){
if ( it == l.begin() ) {
 it = l.end();
 it--;
} else {
 it--;
}
 }
 }





 V[*it] = 0;
 it = l.erase(it);
 if ( it == l.end() ) it = l.begin();
 }
}
int main(){
 cin >> N >> M >> Q;
 for ( int i = 0; i < M; i++ ) scanf("%d", &A[i]);
 for ( int i = 0; i < N; i++ ) V[i] = 1;
 simulate();
 for ( int i = 0; i < Q; i++ ){
 int q; cin >> q;
 cout<<V[q]<<endl;
 }
}

Measured memory_bytes: 11012
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int n,m;
    cin >> n >> m;
    cout << (n-1)*(m-1);
    return 0;
}


Measured memory_bytes: 256
import itertools

def main():
    H, W, K = map(int, input().split())
    C = [list(input().rstrip()) for _ in range(H)]
    ans = 0
    for h in itertools.product([0, 1], repeat=H):
        for w in itertools.product([0, 1], repeat=W):
            black = 0
            for r in range(H):
                for c in range(W):
                    if h[r] == 0 and w[c] == 0 and C[r][c] == "#":
                        black += 1
            if black == K:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 73988
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 

using namespace std;
using namespace __gnu_pbds;

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

#define M 1000010

bool pal(string s){
	ll n=sz(s);
	bool ok=1;
	rep(i,0,n/2)if(s[i]!=s[n-1-i])ok=0;
	return ok;
}
int main(){
	IOS;
	
	string s;cin>>s;
	ll n=sz(s);
	bool ok=pal(s);
	string a="",b="";
	rep(i,0,(n-1)/2)a+=s[i];
	ok&=pal(a);
	rep(i,(n+3)/2-1,n)b+=s[i];
	ok&=pal(b);
	if(ok)cout<<"Yes";
	else cout<<"No";
	return 0;
}



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

int main(){
    int N;
    cin>>N;
    int a = 0;
    for(int i = 0; i < N; i++){
        string str;
        cin>>str;
        if(str=="A")a++;
        else a--;
        if(a < 0){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    if(a==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 3160
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stdio.h>
#include<deque>
#include<map>
#include<queue>
#include<cmath>

typedef long long ll;

#define debug(x) cout << #x << '=' << x << endl;
#define debug_arr(a, n) for(ll i = 0; i < n; i++)cout << a[i] << ' '
#define inf 100000000000
#define loop(i,n) for(ll i = 0; i < n; i++)
#define graph vector<vector<ll>>
#define P pair<ll,ll>

using namespace std;

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

    vector<int> a(n);
    loop(i,n) cin >> a[i];

    sort(a.begin(),a.end(),[](const int& l, const int& r){
        return abs(l) > abs(r);
    });

    int revN = 0;
    ll result = 0;
    loop(i,n-1){
        if(a[i] < 0){
            result -= a[i];
            revN++;
        }else{
            result += a[i];
        }
    }
    if(revN%2 == 1){
        result += a[n-1] * -1;
    }else{
        result += a[n-1];
    }

    cout << result << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)

      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w,r;
string s,s1,s2;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    cin>>n>>k;
    vl v(n);cin>>v;
    vl a(n,0);
    for(int i=1;i<n;i++){
        kv=inf*inf;
        for(int j=i-1;j>=i-k&&j>=0;j--)kv=min(kv,a[j]+abs(v[i]-v[j]));
        a[i]=kv;
    }
    cout<<a[n-1];
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
using namespace std;
int main()
{
	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	long long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//string s;
	long long n, A[100001];
	cin >> n;
	cin >> k;
	for ( a = 0; a < n; a++)
	{
		cin >> A[a];
	}
	/*for ( a = 0; a < n; a++)
	{
		if (A[a]==1)
		{
			b = a;
		}
	}*/
	n--;
	while (n>0)
	{
		n -= k - 1;
		c++;
	}
	cout << c << endl;






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

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


int main() {
	ll a, b;
	cin >> a >> b;
	ll x = min(a, b), y = max(a, b);
	if((y-x)%2==1){
		cout << "IMPOSSIBLE";
	}
	else{
		cout << (a+b)/2;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))

using namespace std;
unsigned long long int newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}
unsigned long long int func(unsigned long long int n)
{
	unsigned long long int sum = 1;
	unsigned long long int d = 1;
	unsigned long long int ds = 1;
	unsigned long long int num = 1;
	unsigned long long int dn = 1;
	unsigned long long int div = 3;
	unsigned long long int dc;
	while(n%2 == 0)
	{
		dn++;
		d*=2;
		ds += d;
		n/=2;
	}
	sum *= ds;
	num *= dn;
	while(n!=1)
	{
		for(dc = 3; dc * dc <= div; dc += 2)
		{
			if(div%dc == 0)
				break;
		}
		if(dc * dc > div)
		{
			//素数
			d = 1;
			dn = 1;
			ds = 1;
			while(n%div == 0)
			{
				dn++;
				d*=div;
				ds += d;
				n/=div;
			}
			sum *= ds;
			num *= dn;
		}
		div+=2;
	}
	return sum - num;
}
int main()
{
	unsigned long long int a,N,b = 1,ans=0;
	cin >> N;
	for(a = 1;a*a <= N; ++a)
	{
		if(N%a == 0)
		{
			if(N>a*a+a)
			{
				ans += N/a-1;
			}
		}
	}
	cout << ans << endl;
	//cout << func(N,N/b) << endl;
	return 0;
}









Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>  // min, max
#include <fstream>  // ifstream
#include <iomanip>  // setprecision
using namespace std;
typedef long long ll;

int main(void)
{
#ifdef FILE_DEBUG
    ifstream inputFile("data/input.txt");
    cin.rdbuf(inputFile.rdbuf());
#endif
    // これより下にコードを書く

    int A, B;
    cin >> A >> B;

    if (B % A == 0)
        cout << A + B << endl;
    else
        cout << B - A << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <ctype.h>
const int bufSize = 1e6;
inline char nc()
{
    #ifdef DEBUG
    return getchar();
    #endif
    static char buf[bufSize],*p1 = buf,*p2 = buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,bufSize,stdin),p1==p2)?EOF:*p1++;
}
template<typename T>
inline T read(T &r)
{
    static char c;
    r=0;
    for(c = nc();!isdigit(c);) c = nc();
    for(;isdigit(c);c=nc()) r = r * 10 + c - 48;
    return r;
}
const int maxn = 1e4 + 100;
int x,y,z,n;
int f[maxn];
inline int calc()
{
    return x * x + y * y + z * z + x * y + x * z + y * z;
}
int main()
{
    read(n);
    for(x = 1;x<=1000;++x)
    {
        for(y = 1;y<=1000;++y)
        {
            if(x * x + y * y + x * y > n) break;
            for(z = 1;z<=1000;++z)
            {
                int t = calc();
                if(t > n) break;
                f[t]++;
            }
        }
    }
    for(int i = 1;i<=n;++i) printf("%d\n",f[i]);
    return 0;
}

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

using namespace std;

const int N = 2e5 + 100;
const int Mod = 1e9 + 7;

ll Fact[N];

ll FastPower (ll a, ll b) {
    if (!b) return 1;
    if (b & 1)    return a * FastPower (a, b - 1) % Mod;
    return FastPower (a * a % Mod, b >> 1);
}

ll C(ll n, ll r) {
    ll Res = 1;
    for (int i = n; i > n - r; i--)
        Res = (Res * i) % Mod;
    Res = (Res * FastPower(Fact[r], Mod - 2)) % Mod;
    return Res;
}

int main()
{
    Fact[0] = 1;
    for (int i = 1; i < N; i++)
        Fact[i] = (Fact[i - 1] * i) % Mod;

    int n, a, b;    cin >> n >> a >> b;

    ll Ans = (FastPower(2, n) - 1 + Mod) % Mod;

    Ans = (Ans - C(n, a) + Mod) % Mod;
    Ans = (Ans - C(n, b) + Mod) % Mod;

    cout << Ans << '\n';
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define pb push_back

#define INF int(1e9)
#define EPS 1e-9
#define MOD int(1e9 + 7)

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin >> s;
	int n = s.length();
	vector<bool> rl(n);
	vector<int> cnt(n);
	for(int i = 0; i < n; i++) {
		int occ = 0;
		char curr = s[i];
		if(curr == 'R') {
			for(; i < n && s[i] != 'L'; i++) {
				occ++;
			}
			cnt[i - 1] = occ - 1;
			rl[i - 1] = true;
 		}
	}
	for(int i = n - 1; i >= 0; i--) {
		int occ = 0;
		char curr = s[i];
		if(curr == 'L') {
			for(; i >= 0 && s[i] != 'R'; i--) {
				occ++;
			}
			cnt[i + 1] = occ - 1;
 		}
	}
	vector<int> ans(n);
	for(int i = 0; i < n; i++) {
		if(rl[i]) {
			ans[i] = 1;
			ans[i + 1] = 1;
			int turns = 0;
			while(cnt[i] > 0 || cnt[i + 1] > 0) {
				swap(ans[i], ans[i + 1]);
				if(cnt[i + 1] > 0) {
					ans[i + 1]++;
					cnt[i + 1]--;
				}
				if(cnt[i] > 0) {
					ans[i]++;
					cnt[i]--;
				}
				turns++;
			}
			if(turns % 2 != 0)
				swap(ans[i], ans[i + 1]);
		}
	}
	for(int i = 0; i < n; i++)
		cout << ans[i] << ' ';
	cout << '\n';
	return 0;
}


Measured memory_bytes: 1488
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
int a[210000],b[210000];
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int i,j,q=1,flag=1,k=0;
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        for(i=1; i<=n; i++)
        {
            scanf("%d",&a[i]);
        }
        if(n%2==0)
        {
            for(i=1; i<=n/2; i++)
            {
                b[i]=a[n-k];
                k+=2;
            }
            for(i=n; i>n/2; i--)
            {
                b[i]=a[n-q];
                q+=2;
            }
        }
        else
        {
            for(i=1;i<=(n+1)/2;i++)
            {
                b[i]=a[n-k];
                k+=2;
            }
            for(i=n;i>(n+1)/2;i--)
            {
                b[i]=a[n-q];
                q+=2;
            }
        }
        for(i=1; i<=n; i++)
        {
            if(i==1)
                printf("%d",b[i]);
            else
                printf(" %d",b[i]);
        }

        printf("\n");
    }
    return 0;
}
/*
4 2 1 3
*/


Measured memory_bytes: 3840
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;
	if (A *B % 2 == 1)puts("Yes");
	else puts("No");

	return(0);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
char ch[10001];
int i=0,joi=0,ioi=0;
while(scanf("%s\n",&ch)!=EOF){
while(1){
if(ch[i]=='\0') break;
if(ch[i]=='J'&&ch[i+1]=='O'&&ch[i+2]=='I')joi++;
if(ch[i]=='I'&&ch[i+1]=='O'&&ch[i+2]=='I')ioi++;
i++;
}
i=0;
printf("%d\n%d\n",joi,ioi);
joi=0;
ioi=0;
}
return 0;
}

Measured memory_bytes: 556
import sys
input = sys.stdin.readline
H, W = map(int, input().split())
table = [0] * 26
a = ord("a")
for _ in range(H):
  s = list(input())[: -1]
  for j in range(W):
    table[ord(s[j]) - a] += 1
#print(table)
t = []
for i in range(26):
  if table[i] > 0: t.append(table[i])

x = 0
y = 0
c = 0
if H % 2 and (W % 2):
  c = 1
if H % 2: y += (W - c) // 2
if W % 2: x += (H - c) // 2
#print(x, y, c)
if H > 1 and (W > 1):
  for p in t:
    if p % 2:
      if c > 0:
        c -= 1
        p -= 1
      else:
        print("No")
        exit(0)
    if p % 4:
      if x > 0:
        x -= 1
      elif y > 0:
        y -= 1
      else:
        print("No")
        exit(0)
else:
  for p in t:
    if p % 2:
      if c > 0:
        c -= 1
      else:
        print("No")
        exit(0)
print("Yes")

Measured memory_bytes: 38512
#include <iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
	string S;
	cin >> S;
	long long ans = 0; 
	int Bcount = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'B') {
			Bcount++;
		}
		else{
			ans += Bcount;
		}
	}
	cout << ans << endl;
	}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000
#define P pair<ll,ll>

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  vector<ll> x(n), l(n);
  for (int i = 0; i < n; i++){
    cin >> x[i] >> l[i];
  }
  vector<P> p(n);
  for (int i = 0; i < n; i++){
    p[i] = P(x[i]+l[i],x[i]-l[i]);
  }
  sort(p.begin(), p.end());
  
  ll ima = -INF;
  ll ans = 0;
  for (int i = 0; i < n; i++){
    if (ima <= p[i].second){
      ans++;
      ima = p[i].first;
    }
  }
  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 6364
N, M = gets.chomp.split.map(&:to_i)
h = {}
M.times do
  a, b = gets.chomp.split.map(&:to_i)
  if h.key?(a)
    h[a] << b
  else
    h[a] = [b]
  end
  if h.key?(b)
    h[b] << a
  else
    h[b] = [a]
  end
end
d = Array.new(N+1, -1)
d[1] = 0
que = [1]
until que.empty?
  index = que.shift
  h[index].uniq.select{|node| d[node] == -1}.each do |node|
    d[node] = index
    que << node
  end
end
puts d.count{|k|k==-1} == 1 ? 'Yes' : 'No'
2.upto(N) do |i|
  puts d[i]
end

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    ll K; cin >> K;
    ll ans = -mod;
    int P[N];
    rep(i, N){
        int a; cin >> a;
        P[i] = a-1;
    }
    ll C[N];
    rep(i, N){
        ll c; cin >> c;
        C[i] = c;
        ans = max(ans, c);
    }

    if(K > N){
        rep(i, N){
            //一回の周期で迎える最大スコアと周期の長さを求める
            int pos = P[i];
            ll len = 1;
            ll mxlen = 1;
            ll mx = C[pos];
            ll acc = C[pos];
            while(pos != i){
                pos = P[pos];
                acc += C[pos]; //行き先のスコアを足す
                //mx = max(mx, acc);
                len++;
                if(acc > mx){
                    mx = acc;
                    mxlen = len;
                }
            }
            if(acc <= 0){
                ans = max(ans, mx);
            }
            else{
                // K - n*len >= 0
                // n <= K/len
                ll num_loop = K/len - 1;
                ll rem = K - num_loop*len;
                ll ac2 = 0;
                int ps2 = i;
                ll mx2 = 0;
                rep(j, rem){
                    ps2 = P[ps2];
                    ac2 += C[ps2];
                    mx2 = max(mx2, ac2);
                }
                ans = max(ans, acc*num_loop + mx2);
/*
                ll K2 = K - mxlen;
                ll num_loop2 = K2/len;
                ll rem2 = K2 - num_loop2*len;
                ll ac3 = 0;
                int ps3 = i;
                ll mx3 = 0;
                rep(j, rem2){
                    ps3 = P[ps3];
                    ac3 += C[ac3];
                    mx3 = max(mx3, ac3);
                }
                ans = max(ans, acc*num_loop2 + mx3);
*/
            }
        }
        cout << ans << endl;
    }
    else{
        rep(i, N){
            ll acc = 0;
            int pos = i;
            rep(j, K){
                pos = P[pos];
                acc += C[pos];
                ans = max(ans, acc);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3680
import java.util.*;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		double r = scan.nextDouble();
		double x = Math.PI;
		System.out.println(r*2*x);
		
	}	
	
	
	//最小公約数
	/*
	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	*/
	
}


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

#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'

typedef long long int ll ;

void solve()
{
	 int n;
	 cin >> n ;
	 string s = "ACL" ;
	 for ( int i = 0 ; i < n ; i++ ) cout << s ;
	 cout << endl ;
}

int main()
{
	 ios ;

	 int T = 1 ;
	 //cin >> T ;
	 for (int i = 1 ; i <= T ; i++)
	 {	solve();	}
}


Measured memory_bytes: 3596
n, k = map(int, input().split())
mod = 10**9+7
A = [list(map(int, input().split())) for _ in range(n)]

# A*B
def mul(a, b):
    c = [[0]*len(b[0]) for i in range(len(a))]
    for i in range(len(a)):
        for k in range(len(b)):
            for j in range(len(b[0])):
                c[i][j] = (c[i][j] + a[i][k]*b[k][j])%mod

    return c

#A**n
def pow(a, n):
    b = [[0]*len(a) for i in range(len(a))]
    for i in range(len(a)):
        b[i][i] = 1
    while n > 0:
        if n & 1 == 1:
            b = mul(a, b)
        a = mul(a, a)
        n = n>>1
    return b

B = pow(A, k)
#print(B)
ans = 0
for i in range(n):
    ans += sum(B[i])
    ans %= mod
print(ans)

Measured memory_bytes: 41720
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double c = Math.toRadians(sc.nextDouble());

		double h = b * Math.sin(c);
		double s = a * h / 2;
		double l = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(c));
		
		System.out.println(String.format("%.4f %.4f %.4f", s, a + b + l, h));
		
		sc.close();
	}
}

Measured memory_bytes: 19104
f m
    | m < 10 = "Yes"
    | m `mod` 2 == 0, m < 20 = "Yes"
    | m `mod` 3 == 0, m < 30 = "Yes"
    | m `mod` 4 == 0, m < 40 = "Yes"
    | m `mod` 5 == 0, m < 50 = "Yes"
    | m `mod` 6 == 0, m < 60 = "Yes"
    | m `mod` 7 == 0, m < 70 = "Yes"
    | m `mod` 8 == 0, m < 80 = "Yes"
    | m `mod` 9 == 0, m < 90 = "Yes"
    | otherwise = "No"
        
main = do
    m <- read <$> getLine :: IO Int
    putStrLn $ f m

Measured memory_bytes: 508