akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

struct E {
  int a, b;
  ll c;
};
typedef vector<vector<E> > G;

const ll INF = 1000000000000000000LL;

vector<ll> go(G& g, int start) {
  int n = g.size();
  vector<ll> costs(n, INF);
  costs[start] = 0;

  REP(k, n) REP(a, n) if (costs[a] != INF) for(auto e : g[a]) {
      int b = e.b;
      ll w = costs[a] + e.c;
      if (w < costs[b]) {
        costs[b] = w;
      }
    }
  return costs;
}


G g, rg;

ll solve(const vector<ll>& c1, const vector<ll>& c2) {
  int n = g.size();
  REP(a, n) for(auto e : g[a]) // negative cycleのチェック
    if (c1[a] + e.c < c1[e.b] && c1[a] < INF && c2[e.b] < INF)
      return -1;
  return max(0LL, -c1[n-1]);
}

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

  int n, nEdge, P;
  cin >> n >> nEdge >> P;
  g.assign(n, vector<E>(0));
  rg.assign(n, vector<E>(0));

  REP(i, nEdge) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    g[a].push_back((E){a, b, -(c-P)});
    rg[b].push_back((E){b, a, -(c-P)});
  }
  vector<ll> costs1 = go(g, 0);
  vector<ll> costs2 = go(rg, n-1);

  ll res = solve(costs1, costs2);
  cout << res << endl;
  return 0;
}


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

using namespace std;

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

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    ll n,m;
    cin>>m>>n;
    ll num=0;
    ll num2=1;
    vll v;
    v.push_back(m);
    while (num2<=n){
        ll num1=(v[num]*v[num])%MOD;
        v.push_back(num1);
        num+=1;
        num2*=2;
    }
    bitset<33> s(n);
    ll ans=1;
    rep(i,num+1){
        if (s.test(i)){
            ans*=v[i];
            ans%=MOD;
        }
    }
    ans%=MOD;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    while (1) {
        int N, M;
        cin >> N >> M;
        if (N == 0 && M == 0) break;
        vector<int> C(M), x(N);
        rep(i, M) cin >> C[i];
        rep(i, N) cin >> x[i];

        vector<vector<int>> dp(N + 1, vector<int>(256, 1e9));
        dp[0][128] = 0;
        rep(i, N) {
            rep(j, 256) {
                if (dp[i][j] == 1e9) continue;
                rep(k, M) {
                    int to = j + C[k];
                    if (to < 0) to = 0;
                    else if (to > 255) to = 255;
                    chmin(dp[i + 1][to], dp[i][j] + (to - x[i]) * (to - x[i]));
                }
            }
        }

        int ans = 1e9;
        rep(i, 256) {
            chmin(ans, dp[N][i]);
        }

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


Measured memory_bytes: 23724
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <chrono>
#include <random>
#include <unordered_map>
#include <cassert>
#pragma GCC optimize("O3")
#pragma comment(linker, "STACK:36777216")
using namespace std;
using i64 = int64_t;
constexpr i64 MOD = 1e9 + 7;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
using vi = vector<i64>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<i64, i64>;

vector<ii> hoge;

int main() {
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    int ma_x = x, mi_y = y;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        ma_x = max(ma_x, a);
    }
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        mi_y = min(mi_y, a);
    }
    
    cout << (ma_x < mi_y ? "No War" : "War") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> x(n);
  rep(i, n) cin >> x[i];
  int sum = 0;
  rep(i, n) {
    sum += min(x[i]*2, abs(k-x[i])*2); 
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var (a, b, c, d) = readLine()!!.split(" ").map { it.toInt() }
    var t_cnt = 0
    var a_cnt = 0
    while(a > 0){
        a -= d
        t_cnt++
    }
    while(c > 0){
        c -= b
        a_cnt++
    }
    if(t_cnt >= a_cnt) println("Yes")
    else println("No")
}

Measured memory_bytes: 36344
#include<iostream>
#include<deque>
using namespace std;
int main() {
	int k, n, x = 0, sum = 0, y;
	cin >> n >> k;
	deque<int>d(n);
	for (int i = 0; i < n; i++)
		cin >> d[i];
	int z = d[0];
	for (int i = 1; i < n; i++) {
		if (d[i] <= z) {
			z = d[i];
			x = i;
		}
	}

	while (d.size() > 1) {
		y = k - 1;
		while (y != 0 && d.size() > 1) {
			if (x + 1 < d.size() && d[x + 1] == d[x]) {
					d.erase(d.begin() + x + 1);
			}
			if (x + 1 < d.size() && d[x + 1] != d[x]) {
				d.erase(d.begin() + x + 1);
				y--;
			}
			if (y == 0)
				break;
			if (x - 1 >= 0 && d[x - 1] == d[x]) {
				d.erase(d.begin() + x - 1);
				x--;
			}
			if (x - 1 >= 0 && d[x - 1] != d[x]) {
				d.erase(d.begin() + x -1);
				y--;
				x--;
			}
		}
		sum++;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 640
#include"iostream"
#include"iomanip"
#include"string"

using namespace std;

int gcd(int a, int b)
{
	int t;
	while (b!=0)
	{
		t = a;
		a = b;
		b = t%b;
	}
	return a;
}

int main()
{
	int a, b,GCD,t;
	while (cin >> a >> b)
	{
		GCD=gcd(a, b);
		cout << GCD << " " << a/GCD*b << endl;
	}
	return 0;
}

Measured memory_bytes: 2980
#include<iostream>
#include<cstdio>
#include<cstring>

inline void check_min(int a,int &b){if(a<b)b=a;}

const int N=201000;

int pos[N];
int n,ans;

int main()
{
	scanf("%d",&n);
	for(int i=1,x;i<=n;i++)
		scanf("%d",&x),pos[x]=i;

	ans=n;

	for(int i=1,j=1;i<=n;i++)
	{
		if(j<i)j=i;
		while(j<n && pos[j+1]>pos[j])j++;
		check_min(n-(j-i+1),ans);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    a,b,c,k=map(int, readline().rstrip().split())

    if k <= a:
        print(k)
        return
    
    if k <= (a+b):
        print(a)
        return
    x=k-(a+b)
    print(a-x)

    #arr=list(map(int, readline().rstrip().split()))
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

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

using namespace std;

void move(int& fx, int& fy, int tx, int ty) {
  if (fy < ty) {
    cout << "U";
    fy = ty;
  } else if (ty < fy) {
    cout << "D";
    fy = ty;
  }
  if (fx < tx) {
    cout << "R";
    fx = tx;
  } else if (tx < fx) {
    cout << "L";
    fx = tx;
  }
}

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

  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int xstart[] = {sx + 1, tx - 1, sx, tx};
  int xgoal[] = {tx, sx, tx + 1, sx - 1};
  int ystart[] = {sy, ty, sy - 1, ty + 1};
  int ygoal[] = {ty - 1, sy + 1, ty, sy};

  int px = sx, py = sy;
  for (int i = 0; i < 3; i += 2) {
    move(px, py, xstart[i], ystart[i]);
    while (px != xgoal[i]) {
      cout << "R";
      ++px;
    }
    while (py != ygoal[i]) {
      cout << "U";
      ++py;
    }
    move(px, py, tx, ty);
    move(px, py, xstart[i+1], ystart[i+1]);
    while (px != xgoal[i+1]) {
      cout << "L";
      --px;
    }
    while (py != ygoal[i+1]) {
      cout << "D";
      --py;
    }
    move(px, py, sx, sy);
  }

  cout << "\n";
}


Measured memory_bytes: 256
import sys

n = int(input())
r0 = int(input())
r1 = int(input())
mx = r1-r0
mn = min(r1,r0)

for i in map(int,sys.stdin.readlines()):
    if mx < i - mn:
        mx = i - mn
        if 0 > i-mn:
            mn = i
    elif mn > i:
        mn = i

print(mx)

Measured memory_bytes: 21844
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		
		int X = stdin.nextInt();
		
		for(int i=1;i<=X;i++) {
			if(100*i <= X && 105*i >= X) {
				System.out.print("1");
				break;
			}
			if(i==X) {
				System.out.print("0");
			}
		}
	}
}


Measured memory_bytes: 22868
N = int(input())
ans = 0

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)

    return divisors

ans += len(make_divisors(N-1))-1

for i in make_divisors(N):
    if i == 1:
        continue

    now = N
    while now % i == 0:
        now //= i
    if now == 1:
        ans += 1
    if i in make_divisors(now-1):
        ans += 1

print(ans)

Measured memory_bytes: 40304
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

#define ll long long
#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()

int main(){
    int N, X;
    cin >> N >> X;
    int L[102];
    rep(i, N) cin >> L[i];
    int D[102] = {0};
    int ans = 1;
    for(int i = 1; i <= N; i++){
        D[i] = D[i - 1] + L[i -1];
        if(D[i] <= X) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// Aizu 0254: Scone
// 2017.9.12 bal4u@uu

#include <stdio.h>
#include <string.h>

int s[30003], f[100002];
char buf[330002], *p;
unsigned getInt()
{
	unsigned n = 0;
	if (*p == ' ') p++;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, m, i, a, ans, max;
	unsigned aa;
	long long sum;

	while (fgets(p=buf, 100, stdin) && *p != '0') {
		n = getInt(), m = getInt();
		memset(f, -1, sizeof(int)*m);
		fgets(p=buf, 330000, stdin);
		for (sum = 0, max = ans = s[0] = 0, i = 1; i <= n; i++) {
			aa = getInt(), sum += aa; a = aa % m; if (a > max) max = a;
			if (a == m-1) ans = a;
			if ((s[i] = s[i-1] + a) >= m) s[i] -= m; f[s[i]] = i;
		}
		if (ans > 0) goto Done;
		if (max == 0) { ans = 0; goto Done; }
		if (sum < m) { ans = (int)sum; goto Done; }
		for (ans = m-1; ans > max; ans--) {
			for (i = 0; i <= n; i++) {
				if ((a = s[i] + ans) >= m) a -= m;
				if (f[a] >= i) goto Done;
			}
		}
Done:	printf("%d\n", ans);
	}
	return 0;
}

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

int main() {
    int N, sum = 0;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L.at(i);
        sum += L.at(i);
    }
    sort(L.begin(), L.end());
    if (L.at(N - 1) * 2 < sum) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Math;

class F
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var vs = new int[n].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();

		var mi = -1;
		var ms = 0.0;
		var div = 360;
		var d = 2 * PI / div;
		for (int i = 0; i < div; i++)
		{
			var a = i * d;
			var s = vs.Select(v => v[0] * Cos(a) + v[1] * Sin(a)).Where(x => x > 0).Sum();
			if (ms < s) { mi = i; ms = s; }
		}

		var ma = mi * d;
		var mvs = vs.Select(v => new { v, x = v[0] * Cos(ma) + v[1] * Sin(ma) }).Where(_ => _.x > 0).ToArray();
		double xs = mvs.Sum(_ => _.v[0]);
		double ys = mvs.Sum(_ => _.v[1]);
		Console.WriteLine(Sqrt(xs * xs + ys * ys));
	}
}


Measured memory_bytes: 13652
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main(){
	string s; cin>>s;
	vector<string> v;
	int k; cin >> k;
	rep(i,s.size()){
		rep(j,k){
			if (s.size() <= i+j) break;
			v.push_back(s.substr(i,j+1));
		}
	}
	sort(all(v));
	// rep(i,v.size()){
	// 	print(v[i]);
	// }
	// print("#####3");
	v.erase(unique(all(v)), v.end());
	// rep(i,v.size()){
	// 	print(v[i]);
	// }
	cout << v[k-1] << endl;
}


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

int main() {
  string  s;
  cin >> s;
  if(s.at(0)=='9'){
    s.at(0)='1';
  }
  else{ 
    s.at(0)='9';
  }
  
  if(s.at(1)=='9'){
    s.at(1)='1';
  }
  else{ 
    s.at(1)='9';
  }
  
  if(s.at(2)=='9'){
    s.at(2)='1';
  }
  else{ 
    s.at(2)='9';
  }
  
  cout << s;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int a[m];
  int sum=0;
  for(int i=0;i<m;i++)
  {
    cin>>a[i];
    sum+=a[i];
  }
  if(sum>n)
  {
    cout<<"-1";
  }
  else
  {
    cout<<(n-sum);
  }
  return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &p : a) cin >> p;
  auto p = unique(a.begin(), a.end());
  for (int i = 0; i < p - a.begin(); i++) {
    if (i) cout << " ";
    cout << a[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3088
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const N = Number(input[0][0]);
  const A = Number(input[1][0]);

  return N % 500 <= A ? "Yes" : "No";
};

console.log(main(read()));


Measured memory_bytes: 29588
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#define mod 1000007
using namespace std;                       
typedef long long ll;

 int main(){
 	double  n,m,k,l,t1,t2,t3,t4,t5;
	   scanf("%lf%lf%lf%lf",&n,&m,&k,&l);
	        t1=30*k+l*30/60;
	        t2=l*6;
	        t3=fabs(t2-t1);
	        t4=t3*3.1415926535897932384626433/180;
	        t5=sqrt(n*n+m*m-2*n*m*cos(t4));
	        printf("%.12f",t5);
	    }
	         

Measured memory_bytes: 4316
my $n = <STDIN>;
my @a = split(/[\s\n\r]+/, <STDIN>);

my %count = ( 0=>1 );
my $sum = 0;
my $ans = 0;

for my $i (@a) {
    $sum += $i;
    $ans += $count{$sum} if $count{$sum};
    #print "$i $sum $count{$sum}\n";
    $count{$sum}++;
}

print $ans, "\n";


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

int main()
{
	//?????????
	int num1,num2,num3,num4,num5,num6;
	int sum;

	cin>>num1>>num2>>num3>>num4>>num5;
	if(num1>=num2){
		sum=num1;
		num1=num2;
		num2=sum;
	}
	if(num2>=num3){
		sum=num2;
		num2=num3;
		num3=sum;
	}
	if(num1>=num2){
		sum=num1;
		num1=num2;
		num2=sum;
	}
	if(num4>=num5){
		sum=num4;
		num4=num5;
		num5=sum;
	}
	num6=num1+num4-50;
	cout<<num6;
	cout<<"\n";
	return 0;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int>W(N);

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

	int ans = 1e9;
	int tmp = 0;
	for (int i = 0; i < N; i++) {
		tmp += W[i];
		int tmp1 = 0;
		for (int j = i+1; j < N; j++) {
			tmp1 += W[j];
		}
		ans = min(ans, abs(tmp - tmp1));
	}

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

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


/*long long int Set(long long int N,long long int pos){return N=N | (1<<pos);}
long long int reset(long long int N,long long int pos){return N= N & ~(1<<pos);}
bool check(long long int N,long long int pos){return (bool)(N & (1<<pos));}*/




int main()
{
    /*ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);*/

    long long int 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;


    cin>>n>>k;
    d=0;

    double cc;
    for(i=0;i<n;i++)
    {
        cin>>a>>b;
        cc=(a*a)+(b*b);
        cc=sqrt(cc);
        //cout<<c<<"\n";
        if(cc<=k)
            d++;

    }
    cout<<d<<"\n";

    return 0;


}


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int N;
	cin >> N;

	vector<int> ds(101);// 配列を使う

	int d;
	for (int i = 0; i < N; i++)
	{
		cin >> d;
		ds.at(d)++;
	}
	int count = 0;
	for (int j = 1; j <= 100; j++)
	{
		if (ds.at(j)!=0)
		{
			count++;
		}
	}
	cout << count << endl;
}

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

#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
#define FILL(a, b) memset((a), (b), sizeof((a)))
#define MCPY(a, b) memcpy((a), (b), sizeof((b)))

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;

const int iinf = 1e9 + 7;
const int oo = 0x3f3f3f3f;
const LL linf = 1ll << 60;
const flt dinf = 1e60;

template <typename T>
inline void scf(T &x)
{
	bool f = 0; x = 0; char c = getchar();
	while((c < '0' || c > '9') && c != '-') c = getchar();
	if(c == '-') { f = 1; c = getchar(); }
	while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	if(f) x = -x; return;
}
template <typename T1, typename T2>
void scf(T1 &x, T2 &y) { scf(x); return scf(y); }
template <typename T1, typename T2, typename T3>
void scf(T1 &x, T2 &y, T3 &z) { scf(x); scf(y); return scf(z); }
template <typename T1, typename T2, typename T3, typename T4>
void scf(T1 &x, T2 &y, T3 &z, T4 &w) { scf(x); scf(y); scf(z); return scf(w); }

inline char mygetchar(){ char c = getchar(); while(c == ' ' || c == '\n') c = getchar(); return c; }

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

#ifdef ONLINE_JUDGE
#define debug(...) ;
#else
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define DEBUG
#endif

//---------------------------------------------------------head----------------------------------------------------

const int maxn = 2e5 + 100;

int n;
LL a, b, c, d;

int main()
{
	scf(n);
	scf(a, b, c, d);
	rep(i, n - 1)
	{
		LL lb = a - d * i + c * (n - i - 1), rb = a + d * (n - i - 1) - c * i;
		if(lb <= b && rb >= b){ puts("YES"); return 0; }
	}
	puts("NO");
	return 0;
}

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

int main(int argc, char const *argv[])
{
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (s == u)
    {
        cout << a-1 << " " << b << endl;
    }
    else
    {
        cout << a << " " << b-1 << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
    ll N, W;
    cin >> N >> W;
    struct Item {
        ll w;
        ll v;
    };
    vector<Item> items(N);
    rep(i,0,N) {
        cin >> items[i].w >> items[i].v;
    }
    ll w_base = items[0].w;
    auto dp = make_vec_nd(numeric_limits<ll>::min(), 2, N+1, 300*N+1);
    dp[0][0][0] = 0;
    rep(n,1,N+1) {
        rep(m,0,n+1) {
            rep(w,0,300*N+1) {
                if (!(m * w_base + w <= W)) {
                    continue;
                }
                dp[n%2][m][w] = dp[(n-1)%2][m][w];
                ll w_off = items[n-1].w - items[0].w;
                if (m >= 1 && w >= w_off) {
                    dp[n%2][m][w] = max(dp[n%2][m][w], dp[(n-1)%2][m-1][w-w_off] + items[n-1].v);
                }
            }
        }
    }
    ll ans = numeric_limits<ll>::min();
    rep(m,0,N+1) {
        rep(w,0,300*N+1) {
            ans = max(ans, dp[N%2][m][w]);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 72076
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        loop: while(true){
            int w = sc.nextInt(),h = sc.nextInt();
            if(w == 0 && h == 0) break loop;
            for(int i = 0;i < w;i++){
                for(int j = 0;j < h;j++){
                    System.out.print((i == 0 || i == w - 1 || j == 0 || j == h - 1) ? "#" : ".");
                }
                System.out.println();
            }
            System.out.println();
        }
    }

}

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

int main(){
  string n;
  cin>>n;
  rep(i,3){
    if(n[i]=='7') {
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define input() for(int i=0;i<n;i++)cin>>a[i];
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
int n, a[100005], b[100005], cnt1, cnt2;
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i], cnt1 += a[i];
	rep(i, n)cin >> b[i], cnt2 += b[i];
	int ans1 = 0, ans2 = 0;
	rep(i, n) {
		if (a[i] > b[i])ans1 += a[i] - b[i];
		if (a[i] < b[i])ans2 += (b[i] - a[i] + 1) / 2;
	}
	if (ans1 <= cnt2 - cnt1 && ans2 <= cnt2 - cnt1) {
		puts("Yes");
	}
	else puts("No");
	endre;
}


Measured memory_bytes: 384
<?php
$A=[];
for($i=97;$i<123;$i++) $A[$i]=0;

while(!feof(STDIN)){
	$S=trim(fgets(STDIN));
	foreach(str_split($S) as $c){
		$n=ord($c);
		if(64<$n && $n<91) ++$A[$n+32];
		elseif(96<$n && $n<123) ++$A[$n];
	}
}

for($i=97;$i<123;$i++) echo chr($i),' : ',$A[$i],PHP_EOL;

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

int main(void){
    int n,q;
    cin >> n >> q;
    list<int> L[n];
    list<int>::iterator it;

    for(int i=0; i<q; i++){
        int cmd;
        cin >> cmd;
        if(cmd==0){
            int t,x;
            cin >> t >> x;
            L[t].push_back(x);
        }
        else if(cmd==1){
            int t;
            cin >> t;
            for(it=L[t].begin(); it!=L[t].end(); it++){
                if(it != L[t].begin()) cout << " ";
                cout << *it;
            }
            cout << "\n";
        }
        else if(cmd==2){
            int s,t;
            cin >> s >> t;
            L[t].splice(L[t].end(), L[s]);
        }
    }
    return 0;
}


Measured memory_bytes: 18624
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
//	cin>>n>>k;
//	cout<<n<<k<<endl;
//string S[100];

int main(){

	int res=1000000000;
	int N;cin>>N;
	int st[N];
	for(int i=0;i<N;i++)cin>>st[i];


	int ans;
	for(int i=-100;i<=100;i++){
		ans=0;
		for(int j=0;j<N;j++){
			ans+=(i-st[j])*(i-st[j]);
		}
		res=min(res,ans);
	}
	cout<<res<<endl;
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define lli long long int
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define mii map<lli,lli>
#define msi map<string,lli>
#define pii pair<lli,lli> 
#define vi vector<lli> 
#define vvi vector< vector<lli> >
#define sz(x) (lli)x.size()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX1 998244353
#define MAX2 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define input(data,n,command) for(lli i=0;i<n;i++){lli tmp;cin>>tmp;data.pb(tmp);command}
#define sort_asc(a) sort(a.begin(),a.end());
//#define sort_desc(a) sort(a.begin(),a.end(),greater<lli>());
#define display(a) for(lli i = 0 ;i<a.size();i++){cout<<a[i]<<" ";} cout<<endl;
#define rep(i,a,b) for(lli i = a;i < b;i++)
#define endl "\n"

//Written By MUDIT BHARDWAJ...
/*--------------------------------------------------------------------*/
//vector<pair<lli,lli>>adj[300010];

lli solve()
{
    //start from here
    lli n;
    cin>>n;
    if(n >= 30)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}

int main()
{
    ios
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    lli T=1;
    //cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}
/*-----------------------------------------------------------------------*/

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



int main(){
	int n,cnt=0;
	cin >> n;
	for(int i=1;i<=n;i+=2){
		for(int j=2;j<=n;j+=2){
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::max;
#[allow(unused_imports)]
use std::fmt;
#[allow(unused_imports)]
use std::fmt::Debug;
#[allow(unused_imports)]
use std::io;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
    let mut inputs = String::new();
    loop {
        let input = get_string_input();
        if input == "" {
            break;
        }
        inputs += &input;
    }

    let alphabet = (b'a'..b'z' + 1)
        .map(|c| c as char)
        .filter(|c| c.is_alphabetic())
        .collect::<Vec<_>>();
    for lowercase in alphabet {
        let uppercase: char = lowercase.to_string().to_uppercase().chars().next().unwrap();
        let lowercase_count = inputs.match_indices(lowercase).count();
        let uppercase_count = inputs.match_indices(uppercase).count();
        println!("{} : {}", lowercase, lowercase_count + uppercase_count);
    }
}

#[allow(dead_code)]
fn sum_digit2(value: String) -> u32 {
    return value.chars().fold(0u32, |a, b| a + b.to_digit(10).unwrap());
}

#[allow(dead_code)]
fn sum_digit(value: i64) -> i64 {
    if value < 10 {
        return value;
    }
    return sum_digit(value / 10) + value % 10;
}

#[allow(dead_code)]
fn update_max<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left < right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn update_min<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left > right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn get_vec_input<T>() -> Vec<T>
where
    T: FromStr,
    T::Err: Debug,
{
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<T> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    vec
}

#[allow(dead_code)]
fn get_tuple_input() -> (u64, f32) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c: u64 = iter.next().unwrap().parse().unwrap();
    let n: f32 = iter.next().unwrap().parse().unwrap();
    (c, n)
}

#[allow(dead_code)]
fn get_string_input() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    s
}



Measured memory_bytes: 5048
/*
lakshaygpt28
Lakshay Gupta
*/

#include <bits/stdc++.h>
using namespace std;

const double PI = acos(-1);
const long long LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

int main() {
    ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a * c, b * d, b * c, a * d}) << "\n";
    return 0;
}


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

int main()
{
  string S,T,U;
  int A,B;
  cin >> S >> T >> A >> B >> U;
  if(0==S.compare(U)) cout << A-1 << " " << B << endl;
  else cout << A << " " << B-1 << endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <unordered_map>

#define mod 1000000007

using namespace std;
using ll = long long;

void solve(){
    int n, res = 0;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    while(1){
        for(int i = 0; i < n; i++){
            if(a[i]%2 != 0){
                cout << res << endl;
                return;
            }else{
                a[i] = a[i]/2;
            }
        }
        res++;
    }
}

int main(){
    solve();
    return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */
int main(){
    int n; lint l; cin >> n >> l;
    vector<lint> a(n);
    rep(i, n) cin >> a[i];

    int ok = -1;
    rep(i, n-1){
        if(a[i]+a[i+1] >= l){
            ok = i; break;
        }
    }

    if(ok == -1){
        out("Impossible"); return 0;
    }
    out("Possible");

    for(int i = 0; i < ok; i++) out(i+1);
    for(int i = n-2; i > ok; i--) out(i+1);
    out(ok+1);
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    string s;
    cin >>s;
    s[5]=' ';
    s[13]=' ';
    cout<<s<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

double a;
int n;
string ans[6] = { "", "", "", "", "", "" };

int main(){
	cin >> n;
	REP(i, n){
		cin >> a;
		for (int j = 0; j < 6; j++){
			if (a < 165 + 5 * j){
				ans[j] += "*";
				break;
			}
		}
	}
	REP(j, 6)cout << j+1 << ':' << ans[j] << endl;
}

Measured memory_bytes: 1244
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] c = new int[N+1];
    int[] s = new int[N+1];
    int[] f = new int[N+1];
    for(int i=1;i<N;i++){
      c[i] = sc.nextInt();
      s[i] = sc.nextInt();
      f[i] = sc.nextInt();
    }
    for(int i=1; i<=N-1; i++){
      long ans = 0;
      for(int j=i;j<=N-1;j++){
        if(ans <= s[j]){
          ans = s[j];
          ans += c[j];
        }
        else{
          long remain = (ans-s[j])%f[j];
          if(remain!=0) ans += f[j]-remain;
          ans += c[j]; 
        }
      }
      System.out.println(ans);  
    }
    System.out.println(0);
  }
}

Measured memory_bytes: 26700
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int sum = f753(0,false,false,false,N);
		System.out.println(sum);
	}
	
	public static int f753(long x,boolean c7,boolean c5,boolean c3,int N) {
		int res = 0;
		
		if(x> N) {
			return res;
		}
		if(c7&&c5&&c3) {
			res++;
		}
		
		res += f753(x * 10 +7,true,c5,c3,N);
		res += f753(x * 10 +5,c7,true,c3,N);
		res += f753(x * 10 +3,c7,c5,true,N);
		return res;
	}

}

Measured memory_bytes: 23380
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int f[100000];
long long ans[200001];
vector <long long> v[100000];

int main() {
    int n, k, c = 0, i, j;
    long long p = 0, q = 0;
    vector <pair<double, int>> w;
    multiset <long long> m1, m2;
    
    scanf("%d %d", &n, &k);
    
    for (i = 0; i < n; i++) {
        int x, y;
        
        scanf("%d %d", &x, &y);
        
        v[x - 1].push_back(y);
    }
    
    for (i = 0; i < k; i++) {
        sort(v[i].begin(), v[i].end());
        reverse(v[i].begin(), v[i].end());
        
        if (v[i].size() >= 3) m2.insert(v[i][0] + v[i][1] + v[i][2]);
        
        w.push_back(make_pair((v[i][0] + v[i][1]) / 2.0, i));
        w.push_back(make_pair((v[i][0] + v[i][1]) / 2.0, i));
        
        for (j = 2; j < v[i].size(); j++) w.push_back(make_pair(v[i][j], i));
    }
    
    sort(w.begin(), w.end());
    reverse(w.begin(), w.end());
    
    for (i = 1; i <= n; i++) ans[i] = -1;
    
    for (i = 0; i < w.size(); i++) {
        int x = w[i].second;
        
        f[x]++;
        
        if (f[x] == 2) {
            c += 2;
            ans[c] = ans[c - 2] + v[x][0] + v[x][1];
            
            if (p > 0) ans[c - 1] = max(ans[c - 1], ans[c] - p);
            if (m1.size() > 0) ans[c - 1] = max(ans[c - 1], ans[c - 2] + *m1.rbegin());
            if (q > 0 && m2.size() > 0) ans[c - 1] = max(ans[c - 1], ans[c - 2] - q + *m2.rbegin());
            
            q = v[x][0] + v[x][1];
            for (j = 2; j < v[x].size(); j++) m1.insert(v[x][j]);
            if (v[x].size() >= 3) m2.erase(m2.find(v[x][0] + v[x][1] + v[x][2]));
        } else if (f[x] > 2) {
            long long y = v[x][f[x] - 1];
            
            c++;
            ans[c] = ans[c - 1] + y;
            
            p = y;
            m1.erase(m1.find(y));
        }
    }
    
    for (i = 1; i <= n; i++) printf("%lld\n", ans[i]);
    
    return 0;
}


Measured memory_bytes: 21876
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int sortup(const void *a, const void *b){
    return *(int*)a-*(int*)b ;
}
int sortdown(const void *a, const void *b){
    return *(int*)b-*(int*)a ;
}

int main(void){
    long long n,ans=0;
    scanf("%lld",&n);
    long long a[n],b[n],c[n];
    for (int i=0; i<n; i++){
        scanf("%lld",&a[i]);
    }
    for (int i=0; i<n; i++){
        scanf("%lld",&b[i]);
    }
    for (int i=0; i<n; i++){
        scanf("%lld",&c[i]);
    }
    qsort (a,n,sizeof(long long),sortup);
    qsort (b,n,sizeof(long long),sortup);
    qsort (c,n,sizeof(long long),sortdown);
    
    long long max,min,mid,ansa,ansc;
    for (int i=0; i<n; i++){
        if(b[i]<=a[0] || b[i]>=c[0]){

        } else if (i!=0 && b[i]==b[i-1]){
            ans+=ansa*ansc;
    
        } else {
            
            ansa=0;
            ansc=0;
            max=n;
            min=0;
            while(min<=max){
                mid = (max+min)/2;
                if (a[mid]>b[i]){
                    max=mid-1;
                } else {
                    min=mid+1;
                }
            }
            if (a[mid]>=b[i]){
                while(a[mid]>=b[i] && mid>=0){
                     mid--;
                }
            } else {
                while (a[mid]<b[i] && mid<n){
                mid++;
                }
                mid--;
            }
            ansa = mid+1;
            max=n;
            min=0;
            while(min<=max){
                mid = (max+min)/2;
                if (c[mid]>b[i]){
                    min=mid+1;
                } else {
                    max=mid-1;
                }
            }
            if (c[mid]<=b[i]){
                while(c[mid]<=b[i] && mid>=0){
                    mid--;
                }
            } else {
                while (c[mid]>b[i] && mid<n){
                    mid++;
                }
                mid--;
            }
            ansc = mid+1 ;
            ans+=ansa*ansc;
        }
    }
    printf ("%lld\n",ans);
	return 0 ;
}

Measured memory_bytes: 3324
import java.util.*;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);

		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		long K = Long.parseLong(tokens[1]);
		int Q = Integer.parseInt(tokens[2]);

		long[] scores = new long[N];
		Arrays.fill(scores, K - Q);

		for (int i = 0; i < Q; ++i) {
			int target = Integer.parseInt(in.readLine());
			scores[target - 1]++;
		}

		for (int i = 0; i < N; ++i) {
			if (scores[i] > 0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}

	}
}

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

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int>x(N);
  vector<int>y(M);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i);
  }
  for (int i = 0; i < M; i++) {
    cin >> y.at(i);
  }
  bool ans = false;
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  for (int i = -100; i <= 100; i++) {
    if (x.at(N - 1) < i) {
      if (y.at(0) >= i) {
        if (X < i) {
          if (i <= Y) {
            ans = true;
          }
        }
      }
    }
  }
  if (ans) {
    cout << "No War";
  }
  else {
    cout << "War";
  }
}

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

int main(){

   string str;
   int a = 0, i = 0;

   while(1){

       cin >> str;

       if(str == "0")break;

       for(i = 0; i < str.size(); ++i){

           a += str[i] - '0';
       }

       cout << a << endl;
       a = 0;
   }

   return 0;
}


Measured memory_bytes: 3220
#include<stdio.h>
int main(){
  int x;
  scanf("%d",&x);
  
  if(x==3){
    printf("YES");
  }
  else if(x==5){
    printf("YES");
  }
  else if(x==7){
	printf("YES");
  }
  else{
    printf("NO");
  }
  return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //c
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> in(h);
  for (int i = 0; i < h; i++) {
    cin >> in[i];
  }
  vector<vector<int>> ans(h, vector<int>(w));
  int cur = 1;
  for (int i = 0; i < h; i++) {
    int cnt = 0;
    for (int j = 0; j < w; j++) {
      if (in[i][j] == '#') cnt++;
    }
    if (cnt == 0) continue;
    if (cnt == 1) {
      fill(ans[i].begin(), ans[i].end(), cur);
      cur++;
      continue;
    }
    int c = 1;
    for (int j = 0; j < w; j++) {
      ans[i][j] = cur;
      if (in[i][j] == '#' && c < cnt) {
        cur++;
        c++;
      }
    }
    cur++;
  }
  for (int i = 1; i < h; i++) {
    if (ans[i][0] == 0) ans[i] = ans[i - 1];
  }
  for (int i = h - 2; i >= 0; i--) {
    if (ans[i][0] == 0) ans[i] = ans[i + 1];
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (j > 0) cout << " ";
      cout << ans[i][j];
    }
    cout << '\n';
  }
  return 0;
}

Measured memory_bytes: 1280
#                               #
    # author : samars_diary #
    # 17-09-2020 │ 16:21:14 #
#                               #

import sys, os.path

#if(os.path.exists('input.txt')):
    #sys.stdin = open('input.txt',"r")
    #sys.stdout = open('output.txt',"w")

sys.setrecursionlimit(10 ** 5)

def mod(): return 10**9+7
def i(): return sys.stdin.readline().strip()
def ii(): return int(sys.stdin.readline())
def li(): return list(sys.stdin.readline().strip())
def mii(): return map(int, sys.stdin.readline().split())
def lii(): return list(map(int, sys.stdin.readline().strip().split()))

#print=sys.stdout.write

def solve():
    a=ii()
    val=7%a
    for i in range(1,10**7):
        if val==0:
            print(i)
            return
        val=(val*10+7)%a
    print(-1)
for _ in range(1):
    solve()

Measured memory_bytes: 8984
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
  double a[2],b[2],c[2],m[2][2],inv[2][2],ans[2],x,y,det,r;
  int n;
  cin >>n;
  while(n--){
    cin >>a[0]>>a[1]>>b[0]>>b[1]>>c[0]>>c[1];
    b[0]-=a[0];
    b[1]-=a[1];
    c[0]-=a[0];
    c[1]-=a[1];
    m[0][0] = 2*b[0];
    m[1][0] = 2*b[1];
    m[0][1] = 2*c[0];
    m[1][1] = 2*c[1];
    ans[0] = b[0]*b[0]+b[1]*b[1];
    ans[1] = c[0]*c[0]+c[1]*c[1];
    det = m[0][0]*m[1][1]-m[0][1]*m[1][0];
    inv[0][0] = m[1][1]/det;
    inv[1][0] = -m[1][0]/det;
    inv[0][1] = -m[0][1]/det;
    inv[1][1] = m[0][0]/det;
    x = ans[0]*inv[0][0]+ans[1]*inv[1][0];
    y = ans[0]*inv[0][1]+ans[1]*inv[1][1];
    r = sqrt(x*x+y*y);
    x+=a[0];
    y+=a[1];
    printf("%.3lf %.3lf %.3lf\n",x,y,r);
  }
  return 0;
}

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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n, m;
  cin >> n >> m;

  vector<int> ans(n, 0);
  vector<vector<int>> g(n), vis(n, vector<int> (11, 0));
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;

    --u; --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }

  int q, col;
  cin >> q;

  vector<int> v(q), d(q), c(q);
  for (int i = 0; i < q; ++i) {
    cin >> v[i] >> d[i] >> c[i];
    --v[i];
  }

  function<void(int, int)> paint = [&](int x, int dist) {
    if (vis[x][dist]) return ;
    if (dist == 0) {
      ans[x] = col;
      vis[x][dist] = 1;
      return ;
    }

    vis[x][dist] = 1;
    paint(x, dist - 1);
    for (auto to : g[x]) {
      paint(to, dist - 1);
    }
  };

  for (int i = q - 1; i >= 0; --i) {
    col = c[i];
    paint(v[i], d[i]);
  }

  for (int i = 0; i < n; ++i) {
    cout << ans[i] << '\n';
  }
}

Measured memory_bytes: 16632
#include<stdio.h>
int main()
{
	int a,i=0,n[10020];
	scanf("%d",&a);
	while(a!=0)
	{
		i++;
		n[i]=a;
		scanf("%d",&a);
	}
	for(a=1;a<=i;a++)
	{
		printf("Case %d: %d",a,n[a]);
		
		printf("\n");
	}
	
	return 0;
}


Measured memory_bytes: 2040
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	ll a, b;
	string inp;
	cin >> a >> inp;
	b = (inp[0] - '0') * 100 + stoi(inp.substr(2));
	cout << a * b / 100 << '\n';
}



Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#define endl '\n'
#define ll long long

using namespace std;

int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	int N, input, ret = 0;
	cin >> N;
	vector<int> machine;
	unordered_set<int> st;
	for (int i = 0; i < N; i++)
	{
		cin >> input; machine.push_back(input);
	}

	int cur = 0;
	while (st.find(cur + 1) == st.end())
	{
		if (cur + 1 == 2)
		{
			cout << ret;
			return 0;
		}

		ret += 1;
		st.insert(cur + 1);
		cur = machine[cur] - 1;
	}
	cout << -1;
	return 0;
}

Measured memory_bytes: 4752