akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int                 long long   
#define double              long double
#define endl                "\n"
#define pb                  push_back
#define PI                  3.1415926535897932384626433832795l
#define F                   first
#define S                   second
#define mp                  make_pair
#define f(i,n)              for(int i=0;i<n;++i)
#define loop(i,a,b)         for (int i=a ; i<b ;++i)
#define fastio              ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)              (v).begin(),(v).end()
#define rall(v)             (v).rbegin(),(v).rend()
#define gcd(a,b)            __gcd((a),(b))
#define fill(a,value)       memset(a,value,sizeof(a));
#define minn(v)             *min_element(v.begin(), v.end());
#define maxx(v)             *max_element(v.begin(), v.end());
#define print(x)            cout<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;
signed main() 
{
    fastio;
    int n,k;
    cin>>n>>k;
    int mod=1000000007;
    vi a(n);
    f(i,n)cin>>a[i];
    int ans=0;
    f(i,n)
    {
        f(j,n)
        {
            if(a[i]>a[j])
            {
                if(j>i)
                {
                    ans+=(k*(k+1))/2;
                    ans%=mod;
                }
                if(i>j)
                {
                    ans+=(k*(k-1))/2;
                    ans%=mod;
                }
            }
        }
    }
    print(ans)
    
    return 0;
    
}

Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <stdio.h>
using namespace std;

int main()
{
  int a,b;

  cin >> a >> b;
  
  int d = a / b;
  int r = a % b;
  double f = 1.0 *a / b;

  cout << d << " " << r << " " << fixed << setprecision(5) << f <<endl; ;

  return 0;
}



Measured memory_bytes: 3300
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    string a, b, c;

    cin >> a >> b >> c;

    if (a.back() == b.front() && b.back() == c.front()) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
n = int(input())
s = input()
ans = ""
def next_animal(pre,now,letter):
    if pre == "S" and now == "S" and letter == "o":
        return "S"
    if pre == "S" and now == "S" and letter == "x":
        return "W"
    if pre == "S" and now == "W" and letter == "o":
        return "W"
    if pre == "S" and now == "W" and letter == "x":
        return "S"
    if pre == "W" and now == "S" and letter == "o":
        return "W"
    if pre == "W" and now == "S" and letter == "x":
        return "S"
    if pre == "W" and now == "W" and letter == "o":
        return "S"
    if pre == "W" and now == "W" and letter == "x":
        return "W"

for case in range(4):
    if case == 0:
        ans = "SS"
    if case == 1:
        ans = "SW"
    if case == 2:
        ans = "WS"
    if case == 3:
        ans = "WW"
    for i in range(1,n-1):
        next = next_animal(ans[-1],ans[-2],s[i])
        ans += next
    if ans[-1] == next_animal(ans[1],ans[0],s[0]) and ans[0] == next_animal(ans[-2],ans[-1],s[-1]):
        print(ans)
        exit()

print(-1)


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    ll n;
    scanf("%lld",&n);
    int cnt=0;
    ll ans=100;
    while(ans<n){
        ans+=(ans/100)*1;
        cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    ll k;
    cin>>k;
    
    ll x=7;
    ll tmp=10,ans=1;
    rep(i,10000000){
        if(x%k==0){
            cout<<ans<<endl;
            return 0;
        }
        ll add=(7*tmp)%k;
        x=(x+add)%k;
        ans++;
        tmp=(tmp*10)%k;
    }

    cout<<-1<<endl;
}

Measured memory_bytes: 3516
/*

Author: @karngyan
Team: BlundersPride

*/

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
using namespace std;

using ll = long long;
using ld = long double;
using vll = std::vector< ll >;
using pll = std::pair< ll, ll >;
using vvll = std::vector<vll>;
using vpll = std::vector< pll >;


#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define eb emplace_back
#define rep(i, begin, end) for(__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define max3( a, b, c ) max( a , max(b , c))
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define cntll(a) __builtin_popcountll((a))
#define ff first
#define ss second
#define mk make_pair
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it){}
template<typename T , typename... Args>
void err(istream_iterator<string> it , T a , Args... args)
{
	cerr << *it << " = " << a << endl;
	err(++it , args ... );
}

ll sum(){ return 0; }
template<typename T, typename... Args>
auto sum(T a, Args... args){ return a + sum(args...);}
const ll MOD = 1e9+7;
////////////////////////////////////////////////////////////////////////////////////////////////////////



signed main()
{

	fast;
////////////////////////////////////////////////////////////////////////////////////////////


	ll r , d , x;
	cin >> r >> d >> x;
	rep(i,0,10){
		x = r*x - d;
		cout<<x<<endl;
	}



	
	return 0;
}




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

int main() {

  int a, b;
  cin >> a >> b;

  int ans = -1;
  int na, nb;
  for(int i = 1; i <= 1250; i++) {
    na = i * 0.08;
    for(int j = 1; j <= 1000; j++) {
      nb = j * 0.1;
      if(na == a and nb == b and ans == -1 and i == j) {
        ans = int(i);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
d,x = map(int, input().split())
l=[int(input()) for x in range(n)]
cnt=0
for i in range(n):
    choco=1
    for j in range(1,d+1):
        if choco<=d:
            choco+=l[i]
            cnt+=1
print(cnt+x)     

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  string s, t;
  cin >> s >> t;

  int s_size = s.size();
  int t_size = t.size();

  int ans = s_size;
  for (int i = 0; i < (s_size - t_size + 1); i++) {
    int cnt = 0;
    for (int j = 0; j < t_size; j++) {
      if (s.at(i+j) != t.at(j)) {
        cnt++;
      }
    }
    ans = min(ans, cnt);
  }

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


Measured memory_bytes: 3628
#include<stdio.h>

#define MAX 100000

int count[MAX+1];

void quickSort(int *,char *,int,int);
int partition(int *,char *,int,int);
int Stable(int *,int);

int main(){

  int i,n,k;
  char B[MAX+1],c,d,e;
  int A[MAX+1];
  

  scanf("%d%c",&n,&e);
  
  for(i=1;i<n+1;i++){
   scanf("%c%c%d%c",&B[i],&c,&A[i],&d);
   count[i]=i;
  }

  quickSort(A,B,1,n);

  if(Stable(A,n)==0) printf("Stable\n");
  else printf("Not stable\n");

  for(k=1;k<=n;k++){
    printf("%c %d\n",B[k],A[k]);
  }

  return 0;
}

void quickSort(int *A,char *B,int p,int r){
  int q;
  
  if(p<r){
    q=partition(A,B,p,r);
    quickSort(A,B,p,q-1);
    quickSort(A,B,q+1,r);
  }
}

int partition(int *A,char *B,int p,int r){
  int x,i,j,s,swap;
  char exc;

   x=A[r];
   i=p-1;

  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      swap=A[i];
      A[i]=A[j];
      A[j]=swap;
      exc=B[i];
      B[i]=B[j];
      B[j]=exc;
      s=count[i];
      count[i]=count[j];    
      count[j]=s;
    }
}
      swap=A[i+1];
      A[i+1]=A[r];
      A[r]=swap;
      exc=B[i+1];
      B[i+1]=B[r];
      B[r]=exc;
      s=count[i+1];
      count[i+1]=count[r];    
      count[r]=s;

      return i+1;
}

int Stable(int *A,int n){
  int i;

  for(i=1;i<=n;i++){
    if(A[i]==A[i+1]){
      if(count[i]>count[i+1]) return 1;
    }
  }
  return 0;

}

Measured memory_bytes: 1484
/// Kazuki Hoshino


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
//#define endl '\n'
typedef tree<
int,
null_type,less<int>,
rb_tree_tag,tree_order_statistics_node_update>
ordered_set;



int n,q,k;
string s;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

cin >> n >> s;
cin >> q;
while(q--){
       cin >> k;
       int dc=0,mc=0,cc=0,ans=0,add=0;
       int l=0,r=0;
       while(l<=r && r<n){
              if(r-l<k){
                     if(s[r]=='D'){
                            dc++;
                     }
                     if(s[r]=='M'){
                            add+=dc;
                            mc++;
                     }
                     if(s[r]=='C'){
                            ans+=add;
                     }
                     r++;
              }
              else {
                     if(s[l]=='D'){
                            add-=mc;
                            dc--;
                     }
                     if(s[l]=='M'){
                            mc--;
                     }
                     l++;
              }
       }
       cout << ans << endl;
}








return 0;}
///....


Measured memory_bytes: 1948
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <stack>
#include <bitset>
#include <queue>

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

ll bitdp[1 << 23];
int table[24][24];
const int mod = 1e9+7;

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

    rep(i,n){
        rep(j,n){
            cin >> table[i][j];
            if(i==0 && table[i][j] == 1) bitdp[1 << j] = 1;
        }
    }

    reps(k,1,n){
        int comb = (1 << k) - 1;
        while(comb < 1 << n){

            rep(l,n){
                if(table[k][l] == 1 && ((comb >> l) & 1) == 0){
                    int new_pat = comb | 1 << l;
                    bitdp[new_pat] = (bitdp[new_pat] + bitdp[comb] ) % mod;
                }
            }

            int x = comb & -comb, y = comb + x;
            comb = ((comb & ~y) / x >> 1) | y;
        }
    }
    cout << bitdp[(1<<n)-1] << endl;

    return 0;
}


Measured memory_bytes: 18688
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = ReadInt();
            var ans = 0;
            for (int i = 1; i <= r; i+=2)
            {
                for (int i1 = 2; i1 <= r; i1+=2)
                {
                    ans++;
                }
            }
            WriteLine(ans);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11220
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long int ll;
const ll INF=pow(10,15);
const ll md=pow(10,9)+7;

//20
ll conbi[2001][2001]={};


int main()
{
 conbi[0][0]=1;
 for(int i=1;i<=2000;i++)
 {
	for(int j=0;j<=i;j++)
	{	
		if(j==0){conbi[i][j]=1;}
		else{conbi[i][j]=(conbi[i-1][j-1]+conbi[i-1][j])%md;}
	}
 }
 int N,K;
 scanf("%d %d",&N,&K);
 for(int r=1;r<=K;r++)
 {
	ll ans=(conbi[K-1][r-1]*conbi[N-K+1][r])%md;
	printf("%lld\n",ans);
 }
}

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

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int main() {
  string s;
  cin >> s;
  if (stringcount(s, 'a') == 1 && stringcount(s, 'b') == 1 && stringcount(s, 'c') == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
(r, c) = [int(i) for i in input().split()]
src = []
for i in range(r):
    row = [int(i) for i in input().split()]
    row.append(sum(row))
    src.append(row)

last_row = [0 for _ in range(c+1)]
for rc in range(r):
    for cc in range(c+1):
        last_row[cc] += src[rc][cc]
src.append(last_row)
for rc in range(r+1):
    print(' '.join([str(a) for a in src[rc]]))

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

typedef long long ll;
const ll MOD = 1000000007;
int K, n, m, c;
ll dp[4010][2010], ans;

inline void update(ll &cur, ll val) {
	cur = cur + val;
	if(cur >= MOD) cur -= MOD;
}

int main() {

	int i, j, k;
	scanf("%d%d%d", &n, &m, &K);

	c = (n+m-1)/(K-1);

	for(j = 1; j <= K-1; j++) dp[c][j] = 1;
	for(i = c; i > 1; i--) 
		for(j = 1; j <= m; j++) 
			for(k = 0; k < K && k+j <= m; k++) 
				update(dp[i-1][j+k], dp[i][j]);
	for(i = c; i >= 1; i--) {
		for(j = 1; j <= m; j++) {
			if((m-j)%(K-1)) continue;
			int t = (c-i+1)*(K-1)-j+1;
			if(t > n || (n-t)%(K-1)) continue;
			update(ans, dp[i][j]);
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 62976
n = int(input())
enemy = list(map(int, input().split()))
beat = list(map(int, input().split()))
ans = 0 
for i in range(n):
  #左を全力で倒す
  left = min([enemy[i], beat[i]])
  ans += left
  enemy[i] -= left
  beat[i] -= left
  
  right = min([enemy[i+1], beat[i]])
  ans += right
  enemy[i + 1] -= right
  beat[i] -= right
  
print(ans)


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

using namespace std;

#define ll long long
#define pb push_back
#define vi vector<int>
#define bn(n) (n).begin(), (n).end()
#define FOR(n) for(int i = 0; i < (int)n; i++)


void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = 1; i <= b; i++) {
        if (a*i % b == c) {
            cout << "YES\n";
            return;
        }
    }
    cout << "NO\n";
}

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

    int t = 1, i = 1;
    //cin >> t;
    while(t--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


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

ifstream fin("pentagon.in");
ofstream fout("pentagon.out");

#define MOD 100019
#define NMAX 100005

int main()
{
   int n,a,b;
   string s;
   cin>>n>>a>>b>>s;

   int ac = 0;
   int ab = 0;

   for(int i=0;i<s.size();i++)
   {
      char c = s[i];
      if(c == 'c')
      {
         cout<<"No"<<'\n';
         continue;
      }
      else
      {
         if(c == 'a')
         {
            if(ac + ab < a+b)
            {
               cout<<"Yes"<<'\n';
               ac++;
            }
            else
            {
               cout<<"No"<<'\n';
            }
         }
         else
         {
            if(ac+ab < a+b && ab < b)
            {
               cout<<"Yes"<<'\n';
               ab++;
            }
            else
            {
               cout<<"No"<<'\n';
            }
         }

      }
   }

   return 0;
}


Measured memory_bytes: 896
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			if( (h|w) == 0 ) break;
			
			int[][] map = new int[h+1][w+1];
			
			for(int i=1;i<=h;i++) {
				String str = sc.next();
				for(int j=1;j<=w;j++) {
					if(str.charAt(j-1) == '*')
						map[i][j] = 0;
					else 
						map[i][j] = map[i][j-1]+1;
				}
			}
//			for(int[] a: map) debug(a);
			int max = 0;
			for(int j=1;j<=w;j++) for(int i=1;i<=h;i++){
				if(map[i][j] > 0) {
					int ww = INF;
					for(int k=i;k<=h;k++) {
						ww = min(ww, map[k][j]);
						max = max(max, ww * (k-i+1));
					}
				}
			}
			System.out.println(max);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 14000
#include<iostream>
#include<sstream>
#include<string>
#define div(x,d) (x-1)/d
using namespace std;

typedef long long ll;

string llitos(ll a){
  stringstream ss;
  ss << a;
  return ss.str();
}

ll pos(ll a){
  ll res = 4*(div(a,3) + div(a,5));
  ll p,n,k = 1;
  for(int i=1;k<a;i++,k*=10){
    p = div(k,3) + div(k,5) - div(k,15);
    if(k*10<a){
      n = div(k*10,3) + div(k*10,5) - div(k*10,15);
      res += i*(k*9 - (n-p) );
    }else{
      n = div(a,3) + div(a,5) - div(a,15);
      res += i*(a-k - (n-p) );
    }
  }
  return res+1;
}
      
int main(){
  ll s;
  cin >> s;

  ll l = 1, r = 1LL<<60;
  while(r-l>1){
    ll mid = (l+r)/2;
    if(pos(mid)+1<=s)l = mid;
    else r = mid;
  }

  ll tmp = pos(l);
  string ans = "";
  while(ans.size()<=40){
    if(l%3 && l%5)ans += llitos(l);
    else{
      if(!(l%3))ans += "Fizz";
      if(!(l%5))ans += "Buzz";
    }
    l++;
  }
  cout << ans.substr(s-tmp,20) << endl;
}

Measured memory_bytes: 1224
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut a: Vec<u32> = vec![0; n];

    for i in 0..n {
        a[i] = read();
    }
    a.sort();
    a.reverse();

    let mut alice = 0;
    let mut bob = 0;

    for i in 0..n {
        if i % 2 == 0 {
            alice += a[i];
        } else {
            bob += a[i];
        }
    }

    println!("{}", alice - bob);
}


Measured memory_bytes: 4352
K, N = map(int, input().split())
listA = list(map(int, input().split()))

listA.append(K + listA[0])
#listA.insert(0, listA[N -1])
max_now = 0

for i in range(N):
    kyori = abs(listA[i] - listA[i+1])
    max_now = max(max_now, kyori)

print(K - max_now)

Measured memory_bytes: 26444
#include <CodeforcesSolutions.h>
#include <ONLINE_JUDGE_SOLUTION <solution.cf(contestID = "1359",problemID = "C",method = "GET")>.h>
"""
    Author : thekushalghosh
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time,itertools
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    ONLINE_JUDGE_SOLUTION = Codeforces.CodeforcesSolutions("1361","A","GET","POST")
    print(ONLINE_JUDGE_SOLUTION)
                
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
    sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
    return(q)

class Codeforces():
    def CodeforcesSolutions(id,question,get,post):
        n,m,x = invr()
        a = []
        c = []
        qwqw = []
        for i in range(n):
            s = inlt()
            c.append(s.pop(0))
            a.append(s)
        q = [i for i in range(n)]
        for i in range(n):
            w = list(itertools.combinations(q,i + 1))
            for j in range(len(w)):
                qw = w[j]
                qq = [0] * m
                ww = 0
                for k in range(len(qw)):
                    ww = ww + c[qw[k] - 1]
                    qq = [qq[l] + a[qw[k] - 1][l] for l in range(m)]
                if min(qq) >= x:
                    qwqw.append(ww)
        if qwqw:
            return(min(qwqw))
        return(-1)
                    


        q = min(a,d)
        w = min(b,d - q)
        qw = min(d - q - w,c)
        return(q - qw)
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
main()

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

const int INF = 1000000000;

struct Edge{
  int to,cost;
};

struct Node{
  int val,num;
};

struct P{
  int val,num,c;
  bool operator<(const P &r)const{
    return val < r.val;
  }
};




int main(){
  int c,n,m,s,d;
  
  while(1){
  cin >> c >> n >> m >> s >> d;
  s--;d--;
  if(c == 0 && n == 0 && m == 0 && s == -1 && d == -1)break;
  vector<Edge>edge[105];
  Node node[11][105];
  
  priority_queue<P> que;
  for(int i = 0; i < m; i++){
    int a,b,c;
    cin >> a >> b >> c;
    a--;b--;
    edge[a].push_back((Edge){b,c});
    edge[b].push_back((Edge){a,c});
  }


  for(int i = 0; i < 11; i++){
    for(int j = 0; j < n; j++){
      node[i][j].val = INF;
      node[i][j].num = j;
    }
  }

  node[c][s].val = 0;
  
  que.push((P){0,s,c});

  while(!que.empty()){
    int val = que.top().val;
    int now = que.top().num;
    int ticket = que.top().c;
    que.pop();
  
    if(ticket){
      for(int i = 0; i < edge[now].size(); i++){
	int next = edge[now][i].to;
	int cost = edge[now][i].cost;

	if(node[ticket - 1][next].val > node[ticket][now].val + cost / 2){
	  node[ticket - 1][next].val = node[ticket][now].val + cost / 2;
	  que.push((P){node[ticket - 1][next].val,next,ticket - 1});
	}
      } 
    }

    for(int i = 0; i < edge[now].size(); i++){
      int next = edge[now][i].to;
      int cost = edge[now][i].cost;
      
      if(node[ticket][next].val > node[ticket][now].val + cost){
	node[ticket][next].val = node[ticket][now].val + cost;
	que.push((P){node[ticket][next].val,next,ticket});
      }
    }
  }
  
  int ans = INF;

  for(int i = 0; i < c; i++){
    ans = min(ans,node[i][d].val);
  }

  cout << ans << endl;
  }
}
  

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

const int MAX = 200000;

bool isPrime[MAX + 1];

void sieve(int N) {
  for (int i = 0; i <= N; i++) {
    isPrime[i] = true;
  }

  isPrime[0] = isPrime[1] = false;

  for (int i = 2; i <= N; i++) {
    if (!isPrime[i]) continue;
    for (int j = i + i; j <= N; j += i) {
      isPrime[j] = false;
    }
  }
}

int main() {
  sieve(MAX);
  int x;
  cin >> x;
  for (int i = 0;; i++) {
    if (isPrime[x + i]) {
      cout << x + i << endl;
      return 0;
    }
  }
}


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

using namespace std;
 
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
#define pb push_back;
#define mp make_pair;
#define fi first;
#define se second;
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define forin(i, n) for (auto& i : (n))
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;

const int INF = 1 << 29;
const int MOD = 1e9 + 7;

vector<int> z_f(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}

int main() {
  int n;
  string s;
  cin >> n >> s;

  int ans = 0;
  forn(j,n){
    string ss = s.substr(j);
    int nn = (int) ss.size();
    vi z = z_f(ss);
    forn(i,nn) ans = max(ans, min(z[i],i));
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
   int a,b;
   cin >> a >> b;
   cout << a * a - b << endl; 
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int x; cin >> x;
	if (x < 1200) cout << "ABC" << endl;
	else  cout << "ARC" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
using namespace std;
typedef long long ll;
int len(ll x){
  int ret=0;
  while(x){
    x/=10;
    ++ret;
  }
  return ret;
}
int main(){
  ll n; cin>>n;
  int ans = len(n);
  for(ll i=1;i*i<=n;++i)
    if(n%i==0)
      ans=min(ans,max(len(i),len(n/i)));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	char c;
	cin>>c;
	
	cout<<char(c+1)<<endl;
}


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

int main(){
    int N;
    cin >> N;
    vector<float> A(N);
    for (int i = 0; i < N; i++) cin >> A.at(i);
    double X = 0, Y = 0;
    for (int i = 0; i < N; i++){
        X = X + (1 / A.at(i));
    }
    Y = 1 / X;
    cout << Y << endl;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;
int n,i,x,nr;
int main()
{
    scanf ("%d", &n);
    for (i=1;i<=n;i++)
    {
        scanf ("%d", &x);
        if (x%2==1)
            nr++;
    }
    if (nr%2==0)
        printf ("YES\n");
    else
        printf ("NO\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val (a, b, c, x, y) = (sc.nextLong(), sc.nextLong(), sc.nextLong(), sc.nextLong(), sc.nextLong())

  println(Seq(a * x + b * y, c * x * 2 + b * math.max(0, y - x), c * y * 2 + a * math.max(0, x - y)).min)
}


Measured memory_bytes: 27168
/*
* @Author: kabbo
* @Date:   2020-05-24 06:47:42
* @Last Modified by:   kabbo
* @Last Modified time: 2020-05-24 07:01:05
*/
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define endl '\n'
#define ull unsigned long long
#define ll long long
const int mod = 1e9 + 7;
using u64 = uint64_t;
using u128 = __uint128_t;
double dp[3005][3005];
void solve() {
	int n;
	cin >> n;
	vector<double>arr(n + 1);
	for (int i(1); i <= n; ++i)
		cin >> arr[i];

	memset(dp, -1, sizeof(dp));
	function<double(int, int)>prob = [&](int n, int x) {
		if (x == 0)
			return 1.0;
		if (n == 0)
			return 0.0;
		if (dp[n][x] > -0.9)
			return dp[n][x];
		return dp[n][x] = arr[n] * prob(n - 1, x - 1) + (1 - arr[n]) * prob(n - 1, x);
	};
	cout << setprecision(10) << fixed << prob(n, (n + 1) / 2) << endl;
}
int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	/*int t;
	cin >> t;
	for (int i(1); i <= t; ++i) {
		printf("Case %d: ", i);*/
	solve();
	//}
#ifndef LOCAL_DEFINE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
	return 0;
}

Measured memory_bytes: 71168
def gcd(a, b):
    if a < b:
        a,b = b,a
    while b > 0:
        r = a % b
        a,b = b,r
    return a

def lcm(a, b):
    if a == 0 or b == 0:
        print("Error")
        return 0
    return int(a * b // gcd(a, b))

def arrlcm(a):
    alen = len(a)
    if alen == 3:
        return lcm(a[0], lcm(a[1], a[2]))
    elif alen == 2:
        return lcm(a[0], a[1])
    elif alen == 1:
        return a[0] # 最初から1つ
    elif alen == 0:
        return 0
    else:
        return lcm(arrlcm(a[:alen//2]), arrlcm(a[alen//2:]))

def solve():
    n = int(input())
    print(arrlcm([int(input()) for _ in range(n)]))


if __name__=="__main__":
    solve()

Measured memory_bytes: 3064
#include <stdio.h>
#include<iostream>
#include<cstring>
typedef long long LL;
struct node{
	int id,ai;
}s[200005];
int siz;
struct nb{
	int l,r,ai;
}num[200005];
void psh(int id,int ai){
	s[++siz].id=id;
	s[siz].ai=ai;
}
int main(void)
{
	int n;
	siz=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		num[i].r=n;
		num[i].l=1;
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&num[i].ai);
		if(siz==0){
			psh(i,num[i].ai);
		}
		else {
			while(siz){
				if(num[i].ai<s[siz].ai){
					num[s[siz].id].r=i-1;
					siz--;
				}
				else break;
			}
			psh(i,num[i].ai);
		}
	}
	siz=0;
	for(int i=n;i>=1;i--){
		if(siz==0){
			psh(i,num[i].ai);
		}
		else {
			while(siz){
				if(num[i].ai<s[siz].ai){
					num[s[siz].id].l=i+1;
					siz--;
				}
				else break;
			}
			psh(i,num[i].ai);
		}
	}
	LL ans=0;
	for(int i=1;i<=n;i++){
		ans+=(LL)(i-num[i].l+1)*(num[i].r-i+1)*num[i].ai;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 4096
chop($s=<>=~y/?/./r);chop($t=<>);$n=length$s;$a=UNRESTORABLE;$p=substr($s,$_,$m=length$t),$t=~/^$p$/?$a=substr($s,0,$_).$t.substr($s,$_+$m):0for 0..length$s;print$a=~y/./a/r;

Measured memory_bytes: 512
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, k;
  cin >> n >> k;

  int a = k;
  for (int i = 0; i < n - 1; i++) a *= k - 1;
  printf("%d\n", a);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int n, arr['z'-'a'+1]{};
  string curr;
  cin >> n >> curr;
  for(int i = 0; i < curr.size(); i++)
    arr[ curr[i] - 'a' ]++;
  for(int i = 1; i < n; i++)
  {
    cin >> curr;
    int  tmp['z'-'a'+1]{};
    for(int j = 0; j < curr.size(); j++)
      tmp[ curr[j] - 'a' ]++;
    for(int j = 0; j < 'z'-'a'+1; j++)
      arr[j] = arr[j] > tmp[j] ? tmp[j] : arr[j];
  }
  for(int i = 0; i < 'z'-'a'+1; i++)
    for(int j = 0; j < arr[i]; j++)
      cout << (char)('a'+i);
}

Measured memory_bytes: 3036
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int n, b[2][128];

int rec1(int x, int y){
  if(b[x][y+1] == 1) return rec1(x, y+1);
  return y;
}

int rec2(int x, int y){
  if(b[x][y] == 2) return rec2(x, y-1);
  return y;
}

int main(){
  while(scanf("%d", &n) && n){
    rep(i, 2) rep(j, n) scanf("%d", &b[i][j]);

    queue<pii>q;
    q.push(MP(0, MP(0, 0)));
    q.push(MP(1, MP(0, 0)));
    map<pi, int>m;
    m[MP(0, 0)] = 1; m[MP(1, 0)] = 0;

    int res = -1;
    while(!q.empty()){
      pii now = q.front(); q.pop();
      //      printf("%d %d %d\n", now.F, now.S.F, now.S.S);
      if(b[now.F][now.S.F] == 1) now.S.F = rec1(now.F, now.S.F);
      else if(b[now.F][now.S.F] == 2) now.S.F = rec2(now.F, now.S.F);

      if(now.S.F >= n-1){
	res = now.S.S;
	break;
      }

      rep(i, 3){
	pii next = now;
	next.F = (next.F+1)%2;
	next.S.F += i;
	next.S.S++;
	if(m.count(MP(next.F, next.S.F))) continue;
	m[MP(next.F, next.S.F)] = next.S.S;
	q.push(next);
      }
    }
    if(res < 0) puts("NA");
    else printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 1212
class Node():
	def __init__(self, key):
		self.parent = None
		self.left = None
		self.right = None
		self.key = key
 
class Tree():
	def __init__(self):
		self.root = None
	def insert_node(self, key):
		z = Node(key)
		y = None
		x = self.root
		while x:
			y = x
			if z.key < x.key:
				x = x.left
			else:
				x = x.right
		z.parent = y
		if y == None:
			self.root = z;
		elif z.key < y.key:
			y.left = z
		else:
			y.right = z
	def delete_node(self, key):
		node = self.find_node(key)
		if node.left and node.right:
			right_min = node.right
			while right_min.left:
				right_min = right_min.left
			node.key = right_min.key
			node = right_min
		if node.left or node.right:
			child = node.left if node.left else node.right
			if node.parent.left == node:
				node.parent.left = child
				child.parent = node.parent
			else:
				node.parent.right = child
				child.parent = node.parent
		else:
			if node.parent.left == node:
				node.parent.left = None
			else:
				node.parent.right = None

	def pre_order(self, node):
		print(" {}".format(node.key), end = "")
		if node.left:
			self.pre_order(node.left)
		if node.right:
			self.pre_order(node.right)
	def in_order(self, node):
		if node.left:
			self.in_order(node.left)
		print(" {}".format(node.key), end = "")
		if node.right:
			self.in_order(node.right)
	def print_node(self):
		self.in_order(self.root)
		print("")
		self.pre_order(self.root)
		print("")
	def find_node(self, key):
		node = self.root;
		while node:
			if node.key == key:
				return node
			elif node.key > key:
				node = node.left
			else:
				node = node.right
		return None

tree = Tree()
n = int(input())
for i in range(n):
	c = input().split()
	if c[0] == "insert":
		tree.insert_node(int(c[1]))
	elif c[0] == "find":
		print("yes" if tree.find_node(int(c[1])) else "no")
	elif c[0] == "delete":
		tree.delete_node(int(c[1]))
	else:
		tree.print_node()

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

const int MOD = (int)1e9+7;

int main(){
	int H,W;
	cin >> H >> W;
	vector<string> A(H);
	for(int i=0;i<H;i++)	cin >> A.at(i);

	vector<vector<int>> dis(H,vector<int>(W,1e9));
	queue<pair<int,int>> que_yx;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(A.at(i).at(j)=='#'){
				dis.at(i).at(j)=0;
				que_yx.push(make_pair(i,j));
			}
		}
	}

	vector<int> move_y={0,1,0,-1};
	vector<int> move_x={1,0,-1,0};
	while(!que_yx.empty()){
		int y=que_yx.front().first;
		int x=que_yx.front().second;
		que_yx.pop();
		for(int i=0;i<4;i++){
			int next_y=y+move_y.at(i);
			int next_x=x+move_x.at(i);
			if(next_y<0 || next_y>=H || next_x<0 || next_x>=W)	continue;
			if(dis.at(next_y).at(next_x)!=1e9)	continue;
			que_yx.push(make_pair(next_y,next_x));
			dis.at(next_y).at(next_x)=dis.at(y).at(x)+1;
		}
	}

	int ans=0;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			ans=max(ans,dis.at(i).at(j));
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 13456
#include <iostream>

using namespace std;

long long int S[(int)1e4];
long long int T[(int)5e2];

int main() {
  int n;
  int q;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> S[i];
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> T[i];
  }

  int count = 0;

  for (int i = 0; i < q; i++) {
    for (int j = 0; j < n; j++) {
      if (T[i] == S[j]) {
        count++;
        break;
      }
    }
  } 

  cout << count << endl;
  return 0;
}



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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="776";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
from math import ceil, sqrt

N = int(input())

k = ceil(0.5 * (-1 + sqrt(1 + 8 * N)))

ans = set()
for i in range(1, k + 1)[::-1]:
    if i <= N:
        N -= i
        ans.add(i)

print(*sorted(list(ans)), sep='\n')


Measured memory_bytes: 3700
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >>n;
    vector<int> arr(n);
    for(int i = 0; i < n; i++)
        cin >>arr[i];
    vector<int> temp = arr;
    sort(temp.begin(), temp.end());
    int mx = temp[n-1];
    int mx2 = temp[n-2];
    for(auto ele : arr){
        if(ele == mx)
            cout <<mx2 <<"\n";
        else 
            cout <<mx <<"\n";
    }
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define ms(a,v) memset(a,v,sizeof a)
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor
 *
 * */
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, k, d, x; cin>>n>>k;
	vector<bool> freq(10, 0);
	while(k--){
		cin>>d;
		freq[d]=1;
	}
	while(2+2!=5){
		x=n;
		while(x){
			if (freq[x%10]) break;
			x/=10;
		}
		if (x==0) {cout<<n; return 0;}
		n++;
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
ans =  S.count("E")
left = 0
right = ans
for i in S:
    if i == "E":
        right -= 1
        ans = min(ans,right+left)
    if i == "W":
        ans = min(ans,right+left)
        left += 1
print(ans)

Measured memory_bytes: 9768
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int T = sc.nextInt();
        int A = sc.nextInt();
        
        int ans = 0;
        double best = 100000000;
        for(int n=1;n<=N;n++){
        	int h = sc.nextInt();
        	double temp = T - h*0.006;
        	double err = Math.abs(A-temp);
        	if(err<best){
        		best = err;
        		ans = n;
        	}
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23396
import sys
readline = sys.stdin.readline

import numpy as np

N,W = map(int,readline().split())

dp = np.zeros(W + 1, dtype = int)
for i in range(N):
  w,v = map(int,readline().split())
  np.maximum(dp[:-w] + v,dp[w:],out = dp[w:])
  
print(max(dp))

Measured memory_bytes: 28864
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define mp make_pair
#define ff first
#define se second
#define MAX 1000001
#define MAXN 200001
#define mod 1000000007 
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=3,count=0,count1=0,i,x,y;
    ll a[5]={0};
    cin>>x>>y;
    a[x]++;
    a[y]++;
    cin>>x>>y;
    a[x]++;
    a[y]++;
    cin>>x>>y;
    a[x]++;
    a[y]++;
    for(i=1;i<=4;i++){
        if(a[i]==1){
            count++;
        }
        if(a[i]==2){
            count1++;
        }
    }
    if(count==count1 && count==2){
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }
}

Measured memory_bytes: 256
N, M, C = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
A = [[]] * N
for i in range(N):
    A[i] = [int(i) for i in input().split()]


def inner_prod(v1, v2):
    return sum([x * y for x, y in zip(v1, v2)])


ans = 0
for a in A:
    if inner_prod(a, B) + C > 0:
        ans += 1
print(ans)


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

int n;
int col[200000];
vector<int> g[200000];
int siz[200000];
int par[200000];
int tmp[200000];
void pre(int from, int prev) {
  int sum = 1;
  for (int to : g[from]) {
    if (to == prev) continue;
    pre(to, from);
    sum += siz[to];
  }
  siz[from] = sum;
}

void pre2(int from, int prev) {
  int saved = -1;
  if (prev != -1) {
    saved = tmp[col[prev]];
    tmp[col[prev]] = from;
  }
  par[from] = tmp[col[from]];
  for (int to : g[from]) {
    if (to == prev) continue;
    pre2(to, from);
  }
  if (prev != -1) {
    tmp[col[prev]] = saved;
  }
}

long ans[200000];
long cnt[200000];
long det[200000];
void rec(int from, int prev) {
  int p = par[from];
  int c = col[from];
  if (p == 0) {
    det[c] += siz[from];
  } else {
    cnt[p] += siz[from];
  }
  
  for (int to : g[from]) {
    if (to == prev) continue;
    rec(to, from);
  }
  
  if (from == 0) {
    for (int i = 0; i < n; ++i) {
      long num = siz[from] - det[i];
      ans[i] -= num * (num + 1) / 2;
    }
  } else {
    long num = siz[from] - cnt[from];
    ans[col[prev]] -= num * (num + 1) / 2;
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> col[i];
    --col[i];
  }
  for (int i = 1; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  
  pre(0, -1);
  fill(tmp, tmp + n, 0);
  pre2(0, -1);
  fill(ans, ans + n, long(n) * (n + 1) / 2);
  rec(0, -1);
  
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 37796
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	string a;
	bool v[2]={0};
	int i=0;
	for(cin>>a;i<a.length();i++){
		if(a[i]=='C') v[0]=1;
		if(a[i]=='F'&&v[0])  v[1]=1;
	}
	if(v[1])
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;


int main(){
	int a, b;
	cin >> a >> b;
	cout << max(0, a-b*2) << endl;
	return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll Pow(ll A, ll B, ll mod){
  if (B == 0) return 1;
  else{
    if (B % 2 == 0){
      return Pow(A * A % mod, B / 2, mod) % mod;
    }else{
      return A * Pow(A * A % mod, B / 2, mod) % mod;
    }
  }
}

ll nCr(ll N, ll C, ll mod){
  ll ans = 1; C = min(C, N - C);
  for (ll i = 1; i <= C; i++){
    ans *= N - i + 1; ans %= mod;
    ans *= Pow(i, mod - 2, mod); ans %= mod;
  }
  return ans;
}


int main(){
  int N; ll D, A; cin >> N >> D >> A;
  vector <Pll> XH(N);
  for (int i = 0; i < N; i++){
    ll X, H; cin >> X >> H;
    XH[i] = make_pair(X, H);
  }
  sort(XH.begin(), XH.end());

  vector <int> can(N);
  int L = 0, R = 0;
  for (int i = 0; i < N; i++){
    for (int j = R; j < N; j++){
      if (XH[j].first - XH[i].first <= 2 * D) R = j;
      else break;
    }
    can[i] = R;
  }

  vector <ll> damage(N + 1);
  ll ans = 0;
  for (int i = 0; i < N; i++){

    if (damage[i] < XH[i].second){
      ll rest = (XH[i].second - damage[i]) / A;
      if ((XH[i].second - damage[i]) % A != 0) rest++;

      ans += rest;
      damage[i] += rest * A;
      damage[can[i] + 1] -= rest * A;
    }
    
    damage[i + 1] += damage[i];
  }
  cout << ans << endl;

  
  return 0;
}


Measured memory_bytes: 5760
import java.util.Scanner;


public class Main {

	public static void main(String [] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int x;
		
		for(int i = 1;i <= n;i++) {
			
			x = i;
			
			
			if(x % 3 == 0) {
				System.out.print(" " + x);
				
			}else {
					
			
			while(true) {
				if(x % 10 == 3) {
					System.out.print(" " + i);
					break;
					
				}
				
				if(x < 10) {
					break;
					
				}else {
					x = x / 10;
					
				}
			}
		}
		}
		
		
		System.out.println("");
		
				
	}
}



Measured memory_bytes: 28776