akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
  int n,b,f,r,v;
  int bd[13][11] = {}; 
  int i,j,k;

  scanf("%d",&n);
  for(k=0;k<n;k++)
    {
      scanf("%d %d %d %d",&b,&f,&r,&v);
      bd[(b-1)*3+f][r] += v;
    }
      for(i=1;i<=12;i++)
	{
	  for(j=1;j<=10;j++)
	    {
	      printf(" %d",bd[i][j]);
	    }
	  printf("\n");
	  if(i % 3 == 0 && i != 12)printf("####################\n");
	}
      return 0;
}



Measured memory_bytes: 2140
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	String s = sc.next();
	char[] alp = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
	String ans = "None";
	for(int i=0; i<26; i++) {
		if(!s.contains(String.valueOf(alp[i]))) {
			ans = String.valueOf(alp[i]);
			break;
		}
	}
	System.out.println(ans);
}
}


Measured memory_bytes: 24176
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datN) = readLine.split(" ").map(_.toInt)
    val datA = for(i <- 1 to datN) yield readLine

    val ac = datA.filter(_ == "AC").length
    val wa = datA.filter(_ == "WA").length
    val tle = datA.filter(_ == "TLE").length
    val re = datA.filter(_ == "RE").length

    println("AC x " + ac)
    println("WA x " + wa)
    println("TLE x " + tle)
    println("RE x " + re)

  }
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	string s;

	cin >> s;

	for(int i = 1; i < (int)s.size(); i++){
		if(s[i] == 'C' && s[i-1] == 'A'){
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main (){
    long long r,d,x;
    cin>>r>>d>>x;
    if(d/r>x){
        cout<<x;
        return 0;
    }
    if(d<r){
        cout<<0;
        return 0;
    }
    else{
        cout<<d/r;
        return 0;
    }
      return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	static int pos=0;
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int N=in.nextInt();
		long max=0;
		Stack<Rect> stk=new Stack<>();
		
		for(int i=0;i<N;i++) {
			long h=Long.parseLong(in.next());
			
			if(stk.isEmpty() || h>stk.peek().h) {
				stk.push(new Rect(h,i));
			}
			else if(h<stk.peek().h) {
				max=Math.max(max,createRect(stk,h,i));
				stk.push(new Rect(h,pos));
			}
			
		}
		max=Math.max(max, createRect(stk,0,N));
		
		System.out.println(max);
	}
	
	static long createRect(Stack<Rect> stk,long h,int i) {
		long max=0;
		while(!stk.isEmpty()) {
			Rect crect=stk.peek();
			if(crect.h<h)break;
			
			max=Math.max(max, crect.h*(i-crect.i));
			pos=crect.i;
			stk.pop();
		}
		return max;
	}
	
}

class Rect{
	long h;
	int i;
	Rect(long a,int b){
		h=a;i=b;
	}
}




Measured memory_bytes: 73444
S = [0,0]
T = [0,0]

S[0],S[1],T[0],T[1]= map(int,input().split())

del_x = T[0] - S[0]
del_y = T[1] - S[1]

ans = ''

ans = 'R'*del_x + 'U'*del_y + 'L'*del_x + 'D'*del_y

ans = ans + 'D' + 'R'*(del_x+1) + 'U'*(del_y+1) + 'L'

ans = ans + 'U' + 'L'*(del_x+1) + 'D'*(del_y+1) + 'R'
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;

struct edge{int to, cap, rev;};
vector<edge> G[206];
bool used[206];
int dfs(int v, int t, int f){
	if(v == t)return f;
	used[v] = true;
	for(int i = 0;i < G[v].size();i++){
		edge &e = G[v][i];
		if(!used[e.to] && e.cap > 0){
			int d = dfs(e.to, t, min(f, e.cap));
			if(d > 0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

void add(int v, int u){
	G[v].push_back((edge){u, 1, (int)G[u].size()});
	G[u].push_back((edge){v, 0, (int)G[v].size()-1});
}

int main(){
	int n1, n2, m, v, u, c;
	scanf("%d%d%d", &n1, &n2, &m);
	for(int i = 0;i < m;i++){
		scanf("%d%d", &v, &u);
		add(v, n1+u);
	}
	for(int i = 0;i < n1;i++)add(n1+n2, i);
	for(int i = 0;i < n2;i++)add(n1+i, n1+n2+1);
	
	int flow = 0;
	while(1){
		fill(used, used+206, 0);
		int f = dfs(n1+n2, n1+n2+1, inf);
		if(f == 0)break;
		flow += f;
	}
	
	printf("%d\n", flow);
	return 0;
}


Measured memory_bytes: 3412
n, m = [int(i) for i in input().split()]
wa = [0]*n
ac = [0]*n

for _ in range(m):
    p, s = input().split()
    if s == "WA":
        if ac[int(p)-1] == 0:
            wa[int(p)-1] += 1
    else:
        ac[int(p)-1] += 1

print(n-ac.count(0), sum([wa[i] for i in range(n) if ac[i] >= 1]))


Measured memory_bytes: 51288
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int k;
    vector<int> a;
    cin >> k;
    a.assign(k+1, 1);
    for(int i=1;i<=k;i++){
        cin >> a[i];
    }
    if(a[k] != 2){
        cout << -1 << endl;
        return 0;
    }

    long long mn = 2, mx = 2;
    for(int i=k;i>=1;i--){
        long long dlt = (a[i-1] - mn%a[i-1]) % a[i-1];
        mn += dlt;
        mx = (mx + a[i]-1) / a[i-1] * a[i-1];
        if(mx < mn){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << mn << " " << mx << endl;
}


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

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1001001001;

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

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

    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
}

Measured memory_bytes: 3516
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstring>
#define ll long long
using namespace std;
const int N=200005;
inline int read(){
  int x=0; char ch=getchar();
  for(;!isdigit(ch);ch=getchar());
  for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
  return x;
}
int n,px,py;
ll a[N],ans=1e18,tot,now,mx,mn;
inline void update(){
  if(now<mn) mn=now;
  else if(now>mx) mx=now;
}
inline void solve(){
  for(int i=1;i<=n;i++){
    while(px<i&&a[px+1]*2ll<=a[i]) px++;
    while(py<n&&a[py+1]*2ll<=tot+a[i]) py++;
    for(int u=px+1;u>=px;u--)
      for(int v=py+1;v>=py;v--){
        mx=mn=a[u];
        now=a[i]-a[u],update();
        now=a[v]-a[i],update();
        now=tot-a[v],update();
        ans=min(ans,mx-mn);
      }
  }
}
int main(){
  n=read();
  for(int i=1;i<=n;i++) a[i]=a[i-1]+(ll)read();
  a[n+1]=a[n+2]=tot=a[n];
  solve(),printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
typedef long long ll;
using namespace std;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, k;
	cin >> a >> b >> k;
	int pos = 0;
	for(int i = a; i <= b; i++)
	{
		if(i < a + k)
			cout << i << endl;
		else if(i > b - k)
			cout << i << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
// #define mod 998244353
using namespace std;

void solve()
{
	ll n;
	cin >> n;
	int ans = 0;
	for (ll p = 2; p * p <= n; p++)
	{
		if (n % p)
		{
			continue;
		}
		int count = 0;
		while (n % p == 0)
		{
			n /= p;
			count++;
		}
		int cur = 1;
		while (count)
		{
			if (cur <= count)
			{
				ans++;
				count -= cur;
			}
			else
			{
				count = 0;
			}
			cur++;
		}
	}
	if (n != 1)
	{
		ans++;
	}
	cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	solve();
	return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;



int main(){
  ios_base::sync_with_stdio(false);

  int n;
  int l;
  int r;
  int ans = 0;

  cin >> n;
  for(int i=0;i<n;i++){
    cin >> l >> r;
    ans += r - l + 1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define va vector<long long int> a 
#define vb vector<long long int> b
const ll M = 1e9+7;
const ll inf = 1e18+5;
using namespace std;
void fast(){cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);}
ll bs(ll arr[], ll l, ll r, ll x){
	ll mid=0;
    if (r >= l){
		if (arr[mid] == x) return mid; 
        if (arr[mid] > x) return bs(arr, l, mid - 1, x); 
        return bs(arr, mid + 1, r, x); 
    }
    return -1;
}
ll power(ll x,ul y,ll p){
	ll res = 1;
	x = x % p;
	if(x == 0) return 0;
	while (y > 0){
		if (y & 1) res = (res*x) % p;
		y = y>>1;
		x = (x*x) % p;
		}
	return res;
}
void solve(){
	ll n,w=0,r=0;
	cin>>n;
	string s;
	cin>>s;
	for(ll i=0;i<n;i++) s[i]=='W'?w++:r++;
	if(w==0) cout<<"0\n";
	else if(w==n) cout<<"0\n";
	else{
		ll count=0;
		for(ll i=n-w;i<n;i++) if(s[i]=='W') count++;
		cout<<w-count<<"\n";
	}
 }
int main(){
	fast();
	solve();
	return 0;
}



Measured memory_bytes: 3732
tdlist = lambda i, j, value=0: [[value] * j for _ in range(i)]
n = int(input())
abc = [tuple(map(int, input().split())) for _ in range(n)]
dp = tdlist(n, 3)
dp[0] = list(abc[0])

for i in range(1, n):
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + abc[i][0]
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + abc[i][1]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + abc[i][2]

print(max(dp[n-1]))

Measured memory_bytes: 40256
#include<iostream>
#include<string>
#include<cctype>

using namespace std;

string toUpper( string s ){
  string t = s;
  for ( int i = 0; i < s.size(); i++ ){
   t[i] = toupper(s[i]);
  }
  return t;
}

 int main(){
   string target, source;
 
   cin >> target;
   target = toUpper(target);

   int cnt = 0;

   while(1){
     cin >> source;
     if ( source == "END_OF_TEXT" ) break;
     source = toUpper(source);
     if ( target == source ) cnt++;
 }

  cout << cnt << endl;
  
  return 0;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
/* ちゃんと考えて実装して問題なくACできた時嬉しいよ！！ */

double fact(int n){
    if(n==1) return 1;
    else return n*fact(n-1);
}

int main(void){
    int n;
    cin >> n;
    vector< pair<int,int> > v(n);
    for(int i=0; i<n; i++){
        int x,y;
        cin >> x >> y;
        v[i].first = x;
        v[i].second = y;
    }

    vector<int> num;
    for(int i=0; i<n; i++){
        num.push_back(i);
    }

    double sum = 0;
    do{
        for(int i=0; i<n-1; i++){
            double dx = v[num[i]].first - v[num[i+1]].first;
            double dy = v[num[i]].second - v[num[i+1]].second;
            dx = dx*dx;
            dy = dy*dy;
            sum += sqrt(dx + dy);
        }
    }while(next_permutation(num.begin(), num.end()));


    double ans = sum/fact(n);
    cout << setprecision(15) << ans;

    return 0;
}

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

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

    sort(h.begin(),h.end());
    int ans = h[n-1]-h[0];
    rep(i,n-k+1){
        int hmax = h[i+k-1];
        int hmin = h[i];
        int d = hmax-hmin;
        ans = min(ans,d);
    }

    cout << ans << "\n";
}


Measured memory_bytes: 640
main(){int m,d,s[]={0,31,60,91,121,152,182,213,244,274,305,335};char a[7][9]={"Thurs","Fri","Satur","Sun","Mon","Tues","Wednes"};while(1){scanf("%d %d",&m,&d);if(m==0)break;d+=s[m-1];printf("%sday\n",&a[(d%7==0)?6:(d%7-1)][0]);}return 0;}

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

using namespace std;

int main(){

  int N,M;

  cin >> N >> M;
  
  char A[N][M];
  char B[N][M];

  int total = 0;
  
  for(int i = 0;i < N;++i){
    for(int j = 0;j < M;++j){
      cin >> A[i][j];
    }
  }
  
  for(int i = 0;i < N;++i){
    for(int j = 0;j < M;++j){
      cin >> B[i][j];
      if(A[i][j] != B[i][j])
	total++;
    }
  }

  cout << total << endl;
  
}



Measured memory_bytes: 10900
#include<stdio.h>
#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>
 
 
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;}
 
//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)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(std::string s){
    int l=0,r=s.size()-1;
    int ans=0;
    while(l<r){
        if(s[l]==s[r]){
            l++;r--;
        }
        else if(s[l]!='x' && s[r] != 'x'){ // both l and r is not x;
            if(s[l]!=s[r]){
                cout<<-1<<endl;
                return;
            }
        }else{
            if(s[l]=='x'){
                l++;ans++;
            }
            else if(s[r]=='x'){
                r--;ans++;
            }
        }
    }
    cout<<ans<<endl;
    
}

int main(){
    std::string s;
    std::cin >> s;
    solve(s);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
typedef long long ll;
const int N = 1e5+10;

int main()
{
    double n, k;
    double ans = 0.0;
    cin>>n>>k;
    if(n < k)
    {
        for(int i=1;i<=n;i++)
        {
            ans += pow(0.5, ceil(log2(k / i)));
        }
        ans = ans / n;
    }
    else
    {
        for(int i=1;i<k;i++)
        {
            ans += pow(0.5, ceil(log2(k / i)));
        }
        ans += (n -k + 1);
        ans = ans / n;
    }
    cout<<setprecision(9)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int N,M;
  cin>>N>>M;
  
  int DP[N+1][11],DIS[N+1];
  REP(i,N+1){
    REP(j,11){
      DP[i][j]=0;
    }
    DIS[i]=0;
  }
  
  Graph G(N+1);
  REP(i,M){
    int a,b;
    cin>>a>>b;
    G[a].PB(b);
    G[b].PB(a);
  }
  
  int Q;
  cin>>Q;
  
  int V[Q],D[Q],C[Q];
  REP(i,Q) cin>>V[i]>>D[i]>>C[i];
  
  for(int i=Q-1; i>=0; --i){
    queue<int> Q;
    Q.push(V[i]);
    DIS[V[i]]=D[i];
    
    while(!Q.empty()){
      int v=Q.front();
      Q.pop();
      
      int d=DIS[v];
      if(DP[v][d]>0) continue;
      DP[v][d]=C[i];
      if(d==0) continue;
      while(DP[v][d-1]==0){
        DP[v][d-1]=DP[v][d];
        d--;
        if(d==0) break;
      }
      
      if(DIS[v]>0){
        FORE(nv,G[v]){
          if(DIS[nv]==0) DIS[nv]=DIS[v]-1;
          else chmax(DIS[nv],DIS[v]-1);
          Q.push(nv);
        }
      }
      
      DIS[v]=0;
    }
  }
  
  RREP(i,N){
    co(DP[i][0]);
  }
  return 0;
}

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


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

char grid[810][810];
int dist[810][810];


int main(void) {
	int h, w, k;
	cin >> h >> w >> k;

	rep(i, h)rep(j, w) cin >> grid[i][j];

	int si = 0 , sj = 0;
	rep(i, h)rep(j, w) if (grid[i][j] == 'S') si = i, sj = j;

	queue<int> q;
	rep(i, h) rep(j, w) dist[i][j] = 1 << 20;
	dist[si][sj] = 0, q.push(si), q.push(sj);

	while (!q.empty()) {
		int ci = q.front(); q.pop();
		int cj = q.front(); q.pop();

		rep(d, 4) {
			const int ni = ci + dy[d];
			const int nj = cj + dx[d];
			if (ni < 0 or h <= ni or nj < 0 or w <= nj or grid[ni][nj] == '#') continue;
			if (chmin(dist[ni][nj], dist[ci][cj] + 1)) {
				q.push(ni);
				q.push(nj);
			}
		}
	}

	int ans = 1 << 20;

	rep(i, h)rep(j, w) {
		if (grid[i][j] == '#' or dist[i][j] > k) continue;

		int need = min({i , j , h - 1  - i, w - 1 - j});
		//cerr << i << " " << j << " " << need << endl;

		need = (need + k - 1) / k + 1;

		chmin(ans, need);
	}

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

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define INF LLONG_MAX/3
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int n,m,p[100010],y[100010];
vector<int> vec[100010];
signed main(){
	cin>>n>>m;
	rep(i,m){
		cin>>p[i]>>y[i];
		vec[p[i]].push_back(y[i]);
	}
	for(int i=1;i<=n;i++){
		sort(vec[i].begin(),vec[i].end());
	}
	rep(i,m){
		rep(j,6-to_string(p[i]).size())cout<<0;
		cout<<p[i];
		rep(j,6-to_string(upper_bound(vec[p[i]].begin(),vec[p[i]].end(),y[i])-vec[p[i]].begin()).size())cout<<0;
		cout<<upper_bound(vec[p[i]].begin(),vec[p[i]].end(),y[i])-vec[p[i]].begin()<<endl;
	}
	return 0;
}

Measured memory_bytes: 8576
#include <stdio.h>
#include <string.h>

char t[1001];
int main(int argc, const char * argv[]) {
    int i, n, num;
    
    while(scanf("%s", &t)){
        n=strlen(t);
        num=0;
        
        if (n==1 && t[0]=='0') {
            break;
        }
        
        for(i=0;i<n;i++){
            num+=t[i]-'0';
        }
        printf("%d\n",num);
    }
    return 0;
}



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

using namespace std;

int main()

{

   int n;
   cin>>n;
   string s1,s2;
   cin>>s1>>s2;

   for(int i=0;i<n;i++)
   {
       cout<<s1[i]<<s2[i];
   }
   cout<<endl;











    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;
 
int main()
{
    long long a, b, c, k;
    cin >> a >> b >> c >> k;
    if( k - a <= 0 ){
        cout << k;
    }
    else if( k-a-b <= 0 ){
        cout << a;
    }
    else{
        cout << a - (k-(a+b));
    }
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
    int K,N;
    scanf("%d %d",&N,&K);
    int t=1,i=0;
    double y;
    if(N==0){ printf("%d\n",N);printf("0");return 0;}
    while(t>=0)
    {
        y=pow(K,i);
        t=N-y;
        i++;
    }
    printf("%d\n",i-1);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long Max = -10000001;
        long Min = 10000000;
        long Sum = 0;
            for(int i=0;i<n;i++){
                long a = sc.nextLong();
                Sum += a;
                if(Max<a){
                    Max = a;
                }
                if(Min>a){
                    Min = a;
                }
            }
        System.out.println(Min + " " + Max + " " + Sum);
    }
}


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

int main()
{
    int n;
    cin>>n;
    long long arr[n+5];
    for(int i=0;i<n;i++)cin>>arr[i];
    int counter=0,k=0;
    for(int i=1;i<n;i++)
    {
        if(arr[i]<=arr[i-1])
        {
         counter++;
        }
        else
        {
            k=max(counter,k);
            counter=0;
        }
    }
    k=max(k,counter);
    cout<<k<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int A,B,M;
    cin >> A >> B >> M;
    vec<int> a(A),b(B);
    int minA = 99999999;
    int minB = 99999999;
    rep(i,A) {
        cin >> a[i];
        minA = min(minA, a[i]);
    }
    rep(i,B) {
        cin >> b[i];
        minB = min(minB, b[i]);
    }
    int ans = minA +minB;
    vec<int> x(M),y(M),c(M);
    rep(i,M) {
        int x,y,c;
        cin >> x >> y >> c;
        --x,--y;
        ans = min(ans,a[x]+b[y]-c);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2176
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int main() {
    int c;
    while (cin >> c) {
        if  (c == 1) puts("Hello World");
        else {
            int a, b; cin >> a >> b;
            cout << a + b << endl;
        }
    }
}















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

using namespace std;

int main() {

	int n;
	string tmp;
	set<string> s;

	cin >> n;

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

	cout << s.size() << endl;

}

Measured memory_bytes: 19228
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  vector<int> v(N,0);
  REP(i,N-1){
    int A;
    cin>>A;
    A--;
    v[A]++;
  }
  REP(i,N)cout<<v[i]<<endl;
  return 0;
}


Measured memory_bytes: 4048
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

# 四方向
dy = [0, 0, 1, -1]
dx = [1, -1, 0, 0]
INF = float("inf")

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))

N = int(input())
S = input()
K = int(input())

ssi = S[K-1]

ans = ""

for si in S:
    if si != ssi:
        ans = ans + "*"
    else:
        ans = ans + si

print(ans)

Measured memory_bytes: 3572
import numpy as np

n = int(input())
x,y = np.array([list(map(int,input().split())) for _ in range(n)]).T

# 内積が0以上かどうか
def isin90deg(v1, v2):
    if np.dot(v1, v2) >= 0 : return 1
    else: return 0

# 内積が0かどうか
def is90deg(v1, v2):
    if np.dot(v1, v2) == 0 : return 1
    else: return 0

ans = []
for i in range(n):
    # tangent-vector, normal-vector
    tv, nv1 = np.array([x[i],y[i]]), np.array([y[i],-x[i]])
    nv2 = - nv1
    # tvから時計回り180度エリアにおけるベクトル和を考える
    # ただし、tvに平行なベクトル群（posi/nega）だけ例外処理
    for nv in [nv1, nv2]:
        sum,posi,nega = np.array([0,0]), np.array([0,0]), np.array([0,0])
        for j in range(n):
            v = np.array([x[j],y[j]])
            if isin90deg(v,nv): sum += v
            if is90deg(v,nv) and isin90deg(v,tv): posi += v
            if is90deg(v,nv) and not isin90deg(v,tv): nega += v
        # ユークリッド距離
        ans.append(np.linalg.norm(sum, ord=2))
        ans.append(np.linalg.norm(sum - posi, ord=2))
        ans.append(np.linalg.norm(sum - nega, ord=2))

print(max(ans))




Measured memory_bytes: 14468
/**
*    created: 23.05.2020 03:13:42
**/
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    double t, x;
    cin >> t >> x;
    cout << fixed << setprecision(8);
    cout << t/x << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    int maxn = ((a + b) > (a - b) ? (a+b) : (a-b));
    int ans = (maxn > (a * b) ? maxn : (a*b));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N, T = map(int, input().split())
 
c = []
for i in range(N):
    ci, ti = map(int, input().split())
    c.append([ci, ti])
 
c.sort(key=lambda x:x[0])
 
for i in range(len(c)):
    if c[i][1] <= T:
        print(c[i][0])
        exit()
print('TLE')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <unistd.h>
using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds;
#define ll long long int
//mp.reserve(1024);
//mp.max_load_factor(0.25);
typedef tree<int, null_type, less<int>, rb_tree_tag,
                 tree_order_statistics_node_update>
          ordered_set;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
            x += 0x9e3779b97f4a7c15;
            x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
            x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
            return x ^ (x >> 31);
        }

        size_t operator()(uint64_t x) const {
            static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
            return splitmix64(x + FIXED_RANDOM);
        }
};

void addEdge(vector<ll> adj[], ll u, ll v)
{
   adj[u].push_back(v);
   adj[v].push_back(u);
}
vector<ll> z_function(string s) {
    ll n = s.length();
    vector<ll> z(n);
    for (ll i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}
ll mod=1e9+7;
ll power(ll x,ll y)
{
    ll res = 1; // Initialize result

    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1)
            res = ((res%mod) * (x%mod))%mod;

        // n must be even now
        y = y >> 1; // y = y/2
        x = ((x%mod) * (x%mod))%mod; // Change x to x^2
    }
    return res;
}

int mod1(string num, int a)
{
    // Initialize result
    int res = 0;

    // One by one process all digits of 'num'
    for (int i = 0; i < num.length(); i++)
         res = (res*10 + (int)num[i] - '0') %a;

    return res;
}
int main()
{
 	ios_base::sync_with_stdio(false);
   	cin.tie(NULL);
   	cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output1.txt", "w", stdout);
   ll k;
   cin>>k;
   ll a,b;
   cin>>a>>b;
   ll temp=a/k,temp1=temp+1;
   if((temp*k<=b&&temp*k>=a)||(temp1*k<=b&&temp1*k>=a))
	cout<<"OK"<<endl;
else
	cout<<"NG"<<endl;
	return 0;
}


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

LL mod = 1000000007;

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

	vector<LL> p(n);

	for (auto &e : p) {
		cin >> e;
	}

	LL cur = n+1, cnt = 0;

	for (LL i = 0; i < n; ++i) {
		if (min(p[i], cur) == p[i]) {
			cur = p[i];
			cnt++;
		}
	}
	cout << cnt << "\n";
	
}

Measured memory_bytes: 1920
import java.math.BigInteger;
import java.util.*;

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

        Map<Long, Long> map = new HashMap<>();
        long N = Long.parseLong(sc.next());
        BigInteger K = new BigInteger(sc.next());

        for (int i = 0; i < N; i++) {
            long a = Long.parseLong(sc.next());
            long b = Long.parseLong(sc.next());

            if (!map.containsKey(a)) map.put(a, 0L);

            map.put(a, map.get(a) + b);
        }

        List<Map.Entry<Long, Long>> entries = new ArrayList<>(map.entrySet());
        entries.sort((o1, o2) -> {
            if (o1.getKey() > o2.getKey()) return 1;
            if (o1.getKey() < o2.getKey()) return -1;
            return 0;
        });

        long ans = 0;
        for (Map.Entry<Long, Long> entry : entries) {
            if (K.compareTo(new BigInteger(String.valueOf(entry.getValue()))) <= 0) {
                ans = entry.getKey();
                break;
            } else {
                K = K.subtract(BigInteger.valueOf(entry.getValue()));
            }
        }

        System.out.println(ans);
    }
}


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

public class Main {
    int n;
    long[] a;
    void run() {
        Scanner scan = new Scanner(System.in);
        n = scan.nextInt();
        a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = scan.nextLong();
        }
        long count = 0;
        while(!check()) {
            Arrays.sort(a);
            long add = a[n-1] / n;
            a[n-1] %= n;
            for (int i = 0; i < n-1; i++)
                a[i] += add;
            count += add;
        }
        System.out.println(count);
    }
    boolean check() {
        boolean flg = false;
        for (int i = 0; i < n; i++) {
            if (a[i] >= n) {
                return false;
            } else if (a[i] == n - 1) {
                flg = true;
            }
        }
        return flg;
    }
    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 24660
#include <iostream>
#include <vector>
#include <algorithm>
using i64 = long long;

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

    std::vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) std::cin >> a[i] >> b[i];

    std::sort(a.begin(), a.end());
    std::sort(b.begin(), b.end());

    if (n % 2) {
        std::cout << b[n / 2] - a[n / 2] + 1 << std::endl;
    } else {
        const i64 l = a[n / 2 - 1] + a[n / 2],
            r = b[n / 2 - 1] + b[n / 2];
        std::cout << r - l + 1 << std::endl;
    }

    return 0;
}


Measured memory_bytes: 4780
/*بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم*/

#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <climits>
#include <map>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <vector>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <utility>
#include <queue>

#define ll long long
#define pb  push_back
#define mod  1000000007
#define inf  1000000000000000000
#define pi  acos(-1.0)
#define maxn  1000009
#define sorted(s)  sort(s.begin(),s.end())
#define slc(n) scanf("%I64d", &n)
#define sl(n)  scanf("%lld", &n)
#define sf(n)  scanf("%lf", &n)
#define si(n)  scanf("%d", &n)
#define sch(n)  scanf(" %c", &n)
#define ss(n)  scanf("%s", n)
#define pii  pair <int, int>
#define pll  pair <ll, ll>
#define plp  pair <int, pll >
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()

using namespace std;
ll a, b, w;

int main()
{
      cin>>w>>a>>b;
      cout << max(abs(a-b)-w, (ll)0) << endl;

      return 0;
}

/**look out for SPECIAL CASES**/

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

int gcd(int m, int n);
int a[100010];
int l[100010];
int r[100010];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int j = 0; j < n; j++) {
		if (j == 0) l[j] = a[0];
		else {
			l[j] = gcd(l[j - 1], a[j]);
		}
		if (j == 0) r[j] = a[n - 1];
		else {
			r[j] = gcd(r[j - 1], a[n - 1 - j]);
		}
	}
	int ans = max(l[n - 2], r[n - 2]);
	int tmp;
	for (int k = 1; k < n - 1; k++) {
		tmp = gcd(l[k - 1], r[n - 2 - k]);
		if (tmp > ans) ans = tmp;
	}
	cout << ans << endl;
	cin >> n;
	return 0;
}

int gcd(int m, int n) //ユークリッドの互除法
{
	if ((0 == m) || (0 == n))
		return 0;

	while ((m != n) && ((0 != m) && (0 != n)) )
	{
		if (m > n) m = m % n;
		else    n = n % m;
	}
	return max(m,n);
}

Measured memory_bytes: 1408
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!int;
void scan(Args...)(ref Args args) {
    string[] ss = readln.split;
    foreach (i, ref arg ; args)
        arg = ss[i].parse!int;
}


enum MOD = 10^^9 + 7;
pragma(inline, true)
int mul(long x, long y) {
    return (x * (y % MOD)) % MOD;
}

int[] f;
void make_table(int n) {
    f = new int[n + 1];
    f[0] = f[1] = 1;
    foreach (i ; 2..n+1)
        f[i] = mul(i, f[i-1]);
}

int powmod(S,T,U)(S x, T n, U MOD) {
    int r = 1;
    while (n > 0) {
        if (n & 1) r = mul(r, x);
        x = mul(x, x);
        n >>= 1;
    }
    return r;
}

pragma(inline, true)
int mod_inv(int x) {
    return powmod(x, MOD - 2, MOD);
}

pragma(inline, true)
int comb(int n, int r) {
    if (n - r < 0 || n < 0 || r < 0) return 0;
    return mul(mul(f[n], f[r].mod_inv), f[n - r].mod_inv);
}

void main() {
    int n, k;
    scan(n, k);
    make_table(2010);
    foreach (i; 1..k+1) {
        int x = mul(comb(n-k+1, i), comb(k-1, i-1));
        writeln(x);
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
#define endl "\n"
#define ff first
#define ss second 
#define pb push_back
#define INF ll(1e18)
#define MOD 1000000007
#define debug(x) cout<<x<<"\n";
#define pll pair<ll,ll>
#define mp make_pair
#define Craig ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(v) v.begin(),v.end()
#define MAX 200015
#define vll vector<ll>

int main() 
{ 
    ll i,j=0,x,k=0,d,n,m=0;

    cin>>x>>k>>d;
    if(x<0)x=-x;
    m=x/d;
    ll r=x%d;
    //cout<<r;
    if(abs(d-r) < r)
    {
        r=abs(d-r);
        m++;
    }
    if(m<=k)
    {
        if(m==k || (k-m)%2==0)
            cout<<r<<endl;
        else
        {
            cout<<abs(r-d)<<endl;
        }
    }
    else
    {
        r=x-k*d;
        cout<<r<<endl;
    }

}


Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);
            if (b-a==c-b)
            {
                Console.WriteLine("YES");
            }else
            {
                Console.WriteLine("NO");
            }


        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  for(int i=0;i<1000;i +=111){
  if(i>=N){
    cout<< i <<endl;
    break;
  }
  }
    }

   
  
   


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)



int main(){
  int ans=0;
  int N;
  cin>>N;
  
  string s;
  vector<int> a(4);//1ならB****、2なら****A、3ならB****A
  REP(i,N){
    cin >> s;
    int l=s.length();
    if ((s[0]=='B')&(s[l-1]=='A'))
      a[3]++;
    if ((s[0]=='B')&(s[l-1]!='A'))
      a[1]++;
    if ((s[0]!='B')&(s[l-1]=='A'))
      a[2]++;
    
    REP(j,l){
      if ((s[j]=='A')&(j!=l-1)){
        if (s[j+1]=='B'){
          ans++;
        }
      }
    }
  }
  
  int a3=a[3]-1;
  if (a3<0)
    a3=0;
  a[3]-=a3;
  ans+=a3;//B***Aをつなげる
  
  if (a[3]==1){//ここでB***Aがひとつ残っているじょうたい
    if (a[2]>=1){
      a[2]--;
      ans++;
    }
    if (a[1]>=1){
      a[1]--;
      ans++;
    }
  }
  
  ans+=min(a[1],a[2]);

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int n;
	cin >> n;
	string k, l;
	for(int j=0;j<n;j++) {
		int c = 0, d;
		cin >> k >> l;
		string g = "";
		string a="", b="";
		for (int i = k.length() - 1; i >= 0; i--) 
			a += k[i];
		for (int i = l.length()-1; i >= 0; i--)
			b += l[i];
		for (int i = 0; i < max(a.length(), b.length()) + 1; i++) {
			if (i < min(a.length(), b.length())) {
				int e = (int)a[i] - '0', f = (int)b[i] - '0';
				d = e + f + c;
				if (d >= 10) {
					g += (char)(d - 10) + '0';
					c = 1;
				}
				else {
					g += (char)d + '0';
					c = 0;
				}
			}
			else if (i < a.length()) {
				int e = (char)a[i] - '0';
				e += c;
				if (e >= 10) {
					g += (char)(e - 10) + '0';
					c = 1;
				}
				else {
					g += (char)e + '0';
					c = 0;
				}
			}
			else if (i < b.length()) {
				int e = (char)b[i] - '0';
				e += c;
				if (e >= 10) {
					g += (char)(e - 10) + '0';
					c = 1;
				}
				else {
					g += (char)e + '0';
					c = 0;
				}
			}
			else if (c == 1) {
				g += (char)c + '0';
				c = 0;
			}
		}
		string h = "";
		if (g.length() >= 81)
			cout << "overflow" << endl;
		else {
			for (int i = g.length() - 1; i >= 0; i--)
				h +=g[i];
			cout << h << endl;
		}
	}
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 10005;

string x[MAX_N],y[MAX_N];
string t;
vector<string> v1,v2;
int n;

int main()
{
	scanf("%d",&n);
	rep(i,n){
		cin >> x[i];
		y[i] = x[i];
		rep(j,x[i].length()){
			if(x[i][j] == '?'){
				x[i][j] = 'a';
				y[i][j] = 'z';
			}
		}
		v1.push_back(x[i]);
		v2.push_back(y[i]);
	}
	cin >> t;
	v1.push_back(t);
	v2.push_back(t);
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	int b = upper_bound(v1.begin(),v1.end(),t) - v1.begin();
	int a = lower_bound(v2.begin(),v2.end(),t) - v2.begin();
	for(int i=a;i<b-1;i++){
		printf("%d ",i+1);
	}
	printf("%d\n",b);
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>

int A[500000], c;

int merge(int left, int mid, int right){
  int n1, n2, i, j = 0, k, L[mid], R[right - mid];

  n1 = mid - left;
  n2 = right - mid;

  for(i = 0; i <= n1-1; i++) L[i] = A[left + i];
  for(i = 0; i <= n2-1; i++) R[i] = A[mid + i];
  L[n1] = 1000000001;
  R[n2] = 1000000001;
  i = 0;
  for(k = left; k <= right-1; k++){
    if(L[i] <= R[j]){
      c++;
      A[k] = L[i];
      i = i + 1;
    }
    else{
      c++;
      A[k] = R[j];
      j = j + 1;
    }
  }

}

int mergeSort(int left, int right){
  int mid;
  
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(left, mid);
    mergeSort(mid, right);
    merge(left, mid, right);
  }
}

int main(){
  int i, n;
  
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
  
  mergeSort(0, n);
  
  for(i = 0; i < n; i++){
    printf("%d", A[i]);
    if(i != n-1) printf(" ");
  }
  printf("\n%d\n", c);

  return 0;
}

Measured memory_bytes: 4504
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pint pair<int,int>
using namespace std;

ll dp[400][400],a[400];

ll fun(int s, int e){
	if(s==e)	return 0;
	if(dp[s][e])	return dp[s][e];
	dp[s][e]=1000000000000000000;
	ll sum=0;
	for(int i=s;i<=e;i++){
		sum+=a[i];
	}
	for(int i=s+1;i<=e;i++){
		dp[s][e]=min(dp[s][e],fun(i,e)+fun(s,i-1));
	}
	dp[s][e]+=sum;
	return dp[s][e];
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int i,n;	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	cout<<fun(0,n-1)<<endl;
	return 0;
}

Measured memory_bytes: 1536
//Chandigarh University 
//author:- shivamkr21 (pseduo coders)
#include<bits/stdc++.h>
#define endl "\n"
#define lli long long int
#define vint vector<long long int>
#define vvint vector< vector<long long int> >
#define pubk push_back
#define ppbk pop_back
using namespace std;
int main() {
	lli a,b,c;
	cin>>a>>b;
	if(a==1) {
		if(b==2) {
			cout<<3;
		}
		else if(b==3) {
			cout<<2;
		}
	}
	else if(a==2) {
		if(b==1) {
			cout<<3;
		}
		else if(b==3) {
			cout<<1;
		}
	}
	else if(a==3) {
		if(b==1) {
			cout<<2;
		}
		else if(b==2) {
			cout<<1;
		}
	}
	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 n = sc.nextInt();

        int count = 0;
        int res = 0;
        for (int i = 1; i <= n; i++) {
            int targetNumber = i;
            int tmpCount = 0;
            while (targetNumber % 2 == 0) {
                tmpCount++;
                targetNumber /= 2;
            }

            if (count < tmpCount) {
                res = i;
                count = tmpCount;
            }
        }

        System.out.println(n == 1 ? 1 : res);
    }
}


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

int main(){
    int hlen,mlen;
    cin>>hlen>>mlen;
    int hour,min;
    cin>>hour>>min;
    double h,m;
    double pi=M_PI;
    h=(hour%12)*30+0.5*min;
    m=6*min;
    h=pi*h/180;
    m=pi*m/180;
    double ans=pow(hlen,2)+pow(mlen,2)-2*hlen*mlen*cos(abs(h-m));
    printf("%.10f\n",pow(ans,0.5));
}

Measured memory_bytes: 4288
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    C = [list(map(int, input().split())) for _ in range(3)]

    A = [0] * 3
    B = [0] * 3
    for i in range(3):
        B[i] = C[0][i] - A[0]

    for j in range(3):
        A[j] = C[j][0] - B[0]

    for i in range(3):
        for j in range(3):
            if A[i] + B[j] != C[i][j]:
                print("No")
                break
        else:
            continue
        break
    else:
        print("Yes")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  long x,k,d,xd,ans = 0;
  
  cin >> x >> k >> d;
  
  x = abs(x);
  
  xd = x / d;
  
  if(xd > k)
    xd = k;
  
  if((k - xd) % 2 == 1)
    xd++;
  
  ans = abs(x - d * xd);
  
  cout << ans << endl;
}

Measured memory_bytes: 3592