akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
 
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    /*     input! {
        n: usize,
        mut plan: [(i32, i32, i32); n],  // Vec<(i32, i32, i32)>
    }
 */
    input! {
        a: String,
        b: String 
    }
    let ab = [a,b].concat();
    let ab_num:f32 = ab.parse().unwrap();
    if (ab_num.sqrt() as u32).pow(2) == ab_num as u32 {
        println!("Yes");
    }else{
        println!("No");
    }
}    


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

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

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> h,hh;

int main()
{
	ll n, k, ans;
	
	cin >> n >> k;

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

	sort(h.begin(), h.end());
	ans = INF;
	for (int i = 0; i < n-k+1; i++) {
		ans = min(ans, h[i + k - 1] - h[i]);
	}

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


Measured memory_bytes: 1400
///in the name of Allah the most beneficent the most merciful.
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 998244353
//#define mod2 20071027
//#define MOD 998244353
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
#define base 139
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case #%lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
const ll N=300010, M=1000005;
ll n, a[N],pos[N],sz[N],vis[N], res;

int main()
{
    in1(n);
    for(int i=0;i<n;i++)
    {
        in1(a[i]);
        pos[a[i]]=i;
    }
    for(int i=0;i<n;i++)
    {
        if(vis[a[i]]==0)
        {
            vis[a[i]]=1;
            sz[a[i]]++;
            for(int j=a[i]+1;j<=n;j++)
            {
                if(pos[j]<pos[j-1])
                    break;
                vis[j]=1;
                sz[a[i]]++;
            }
            res=max(res, sz[a[i]]);
        }
    }
    printf("%lld\n",n-res);
    return 0;
}
/*

*/


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

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


int main() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int count = 0;
  rep (i, a + 1) {
    rep (j, b + 1) {
      rep (k, c + 1) {
        if (500 * i + 100 * j + 50 * k == x) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
  
}



Measured memory_bytes: 3616
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;



int main(void){
	int n,k;
	while(cin >> n >> k,n|k){
		//dump(n) dump(k)
		bool seq[100010];
		bool empty=false;
		rep(i,100010) seq[i]=false;
		rep(i,k){
			int in;
			cin >> in;
			if(in)
				seq[in-1]=true;
			else
				empty=true;
		}
		int cmax=0;
		int l=0,r=0;
		rep(i,n){
			if(seq[i])
				r++;
			else{
				cmax=max(cmax,r-l);
				l=i+1,r=i+1;
			}
			//dump(cmax)
		}
		cmax=max(cmax,r-l);
		l=0,r=0;
		int mid=-1;
		if(empty){
			rep(i,n){
				if(seq[i])
					r++;
				else if(!seq[i]&&mid==-1){
					mid=i;
				}else{
					cmax=max(cmax,r-l);
					l=mid+1,mid=i,r=i+1;
				}
				/*dump(i) dump(l) dump(mid) dump(r)
				cout << endl;*/
			}
		}
		cmax=max(cmax,r-l);
		cout << cmax << endl;
	}
	return 0;
}

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    ll n, k;
    cin >> n >> k;
    ll tmp = k;
    int res = 1;
    while(tmp <= n){
        tmp *= k;
        res++;
    }
    // cout << res << endl;
    string ans;
    while(tmp >= k){
        int cnt = 0;
        while(n > tmp){
            n -= tmp;
            cnt++;
        }
        ans += to_string(cnt);
        tmp /= k;
    }
    ans += to_string(n);
    cout << ans.size() - 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>

using namespace std;

const int INF=1000000000;

int n,m;
int dp[256][20001];
int codeBook[20];
int input[20001];

int dfs(int lastNum,int idx){
    if(idx==n)
        return 0;
    if(dp[lastNum][idx]!=INF)
        return dp[lastNum][idx];
    int minSum=INF;
    for(int i = 0; i < m; i++){
        int nextNum=min(255,max(0,lastNum+codeBook[i]));
        minSum=min(minSum,dfs(nextNum,idx+1)+(nextNum-input[idx])*(nextNum-input[idx]));
    }
    return dp[lastNum][idx]=minSum;
}

int main(){

    while(cin>>n>>m&&!(n==0&&m==0)){
        for(int i = 0; i < 256; i++)
            for(int j = 0; j < 20001; j++)
                dp[i][j]=INF;
        for(int i = 0; i < m; i++)
            cin>>codeBook[i];
        for(int i = 0; i < n; i++)
            cin>>input[i];
        int res=dfs(128,0);
        cout<<res<<endl;
    }

    return 0;
}

Measured memory_bytes: 21000
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var ab =ReadLine().Split().Select(int.Parse).ToArray();
        if(ab[0]+ab[1]==15)WriteLine("+");
        else if(ab[0]*ab[1]==15)WriteLine("*");
        else WriteLine("x");
    }
}

Measured memory_bytes: 13268
#include<iostream>

int main(void)
{
    int a, b;
    std::cin >> a >> b;
    if (a == b)
        std::cout << "a == b" << std::endl;
    else if(a > b)
        std::cout << "a > b" << std::endl;
    else
        std::cout << "a < b" << std::endl;
    return 0;
}


Measured memory_bytes: 3128
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
typedef long long ll;
using namespace std;

int main(){
    ll N;
    cin>>N;
    ll A[N];
    for(int i = 0;i<N;i++){
        cin>>A[i];
    }
    sort(A,A+N,greater<ll>());
    ll ans = A[0];
    ll ind = 0;
    double o = 0.5;
    
    for(int i = 1;i<N-1;i++){
        if(fmod(o, 1.0) !=0){
            ind++;
        }
        ans+=A[ind];
        
        o+=0.5;
        
        
    }
    cout<<ans<<endl;


}

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

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

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

  int max_cnt = max(A, B) * 10 + 10;
  int ans = 2000;
  for(int i = 10; i < max_cnt; ++i) {
    if((int)(i * 0.08) == A && (int)(i * 0.1) == B) {
      ans = min(ans, i);
    }
 }

  cout << (ans != 2000 ? ans : -1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
    int i, j, n;
    char mark;
    char marks[4] = {'S', 'H', 'C', 'D'};
    int num;
    bool cards[4][13] = {false};

    scanf("%d ", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%c %d ", &mark, &num);
        for (j = 0; j < 4; j++)
        {
            if (mark == marks[j])
            {
                cards[j][num - 1] = true;
                break;
            }
        }
    }
    for (i = 0; i < 4; i++)
    {
        for (j = 0; j < 13; j++)
        {
            if (!cards[i][j])
            {
                printf("%c %d\n", marks[i], j + 1);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2716
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    cout << "88874100321238209719819013272565736216284761125002371810653300184015543867497208821304903291591893742690314210628661444749205508727880023679928585142957605520362472512545133643763317352169701404401216360248053883700606827872818945761708984895130149801381566852502381938413035090108099910195416469364225372303530346759237976066080348509785111131341216038505598381132070513707706447467014464030041516012813927795482817537692315535275898685085658868825647710646479438286705396164993046832226271418944049587951088309367848535540055794386932605551180265087442965893429828359883445648307784394602905061553039148922250421325882787365587821737028864469560718720000" << endl;
    for(int i = 0; i < N; ++i) {
        if(i == 0) cout << 2 << endl;
        else if(i == 1) cout << 22133 << endl;
        else cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 1168
import heapq
h, w = map(int, input().split())
graph = [list(map(int, input().split())) for _ in range(10)]

trans_graph = list(zip(*graph))
next_nodes = []
for idx, d in enumerate(trans_graph[1]):
    next_nodes.append((d, idx))
heapq.heapify(next_nodes)

INF = 10**9
decided = [0]*10
decided[1] = 1
dist = [INF]*10
dist[1] = 0

while next_nodes:
    distance, v = heapq.heappop(next_nodes)
    if decided[v]:
        continue
    decided[v] = 1
    dist[v] = distance
    for v2, x in enumerate(trans_graph[v]):
        if decided[v2]:
            continue
        heapq.heappush(next_nodes, (dist[v]+x, v2))

ans = 0
for _ in range(h):
    for x in map(int, input().split()):
        if x == -1:
            continue
        ans += dist[x]

print(ans)

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

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

Measured memory_bytes: 256
n = int(input())
s = input()
ch = []
for i in range(0, n):
    x = s[:i+1]
    y = s[i+1:len(s)]
    a = set(x)
    b = set(y)
    c = a.intersection(b)
    ch.append(len(c))
print(max(ch))

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	string s, t;
	cin >> s;
	cin >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;


	


}

Measured memory_bytes: 3612
n = int(input())
s = [''.join(sorted(input())) for _ in range(n)]

dct = {}
ans = 0

for i in range(n):
    item = s[i]
    if item in dct:
        dct[item] += 1
    else:
        dct.setdefault(item, 0)
    num = dct[item]
    ans += num

print(ans)

Measured memory_bytes: 19400
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int	main()
{
	int	N, M;
	int	A, B;
	cin >> N >> M;
	Graph		graph(N);
	vector<int>	dg(N, 0);
	for (int i = 0; i < M; ++i) {
		cin >> A >> B;
		--A; --B;
		graph.at(A).push_back(B);
		graph.at(B).push_back(A);
		++dg.at(A);
		++dg.at(B);
	}
	queue<int>		que;
	vector<int>		color(N, -1);
	color.at(0) = 0;
	que.push(0);
	bool	is_bipartile = true;
	while (!que.empty()) {
		int	u = que.front(); que.pop();	
		for (int v : graph.at(u)) {
			if (color.at(v) >= 0) {
				if (color.at(v) == color.at(u)) {
					is_bipartile = false;
					break;
				}
				continue;	
			}
			color.at(v) = (color.at(u) + 1) % 2;
			que.push(v);
		}
	}
	int64_t	cnt = 0;
	if (!is_bipartile) {
		cnt = N;
		cnt = cnt * (N - 1) / 2 - M;
		cout << cnt << endl;
		return 0;
	}
	int	cnt_0 = 0, cnt_1 = 0;
	for (int i = 0; i < N; ++i) {
		if (color.at(i) == 0) 
			++cnt_0;
		else
			++cnt_1;
	}
	for (int i = 0; i < N; ++i) {
		if (color.at(i) == 0)
			cnt += cnt_1 - dg.at(i);
		else
			cnt += cnt_0 - dg.at(i);
	}
	cout << cnt / 2 << endl;
	return 0;
}	


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

int main(void){

    char s[200001];

    scanf("%s", s);

    int len = strlen(s);
    int a = 0, z = len-1;

    for(int i = 0; i < len; i++){
        if(s[i] == 'A'){
            a = i;
            break;
        }
    }
    for(int i = len - 1; i >= 0; i--){
        if(s[i] == 'Z'){
            z = i;
            break;
        }
    }

    printf("%d\n", z-a+1);

    return 0;
}

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


int main() {
    int N, L;
    std::cin >> N >> L;

    int flavor = 0;
    for (int i = 0 ; i < N; i++) {
        flavor += i + L;
    }

    if (L > 0) {
        flavor -= L;
    } else if (L + N - 1 < 0) {
        flavor -= L + N - 1;
    }

    std::cout << flavor << std::endl;
}


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

int main(){
  int n;
  cin >> n;
  bool ans = false;
  for(int i = 1; i <= 9; ++i ){
    for(int j = 1; j <= 9; ++j ){
      int num = i * j;
      if(n % num == 0 && n/num == 1){
        ans = true;
        break;
      }
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

int main()
{
   char str[5];cin>>str;
   sort(str,str+(strlen(str)));
      if(str[0]==str[1] && str[2]==str[3] && str[1]!=str[2])cout<<"Yes\n";
      else cout<<"No\n";
 
   return 0;
}

Measured memory_bytes: 3612
X, N = map(int, input().split())
lst = list(map(int, input().split()))
lst.sort()
if len(lst) == 0:
    print(X)
    exit()
A = X
while A in lst:
    A -= 1
B = X
while B in lst:
    B += 1
if X-A > B-X:
    print(B)
else:
    print(A)

Measured memory_bytes: 9196
#include <iostream>

using namespace std;

int H, W;

void solve() {
    if(H == 0 && W == 0) return;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cout << "#" << flush;
        }
        cout << endl;
    }
    cout << endl;
}

int main() {
    do {
        cin >> H >> W;
        solve();
    }while(H != 0 || W != 0);
}


Measured memory_bytes: 3056
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ABC080A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, a, b, p1, p2, x;
 
            var word = Console.ReadLine().Split(' ');
 
            n = int.Parse(word[0]);
            a = int.Parse(word[1]);
            b = int.Parse(word[2]);
 
            p1 = n * a;
            p2 = b;
 
            if (p1 < p2) x = p1;
            else x = p2;
 
            Console.WriteLine(x);
 
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
use proconio::{ input, fastout };

#[fastout]
fn main() {
    input! {
        n: usize,
    };
    let yomi = match n % 10 {
        2 | 4 | 5 | 7 | 9 => "hon",
        0 | 1 | 6 | 8 => "pon",
        _ => "bon",
    };
    print!("{}", yomi);

}


Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
string a;
string b;
int main()
{
	cin >> a;
	b = a;	
	reverse(a.begin(), a.end());
	for(int i = 0; i < a.size(); ++i)
	{
		if(a[i] == 'b') a[i] = 'd';
		else if(a[i] == 'd') a[i] = 'b';
		else if(a[i] == 'p') a[i] = 'q';
		else if(a[i] == 'q') a[i] = 'p';
	}
	if(a == b) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 512
#include <cstdio>

int main()
{
	int N, D, X, A;
	int cnt=0;
	int i, j;
	
	scanf("%d", &N);
	scanf("%d %d", &D, &X);
	
	for(i=0; i<N; i++)
	{
		scanf("%d", &A);
		
		for(j=1; j<=D; j+=A)
			cnt++;
	}
	
	printf("%d", cnt+X);
	
	return 0;
}

Measured memory_bytes: 128
object Main extends App {
  val read = scala.io.StdIn.readLine()
  val array =  read.split(" ").map(_.toInt).toVector
  val enable = array(0) - array(1)
  if (array(2) - enable < 0) {
    println(0)
  } else {
    println(array(2) - enable)
  }
}


Measured memory_bytes: 26844
#include <iostream>
#define INF 10000000
using namespace std;

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

  for(int i=0;i<n;i++)
    for(int j=n-2;j>=0;j--) {
      x[i][j]+=x[i][j+1];
      y[j][i]+=y[j+1][i];
    }
  
  int ans=y[0][n-1];
  for(int i=0;i<n;i++) //yoko
    for(int j=i+1,sum,a=0;j<n;j++,a=0)//yoko
      while(a<n-1){
	int na=a;
	sum=-INF;
	for(int k=a+1;k<n;k++) { //tate
	  int X=(x[a][i]-x[a][j+1])+(x[k][i]-x[k][j+1]);
	  int Y=(y[a+1][i]-y[k][i])+(y[a+1][j]-y[k][j]);
	  if(sum<=X+Y)sum=X+Y,na=k;
	}
	ans=max(ans,sum);
	
	for(int k=a+1;k<na;k++){//tate
	  sum+=(x[k][i+1]-x[k][j])-(x[k-1][i]-x[k-1][j+1]);
	  ans=max(ans,sum);
	}
	if(a+1==na&&j-i!=1) na=n-1;
	a=na;
      }
  cout <<ans<<endl;
  return 0; 
}

Measured memory_bytes: 1880
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int INF=1e9;
int main(){
	string s;cin>>s;
	char temp='A';int k=0;
	rep(i,0,s.size()){
		if(s.at(i)==temp){
			if(i==s.size()-1) k--;
			i++;
			temp='A';
		}else{
			temp=s.at(i);
		}
		k++;
	}cout<<k<<endl;
}

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

int main()
{
	int x, a, b; cin >> x >> a >> b;

	if (b <= a) {
		cout << "delicious" << endl;
		return 0;
	}

	string ans;

	if( x + 1 <= b - a) ans = "dangerous";
	else ans = "safe";

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

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

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cstring>
using namespace std;
using Graph = vector< vector<int> >;

const int MOD = 1000000007;
int dx[] = {-1, 0, 0, 1, 1, 1};
int dy[] = {0, -1, 1, -1, 0, 1};

int R, C, board[40][40], node[1600], val[1600], indeg[1600];

int get_idx(int x, int y) {
    return C*x + y;
}
int find(int x) {
    return node[x] < 0 ? x : node[x] = find(node[x]);
}
int same(int x, int y) {
    return find(x) == find(y);
}
void unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return;
    node[x] += node[y];
    node[y] = x;
}

int dfs(Graph &G, vector<int> &vs, int idx) {
    if(idx == vs.size()) return 1;

    int ret = 0;
    for(int k=0; k<4; k++) {
        bool ok = true;
        for(auto to : G[ vs[idx] ]) {
            indeg[to]--;
            val[to] -= k;

            if(indeg[to] == 0 && val[to] > 0) ok = false;
            if(val[to] < 0) ok = false;
        }

        if(ok) {
            (ret += dfs(G, vs, idx+1)) %= MOD;
        }

        for(auto to : G[ vs[idx] ]) {
            indeg[to]++;
            val[to] += k;
        }
    }
    return ret;
}

int main() {
    scanf("%d%d", &R, &C);

    memset(node, -1, sizeof(node));
    memset(val, -1, sizeof(val));
    for(int i=0; i<R; i++) {
        for(int j=0; j<C; j++) {
            scanf("%d", &board[i][j]);
            if(board[i][j]) val[ get_idx(i, j) ] = board[i][j];
        }
    }

    Graph G(R*C);
    for(int i=0; i<R; i++) {
        for(int j=0; j<C; j++) {
            if(board[i][j] == 0) continue;
            for(int k=0; k<6; k++) {
                int nx = i + dx[k], ny = j + dy[k];
                if(nx < 0 || nx >= R || ny < 0 || ny >= C) continue;
                if(board[nx][ny] != 0) continue;

                int u = get_idx(i, j), v = get_idx(nx, ny);
                unite(u, v);
                G[u].push_back(v);
                G[v].push_back(u);
                indeg[u]++;
            }
        }
    }

    long long int ans = 1;
    for(int i=0; i<R*C; i++) {
        if(find(i) != i) continue;
        vector<int> vs;
        for(int j=0; j<R*C; j++) {
            if(same(i, j) && val[j] < 0) vs.push_back(j);
        }
        if(vs.size() == 0) ans = 0;
        else {
            (ans *= dfs(G, vs, 0)) %= MOD;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


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

using namespace std;

int main()
{
  int N, D, X;
  cin >> N;
  cin >> D >> X;
  vector<int> A(N, 0);
  for( int i=0;i<N;i++ )
    cin >> A[i];

  int r = 0;
  for( int i=0;i<N;i++ )
    for( int j=1;j<=D;j+=A[i] )
      r++;

  cout << r+X << endl;
}


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

int main() {
  int n;
  string a;
  cin >> n;
  for (int i = 0; i < n; i++){
    cin >> a;
    if (a == "Y"){
      cout << "Four" << endl;
      break;
    }
    else if(i == n - 1){
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 764
#include <iostream>

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

int n, m;
int map[10][10];
bool visit[10];
int ans = 0;

bool all_visited()
{
  REP(i, n) {
    // 見てないところがあったら　false
    if(! visit[i]) return false;
  }
  return true;
}

void dfs(const int pos)
{
  visit[pos] = true;
  if(all_visited()) {
    ans++;
    visit[pos] = false;
    return;
  }
  REP(i, n) {
    if(map[pos][i]) {
      if(! visit[i]) {
        dfs(i);
      }
    }
  }
  visit[pos] = false;
  return;
}

int main()
{
  cin >> n >> m;
  REP(i, 10)
    REP(k, 10)
      map[i][k] = 0;
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    map[a][b] = 1;
    map[b][a] = 1;
  }
  dfs(0);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct SCC{
  Int n;
  vector<vector<Int> > G,rG,T,C;
  vector<Int> vs,used,blg;
  SCC(){}
  SCC(Int n):n(n),G(n),rG(n),used(n),blg(n){}
  
  void add_edge(Int from,Int to){
    G[from].emplace_back(to);
    rG[to].emplace_back(from);
  }
  
  void dfs(Int v){
    used[v]=1;
    for(Int u:G[v])
      if(!used[u]) dfs(u);
    vs.emplace_back(v);
  }
  
  void rdfs(Int v,Int k){
    used[v]=1;
    blg[v]=k;
    C[k].emplace_back(v);
    for(Int u:rG[v])
      if(!used[u]) rdfs(u,k);
  }
  
  Int build(){
    for(Int v=0;v<n;v++)
      if(!used[v]) dfs(v);
    
    fill(used.begin(),used.end(),0);
    Int k=0;
    for(Int i=vs.size()-1;i>=0;i--){
      if(!used[vs[i]]){
        T.emplace_back();
        C.emplace_back();
        rdfs(vs[i],k++);
      }
    }
    for(Int v=0;v<n;v++)
      for(Int u:G[v])
        if(blg[v]!=blg[u])
          T[blg[v]].push_back(blg[u]);
    
    for(Int i=0;i<k;i++){
      sort(T[i].begin(),T[i].end());
      T[i].erase(unique(T[i].begin(),T[i].end()),T[i].end());
    }
    return k;
  }
};

//INSERT ABOVE HERE
signed main(){
  Int m,n;
  cin>>m>>n;
  
  struct Skill{
    vector<Int> s,t;
    vector<string> cond;
    Skill(Int k):s(k),t(k),cond(k){}
  };
  
  vector<Skill> vs;
  for(Int i=0;i<m;i++){
    Int k;
    cin>>k;
    vs.emplace_back(k);
    for(Int j=0;j<k;j++)
      cin>>vs[i].s[j]>>vs[i].cond[j]>>vs[i].t[j],vs[i].s[j]--;
  }
  
  auto check=
    [&](Int x,Int y)->Int{
      auto &vx=vs[x];
      auto &vy=vs[y];
      vector<Int> va(n,0);
      
      for(Int i=0;i<(Int)vx.s.size();i++){
        if(vx.cond[i]==">=")
          chmax(va[vx.s[i]],vx.t[i]);
      }
      
      for(Int i=0;i<(Int)vy.s.size();i++){
        if(vy.cond[i]=="<="){
          if(va[vy.s[i]]>vy.t[i]) return 1;
        }
      }
      
      return 0;
    };
  
  auto NG=[](){cout<<"No"<<endl;exit(0);};  
  for(Int i=0;i<m;i++) if(check(i,i)) NG();

  SCC scc(m);
  for(Int i=0;i<m;i++)
    for(Int j=0;j<m;j++)
      if(check(i,j)) scc.add_edge(j,i);
  
  if(scc.build()!=m) NG();
  
  cout<<"Yes"<<endl;
  return 0;
}



Measured memory_bytes: 4092
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }


int main(void){
    // Your code here!
    int N , W;
    cin >> N >> W;
    vector<ll> w(N);
    vector<ll> v(N);
    rep(i,N) cin >> w[i] >> v[i];
    vector<vector<ll>> dp(N+1,vector<ll>(W+1));
    rep(j,W+1) dp[0][j] = 0;
    rep(i,N)rep(j,W+1) {
        if (j >= w[i]) dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i]);
        else dp[i+1][j] = dp[i][j];
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 80256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
	public static long [][] adj;
	public static int res= Integer.MAX_VALUE;
	public static void main(String[] args) {
		Scanner in= new Scanner(System.in);
		PrintWriter out= new PrintWriter(System.out);
		int n= in.nextInt();
		int m= in.nextInt();
		int rr= in.nextInt();
		int [] r= new int[rr];
		for (int i = 0; i < r.length; i++) {
			r[i]= in.nextInt()-1;
		}
		adj = new long[n][n];
		for (int i = 0; i < adj.length; i++) {
			Arrays.fill(adj[i], 1000000000);
			adj[i][i]=0;
		}
		for (int i = 0; i < m; i++) {
			int a= in.nextInt()-1;
			int b= in.nextInt()-1;
			int c= in.nextInt();
			adj[a][b]= c;
			adj[b][a]= c;
		}
		adj= fl(adj);
//		for (int i = 0; i < n; i++) {
//			for (int j = 0; j < n; j++) {
//				System.out.print(adj[i][j]+" ");
//			}
//			System.out.println();
//		}
		int [] perm= new int[rr];
		boolean [] used= new boolean[rr];
		RecPerm(perm, r, used, 0);
		System.out.println(res);
	}
	public static void RecPerm(int[] perm, int [] key, boolean[] used, int k) {
        if (k == perm.length) {
            go(perm);
        }
        else {
            for (int i=0; i<key.length; i++) {
                if (!used[i]) {
                    perm[k] = key[i];
                    used[i] = true;
                    RecPerm(perm, key, used, k+1);
                    used[i] = false;
                }
            }
        }
    }
	public static long [][] fl(long [][] adj) {
		int n = adj.length;
		for(int k=0; k<n; k++)
	        for(int i=0; i<n; i++)
	          for(int j=0; j<n; j++)
	            adj[i][j] = Math.min(adj[i][j], adj[i][k]+adj[k][j]);
		return adj;
	}
	public static void go(int [] d) {
		int cur=0;
		for (int i = 0; i < d.length-1; i++) {
			//System.out.print(adj[i][i+1]+" ");
			cur+= adj[d[i]][d[i+1]];
		}
		//System.out.println(cur);
		res= Math.min(cur, res);
	}
	
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

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

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 48032
n, m = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(m)]

cities = [[] for _ in range(n)]

for i, (p, y) in enumerate(a):
    cities[p-1].append((y, i))

ans = [None]*m
for p in range(n):
    for j, (y, i) in enumerate(sorted(cities[p])):
        tmp = str(p+1).zfill(6) + str(j+1).zfill(6)
        ans[i] = tmp

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


Measured memory_bytes: 47872
n, m, x = map(int, input().split())
c = [0] * n
a = [[0 for _ in range(m)] for _ in range(n)]
for i in range(n):
    tmp = list(map(int, input().split()))
    c[i] = tmp[0]
    a[i] = tmp[1:]
ans_flag = False
ans = sum(c)
for i in range(1 << n):
    flag = [False] * n
    for j in range(n):
        if (i >> j) & 1:
            flag[j] = True
    ok = [0] * m
    cost = 0
    for k in range(n):
        for t in range(m):
            if flag[k]:
                ok[t] += a[k][t]
        if flag[k]:
            cost += c[k]
        look = [False] * m
        for s in range(m):
            if ok[s] >= x:
                look[s] = True
            if all(look):
                ans = min(ans, cost)
                ans_flag = True
if ans_flag:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 69124
#include <iostream>

using namespace std;

int main(void)
{
	char topping[4];
	cin >> topping;

	int value = 700;

	for (int i = 0; i < 3; i++){
		if (topping[i] == 'o')
			value += 100;
	}

	cout << value << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define reps(i,n) for(int i=1;i<=(int)n;i++)
#define all(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    string S;
    int w;
    cin >> S >> w;
    int cnt = 0;
    rep(i,SZ(S)){
        if(cnt % w == 0){
            cout << S[cnt];
        }
        cnt++;
    }
    cout << enld;
    return 0;
}

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

struct Edge{
    int to, c;
    Edge(int to, int c):to(to), c(c){}
};

using Graph = vector<vector<Edge>>;

Graph G;
ll dist[100005];

void dfs(int v, int p){
    for(auto e : G[v]){
        if(e.to == p) continue;
        dist[e.to] = dist[v] + e.c;
        dfs(e.to, v);
    }
}

int main(){
    int n; cin >> n;
    G.resize(n);
    rep(i,n-1){
        int a, b, c; cin >> a >> b >> c;
        --a, --b;
        G[a].push_back(Edge(b,c));
        G[b].push_back(Edge(a,c));
    }
    int q, k; cin >> q >> k;
    --k;
    dfs(k, -1);
    rep(i,q){
        int x, y; cin >> x >> y;
        --x, --y;
        ll ans = dist[x] + dist[y];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 15644
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    ll n,t1,t2;
    cin>>n>>t1;
    if(n==1) cout<<t1<<endl;
    else{
        cin>>t2;
        ll l=lcm(t1,t2);
        rep(i,n-2){
            cin>>t1;
            l=lcm(l,t1);
        }
        cout<<l<<endl;
    }
    return 0;
}

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

using namespace std;

const int N=200010;

int n,a[N],ans1[N],ans2[N],cnt;

int main(){
//	freopen("c.in","r",stdin);
//	freopen("c.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	int mx=-1e9,mn=1e9,p1,p2;
	for(int i=1;i<=n;++i){
		if(mx<a[i]||(mx==a[i]&&p1<i))mx=a[p1=i];
		if(mn>a[i]||(mn==a[i]&&p2>i))mn=a[p2=i];
	}
	for(int i=1;i<=n;++i)if(i!=p1&&i!=p2){
		if(a[i]<0){
		//	printf("%d %d\n",mx,a[i]);
			ans1[++cnt]=mx;mx-=a[i];
		}else{
		//	printf("%d %d\n",mn,a[i]);
			ans1[++cnt]=mn;mn-=a[i];
		}
		ans2[cnt]=a[i];
	}
	ans1[++cnt]=mx;ans2[cnt]=mn;
	//printf("%d %d\n",mx,mn);
	mx-=mn;cout<<mx<<endl;
	for(int i=1;i<=cnt;++i)printf("%d %d\n",ans1[i],ans2[i]);
	return 0;
}


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

struct vac{
    int a;
    int b;
    int c;
};

int vacation(vector<vac> v,int n){

    int dp[n+1][3];
    dp[1][0]=v[1].a;
    dp[1][1]=v[1].b;
    dp[1][2]=v[1].c;
    for(int i=2;i<=n;i++){
        dp[i][0]=v[i].a+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=v[i].b+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=v[i].c+max(dp[i-1][0],dp[i-1][1]);
    }
    return max(dp[n][0],max(dp[n][1],dp[n][2]));
}
int main(){
    int n;
    cin>>n;
    vector<vac> v(n+1);

    for(int i=1;i<=n;++i){
        cin>>v[i].a>>v[i].b>>v[i].c;
    }
    int ans=vacation(v,n);
    cout<<ans;
}


Measured memory_bytes: 6632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
const ll MOD=1e9+7;
const int INF=1<<30;

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

int dp[100010];

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  rep(i,N){
    cin >> h[i];
  }
  for(int i=0;i<1e5+10;i++){
    dp[i]=INF;
  }
  dp[0]=0;
  for(int i=0;i<N;i++){
    for(int j=1;j<=K;j++){
      chmin( dp[i+j],dp[i]+abs(h[i]-h[i+j]) );
    }
  }
  cout << dp[N-1] << endl;
  
}

Measured memory_bytes: 1024
#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define p 1000000007
#define file(x)freopen(x".in","r",stdin);freopen(x".out","w",stdout)
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    ll x=0;char zf=1;char ch=getchar();
    while(ch!='-'&&!isdigit(ch))ch=getchar();
    if(ch=='-')zf=-1,ch=getchar();
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();return x*zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int k,m,n,x,y,z,cnt,ans;
int a[605];bool vis[605],nt[605];
int q[605],t;
int f[605][305][305];
int main(){
	n=r;
	for(rt i=1;i<=2*n;i++){
		a[i]=r;if(a[i]!=-1)vis[a[i]]=1;
		if(i&1^1){
			if(a[i]==-1&&a[i-1]==-1)cnt++;
			if(a[i]!=-1&&a[i-1]!=-1)nt[a[i]]=nt[a[i-1]]=1;
		}
	}
	for(rt i=1;i<=2*n;i++)if(!nt[i])if(vis[i])q[++t]=1;else q[++t]=0;n=t; 
	//q=1在原数列中  
	f[n][0][0]=1;
	for(rt i=n;i>=1;i--){
		for(rt j=0;j<=n/2;j++)
		for(rt k=0;k<=n/2;k++)if(f[i][j][k]){
			const int v=f[i][j][k];
			if(q[i]){
				(f[i-1][j+1][k]+=v)%=p;
				if(k)(f[i-1][j][k-1]+=v)%=p;
			}else {
				(f[i-1][j][k+1]+=v)%=p;
				if(k)(f[i-1][j][k-1]+=v)%=p;
				if(j)(f[i-1][j-1][k]+=1ll*v*j%p)%=p;
			}
		}
	}
	int ans=f[0][0][0];
	for(rt i=2;i<=cnt;i++)ans=1ll*ans*i%p;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 219392
N = int(input())
A = list(map(int, input().split()))

silver = 0
rate = set([])
for a in A:
    if a >= 3200:
        silver += 1
    elif 2800 <= a <= 3199:
        rate.add("red")
    elif 2400 <= a <= 2799:
        rate.add("orange")
    elif 2000 <= a <= 2399:
        rate.add("yellow")
    elif 1600 <= a <= 1999:
        rate.add("blue")
    elif 1200 <= a <= 1599:
        rate.add("cyan")
    elif 800 <= a <= 1199:
        rate.add("green")
    elif 400 <= a <= 799:
        rate.add("brown")
    else:
        rate.add("hai")

if len(rate) == 0:
    print(1, silver)
else:
    print(len(rate), len(rate)+silver)

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

int main() {
	long N, ans = 0;
	cin >> N;
	vector<long> a;
	for (long i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			a.push_back(N / i);
			a.push_back(i);
		}
	}
	for (long& i : a) {
		long m = N / i - 1;
		if (m == 0) continue;
		if (N % m == N / m) ans += m;
	}
	cout << ans;
}

Measured memory_bytes: 384
N, M = map(int, input().split())


def make_divisors(n):
    i, divisors = 1, []
    while i * i <= n:
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
        i += 1
    return divisors


ans = 0
for x in make_divisors(M):
    if N <= M // x:
        ans = max(ans, x)
print(ans)


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

const int mod = 1e9+7;
const int INF = 2000000;

int main() {
    int N;
    cin >> N;
    vector<int> A(N+1, 0);
    int a;
    for(int i=2;i<=N;i++) {
        cin >> a;
        A[a]++;
    }
    for(int i=1;i<=N;++i) {
        cout << A[i] << endl;
    }
}


Measured memory_bytes: 3988
use std::io::{self, BufRead};

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let line = lines.next().unwrap().unwrap();
  let n: usize = line.parse().unwrap();
  let line = lines.next().unwrap().unwrap();
  let xs: Vec<usize> = line.split(' ').map(|x| x.parse().unwrap()).map(|x: usize| x - 1).collect();
  let mut men = vec![0; n];
  for x in xs {
    men[x] += 1;
  }
  for m in men {
    println!("{}", m);
  }
}

Measured memory_bytes: 5692
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define vi vector<int>
#define Sort(v) sort(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;


int calc(int x,int y,char z){
    
    if(z =='+') return x+y;
    if(z =='-') return x-y;
    if(z =='*') return x*y;
    if(z =='/') return x/y;
    
    return 0;
}

int main(){
    while(true){
        int a,b; char op;
        cin >> a >> op >> b;
        
        if(op =='?') break;
        
        cout << calc(a,b,op) << endl;
    }
    
    
    
}









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

using namespace std;

int main() {
	int a = 0, b = 0;
	char c[4];

	scanf("%s", c);

	for (int i=0; i<3; ++i) {
		if (c[i] == 'A')
			++a;
		else
			++b;
	}

	if (a && b)
		puts("Yes");
	else
		puts("No");
	
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    for(int i = 0; i < n; i++) cin >> q[i];

    vector<int> r(n);
    for(int i = 0; i < n; i++) r[i] = i+1;

    int count = 0;
    int pcount, qcount;
    do{
        bool ismatch = true;
        for(int i = 0; i < n; i++){
            if(p[i] != r[i]) ismatch = false;
        }
        if(ismatch) pcount = count;

        ismatch = true;
        for(int i = 0; i < n; i++){
            if(q[i] != r[i]) ismatch = false;
        }
        if(ismatch) qcount = count;
        count++;
    }while(next_permutation(r.begin(), r.end()));

    cout << max(pcount-qcount, qcount-pcount) << endl;
    return 0;
}



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

int main() {
    ll N, M; cin >> N >> M;
    ll ans = 0;
    //端以外全部裏
    if (N == 1) {
        if (M == 1) ans = 1;
        else ans = M-2;
    }
    else if (M == 1) {
        if (N == 1) ans = 1;
        else ans = N-2;
    }
    else ans += (N-2)*(M-2);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		int[] map = S.chars().distinct().toArray();
		
		int NS = 0;
		int EW = 0;
		for (int c : map) {
			if (c == 'N') {
				NS += 1;
			} else if (c == 'S') {
				NS += -1;
			} else if (c == 'E') {
				EW += 1;
			} else if (c == 'W') {
				EW += -1;
			}
			
		}
		
		String ans = Math.abs(NS) + Math.abs(EW) == 0 ? "Yes" : "No";
		System.out.println(ans);
		
	}
}

Measured memory_bytes: 28756
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// 入力
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int p = 0;
		if(n%2==0){
			p = n/2;
		}else{
			p = n/2 + 1;
		}

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


Measured memory_bytes: 22356
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s, s1, s2, ans;
	cin >> s >> s1 >> s2;

	ans = "A" + s1.substr(0, 1) + "C";
	cout << ans << "\n";

	return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

signed main(){
    int n, m;
    cin >> n >> m;
    
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(ALL(a));
    
    vector<pair<int, int>> changes(m);
    rep(i,m) cin >> changes[i].second >> changes[i].first;
    sort(rALL(changes));
    
    queue<int> q;
    for(auto p: changes){
        rep(i,p.second){
            q.push(p.first);
        }
        if(q.size() >= n) break;
    }
    
    int ans = 0;
    rep(i,n){
        if(q.front() <= a[i]){
            ans += a[i];
        }else{
            ans += q.front();
            q.pop();
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3840
package main
import (
  "fmt"
  // "math"
)

func main() {
  var (
    A int
    B int
    C int
  )
  fmt.Scan(&A)
  fmt.Scan(&B)
  fmt.Scan(&C)

  if A == B {
    fmt.Println(C)
  } else if B == C {
    fmt.Println(A)
  } else {
    fmt.Println(B)
  }

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
template <class T> inline bool chmin(T &x, const T &y) { return x > y ? x = y, true : false; }
template <class T> inline bool chmax(T &x, const T &y) { return x < y ? x = y, true : false; }
using namespace std;
using pii=pair<int,int>;

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


    int n; cin>>n;
    map<pii,long long> mp;
    for(int i=1; i<=n; ++i)
    {
        if(i%10)
        {
            int j;
            for(j=i; j/10; j/=10);
            mp[pii(j,i%10)]++;
        }
    }
    long long ans=0;
    for(int i=1; i<=n; ++i){
        if(i%10){
            int j;
            for(j=i; j/10; j/=10);
            ans+=mp[pii(i%10,j)];
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }
vll fac(2,1),inv(2,1),finv(2,1) ;

void nCr_set(int n){
	for(int i=2;i<=n;i++){
		fac.push_back(fac.at(i-1)*i%mod) ;
		inv.push_back(mod-inv.at(mod%i)*(mod/i)%mod) ;
		finv.push_back(finv.at(i-1)*inv.at(i)%mod) ;
	}
}

ll nCr(ll n,ll r){
	if(n<0||r<0||n<r) return 0 ;
	if(n==r||r==0) return 1 ;
	return fac.at(n)*finv.at(n-r)%mod*finv.at(r)%mod ;
}

ll nHr(ll n,ll r){
	return nCr(n+r-1,n-1) ;
}

ll modpow(ll a,ll b){
	ll res = 1 ;
	while(b>0){
		if(b&1) res = res*a%mod ;
		b >>= 1 ;
		a = a*a%mod ;
	}
	return res ;
}

int main(){
	ll k ; cin >> k ;
	string s ; cin >> s ;
	ll n = s.size() ;
	ll ans = 0 ;
	nCr_set(3*1e6) ;
	for(int i=0;i<=k;i++){
		ans += nCr(n+k-i-1,n-1)*modpow(25,k-i)%mod*modpow(26,i)%mod ;
		ans %= mod ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 74792