akhauriyash/Code-Regression huggingface dataset:
A = input()
B = input()
C = input()
X = input()

A,B,C,X = map(int, [A,B,C,X])

pattern_count = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            x = a*500 + b*100 + c*50
            if X == x:
                pattern_count += 1

print(pattern_count)

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;


int main(){
  int N,X,T;
  cin >> N >> X >> T;
  
  int ans;
  if(N%X ==0){
  ans = (N/X)*T;
  }
  else{
    ans = (N/X+1)*T;
  }
  
  cout << ans << endl;
      
}

      
      
       

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


int main(){
    int k,x;
    cin>>k>>x;
    for(int i=x-k+1;i<=x+k-1;i++){
        cout<<i;
        if(i!=x+k-1) cout<<' ';
    }
    cout<<endl;
}

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

int main()
{
    int a,b,q;
    cin >> a >> b >> q;
    vector<ll> s(a), t(b), x(q);
    for(auto& si:s) cin >> si;
    for(auto& ti:t) cin >> ti;
    for(auto& xi:x) cin >> xi;

    const ll INF = 1e11;
    for(auto xi:x) {
        vector<vector<ll>> d(2,vector<ll>(2,INF));

        auto itr = lower_bound(s.begin(),s.end(),xi);
        if(itr != s.end()) d[0][1] = *itr - xi;
        if(itr != s.begin()) d[0][0] = xi - *(--itr);
        itr = lower_bound(t.begin(),t.end(),xi);
        if(itr != t.end()) d[1][1] = *itr - xi;
        if(itr != t.begin()) d[1][0] = xi - *(--itr);

        ll ans = min(max(d[0][0], d[1][0]), max(d[0][1], d[1][1]));
        if(d[0][0] != INF && d[1][1] != INF)
            ans = min(ans, 2*min(d[0][0],d[1][1]) + max(d[0][0],d[1][1]));
        if(d[0][1] != INF && d[1][0] != INF)
            ans = min(ans, 2*min(d[0][1],d[1][0]) + max(d[0][1],d[1][0]));

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

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

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

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

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

D, G = s_inpl()
p, c = [], []

for i in range(D):
    pi, ci = s_inpl()
    p.append(pi)
    c.append(ci)

ans = INF
for i in range(1<<D):
    ct = 0
    score = 0
    for j in range(D):
        if i>>j&1:
            score += c[j]
            score += p[j] * (j+1) * 100
            ct += p[j]
    for j in range(D-1, -1, -1):
        if i>>j&1: continue
        if score >= G: break
        g = (j+1)*100
        got = (G-score+g-1)//g
        score += min(got, p[j]) * g
        ct += min(got, p[j])
    ans = min(ans, ct)
print(ans)


Measured memory_bytes: 3564
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max<int>(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max<int>(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int N, R;
  std::cin >> N >> R;
  if (N >= 10) {
    std::cout << R << '\n';
  }
  else {
    std::cout << R + 100 * (10 - N) << '\n';
  }
  return 0;
}


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

int main(void)
{
   int num,rem = 0,track = 0;
   cin>>num;

   while(num > 0)
   {
       rem = num % 10;
       if(rem == 7)
        track++;
       num = num/10;
   }
   if(track == 0)
    cout<<"No\n";
   else
    cout<<"Yes\n";
   
   return 0;
}


Measured memory_bytes: 3568
n = int(input())
s = list(str(input()))

alp = ['A','B','C','D','E','F','G','H','I','J',
       'K','L','M','N','O','P','Q','R','S','T',
       'U','V','W','X','Y','Z']


ans = ''

for x in s:
    ind = alp.index(x)
    ans += alp[(ind+n)%26]

print(ans)


Measured memory_bytes: 41068
#include <bits/stdc++.h>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
const int MOD = 1000000007;

long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

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

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
  int N;
  double ans=0;
  cin >> N;
  
  if(N%2==0) ans=1.0/2;
  else ans = (N+1)/2.0/N;
  cout << fixed << setprecision(10) << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3668
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
    static List<int> s = new List<int>();
    static decimal result;
static StringBuilder sb = new StringBuilder();
static int N,M,K,A,B,C,D;
  static string a;
    static void Main()
    {
      Read5();
//A,BC,それ以外の３種に分ける。
//それ以外は区切り。
//区切りからそれぞれのBCまで何回Aをまたぐか。
//総合計が求める数
      int count=0;
      for(int i=0;i<a.Length-1;i++){if(a[i]=='A'){count++;}
      else if
      (a[i]=='B' && a[i+1]=='C'){result+=count;i++;}
                                    else{count=0;}
                                   }
Console.WriteLine(result.ToString());
    }


    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }
 
    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
   {
       string[] tmp = Console.ReadLine().Split(' ');
       for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
       N = int.Parse(tmp[0]);
       K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {
a= Console.ReadLine();
 
    }


}

Measured memory_bytes: 14036
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    int n;
    cin >> n;
    int keta = n / 100;
    if(n <= keta*111)cout << keta*111;
    else cout << ++keta*111;
}

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

const int MAX = 2 * 100005;
int A[MAX];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) scanf("%d", &A[i]);
    int l, r, s, x;
    l = r = 0;
    s = x = A[0];
    long long ans = 0;
    while (r < N) {
        if (s == x) {
            ans += 1 + r - l;
            r++;
            s += A[r];
            x ^= A[r];
        } else {   
            s -= A[l];
            x ^= A[l];
            l++;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    string A,B; cin >> A >> B;
    if(A.size()>B.size()){
        cout << "GREATER" << endl;
    }else if(A.size()<B.size()){
        cout << "LESS" << endl;
    }else{
        int f=0;
        for(int i=0;i<A.size();i++){
            if(A[i]>B[i]){
                f=1;break;
            }else if(A[i]<B[i]){
                f=-1;break;
            }
        }
        if(f==1) cout << "GREATER" << endl;
        else if(f==-1) cout << "LESS" << endl;
        else cout << "EQUAL" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include<cstdio>  
#include<iostream>  
#include<algorithm>  
#include<cstdlib>  
#include<cstring>
#include<string>
#include<climits>
#include<vector>
#include<cmath>
#include<map>
#define LL long long
#define pii pair<int,int>
#define mp make_pair
 
using namespace std;
 
inline char nc(){
	/*
  static char buf[100000],*p1=buf,*p2=buf;
  if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2) return EOF; }
  return *p1++;
  	*/return getchar();
}
 
inline void read(int &x){
  char c=nc();int b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
 
inline void read(LL &x){
  char c=nc();LL b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}

inline int read(char *s)
{
	char c=nc();int len=1;
	for(;!(c>='a' && c<='z');c=nc()) if (c==EOF) return 0;
	for(;(c>='a' && c<='z');s[len++]=c,c=nc());
	s[len++]='\0';
	return len;
}

inline void read(char &x){
  for (x=nc();!(x>='A' && x<='Z');x=nc());
}

int wt,ss[19];
inline void print(int x){
	if (x<0) x=-x,putchar('-'); 
	if (!x) putchar(48); else {
	for (wt=0;x;ss[++wt]=x%10,x/=10);
	for (;wt;putchar(ss[wt]+48),wt--);}
}
inline void print(LL x){
	if (x<0) x=-x,putchar('-');
	if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}
}

int n,m,a[200010],b[200010];

int main()
{
	read(n);read(m);
	if (m==1 || m==2*n-1) puts("No");
	else
	{
		puts("Yes");
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		if (m>2)
		{
			a[n-1]=m-1,a[n]=m,a[n+1]=m+1,a[n+2]=m-2;
			b[m-2]=1,b[m-1]=1,b[m]=1,b[m+1]=1;
		}
		else
		{
			a[n-1]=m+1,a[n]=m,a[n+1]=m-1,a[n+2]=m+2;
			b[m-1]=1,b[m]=1,b[m+1]=1,b[m+2]=1;
		}
		int x=1;
		for (int i=1;i<n-1;i++)
		{
			while (b[x]==1) x++;
			a[i]=x;b[x]=1;
		}
		for (int i=n+3;i<=2*n-1;i++)
		{
			while (b[x]==1) x++;
			a[i]=x;b[x]=1;
		}
		for (int i=1;i<=2*n-1;i++)
			print(a[i]),puts("");
	}
	return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
 
using namespace std;
 
int N, M;
 
struct edge
{
  int u, v, cost, time;
  double p;
 
  edge(int u, int v, int cost, int time) : u(u), v(v), cost(cost), time(time) {};
 
  bool operator<(const edge &e) const
  {
    return p < e.p;
  }
 
};
 
typedef vector< edge > Edges;
 
class DisjointSet
{
private:
  vector< int > rank, p;
 
  void link(int x, int y)
  {
    if(rank[x] > rank[y]) {
      p[y] = x;
    } else {
      p[x] = y;
      if(rank[x] == rank[y]) rank[y]++;
    }
  }
 
public:
  DisjointSet() {}
 
  DisjointSet(int size)
  {
    rank.resize(size, 0);
    p.resize(size, 0);
  }
 
  void makeSet(int x)
  {
    p[x] = x, rank[x] = 0;
  }
 
  void Union(int x, int y)
  {
    link(findSet(x), findSet(y));
  }
 
  int findSet(int x)
  {
    return (x != p[x] ? p[x] = findSet(p[x]) : p[x]);
  }
};
 
double kruskal(Edges &edges, int V)
{
  sort(edges.rbegin(), edges.rend());
  DisjointSet uf_tree(V);
  for(int i = 0; i < V; i++) {
    uf_tree.makeSet(i);
  }
  double ret = 0;
  for(int i = 0; i < edges.size(); i++) {
    edge &e = edges[i];
    ret += e.p;
  }
  for(int i = 0; i < edges.size(); i++) {
    edge &e = edges[i];
    if(uf_tree.findSet(e.u) != uf_tree.findSet(e.v)) {
      uf_tree.Union(e.u, e.v);
      ret -= e.p;
    }
  }
  return ret;
}
 
bool calc(Edges &edges, double value)
{
  double ret = 0.0;
  for(int i = 0; i < edges.size(); i++) {
    edge &e = edges[i];
    e.p = (double) e.cost - (double) e.time * value;
  }
  return kruskal(edges, N) <= 0.0;
}
 
int main()
{
  Edges edges;
  scanf("%d %d", &N, &M);
  for(int i = 0; i < M; i++) {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    edges.push_back(edge(a, b, d, c));
  }
  double row = 0.0, high = 1e9;
  for(int i = 0; i < 100; i++) {
    double mid = (row + high) / 2;
    if(calc(edges, mid)) high = mid;
    else row = mid;
  }
  cout << fixed << setprecision(5) << (high + row) / 2 << endl;
}

Measured memory_bytes: 3440
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>a>>b>>c>>d>>n;
    ll ni;
    ni=min({a*8,b*4,c*2,d});
    if(n%2==0){
        n/=2;
        Cout(n*ni);
    }
    else{
        ans=(n/2)*ni;
        ll iti=min({a*4,b*2,c});
        ans+=iti;
        Cout(ans);
    }
    return 0;
}


Measured memory_bytes: 764
fun main(args: Array<String>) {
    a90(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}


fun a90(args: Array<String>) {
    if (args.size != 3) {
        throw IllegalArgumentException()
    }
    println((0..2).map { args[it][it] }.toCharArray())
}

Measured memory_bytes: 31776
#include <bits/stdc++.h>
using namespace std;
static const int MOD = 1000000007;
using ll = long long;
int main(){
    ll a,b,k;
    cin>>a>>b>>k;
    if(a>k){
        a=a-k;
    }
    else{
        k=k-a;
        a=0;
        if (b>k){
            b=b-k;
        }
        else b=0;
    }
    cout<<a<<" "<<b<<endl;

    }

Measured memory_bytes: 256
n,t=map(int,input().split())
l=[]
for i in range(1,n+1):
  p,q=map(int,input().split())
  if q<=t:
    l.append(p)
  else:
    pass
if len(l)==0:
  print("TLE")
else:
  print(min(l))
  


Measured memory_bytes: 2940
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	var tmp int
	var max int
	for i := 0; i < len(s); i++ {
		switch s[i] {
		case 'A':
		case 'C':
		case 'G':
		case 'T':
		default:
			if max < tmp {
				max = tmp
			}
			tmp = 0
			continue
		}
		tmp++
	}
	if max < tmp {
		max = tmp
	}
	fmt.Println(max)
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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


struct rail{
	int sx;
	int sy;
	int gx;
	int gy;
};

double cross(rail v1,rail v2){//?????????v1?????????????????????
	int cv1v2=(v1.gx - v1.sx)*(v2.gy - v2.sy) - (v1.gy - v1.sy)*(v2.gx - v2.sx);
	int cvv2 = (v2.sx - v1.sx)*(v2.gy - v2.sy) - (v2.sy-v1.sy)*(v2.gx - v2.sx);
	if (cv1v2 == 0.0)
		return 0.0;
	return (double)cvv2/(double)cv1v2;
}
struct cross_t{
	int no;
	double dis;
};

bool operator < (const cross_t &left, const cross_t &right){
	return left.dis < right.dis;
};
int main() {
	ofstream ofs("out.txt");
	int dataset;
	cin >> dataset;
	while (dataset--){
		rail atob;
		cin >> atob.sx;
		cin >> atob.sy;
		cin >> atob.gx;
		cin >> atob.gy;
		int n;
		cin >> n;
		vector<rail> vr(n);
		vector<bool> high_b(n);
		priority_queue<cross_t> P;
		REP(i, n){
			cin >> vr[i].sx;
			cin >> vr[i].sy;
			cin >> vr[i].gx;
			cin >> vr[i].gy;
			int mine,high;
			cin >> mine;
			cin >> high;
			high_b[i] = (mine == high);
			double t1 = cross(atob, vr[i]);
			double t2 = cross(vr[i], atob);
			if (0.0<t1 && t1<1.0&&0.0<t2 && t2<1.0)P.push({ i, t1 });
		}
		bool b=false;
		int ans = 0;
		int ps = P.size();

		REP(i, ps){
			cross_t p = P.top();
			P.pop();
			if (i == 0){
				b = high_b[p.no];
			}else{
				if (b != high_b[p.no]){
					ans++;
					b = high_b[p.no];
				}
			}
			//cout << p.dis << " : " << high_b[p.no] << endl;
		}
		ofs << ans << endl;
		cout << (ans) << endl;
	}
}

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

int main() {
  int n;
  int dp[4100];
  fill(dp, dp+4100, 0);

  for(int i = 0; i <= 1000; i++) {
    for(int j = 0; j <= 1000; j++) {
      dp[i+j]++;
    }
  }

  while(cin >> n) {
    int ans = 0;
    for(int i = 0; i <= n; i++) {
      ans += dp[i] * dp[n-i];
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1176
n= int(input())
x = list(map(int,input().split()))

y = sorted(x)

from bisect import bisect_left
border=n//2-1

if n==2:
    print(x[1])
    print(x[0])
    exit(0)


for i in range(n):
    index = bisect_left(y,x[i])

    if index<=border:
        print(y[border+1])
    else:
        print(y[border])


Measured memory_bytes: 25620
from collections import deque
n = int(input())
cnt = 0
d = {n:0}
q = deque([n])
while q[0] > -5:
    t = q.popleft()
    cnt = d[t]
    # print(t)
    a = 1
    b = 1
    while 6**a <= t:
        a += 1
    while 9**b <= t:
        b += 1
    a -= 1
    b -= 1
    # print(t,a,b)
    if t-6**a in d:
        if d[t-6**a] > cnt+1:
            d[t-6**a] = cnt+1
            q.append(t-6**a)
    else:
        d[t-6**a] = cnt+1
        q.append(t-6**a)
    if t-9**b in d:
        if d[t-9**b] > cnt+1:
            d[t-9**b] = cnt+1
            q.append(t-9**b)
    else:
        d[t-9**b] = cnt+1
        q.append(t-9**b)
    # print(q)
print(d[0])
# print(d)

Measured memory_bytes: 9480
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>

constexpr long long int MOD = 998244353;
struct Robot {
	int position, distance;
	int right() const { return position + distance; }
};
class Bit {
	std::vector<int> vec;
public:
	Bit(int size) : vec(size, INT_MIN) {};
	int get(int position) const {
		int result = INT_MIN;
		while (position >= 0) {
			result = std::max(result, vec[position]);
			position -= ~position & (position + 1);
		}
		return result;
	}
	void increase(int position, int value) {
		while (position < vec.size()) {
			vec[position] = std::max(vec[position], value);
			position += ~position & (position + 1);
		}
	}
};
int main() {
	int n; std::cin >> n;
	std::vector<Robot> robots(n);
	for (auto& r : robots) std::cin >> r.position >> r.distance;
	std::sort(robots.begin(), robots.end(), [](const Robot a, const Robot b) {return a.position < b.position; });
	std::vector<int> next(n);
	Bit bit(n + 1); bit.increase(n, n);
	for (int i = n - 1; i >= 0; --i) {
		const auto right = std::lower_bound(robots.begin(), robots.end(), robots[i].right(), [](const Robot a, int position) {return a.position < position; });
		next[i] = std::max(i + 1, bit.get(std::distance(robots.begin(), right) - 1));
		bit.increase(i, next[i]);
	}
	std::vector<long long int> dp(n + 1, 1);
	for (int i = n - 1; i >= 0; --i) {
		dp[i] = (dp[i + 1] + dp[next[i]]) % MOD;
	}
	std::cout << dp.front() << '\n';
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;

void solve(std::vector<long long> A){
    sort(A.begin(), A.end());
    cout << A[2]-A[0] << endl;
}

int main(){
    std::vector<long long> A(3);
    for(int i = 0 ; i < 3 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 100000000000
long long int dp[100005][105];
long long int arr[105],n,val[1005];
void debug(long long int a,long long int b)
{
	printf("a-%lld\nb-%lld\n",a,b);
}
long long int solve(long long int ch,long long int idx)
{
	if(idx>n)
		return 0;
	if(dp[ch][idx]!=-1)
		return dp[ch][idx];
	long long int ans1,ans2=0,ans;
	ans1=solve(ch,idx+1);
	if(ch>=arr[idx])
	{
        //printf("ok\n");
		ans2=val[idx]+solve(ch-arr[idx],idx+1);
	}	
	ans=max(ans1,ans2);
	dp[ch][idx]=ans;
	//debug(ans,idx);
    return dp[ch][idx]; 
}
int main()
{
   long long int i,j,k,ans=0,w;
   scanf("%lld%lld",&n,&w);
   for(i=0;i<=w;i++)
   {
   	//visited[i]=false;
   	for(j=1;j<=n;j++)
   		dp[i][j]=-1;
   }	
   for(i=1;i<=n;i++)
   	scanf("%lld%lld",&arr[i],&val[i]);
   ans=solve(w,1);
      /*for(i=0;i<=w;i++)
   	for(j=1;j<=n;j++)
   		printf("%lld\n",dp[i][j]);*/
   printf("%lld\n",ans);
}


Measured memory_bytes: 82304
# from math import factorial
# from collections import defaultdict, deque
#  from heapq import heappush, heappop, heapify

# A, B = [int(i) for i in input().split(" ")]
# A = int(input())
# As = [int(i) for i in input().split(" ")]
# Ss = ["".join(sorted(input())) for _ in range(N)]
# edges = defaultdict(list)
# for _ in range(N - 1):
#     a, b = [int(i) for i in input().split(" ")]
#     edges[a-1].append(b-1)

N = int(input())
As = [int(i) for i in input().split(" ")]
for i in [i + 1 for i, j in sorted(enumerate(As), key=lambda x: x[1])]:
  print(i)


Measured memory_bytes: 23136
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    ll n;
    cin >> n;
    vector<vector<ll>> data(n+3,vector<ll>(3,0));
    rep(i,n)rep(j,3)cin >> data[i][j];
    vector<vector<ll>> dp(n+3,vector<ll>(3,0));
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    rep(i,n){
        rep(j,3){
            rep(k,3)if(j != k)chmax(dp[i+1][j],dp[i][k] + data[i][k]);
        }
    }
    cout << max({dp[n][0],dp[n][1],dp[n][1]}) << "\n";
    return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;

  int ans = -1;
  rep_s(i, 1, 1010) {
    if (i * 8 / 100 == A && i / 10 == B) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  string s;
  cin>>a>>b>>s;
  if(s[b-1]=='A')
    s[b-1]='a';
  else if(s[b-1]=='B')
    s[b-1]='b';
  else if(s[b-1]=='C')
    s[b-1]='c';
  cout<<s<<endl;
}

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

typedef long long int ll;
typedef long double ld;

#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define pll pair<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ln length()
#define M 1000000007

ll n,a[300002],pr[300002],mx[300002],mi[300002];
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    cin>>n;
    rep(i,1,3*n) cin>>a[i],pr[i]=a[i]+pr[i-1];
    mx[n]=pr[n];
    multiset<ll> tem;
    rep(i,1,n) tem.insert(a[i]);
    ll cur=pr[n];
    rep(i,n+1,2*n){
        tem.insert(a[i]);
        cur+=(a[i]-*(tem.begin()));
        tem.erase(tem.begin());
        mx[i]=cur;
    }

    mi[2*n+1]=pr[3*n]-pr[2*n];
    tem.clear();
    rep(i,2*n+1,3*n) tem.insert(a[i]);
     cur=mi[2*n+1];
    rev(i,2*n,n+1){
        tem.insert(a[i]);
        auto it=tem.end();it--;
        cur+=(a[i]-*(it));
        tem.erase(it);
        mi[i]=cur;
    }
    ll ans=mx[n]-mi[n+1];
    rep(i,n+1,2*n) ans=max(ans,mx[i]-mi[i+1]);
    cout<<ans<<'\n';
}


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

using namespace std;
using ll = long long;
using ld = long double;

#define int long long
signed main(){
//int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans=0;
    for(int i = 1; i < n; i++) {
        int tmp=max(ll(0),a[i-1]-a[i]);
        ans+=tmp;
        a[i]+=tmp;
    }
    cout << ans << "\n";

    return 0;
}

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

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

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

    // start
    vector<string> vs(3);
    rep(i, 3) cin >> vs.at(i);
    rep(i, 3) cout << vs.at(i)[0];
    cout << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
int read()
{  int f=1,x=0;
   char ch=getchar();
   for(;ch>'9'||ch<'0';ch=getchar())if(ch=='-') f=-1;
   for(;ch<='9'&&ch>='0';ch=getchar())x = x * 10 + ch - '0';
   return x*f;
}
int n, k, a[200005],ans,x,y;
int main()
{     int flag=0;
      cin>>x>>y;
    for(int i=0;i<=x;i++)
      {   int q=i,p=x-i;
          if(q*2+p*4==y)flag=1;
      }
    if(flag)printf("Yes\n");
    else printf("No\n");

       

      return 0;
}

Measured memory_bytes: 3632
// problem: "https://atcoder.jp/contests/abc153/tasks/abc153_e"

#include<bits/stdc++.h>
#define ll long long

using namespace std;

ll minMagicPts(ll i,ll h,vector<ll>&A,vector<ll>&B,vector<vector<ll>>&V)
{
    if(h <= 0)
        return 0;

    if(i < 0)
        return INT_MAX;

    if(V[i][h] == -1)
        V[i][h] = min(minMagicPts(i-1,h,A,B,V), minMagicPts(i,h-A[i],A,B,V)+B[i]);

    return V[i][h];
}

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

    vector<ll>A(n),B(n);

    ll i;
    for(i=0;i!=n;i++)
        cin>>A[i]>>B[i];

    vector<vector<ll>>V(n,vector<ll>(h+1,-1));

    cout<<minMagicPts(n-1,h,A,B,V);       // define

    return 0;
}


Measured memory_bytes: 78592
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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


	int n;
	double s = 0;
	cin >> n;
	rep(i,n) {
		double x;
		string c;
		cin >> x >> c;
		if (c=="JPY") {
			s += x;
		}
		else {
			s += x * 380000.0;
		}
	}
	printf("%.10f\n", s);


	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
multiset<int> S;
int P[101010];
vector<pair<int,int>> V;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	//S.insert(0);
	S.insert(0);
	//S.insert(N+1);
	S.insert(N+1);
	
	FOR(i,N) {
		cin>>P[i+1];
		V.push_back({P[i+1],i+1});
	}
	sort(ALL(V));
	reverse(ALL(V));
	ll ret=0;
	FORR(v,V) {
		ll num=v.first;
		int id=v.second;
		auto it=S.lower_bound(id);
		int R1=*it;
		it++;
		int R2=*it;
		it--;
		it--;
		int L1=*it;
		it--;
		int L2=*it;
		if(R2>R1) ret+=num*(R2-R1)*(id-L1);
		if(L2<L1) ret+=num*(L1-L2)*(R1-id);
		S.insert(id);
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 6132
# coding: utf-8
# Your code here!

A, B, X = map(int, input().split())

# print(A)
# print(B)
# print(X)

# print((A < X) and (A + B >= X))

if (A <= X) and (A + B >= X):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>	
#include<math.h>
char s[200005];
void swap(char *a,char *b){
	char c=*a;
	*a=*b;
	*b=c;
}
int main(){
	int n,ans=0;
	scanf("%d",&n);
	scanf("%s",s);
	int left=0,right=n-1;
	while(left<right){
		if(s[left]=='W'&&s[right]=='R'){
			swap(&s[left],&s[right]);
			left++;
			right--;	
			ans++;
		}
		else if(s[left]!='W')left++;
		else if(s[right]!='R')right--;
	} 
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 1900
while True:
    m,f,r = map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    sum=m+f
    if m==-1 or f==-1:
        print('F')
    elif 30<=sum<50:
        if r>=50:
            print('C')
        else:
            print('D')
    elif 50<=sum<65:
        print('C')
    elif 65<=sum<80:
        print('B')
    elif 80<=sum:
        print('A')
    else:
        print('F')
        


Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
char a[100][100];

int main()
{
    int r,c,n=0,f=0;
    cin>>r>>c;
    for(int i=1;i<=r;i++)
    {
        for(int j=1;j<=c;j++)
        {
            cin>>a[i][j];
        }
    }

    for(int i=1;i<=r;i++)
    {
        for(int j=1;j<=c;j++)
        {
            if(a[i][j]=='#') {
                if(a[i-1][j]=='.'&&a[i+1][j]=='.'&&a[i][j-1]=='.'&&a[i][j+1]=='.') n=1;

            }
            if(n==1) break;
        }
        if(n==1) break ;
    }
   if(n==1) cout<<"No\n";
   else cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 256
N, M = map(int,input().split())
H = list(map(int,input().split()))
way = [list(map(int,input().split())) for i in range(M)]
ans = [0]* N
for i in range(M):
    if H[way[i][0]-1] > H[way[i][1]-1]:
        ans[way[i][1]-1] += 1
    
    elif H[way[i][0]-1] < H[way[i][1]-1]:
        ans[way[i][0]-1] += 1
    
    else:
        ans[way[i][0]-1] += 1
        ans[way[i][1]-1] += 1
print(ans.count(0))

Measured memory_bytes: 31900
N = int(input())
P = list(map(int, input().split()))

min_num = 10**9
min_l = []
cnt = 0
for i in range(N):
  if P[i] < min_num:
    min_l.append(P[i])
    min_num = P[i]
    cnt += 1
  else:
    min_l.append(min_num)

print(cnt)

Measured memory_bytes: 24744
#include<stdio.h>


int main(){

  int a, b, c, d = 0, i;

  scanf("%d %d %d", &a, &b, &c);
  
  for(i = a;i <= b;i++){

    if(c % i == 0)

      d = d + 1;
    
  }

  printf("%d\n", d);

    
  return 0;
  
}

Measured memory_bytes: 596
import numpy as np

L,R = map(int, input().split())

if R - L > 2018:
    print(0)
    
else:
    R = R % 2019
    L = L % 2019

    if L > R:
        R += 2019 
        
    ans = 2018        
    for i in np.arange(L, R+1):
        for j in np.arange(i+1, R+1):
            i = i % 2019
            j = j % 2019
            k = i * j % 2019
            ans = np.amin(np.array([k, ans]))
        
            if ans == 0:
                break
        if ans == 0:
            break        

    print(ans)   

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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

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

    int n, k;
    cin >> n >> k;
    int res = 0;
    for (int i = 0; i < n;i++) {
        int x;
        cin >> x;
        if (x >= k) res++;
    }
    cout <<res;

    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(intl)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(intl)(n)+1;i++)
#define vec vector
#define fi first
#define se second
#define pub push_back
#define pob pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
#define All(a) (a).begin(),(a).end()
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
using pi = pair<intl,intl>;
using vpi = vec<pi>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr intl INF = 9223372036854775807;


int main(){
  string X;
  cin >>X;
  Rep(i,X.size()){
    cout <<( (X.at(i) == '?')?'D':X.at(i) );
  }
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long int n,W;
	cin>>n>>W;
	long long int w[n],v[n];
	for(int i=0;i<n;i++)
	cin>>w[i]>>v[i];
    long long int dp[n+1][W+1];
    memset(dp,0,sizeof dp);

    for(int i=1;i<=n;i++)
    {
    for(int j=1;j<=W;j++)
    {
    if(j>=w[i-1])
    dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
    else
    dp[i][j]=dp[i-1][j];
    }
    }
    cout<<dp[n][W];
    return 0;
}

Measured memory_bytes: 82404
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>
#include <map>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

int main(void){
    //素数生成
    vector<int> sosu;
    sosu.push_back(2);
    for(int i=3;i<100001;i+=2){
        if(!any_of(sosu.begin(),sosu.end(),[i](int x){return i%x == 0;})){
            sosu.push_back(i);
        }
    }
    
    //2017に似た数生成
    vector<int> like;
    for(int i=3;i<100001;i+=2){
        if(i == 2017){
            like.push_back(i);
            continue;
        }
        if(binary_search(sosu.begin(),sosu.end(),(i+1)/2) && binary_search(sosu.begin(),sosu.end(),i))like.push_back(i);
    }
    
    //累積和生成
    array<int ,100001>rui = {};
    
    for(int i=3;i<100001;i++){
        rui[i] = rui[i-1];
        if(binary_search(like.begin(),like.end(),i))rui[i]++;
    }

    int roop,a,b;
    cin >> roop;
    for(int i = 0;i<roop;i++){
        cin >> a >> b;
        cout << rui[b]-rui[a-1] << endl;
    }
    
}


Measured memory_bytes: 1152
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PI  3.14159265358979323846
#define M   1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }
    }
}
ll lcm(ll a,ll b)
{
    ll p=a*b;
    p/=__gcd(a,b);
    return p;
}
ll solve(ll z,ll p,ll q,ll n)
{
    ll g=n/z;
    if(g<p)
    {
        return -1;
    }
    else
    {
       g-=p;
       if(g%q==0)
       {
           g/=q;
           return (z+g);
       }
       else
       {
           return -1;
       }
    }
}
int main()
{
    int i,j;
   int a[3][3],d[3][3];
   int x[101]={0},y[101]={0};
   for(i=0;i<3;i++)
   {
       for(j=0;j<3;j++)
       {
           d[i][j]=0;
           cin>>a[i][j];
           x[a[i][j]]=i+1;
           y[a[i][j]]=j+1;
       }
   }

   int n;
   cin>>n;
   int c[n];
   for(i=0;i<n;i++)
   {
       cin>>c[i];
       if(x[c[i]]!=0&&y[c[i]]!=0)
       {
           d[x[c[i]]-1][y[c[i]]-1]=1;
       }
   }
   int ok=0;
   for(i=0;i<3;i++)
   {
       if(d[i][0]==1&&d[i][1]==1&&d[i][2]==1)
       {
           ok=1;
       }
       if(d[0][i]==1&&d[1][i]==1&&d[2][i]==1)
       {
           ok=1;
       }

   }
   if(d[0][0]==1&&d[1][1]==1&&d[2][2]==1)
   {
       ok=1;
   }
   if(d[0][2]==1&&d[1][1]==1&&d[2][0]==1)
   {
       ok=1;
   }
   if(ok==1)
    cout<<"Yes";
   else
    cout<<"No";

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAXN = 1e5 + 5;

int n,k;
int niz[MAXN];
long long pref[MAXN];
long long ppref[MAXN];

int main () {
    cin >> n >> k;
    for (int i = 0 ; i < n; i ++) {
        cin >> niz[i];
    }
    pref[0] = niz[0];
    if (niz[0] > 0) {ppref[0] = niz[0];}
    else {ppref[0] = 0;}
    for (int i = 1 ; i < n ; i++) {
        pref[i] = niz[i] + pref[i-1];
        ppref[i] += ppref[i-1];
        if (niz[i] > 0) {ppref[i] += niz[i];}
    }
    long long sol = 0;
    //cout <<"PREFIKS SUME: " << endl;
    /*for (int i = 0 ; i < n ; i++) {
        cout << pref[i] <<" ";
    }
    cout << endl << "POZITIVAN PREF: " << endl;
    for (int i = 0 ; i < n ; i++) {
        cout << ppref[i] << " ";
    }*/
    //cout << endl;
    long long z = pref[k-1] + ppref[n-1] - ppref[k-1];
    long long z1 = ppref[n-1] - ppref[k-1];
    if (z > sol) sol = z;
    if (z1 > sol) sol = z1;
    for (int i = 1 ; i < n-k+1 ; i++) {
        long long u, u1;
        if (i < n-k) u = ppref[i-1] + pref[i+k-1] - pref[i-1] + ppref[n-1] - ppref[i+k-1];
        if (i < n-k) u1 = ppref[i-1] + ppref[n-1] - ppref[i+k-1];
        if (i == n-k) {
            u = ppref[i-1] + pref[n-1] - pref[i-1];
            u1 = ppref[i-1];
        }
        if (u > sol) sol = u;
        if (u1 > sol) sol = u1;
    }
    cout << sol;
    return 0;
}


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

int main() {
  char c;
  cin >> c;

  string vowels = "aiueo";
  for (int i = 0; i < vowels.size(); i++) {
    if (vowels.at(i) == c) {
      cout << "vowel" << endl;
      return 0;
    }
  }
  cout << "consonant" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int price = sc.nextInt();
    int result = 1000 - (price % 1000);
    result = result == 1000 ? 0 : result;
    System.out.println(result);
    sc.close();
  }
}

Measured memory_bytes: 35788
/*input
3 2
2 6
4 3
1 5
*/
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
const int maxn = 205;
const int mod = 1e9 + 7;
int n, m, arr[maxn][maxn], match[maxn], vis[maxn][maxn], ans[maxn][maxn], mark[maxn];
multiset<int>adj[maxn];
bool dfs(int v)
{
	if(mark[v])
		return false;
	mark[v] = true;
	for(int to : adj[v])
	{
		if(match[to] == -1 || dfs(match[to]))
		{
			match[v] = to;
			match[to] = v;
			return true;
		}
	}
	return false;
}
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			cin >> arr[i][j];
			--arr[i][j];
		}
	}
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
		{
			adj[i + n].insert(arr[i][j] / m);
		}
	}
	for(int j = 0; j < m; j++)
	{
		memset(match, -1, sizeof match);
		while(true)
		{
			memset(mark, 0, sizeof mark);
			bool chk = false;
			for(int i = n; i < 2 * n; i++)
				if(match[i] == -1 && !mark[i])
					chk |= dfs(i);
			if(!chk)
				break;
		}
		for(int i = 0; i < n; i++)
		{
			int color = match[i + n];
			adj[i + n].erase(adj[i + n].find(color));
			for(int jj = 0; jj < m; jj++)
			{
				if(arr[i][jj] / m == color && !vis[i][jj])
				{
					vis[i][jj] = 1;
					ans[i][j] = arr[i][jj];
					break;
				}
			}
		}
	}
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
			cout << ans[i][j] + 1 << " ";
		cout << "\n";
	}
	for(int j = 0; j < m; j++)
	{
		for(int i = 0; i < n; i++)
		{
			for(int ii = i + 1; ii < n; ii++)
			{
				if(ans[i][j] > ans[ii][j])
					swap(ans[i][j], ans[ii][j]);
			}
		}
	}
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
			cout << ans[i][j] + 1 << " ";
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 1152
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_asc(const void* a, const void* b) {
    return *((size_t*)a) < *((size_t*)b) ? -1 : 1;
}

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_i64_desc(const void* a, const void* b) {
    return *((int64_t*)a) > * ((int64_t*)b) ? -1 : 1;
}

int compare_c_asc(const void* a, const void* b) {
    return *((char*)a) < *((char*)b) ? -1 : 1;
}

int compare_c_desc(const void* a, const void* b) {
    return *((char*)a) > * ((char*)b) ? -1 : 1;
}

static size_t powSz(const size_t base, const size_t exp) {
    if (exp == 0) {
        return 1;
    }

    if (exp == 1) {
        return base;
    }

    if (exp % 2 == 0) {
        return powSz(base * base, exp / 2);
    }
    else {
        return base * powSz(base, exp - 1);
    }
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

typedef struct {
    uint64_t A;
    uint64_t idx;
    uint64_t order;
} _info;

static _info info[200000];

static int compare_num(const void* a, const void* b) {
    const _info* aP = (_info*)a;
    const _info* bP = (_info*)b;

    return aP->A > bP->A ? -1 : 1;
}

static int compare_idx(const void* a, const void* b) {
    const _info* aP = (_info*)a;
    const _info* bP = (_info*)b;

    return aP->idx < bP->idx ? -1 : 1;
}

int main(void) {
    uint64_t N;

    scanf("%"PRIu64, &N);

    for (uint64_t i = 0; i < N; i++) {
        scanf("%"PRIu64, &(info[i].A));
        info[i].idx = i;
    }

    qsort(info, (size_t)N, sizeof(_info), compare_num);

    for (uint64_t i = 0; i < N; i++) {
        info[i].order = i;
    }

    uint64_t orderIdx[2];

    orderIdx[0] = info[0].idx;
    orderIdx[1] = info[1].idx;

    qsort(info, (size_t)N, sizeof(_info), compare_idx);

    for (uint64_t i = 0; i < N; i++) {
        printf("%"PRIu64"\n", info[i].order == 0 ? info[orderIdx[1]].A : info[orderIdx[0]].A);
    }

    return 0;
}


Measured memory_bytes: 10924