akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static int M;
	public static int N;
	public static boolean[][] A;
	public static boolean[] visited ;
public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		//A
		/*int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a == c){
			System.out.println(b);
		}else if(b == c){
			System.out.println(a);
		}else if(b == a){
			System.out.println(c);
		}else{
			System.out.println("error!");
		}
	}*/

		//B
		/*int Height = sc.nextInt();
		int Weight = sc.nextInt();
		if(Height < 1 || Weight > 50){
			System.out.println("error!");
		}

		String[] S = new String[Height];
		for(int i = 0 ; i < Height ; i ++){
			S[i] = sc.next();
		}
		int BombCounter;
		for(int i = 0; i < Height ; i++){
			for(int j = 0; j < Weight ; j++){
				BombCounter = 0;
				if(i != 0 && j >= 1){
					if(S[i-1].charAt(j-1)== '#'){
						BombCounter ++;
					}
				}
				if(i != 0){
					if(S[i-1].charAt(j)== '#'){
						BombCounter ++;
					}
				}
				if(i != 0 && j <= Weight - 2){
					if(S[i-1].charAt(j+1)== '#'){
						BombCounter ++;
					}
				}
				if(j >= 1){
					if(S[i].charAt(j-1)== '#'){
						BombCounter ++;
					}
				}
				if(S[i].charAt(j)== '#'){
					BombCounter ++;
				}
				if(j <= Weight -2){
					if(S[i].charAt(j+1)== '#'){
						BombCounter ++;
					}
				}
				if(i <= Height -2 && j >= 1){
					if(S[i+1].charAt(j-1)== '#'){
						BombCounter ++;
					}
				}
				if(i <= Height-2){
					if(S[i+1].charAt(j)== '#'){
						BombCounter ++;
					}
				}
				if(i <= Height-2 && j <= Weight -2){
					if(S[i+1].charAt(j+1)== '#'){
						BombCounter ++;
					}
				}
				if(S[i].charAt(j)=='.'){
					System.out.print(BombCounter);
				}else{
					System.out.print("#");
				}
			}
			System.out.print("\n");
		}*/

		//C
		N = sc.nextInt();						//頂点の数の入力
		M = sc.nextInt();						//辺の数の入力
		int ans = 0;								//答えを保存する変数ans
		boolean bridge = false;
		A = new boolean[N][N];				//隣接行列A
		visited = new boolean[N];
		int[] a = new int[M];
		int[] b = new int[M];
		//Arrays.fill(A, false);					//Aの初期化
		for(int i = 0 ; i < M ; i++){
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			a[i]--;
			b[i]--;
		}

		for(int i = 0; i < M; i++){
			A[a[i]][b[i]] = true;
			A[b[i]][a[i]] = true;
		}

		for(int i = 0 ; i < M ; i++){
			A[a[i]][b[i]] = false;
			A[b[i]][a[i]] = false;
			for(int x = 0 ; x < N ; x++){
				visited[x] = false;
			}
			bridge = false;
			DFS(N-1);
			for(int i2 = 0; i2 < N ; i2++){
				//System.out.println(i2 +","+visited[i2]);
				if(!visited[i2]){
					bridge = true;
				}
			}
			if(bridge){
				ans++;
			}
			A[a[i]][b[i]] = true;
			A[b[i]][a[i]] = true;
		}
		System.out.println(ans);

	}

	public static  void DFS(int a){
		visited[a] = true;
		for(int i = 0; i < N ; i++){
			if(A[a][i] && !visited[i]){
				DFS(i);
			}
		}
	}
}


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

using namespace std;
#define ll long long
const int N = 2e3 + 5;
int ord[N], a[N];
ll dp[N][N];
int n;

ll solve(int l, int r) {
    if (l > r) return 0;
    ll &ret = dp[l][r];
    if (ret != -1) return ret;
    int indx = ord[(l - 1) + (n - r) + 1];
    ret = max(solve(l + 1, r) + a[indx] * 1LL * abs(indx - l), solve(l, r - 1) + a[indx] * 1LL * abs(indx - r));
    return ret;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        ord[i] = i;
    }
    sort(ord + 1, ord + 1 + n, [](int i, int j) {
        return a[i] > a[j];
    });
    memset(dp, -1, sizeof(dp));
    cout << solve(1, n) << endl;

    return 0;
}

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

int main(void) {
	int n, b, f, r, v;
	int a[4][3][10];
	cin >> n;

	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 10; k++)
			{
				a[i][j][k] = 0;
			}
		}
	}

	for (int i = 0; i < n; i++)
	{
		cin >> b >> f >> r >> v;
		a[b -1][f-1][r-1] += v;
	}

	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 10; k++)
			{
				cout << " " << a[i][j][k];
			}
			cout << endl;
		}
		if(i != 3) cout << "####################" << endl;
	}

	return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n, x, i, j, k, count;
		while (true) {
			n = stdIn.nextInt();
			x = stdIn.nextInt();
			count=0;
			if (n == 0 && x == 0) {
				break;
			}
			for (i = 1; i <= n; i++) {
				for (j = i+1; j < n; j++) {
					for (k = j+1; k <= n; k++) {
						if (i + j + k == x) {
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
		stdIn.close();
	}
}



Measured memory_bytes: 26960
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
struct Point{
  double x,y;
  Point(double x,double y):x(x),y(y){}
  Point operator+(Point p){return Point(x+p.x,y+p.y);}
  Point operator-(Point p){return Point(x-p.x,y-p.y);}
  Point operator*(double k){return Point(x*k,y*k);}
  Point operator/(double k){return Point(x/k,y/k);}
  double norm(){return x*x+y*y;}
  double abs(){return sqrt(norm());}
};
typedef Point Vector;

double cross(Vector a,Vector b){
  return a.x*b.y - a.y * b.x;
}



signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  auto calc=[](string s,int d,int l){
    const double PI = acos(-1);
    const double EPS = 1e-8;
    auto mstr=[s](int i,int j,int k){
      // cout<<s<<endl;
      string c="";
      if(s=="BC") c="D";
      if(s=="CD") c="B";
      if(s=="DB") c="C";
      assert(!c.empty());
      //cout<<c<<endl;
      string x="";
      if(i%2) x=string(1,s[1])+c;
      else x="A"+string(1,s[0]);
      if(i%2){
	if((j&1)^k) x=x+s[0];
	else x=x+"A";
      }else{
	if((j&1)^k) x+=c;
	else x=x+s[1];
      }
      //cout<<x<<endl;
      return x;
    };
    double x=l*cos((double)d/360*2*PI);
    double y=l*sin((double)d/360*2*PI);
    //cout<<x<<" "<<y<<endl;
    Point P(x,y);
    string tri="";
    //cout<<sqrt(3)<<endl;
    int cnt=0;
    for(int i=0;i<100;i++){
      for(int j=0;j<100;j++){
	Point X(0.5*i+j,sqrt(3.0)/2.0*i);
	Point Y(0.5*i+j+1,sqrt(3.0)/2.0*i);
	for(int k=0;k<2;k++){
	  Point Z(0.5*i+j+0.5,sqrt(3.0)/2.0*(i+1-(k*2)));
	  if(!k&&cross(Y-X,P-X)<=EPS) continue; 
	  if( k&&cross(Y-X,P-X)>=EPS) continue; 
	  if(!k&&cross(Z-Y,P-Y)<=EPS) continue; 
	  if( k&&cross(Z-Y,P-Y)>=EPS) continue; 
	  if(!k&&cross(X-Z,P-Z)<=EPS) continue; 
	  if( k&&cross(X-Z,P-Z)>=EPS) continue; 
	  if(0){
	    cout<<i<<" "<<j<<" "<<k<<endl;
	    cout<<X.x<<" "<<X.y<<endl;
	    cout<<Y.x<<" "<<Y.y<<endl;
	    cout<<Z.x<<" "<<Z.y<<endl;
	  }
	  cnt++;
	  tri=mstr(i,j,k);
	}
      }
    }
    assert(cnt==1);
    //cout<<tri<<":"<<tri.size()<<endl;
    sort(tri.begin(),tri.end());
    tri.erase(unique(tri.begin(),tri.end()),tri.end());
    return tri;
  };
  string s1,s2;
  int d1,l1,d2,l2;
  cin>>s1>>d1>>l1;
  cin>>s2>>d2>>l2;
  cout<<(calc(s1,d1,l1)==calc(s2,d2,l2)?"YES":"NO")<<endl;
  return 0;
}



Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
using namespace std;



int main(){
  int A,B,C;
  cin >> A >> B >> C;
  
  int ANS = C-A+B;
  if(ANS < 0)
  {
    cout << "0" << endl;
  }
  else
  {
    cout << ANS << endl;
  }
  
  return 0;
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int N,sum;
    cin >> N;
    vector<int> vec(N);
    REP(i,0,N){
        cin >> vec[i];
    }

    REP(i,0,N){
        REP(j,i+1,N){
            sum+=vec[i]*vec[j];
        }
    }

    P(sum);
}

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

using namespace std;
typedef long long int lli;

int main(){
	int n;
	cin >> n;
	vector<long> list(n,0);
	for(int i = 0; i < n; i++){
		cin >> list[i];
	}
	sort(list.begin(), list.end() );
	vector<long> line(2,0);
	for(int i = n-1; i >= 1; i--){
		if(line[0]==0){
			if(list[i] == list[i-1] ){
				line[0]=list[i];
				i--;
				continue;
			}
		}
		else if(line[1]==0 ){
			if(list[i] == list[i-1]){
				line[1]=list[i];
				break;
			}
		}
	}
	lli ans = (lli)line[0] * (lli)line[1];
	cout << ans << endl;
			
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>

int del_Recipies(int del,int count,int n,int m,int p[],int Recipies[500][500]);

int main()
{
	int n,m,Recipies[500][500]={0},MAX[500],min_del_Recipies,c,flag,*p,count;
	
	while(1)
	{
		scanf("%d %d",&n,&m);
		if(n==0&&m==0) break;
		min_del_Recipies=-1;
		for(int i=0;i<m;i++) MAX[i]=0;
		for(int i=0;i<n;i++)
		{
			for(int t=0;t<m;)
			{
				Recipies[i][t]=getchar();
				if(Recipies[i][t] != '\n'&& Recipies[i][t] != ' ')
				{
					Recipies[i][t]-='0';
					MAX[t]+=Recipies[i][t];
					t++;
				}
			}
		}
		flag=1;
		//作る際に必要な材料数がすべての材料で2で割り切れたなら、その時のレシピ数になる
		for(int t=0;t<m;t++)
		{
			if(MAX[t]%2)
			{
				flag=0;
				break;
			}
		}
		if(flag) min_del_Recipies=0;
		else
		{
			p=(int*)malloc(m*sizeof(int));
			//すべて作った時に必要な材料からレシピを減らしていく
			//減らしていく数を順に増やしていき、その減らす数の時のすべての減らし方を試す
			
			for(int del=1;del<n;del++)//何個引くか del個 引いた個数 count
			{
				for(int i=0;i<m;i++) p[i]=MAX[i];
				count=0;
				flag=del_Recipies(del,count,n,m,p,Recipies);//何個引くか del個 引いた個数 count
				//del個減らしたときにすべての材料が2で割り切れるものがあったら 1を返す なかったら 0を返す
				if(flag)
				{
					min_del_Recipies = del;//delで割り切れたとき
					break;
				}
			}
			if(min_del_Recipies==-1)min_del_Recipies=n;//どれも割り切れなかったとき
			free(p);
		}
		printf("%d\n",n-min_del_Recipies);//全体から割り切れるまでに引いた個数を引くと求まる
	}
	return 0;
}

int del_Recipies(int del,int count,int n,int m,int p[],int Recipies[500][500])
{
	//引く個数=del 引いた個数=count何種類目 i
	int flag=1;
	for(;count<n && n-count>=del;count++)
	{
		
		if(del==1)
		{
			flag=1;
			for(int t=0;t<m;t++)
			{
				p[t]-=Recipies[count][t];
				if(p[t]%2!=0)
				{
					flag=0;
					p[t]+=Recipies[count][t];
					break;
				}
				p[t] += Recipies[count][t];
			}
			if(flag) return 1;
			else continue;
		}
		else 
		{
			//残りの引く個数が1になるまで再起
			//pから今回引くRecipiesを引いてから次に渡す
			for(int t=0;t<m;t++) p[t]-=Recipies[count][t];
			//引く個数delを一つ減らす　引いた個数countを一つ増やす
			if(del_Recipies(del-1,count+1,n,m,p,Recipies)) return 1;
			for (int t = 0; t<m; t++) p[t] += Recipies[count][t];
		}
		
	}
	return 0;
}


Measured memory_bytes: 2748
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

/* Binary Indexed Tree(0-index) */

struct BIT{
  typedef int Type;
  int bit_size;
  vector<Type> data;

  BIT(int n){
    bit_size = n;
    data.assign(n+2, 0);
  }

  //add x to kth value
  void add(int k, Type x){
    k++;
    while(k <= bit_size){
      data[k] += x;
      k += k & (-k);
    }
  }

  //sum of [0,k]
  Type query(int k){
    k++;
    Type rec = 0;
    while(k > 0){
      rec += data[k];
      k -= k & (-k);
    }
    return rec;
  }

  //sum of [a, b)
  Type query(int a, int b){
    return query(b-1) - query(a-1);
  }
};

int main(){
  int n, a;
  pair<int,int> pos[SIZE];

  scanf("%d", &n);
  for (int i=0; i<n; i++) {
    scanf("%d", &a);
    pos[i] = {a, i};
  }

  sort(pos, pos+n);

  BIT bit(n);
  ll ans = 0;

  for (int i=0; i<n; i++) {
    int p = pos[i].second;
    ans += p - bit.query(0, p);
    bit.add(pos[i].second, 1);
  }

  printf("%lld\n", ans);

  return 0;
}



Measured memory_bytes: 5212
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n=0;
  for(int i=0;i<s.size();i++){
    int m=s[i]-'0';
    n += m;
  }
  if(n%9==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3732
#include<stdio.h>

int main(){
    int N;
    int a[110000];
    int i;
    int sum = 0;

    scanf("%d", &N);

    for(i=0; i<N; i++){
        scanf("%d", &a[i]);
        sum = sum + a[i] -1;
    }

    printf("%d", sum);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
       
int main() {
  int n;
  cin >> n;
  int TYPES = 4;
  int NUMBERS = 13;
  int cards[TYPES][NUMBERS];
  string type;
  int num;
  for (int i = 0; i < n; i++) {
    cin >> type >> num;
    if (type == "S") {
      cards[0][num - 1] = 1;
    } else if (type == "H") {
      cards[1][num - 1] = 1;
    } else if (type == "C") {
      cards[2][num - 1] = 1;
    } else if (type == "D") {
      cards[3][num - 1] = 1;
    }
  }
  for (int i = 0; i < TYPES; i++) {
    for (int j = 0; j < NUMBERS; j++) {
      if (cards[i][j] != 1) {
        if (i == 0) {
          cout << "S " << j + 1 << endl;
        } else if (i == 1) {
          cout << "H " << j + 1 << endl;
        } else if (i == 2) {
          cout << "C " << j + 1 << endl;
        } else if (i == 3) {
          cout << "D " << j + 1 << endl;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1208
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
using namespace std;

int main() {

    int n;
    while(cin >> n && n) {
        int h, m, t;

        int lunch_all = 0;
        int lunch_ok = 0;
        int dinner_all = 0;
        int dinner_ok = 0;
        int midn_all = 0;
        int midn_ok = 0;

        for(int i = 0; i < n; i++) {
            scanf("%d%*c%d%d", &h, &m, &t);

            if ( 11 <= h && h <= 14 ) {
                lunch_all += 1;
                if ( (0 <= t - m && t - m <= 8) || t + 60 - m <= 8 ) lunch_ok += 1;
            }
            if ( 18 <= h && h <= 20 ) {
                dinner_all += 1;
                if ( (0 <= t - m && t - m <= 8) || t + 60 - m <= 8 )  dinner_ok += 1;
            }
            if ( 21 <= h || h <= 1 ) {
                midn_all += 1;
                if ( (0 <= t - m && t - m <= 8) || t + 60 - m <= 8 ) midn_ok += 1;
            }
        }

        if (lunch_all > 0) {
            cout << "lunch " << lunch_ok * 100 / lunch_all << endl;
        } else {
            cout << "lunch no guest" << endl;
        }
        if (dinner_all > 0) {
            cout << "dinner " << dinner_ok * 100 / dinner_all << endl;
        } else {
            cout << "dinner no guest" << endl;
        }
        if (midn_all > 0) {
            cout << "midnight " << midn_ok * 100 / midn_all << endl;
        } else {
            cout << "midnight no guest" << endl;
        }
    }
     
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF = 100000000;
ll i,j,k;
ll mod=1000000007;

int h,w;
vector<vector<char>> maze;
vector<vector<int>> ans;
int dy[4]={0,0,1,-1},dx[4]={1,-1,0,0};

int main(){
    cin>>h>>w;
    maze.assign(h,vector<char>(w,'.'));
    ans.assign(h,vector<int>(w,0));
    int answer=0;

    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cin>>maze[i][j];
            if(maze[i][j]=='.'){answer++;}
        }
    }

    queue<pair<int,int>> que;
    que.push(make_pair(0,0));

    while(que.size()!=0){
        pair<int,int> state=que.front();
        que.pop();
        if(maze[state.first][state.second]=='.'){
            maze[state.first][state.second]='#';
            
            for(i=0;i<4;i++){
                int y=state.first,x=state.second;

                if(y+dy[i]<0 || y+dy[i]>=h || x+dx[i]<0 || x+dx[i]>=w) continue;//迷路外
                if(maze[y+dy[i]][x+dx[i]]=='#') continue;//もう通れない

                ans[y+dy[i]][x+dx[i]]=ans[y][x]+1;//距離の記憶
                que.push(make_pair(y+dy[i],x+dx[i]));
            }
        }
    } 

    if(ans[h-1][w-1]==0){cout<<-1<<endl;return 0;}//goalできない

    cout<<(answer-ans[h-1][w-1]-1)<<endl;
    return 0;
}

Measured memory_bytes: 256
void main() {
	auto N = ri;
	auto T = readAs!(int[]);
	auto M = ri;
	int tmp = T.sum;
	foreach(i; 0..M) {
		auto ip = readAs!(int[]);
		(tmp - T[ip[0]-1] + ip[1]).writeln;
	}
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    double R; cin >> R;
    cout << 2 * R * 3.14 << endl;
}

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

long long N,C,K,arr[100010];

int main(){
	cin>>N>>C>>K;
	for(long long i=0; i<N; i++)cin>>arr[i];
	sort(arr,arr+N);
	long long total=1,sol=1,maxim=arr[0]+K;
	for(long long i=1; i<N; i++){
		if(total==C||maxim<arr[i]){
			sol++; total=1; maxim=arr[i]+K;
		}else{
			total++;
		}
	}
	cout<<sol<<'\n';
}

Measured memory_bytes: 4312
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

bool is_prime(ll n) {
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  ll X;
  cin >> X;
  if (X == 2) {
    cout << 2 << endl;
    return 0;
  }

  for (ll i = X; i < 100100; i++) {
    if (is_prime(i)) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define int long long

using namespace std;
typedef pair <int, int> ii;

int n, m, k, grid[3001][3001];

int memo[3001][3001][4], g[3001][3001][4];
int cal(int r, int c, int take)
{
//    cerr << "r, c, reached: " << r << " " << c << " " << reached << '\n';
    if (r > n && c == m) return 0;
    if (r == n && c > m) return 0;
    if (r > n || c > m) return -1e18;
    if (take > 3) return -1e18;
    if (g[r][c][take]) return memo[r][c][take];
    int ans = 0;
    if (take < 3) {
        ans = max(ans, max(cal(r + 1, c, 0) + grid[r][c], cal(r, c + 1, take + 1) + grid[r][c]));
    }
    ans = max(ans, max(cal(r + 1, c, 0), cal(r, c + 1, take)));
    g[r][c][take] = 1;
    return memo[r][c][take] = ans;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    freopen("INP.INP", "r", stdin);
//    freopen("OUT.OUT", "w", stdout);
    cin >> n >> m >> k;
    for (int i = 1; i <= k; i++) {
        int l, r, v;
        cin >> l >> r >> v;
        grid[l][r] = v;
    }
    vector <int> d;
    cout << cal(1, 1, 0);
//    cerr << '\n' << '\n';
//    for (int i = 1; i <= n; i++) {
//        for (int j = 1; j <= m; j++)
//            cerr << memo[i][j][0] << " ";
//        cerr << '\n';
//    }
//    for (int i = 1; i <= n; i++) {
//        for (int j = 1; j <= m; j++)
//            cerr << memo[i][j][1] << " ";
//        cerr << '\n';
//    }
    return 0;
}


Measured memory_bytes: 637048
import java.util.*
 
fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}
 
object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val R = sc.next().toInt()
        pw.println(Math.PI * R * 2)
    }
}


Measured memory_bytes: 36580
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using P = pair<ll,ll>;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    ll n,k;cin>>n>>k;
    if(k==0){
        cout<<n*n<<endl;
        return 0;
    }
    ll res=0;
    for(ll i=1;i<=n;i++){
        if(i<=k) continue;
        res+=(n/i)*(i-k);
        if(n%i>=k) res+=(n%i)-k+1;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#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--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

vector<int> g[100010];

int dfs(int v){
    int res = 0;
    vector<int> vec;
    for(auto nv : g[v]) vec.push_back(dfs(nv));
    sort(vec.rbegin(), vec.rend());
    rep(i, vec.size()) res = max(res, vec[i] + i);
    return res + 1;
}

int main(){
    int n;
    cin >> n;
    rep(i, n - 1){
        int a;
        cin >> a;
        a--;
        g[a].push_back(i + 1);
    }
    cout << dfs(0) - 1 << endl;
    return 0;
}


Measured memory_bytes: 18440
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<cmath>
#include<cstdio>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

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


int main(){
    int D; cin>>D; string ans;
    if(D==25) ans = "Christmas";
    else if(D==24) ans = "Christmas Eve";
    else if(D==23) ans = "Christmas Eve Eve";
    else ans = "Christmas Eve Eve Eve";
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
class Dice {
private:
    string r[2][7] = {
        // 1<-1,2(fix),3,4,5(fix),6
        {"","","","W","E","","WW"},
        // 2<-1,2,3,4,5,6
        {"","S","","WS","ES","SS","N"}
    };
    void shift(int i, int j, int k, int l) {
        // i<-j<-k<-l<-i
        int t=a[i];a[i]=a[j];a[j]=a[k];a[k]=a[l];a[l]=t;
    }
public:
    int a[7]={0};
    void move(char d) {
        if(d=='N') shift(1,2,6,5);
        else if(d=='E') shift(1,4,6,3);
        else if(d=='W') shift(1,3,6,4);
        else if(d=='S') shift(1,5,6,2);
    }
    void adapt(Dice d) {
        int p = 0, q = 0;
        for(int j = 1; j <= 6; ++j) if(a[j]==d.a[2]) {q=j;break;}
        for(int j = 0; j < r[1][q].length(); ++j) move(r[1][q][j]);
        for(int j = 1; j <= 6; ++j) if(a[j]==d.a[1]) {p=j;break;}
        for(int j = 0; j < r[0][p].length(); ++j) move(r[0][p][j]);
    }
};
int main() {
    int n;
    cin >> n;
    Dice d0, dn;
    for(int j = 1; j <= 6; ++j) cin >> d0.a[j];
    string ans = "Yes";
    for(int i = 1; i < n; ++i) {
        for(int j = 1; j <= 6; ++j) cin >> dn.a[j];
        dn.adapt(d0);
        bool isDiff = false;
        for(int j = 1; j <= 6; ++j) if(d0.a[j]!=dn.a[j]) {isDiff=true;break;}
        if(!isDiff) {ans="No";break;}
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3212
H,W=map(int,input().split())
a=[]

for h in range(H):
    a.append(list(map(int,input().split())))

ans=[]
for h in range(H):
    for w in range(W):
        if h==H-1 and w==W-1:break
        if a[h][w]%2==1:
            if w==W-1:
                ans.append([h+1,w+1,h+2,w+1])
                a[h][w]-=1
                a[h+1][w]+=1
            else:
                ans.append([h+1,w+1,h+1,w+2])
                a[h][w]-=1
                a[h][w+1]+=1
L=len(ans)
print(L)

for i in range(L):
    print(*ans[i])


Measured memory_bytes: 32400
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=1;i<10000000;i++){
		if(i*a%b==c){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  int maxi = *max_element(v.begin(), v.end());
  int sum = accumulate(v.begin(), v.end(), 0);
  if (maxi < sum - maxi) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
using namespace std;
int n,x;
map<int,int> mp;
vector<int> g;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&x),++mp[x];
	for (map<int,int>::iterator it=mp.begin();it!=mp.end();++it)
		while (it->second>=2) it->second-=2,g.push_back(it->first);
	if (g.size()<2) return puts("0")*0;
	printf("%lld",1ll*g[g.size()-1]*g[g.size()-2]);
	return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>
#include<math.h>

int main(){
  double a,b,h,m,time,pi=3.14159265358979323846264338;
  double kaku,len;
  scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
  
  time=60*h+m;
  kaku=time*5.5;
  
  for(int i=1;i>0;i++){
    if(kaku<360){
      break;
    }
    kaku-=360;
  }
  
  kaku*=pi/180;
  
  len=sqrt(a*a+b*b-2*a*b*cos(kaku));
  
  printf("%.12lf",len);
  
}




Measured memory_bytes: 2608
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;

int main()
{
    int N,t;
    int c =0;
    int count =0;
    cin>>N;
    for(int i=1;i<=N;i++){
        t = i;
        c=0;
        while(t != 0){
            t = t / 10;
            c++;
        }
        if(c%2!=0){
            count++;
        }
    }
    log(count);
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main{
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int N=sc.nextInt();
		double btc=0;
		long jpy=0;
		for(int i=0; i<N; i++) {
			String kane=sc.next();
			String s=sc.next();
			if(s.equals("JPY")) {
				jpy+=Long.parseLong(kane);
			}
			else if(s.equals("BTC")) {
				btc+=Double.parseDouble(kane);
			}
		}
		pl((jpy+btc*380000.0));
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

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

using namespace std;
typedef long long ll;

const int N=300005,P=998244353;

int fpow(int a,int t){
	static int r;
	for(r=1;t;t>>=1,a=(ll)a*a%P)if(t&1)r=(ll)r*a%P;
	return r;
}
int fac[N],ifac[N],n,A,B,ret;
long long K;
int C(int n,int m){return n<m?0:(ll)fac[n]*ifac[m]%P*ifac[n-m]%P;}

int main(){
	cin>>n>>A>>B>>K;
	for(int i=fac[0]=1;i<=n;i++)fac[i]=(ll)fac[i-1]*i%P;
	ifac[n]=fpow(fac[n],P-2);
	for(int i=n;i>=1;i--)ifac[i-1]=(ll)ifac[i]*i%P;
	for(int i=0;i<=n;i++){
		long long r=K-(ll)A*i;
		if(r<0||r%B)continue;
		r/=B;
		if(r>n)continue;
		ret=(ret+(ll)C(n,i)*C(n,r))%P;
	}
	printf("%d\n",ret);
	return 0;
}

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

int main() {
    string s; cin >> s;
    Int ans = 0;
    Int w_pos = 0;
    for(int i = 0; i < s.size(); i++) {
        if (s[i] == 'W') {
            ans += (Int)(i-w_pos);
            w_pos++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

ll n;
vector<vector<P>> v;

bool j(ll bit){
    rep(i,n){
        if(!(bit & (1<<i))) continue;
        for(auto xy:v[i]){
            ll x = xy.first;
            ll y = xy.second;
            if(y==1 && !(bit & (1<<x))) return false;
            if(y==0 && (bit & (1<<x))) return false;
        }
    }
    return true;
}

int main(void)
{
    ll ans=0;
    cin >> n;
    v.resize(n);
    rep(i,n){
        ll a;
        cin >> a;
        rep(j,a){
            ll x, y;
            cin >> x >> y;
            x--;
            v[i].push_back({x,y});
        }
    }
    rep(bit,(1<<n)){
        if(j(bit)){
            ll cnt = 0;
            rep(i,n){
                if(bit & (1<<i)) cnt++;
            }
            ans = max(ans, cnt);    
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
const int mod = 1000000007;
const int MAX_N = 100005;

ll fact[MAX_N];         // 階乗
ll ifact[MAX_N];        // 階乗の逆元

// x^nを求める繰り返し二乗法(累乗の高速化)
// フェルマーの小定理より、逆元を計算するときに用いる。
ll mod_pow(ll x, int n){
    if(n == 0)      return 1;

    ll res = 1;
    while(n > 0){
        if(n & 1)   res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }

    return res;
}

// 階乗とその逆元テーブルを(0-n)まで埋める
void table(int n){
    fact[0] = 1;    // i^0 = 1;
    for(int i = 1; i <= n; ++i){
        fact[i] = fact[i - 1] * i % mod;
    }

    // フェルマーの小定理を利用して、右端の逆元を求める
    // 階乗の(mod-2)乗
    ifact[n] = mod_pow(fact[n], mod - 2);

    // 逆元の性質を利用して、テーブルを埋める
    for(int i = n; i >= 1; --i){
        ifact[i - 1] = ifact[i] * i % mod;
    }
}

// nCrを求める
ll combination(int n, int r){
    if(n < 0 || r < 0 || n < r)     return 0;

    return fact[n] * ifact[r] % mod * ifact[n - r] % mod;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, id1 = 0, id2 = 0;
    cin >> n;
    vector<int> a(n+1), cnt(n+1, 0);
    for(int i = 0; i < n+1; ++i){
        cin >> a[i];
        ++cnt[a[i]];
        
        if(cnt[a[i]] == 2)      id2 = i;   
    }
    for(int i = 0; i < n+1; ++i){
        if(a[i] == a[id2]){
            id1 = i;
            break;
        }
    }
    
    table(n+2);
    
    // 重複している数字をxとして、xの左にある数字の個数
    // a = [...x.....x...]
    int num1 = id1;
    // xの右側にある数字の個数
    int num2 = n - id2;

    // 重複している数字：x
    for(int i = 1; i <= n+1; ++i){        // 数字をi個取る
        ll res = (combination(n + 1, i) - combination(num1 + num2, i - 1) + 2 * mod) % mod;
        
        cout << res << "\n";
    }
}

Measured memory_bytes: 3584
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int d = a - b;
  int ans = c - d;
  if(ans < 0)
    ans = 0;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define all(v) v.begin(),v.end()
#define fi first
#define se second
const int inf = 1e9;

signed main(){
	int n, m;
	scanf("%lld%lld", &n, &m);
	int ans = min(n, m/2);
	m -= ans*2;
	if(m > 0)ans += m/4;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, M: int, a: "List[int]", b: "List[int]", x: "List[int]", y: "List[int]", c: "List[int]"):
    result = min(a)+min(b)
    for i in range(M):
        result = min(result,a[x[i]-1]+b[y[i]-1]-c[i])
    print(max(0,result))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(A)]  # type: "List[int]"
    b = [int(next(tokens)) for _ in range(B)]  # type: "List[int]"
    x = [int()] * (M)  # type: "List[int]"
    y = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(A, B, M, a, b, x, y, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 24612
#include <algorithm>
#include <cfenv>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end(), std::greater<int>());
  vector<int> even;
  vector<int> odd;
  bool is_even = 1;
  for (auto itr = a.begin(); itr != a.end(); ++itr) {
    if (is_even) {
      even.push_back(*itr);
    } else {
      odd.push_back(*itr);
    }
    is_even = !is_even;
  }
  int amount_alice = accumulate(even.begin(), even.end(), 0);
  int amunt_bob = accumulate(odd.begin(), odd.end(), 0);
  cout << amount_alice - amunt_bob << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> a(5, 0);
  int A, B, C;
  cin >> A >> C >> B;
  if (A > C) {
    if (A > B && B > C) {
      cout << "Yes" << endl;
      return 0;
    }
  } else {
    if (C > B && B > A) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

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

    int a, b;
    cin >> a >> b;
    cout << (a / b) << " ";
    cout << (a % b) << " ";
    cout << fixed << setprecision(10) << (a / (double)b) << endl;
    // cout << dec_point(10) << (a / (double)b) << endl;
}


Measured memory_bytes: 3304
h,w,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
H=[0]*h
W=[0]*w
for i in range(m):
  H[l[i][0]-1]+=1
  W[l[i][1]-1]+=1
hmax=max(H)
wmax=max(W)
cthmax=0
ctwmax=0
for i in range(h):
  if H[i]==hmax:
    cthmax+=1
for i in range(w):
  if W[i]==wmax:
    ctwmax+=1
ct=0
for i in range(m):
  if H[l[i][0]-1]==hmax and W[l[i][1]-1]==wmax:
    ct+=1
if cthmax*ctwmax>ct:
  print(hmax+wmax)
else:
  print(hmax+wmax-1)

Measured memory_bytes: 130060
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int a, b;
    std::cin >> a >> b;
    int t = 1;
    for (int i = 0; ; i++) {
        if (t >= b) {
            std::cout << i << std::endl;
            return 0;
        }
        t += a - 1;
    }

    return 0;
}


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define pb push_back

template<typename T> T DUP(T x, T y) { return (x + y - 1) / y; };
template <typename A, size_t N, typename T> inline void arrayFill(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = unordered_set<int32_t>;
using setstr = unordered_set<string>;
using qint = queue<int32_t>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;


void Main() {
    int n, k;
    cin >> n >> k;
    if (n % k == 0)puts("0");
    else puts("1");
}
 
int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n - 1); i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

const int N = 1e5 + 10;
ll fact[N];

ll Pow(ll a, ll b) {
    ll x = 1, y = a;
    while (b) {
        if (b % 2) x = x * y % MOD;
        y = y * y % MOD;
        b /= 2;
    }
    return x;
}

ll Inv(ll n) {
    return Pow(n, MOD - 2);
}

ll C(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * Inv(fact[k]) % MOD * Inv(fact[n - k]) % MOD;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    fact[0] = 1;
    forn(i, 1, N)
        fact[i] = fact[i - 1] * i % MOD;
    int n;
    cin >> n;
    vector<int> pos(n, -1);
    int p, q;
    forn(i, 0, n + 1) {
        int x;
        cin >> x;
        --x;
        if (pos[x] == -1) pos[x] = i;
        else {
            p = pos[x];
            q = i;
        }
    }
    fore(k, 1, n + 1) {
        ll ans = C(n + 1, k);
        ans -= C(n - q + p, k - 1);
        cout << (ans + MOD) % MOD << '\n';
    }
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define MOD 1000000007
int main(){
  vector<int> A(5);
  rep(i,0,5) cin>>A[i];
  int k;
  cin>>k;
  sort(A.begin(),A.end());
  if(A[4]-A[0]<=k) cout<<"Yay!"<<endl;
  else cout<<":("<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int num=1e9+7;
int main(){
    ll n,k;
    cin >> n >> k;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    ll ans=0;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(a[i]>a[j]&&i<j)ans+=k*(k+1)/2;
            ans%=num;
            if(a[i]>a[j]&&i>j)ans+=k*(k-1)/2;
            ans%=num;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(void){
    string str;
    std::getline(std::cin, str);

    for(int i = 0;i < str.length();++i){
        char c = str.at(i);
        if(c >= 'a' && c <= 'z'){
            str.at(i) = c - 0x20;
        }else if(c >= 'A' && c <= 'Z'){
            str.at(i) = c + 0x20;
        }
    }
    cout << str << endl;
    return 0;
}



Measured memory_bytes: 3164
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n,q,k;
    long ans,a[1000001],b[1000001],c[1000001],d[1000001],sum[1000001];
    char s[1000010];
    scanf("%d",&n);
    scanf("%s",s);
    scanf("%d",&q);
    c[0]=0;
    a[0]=0;
    d[0]=0;
    sum[0]=0;
    for(int i=0;i<n;i++){
        if(s[i]=='C'){
            c[i+1]=c[i]+1;
        }
        else{
            c[i+1]=c[i];
        }
    }
    for(int i=0;i<n;i++){
        if(s[i]=='D'){
            a[i+1]=a[i]+1;
        }
        else{
            a[i+1]=a[i];
        }
    }
    for(int i=0;i<q;i++){
        ans=0;
        scanf("%d",&k);
        for(int i=0;i<n;i++){
            if(s[i]=='D'){
                d[i+1]=c[min(n,i+k)];
            }
            else{
                d[i+1]=0;
            }
            sum[i+1]=sum[i]+d[i+1];
        }
        for(int i=1;i<n-1;i++){
            if(s[i]=='M'){
                ans+=sum[i]-sum[max(0,i-k+2)]-c[i+1]*(a[i]-a[max(0,i-k+2)]);
            }
        }
        printf("%ld\n",ans);
    }
}

Measured memory_bytes: 24576
#include <stdio.h>

int a[22][22];
int w,h;

int r(int x,int y){
  int rtn = 1;
  a[x][y] = 0;

  if( a[x-1][y  ]==1 ) rtn += r( x-1,y   );
  if( a[x  ][y-1]==1 ) rtn += r( x  ,y-1 );
  if( a[x  ][y+1]==1 ) rtn += r( x  ,y+1 );
  if( a[x+1][y  ]==1 ) rtn += r( x+1,y   );
  return rtn;
}
int main(void){
  int i,j;
  char c;
  int x,y;

  while( 1 ){
    scanf("%d %d ",&w,&h );
    if( !w && !h )
      break;

    for( i=0;i<=h+1;i++){
      for( j=0;j<=w+1;j++ ){
	if( i==0 || i==h+1 || j==0 || j==w+1 ){
	  a[i][j] = 0;
	  continue;
	}

	scanf("%c ",&c );
	if( c=='.' ){
	  a[i][j] = 1;// black
	}else if( c=='#' ){
	  a[i][j] = 0;// red
	} else{
	  a[i][j] = 1;
	  x=i;y=j;
	}
      }
    }

    printf("%d\n",r(x,y) );
  }
  return 0;
}

Measured memory_bytes: 424
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, r = 0, a = 0, b = 0, x = 0;cin >> n;
	for (int i = 0; i < n; i++) {
		string s;cin >> s;
		for (int i = 1; i < s.size(); i++)
			if (s[i - 1] == 'A'&&s[i] == 'B')r++;
		if (s[0] == 'B') b++;
		if (s.back() == 'A') a++;
		if (s[0] == 'B' && s.back() == 'A') x++;
	}
	if (a&&a == x && b == x) r--;
	cout << r + min(a, b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main(){
	int x,a,b;
	cin >> x >> a >> b;  //first x second a
	if (abs(a-x) > abs(b-x)){
		cout << "B" << endl;
	} else {
		cout << "A" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld long double
using namespace std;
ld dp[3001][3001];

int main(void)
{
	int n;
	cin >> n;
	ld p[n + 1];

	for(int i = 1; i <= n; i++)
		cin >> p[i];

	memset(dp, 0, sizeof(dp));

	dp[0][0] = 1;

	for(int i = 1; i <= n; i++)
	{
		for(int j = 0; j <= i; j++)
		{
			if(!j)
				dp[i][j] = dp[i - 1][j]*(1.0 - p[i]);
			else
				dp[i][j] = dp[i - 1][j - 1]*p[i] + dp[i - 1][j]*(1.0 - p[i]);
		}
	}

	ld ans = 0;
	for(int i = n/2 + 1; i <= n; i++)
		ans += dp[n][i];

	cout << setprecision(2*n) << ans << endl;






	return 0;
}

Measured memory_bytes: 141056
<?php
// C
fscanf(STDIN, '%d', $n);
if ($n === 0) {
    echo 0;
    exit;
}
$b = '';
while ($n !== 0) {
    if ($n % 2 !== 0) {
        $b .= '1';
        $n--;
    } else {
        $b .= '0';
    }
    $n = $n / (-2);
}
echo strrev($b);

Measured memory_bytes: 4732
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}


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

	rep(i, 200) {
		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			break;
		}
		a -= d;
		if (a <= 0) {
			cout << "No" << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;
class Main{
  public static void main(String args[]){
    Scanner scan=new Scanner(System.in);
    int n=scan.nextInt();
    int m=scan.nextInt();
    int c=scan.nextInt();
    int b[]=new int[m];
    for(int j=0;j<m;j++) b[j]=scan.nextInt();
    int a[][]=new int[n][m];
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        a[i][j]=scan.nextInt()*b[j];
      }
    }
    int count=0;
    int sum;
    for(int i=0;i<n;i++){
      sum=0;
      for(int j=0;j<m;j++){
        sum=sum+a[i][j];
      }
      if(sum+c>0){
        count+=1;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 23892
import java.util.*;

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

        Set<String> dict = new HashSet<String>();

        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            String command = sc.next();
            String str = sc.next();
            if(command.equals("insert")){
                dict.add(str);
            }else if(command.equals("find")){
                if(dict.contains(str)){
                    System.out.println("yes");
                }else{
                    System.out.println("no");
                }
            }
        }

        sc.close();
    }
}


Measured memory_bytes: 253348