akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int W = sc.nextInt();
    int[] w = new int[N];
    int[] v = new int[N];
    for (int i = 0; i < N; i++) {
	  w[i] = sc.nextInt();
      v[i] = sc.nextInt();
    }
    long[][] dp = new long[2][W + 1];
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= W; j++) {
      	dp[i % 2][j] = dp[1 - i % 2][j];
        if (j >= w[i - 1]) {
          dp[i % 2][j] = Math.max(dp[1 - i % 2][j - w[i - 1]] + v[i - 1], dp[i % 2][j]);
        }
      }
    }
    System.out.println(dp[N % 2][W]);
  }
}

Measured memory_bytes: 24276
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> penalty(N, 0);
    vector<bool> AC(N, false);
    string s;
    for (int i = 0, p; i < M; i++) {
        cin >> p >> s;
        if (s == "WA" && !AC[p - 1]) penalty[p - 1]++;
        else AC[p - 1] = true;
    }
    int ans1 = 0, ans2 = 0;
    for (int i = 0; i < N; i++) {
        if (AC[i]) {
            ans1++;
            ans2 += penalty[i];
        }
    }
    cout << ans1 << " " << ans2 << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define lla(s) s.rbegin(),s.rend()
#define pcnt(b) __builtin_popcount(b)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ll INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s,t = "keyence";
    cin>>s;
    if(s.length()<7){cout<<"NO"<<endl;return 0;}
    rep(i,0,8){
        if(s.substr(0,i)+s.substr(s.length()-7+i,7-i)==t){cout<<"YES"<<endl;return 0;}
    }
    cout<<"NO"<<endl;return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

const int mod = 10000;
char const *limit;
int maxk, cut;
int memo[10][512][512][4];

inline int idx(bool up, bool down, bool high)
{
	return ((up << 1) | (down << 0));
}

int search(int n, int k, int p, bool up, bool down, bool high)
{
	int sum = 0;
	
	if(k >= (maxk - 1))
		return p == 0;
		
	if(!high && memo[n][k][p][idx(up, down, high)] != -1)
		return memo[n][k][p][idx(up, down, high)];
	
	for(int i = 0; i < 10; ++i) {
		
		if((n < i && !up) || (n == i) || (n > i && !down))
			continue;
			
		char c = limit[k + 1] - '0';
			
		if(high && c < i)
			continue;
			
		bool nexthigh = high && (c == i);
		
		sum += search(i, k + 1, (p * 10 + i) % cut, n > i, n < i, nexthigh);
	}
	
	sum = sum % mod;
	if(!high)
		memo[n][k][p][idx(up, down, high)] = sum;
	
	return sum;
}

int search(char *str, int law)
{
	int sum = 0;
	int len = strlen(str);
	bool start = false;
	
	memset(memo[0][0][0], -1, 10 * 512 * 512 * 4 * sizeof(int));
	
	maxk = len;
	cut = law;
	limit = str;
	
	for(int i = 0; i < maxk; ++i) {
		
		char c = limit[i] - '0';
		
		if(!start && c == 0)
			continue;
			
		for(int j = 1; j < 10; ++j) {
			
			if(!start && c < j)
				continue;
				
			bool nexthigh = !start && (c == j);
				
			sum += search(j, i, j % cut, true, true, nexthigh);
		}
		
		start = true;
		
		sum = sum % mod;
	}
	
	return sum;
}

int judge(char *str, int law)
{
	int len = strlen(str);
	bool start = false;
	int p = 0;
	bool up;
	
	for(int i = 0; (i < (len - 1)) && (p != -1); ++i) {
		
		char c1 = str[i] - '0', c2 = str[i + 1] - '0';
		
		if(!start && c1 == 0)
			continue;
			
		p = (p * 10 + c1) % law;
			
		if(start) {
			
			if(up && c1 >= c2)
				p = -1;
			if(!up && c1 <= c2)
				p = -1;
			up = !up;
		} else {
			
			if(c1 == c2)
				p = -1;
			else
				up = c1 > c2;
		}
			
		start = true;
	}
	
	if(p != -1)
		p = (p * 10 + (str[len - 1] - '0')) % law;
	
	return p == 0;
}

int main()
{
	char a[512] = "00", b[512] = "00";
	int m;
	
	scanf("%s%s%d", a + 2, b + 2, &m);
	
	int na, nb, ea;
	
	na = search(a, m);
	nb = search(b, m);
	ea = judge(a, m);
	
	int ans = (nb - na + ea + 5 * mod) % mod;
	
	//printf("%d - %d + %d = %d\n", nb, na, ea, ans);
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 40000
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
        int b = 0;
        int c = 0;
        for(int i=a;i<=100003;i++){if(b>=a){break;}c=0;
        for(int j=1;j<=Math.sqrt(i);j++){if(i%j==0){c++;}
                              if(c==1 && j+1>Math.sqrt(i)){b=i;
                                                          }
                                        }
                                  }
		System.out.println(b);
	}
}


Measured memory_bytes: 25044
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin>>n;
     long long ans=0;
    for(i=1; i<=n; i++)

    if(i%3!=0 && i%5!=0)

      ans = ans + i;
        cout<<ans<<endl;

        return 0;

}


Measured memory_bytes: 3596
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define ll 		int
#define int 		long long
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define vpi 		vector<pii>
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define fori(a,b,c) for(register int i=a;i<b;i+=c)
#define ford(a,b,c) for(register int i=a;i>=b;i-=c)
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl()
{
	cout<<"Control\n";
}
signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin.exceptions(cin.failbit);
	int w,h,a,b;
    cin>>w>>h>>a>>b;

        ld a1=w*h;
        a1=a1*1.00;
    coud(a1/2,12);
    cout<<" ";
    if(w%2==0&&h%2==0&&w/2==a&&h/2==b)
    cout<<1;
    else
    {
        cout<<0;
    }
    

return 0;
}

Measured memory_bytes: 256
N = int(input())
MOD = 1000000007
dp = [[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(N+1)]
dp[0][3][3][3] = 1
for n in range(N):
    for i in range(4):
        for j in range(4):
            for k in range(4):
                if (dp[n][i][j][k] == 0): continue
                for a in range(4):
                    if (j==0 and k==1 and a==2): continue
                    if (j==1 and k==0 and a==2): continue
                    if (j==0 and k==2 and a==1): continue
                    if (i==0 and k==1 and a==2): continue
                    if (i==0 and j==1 and a==2): continue
                    dp[n+1][j][k][a] += dp[n][i][j][k]
                    dp[n+1][j][k][a] %= MOD
ans = 0
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans += dp[N][i][j][k]
            ans %= MOD
print(ans)


Measured memory_bytes: 48368
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    for i in range(n+1):
        if int(i*1.08) == n:
            print(i)
            return
    print(":(")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		System.out.println(((a + b )* h / 2));
		scan.close();
	}

}


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

int main() {
  int A,B,answer;
  char op;
  
  cin >> A >> op >> B;
  
  if (op == '+') {
    answer = A + B;
  } 
  if (op == '-') {
    answer = A - B;
  } 
  
  cout << answer << endl;
 
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}


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

  ll a, b, v, w, t;
  cin >> a >> v >> b >> w >> t;

  if(v - w <= 0){
    cout << "NO" << endl;
    return 0;
  }

  ll d = abs(a-b);
  ll s = abs(w-v);

  if((d+s-1)/s <= t){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }


  return 0;
}


Measured memory_bytes: 3588
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    let m = parseInt(input[0][0], 10);
    let n = parseInt(input[0][1], 10);
    let C = 1e9 + 7;
    let C2 = 1e5 * 5;

    console.log(fastRuijoR(m, n, C, C2));

}

function fastRuijoR(a, b, C, C2){
    var ans = 1;
    var binary = b.toString(2);
    var l = binary.length;
    var tmp = a;
    for (var i = 0; i < l; i++){
        if (binary.substr((i + 1) * -1, 1) === '1') ans = kakeruR(ans, tmp, C, C2);
    tmp = kakeruR(tmp, tmp, C, C2);
    }
    return ans;
}

function kakeruR(a, b, C, C2){
    var tmpQ, tmpR, ans;
    tmpQ = (b / C2 | 0);
    tmpR = b - (tmpQ * C2);
    ans = (a * tmpQ % C) * C2 % C + (a * tmpR);
    ans %= C;
    return ans;
}



Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 15448
N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())
DP = [[0] * (W + 1)]
for i in range(1, N + 1):
    row = DP[i - 1][:]
    for j in range(W, -1, -1):
        new_j = j + w[i - 1]
        if 0 <= new_j <= W:
            row[new_j] = max(row[new_j], row[j] + v[i - 1])
    DP.append(row)
print(DP[-1][-1])


Measured memory_bytes: 118364
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b;
    string s;
    cin >> n >> a >> b >> s;
    int ok = 0,ab = 0;
    rep(i,n){
        if (s[i] == 'a'){
            if (ok < a+b){
                PRINT("Yes");
                ok++;
            }
            else PRINT("No");
        }
        else if (s[i] == 'b'){
            if (ok < a+b && ab < b){
                PRINT("Yes");
                ok++;
                ab++;
            }
            else{
                PRINT("No");
            }
        }
        else{
            PRINT("No");
        }
    }
}

Measured memory_bytes: 848
#include <bits/stdc++.h>
using namespace std;
vector<int> val[1048588], id[1048588], ret; int d;
void query(int a, int b, int vl, int vr, int k, int l, int r) {
	if(a <= l && r <= b) {
		int ptl = lower_bound(val[k].begin(), val[k].end(), vl) - val[k].begin();
		int ptr = lower_bound(val[k].begin(), val[k].end(), vr) - val[k].begin();
		for(int i = ptl; i < ptr; i++) ret.push_back(id[k][i]);
		return;
	}
	if(r <= a || b <= l) return;
	query(a, b, vl, vr, k * 2, l, (l + r) >> 1);
	query(a, b, vl, vr, k * 2 + 1, (l + r) >> 1, r);
}
int n, q, x[500009], y[500009], p[500009], tmp[500009], xa, ya, xb, yb;
bool compare(int i, int j) {
	return x[i] < x[j];
}
int main() {
	scanf("%d", &n);
	d = 32 - __builtin_clz(n);
	for(int i = 0; i < n; i++) scanf("%d%d", &x[i], &y[i]), p[i] = i;
	sort(p, p + n, compare);
	vector<int> xs(n), ys(n);
	for(int i = 0; i < n; i++) tmp[i] = x[p[i]];
	for(int i = 0; i < n; i++) x[i] = tmp[i];
	for(int i = 0; i < n; i++) tmp[i] = y[p[i]];
	for(int i = 0; i < n; i++) y[i] = tmp[i];
	for(int i = 0; i < n; i++) {
		val[(1 << d) + i] = vector<int>({ y[i] });
		id[(1 << d) + i] = vector<int>({ p[i] });
	}
	for(int i = (1 << d) - 1; i >= 1; i--) {
		int pl = val[i * 2].size(), pr = val[i * 2 + 1].size();
		val[i].resize(pl + pr);
		id[i].resize(pl + pr);
		int lc = 0, rc = 0;
		while(lc + rc < pl + pr) {
			bool left = true;
			if(lc == pl) left = false;
			else if(rc != pr && val[i * 2][lc] > val[i * 2 + 1][rc]) left = false;
			if(left) {
				val[i][lc + rc] = val[i * 2][lc];
				id[i][lc + rc] = id[i * 2][lc];
				lc++;
			}
			else {
				val[i][lc + rc] = val[i * 2 + 1][rc];
				id[i][lc + rc] = id[i * 2 + 1][rc];
				rc++;
			}
		}
	}
	scanf("%d", &q);
	while(q--) {
		scanf("%d%d%d%d", &xa, &xb, &ya, &yb);
		int ptl = lower_bound(x, x + n, xa) - x;
		int ptr = lower_bound(x, x + n, xb + 1) - x;
		ret.clear();
		query(ptl, ptr, ya, yb + 1, 1, 0, 1 << d);
		sort(ret.begin(), ret.end());
		for(int i : ret) printf("%d\n", i);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 185464
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;
long long n;
long long k;
long long kl[35];
long long t;
long long kn;
long long kk;
long long an[100005];
long long a[100005][32];
long long b[100005];
long long ansa;
long long ansb;
long long ans;
long long A;
long long ff;
long long limi;
int main()
{
	cin>>n;
	cin>>k;
	kk=k;
	for(long long i=0;1;i++)
	{
		kl[i]=kk&1;
		
		kk=kk>>1;
		if(kk==0)
		{
			kn=i+1;
			break;
		}
	}
	rep(i,n)
	{
		cin>>t>>b[i];
		for(long long j=0;1;j++)
		{
			a[i][j]=t&1;
			t=t>>1;
			if(t==0)
			{
				an[i]=j+1;
				break;
			}
		}
	}
	rep(i,n)
	{
		if(an[i]<kn)
		{
			ansa+=b[i];
		}
	}
	long long f;
	rep(i,n)
	{
		f=1;
		rep(j,max(an[i],kn))
		{
			if(kl[j]<a[i][j])f=0;
		}
		ansb+=(f*b[i]);
	}
	/*rep(i,n)
	{
		rep(j,kn)
		{
			cout<<a[i][j];
		}
		cout<<endl;
	}*/
	for(long long i=0;i<n;i++)
	{
		if(kn<an[i])b[i]=0;
	}
	for(long long keta=1;keta<kn;keta++)
	{
		ans=0;
		//f=1;
		rep(i,n)
		{
			f=1;
			for(long long j=keta;j<kn;j++)
			{
				if(kl[j]<a[i][j])f=0;
			}
			ff=0;
			for(long long j=keta-1;j>=0;j--)
			{
				if(kl[j]==1)
				{
					limi=j;
					break;
				}
				if(j==0)
				{
					ff=1;
				}
			}
			if(ff==1)
			{
				rep(j,keta)
				{
					if(a[i][j]==1)f=0;
				}
				if(f==1)
				{
					ans+=b[i];
				}
			}
			else
			{
				rep2(j,limi,keta)
				{
					if(a[i][j]==1)f=0;
				}
				if(f==1)
				{
					ans+=b[i];
				}
			}
		}
		//cout<<ans<<endl;
		A=max(ans,A);
	}
	cout<<max(A,max(ansa,ansb))<<endl;
	return  0;
}

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

long long md(pair<long long,long long> x,pair<long long,long long> y){
    return max(x.first,y.first)-min(x.first,y.first)+max(x.second,y.second)-min(x.second,y.second);
}

int main(){
    int N,ans=0;
    cin >> N;
    vector<int> vec(N-1);
    for(int i=0;i<N-1;i++){
        cin >> vec[i];
    }
    ans+=vec[0];
    for(int i=1;i<N-1;i++){
        ans+=min(vec[i],vec[i-1]);
    }
    ans+=vec[N-2];
    cout << ans << endl;
}

Measured memory_bytes: 256
//#include <ext/pb_ds/assoc_container.hpp> 
 //#include <ext/pb_ds/tree_policy.hpp>
// #include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e17;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power(((((a)%mod)*((a)%mod))%mod),b/2)%mod;
    else return (((a)%mod)*(power(((((a)%mod)*((a)%mod))%mod),b/2)%mod))%mod;
}
inline ll inverse(ll a,ll md) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}
  
  
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution
const int ce=1e9+7;
ll fast_mod(ll input)
{
    return input < ce ? input : input%ce;
}
#define pi acos(-1)

int32_t main()
{
    IOS
  

    int n;
    cin>>n;
    int a,b;
    cin>>a>>b;
    int x=(a/n)*n;
    if(x==a)
    {
        cout<<"OK"<<endl;
        return 0;
    }
    x+=n;
    if(x<=b)
    {
        cout<<"OK";
        return 0;
    }
    cout<<"NG";
}       


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 200000
#define mod1 1000000007
#define mod2 1000000009
#define mod3 998244353
#define endl '\n'
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
ll dp[3001][3001];
vector <char> V;
void fun(ll idx1,ll idx2,string S1,string S2)
{
	if(idx1==0 || idx2==0)
		return;
	if(dp[idx1][idx2] == (1+dp[idx1-1][idx2-1]) && S1[idx1]==S2[idx2])
	{
		V.push_back(S1[idx1]);
		fun(idx1-1,idx2-1,S1,S2);
	}
	else if(dp[idx1][idx2] == dp[idx1-1][idx2])
		fun(idx1-1,idx2,S1,S2);
	else
		fun(idx1,idx2-1,S1,S2);
	return;
}

int main()
{
    IO
	clock_t begin = clock();
    string s1,s2,S1,S2;
    cin>>s1>>s2;
    S1 = "$" + s1;
    S2 = "$" + s2;
    ll n = s1.size(),m = s2.size();
    for(ll i=0;i<=n;i++)
    {
    	for(ll j=0;j<=m;j++)
    		dp[i][j] = 0;
    }
    for(ll i=1;i<=n;i++)
    {
    	for(ll j=1;j<=m;j++)
    	{
    		dp[i][j] = max(dp[i][j],max(dp[i-1][j],dp[i][j-1]));
    		if(S1[i]==S2[j])
    			dp[i][j] = max(dp[i][j],1+dp[i-1][j-1]);
    	}
    }
    fun(n,m,S1,S2);
    reverse(V.begin(),V.end());
    for(auto it:V)
    	cout<<it;
    cout<<endl;
    // cout<<dp[n][m]<<endl;
    // cout<<double(clock() - begin)/CLOCKS_PER_SEC<<endl;
    return 0;
}

Measured memory_bytes: 103524
M,D = map(int,input().split())
r = 0
for i in range(M):
	m = i+1
	for j in range(D):
		d = j+1
		if d<20 or d%10 == 1:
			continue
		if (int(d/10))*(d%10) == m:
			r = r + 1
			
print(r)

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

int main(){
    int n, m;
    cin >> n >> m;
    // n is the size of vector.
    vector<int> v(n); // we are declaring by size.
    int sum = 0;
    for(int i =0; i < n; i++){
        cin >> v[i];
        sum += v[i];
    } // sum is created.

    int cnt = 0;
    for(int i =0; i < n; i++){
        if(ceil(sum / (4 * m * 1.0)) <= v[i]){
            cnt++;
        }
       
    }
    
    if(cnt >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    
}













Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int pow(int x,int y){
  int z = 1;
  while(y != 0){
    z *= x;y--;
  }
  return z;
}
int main(){
  int n,m,i,j,k,s,ans = 0;cin >> n >> m;bool ok;
  vector<vector<int>> a(m);int f[n] = {},p[m],now[m];f[0] = -1;
  for(i=0;i<m;i++){
    cin >> k;
    for(j=0;j<k;j++){
      cin >> s;
      a[i].push_back(s);
    }
  }
  for(i=0;i<m;i++) cin >> p[i];
  for(i=0;i<pow(2,n);i++){
    f[0]++;
    for(j=0;j<n;j++){
      if(f[j]==2){
        f[j]=0;f[j+1]++;
      }
    }
    int now[m] = {};
    for(j=0;j<m;j++){
      for(auto x:a[j]){
        if(f[x-1]) now[j]++;
      }
    }
    ok = true;
    for(j=0;j<m;j++){
      if(now[j]%2!=p[j]) ok = false;
    }
    ans += ok;
  }
  cout << ans << endl;
}

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

class RURM {
public:
	using t1 = int;
	using t2 = int;

	static t1 id1() {
		return INT_MAX;
	}
	static t2 id2() {
		return -1;
	}
	static t1 op1(const t1& l, const t1& r) {
		return min(l, r);
	}
	static t1 op2(const t1& l, const t2& r) {
		return r != id2() ? r : l;
	}
	static t2 op3(const t2& l, const t2& r) {
		return r != id2() ? r : l;
	}
};

template <typename M>
class LazySegmentTree {
	using T1 = typename M::t1;
	using T2 = typename M::t2;
	const int h, n;
	vector<T1> data;
	vector<T2> lazy;
	void push(int node) {
		if (lazy[node] == M::id2()) return;
		if (node < n) {
			lazy[node * 2] = M::op3(lazy[node * 2], lazy[node]);
			lazy[node * 2 + 1] = M::op3(lazy[node * 2 + 1], lazy[node]);
		}
		data[node] = M::op2(data[node], lazy[node]);
		lazy[node] = M::id2();
	}
	void update(int node) {
		data[node] = M::op1(M::op2(data[node * 2], lazy[node * 2])
			, M::op2(data[node * 2 + 1], lazy[node * 2 + 1]));
	}
public:
	LazySegmentTree(int n_)
		: h(ceil(log2(n_))), n(1 << h), data(n * 2, M::id1()), lazy(n * 2, M::id2()) {}
	LazySegmentTree(int n_, T1 v1)
		: h(ceil(log2(n_))), n(1 << h), data(n * 2, v1), lazy(n * 2, M::id2()) {}
	LazySegmentTree(const vector<T1>& data_)
		: h(ceil(log2(data_.size()))), n(1 << h), data(n * 2, M::id1()), lazy(n * 2, M::id2()) {
		init(data_);
	}
	void init() {
		for (int i = n - 1; i >= 1; i--) data[i] = M::op1(data[i * 2], data[i * 2 + 1]);
	}
	void init(const vector<T1>& data_) {
		for (int i = 0; i < (int)data_.size(); i++) data[i + n] = data_[i];
		init();
	}
	void update(int l, int r, T2 val) {
		l += n, r += n - 1;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		int tl = l, tr = r;
		r++;
		while (l < r) {
			if (l & 1) lazy[l] = M::op3(lazy[l], val), l++;
			if (r & 1) r--, lazy[r] = M::op3(lazy[r], val);
			l >>= 1; r >>= 1;
		}
		while (tl >>= 1, tr >>= 1, tl) {
			if (lazy[tl] == M::id2()) update(tl);
			if (lazy[tr] == M::id2()) update(tr);
		}
	}
	T1 find(int l, int r) {
		l += n, r += n - 1;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		r++;
		T1 res1 = M::id1(), res2 = M::id1();
		while (l < r) {
			if (l & 1) res1 = M::op1(res1, M::op2(data[l], lazy[l])), l++;
			if (r & 1) r--, res2 = M::op1(M::op2(data[r], lazy[r]), res2);
			l >>= 1; r >>= 1;
		}
		return M::op1(res1, res2);
	}
};
int main()
{
	int n, q, com, x, y, val;
	cin >> n >> q;
	LazySegmentTree<RURM> st(n);
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", st.find(x, y + 1));
		}
		else {
			cin >> val;
			st.update(x, y + 1, val);
		}
	}
	return 0;
}

Measured memory_bytes: 5124
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;

const int N = 1e5+5;
int n,m,A[N];

vector<int> at[N];

int main() {
	scanf("%d%d",&n,&m);
	ll tot_cross = 0;
	ll tot_score = 0;
	for(int i = 0; i < n; ++i) {
		scanf("%d",A+i),--A[i];
		at[A[i]].pb(i);
		if(i) {
			if(A[i-1] < A[i]) tot_score += (A[i]-A[i-1]+m)%m;
			else {
				++tot_cross;
				tot_score += A[i]+1;
			}
		}
	}

	ll ans = tot_score;
	for(int x = 1; x < m; ++x) {
		//remove any no longer applicable
		for(int i : at[x-1]) {
			if(i != 0) {
				tot_score += (A[i]-A[i-1]+m)%m-1,--tot_cross;
			}
		}
		//shift crossers
		tot_score -= tot_cross;
		//discover new crossers
		for(int i : at[x-1])
			if(i != n-1) {
				++tot_cross;
			}
		//min ans
		ans = min(ans,tot_score);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 5376
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    fa = [ f() for i in range(n)]
    
    pa = [ f() for i in range(n)]

    mxa = int(-1e9)
    for i in range(1,2**10):
        ans = 0
        for j in range(n):
            cnt = 0
            for k in range(10):
                if i&(1<<k) and fa[j][k]:
                    cnt += 1
            ans += pa[j][cnt]
        mxa = max(mxa, ans)

    print(mxa)
            

solve()


Measured memory_bytes: 3064
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#define for(i,n) for(int i=0; i<(n); i++)
#define array(n,a) int a[n]; for (i, n) { scanf("%d", &a[i]); }
#define lint long long
#define mod 1000000007
#define P pair<long long,long long>
#define sort(a) sort((a).begin(),(a).end())
#define all(a) a.begin(),a.end()
#define INF 1000000000000000
#define endl "\n"
#define put(a) cout<<a<<endl
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
lint a, b, c, d;
int l, m, n;
double e, f, g, h;

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

	cin >> n;
	vector<int> vec(n);
	for (i, n) {
		cin >> vec[i];
	}
	sort(vec);
	int sum = 0;
	for (i, n - 1) {
		sum += vec[i];
	}
	if (sum > vec[n - 1]) {
		put("Yes");
	}
	else {
		put("No");
	}
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー


Measured memory_bytes: 256
using System;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; i < 10; i++)
            {
                for(int w=1;w<10;w++)
                {
                    Console.WriteLine(i + "x" + w + "=" + i * w);
                } 
                }
        }
    }
}

Measured memory_bytes: 8956
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string>
#include<math.h>
#include<string.h>
using namespace std;
int main()
{
    char ch[200];
    scanf("%s",ch);
    int t=strlen(ch);
    int i;
    int f1=0,f2=0,f3=0;
   for(i=0;i<(t-1)/2;i++)
   {
       if(ch[i]!=ch[t-1-i])
       {
           f1=1;
           break;
       }
   }
   for(i=0;i<(t-1)/4;i++)
    {
       if(ch[i]!=ch[(t-1)/2-1-i])
       {
           f2=1;
           break;
       }
   }
   for(i=(t+1)/2;i<(3*t-1)/4;i++)
   {
       if(ch[i]!=ch[(3*t-1)/2-i])
       {
           f3=1;
           break;
       }
   }
   // printf("%d %d %d\n",f1,f2,f3);
   if(f1||f2||f3)
    printf("No\n");
   else
    printf("Yes\n");
        return 0;
}


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

#define MAXN 5007
#define inf 1000000007

int n , k ;
int p[ MAXN ] ;
int c[ MAXN ] ;
bool used[ MAXN ] ;

vector < int > v ;

long long ans = -inf ;

void proc ( ) {
    int sz = v.size ( ) ;
    long long total = 0 ;
    for ( int i = 0 ; i < sz ; ++ i ) {
        v.push_back ( v[ i ] ) ;
        total += v[ i ] ;
    }
    if ( k >= sz ) { 
        ans = max ( ans , total * ( k / sz ) ) ;
    }
    for ( int i = 0 ; i < sz ; ++ i ) {
        long long sm = 0 ;
        for ( int j = i ; j < i + sz ; ++ j ) {
            if ( ( j - i + 1 ) > k ) { break ; }
            sm += v[ j ] ;
            ans = max ( ans , sm ) ;
            ans = max ( ans , sm + total * ( ( k - ( j - i + 1 ) ) / sz ) ) ;
        }
    }
}

void input ( ) {
    cin >> n >> k ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        cin >> p[ i ] ;
    }
    for ( int i = 1 ; i <= n ; ++ i ) {
        cin >> c[ i ] ;
    }
}

void solve ( ) {
    for ( int i = 1 ; i <= n ; ++ i ) {
        if ( used[ i ] == true ) { continue ; }
        v.clear ( ) ;
        int x = i ;
        while ( used[ x ] == false ) {
            v.push_back ( c[ x ] ) ;
            used[ x ] = true ;
            x = p[ x ] ;
        }
        proc ( ) ;
    }
    cout << ans << "\n" ;
}


int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 3812
import numpy as np
import itertools

n = int(input())

xys = [ list(map(int,input().split())) for _ in range(n) ]

l = 0
for path in itertools.permutations(xys, n):
    for i in range(n-1):
        nx = path[i+1][0]
        ny = path[i+1][1]
        x  = path[i][0]
        y  = path[i][1]
        l += np.sqrt( (nx-x)**2 + (ny-y)**2 )

for i in range(n):
    l /= (i+1)

print(l)

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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  int place = 0;
  int ans = 1;
  for(int j=0; j<N; j++){
    place += vec.at(j);
    if(place <= X){
      ans++;
    }
    else{
      break;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<string>
#include<tuple>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline void solve(void){
  int N;
  in(N);
  vector<long>A(N),B(N);
  rep(i,N)in(A[i]);
  rep(i,N)in(B[i]);
  long cnt=0;
  rep(i,N){
    if(A[i]<B[i])cnt+=(B[i]-A[i])/2;
    else cnt-=A[i]-B[i];
  }
  out(cnt<0?"No":"Yes");
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 384
def main():

    H, W, K = map(int, input().split())

    c = []
    for _ in range(H):
        c.append(list(input()))
    # print(c)


    tot = 0
    for i in range(H):
        for j in range(W):
            if c[i][j] == '#':
                tot += 1

    b_rows = dict()
    for i in range(H):
        cnt = 0
        for j in range(W):
            if c[i][j] == '#':
                cnt += 1
        b_rows[i] = cnt

    b_cols = dict()
    for j in range(W):
        cnt = 0
        for i in range(H):
            if c[i][j] == '#':
                cnt += 1
        b_cols[j] = cnt

    cols = [[]]
    for i in range(W):
        tmp = []
        for v in cols:
            tmp.append(v + [0])
            tmp.append(v + [1])
        cols = tmp

    rows = [[]]
    for i in range(H):
        tmp = []
        for v in rows:
            tmp.append(v + [0])
            tmp.append(v + [1])
        rows = tmp

    ans = 0
    for rw in rows:
        for cl in cols:
            cnt = 0
            for i in range(H):
                if rw[i] == 1: cnt += b_rows[i]
            for j in range(W):
                if cl[j] == 1: cnt += b_cols[j]
            for i in range(H):
                for j in range(W):
                    if rw[i] == 1 and cl[j] == 1 and c[i][j] == '#':
                        cnt -= 1
            if tot - cnt == K:
                # print(rw, cl)
                ans += 1
    return ans




if __name__ == '__main__':
    print(main())

Measured memory_bytes: 68424
from collections import Counter
N=int(input())
C=Counter(map(int,input().split()))
R=[]
for k in sorted(C)[::-1]:
    if C[k]>=4:
        if R:
            R+=[k]
        else:
            R=[k,k]
        break
    elif C[k]>=2:
        R+=[k]
        if len(R)==2:
            break
if len(R)==2:
    print(R[0]*R[1])
else:
    print(0)

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

int main() {
	int m,d,cnt=0;
	cin>>m>>d;
	if(d <22){
		cout<<0<<"\n";
		return 0;
	}
	//int a = d %10;
	//int b = ((d/10)%10)*10;
	//if(a==0) a+=10;
	//cout<<"a b "<<a<<" "<<b<<endl;
	for(int i =0;i<=d;i++){
		int a = i %10;
			int b = (i/10)%10;
			if((b*10)+(a) <= d && a>=2 && b>=2){
			for(int k = 1;k<=m;k++){
				if(a*b == k) {
					//cout<<a<<" "<<b<<" "<<k<<endl;
					cnt++;}}
		}
		}
	

	cout<<cnt<<"\n";
}


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

int main() {
  string s;
  cin >>s;
  int n=s.size();
  int dai=s.size()/2;
  if(dai*2==s.size())dai--;
  while(dai){
    string a,b;
    a=s.substr(0,dai);
    b=s.substr(dai,dai);
    //cout<<dai<<" "<<a<<" "<<b<<endl;
    if(a==b){
      cout<<a.size()*2<<endl;
      return 0;
    }else{
      dai--;
      if(dai==2){
        if(s[0]==s[1]){
          cout<<2<<endl;
          return 0;
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
 
int main()
{
   int a;
   cin >> a;
   if(a == 1){
       cout << "Hello World" << endl;
       return 0;
   }
   else{
       int b, c;
       cin >> b >> c;
       cout << b+c << endl;
       return 0;
   }
}

Measured memory_bytes: 256
import math

def is_prime_number(x):
    is_prime = True
    for i in range(2, int(math.sqrt(x) + 1)):
        if x % i == 0:
            is_prime = False
            break
    return is_prime

n = int(input())
cnt = 0
for _ in range(n):
    num = int(input())
    if is_prime_number(num):
        cnt += 1

print(cnt)


Measured memory_bytes: 5672
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll n, m;
    cin >> n >> m;    

    vvl G(n);
    vl indeg(n);  // 各頂点の入次数
    rep(i, m) {
        ll x, y;
        cin >> x >> y;
        x--;  y--;
        G[x].pb(y);
        indeg[y]++;
    }
    
    queue<ll> Q;
    rep(v, n) {
        if(indeg[v] == 0) {
            Q.push(v);
        }
    }

    vl dp(n);
    while(!Q.empty()) {
        ll v = Q.front();
        Q.pop();
        for(auto u : G[v]) {
            indeg[u]--;
            if(indeg[u] == 0) {
                Q.push(u);
                dp[u] = max(dp[u], dp[v] + 1);
            }
        }
    }

    ll ans = 0;
    rep(v, n) {
        ans = max(ans, dp[v]);
    }

    out(ans);
    re0;
}

Measured memory_bytes: 7296
#include <stdio.h>
int main(void){
    int a[20000], b[20000], dummy;
    char op;
    int i, x[20000], sum = 0;

    for(i = 0; i < 20000; i++){
        scanf("%d %c %d", &a[i], &op, &b[i]);
        if(op == '?') break;
        sum += 1;

        if(op == '+') x[i] = a[i] + b[i];
        else if(op == '-') x[i] = a[i] - b[i];
        else if(op == '*') x[i] = a[i] * b[i];
        else x[i] = a[i] / b[i];
    }

    for(i = 0; i < sum; i++){
        printf("%d\n", x[i]);
    }
    return 0;
}


Measured memory_bytes: 2128
import math
a,b,h,m = map(int, input().split())
if h > 12:
    h_c = h-12
else:
    h_c = h
p_d = 6*(abs((h_c)*5+5*(m/60) - m)) #時針も分針の位置で一変わるんだった・・・
if p_d >= 180:
    p_d2 = 360 - p_d 
    d_2 = a**2 + b**2 - 2*a*b*math.cos(math.radians(p_d2))
    print(math.sqrt(d_2))
else:
    d_2 = a**2 + b**2 - 2*a*b*math.cos(math.radians(p_d))
    print(math.sqrt(d_2))

Measured memory_bytes: 9520
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

// H =height/witdh
var H int

// W =height/witdh
var W int

func main() {
	scanInit()

	H = nextInt()
	W = nextInt()
	s := nextGrid(H, W)

	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if s[i][j] == "." {
				s[i][j] = getBombnum(i, j, "#", s)
			}
		}
	}

	DBGprintGrid(s)

}

// DBGprintGrid print the grid
//! DBG
func DBGprintGrid(g [][]string) {
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			fmt.Printf("%s", g[i][j])
		}
		fmt.Printf("\n")
	}
}
func getBombnum(i, j int, target string, s [][]string) string {
	cnt := 0

	// 上段
	if i > 0 && j > 0 {
		if s[i-1][j-1] == target {
			cnt++
		}
	}
	if i > 0 {
		if s[i-1][j] == target {
			cnt++
		}
	}
	if i > 0 && j < W-1 {
		if s[i-1][j+1] == target {
			cnt++
		}
	}
	// 中段
	if j > 0 {
		if s[i][j-1] == target {
			cnt++
		}
	}
	if j < W-1 {
		if s[i][j+1] == target {
			cnt++
		}
	}
	// 下段
	if i < H-1 && j > 0 {
		if s[i+1][j-1] == target {
			cnt++
		}
	}
	if i < H-1 {
		if s[i+1][j] == target {
			cnt++
		}
	}
	if i < H-1 && j < W-1 {
		if s[i+1][j+1] == target {
			cnt++
		}
	}

	return fmt.Sprintf("%d", cnt)
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}
func nextGrid(a int, b int) [][]string {
	mat := make([][]string, a)
	for i := 0; i < a; i++ {
		mat[i] = make([]string, b)
		tmp := nextStr()
		mat[i] = strings.Split(tmp, "")
	}
	return mat
}


Measured memory_bytes: 1880
#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)

using int64 = long long;
using i64 = long long;

const int inf = 1 << 30;
const i64 inf64 = 1ll << 60;

const int mod = 1e9 + 7;

template<typename T>
vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
   return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

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

struct StronglyConnectedComponents {
   vector<vector<int>> g, rg;
   vector<int> comp, order, used;

   StronglyConnectedComponents(const vector<vector<int>>& g) : g(g) {
      rg.resize(g.size());
      for (int i = 0; i < g.size(); ++i) {
         for (auto& e : g[i]) {
            rg[e].emplace_back(i);
         }
      }
   }

   int operator[](const int& k) {
      return comp[k];
   }

   void dfs(int u) {
      if (used[u]) return;
      used[u] = true;
      for (auto& v : g[u]) dfs(v);
      order.emplace_back(u);
   }

   void rdfs(int u, int k) {
      if (comp[u] != -1) return;
      comp[u] = k;
      for (auto& v : rg[u]) rdfs(v, k);
   }

   void build(vector<vector<int>>& t) {
      comp.assign(g.size(), -1);
      used.assign(g.size(), 0);
      for (int i = 0; i < g.size(); ++i) dfs(i);
      int k = 0;
      for (int i = g.size() - 1; i >= 0; --i)
         if (comp[order[i]] == -1) rdfs(order[i], k++);

      t.resize(k);
      for (int i = 0; i < g.size(); ++i) {
         for (auto& v : g[i]) {
            int x = comp[i], y = comp[v];
            if (x == y) continue;
            t[x].emplace_back(y);
         }
      }
   }
};

int main() {
   int V, E; cin >> V >> E;
   vector<vector<int>> g(V);
   rep(i, E) {
      int u, v; cin >> u >> v;
      g[u].emplace_back(v);
   }

   StronglyConnectedComponents scc(g);
   vector<vector<int>> buff;
   scc.build(buff);

   int Q; cin >> Q;
   rep(i, Q) {
      int u, v; cin >> u >> v;
      if (scc[u] == scc[v]) cout << 1 << endl;
      else cout << 0 << endl;
   }
}


Measured memory_bytes: 5080
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = list()
x = list()
for i in range(m):
    a,b = map(int, input().split())
    p.append(a)
    x.append(b)
for i in range(m):
    time = 0
    test = p[i]-1
    for j in range(n):
        if test == j:
            time += x[i]
        else:
            time += t[j]
    print(time)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import copy

N = int(input())
list = [input().split() for i in range(N)]
list2 = copy.deepcopy(list)
list2.sort(key=lambda x:(x[0],-int(x[1])))

for i in range(N):
    a = list2[i]
    b = list.index(a)
    print(int(b + 1))

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

#define MAX_V 100001
#define INF (1e9 + 1)
#define REP(i,n) for(long long int (i)=0;(i) < (n);(i)++)
#define REV(i,n) for(long long int (i)=(n-1);(i) > -1;(i)--)

int N;
long long mid_v_,mid_v;
long long X[200001];
long long Y[200001];

int main(){
  cin >> N;
  REP(i,N){
    cin >> X[i];
    Y[i] = X[i];
  }
  sort(X,X+N);
  mid_v_ = X[N/2 - 1];
  mid_v = X[N/2];
  REP(i,N){
    if(Y[i] <= mid_v_) cout << mid_v << endl;
    else cout << mid_v_ << endl;
  }

  return 0;

}


Measured memory_bytes: 5376
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
int main() {
	int a, b, c, d, e, f;
	fscanf(stdin, "%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	P(d, a + b * 5 + c * 10 + d * 50 + e * 100 + f * 500 > 999);
	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main()
{
    int32 h,w;
    cin >> h >> w;
    vector<vector<int32>> a(h, vector<int32>(w, INF));
    queue<pii> que;
    REP(i,h)REP(j,w){
        char ai;
        cin >> ai;
        if(ai == '#'){
            a[i][j] = 0;
            que.push(mp(i,j));
        }
    }while(!que.empty()){
        int32 dy[4] = {0,1,0,-1};
        int32 dx[4] = {1,0,-1,0};
        int32 y,x;
        tie(y, x) = que.front();
        que.pop();
        REP(k,4){
            int32 ny = y + dy[k];
            int32 nx = x + dx[k];
            if(ny < 0 || h <= ny)continue;
            if(nx < 0 || w <= nx)continue;
            if(a[ny][nx] <= a[y][x] + 1)continue;
            a[ny][nx] = a[y][x] + 1;
            que.push(mp(ny,nx));
        }
    }
    int32 ans = 0;
    REP(i,h)REP(j,w){
        ans = max(ans, a[i][j]);
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 24500
def counting(numbers) -> int:
    count = 0
    for i in range(1, len(numbers) - 1):
        pre = numbers[i-1]
        curr = numbers[i]
        next_ = numbers[i+1]
        if pre < curr and curr == next_:
            count += 1
        elif next_ < curr and curr == pre:
            count += 1
        elif pre < curr < next_ or next_ < curr < pre:
            count += 1
    return count
 
_ = input()
numbers_str = input()
result = counting([int(c) for c in numbers_str.split(' ')])
print(result)


Measured memory_bytes: 3064
/*Hey, What's up?*/

#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<long long>v;
int main()
{
    fastio;
    long long a=0,b=0,c,d,e,f=0,l,g,m,n,k,i,j,t,p,q;
    cin>>a>>b;
    g=__gcd(a,b);
    a*=b;
    a/=g;
    cout<<a<<'\n';
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (h, w) = readLongList()
    if (h == 1L || w == 1L) {
        println(1)
    } else {
        println((h * w + 1) / 2)
    }
}


fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 38012