akhauriyash/Code-Regression huggingface dataset:
import kotlin.math.*
import java.util.*

fun main(args: Array<String>) {
  var (a, b, c, d) = readLine()!!.split(' ').map(String::toInt)
  while (true) {
    c -= b
    if (c <= 0) {
      println("Yes")
      break
    }
    a -= d
    if (a <= 0) {
      println("No")
      break
    }
  }
}


Measured memory_bytes: 36316
Q = int(input())
Ans = ""
for i in range(Q):
    A, B = map(int, input().split())
    A, B = min(A, B), max(A, B)
    if A == B or A + 1 == B: Ans += str(2 * (A - 1)) + "\n"
    else:
        limit = int(pow(A * B, 0.5))
        if limit ** 2 == A * B: limit -= 1
        if limit * (limit + 1) >= A * B: Ans += str(2 * (limit - 1)) + "\n"
        else:Ans += str(2 * limit - 1) + "\n"

print(Ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    int sum = a1 + a2 + a3;
    if (sum >= 22) {
        puts("bust");
    }else {
        puts("win");
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 目標値K
        int K = sc.nextInt();
        // 範囲A,B
        int A = sc.nextInt();       
        int B = sc.nextInt();

        int WariFlag=0;

        if( K>B){
        }else{
            for(int i=A;i<=B&&WariFlag==0;i++){
                if(i%K==0){
                   WariFlag=1;
                }
            }
        }
        if(WariFlag==0){
            System.out.println("NG");
        }else{
            System.out.println("OK");
        }

        }
}


Measured memory_bytes: 27072
#include <stdio.h>

int main(){
  int a,b,c,i,x;
  x=0;
  scanf("%d %d %d",&a,&b,&c);
  for(i = a;i <= b;i++){
    if(c%i==0){
      x=x+1;
    }
  }
  printf("%d\n",x);
  
  return 0;
}

Measured memory_bytes: 596
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;



public class Main {

	public static void main(String[] args) {

		Solve s= new Solve();
		s.solve();

	}
}


class Solve{


	 public void solve() {
		 Scanner sc = new Scanner(System.in) ;
		 int N = sc.nextInt();
		 
		 
		 System.out.println(180*(N-2));

		
	 }
}

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

int main(){
  int n;
  cin>>n;
  int num=100005;
  vector<int> v(num, 0);
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    v[x]++;
  }
  int cnt=0;
  for(int i=1;i<=100000;i++){
    cnt=max(cnt,v[i-1]+v[i]+v[i+1]);
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,mod,dp[5555][5555],arr[5555],x,y,ans;
void add(int &x,int y)
{
	x+=y;
	if (x>=mod) x-=mod;
}
int main()
{
	scanf("%d%d",&n,&mod);
	if (n%2==0)
	{
		x=n/2;
		y=n/2-1;
	}
	else
	{
		x=n/2+1;
		y=n/2;
	}
	for (int i=1;i<=x;i++) 
	{
		for (int j=1;j<=i;j++) arr[j]++;
	}
	for (int i=n-y+1;i<=n;i++)
	{
		for (int j=1;j<=i;j++) arr[j]--;
	}
	for (int i=2;i<=n;i++) arr[i]=-arr[i]+1;
	dp[1][0]=1;
	for (int i=2;i<=n;i++)
	{
		for (int j=0;j<=n;j++)
		{
			dp[i][j]=dp[i-1][j];
			if (j>=arr[i]) add(dp[i][j],dp[i][j-arr[i]]);
		}
	}
	for (int i=0;i<n;i++)
	{
		add(ans,1ll*(n-i)*dp[n][i]%mod);
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  
  int N;
  cin >> N;
  
  int count = 0;
  
  for (int i = 1; i <= N; i++) {
    if (1 <= i && i < 10) count++;
    if (100 <= i && i < 1000) count++;
    if (10000 <= i && i < 100000) count++;
  }
  
  cout << count << endl;
  
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
int sx, sy, tx,ty;

string solve(){
    string ret="", tmp="";

    int diffx = tx-sx;
    int diffy = ty-sy;

    //1stloop
    ret += string(abs(diffy), (diffy>0)?'U':'D');
    tmp += string(abs(diffy), (diffy>0)?'D':'U');

    ret += string(abs(diffx), (diffx>0)?'R':'L');
    tmp += string(abs(diffx), (diffx>0)?'L':'R');

    ret += tmp;
    tmp="";

    //2ndloop
    ret += (diffx>0)?'L':'R';
    tmp += (diffx>0)?'R':'L';

    ret += string(abs(diffy)+1, (diffy>0)?'U':'D');
    tmp += string(abs(diffy)+1, (diffy>0)?'D':'U');

    ret += string(abs(diffx)+1, (diffx>0)?'R':'L');
    tmp += string(abs(diffx)+1, (diffx>0)?'L':'R');

    ret += (diffy>0)?'D':'U';
    tmp += (diffy>0)?'U':'D';

    ret += tmp;
    return ret;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>sx>>sy>>tx>>ty;
    //制約 sx<tx, sy<ty
    //なので、sx==tx || sy==ty　はない
    string ans = solve();

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n, x) for (int i = x; i < n; i++)
#define IN(a, x, b) (a <= x && x < b)
const long long INF = 1e18;
const long double PI = acos(-1.0L);

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

Measured memory_bytes: 3620
N=int(input())
alist=list(map(int,input().split()))
#print(alist)

slist=[0]
xlist=[0]
for i in range(N):
  slist.append(slist[-1]+alist[i])
  xlist.append(xlist[-1]^alist[i])
#print(slist)
#print(xlist)

ans_list=[0]*N
l,r=1,1
while(r<N):
  #check [l,r+1] is valid
  sum_lr=slist[r+1]-slist[l-1]
  xor_lr=xlist[r+1]^xlist[l-1]
  #print(l,r,sum_lr,xor_lr)
  if sum_lr==xor_lr:
    r+=1
  else:
    #print(l-1,r-1)
    ans_list[l-1]=r-1
    l+=1
#print(l-1,r-1)

for i in range(l-1,N):
  ans_list[i]=r-1
#print(ans_list)

answer=0
for i in range(N):
  answer+=ans_list[i]+1-i
  
print(answer)

Measured memory_bytes: 37312
from itertools import accumulate
from collections import defaultdict

N, T = map(int, input().split())
A = [int(x) for x in input().split()]

B = [x for x in accumulate(A[::-1], max)][::-1]
c = defaultdict(int)
for i in range(N - 1):
    c[B[i] - A[i]] += 1
print(c[max(c)])

Measured memory_bytes: 21720
#include <bits/stdc++.h>
typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

bool is_prime(ll N)
{
    if (N < 2)
        return false;
    for (ll i = 2; i * i <= N; ++i)
    {
        if (N % i == 0)
            return false;
    }
    return true;
}
vector<pair<ll, ll>> soinsubunkai(ll N)
{
    vector<pair<ll, ll>> tmp;
    ll num = N;
    for (ll i = 2; i * i <= N; ++i)
    {
        if (N % i == 0)
        {
            ll j = N / i;
            if (is_prime(i))
            {
                ll a = 1;
                while (num % i == 0)
                {
                    a++;
                    num /= i;
                }
                tmp.push_back({i, a});
            }
            if (is_prime(j))
            {
                ll a = 1;
                while (num % j == 0)
                {
                    a++;
                    num /= j;
                }
                tmp.push_back({j, a});
            }
        }
    }
    return tmp;
}

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    vector<pair<ll, ll>> v = soinsubunkai(__gcd(a, b));
    if (v.size() == 0 && __gcd(a, b) != 1)
        v.push_back({__gcd(a, b), 1});
    cout << v.size() + 1 << endl;
}

Measured memory_bytes: 3608
integer N
integer A,B,C,D
read*,N
A=N/1000
N=N-A*1000
B=N/100
N=N-B*100
C=N/10
N=N-C*10
D=N
if(A+B+C+D==7)then
  print"(i0,A,i0,A,i0,A,i0,A)",A,"+",B,"+",C,"+",D,"=7"
  stop
end if
if(A+B+C-D==7)then
  print"(i0,A,i0,A,i0,A,i0,A)",A,"+",B,"+",C,"-",D,"=7"
  stop
end if
if(A+B-C+D==7)then
  print"(i0,A,i0,A,i0,A,i0,A)",A,"+",B,"-",C,"+",D,"=7"
  stop
end if
if(A+B-C-D==7)then
  print"(i0,A,i0,A,i0,A,i0,A)",A,"+",B,"-",C,"-",D,"=7"
  stop
end if
if(A-B+C+D==7)then
  print"(i0,A,i0,A,i0,A,i0,A)",A,"-",B,"+",C,"+",D,"=7"
  stop
end if
if(A-B+C-D==7)then
  print"(i0,A,i0,A,i0,A,i0,A)",A,"-",B,"+",C,"-",D,"=7"
  stop
end if
if(A-B-C+D==7)then
  print"(i0,A,i0,A,i0,A,i0,A)",A,"-",B,"-",C,"+",D,"=7"
  stop
end if
if(A-B-C-D==7)then
  print"(i0,A,i0,A,i0,A,i0,A)",A,"-",B,"-",C,"-",D,"=7"
  stop
end if
end

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main()
{
    double a, b, C;
    cin >> a >> b >> C;
    double rad = C * acos(-1) / 180;
    double h = b * sin(rad);
    double s = a * h / 2;
    double c = sqrt(pow(a, 2) + pow(b, 2) - 2*a*b*cos(rad));
    printf("%f\n", s);
    printf("%f\n", a+b+c);
    printf("%f\n", h);
    return 0;
}


Measured memory_bytes: 3428
#include<iostream>
#include<queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];   //頂点からの距離を格納するための配列

void bfs(int s) {
    queue<int> q;
    q.push(s);
    for ( int i = 0; i < n; i++ ) d[i] = INFTY;
    d[s] = 0;
    int u;
    while ( !q.empty() ) {
        u = q.front(); q.pop();   //front:キューから取り出し、pop:キューから削除
        for ( int v = 0; v < n; v++ ) {
            if ( M[u][v] == 0 ) continue;   //頂点同士が隣接しているか確認
            if ( d[v] != INFTY ) continue;   //頂点を訪れたか確認
            d[v] = d[u] + 1;   //始点からの距離を格納
            q.push(v);   //次に調査する頂点をキューに追加
        }
    }
    for ( int i = 0; i < n; i++ ) {
        cout << i+1 << " " << ( (d[i] == INFTY) ? (-1) : d[i] ) << endl;
    }
}

int main() {
    int u, k, v;   //u:頂点番号、k:uの出次数、v:隣接する頂点番号
    
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        for ( int j = 0; j < n; j++ ) M[i][j] = 0;
    }
    
    //隣接する頂点のリストを作成
    for ( int i = 0; i < n; i++ ) {
        cin >> u >> k;
        u--;
        for ( int j = 0; j < k; j++ ) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    
    bfs(0);
    
    return 0;
}


Measured memory_bytes: 3136
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    char A[1000],B[1000];
    int len1,len2;
    scanf("%s %s",A,B);
    len1=strlen(A);
    len2=strlen(B);
    if(len1>len2)
        printf("GREATER");
    else if(len1<len2)
        printf("LESS");
    else if(len1=len2)
    {
        for(int i=0; i<=len1; i++)
        {
            if(A[i]>B[i])
            {
                printf("GREATER");
                goto loop;
            }
            else if(A[i]<B[i])
            {   printf("LESS");
                goto acm;
            }
            if(A[i]==B[i])
                continue;
         }
        printf("EQUAL");
     }
    acm:
    loop:
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[2200][3200],_prev[2200][3200],n,m,s;
int main(){
	while(true){
		cin>>n>>s>>m;if(n==0)return 0;n*=n;
		for(int i=0;i<2200;i++){fill(dp[i],dp[i]+3180,0);fill(_prev[i],_prev[i]+3180,0);}
		for(int i=0;i<=s;i++)_prev[i][0]=1;
		for(int i=0;i<n;i++){
			for(int j=1;j<=s;j++){
				for(int k=j;k<=m;k++){
					dp[j][k]+=_prev[j-1][k-j];dp[j][k]%=100000;
				}
			}
			for(int j=0;j<=s;j++){
				for(int k=0;k<=m;k++){
					_prev[j][k]=dp[j][k];dp[j][k]=0;
				}
			}
			for(int j=1;j<=s;j++){
				for(int k=1;k<=m;k++){
					_prev[j][k]+=_prev[j-1][k];
				}
			}
		}
		cout<<_prev[s][m]%100000<<endl;
	}
}

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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int l,r,d;cin>>l>>r>>d;
  int ans=0;
  for(int i=l;i<=r;i++){
    if(i%d==0)ans++;
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<set>
using namespace std;
int main(){
  int n,i,cou=0;
  string x,y,b="insert",c="find";
  set<string> a;
  cin>>n;
  int ans[n];
  for(i=0;i<n;i++){
    cin>>x;
    if(x==b){
      cin>>y;
      a.insert(y);
    }
    if(x==c){
      cin>>y;
      if(a.find(y)!=a.end()){
	printf("yes\n");
      }
      else printf("no\n");
    }
  }
  return(0);
}

Measured memory_bytes: 32556
#include<stdio.h>
 int main(void)
 {
     int D,N,i,j=0;
 
     scanf("%d%d",&D,&N);
 
     if(D==0){
       for(i=1;i<=10000;i++){
         if(i%100!=0) j++;
         if(j==N){
           printf("%d\n",i);
           return 0;
         }
       }
     }
     if(D==1){
       for(i=0;i<=10000;i++){
         if(i%100!=0) j++;
         if(j==N){
           printf("%d\n",i*100);
           return 0;
         }
       }
     }
 
     if(D==2){
       for(i=1;i<=10000;i++){
         if(i%100!=0) j++;
         if(j==N){
           printf("%d\n",i*10000);
           return 0;
         }
       }
     }
 
 }

Measured memory_bytes: 1728
def man(a,b,c,d):
  return abs(a-c)+abs(b-d)
n=int(input())
li = [[0,0,0]]+[list(map(int,input().split())) for i in range(n)]
for i in range(1,n+1):
  if man(li[i][1],li[i][2],li[i-1][1],li[i-1][2])<= li[i][0]-li[i-1][0] and (li[i][0]-li[i-1][0]-man(li[i][1],li[i][2],li[i-1][1],li[i-1][2]))%2==0:
    continue
  else:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 28068
#include<bits/stdc++.h>
using namespace std;
      
int main(){
  int K,sum=0,ans=0;
  cin >> K;
  
  for(int a=1; a<=K ; a++){
    for(int b=1; b<=K ; b++){
      for(int c=1; c<=K ; c++){
        
        ans = gcd(a,gcd(b,c));
        
        sum += ans;}
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3676
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let a: usize = sc.read();
    let x = sc.vec(n);
    let mut dp = vec![vec![vec![0; a*n+1]; n+1]; n+1];
    dp[0][0][0] = 1;
    for i in 0..n {
        for j in 0..n {
            for k in 0..a*n+1 {
                dp[i+1][j][k] += dp[i][j][k];

                if k >= x[i] {
                    dp[i+1][j+1][k] += dp[i][j][k-x[i]]
                }
            }
        }
    }

    let mut ans = 0u64;
    for j in 1..n+1 {
        ans += dp[n][j][j*a];
    }
    println!("{}", ans);

}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 67836
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> P;
const int INF = 1e15;

signed main(){
    int n;
    cin >> n;
    vector<P> a(n), b(n);
    for(int i = 0; i < n; i++){
        int l, r;
        cin >> l >> r;
        a[i] = {l, i};
        b[i] = {r, i};
    } 
    sort(a.rbegin(), a.rend());
    sort(b.begin(), b.end());
    int ans = 0;
    int now = 0;
    vector<bool> used(n);
    int ita = 0, itb = 0;
    for(int i = 0; i < n; i++){
        if(i % 2 == 0){
            while(ita < n && used[a[ita].second]) ita++;
        }else{
            while(itb < n && used[b[itb].second]) itb++;
        }
        if(ita >= n || itb >= n) break;
        if(i % 2 == 0){
            now += 2 * a[ita].first;
            used[a[ita].second] = true;
            ans = max(ans, now);
        }else{
            now -= 2 * b[itb].first;
            used[b[itb].second] = true;
            ans = max(ans, now);
        }
    }
    for(int i = 0; i < n; i++) used[i] = false;
    ita = 0, itb = 0;
    now = 0;
    for(int i = 0; i < n; i++){
        if(i % 2){
            while(ita < n && used[a[ita].second]) ita++;
        }else{
            while(itb < n && used[b[itb].second]) itb++;
        }
        if(ita >= n || itb >= n) break;
        if(i % 2){
            now += 2 * a[ita].first;
            used[a[ita].second] = true;
            ans = max(ans, now);
        }else{
            now -= 2 * b[itb].first;
            used[b[itb].second] = true;
            ans = max(ans, now);
        }
    }
    cout << ans << endl;
}

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

int main() {
  
  int n;
  cin >> n;
  
  vector<int> a(n),b(n);
  for ( int i = 0; i < n; i++){
    cin >> a[i];
    b[i] = a[i];
  }
  
  sort(b.begin(),b.end());
  
  int gold = b[n-1],silver = b[n-2];
  
  for ( int i = 0; i < n; i++){
    if ( a[i] != gold ){
      cout << gold << endl;
    }else{
      cout << silver << endl;
    }
  }
  
}

Measured memory_bytes: 3200
program main

  implicit none

  !integer :: a,b
  character(100) :: s,t
  character(200) :: tmp
  integer :: lns,lnt

  read(*,*) s, t

  lns = len_trim( s )
  lnt = len_trim( t )
  s = trim( s )
  t = trim( t )


  !tmp = t(1:lnt+1)/s(1:lns+1)
  tmp = trim(t)//trim(s)

  print*, tmp


end program main

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){
  int D,G;
  cin>>D>>G;
  vector<pair<int,int>> vec(D);
  for(int i=0;i<D;i++){
    cin>>vec.at(i).first>>vec.at(i).second;
  }
  int ans=999999;
  for(int i=0;i<(1<<D);i++){
    bitset<10> bit(i);
    int point=0,ans_=0;
    for(int j=0;j<D;j++){
      if(bit.test(j)){
        point+=100*(j+1)*vec.at(j).first+vec.at(j).second;
        ans_+=vec.at(j).first;  
      } 
    }
    int de=D;
    while(point<G&&de>=1){
      if(de*100<=G-point&&!bit.test(de-1)){
        ans_+=min((G-point)/(de*100),vec.at(de-1).first-1);
        point+=(min((G-point)/(de*100),vec.at(de-1).first-1))*(de*100); 
      }
      de--;
    }
    if(point>=G&&ans_<ans) {
      ans=ans_;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	int i=0;
	int l=0;
	while(1)
	{
		if(i*i>n)
		{
			break;
		}
		l=i;
		i++;

	}
	cout<<l*l<<endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int date = B - A;
    if(date <= 0){
      System.out.println("delicious");
    }else if(date <= X){
      System.out.println("safe");
    }else{
      System.out.println("dangerous");
    }
  }  
}

Measured memory_bytes: 21716
// IOI 2021
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////
 
const int N = 1e5 + 5;

vector<int> G[N];

int Grundy(int v, int p = 0) {
	int g = 0;
	for (int u : G[v]) if (u != p) g ^= Grundy(u, v) + 1;
	return g;
}

int main() {
 
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));

	int n; cin >> n;
	for (int i = 1; i < n; i++) {
		int v, u; cin >> v >> u;
		G[v].push_back(u), G[u].push_back(v);
	}
	cout << (Grundy(1) ? "Alice" : "Bob") << endl;

	return 0;
}


Measured memory_bytes: 13716
n,y = map(int,input().split())

num_of_a = 0
num_of_b = 0
num_of_c = 0
flg = 0

while num_of_a <= n:
    remain1 = n - num_of_a
    num_of_b = 0
    num_of_c = 0
    while num_of_b <= remain1:
        remain2 = remain1 - num_of_b
        num_of_c = remain2
        ans = num_of_a*10000 + num_of_b*5000 + num_of_c*1000

        if ans == y:
            flg = 1
            break
        else:
            num_of_b += 1
    if flg == 1:
        break
    num_of_a += 1

if num_of_a == n+1:
    print("-1 -1 -1")
else:
    print(str(num_of_a)+" "+str(num_of_b)+" "+str(num_of_c))


Measured memory_bytes: 3064
#include <cstdint>
#include <iostream>

#define M 1000000007

int countDogMonkyLine(const int n, const int m) {
  if (n - m > 1 || m - n > 1)
    return 0;
  int64_t ans = 1;
  for (int i = (n <= m) ? n : m; i > 0; --i) {
    ans *= i;
    ans %= M;
  }
  ans *= ans;
  ans %= M;
  if (n == m)
    ans *= 2;
  else {
    int bigger = (n > m) ? n : m;
    ans *= bigger;
  }
  return ans % M;
}

int main() {
  int n, m;
  std::cin >> n >> m;
  std::cout << countDogMonkyLine(n, m) << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
int f(int x){int res=0;while(x)res+=x%10,x/=10;return res;}int main(){int n,res=1e9;std::cin>>n;for(int a=1,b;a<n;a++){b=n-a;int sum=f(a)+f(b);if(res>sum)res=sum;}std::cout<<res;}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner	sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		int[] x = new int[n + 1];
		x[0] = Math.abs(a[0]);
		x[n] = Math.abs(a[n - 1]);
		for(int i = 1 ; i < n ; i++) x[i] = Math.abs(a[i] - a[i - 1]);
		int sum = 0;
		for(int i = 0 ; i < n + 1 ; i++) sum += x[i];
		for(int i = 0 ; i < n ; i++) {
			int temp = sum;
			temp -= x[i] + x[i + 1];
			if(i == 0) {
				temp += Math.abs(a[1]);
			} else if(i == n - 1) {
				temp += Math.abs(a[n - 2]);
			} else {
				temp += Math.abs(a[i - 1] - a[i + 1]);
			}
			System.out.println(temp);
		}
	}
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a == b && b == c ? "Yes" : "No") << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int K = scn.nextInt();
		int ans = 0;
		for(int i = 0;i < N;i++) {
			int a = scn.nextInt();
			if(a >= K)ans++;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 48168
#!/usr/bin/env python

ss = []
sumf = []

n, m = input().split()
n = int(n)
m = int(m)

for i in range(n):
    r = input()
    rSplit = r.split()
    for j in range(m):
        rSplit[j] = int(rSplit[j])
    ss.append(rSplit)

for i in range(m):
    summ = 0
    for j in range(n):
        summ += ss[j][i]
    sumf.append(summ)

ss.append(sumf)

for x in ss:
    summ = sum(x)
    x.append(summ)

for i in range(n + 1):
    for j in range(m + 1):
        ss[i][j] = str(ss[i][j])

for x in ss:
    print(" ".join(x))
    

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

double dot(P a,P b){return real(conj(a)*b);};
double cross(P a,P b){return imag(conj(a)*b);};

int main(){
  int d;
  while(~scanf("%d",&d)){
    ll sum = 0;
    REPR(i,600/d){
      sum += i*d*i*d*d;
    }
    cout<<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) max_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

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

    int N; cin >> N;
    ll Y; cin >> Y;

    rep(i,N+1) {
        rep(j,N+1) {
            if(10000*i + 5000*j + 1000*(N-i-j) == Y and (N-i-j) >= 0){
                cout << i << " " << j << " " << N-i-j << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if (a*a+b*b==c*c)  cout<<(a*b)/2<<endl;
	else if (a*a+c*c==b*b)  cout<<(a*c)/2<<endl;
	else cout<<(b*c)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
 int main()
{

 int h,w,i,j;
 
 for(;;){
         scanf("%d%d",&h,&w);
         if(h+w==0) break;
         for(i=0;i<h;i++){
                          for(j=0;j<w;j++)
                          if(i*j==0 || i+1==h || j+1==w)
                                  printf("#");
                          else
                                  printf(".");
                          printf("\n");
                          }

           printf("\n");
          }
     return 0;
}



Measured memory_bytes: 2028
import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    Num = [-1] * N
    for _ in range(M):
        s, c = map(int, input().split())
        if Num[s-1] == -1: 
            if N > 1 and s == 1 and c == 0:
                print(-1)
                break
            else: Num[s-1] = c
        else:
            if Num[s-1] != c:
                print(-1)
                break
    else:
        if N == 1 and Num[0] == -1: print(0)
        else: 
            for i in range(N):
                if Num[i] == -1:
                    if i == 0: Num[i] = 1
                    else: Num[i] = 0
            print("".join(map(str, Num)))

    return 0

if __name__ =="__main__":
    solve()

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

typedef long long ll;
typedef long double ld;

int main() {
    int n;
    cin >> n;
    vector<ld> p(n);
    for (int i = 0; i < n; i++)
        cin >> p[i];
    vector<vector<ld>> dp(n + 1, vector<ld>(n + 1, 0));
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= i - 1; j++) {
            dp[i][j + 1] += dp[i - 1][j] * p[i - 1];
            dp[i][j] += dp[i - 1][j] * (1 - p[i - 1]);
        }
    }
    long double ans = 0;
    for (int i = n / 2 + 1; i <= n; i++) {
        ans += dp[n][i];
    }
    cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 141824
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	long long ans = 0, a;
	for (int i = 0; i < 4; i++) {
		cin >> a;
		ans += a;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3116
N = gets.to_i
mts = gets.split.map(&:to_i)
ans = 1
(N-1).times do |i|
  ng = 0
  (i + 1).times do |j|
    if mts[j] > mts[i + 1]
      ng += 1
    end
  end
  ans += 1 if ng == 0
end
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ls (o << 1)
#define rs (o << 1 | 1)
#define mid ((L + R) >> 1)
using namespace std;
typedef long long LL;
const int N = 200500;
const int mod = 998244353;
bool is[N];
int x[N], y[N], h[N], n;
bool cmp(const int &o, const int &p) { return x[o] < x[p]; }
bool cmp1(const int &o, const int &p) { return y[o] < y[p]; }
int main() {
#ifdef TEST
	freopen("input.txt", "r", stdin);
#endif
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d%d", &x[i], &y[i]);
		if (x[i] > y[i]) swap(x[i], y[i]);
		h[i] = i;
	}
	sort(h, h + n, cmp1);
	int mx = h[n - 1];
	LL ans = y[h[n - 1]] - y[h[0]];
	sort(h, h + n, cmp);
	int mn = h[0];
	ans *= x[h[n - 1]] - x[h[0]];
	if (mn == mx) {
		cout << ans << endl;
		return 0;
	}
	multiset<int> s;
	for (int i = 0; i < n; ++i) {
		if (i == mn) {
			s.insert(y[i]);
		} else {
			s.insert(x[i]);
		}
	}
	LL con = y[mx] - x[mn];
	int ans2 = *s.rbegin() - *s.begin();
	for (int i = 1; i < n; ++i) {
		if (h[i] == mx) continue;
		s.erase(s.find(x[h[i]]));
		s.insert(y[h[i]]);
		ans2 = min(ans2, *s.rbegin() - *s.begin());
	}
	cout << min(ans, con * ans2) << endl;
	return 0;
}


Measured memory_bytes: 12032
#include <stdio.h>
#include <math.h>
#include <string.h>
int main()
{
    int x,min=1010;
    char a[1010],b[1010];
    scanf("%s",a);
    scanf("%s",b);
    x = strlen(a)-strlen(b)+1;
    for(int i=0;i<x;i++){
        int count=0;
        for(int j = 0;j<strlen(b);j++){
            if(a[j+i]!=b[j])
                count++;
        }
        if(count<min)
            min = count;
    }
    printf("%d\n",min);
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    string s; cin >> s;
    ll ans = 0;
    ll w = 0;
    reverse(all(s));
    rep(i, s.size()) {
        if(s[i] == 'W') w++;
        else ans += w;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3756
#include <iostream>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <iomanip>
#include <math.h>
#include <map>
#include <algorithm>
#define M_PI 3.14159265358979323846264338327950288
#define oo 998244353
#define maxN 200007
using namespace std;

int a[maxN], b[maxN];
bool cmp(int &a, int &b) {
    return a > b;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;

    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= n; ++i) cin >> b[i];
    sort(b+1, b+n+1, cmp);

    int left = 0, right = -1;
    for (int i = 1; i <= n; ++i) {
        if (a[i] == b[i]) {
            left = i;
            break;
        }
    }

    for (int i = n; i >= 1; --i) {
        if (a[i] == b[i]) {
            right = i;
            break;
        }
    }

    bool to_right = false;
    int left_correct = 1, right_correct = n;
    for (int i = left; i <= right; ++i) {
        if (b[left_correct] == b[i] || a[left_correct] == b[i]) to_right = true;
        if (!to_right) {
            swap(b[left_correct], b[i]);
            ++left_correct;
        }
        else {
            swap(b[right_correct], b[i]);
            --right_correct;
        }
    }

    for (int i = 1; i <= n; ++i) {
        if (b[i] == a[i]) {
            puts("No");
            return 0;
        }
    }

    puts("Yes");
    for (int i = 1; i <= n; ++i) cout << b[i] << " ";

    return 0;
}

Measured memory_bytes: 4732
import java.util.*;

import static java.lang.System.*;

class Main {
	public static Scanner sc = new Scanner(in);
	public static Random rand=new Random();

	public void fall(char[][] tmp){
		for(int x=0;x<w;x++)
			for(int y=h-1;y>=0;y--)if(tmp[y][x]=='.')
				for(int dy=y-1;dy>=0;dy--)if(tmp[dy][x]!='.'){
					tmp[y][x]=tmp[dy][x];
					tmp[dy][x]='.';
					break;
				}
	}
	public boolean check(char[][] tmp){
		boolean change=true;
		while(change){
			change=false;
			fall(tmp);
			boolean[][] dels=new boolean[h][w];
			for(int y=0;y<h;y++)for(int x=0;x<w;x++){
				for(int i=0;i<4;i++){
					int px=x,py=y;
					char s=tmp[py][px];
					if(s=='.')continue;
					int l=1;
					px+=d[i][0];
					py+=d[i][1];
					//連結数
					while((0<=px && px < w && 0<=py && py<h)
								&& tmp[py][px]==s){
						l++;
						px+=d[i][0];
						py+=d[i][1];
					}
					if(l>=n){
						//back
						px-=d[i][0];
						py-=d[i][1];
						while(!(px==x && py ==y)){
							dels[py][px]=true;
							px-=d[i][0];
							py-=d[i][1];
						}
						dels[py][px]=true;
					}
				}
			}
			for(int y=0;y<h;y++)for(int x=0;x<w;x++){
				if(dels[y][x]){
					tmp[y][x]='.';
					change=true;
				}
			}
		}
		for(int y=0;y<h;y++)for(int x=0;x<w;x++){
			if(tmp[y][x]!='.')return false;
		}
		return true;

	}

	int h,w,n;
	int[][] d=new int[][]{{1,0},{0,1},{-1,0},{0,-1}};

	public void run() {
		h=sc.nextInt();
		w=sc.nextInt();
		n=sc.nextInt();

		char[][] map=new char[h][w];
		char[][] tmp=new char[h][w];
		for(int i=0;i<h;i++){
			map[i]=sc.next().toCharArray();
		}
		for(int y=0;y<h;y++)for(int x=0;x<w;x++)for(int i=0;i<4;i+=2){//0,2
			for(int dy=0;dy<h;dy++)for(int dx=0;dx<w;dx++)
				tmp[dy][dx]=map[dy][dx];

			int px=x+d[i][0];
			int py=y+d[i][1];
			if(0<=px && px<w && 0<=py && py<h
				&& tmp[py][px]!=tmp[y][x]){
				char tm=tmp[py][px];
				tmp[py][px]=tmp[y][x];
				tmp[y][x]=tm;
				if(check(tmp)){
					ln("YES");
					return;
				}
			}
		}
		ln("NO");
	}
	public static void main(String[] args) {
		new Main().run();
	}

	public int[] nextIntArray(int n){
		int[] res=new int[n];
		for(int i=0;i<n;i++){
			res[i]=sc.nextInt();
		}
		return res;
	}
	public static void pr(Object o) {
		out.print(o);
	}
	public static void ln(Object o) {
		out.println(o);
	}
	public static void ln() {
		out.println();
	}
}

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

const int MAX = 3000000;
const int MOD = 1000000007;

int main() {
  string s; cin >> s;
  int rain = 0, sun = 0;
  rep(i, 3){
  if(s[i] == 'R') rain ++; 
  else sun ++;
  }
  
  if(s == "RSR") rain --;
   
  cout << rain << endl;
   
   
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define SIZE 5005
using namespace std;
typedef long long int ll;

int main(){
    ios::sync_with_stdio(false);
    priority_queue<int,vector<int>, greater<> > q;
    priority_queue<int,vector<int>, less<> > p;
    int n;
    cin>>n;
    char s[200005];
    cin>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='W'){
            q.push(i+1);
        }else{
            p.push(i+1);
        }
    }
    int ans=0;
    if(q.empty()||p.empty()){
        printf("0\n");
        return 0;
    }
    while(q.top()<p.top()){
        int tmp1=q.top();
        q.pop();
        int tmp2=p.top();
        p.pop();
        q.push(tmp2);
        p.push(tmp1);
        ans++;
    }
    printf("%d\n",ans);
}


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

int countDiviser(int N){
  int ans=0;
  for (int i = 1; i <= N; i+=2) {
    if(N%i==0) ans++;
  }
  return ans;
}

int main(){
  int N;
  cin >> N;
  int ans=0;
  for (int i = 0; i <= N; i++) {
    if(countDiviser(i)==8) ans++;
  }  
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

S = str(input())
T = str(input())

if len(S)+1 != len(T):
    print('No')
    sys.exit()

for s in range(len(T)):
    if s == (len(T)-1):
        print("Yes")
        sys.exit()
    if S[s] != T[s]:
        print("No")
        sys.exit()

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

int main() {
  int k, a, b; cin >> k >> a >> b;
  bool good = 0;
  for (int i = a; i <= b && !good; i++) {
    if (i%k == 0)
      good = 1;
  }
  cout << (good ? "OK" : "NG") << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main() {
	int a,b;
	cin>>a>>b;
	if(a==b){
		cout<<"0"<<endl;
	}else if((a+b)%2>0){
		cout<<"IMPOSSIBLE"<<endl;
	}else{
		cout<<(a+b)/2<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
using Grapgh = vector<vector<ll>>;
Grapgh G;

void search(ll n, ll sum, vector<bool> &seen, vector<ll> &ans) {
    seen[n] = true;
    sum += ans[n];
    ans[n] = sum;
    for (auto nn : G[n]) {
        if (seen[nn])
            continue;
        search(nn, sum, seen, ans);
    }
}

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<ll> ans(N, 0);
    vector<bool> seen(N, false);
    G.assign(N, vector<ll>());
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    rep(i, Q) {
        int a, b;
        cin >> a >> b;
        a--;
        ans[a] += b;
    }

    int sum = 0;
    search(0, sum, seen, ans);

    for (auto a : ans) {
        cout << a << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 27392
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 6e2 + 10,mod = 1e9 + 7;

int Sum[N],a[N],b[N],val[N],dp[N][N];
int n,m;

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

inline bool in(int p,int l,int r) {
	return p >= l && p <= r;
}

inline bool check(int l,int r) {
	For(i,1,m) if(in(a[i],l,r) ^ in(b[i],l,r)) return false;
	return true;
}

int main() {

	n = read() << 1,m = read();
	For(i,1,n) Sum[i] = 1;
	val[0] = 1;
	for(int i = 2;i <= n;i += 2) val[i] = 1ll * val[i - 2] * (i - 1) % mod;
	For(i,1,m) {
		a[i] = read(),b[i] = read();
		Sum[a[i]] = Sum[b[i]] = 0;
	}
	For(i,1,n) Sum[i] += Sum[i - 1];

	int ans = 0;
	For(len,1,n) For(i,1,n - len + 1) {
		int j = i + len - 1,tot = Sum[j] - Sum[i - 1];
		if(!check(i,j) || (tot & 1)) continue;
		int cur = val[tot];
		For(k,i,j - 1) cur = (cur - 1ll * dp[i][k] * val[Sum[j] - Sum[k]]) % mod;
		cur = (cur + mod) % mod;
		ans = (ans + 1ll * (dp[i][j] = cur) * val[Sum[n] - tot]) % mod;
	}

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

Measured memory_bytes: 1664
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
#include<stdio.h>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    int A;
    cin >> A;
    int L=A/100;
    int R=A%100;
    if(L>=1 && L<=12){
        if(R>=1 && R<=12){
            cout << "AMBIGUOUS";
        }
        else{
            cout << "MMYY";
        }
    }
    else{
        if(R>=1 && R<=12){
            cout << "YYMM";
    }
    else{
        cout << "NA";
    }
}

    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test ll t; cin>>t; while(t--)
typedef long long int ll;
int main() {
    FIO;
    //test
    {
        ll a,b;
        cin>>a>>b;
        cout<<a*b<<endl;
    }
	return 0;
}


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

using namespace std;

#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define int long long
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define MOD 1000000007

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

signed main()
{
    fast_IO;
    int test = 1;
    // cin >> test;
    while(test--)
    {
        int n, x, t;
        cin >> n >> x >> t;
        int ans = ceil((1.00 * n) / x);
        ans *= t;
        cout << ans << endl;
        
    }
    return 0;
}

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

int main(){
    int H,W; cin>>H>>W;
    int dp[10][10];
    rep(i,10){
        rep(j,10){
            cin>>dp[i][j];
        }
    }
    rep(k,10)rep(i,10)rep(j,10){
        dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
    }
    int ans=0;
    rep(i,H)rep(j,W){
        int b; cin>>b;
        if(b!=-1)ans+=dp[b][1];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        var scaner = new Scanner(System.in);
        
        var ans = 0;

        for (int i = 1; i < 6; i++) {
            var input = scaner.nextInt();
            if (input == 0) {
                ans = i;
            }
        }

        System.out.println(ans);

        scaner.close();
    }

}


Measured memory_bytes: 35712
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        long a = sc.nextLong();
        long b = sc.nextLong();

        long gcd = gcd(a, b);

        long x = gcd;

        long ans = 1;

        for (long i = 2; i <= Math.sqrt(x); i++) {
            if (x % i == 0) { // 最小の因数を求める
                while (x % i == 0) {
                    x /= i; // 最小の因数で割った数を代入する
                }
                ans++;
            }
        }

        if (x > 1) {
            ans++;
        }

        System.out.println(ans);
    }

    private static long gcd(long a, long b) {
        long temp;
        while ((temp = a % b) != 0) {
            a = b;
            b = temp;
        }
        return b;
    }
}

Measured memory_bytes: 23636
#include<iostream>
#include<cstdio>
//#include<cmath>
#include<algorithm>
//#include<cstring>
//#include<map>
using namespace std;
inline int read()
{
    int p=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9'){p=p*10+c-'0';c=getchar();}
    return f*p;}
int N,d[101],ans=1;
int main()
{
	N=read();
	for(int i=1;i<=N;i++)
	    d[i]=read();
	sort(d+1,d+1+N);
	cout<<unique(d+1,d+1+N)-d-1;
	return 0;
}

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

int main(){
   int N;
   std::cin >> N;
   int A;
   std::vector<int> v;
   for(int i=0; i<N; ++i) {
      std::cin >> A;
      v.push_back(A);
   }
   std::sort(v.begin(), v.end());
   for(int i=0; i<N-1; ++i){
      if(v[i]==v[i+1]){
	 std::cout << "NO" << std::endl;
	 return 0;
      }
   }
   std::cout << "YES" << std::endl;

   return 0;

}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, vector<int> > mp;
    vector<int> sum(n + 1);
    rep(i, 0, n){
        cin >> a[i];
    }
    int now = 0;
    int ans = 0;
    rep(i, 0, n){
        mp[now].push_back(i);
        sum[i] = now;
        now += a[i];        
    }
    mp[now].push_back(n);
    rep(i, 0, n){
        int id = mp[sum[i]].end() - upper_bound(all(mp[sum[i]]), i);
        // cout << i << ' ' << sum[i] << ' ' << id << endl;
        ans += id;
    }
    cout << ans << endl;
}

Measured memory_bytes: 25216
#include <stdio.h>

int gdc(int a,int b){
    if(b == 0) return a;
    return gdc(b,a%b);
}

int main(){
    int k;
    long long s=0;
    scanf("%d", &k);
    for(int i = 1;i<=k;i++){
        for(int j = 1;j<=k;j++){
            int x = gdc(i,j);
            for(int z = 1;z<=k;z++){
                s+=gdc(x,z);
            }
        }
    }
    printf("%lld\n", s);
}

Measured memory_bytes: 1724