akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
// IO
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
#define pd(a) printf("%d ", a)
#define pld(a) printf("%d\n", a)
#define pda(a, n) fo(i, n) pd(a[i])
#define pl printf("\n")
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b) 
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
// math
const ll mod = 1e9+7;
template<typename T> T gcf(T a, T b) {return (b == 0) ? a : gcf(b, a%b);} 
template<typename T> T lcm(T a, T b) {return (a*b)/gcf(a, b);}
template<typename T> T sumTo(T x) {return x * (x+1) / 2;}
template<typename T> T sumSquaresTo(T x) {return x * (x+1) * (2*x+1) / 6;}
template<typename T> T ceilDiv(T n, T d) {return (n+d-1)/d;}

void solve() {
    int r; sc(r);
    pd(r*r);
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
#include<stdio.h>
#include<algorithm>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn =200050 ;
typedef long long ll;


ll a[maxn];

int main()
{
    ll n;
    scanf("%lld",&n);
    for(ll i=1; i<=n; i++)
        scanf("%lld",&a[i]);

    ll xlast = 0;
    ll ans = 0;
    ll l = 1;
    for(ll r=1; r<=n; r++)
    {
        while(xlast + a[r] != (xlast ^ a[r]))
        {
            xlast -= a[l];
            l++;
        }
        ans += r - l +1;
        xlast += a[r];

    }
    cout<<ans<<endl;


}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;

int main(){

    long long int a, b, c, k;
    cin >> a >> b >> c >> k;

    long long int ans = 0;

    if(a>=k){
        cout << k << endl;
        return 0;
    }
    else{
        ans += a;
        k -= a;
    }

    if(b>=k){
        cout << ans << endl;
        return 0;
    }
    else{
        k -= b;
    }

    if(k>0){
        ans -= k;
    }

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


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);

using namespace std;

int n, a[200001], p[200001];

signed main()
{

 	FLASH

 	cin>>n;

 	fr(i, 1, n + 1){
 		cin>>a[i];
 		p[i] = p[i - 1] + a[i];

 	}

	int l = 1, r = 1;
	int x = 0;
	int ans = 0;

	while(r <= n){
		while((x^a[r]) != p[r] - p[l - 1]){
			x ^= a[l];
			l++;
		}

		x ^= a[r];
		int len = r - l + 1;
		ans += len;
		r++;
	}

	cout<<ans;
 	
}

Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var xy = ReadInts();
            var X = xy[0];
            var Y = xy[1];

            var gcd = Gcd(X, Y);

            var ans = X + Y + 1 - gcd;
            WriteLine(ans);
        }

        //最大公約数
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



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

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

    long n;
    cin >> n;

    long a;
    vector<long> as;
    long cnt = 0;
    while (cnt < n && cin >> a){
        as.push_back(a);
        ++cnt;
    }

    std::sort(as.begin(), as.end());
    as.erase(std::unique(as.begin(), as.end()), as.end());

    long result = as.size() % 2 == 0 ? as.size() - 1 : as.size();

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 1400
#include<stdio.h>
#include<string.h>
int main(){
	int a, b;
	char s[11];
	char t[11];
	char u[11];
	
	scanf("%s %s\n", &s, &t);
	scanf("%d %d\n", &a, &b);
	scanf("%s", &u);

	if(strcmp(s,u) == 0){
		printf("%d %d\n", a-1, b);
	}
	else if(strcmp(t, u) == 0){
		printf("%d %d\n", a, b-1);
	}
	return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int ans[26];
  rep(i,26) ans[i]=0;
  string s;
  cin >> s;
  rep(i,s.size()){
    int tmp=s[i]-'a';
    ans[tmp]++;
  }
  rep(i,n-1){
    string st;
    multiset<int> t;
    cin >> st;
    rep(j,st.size()){
      int ttt=st[j]-'a';
      t.insert(ttt);
    }
    rep(j,26){
      ans[j]=min((int)t.count(j),ans[j]);
    }
  }
  rep(i,26){
    rep(j,ans[i]){
      char c='a'+i;
      cout << c;
    }

  }
        
  
  return 0;
    

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <set>
#include <utility>
#include <climits>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>

#define ll long long
#define ull unsigned long long
using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	bool c[n + 1]{};
	for (int i = 0, d; i < k; ++i) {
		cin >> d;
		for (int j = 0, a; j < d; ++j) {
			cin >> a;
			c[a] = 1;
		}
	}
	
	ll res = 0;
	for (int i = 1; i <= n; ++i) {
		if (!c[i]) ++res;
	}
	
	cout << res;
}

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

int main(){
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int res = 0;

  for (int an = 0; an <= a; ++an){
    for (int bn = 0; bn <= b; ++bn){
      for (int cn = 0; cn <= c; ++cn){
        if (500 * an + 100 * bn + 50 * cn == x){
          ++res;
          break;
        }
      }
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 256
object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val coins = List(1,5,10,50, 100, 500)
  println(
    if (readLine.trim.split(' ').map(_.toInt).zip(coins).map{case (a, b) ⇒ a * b}.sum >= 1000 ) 1 else 0
  )
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}
/*
 */


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

int main(){
    int a,b;
    while(true){
        scanf("%d %d",&a,&b);
        if(a==0&&b==0)return 0;
        for(int i=0;i<a;i++){
            for(int j=0;j<b;j++){
                if(i==0||i==a-1||j==0||j==b-1){
                    printf("#");
                }
                else{
                    printf(".");
                }
            }
            printf("\n");
        }
        
        printf("\n");
    }
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define vii vector<ll> 
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int MOD = 1e9 + 7, N = 1e4 + 3;

int main(){
    fast;
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans = 0;
    for(int i = a; i <= b; ++i)
        if(i%c == 0) ++ans;
    cout << ans;
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}

Measured memory_bytes: 3792
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
using namespace std;

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

	if ((b-a) == (c-b)){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}

	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();

  vector<int> r(n);
  for (int i = 0, t = 0; i + 1 < n; i++) {
    if (s[i] == 'R') {
      t++;
      if (s[i + 1] == 'L') {
        r[i] += (t + 1) / 2;
        r[i + 1] += t / 2;
        t = 0;
      }
    }
  }
  for (int i = n - 1, t = 0; i - 1 >= 0; i--) {
    if (s[i] == 'L') {
      t++;
      if (s[i - 1] == 'R') {
        r[i] += (t + 1) / 2;
        r[i - 1] += t / 2;
        t = 0;
      }
    }
  }

  for (auto e : r) cout << e << ' ';
  cout << endl;
}


Measured memory_bytes: 1024
using System.Linq;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine();
            string ret = string.Empty;
            for (int i = 0; i < r.Length; i++)
            {
                if ((i+1) % 2 == 1)
                {
                    ret += r[i].ToString();
                }
            }
            Console.WriteLine(ret);
        }
        
    }
}

Measured memory_bytes: 32724
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi cost(n,1e18);
    vi h(n);
    ffor(i,n) cin >> h[i];
    cost[0] = 0;
    
    for(int i = 0; i < n; ++i)
    {
        if(i + 1 < n)
        {
            cost[i + 1] = min(cost[i + 1],cost[i] + abs(h[i + 1] - h[i]));
        }
        if(i + 2 < n)
        {
            cost[i + 2] = min(cost[i + 2],cost[i] + abs(h[i + 2] - h[i]));
        }
    }
    cout << cost[n - 1];
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
using namespace std;
vector<pair<int,int> > v[100005];
bool vis[100005];
int num[100005];
bool dfs(int x,int fill){
	if(vis[x]) return num[x]!=fill;
	vis[x]=true;
	num[x]=fill;
	for(int t=0;t<v[x].size();t++) if(dfs(v[x][t].first,fill+v[x][t].second)) return true;
	return false;
}
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int l,r,d;
		cin>>l>>r>>d;
		v[l].push_back(make_pair(r,d));
		v[r].push_back(make_pair(l,-d));
	}
	for(int i=1;i<=n;i++) if(!vis[i]&&dfs(i,0)){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	return 0;
	return 0;
}

Measured memory_bytes: 12032
#include<bits/stdc++.h>
int main()
{
    int s=0;
    long long n,x;
    scanf("%lld",&n);
    for(int i=sqrt(n);i>0;i--){
        if(n%i==0){
            x=n/i;
            break;
        }
    }
    while(x!=0){
        x/=10;
        s++;
    }
    printf("%d\n",s);
    return 0;
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = "";

        while ((line = br.readLine()) != null && !line.isEmpty()) {
            char[] str = line.toCharArray();
            char c;
            int i = 0, j = str.length - 1;
            while (i < j) {
                c = str[i];
                str[i] = str[j];
                str[j] = c;
                i++;
                j--;
            }
            System.out.println(str);
        }
    }
}

Measured memory_bytes: 16852
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
 
using namespace std;
 
int main()
{
	long long h,w;
	cin >> h >> w;
 
	long long ans=100000000009;
 
	for(int i=1;i<=h;i++)
	{
		long long a=i*w;
		long long b=(h-i)*(w/2);
		long long c=h*w-a-b;
 
		long long div=abs(a-b);
		if(div<abs(a-c))div=abs(a-c);
		if(div<abs(b-c))div=abs(b-c);
 
		if(ans>div)ans=div;
 
		b=w*((h-i)/2);
		c=h*w-a-b;
 
		div=abs(a-b);
		if(div<abs(a-c))div=abs(a-c);
		if(div<abs(b-c))div=abs(b-c);
 
		if(ans>div)ans=div;
 
	}
 
	for(int i=1;i<=w;i++)
	{
		long long a=i*h;
		long long b=(w-i)*(h/2);
		long long c=h*w-a-b;
 
		long long div=abs(a-b);
		if(div<abs(a-c))div=abs(a-c);
		if(div<abs(b-c))div=abs(b-c);
 
		if(ans>div)ans=div;
 
		b=h*((w-i)/2);
		c=h*w-a-b;
 
		div=abs(a-b);
		if(div<abs(a-c))div=abs(a-c);
		if(div<abs(b-c))div=abs(b-c);
 
		if(ans>div)ans=div;
 
	}
 
 
	cout << ans << endl;
 
	
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
#define fr(i,n) for(ll i=0;i<n;i++)

ll par[200010],ranki[200010]; 

void init(ll n){
  fr(i,n){
    par[i]=i;
    ranki[i]=0;
  }
}

ll find(ll x){
  if(par[x]==x) return x;
  else return par[x]=find(par[x]);
}
 
void unit(ll x,ll y){
  x=find(x);
  y=find(y);
  if(x==y) return;
  if(ranki[x]<ranki[y]) par[x]=y;
  else par[y]=x;
  if(ranki[x]==ranki[y]) ranki[x]++;
}
 
bool same(ll x,ll y){
  return find(x)==find(y);
}

int main(){
  ll h,w,x,y,gg[161000][2];
  bool vis[410][410];
  char s[410][410];
  cin>>h>>w;
  fr(i,h){
    fr(j,w) cin>>s[i][j];
  }
  init(h*w);
  fr(i,h*w){
    x=i/w;
    y=i%w;
    if(s[x][y]=='.'){
      if(y!=w-1 && s[x][y+1]=='#') unit(i,i+1);
      if(x!=h-1 && s[x+1][y]=='#') unit(i,i+w);
    }
    if(s[x][y]=='#'){
      if(y!=w-1 && s[x][y+1]=='.') unit(i,i+1);
      if(x!=h-1 && s[x+1][y]=='.') unit(i,i+w);
    }
  }
  fr(i,h*w){
    x=i/w;
    y=i%w;
    if(s[x][y]=='.'){
      gg[find(i)][0]++;
    }
    if(s[x][y]=='#'){
      gg[find(i)][1]++;
    }
  }
  ll res=0;
  fr(i,h*w) res+=gg[i][0]*gg[i][1];
  cout<<res<<endl;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

using ll = long long;
const ll mod = 100000000+7;
const ll MAX_N = 1000;

ll n,m;
string s,t;
ll a[MAX_N];

char p[17]={'C','O','D','E','F','E','S','T','I','V','A','L','2','0','1','6'};
int main(){
  cin>>s;
  int cnt=0;
  for(int i=0;i<s.size();i++){
    if(s[i]!=p[i])cnt++;
  }
  cout<<cnt<<endl;

}


Measured memory_bytes: 256
#!/usr/bin/perl

use strict;
use warnings;
use 5.010;

use Data::Dumper;
use POSIX qw(floor);

my @INPUT;
while (<>) {
    chomp;
    push @INPUT, $_;
}

my ($N, $P) = split " ", shift @INPUT;

my $n = $P;
my @f = factorization($n);
my %f;
for my $f (@f) {
    $f{$f}++;
}
my $ans = 1;

for my $d (keys %f) {
    my $num = $f{$d};
    my $times = floor($num / $N);
    $ans = $ans * ($d ** $times);
}

say $ans;

sub factorization {
    my $arg = shift;
    for my $i (2 .. (int(sqrt($arg)) + 1) ) {
        if ($arg % $i == 0) {
            return ($i, &factorization($arg / $i));
        }
    }
    return $arg;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define Rep(i, n) for (long long i = 0, i##_len = (n); i < i##_len; i++)
#define For(i, a, b) for (long long i = (a); i < b; i++)
typedef long long ll;

using namespace std;
int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N, 0);
    Rep(i, N)
    {
        cin >> A[i];
        A[i]--;
    }
    ll cur_town = 0;
    set<ll> hist{0};
    map<ll, ll> dict{{0, 0}}; //初期位置、移動回数0
    ll loop_num = 0;
    ll loop_start = 0;
    bool finished = false;
    For(i, 1, K + 1)
    {
        cur_town = A[cur_town];
        if (hist.find(cur_town) != hist.end())
        {
            loop_num = i - dict[cur_town];
            loop_start = dict[cur_town];
            finished = true;
            break;
        }
        dict[cur_town] = i; //位置、それまでの移動回数
        hist.insert(cur_town);
        if (finished)
            break;
    }
    ll rest = finished ? (K - loop_start) % loop_num : K;
    cur_town = 0;
    ll pre_town = 0, post_town = 0;
    // cout << "rest:" << rest << endl;
    // cout << "loopnum:" << loop_num << endl;
    // cout << "loopstart:" << loop_start << endl;
    For(i, 0, rest + loop_start)
    {
        cur_town = A[cur_town];
        if (i == rest + loop_start - 2)
            pre_town = cur_town + 1;
        // if (cur_town == 60213)
        //     cout << "found60214 at:" << i << endl;
    }
    post_town = A[cur_town] + 1;
    cur_town++;
    cout << cur_town << endl;
    // cout << "pre:" << pre_town << endl;
    // cout << "post:" << post_town << endl;
    return 0;
}

Measured memory_bytes: 22252
#include <cstdio>
#include <cstdlib>
#include <cmath>

#include <iostream>

#include <vector>
#include <algorithm>

int main(){
  int N,K;
  std::cin >> N >> K;
  int V[N];
  for(int i=0;i<N;i++){
    std::cin >> V[i];
  }
  /*
  if(K>=2*N){
    long long score = 0;
    for(int i=0;i<N;i++){
      if(V[i]>0) score += V[i];
    }
    std::cout << score << std::endl;
    return 0;
  }
  //*/
  const int M = std::min(K,N);
  int ans = 0;
  for(int k=1;k<=M;k++){
    int taken[k];
    const int rest = K - k;
    for(int l=0;l<=k;l++){
      for(int r=0;r<=k-l;r++){
	if(r==0 && l==0) continue;
	int count = 0;
	int score = 0;
	for(int ll=0;ll<l;ll++){
	  score += V[ll];
	  taken[count++] = V[ll];
	}
	for(int rr=N-1;rr>N-r-1;rr--){
 	  score += V[rr];
	  taken[count++] = V[rr];
	}
	std::sort(taken,taken+count,[](int a,int b){return a<b;});
	/*
	for(int i=0;i<count;i++){
	  printf(" %d",taken[i]);
	}
	*/
	for(int i=0;i<rest;i++){
	  if(i>=count) break;
	  if(taken[i]>=0) break;
	  score -= taken[i];
	}
	//printf(": %d %d %d %d %d\n",l,r,k,rest,score);
	ans = std::max(ans,score);
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long
map<char, int> m;
signed main() {
   int n,k;
   cin >> n >> k;
   vector<int> a(n);
   rep(i,n) cin >> a[i];
   sort(a.begin(),a.end(),greater<int>());
   if(k==0) {
       cout << a[0] << endl;
       return 0;
   }
   int l = 1;
   int r = a[0];
   int m = (l+r)/2;
    sort(a.begin(),a.end());
   while(l<=r) {
       bool f = true;
        int c = k;
        // cout << m << endl;
        rep(i,n) {
            c -= (int)ceil((double)a[i]/(double)m)-1;
            if(c<0) {
                f=false; 
                break;
            }
        }
        // cout << c << endl;
        if(f) {
            r = m-1;
            m = (l+r)/2;
        }else {
            l = m+1;
            m = (l+r)/2;
        }
        // cout << l<<" "<<r<<" "<<m <<" "<<f<< endl;
   }
   cout << l << endl;
  return 0; 
}



Measured memory_bytes: 4812
import math

def prime_number(j):
    if j == 1: return False
    
    for i in range(2,int(math.sqrt(j)) + 1):
        if j % i == 0:
            return False
    return True

x = int(input())
for j in range(x,10**6):
    if prime_number(j) and x <= j:
        print(j)
        break

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

public class ABC0123_A2v3 {
    private static void Main(string[] args) {
        var inputs = new List<string>();
        inputs = ReadStringList(5);

        ConvertInputs(inputs);
    }

    private static List<string> ReadStringList(int numberOfLines) {
        var stringList = new List<string>();

        for (int lineIndex = 0; lineIndex < numberOfLines; lineIndex++) {
            stringList.Add(Console.ReadLine().Trim());
        }

        return stringList;
    }

    public static void ConvertInputs(List<string> inputs) {
        var waitingTimes = inputs
            .Select(s => int.Parse(s))
            .OrderByDescending(n => (n + 9) % 10)
            .ToList();

        Solve(waitingTimes);
    }

    public static void Solve(List<int> waitingTimes) {
        var time = 0;

        for (int i = 0; i < waitingTimes.Count - 1; i++) {
            time += CalculateCeiling10(waitingTimes[i]);
        }
        time += waitingTimes[waitingTimes.Count - 1];

        OutputAnswer(time.ToString());
    }

    public static int CalculateCeiling10(int waitingTime) {
        if (waitingTime % 10 == 0)
            return waitingTime;

        return waitingTime += 10 - (waitingTime % 10);
    }

    public static void OutputAnswer(string text) {
        Console.WriteLine(text);
    }
}


Measured memory_bytes: 11348
N, A, B = map(int,input().split())
S = input()

count, rank = 0, 0
for s in S:
    if s == 'b':
        rank += 1

    if (s == 'a') and (count < A + B):
        count += 1
        print('Yes')
    elif (s == 'b') and (count < A + B) and (rank <= B):
        count += 1
        print('Yes')
    else:
        print('No')

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

void rot(string &s) { s = s.substr(1) + s.front(); }

int main() {
  string s, t;
  cin >> s >> t;

  for (int i = 0; i < s.length(); i++) {
    if (s == t) {
      cout << "Yes" << endl;
      return 0;
    }
    rot(s);
  }

  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<ll>>;
ll inf = pow(2,62);

int main(){
    ll a, b, c, x, y;
    ll ans = inf;
    cin >> a >> b >> c >> x >> y;
    for(int i = 0;i <= 2 * max(x, y);i++){
        ll sum = 0;
        if(x - i/2 <= 0 && y - i / 2 <= 0){
            sum = i * c;
        }
        else if (x - i/2 <= 0 && y - i / 2 > 0)
        {
            sum = i*c + b * (y - i / 2);
        }
        else if(x - i/2 > 0 && y - i / 2 <= 0){
            sum = i * c + a * (x - i / 2);
        }
        else{
        sum = i * c + a * (x - i / 2) + b * (y - i / 2);
        }
        ans = min(ans,sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int H, W;
char grid[1111][1111];
int cost[1111][1111];

int main()
{
    cin >> H >> W;

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> grid[i][j];
            cost[i][j] = inf;
        }
    }
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};

    queue<pair<int, pair<int, int>>> que;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (grid[i][j] == '#')
            {
                que.emplace(0, make_pair(i, j));
            }
        }
    }

    while (!que.empty())
    {
        auto p = que.front();
        que.pop();
        int y = p.second.first, x = p.second.second, cnt = p.first;
        if (cost[y][x] != inf)
            continue;
        cost[y][x] = cnt;
        grid[y][x] = '#';
        cnt++;
        for (int i = 0; i < 4; i++)
        {
            int ny = y + dy[i], nx = x + dx[i];
            if (ny < 0 || ny >= H)
                continue;
            if (nx < 0 || nx >= W)
                continue;
            if (grid[ny][nx] == '#')
                continue;
            que.emplace(cnt, make_pair(ny, nx));
        }
    }

    int ans = 0;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            ans = max(cost[i][j], ans);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 17808
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
}

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

struct Edge {
    int a, b;
};

void show_result(vector<Edge> es) {
    cout << es.size() << endl;
    for (auto e : es) {
        cout << e.a << ' ' << e.b << endl;
    }
}

void odd_solve(int n) {
    vector<Edge> es;
    for (int i = 1; i < n; i++) {
        es.push_back(Edge {i, n});
    }
    int b[n];
    b[0] = 0;
    for (int i = 1; i < n; i++) {
        b[i] = b[i - 1] + i;
    }
    int rem[n];
    fill(rem, rem + n, b[n - 1] - n);
    for (int i = 1; i < n; i++) {
        int d = b[n - 1] - b[i] - rem[i];
        for (int j = i + 1; j < n; j++) {
            if (d != j) {
                rem[j] -= i;
                es.push_back(Edge {i, j});
            }
        }
    }
    show_result(es);
}

void even_solve(int n) {
    int a = n + 1;
    vector<Edge> es;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            if (j != a - i) {
                es.push_back(Edge {i, j});
            }
        }
    }
    show_result(es);
}

int main() {
    int n;
    cin >> n;
    if (n & 1) {
        odd_solve(n);
    } else {
        even_solve(n);
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define emb emplace_back

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

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

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

int main() {
  string s;
  cin >> s;
  int q;
  cin >> q;
  int rev = 0;
  string mae = "",usiro = "";
  rep(i,q) {
    int t;
    cin >> t;
    if(t == 1) {
      rev += 1;
    } else {
      int f;string c;
      cin >> f >> c;
      if(rev % 2 == 1) {
        if(f == 1) {
          usiro += c;
        } else {
          mae.insert(0,c);
        }
      } else {
        if(f == 1) {
          mae.insert(0,c);
        } else {
          usiro += c;
        }
      }
    }
  }
  s = mae + s + usiro;
  if (rev % 2 == 1) reverse(all(s));
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 1348
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <stdio.h>

using namespace std;

#define fo(i,n) for(int i=0; i<(int)n; i++)
#define rep(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define pii pair<int,int>

int n,m,c;
vector<int> e[110];
vector<int> w[110];
int best[110][110];

int main() {

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

	while (scanf("%d%d%d",&n,&m,&c) && n!=0) {
		for (int i=0; i<n; i++) e[i].clear();
		for (int i=0; i<n; i++) w[i].clear();
		for (int i=0; i<m; i++) {
			int a,b,t;
			scanf("%d%d%d",&a,&b,&t);
			a--; b--;
			e[a].push_back(b);
			w[a].push_back(t);
		}
		int lo = 0;
		int hi = n-1;
		while (lo<hi) {
			int mi = (lo+hi)>>1;
			for (int i=0; i<n; i++) for (int j=0; j<=mi; j++) best[i][j] = 1000000000;
			priority_queue<pair<pair<int,int>, int> > q;
			best[0][mi] = 0;
			q.push(make_pair(make_pair(0,mi),0));
			bool good = 0;
			while (!q.empty()) {
				int h = q.top().first.second;
				int p = q.top().second;
				int d = best[p][h];
				q.pop();
				//if (d<-q.top().first.first) continue;
				if (p==n-1) {
					good = 1;
					break;
				}
				for (int i=0; i<e[p].size(); i++) {
					int x = e[p][i];
					int t = w[p][i];
					
					if (best[x][h]>d+t && d+t<=c) {
						best[x][h] = d+t;
						q.push(make_pair(make_pair(-d-t,h),x));
					}
					if (h>0 && best[x][h-1]>d) {
						best[x][h-1] = d;
						q.push(make_pair(make_pair(-d,h-1),x));
					}
				}
			}
			if (good) {
				hi = mi;
			}
			else lo = mi+1;
		}
		cout<<lo<<endl;
	}

    return 0;

}

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

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

    int i;
    int A[21];
    for (i = 1; i <= N; i++) {
        scanf("%d", &A[i]);
    }

    int s = 0;
    int B;
    for (i = 0; i < N; i++) {
        scanf("%d", &B);
        s += B;
    }

    int C[21];
    for (i = 1; i < N; i++) {
        scanf("%d", &C[i]);
    }

    int cuisine = A[1];
    for (i = 2; i <= N; i++) {
        if (cuisine + 1 == A[i]) {
            s += C[cuisine];
        }
        cuisine = A[i];
    }
    printf("%d", s);
}

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

#define      ll     long long int

int main()
{
    int n, y, dosh, pach, ek;
    int s = 0;
    cin >> n >> y;
    int i, j, k;
    for (i = 0; i * 10000 <= y; i++) {
        for (j = 0; j * 5000 <= y; j++) {
            //cout << i << ' ' << j << '\n';
            k = (y - (i * 10000) - (j * 5000)) / 1000;
            if (k >= 0 && i + j + k == n) {
                cout << i << ' ' << j << ' ' << k << '\n';
                return 0;
            }
        }
    }
    //cout << i << ' ' << j << '\n';
    cout << "-1 -1 -1\n";
    return 0;
}


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

ll solve() {
    ll H, W;
    cin >> H >> W;
    vector<string> S(H);
    for ( int i = 0; i < H; i++ ) {
        cin >> S[i];
        for ( int j = 0; j < W; j++ ) {
            if ( (i + j) & 1 ) {
                S[i][j] = S[i][j] == '#' ? '.' : '#';
            }
        }
    }
    vector<int> dh = {0, 1, 0, -1}, dw = {1, 0, -1, 0};
    
    vector<vector<int>> t(H, vector<int>(W, -1));
    function<void(int,int,int)> dfs = [&](int vh, int vw, int ty) {
        if ( t[vh][vw] >= 0 ) return;
        t[vh][vw] = ty;
        for ( int ii = 0; ii < 4; ii++ ) {
            int h = vh + dh[ii];
            int w = vw + dw[ii];
            if ( h < 0 || h >= H || w < 0 || w >= W ) continue;
            if ( S[vh][vw] == S[h][w] ) {
                dfs(h, w, ty);
            }
        }
    };

    int c = 0;
    for ( int h = 0; h < H; h++ ) {
        for ( int w = 0; w < W; w++ ) {
            if ( t[h][w] == -1 ) {
                dfs(h, w, c);
                c++;
            }
        }
    }

    for ( int i = 0; i < H; i++ ) {
        for ( int j = 0; j < W; j++ ) {
            if ( (i + j) & 1 ) {
                S[i][j] = S[i][j] == '#' ? '.' : '#';
            }
        }
    }
    vector<int> num_w(c), num_b(c);
    for ( int h = 0; h < H; h++ ) {
        for ( int w = 0; w < W; w++ ) {
            ll ct = t[h][w];
            if ( S[h][w] == '#' ) {
                num_b[ct]++;
            } else {
                num_w[ct]++;
            }
        }
    }
    
    ll ans = 0;
    for ( int i = 0; i < c; i++ ) {
        ans += (ll)num_b[i] * (ll)num_w[i];
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 21120
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

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

typedef long long ll;

int SURP = 1000000007;

class UnionFindTree{
private:
	vector<int> par;
	vector<int> rank;

public:
	UnionFindTree(){
		UnionFindTree(100000);
	};

	UnionFindTree(int N){
		par.resize(N);
		rank.resize(N);
		for (int i = 0; i < N; ++i)
		{
			par[i] = i;
			rank[i] = 0;
		}
	}

	int root(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = root(par[x]);
		}
	}

	void connect(int x, int y){
		int root_x = root(x);
		int root_y = root(y);
		if(root_x == root_y) return;
		if(rank[root_x] < rank[root_y]){
			par[root_x] = root_y;
		}else{
			par[root_y] = root_x;
			if(rank[root_x] == rank[root_y]) rank[root_x]++;
		}
	}

	bool same(int x, int y){
		return root(x) == root(y);
	}
};

int main(){
	UnionFindTree t1;
	UnionFindTree t2;
	map<pair<int,int>,int> pnum;

	int N,K,L;
	cin >> N >> K >> L;

	t1 = UnionFindTree(N);
	t2 = UnionFindTree(N);

	REP(i,K){
		int pi,qi;
		cin >> pi >> qi;
		t1.connect(pi-1,qi-1);
	}

	REP(i,L){
		int pi,qi;
		cin >> pi >> qi;
		t2.connect(pi-1,qi-1);
	}

	REP(i,N){
		pnum[make_pair(t1.root(i),t2.root(i))]++;
	}

	REP(i,N-1){
		cout << pnum[make_pair(t1.root(i),t2.root(i))] << " ";
	}
	cout << pnum[make_pair(t1.root(N-1),t2.root(N-1))] << endl;

	cout << endl;
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define FOR(i, n, m) for(ll i = (ll)n; i < (ll)(m); i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define PRINT(x) std::cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dx[8] = {0,1,0,-1, 1, -1, 1, -1}, dy[8] = {1,0,-1,0,1,1,-1,-1};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{
  ll N, M, K;
  cin >> N >> M >> K;
  
  vector<ll> A(N);
  REP(i, N) { 
      cin >> A[i];
  }
  
  vector<ll> B(M);
  REP(i, M) { 
      cin >> B[i];
  }

  vector<ll> sumA(N+1);
  vector<ll> sumB(M+1);
  sumA[0] = 0;
  sumB[0] = 0;
  REP(i, N) sumA[i+1] = A[i] + sumA[i]; 
  REP(i, M) sumB[i+1] = B[i] + sumB[i]; 
  ll ans = 0;
  ll j = M;
  REP(i, N+1) {
    if (sumA[i] > K) break;
    while(sumB[j] + sumA[i] > K) {
      j--;
    }
    ans = max(ans, i+j);
  }
  PRINT(ans);
  return 0;
} 


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

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

    if (rate < 1200) {
        cout << "ABC";
    } else if (rate >= 1200 && rate < 2800) {
        cout << "ARC";
    } else {
        cout << "AGC";
    }

    cout << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int ans;
  ans = n - 7;
  if(ans%10 == 0){
    cout << "Yes" << endl;
  } else if( n>=700 && n<800){
    cout << "Yes" << endl;
  }else if(n>=170 && n<180) cout << "Yes" << endl;
 else if(n>=270 && n<280) cout << "Yes" << endl;
 else if(n>=370 && n<380) cout << "Yes" << endl;
 else if(n>=470 && n<480) cout << "Yes" << endl;
 else if(n>=570 && n<580) cout << "Yes" << endl;
 else if(n>=670 && n<680) cout << "Yes" << endl;
 else if(n>=870 && n<880) cout << "Yes" << endl;
 else if(n>=970 && n<980) cout << "Yes" << endl;
 else{
   cout << "No" << endl;
 }
}


Measured memory_bytes: 3620
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	h := scanInt()
	w := scanInt()

	a := make([]string, h)
	cnt := make(map[string]int, 0)

	for i := 0; i < h; i++ {
		a[i] = scanText()
		for j := 0; j < w; j++ {
			cnt[string(a[i][j])]++
		}
	}

	chk2 := 0
	chk1 := 0

	if h%2==1 {
		chk2+=w/2
	}

	if w%2==1 {
		chk2+=h/2
	}

	if h%2==1&&w%2==1 {
		chk1=1
	}

	for _, e := range cnt {
		if e%4 != 0 {
			if e%2==0 {
				chk2--
			} else {
				chk1--
			}
		}
	}

	if chk2<0||chk1<0 {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<complex>
#include<cmath>
using namespace std;
typedef complex<double> comp;

double crs_prod(comp a, comp b) { return (conj(a)*b).imag(); }

double c1, c2;
double area = 0;
comp z[20];
int n = 0;
int main(){
	while(~scanf("%lf,%lf", &c1, &c2)){
		z[n] = comp(c1, c2);
		n++;
	}
	for(int i=1; i<n-1; i++){
		area += crs_prod(z[i]-z[0], z[i+1]-z[0])/2;
	}
	printf("%f",area>0 ? area : -area);
	return 0;
}

Measured memory_bytes: 1240
#include <stdio.h>
#include <cmath>

using namespace std;

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  double ans = 0.0;
  for (int i = 1; i <= n; i++) {
    if (i >= k) {
      ans += 1.0 / n;
    } else {
      ans += pow(0.5, ceil(log2((double)k/i))) / n;
    }
  }

  printf("%.12f", ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll N,A,B;
    cin >> N >> A >> B;
    if(N==1){
        if(A==B){
            printf("1\n");
        }
        else{
            printf("0\n");
        }
    }
    else if( A > B ){
        printf("0\n");
    }
    else{
        printf("%lld\n", (N-2)*(B-A)+1);
    }

}


Measured memory_bytes: 3692
# -*- coding: utf-8 -*-
import sys
from itertools import product
from collections import Counter, defaultdict
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

date = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
S = input()
j = date.index(S)
for i in range(1, 8):
    if date[(i+j)%7] == "SUN":
        print(i)

Measured memory_bytes: 38256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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; }
template<class T> void printv(vector<T> v){ for (T t : v) {cout << t << " " ;} cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

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

int gcd(int a, int b) {
    if (b == 0)
        return a;

    return gcd(b, a % b);
}

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

    int N, M;
    cin >> N >> M;

    int ans = 1;
    for (int a=1; a*a<=M; a++){
        if (M % a != 0) continue;
        int b = M/a;
        if ((ll)a*N <= M) ans = max(ans,a);
        if ((ll)b*N <= M) ans = max(ans,b);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
int d,w;
int main(){
	while(scanf(" %d%d",&d,&w)==2&&w!=0&&d!=0){
		int tbl[12][12]={};
		int ans=0;
		for(int i=1;i<=d;i++){	//d代表行数 
			for(int j=1;j<=w;j++){	//w代表列数 
				cin>>tbl[i][j];	//x,y仍然是，x代表列数，y代表行数,横坐标写在后面，纵坐标写在前面 
			}
		}
		//枚举所有矩形，每次枚举记录边界的最小值和区域的最大值，不满足则break，满足就记录面积
		//取max，至遍历完，关键在于边界的遍历注意坐标。
		//不妨每次枚举左上端点以及深度和宽度，则决定了一个矩形
		for(int i=1;i<=d-2;i++){	//(j,i)为枚举的左上端点 
			for(int j=1;j<=w-2;j++){
				for(int deep=3;deep+i-1<=d;deep++){	//枚举深度和宽度 
					for(int wid=3;wid+j-1<=w;wid++){
						//到此处矩形已经决定了
						//遍历边界
						int y,x;
						int outmii=100,inmiv=-1;
						for(x=0;x<wid;x++)	//水平向右遍历
						{
							if(tbl[i][x+j]<outmii) outmii=tbl[i][x+j];
							if(tbl[i+deep-1][x+j]<outmii) outmii=tbl[i+deep-1][x+j];
						}
						for(y=0;y<deep;y++)
						{
							if(tbl[y+i][j]<outmii) outmii = tbl[y+i][j];
							if(tbl[y+i][j+wid-1]<outmii) outmii = tbl[y+i][j+wid-1];
						}
						
						//遍历区域
						int sum=0;
						for(int x=1;x<wid-1;x++){
							for(int y=1;y<deep-1;y++){
								if(tbl[y+i][x+j]>inmiv) inmiv = tbl[y+i][x+j];
								sum+=outmii-tbl[y+i][x+j];
							}
						}
						
					//	if(i==1&&j==1&&wid==5&&deep==3){
					//		cout<<sum<<" "<<outmii<<" "<<inmiv<<endl;
					//	}
						
						if(inmiv >= outmii) continue;
						else{
							ans=max(ans,sum);
						} 
					}
				}
			}
		} 
		cout<<ans<<endl;
	}
} 

/*
3 3
2 3 2
2 1 2
2 3 1
3 5
3 3 4 3 3
3 1 0 2 3
3 3 4 3 2
7 7
1 1 1 1 1 0 0
1 0 0 0 1 0 0
1 0 1 1 1 1 1
1 0 1 0 1 0 1
1 1 1 1 1 0 1
0 0 1 0 0 0 1
0 0 1 1 1 1 1
6 6
1 1 1 1 2 2
1 0 0 2 0 2
1 0 0 2 0 2
3 3 3 9 9 9
3 0 0 9 0 9
3 3 3 9 9 9
0 0
*/


Measured memory_bytes: 3256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, n) for(long long (i) = (a); (i) < (n); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define GET(v) cin >> (v)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;

ll n;
ll ans = 0;

ll xyz(ll x, bool a, bool b, bool c) {
    if(x > n) {
        return 0;
    }
    else if(a && b && c) {
        ans++;
    }
    
    xyz(x * 10 + 3, true, b, c);
    xyz(x * 10 + 5, a, true, c);
    xyz(x * 10 + 7, a, b, true);
    return 0;
}

int main()
{
    GET(n);
    
    xyz(0, false, false, false);
    
    SHOW(ans);
    return 0;
}


Measured memory_bytes: 256
import sys


H, W, M = map(int, input().split())
bomb =[]
for I in range(M):
    bom = tuple(map(lambda x: int(x) - 1, input().split()))
    bomb.append(bom)
X = [0] * H  # X:各行の爆破対象の個数
Y = [0] * W  # Y:各列の爆破対象の個数
for h, w in bomb:
    X[h] += 1
    Y[w] += 1
maxX = max(X)
maxY = max(Y)

R = [h for h, x in enumerate(X) if x == maxX]  # R:爆破対象の数が最大となる行の番号
C = [w for w, y in enumerate(Y) if y == maxY]  # C:爆破対象の数が最大となる列の番号

bomb = set(bomb)
for r in R:
    for c in C:
        if (r, c) not in bomb:
            # (r, c)に爆破対象が存在しないとき, maxX + maxY が答えとなることが確定するため, 
            # 即座に探索を終了する. これによりループの回数は最大でもM+1回となる.
            print(maxX + maxY)
            exit()
print(maxX + maxY - 1)

Measured memory_bytes: 90332
int main(){
  int A,B,M,c,x,y;
  int a[100000],b[100000];
  int i,min,sum,mina,minb;
  scanf("%d %d %d",&A,&B,&M);
  for(i=0;i<A;i++){
    scanf("%d",&a[i]);
    if(i==0 || a[i]<mina) mina=a[i];
  }
  for(i=0;i<B;i++){
    scanf("%d",&b[i]);
    if(i==0 || b[i]<minb) minb=b[i];
  }
  min=mina+minb;
  for(i=0;i<M;i++){
    scanf("%d %d %d",&x,&y,&c);
    sum=a[x-1]+b[y-1]-c;
    if(sum<min) min=sum;
  }
  printf("%d",min);
  return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		while(true){
			int w = in.nextInt();
			if(w == -1)break;
			int S = 0;
			if(w <= 10){
				S = 1150;
			}else if(w <= 20){
				S = 1150 + (w - 10) * 125;
			}else if(w <= 30){
				S = 1150 + 10 * 125 + (w - 20) * 140;
			}else{
				S = 1150 + 10 * 125 + 10 * 140 +(w - 30) * 160;
			}
			S = 4280 - S;
			System.out.println(S);
		}
	}
}

Measured memory_bytes: 18548
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(int i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(c, b / a) << endl;
	return 0;
}
/* --------------------------------------- */


Measured memory_bytes: 256
using System;

    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string a = Console.ReadLine();
            string b = Console.ReadLine();
            string c = Console.ReadLine();
        int count = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] != b[i])
            {
                if (a[i] != c[i])
                {
                    if (b[i] != c[i])
                        count = count + 2;
                    else
                        count++;
                }
                else
                    count++;
            }
            else if (a[i] != c[i])
                count++;
        }
        Console.WriteLine(count);
    }
    }



Measured memory_bytes: 13140
#include <stdio.h>

/* prototype declaration */
int arePallarel(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4);

int main(int argc, const char *argv[])
{
	int i, cnt;
	double x1, y1, x2, y2, x3, y3, x4, y4;

	scanf("%d", &cnt);

	for(i=0; i<cnt; i++){	
		scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4); 
		if(arePallarel(x1, y1, x2, y2, x3, y3, x4, y4)) printf("YES\n");
		else printf("NO\n");
	}	
	return 0;
}

int arePallarel(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
{
	double ax = x1-x2, ay = y1-y2, bx = x3-x4, by = y3-y4;
 	if(ax*by-ay*bx != 0) return 0;
	return 1;	
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int arr[n]={0};
	int arr1[n-1];
	for(int i=0;i<n-1;i++){
		cin>>arr1[i];
		arr[arr1[i]-1]++;
	}
	for(int i=0;i<n;i++)
		cout << arr[i] << endl;
}

Measured memory_bytes: 5156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


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

	
	int N;
	cin >> N;

	int kotae = 0;
	rep(i, N) {
		int L, R;
		cin >> L >> R;
		kotae += R - L + 1;

	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256