akhauriyash/Code-Regression huggingface dataset:
n,d = list(map(int, input().strip().split()))
x=[0]*n
y=[0]*n
s=0
for i in range(n):
    x[i],y[i]= list(map(int, input().strip().split()))
for i in range(n):
    if x[i]**2+y[i]**2<=d**2:
        s=s+1
print(s)


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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int[]input = new int[3];
		for (int i=0; i<=2; i++){
			input[i] = sc.nextInt();
		}
		Arrays.sort(input);
		System.out.println(input[2] * 10 + input[1] + input[0]);
	}
}

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

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  vector<int> a(n + 1, 0);
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = k + 1; i <= n; i++) {
    if(a[i - k] < a[i]) cout << "Yes\n";
    else cout << "No\n";
  }
}

Measured memory_bytes: 4064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a > b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a < b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////


//辺を表す構造体:toは行先,capは容量,revは逆
struct edge { int to, cap, rev; };
vector<edge>G[10010];//グラフの隣接リスト表現
bool used[10010];//DFSですでに調べたかのグラフ
				 //fromからtoへ向かう容量capの辺をグラフに追加する
void add_edge(int from, int to, int cap) {
	G[from].push_back(edge{ to, cap,(int)G[to].size() });
	G[to].push_back(edge{ from,0,(int)G[from].size() - 1 });
}
//増加パスをDFSで探す.
//sからtへ移動可能ならそのルートの最大流用を返し不可能なら0を返す。
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;
}
//sからtへの最大流量を返す
int max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, INF);
		if (f == 0) {
			return flow;
		}
		flow += f;
	}
}
int main() {
	int N, K, E;
	cin >> N >> K >> E;
	bool can[110][110];//can[i][j]:=コンピュータiが仕事jをこなせる
	REP(i, 110)REP(j, 110)can[i][j] = false;
	//0～N-1:コンピュータに対応する頂点
	//N～N+K-1:仕事に対応する頂点
	int s = N + K, t = s + 1;
	//sとコンピュータを結ぶ
	for (int i = 0; i < N; ++i) {
		add_edge(s, i, 1);
	}
	//仕事とtを結ぶ
	for (int i = 0; i < K; ++i) {
		add_edge(N + i, t, 1);
	}
	REP(i, E) {
		int x, y;
		cin >> x >> y;
		can[x][y] = true;
	}
	//コンピュータと仕事を結ぶ
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < K; ++j) {
			if (can[i][j]) {
				add_edge(i, N + j, 1);
			}
		}
	}
	cout << max_flow(s, t) << endl;
	return 0;
}


Measured memory_bytes: 3628
def solve():
    N, M = [int(i) for i in input().split()]
    R = [[] for _ in range(N)]
    for _ in range(M):
        a, b = [int(i) for i in input().split()]
        R[a - 1].append(b)
        R[b - 1].append(a)
    for r in R:
        print(len(r))

if __name__ == "__main__":
    solve()

Measured memory_bytes: 62400
#include <cstdio>

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

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

    for (int i = n - 1; i >= 0; i--)
    {
        printf("%d", a[i]);
        if (i != 0)
            printf(" ");
    }
    printf("\n");

    return NULL;
}


Measured memory_bytes: 2676
def main():
  def make_divisors(n):
      divisors = []
      for i in range(1, int(n**0.5)+1):
          if n % i == 0:
              divisors.append(i)
              if i != n // i:
                  divisors.append(n//i)
      divisors.sort()
      return divisors

  n = int(input())
  l = make_divisors(n)
  ans = make_divisors(n-1)
  for i in l:
    m=n
    if i==1:
      continue
    else:
      while(m%i==0):
        m//=i
    if m==1:
      ans.append(i)
    else:
      if i in make_divisors(m-1):
        ans.append(i)
  ans=set(ans)
  print(len(ans)-1)  

if __name__ == "__main__":
  main()

Measured memory_bytes: 41324
var n,i,j,ans:longint;
var a,r,b:array[0..1000] of longint;
var f:array[0..1000,0..1000] of longint;
procedure dfs(d:longint);
var i,j:longint;
var a1:int64;
begin
  if d>n then begin
  a1:=1;
    for i:=1 to n do
    begin if abs(a[i]-b[i])>1 then exit;a1:=a1*a[i];end;
 if a1 mod 2=0 then     inc(ans);
    exit;
  end;
    a[d]:=b[d];dfs(d+1);
    a[d]:=b[d]-1;dfs(d+1);
    a[d]:=b[d]+1;dfs(d+1);
end;
begin
  read(n);
  for i:=1 to n do read(b[i]);dfs(1);
  writeln(ans);
end.

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


int main(){
    // Your code here!
    int n;
    
    cin >> n;
    
    vector<int> a(n);
    
    int count = 0;
    int sacrifice = pow(10,9)+1;
    long int ans = 0;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        ans=ans+abs(a[i]);
        if (a[i]<0) {
            count++;
        }
        sacrifice = min(abs(a[i]),sacrifice);
        
    }
    
    if (count%2==1) {
        cout << ans-2*sacrifice << endl;
    } else {
        cout << ans << endl;
    }
    
    return 0;
}


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

bool is_pow2( int x)
{
    if (x == 0) {
        return false;
    }
    return (x & (x - 1)) == 0;
}

int main(void){
    
  int N;
  cin >> N;
  for(int i=N;i>=1;i--){
      if(is_pow2(i)){
          cout << i << endl;
          break;
      }
  }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
int main() 
{
    long long n,a,b;
    cin >> n >> a >> b;
    
  	if(a+b==0){
      cout << 0 << endl;
      return 0;
    }
    if(n%(a+b)>a){
        cout << n/(a+b)*a+a;
    }else{
        cout << n/(a+b)*a+n%(a+b);
    }

}

Measured memory_bytes: 256
D,G=map(int,input().split())
l=[list(map(int,input().split())) for i in range(D)]

ans=1000
for i in range(1<<D):
    # print(bin(i))
    score=0
    problem=0
    highest=0
    for j in range(D):
        if ((i>>j)&1)==1:
            score+=l[j][1]+(j+1)*l[j][0]*100    # 素点
            # print('complete:',l[j][1]+(j+1)*l[j][0]*100)
            problem+=l[j][0]
            # print('s:',score,'P:',problem)
        else:
            highest=max(highest,j)
    if score<G and i!=(1<<D)-1:
        for k in range(l[highest][0]+1):
            score+=(highest+1)*100
            problem+=1
            # print('s:',score,'P:',problem)
            if score>=G:
                # print('ANS1')
                # print('s:',score,'P:',problem)
                ans=min(ans,problem)
    elif score>=G:
        ans=min(ans,problem)
        # print('G:',G)
        # print('ANS2')
        # print('s:',score,'P:',problem)

print(ans)

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

typedef long long int ll;

ll absl(ll n)
{
	if(n<0)
	{
		return -1*n;
	}
	return n;
}
int main()
{
	ll n,i,a,b,c;
	cin>>n;
	ll maxa,maxb,maxc;
	maxa=maxb=maxc=0;
	for(i=0;i<n;i++)
	{
		cin>>a>>b>>c;
		ll na=a+max(maxb,maxc);
		ll nb=b+max(maxa,maxc);
		ll nc=c+max(maxa,maxb);
		maxa=na;
		maxb=nb;
		maxc=nc;
	}
	cout<<max(maxa,max(maxb,maxc));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int cnt=0,ans=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='A')
        {
            cnt=i;
            break;
        }
    }
    for(int i=s.size()-1;i>=0;i--)
    {
        if(s[i]=='Z')
        {
            ans=i+1;
            break;
        }
    }
    cout<<(ans-cnt)<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

using namespace std;

constexpr int Z = 1e9+7;

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

    int s;
    cin >> s;

    int dp[s+1];
    fill(dp, dp + s + 1, 0);
    dp[0] = 1;
    for (int i = 1; i <= s; i++) {
        for (int j = 0; j <= i - 3; j++) {
            dp[i] = (dp[i] + dp[j]) % Z;
        }
    }

    cout << dp[s] << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

ll n;
vl a, b;
queue<ll> q;

void f(ll i) {
  bool ok;
  if(i == 0) {
    ll m = b[n - 1] + b[1];
    ok = b[0] - a[0] >= m;
  } else if(i == n - 1) {
    ll m = b[n - 2] + b[0];
    ok = b[n - 1] - a[n - 1] >= m;
  } else {
    ll m = b[i - 1] + b[i + 1];
    ok = b[i] - a[i] >= m;
  }
  if(ok) q.push(i);
}

int main() {
  cin >> n;
  a.resize(n);
  b.resize(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) f(i);
  ll ans = 0;
  while(!q.empty()) {
    ll i = q.front();
    q.pop();
    if(i == 0) {
      ll m = b[n - 1] + b[1];
      ans += (b[i] - a[i]) / m;
      ll r = (b[i] - a[i]) % m;
      b[i] = a[i] + r;
      f(n - 1);
      f(1);
    } else if(i == n - 1) {
      ll m = b[n - 2] + b[0];
      ans += (b[i] - a[i]) / m;
      ll r = (b[i] - a[i]) % m;
      b[i] = a[i] + r;
      f(n - 2);
      f(0);
    } else {
      ll m = b[i - 1] + b[i + 1];
      ans += (b[i] - a[i]) / m;
      ll r = (b[i] - a[i]) % m;
      b[i] = a[i] + r;
      f(i - 1);
      f(i + 1);
    }
  }
  bool ok = true;
  rep(i, n) if(a[i] != b[i]) ok = false;
  if(ok)
    cout << ans << endl;
  else
    cout << -1 << endl;
}

Measured memory_bytes: 7088
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N+1];
        for (int i = 1; i < N+1; i++) {
            a[i] = sc.nextInt();
        }
        int[] hako = new int[N+1];
        List<Integer> dolist = new ArrayList<>();
        for (int i = N; i >= 1; i--) {
            if (!goodState(hako, i, a[i])) {
                dolist.add(i);
                hako[i] = 1;
            }
        }
        System.out.println(dolist.size());
        for (Integer e : dolist) {
            System.out.print(e + " ");
        }
    }

    public static boolean goodState(int[] hako, int n, int amari) {
        int size = hako.length;
        int index = n;
        int bai = 1;
        int count = 0;
        while (index < size) {
            if (hako[index] == 1) {
                count = (count + 1) % 2;
            }
            bai++;
            index = n*bai;
        }
        if (count == amari) {
            return true;
        } else {
            return false;
        }
    }
}

Measured memory_bytes: 93780
#include <iostream>
#include <string>
#include <map>
#include <vector>
#define int long long
using namespace std;
typedef pair<string, string> P;

int n;
string s;
map<P, int> dp;

int dfs(int dep, string x, string y) {
	if (dep == 2 * n) return 1;
	if (dp.find(P(x, y)) != dp.end()) return dp[P(x, y)];
	
	int ret = 0;
	if (x.length() < n && (y.length() < n - x.length() || y[n - x.length() - 1] == s[dep])) {
		ret += dfs(dep + 1, x + s[dep], y);
	}
	if (y.length() < n && (x.length() < n - y.length() || x[n - y.length() - 1] == s[dep])) {
		ret += dfs(dep + 1, x, y + s[dep]);
	}
	return dp[P(x, y)] = ret;
}

signed main() {
	cin >> n >> s;
	cout << dfs(0, "", "") << endl;
	return 0;
}

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

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

    // 0+1+2+3+...+(a-1) < N <= 0+1+2+3+...+(a-1)+a
    // となるaを求める (a >= 1)

    // 1+2+3+...+(a-1)+a == N のとき
    // (1+a) * a == N * 2
    // a^2 + a - 2N == 0
    //     -1 + pow(1 + 8N, 0.5)
    // a = ---------------------
    //               2

    int a = (pow(N * 8 + 1, 0.5) - 1) / 2 + 1;
    int remove_question = (1 + a) * a / 2 - N; // 解かなくていい問題

    for (int i = 1; i <= a; i++)
    {
        if (i == remove_question) continue;
        else cout << i << endl;
    }
    return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    ll MinMove = min({a, b, c, d, e});
    ll ans = (n+MinMove-1)/MinMove+4;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,m = [int(x) for x in input().split()]
ans = [0]*(n+1)
w = [0]*(n+1)
for _ in range(m):
    a,b = input().split()
    a = int(a)
    if ans[a] == 1:
        continue
    if b == "AC":
        ans[a] = 1
    else:
        w[a] += 1

aa = 0
ww = 0
for i in range(1,n+1):
    if ans[i]==1:
        aa += 1
        ww += w[i]
print(aa,ww)


Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll div_ceil(ll, ll);

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

int main() {
  ll N, M;
  std::cin >> N >> M;
  ll a[M];
  REP(i, M) std::cin >> a[i];
  bool NG = false;
  REP(i, M - 1) {
    if (a[i] == a[i + 1]) {
      NG = true;
    }
  }
  if (NG) {
    std::cout << 0 << '\n';
  } else {
    ll dp[N + 2];
    dp[0] = 0;
    dp[1] = 1;
    REP(i, M) dp[a[i] + 1] = -1;
    REP(i, N + 2) {
      if (i > 1) {
        if (dp[i] == -1) {
          dp[i] = 0;
        } else {
          dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
        }
      }
    }
    std::cout << dp[N + 1] << '\n';
  }
}

ll div_ceil(ll a, ll b) {
  ll quotient = a / b;
  ll remainder = a % b;
  if (remainder == 0) {
    return quotient;
  } else {
    return quotient + 1;
  }
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
typedef long long ll;
typedef double db;
const int MX=100005;
const int mod=1000000007;
const int inf=1e9;
int dp[MX][5],a[MX][5],n;
int ok(int i, int k)
{
    if(i>n)return 0;
    if(~dp[i][k])return dp[i][k];
    int mx=0;
    for(int j=1;j<=3;j++)
    {
        if(j==k)continue;
        mx=max(mx,a[i][j]+ok(i+1,j));
    }
    return dp[i][k]=mx;
}
int main()
{
    FasterIO;
    int i,j,k;
    cin>>n;
    for(i=1;i<=n;i++)cin>>a[i][1]>>a[i][2]>>a[i][3];
    memset(dp,-1,sizeof(dp));
    int res=max(ok(1,1),max(ok(1,2),ok(1,3)));
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 12032
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<string>
#include<set>
//int mod(int a,int b,int d);

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

int main() {
  string s;
  cin >> s;
  int c=0;
  int cm=0;
  rep(i,3){
    if(s[i]=='R'){
      c++;
      cm=c;
    }else{
      c=0;
    }
  }
  cout<<cm<<endl;
      



}

Measured memory_bytes: 3620
#-----------にゃんにゃん準備-----------#
def nyan(f=lambda x: x): return map(f,input().split())
def nyannyan(f=lambda x: x,i=0):
    if i==0: return list(map(f,input().split()))
    l = []
    for j in range(i): l.append(f(input()))
    return l
#------------にゃんにゃん------------#
w,h,x,y = nyan(int)
if x==w/2 and y==h/2:
	k=1
else:
	k=0
print(str((w*h)/2)+" "+str(k))
#---------にゃんにゃんおしまい---------#

Measured memory_bytes: 3064
fun main(){
    val k = readLine()!!.toInt()
    val flags = Array(1000000) {i->false}
    var c = 1
    var r = 7

    if (k %2 == 0 || k %5 == 0) {
        print(-1)
        return
    }

    while(true){
        val n = r % k
        if (flags[n]) {
            print(-1)
            return
        }
        if (n == 0) {
            print(c)
            return
        } else {
            c++
            flags[n] = true
            r = n*10 + 7
        }
    }
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(max(a*c,a*d),max(b*c,b*d));
}


Measured memory_bytes: 3624
#include<stdio.h>
main(){
  
  int a,b,c,d,num,ans=0;
  
  while(scanf("%d",&num)!=EOF){
    
    for(a=0;a<=9;a++){
      for(b=0;b<=9;b++){
	for(c=0;c<=9;c++){
	  for(d=0;d<=9;d++){
	    if(a+b+c+d==num){
	      ans=ans+1;
	    }
	  }
	}
      }
    }
    
    printf("%d\n",ans);
    ans=0;
  }
  return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

const int INF = 1e9;
typedef pair<int, int> P;
const int MAX_N = 100;
char maze[MAX_N][MAX_N];
int d[MAX_N][MAX_N];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

int bfs(int h, int w, int sx, int sy) {
    queue<P> que;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) d[i][j] = INF;
    }
    que.push(P(sx,sy));
    d[sx][sy] = 0;
    int max_path = 0;
    
    while(que.size()) {
        P p = que.front(); que.pop();
        // if (p.first == gx && p.second == gy) break;
        for (int i = 0; i < 4; i++) {
            int nx = p.first + dx[i], ny = p.second + dy[i];
            if (0 <= nx && nx < h && 0 <= ny && ny < w && maze[nx][ny] != '#' && d[nx][ny] == INF) {
                que.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second] + 1;
                if (max_path < d[nx][ny]) max_path = d[nx][ny];
            }
        }
    }
    return max_path;
}

void solve() {
    int h,w; cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> maze[i][j];
        }
    }
    int max_path = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (maze[i][j] == '.') max_path = max(max_path, bfs(h, w, i, j));
        }
    }
    cout << max_path << "\n";
}


int main() {
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 100000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N, K;
  cin >> N >> K;
  ll gcd;
  ll M = 0;
  for (ll i = 0; i < N; ++i) {
    ll a;
    cin >> a;
    if (a > M) {
      M = a;
    }
    if (i == 0) {
      gcd = a;
    }
    else {
      gcd = __gcd(gcd, a);
    }
  }
  if (K % gcd == 0 && M >= K) {
    cout << "POSSIBLE" << endl;
  }
  else {
    cout << "IMPOSSIBLE" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

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

        for(;;){
            String s = scan.nextLine();
            if(s.equals(".")) break;

            boolean ans = true;
            Deque<Character> data = new ArrayDeque<Character>();

            for(int i = 0; i < s.length(); i++) {
                if(s.charAt(i) == '(') data.addLast('(');
                else if(s.charAt(i) == ')') {
                    if(data.peekLast() == null) {
                        ans = false;
                        break;
                    }
                    if(data.getLast() == '(') {
                        data.removeLast();
                    } else {
                        ans = false;
                        break;
                    }
                }
                else if(s.charAt(i) == '[') data.addLast('[');
                else if(s.charAt(i) == ']') {
                    if(data.peekLast() == null) {
                        ans = false;
                        break;
                    }
                    if(data.getLast() == '[') {
                        data.removeLast();
                    } else {
                        ans = false;
                        break;
                    }
                }
            }
            
            if(data.peekLast() != null) ans = false;

            if(ans) System.out.println("yes");
            else System.out.println("no");
        }
    }
}


Measured memory_bytes: 44824
import java.io.*;

class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        int n, m;
        String[] str;

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        str = br.readLine().split(" ");
        n = Integer.parseInt(str[0]);
        m = Integer.parseInt(str[1]);

        int[][] arr = new int[n][m];
        int[] vec = new int[m];
        int[] ans = new int[n];

        for(int i = 0; i < n; i++){
            String[] str2 = br.readLine().split(" ");
            for(int j = 0; j < m; j++){
                arr[i][j] = Integer.parseInt(str2[j]);
            }
        }

        for(int i = 0; i < m; i++){
            vec[i] = Integer.parseInt(br.readLine());
        }

        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                ans[i] += arr[i][j]*vec[j];
            }
        }

        for(int num : ans){
            System.out.println(num);
        }
    }
}

Measured memory_bytes: 27788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)n);i++)
#define rep1(i,n) for(int i=1;i<=((int)n);i++)
typedef long long ll;
 
int l[15];
int n;
int main()
{
    while(cin>>n)
    {
        ll sum=0;
        rep(i,n)
        {
            cin>>l[i];
            sum+=l[i];
        }
        sort(l,l+n);
        if(sum>2*l[n-1]) cout<<"Yes\n";
        else cout<<"No\n";
 
    }
	return 0;
}

Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int64_t A,V,B,W,T;

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> A>>V>>B>>W>>T;

    if (V <= W) {
        out << "NO" << endl; return 0;
    }

    V -= W;
    if (std::abs(A - B) > V * T) {
        out << "NO" << endl; return 0;
    }
    out << "YES" << endl; return 0;

    return 0;
}
#endif


Measured memory_bytes: 3124
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<algorithm>
#include<string>
#include<utility>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cstdlib>
#include<cstdio>
using namespace std;

#define N 50002

bool is_prime[N];

void sieve(){
	memset(is_prime,1,sizeof(is_prime));
	is_prime[0] = is_prime[1] = false;
	for(int x=2;x<N;++x){
		if(is_prime[x]){
			for(int i=x+x;i<N;i+=x){
				is_prime[i] = false;
			}
		}
	}
}


int main(){
	sieve();
	int j;
	while(scanf("%d",&j) != EOF , j){
		int t = 0;
		map<pair<int,int>,int> table;
		for(int x=2;x<=j;++x){
			if( is_prime[x] && is_prime[j-x] ){
				table[make_pair(min(x,j-x),max(x,j-x))] = 100;
			}
		}
		printf("%d\n",table.size());
	}
	return 0;
}

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

using namespace std;

#ifdef NeverBeRed
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second



int main()
{
	#ifdef TurnRed
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

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

	ll n;
	cin >> n;
	vector<ll> a(n+1);
	for (auto &i : a) cin >> i;

	if (n == 0 && a[0] == 1)
	{
		cout << "1\n";
		return 0;
	}

	if (a[0] != 0)
	{
		cout << "-1\n";
		return 0;
	}

	auto ac = a;
	for (int i = n-1; i > 0; --i)
		ac[i] += ac[i+1];

	ac.push_back(0);
	ll ans = 1;
	ll x = min(2LL, ac[1]);
	for (int i = 1; i <= n; ++i)
	{
		if (a[i] > x)
		{
			cout << "-1\n";
			return 0;
		}
		ans += x;
		x -= a[i];
		x = min(2*x, ac[i+1]);
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 5540
#include <iostream>
using namespace std;
int main(void){
  int a[26]={};
  string s;
  cin >> s;
  for(int i=0; i<s.size(); i++){
    for(int j=0; j<26; j++){
      if(s[i]=='a'+j){
        a[j]++;
      }
    }
  }
  for(int i=0; i<26; i++){
    if(a[i] == 0){
      cout << (char)(i+'a') << endl;
        return 0;
    }
  }
  cout << "None" << endl;
  return 0; 
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repr(i, a, b) for (int i = a; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define sz(a) (a).size()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
using namespace std;
using pii = pair<int, int>;
constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr double EPS = 1e-10;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N;
  int a[100010];
  cin >> N;
  rep(i, 0, N) cin >> a[i];
  int flag = 1;
  rep(i, 0, N) {
    if (a[i] & 1) flag = 0;
  }
  cout << (flag ? "second" : "first") << endl;

  return 0;
}

Measured memory_bytes: 1024
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))
ans = 10**6
te = 0
I = int()
for i in range(N):
    te = T-H[i]*0.006
    if abs(A-te) < ans:
        ans = abs(A-te)
        I = i
print(I+1)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;

#define pb push_back
#define F  first
#define S  second
#define int ll
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define edl "\n"
#define ceils(s,n) (s+n-1)/n
#define str string
#define add insert
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MOD = 1e9 + 7, N = 5e5 + 10;
const ll LINF = LLONG_MAX;
string s[30];
int h,w;
int dist[30][30];

bool is_pos(int i,int j){
   return i<h and j<w and i>=0 and j>=0 and s[i][j] == '.';
}

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   cin >> h >> w;
   f(i,0,h){
      cin>>s[i];
   }
   int ans = 0;
   f(i,0,h){
      f(j,0,w){
         if(s[i][j]=='.'){
            set<array<int,3>> q;
            int mx = 0;
            q.insert({0,i,j});
            vector<vector<int>> dist(h,vector<int>(w,MOD));
            dist[i][j] = 0;
            while(!q.empty()){
               auto v = *q.begin();
               q.erase(q.begin());
               int ff = v[1];
               int ss = v[2];
               vector<pa> itr = {{ff+1,ss},{ff-1,ss},{ff,ss+1},{ff,ss-1}};
               for(auto e : itr){
                  if(is_pos(e.F,e.S)){
                     if(dist[ff][ss]+1<dist[e.F][e.S]){
                        q.erase({dist[e.F][e.S],e.F,e.S});
                        dist[e.F][e.S] = dist[ff][ss]+1;
                        mx = max(mx,dist[e.F][e.S]);
                        q.insert({dist[e.F][e.S],e.F,e.S});
                     }
                  }
               }
            }
            ans = max(ans,mx);
         }
      }
   }
   cout<<ans<<edl;
   return 0;
}

Measured memory_bytes: 256
let () =
  Scanf.scanf "%d\n" @@ fun n ->
  let vrr = Array.init n @@ fun _ -> Scanf.scanf "%f " @@ fun d -> d in
  let _ = Array.fast_sort compare vrr in
  let lst = Array.to_list vrr in
  let ans = List.fold_left (fun ans x -> (ans +. x) /. 2.) (List.hd lst) (List.tl lst) in
  Printf.printf "%.5f\n" ans

Measured memory_bytes: 3924
#include <stdio.h>
#define H 250

struct a{
  int id;
  int k;
  int pk;
  int lk;
  int rk;  
};

int main()
{
  struct a node[H];
  int i, h;

  scanf("%d",&h);
  for(i=0;i<h;i++){
    scanf("%d",&node[i].k);
    node[i].id=i+1;
  }

  for(i=0;i<h;i++){
    if(i!=0){
      node[i].pk=node[node[i].id/2-1].k;
    }
    if((i+1)*2<=h){
      node[i].lk=node[2*node[i].id-1].k;
    }
    if((i+1)*2+1<=h){
      node[i].rk=node[2*node[i].id].k;
    }
  }

  for(i=0;i<h;i++){
    if(i==0) printf("node %d: key = %d, left key = %d, right key = %d, \n", i+1, node[i].k, node[i].lk, node[i].rk);
    
    else if((i+1)*2>h) printf("node %d: key = %d, parent key = %d, \n", i+1, node[i].k, node[i].pk);
    
    else if((i+1)*2+1>h) printf("node %d: key = %d, parent key = %d, left key = %d, \n", i+1, node[i].k, node[i].pk, node[i].lk);
    
    else printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, \n",i+1,node[i].k, node[i].pk, node[i].lk,node[i].rk);
  }
  return 0;
}



Measured memory_bytes: 2076
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
using namespace std;
const int mod = 1000000007;


int main(){
    int N,M,sum=0;
    cin>>N>>M;
   // vector<int> A(M);
    for(int i=0; i<M; i++){
        int a=0;
        cin>>a;
        sum+=a;
    }
if(sum>N)cout<<-1<<endl;
    else cout<< N-sum <<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int n;
    cin >> n;
    map<string, int> mp;
    REP(i,n){
        string s;
        cin >> s;
        mp[s]++;
    }
    int ma = 0;
    for (auto p : mp) chmax(ma, p.second);
    vector<string> ans;
    for (auto p : mp) if (p.second == ma) ans.push_back(p.first);
    sort(ALL(ans));
    for (string s : ans) cout << s << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

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

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    Vec a(n);
    rep(i,n){
        cin>>a[i];
    }
    ll ans = a[0];
    rep(i,n){
        if(i==0)continue;
        ans = __gcd(ans,a[i]);
    }
    cout<<ans<<endl;
    return  0;
}


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

int main() {
  int a,b,t;
  cin >> a >> b >> t;
  cout << t/a*b << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	/*if (A == 3||A ==5||A==7) {
		cout << "YES" << endl;
	}
	/*else if (A == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (A == 25) {
		cout << "Christmas" << endl;
	}
	else if (A == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}
	else {*/
	cout << A+(B/2) << endl;
//}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

 
//FUNCTION
 
//-----CODE------//
class DisjointSet{
  public:
  vector<int> rank,p;
  DisjointSet(){}
  DisjointSet(int size)
  {
    rank.resize(size,0);
    p.resize(size,0);
    for (int i = 0; i < size; i++)
    {
      makeSet(i);
    }
  }
void makeSet(int x)
{
  p[x] = x;
  rank[x] = 0;
}

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

void unite(int x, int y)
{
  link(findSet(x),findSet(y));
}
void link(int x, int y)
{
  if(rank[x] > rank[y])
  {
    p[y] = p[x];
  }
  else
  {
    p[x] = p[y];
  }
  if(rank[x] == rank[y])
  {
    rank[y]++;
  }
}
  int findSet(int x)
  {
    if(x != p[x])
    {
      p[x] = findSet(p[x]);
    }
    return p[x];
  }
};

//SOLVE
void solve(void)
{
  int N,M;
  cin>>N>>M;
  vector<pair<int,int> > vp;
  for (int i = 0; i < M; i++)
  {
    int A,B;
    cin>>A>>B;
    A--;B--;
    vp.emplace_back(A,B);
  }
  int ANS =0;
  for (int i = 0; i < M; i++)
  {
    DisjointSet uf(N);
    for (int j = 0; j < M; j++)
    {
      if(i == j)continue;
      uf.unite(vp[j].first,vp[j].second);
    }
    bool ok = 1;
    for (int i = 0; i < N; i++)
    {
      /* code */
    }
    
    for (int i = 0; i < N-1; i++)
    {
      if(!uf.same(i,i+1))ok = 0;
    }
    // DEBUG(uf.p);
    if(ok == 0)ANS++;    
  }
  cout<<ANS<<endl;
  
  

  
    
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
def extract(i)
  left = i*2
  right = i*2 + 1
  length = A.length

  if left < length && A[left] > A[i]
    @largest = left
  else
    @largest = i
  end

  if right < length && A[right] > A[@largest]
    @largest = right
  end

  if @largest != i
    A[i], A[@largest] = A[@largest], A[i]
    extract(@largest)
  end
end

def insert(i)
  parent = i/2
  return if parent == 0

  if A[i] > A[parent]
    A[i], A[parent] = A[parent], A[i]
    insert(parent)
  end
end

A = [nil]

until (input=gets.chomp) == "end"
  if input == "extract"
    puts A[1]
    A[1] = A.pop
    extract(1)
  else
    input = input.split(" ")
    A << input[1].to_i
    insert(A.length-1)
  end
end



Measured memory_bytes: 14808
#include <iostream>
#include <stack>
#include <cstring>
using namespace std;

const int size = 101;
string line;
stack <char> S;

bool dfs( int i ) {
    if ( i == line.size() ) return S.empty();
    if ( line[i] == '(' || line[i] == '[' ) {
        S.push( line[i] );
    } else if ( line[i] == ')' || line[i] == ']' ) {
        if ( S.empty() ) return false;
        if ( S.top() == '(' && line[i] == ']' ) return false;
        if ( S.top() == '[' && line[i] == ')' ) return false;
        S.pop();
    }
    return dfs( i+1 );
}

int main() {
    while ( getline( cin, line ) && line != "." ) {
        S = stack<char>();
        bool result = dfs( 0 );
        cout << ( result ? "yes" : "no" ) << endl;
    }
    return 0;
}

Measured memory_bytes: 908
n, c, k = map(int,input().split())
T = sorted([int(input()) for _ in range(n)])
num = 0
count = 0
h0 = T[0]
h = T[0]+k
l = [0]
for i in range(n):
  if h0 <= T[i] <= h and num < c:
    num += 1
  elif num >= c or T[i] > h:
    num = 1
    l.append(count)
    h0 = T[i]
    h = T[i]+k
print(len(l))

Measured memory_bytes: 8280
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(){
  int n;
  long sumSquare;
  int sum,temp,i;
  double ans;
  while(1){
    cin>>n;
    if (n==0)break;
    sum=0;
    sumSquare=0.0;
    for (i=0;i<n;i++){
      cin>>temp;
      sumSquare+=temp*temp;
      sum+=temp;
    }
    ans=sqrt(1.0*sumSquare/n-(1.0*sum/n)*(1.0*sum/n));
    cout<<fixed<<ans<<endl;
  }
}



Measured memory_bytes: 3268
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
a,b,c,d = gets.chomp.split.map(&:to_i)

while true
  c -= b
  if c <= 0
    puts 'Yes'
    exit
  end
  a -= d
  if a <= 0
    puts 'No'
    exit
  end

end

Measured memory_bytes: 14612
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#define endl '\n'
#define ll long long
#define pb push_back
#define PI acos(-1)
#define RUN_FAST ios::sync_with_stdio(false);
#define sz 500010
using namespace std;

int main()
{
    RUN_FAST;
    int n, tmp;
    cin>> n;
    if (n%1000==0) cout << 0 << endl;
    else {
        tmp=n%1000;
        cout << 1000-tmp << endl;
    }
}


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

const int N = 1e5+7;
long long dp[N], x[N], premin[N];

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

    int n, m, T;
    cin>>n>>m>>T;
    premin[0] = 1e18;

    for (int i=1; i<=n; i++) {
        cin>>x[i];
        premin[i] = min(dp[i-1]-2*x[i], premin[i-1]);

        int idx = upper_bound(x+1, x+i, x[i]-(T+1)/2)-x-1;
        dp[i] = min(premin[idx]+2*x[i], dp[idx]+T);
//        cout<<i<<" "<<x[i]<<" --> "<<dp[i-1]-2*x[i]<<" "<<premin[i]<<" \t "<<x[i]-T/2<<" "<<idx<<" \t= "<<dp[i]<<endl;

    }
    cout<<dp[n]+m<<endl;
}


Measured memory_bytes: 6000
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int n;
    cin>>n;
    int i;
    int h[n+5];
    FOR0(i, n)
    {
        cin>>h[i];
    }
    bool is = true;
    int mx = ninf;
    FOR0( i, n)
    {
        if( mx - h[i] > 1)
        {
            is = false;
            break;
        }
        mx = MAX2(mx, h[i]);
    }
    if(is) cout<<"Yes";
    else cout<<"No";
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
 
int main(){
  int *p;
  int x,n;
  cin >> x >> n;
  p = (int*)malloc(sizeof(int)*n);
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
 int small, large, tag;
 small = x;
 large = x;
 while(1){
   tag=0;
   for(int i=0;i<n;i++){
     if(small == p[i]){
       tag += 1;
      }
     }
    if(tag == 0){
      cout << small << endl;
      break;
    }
    tag=0;
    for(int i=0;i<n;i++){
      if(large == p[i]){
       tag += 1;
      }
     }
    if(tag == 0){
      cout << large << endl;
      break;
    }
    small -= 1;
    large += 1;
  }

 

 
  free(p);
  return 0;
 
}



Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
using namespace std;

struct Edge { int to, cost; };
vector<Edge> G[21];

int N;
int deg[21], dist[21];

int rec(int v, int prv, int d) {
    dist[v] = d;
    int ret = 0;
    for (int i=0; i<(int)G[v].size(); ++i) {
        Edge &e = G[v][i];
        if (e.to == prv || deg[e.to] == 1) continue;
        ret += e.cost * 2 + rec(e.to, v, d+e.cost);
    }
    return ret;
}

int main() {
    while (cin >> N, N) {
        fill(deg, deg+21, 0);
        fill(dist, dist+21, INT_MAX);
        fill(G, G+21, vector<Edge>());
        int a, b, t;
        for (int i=0; i<N-1; ++i) {
            cin >> a >> b >> t;
            deg[a] ++;
            deg[b] ++;
            G[a].push_back((Edge){ b, t });
            G[b].push_back((Edge){ a, t });
        }
        int ans = rec(1, -1, 0);
        int maxDist = 0;
        for (int i=1; i<=N; ++i) {
            if (dist[i] != INT_MAX) {
                maxDist = max(maxDist, dist[i]);
            }
        }
        cout << ans - maxDist << endl;
    }
    return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    long N, K;
    cin >> K >> N;

    long A[N];
    for(int i=0; i<N; i++){
        cin >> A[i];
    }

    sort(A, A+N);
    long ans = 0;
    for(int i=0; i<N; i++){
        int prev;
        if(i==0) prev = N-1;
        else prev = i-1;

        long t;
        if(i == 0) t = K+A[i]-A[prev];
        else t = A[i] - A[prev];

        ans = max(t, ans);
    }

    cout << K-ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll = long long;
int main() {
  ll N,K;
  cin>>N>>K;
  vector<ll>vec(N);
  for(ll i=0;i<N;i++){
    cin>>vec.at(i);
  }
  vector<ll>voc(N,1);
  for(ll i=0;i<K;i++){
    ll a,b;
    cin>>a>>b;
    if(vec.at(a-1)>=vec.at(b-1)){
      voc.at(b-1)=0;
    }
    if(vec.at(a-1)<=vec.at(b-1)){
      voc.at(a-1)=0;
    }
  }
  ll c=0;
  for(ll i=0;i<N;i++){
    c+=voc.at(i);
  }
  cout<<c<<endl;
      
}


Measured memory_bytes: 4808
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
using namespace std;
const int INF = 1e9 + 5;
int main() {
    
    int n;
    cin >> n;
    vector<string> v(n);

    for(int i = 0; i < n; i++) {
    	cin >> v[i];
    }
    
    std::map<string, int> myMap;
     
   for(int i = 0; i < n; i++) {
    	myMap[v[i]]++;
    }
    cout << "\n";
    map<string, int> extra;
    int max_len = 0;
    for (std::map<string, int>::iterator iter = myMap.begin(); iter != myMap.end(); ++iter) {
		{

		    max_len = max(max_len, iter->second);
            
           
		}
  }

         for(map<string, int>::iterator it = myMap.begin(); it != myMap.end(); ++it) {

         	 if(it->second == max_len) {
         	 	cout << it->first << "\n";
         	 }
         }

	return 0;
}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,D,count=0,ans=0;
    cin >> N >> D;
    while (1){
        count += D*2 + 1;
        ans++;
        if (count >= N){
            break;
        }
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int N; std::cin >> N;

  int k = 0;
  for(int i=0; i<N; i++) {
    int p; std::cin >> p;
    if ( p != (i+1) ) k++;
  }

  if ( k == 0 || k ==2 ) std::cout << "YES" << std::endl;
  else std::cout << "NO" << std::endl;

  return 0;
}

Measured memory_bytes: 256