akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, m, a, b;
  in2(n, m);
  vector<ll> c(n + 1, 0), d(n + 1, 1);
  c[1] = 1;
  rep(i, m){
    in2(a, b);
    if(c[a] == 1){
      if(d[a] == 1){
        c[a] = 0;
        d[a]--;
        c[b] = 1;
        d[b]++;
      }
      else{
        d[a]--;
        d[b]++;
        c[b] = 1;
      }
    }
    else{
      d[a]--;
      d[b]++;
    }
  }
  a = 0;
  rep(i, n + 1){
    if(c[i] > 0)
      a++;
  }
  out(a);
  memi;
}


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

void solve() {
    int n;
    cin >> n;
    vector<long long> pref(n);
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        long long x;
        cin >> x;

        sum += x;
        pref[i] = sum;
    }
    long long ans = 1e18;
    for (int i = 0; i < n - 1; i++) {
        long long temp = abs(sum - 2 * pref[i] + 0ll);
        ans = min(ans, temp);
    }
    cout << ans;


}


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


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

int main()
{
    int x;
    cin >> x;
    if (x % 7 == 0)
        cout << "thu" << endl;
    else if (x % 7 == 1)
        cout << "fri" << endl;
    else if (x % 7 == 2)
        cout << "sat" << endl;
    else if (x % 7 == 3)
        cout << "sun" << endl;
    else if (x % 7 == 4)
        cout << "mon" << endl;
    else if (x % 7 == 5)
        cout << "tue" << endl;
    else if (x % 7 == 6)
        cout << "wed" << endl;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h> 
using namespace std; 
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI1 3.14159265358979311599796346854418516159057617187500

typedef long long int ll;

int main() 
{ 
    FIO
    ll t;
    t=1;

    while(t--)
    {
        ll n,m;
        cin >> n >> m;

        ll sum = 0;
        for(int i=0;i<m;i++)
        {
            ll x;
            cin >> x;
            sum += x;
        }

        if(sum > n)
            cout << -1 << endl;
        else
            cout << n-sum << endl;

    }
    return 0; 
} 


Measured memory_bytes: 3652
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String input = scan.next();
        for(int i = input.length() - 1; i > -1; i--) {
            System.out.print(input.charAt(i));
        }
        System.out.println();
    }
    
}

Measured memory_bytes: 25796
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  ll N, K;
  cin >> N >> K;
  ll X = N % K;
  cout << min(X, K - X) << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
N,A,B,C,D=map(int,input().split())
S=input()
if C<D:
  for i in range(A-1,D-1):
    if S[i]=="#" and S[i+1]=="#":
      print("No")
      sys.exit()
  print("Yes")
  sys.exit()
else:
  for i in range(A-1,C-1):
    if S[i]=="#" and S[i+1]=="#":
      print("No")
      sys.exit()  
  for i in range(B-2,D-1):
    if S[i]=="." and S[i+1]=="." and S[i+2]==".":
      print("Yes")
      sys.exit()
    if i==D-2:
      print("No")
      sys.exit()
  print("Yes")
  sys.exit()

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

int f[2];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int k;
    string s;
    cin>>k;
    cin>>s;
    if(s.length()<=k)cout<<s<<"\n";
    else{
        cout<<s.substr(0,k);
        cout<<"...\n";
    }
    
    return 0;
}

Measured memory_bytes: 3636
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    n = input()
    num = 0
    for i in n:
        num += int(i)

    if int(n)%num == 0:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3444
#include<stdio.h>
int main(void)
{
    int h,m,s,S;
    scanf("%d",&S);
    
    h=S/3600;
    m=S%3600/60;
    s=S%3600%60;
    
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}


Measured memory_bytes: 2120
//encoding:utf-8
#include <iostream> //c++
#include<time.h> //時間にかんして
#include<stack> //スタックに関して　最新のデータから捨てる
#include<queue> //キューに関して　最古のデータから捨てる
#include<math.h>
#include<vector>
#include<algorithm> //sort とかにいる

#define ll long long
using namespace std;
int main(){
  vector<int>nums(3);
  int even=0;
  int ans=0;
  for(int i=0;i<3;i++){
    cin>>nums[i];
    if(nums[i]%2==0){
      even++;
    }
  }
  if(even==3){
  }
  else if(even==2){
    for(int i=0;i<3;i++){
      if(nums[i]%2==0){
        nums[i]+=1;
      }
    }
  ans++;
  }
  else if(even==1){
    for(int i=0;i<3;i++){
      if(nums[i]%2==1){
        nums[i]+=1;
      }
    }
  ans++;
  }
  else{}
  int max = 0;
  int sum = 0;
  for(int i=0;i<3;i++){
    sum += nums[i];
    if(max<nums[i]){
      max=nums[i];
    }

  }
  ans+=((3*max-sum)/2);

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

int N, K;
vector<vector<int> > G;

int solve1(){ //N < 9;
  
  for(int i=0;i<N;i++){
    cout<<i+1<<endl;
    string res;
    cin>>res;
    if(res == "Yes") return 0;
  }
  assert(0);
  //return 0;
}

int solve2(){
  
  int ans = 0;
  for(int i=0;i<9;i++){
    cout<<i+1<<endl;
    string res;
    cin>>res;
    if(res == "Yes") return 0;
    if(res == "Near") ans = ans + (1<<i);
  }
  cout<<ans+1<<endl;
  string res;
  cin>>res;
  assert(res == "Yes");
  return 0;
}

signed main(){
  srand((unsigned)time(NULL));
  //cin.tie(0);
  //ios_base::sync_with_stdio(0);
  //cout << fixed << setprecision(12);


  cin>>N>>K;

  if(N < 9){
    cout<<0<<endl;
    while(K--) solve1();
  }
  else{

    int M = 0;
    G.resize(N);
    for(int i=9;i<N;i++)
      for(int j=0;j<9;j++){
	if(i>>j&1) G[i].push_back(j), G[j].push_back(i), M++;
      }

    cout<<M<<endl;
    for(int i=0;i<N;i++)
      for(int j:G[i]) if(i < j) cout<<i+1<<" "<<j+1<<endl;

    while(K--) solve2();
  }
  
  return 0;
}



Measured memory_bytes: 3308
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

int main(void) {
    s64 a, b, c, d;
    cin >> a >> b >> c >> d;

    s64 ans = max(max(a*c, a*d), max(b*c, b*d));

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

Measured memory_bytes: 3632
#include <array>
#include <iostream>
#include <vector>

using namespace std;

constexpr int64_t N_SIZE{100 + 1};
constexpr int64_t W_SIZE{100000 + 1};
array<int64_t, N_SIZE> weight;
array<int64_t, N_SIZE> value;
array<array<int64_t, W_SIZE>, N_SIZE> dp;

int main(int argc, char* argv[]) {
  int64_t N, W;
  cin >> N >> W;
  for (int64_t i = 1; i <= N; ++i) {
    cin >> weight[i] >> value[i];
  }

  for (int64_t n = 1; n <= N; ++n) {
    for (int64_t w = 0; w <= W; ++w) {
      if (w < weight[n]) {
        dp[n][w] = dp[n - 1][w];
      } else {
        dp[n][w] = max(dp[n - 1][w], dp[n - 1][w - weight[n]] + value[n]);
      }
    }
  }
  cout << dp[N][W] << endl;
  return 0;
}


Measured memory_bytes: 78464
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
using namespace std;

typedef long long ll;
const int N=1e8+7;

int main()
{
    ll n,m;
    cin>>n>>m;
    if(m==1||n==1)
    {
        cout<<1<<endl;
        return 0;
    }
    ll q1=(n+1)/2,q2=n-q1;
    ll ans1=(m+1)/2,ans2=m/2;
    cout<<q1*ans1+q2*ans2<<endl;
}


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

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

  vector<int> ans(n+1, 0);
  int rootn = sqrt(n);
  for ( int x = 1; x <= rootn; x++ ) {
    for ( int y = 1; y <= rootn; y++ ) {
      for ( int z = 1; z <= rootn; z++ ) {
        int now = x*x + y*y + z*z + x*y + y*z + z*x;
        if ( now <= n ) {
          ans[now]++;
        }
      }
    }
  }

  for ( int i = 1; i <= n; i++ ) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3500
// Think twice, Code once
// 1SAC
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
 
/*============================ DEBUGGING =============================*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
/*============================= DEFINES ==============================*/
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
/*============================== TYPEDEFS ============================*/
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;
/*============================ START FROM HERE =======================*/
vll primes;
bool ok[100055];
void sieve(){
	memset(ok,true,sizeof ok);
	ok[0] = 0;ok[1]=0;
	for(ll i=2;i*i<=100050;i++){
		if(ok[i]){
			for(ll j=i*i;j<=100050;j+=i)ok[j] = 0;
		}
	}
	forn(i,100055)if(ok[i])primes.pb(i);
}
int main(){
	FIO
	
	int x; cin >> x;
	sieve();
	//deb(primes);
	cout <<*lower_bound(all(primes),x);
	return 0;
}


Measured memory_bytes: 512
import fractions
a,b,c,d = [int(i) for i in input().split()]
e = b - a + 1
lcm = c*d//fractions.gcd(c,d)

bc = b//c
bd = b//d
ac = (a-1)//c
ad = (a-1)//d
bcd = b//lcm
acd = (a-1)//lcm

f = (bc + bd - bcd) - (ac+ ad -acd)

print(e-f)

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

typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;
    for ( int i= 0; i<= max( a,b); i++) {
        if (  abs( a - i) == abs(b-i)) {
            cout << i << '\n';
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << '\n';
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s));

            var a = input.ElementAt(0);
            var b = input.ElementAt(1);
            var x = input.ElementAt(2);

            if (a > x)
            {
                Console.WriteLine("NO");
                return;
            }
            if(a + b > x) Console.WriteLine("YES");
            else Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>
#define FREE 0
#define NOT_FREE 1
#define N 8

int row[N];
int col[N];
int dpos[20], dneg[20];
char a[N][N];

void putQueen(int);
void print();

int main(){

  int n, i, r, c, j, k;

  scanf("%d", &n);

  for(i=0; i<n; i++){ //error
    scanf("%d %d", &r, &c);

    a[r][c]='Q';//あらかじめQと分っているところには先に入れておく
  }
  putQueen(0); //i=0から順にQを置いていく

  //print
  
  return 0;
}

void putQueen(int i){

  int j;

  if(i==N){
    print();
    return;
  }
  for(j=0; j<N; j++){

    if(col[j]==NOT_FREE ||
       dpos[i+j]== NOT_FREE ||
       dneg[i-j+N-1]== NOT_FREE){
      continue;
    } // 縦・横・斜めにQが既にあるなら

    //ないならQを置く
    row[i]=j; //i行目にはj列にQがある
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;//Qを置いたのでNOT_FREEを印

    //next row ex) j=2でQ置いたら次の行に行く

    putQueen(i+1);
    col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}
void print(){

  int i, j;

  for(i=0; i<N; i++){
    for(j=0; j<N; j++){

      if(a[i][j]=='Q'){
	if(row[i]!=j) return;
      }
    }
  }
    
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      if(row[i]==j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
  
}

    



Measured memory_bytes: 2112
#include<iostream>
using namespace std;
int main()
{
	long long int n;
	cin>>n;
	long long int s=100;
	long long int m;
	long long int l=0;
	while(s<n)
	{
		m=(s*0.01)/1;
		s+=m;
		l++;
	}
	cout<<l<<endl;
}

Measured memory_bytes: 3224
gets
elems = gets.chomp.split.map(&:to_i)
gets
query = gets.chomp.split.map(&:to_i)

def bsearch(q, elems)
    mid = elems.length / 2
    if elems[mid] == q then
        1
    elsif elems.length == 1
        0
    elsif elems[mid] > q
        bsearch(q, elems[0...mid])
    else
        bsearch(q, elems[mid...elems.length])
    end
end

sum = query.reduce(0) do |acc, q|
    acc += bsearch(q, elems)
end

p sum


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

ll n, k;
vector <ll> arr, dp;

void init()
{
	for(ll i = 0; i < n; i++)
	dp[i] = -1;
}

ll solve(ll i)
{
	if(dp[i] != -1)
	return dp[i];
	
	if(i <= 0)
	return 0;
	
	else
	{
		ll z = 1000000000;
		for(ll j = 1; j <= k; j++)
		{
			if(i >= j)
			z = min(z, solve(i - j) + abs(arr[i] - arr[i - j]));
		}
		dp[i] = z;
		return z;
	}
}

int main()
{
	cin>>n>>k;
	arr.resize(n);
	dp.resize(n);
	init();
	for(int i = 0; i < n; i++)
		cin>>arr[i];
	
	cout<<solve(n - 1)<<"\n";
	return 0;
}

Measured memory_bytes: 6528
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() (h, w, k int, g [][]int) {
	h, w, k = scanInt(sc), scanInt(sc), scanInt(sc)
	g = nextGrid(h, w)
	return
}

const (
	white = 0 + iota
	black
	red
)

func nextGrid(h, w int) [][]int {
	grid := make([][]int, h)
	for i := 0; i < h; i++ {
		grid[i] = make([]int, w)
		str := scanString(sc)
		for j := 0; j < w; j++ {
			switch str[j] {
			case '.':
				grid[i][j] = white
			case '#':
				grid[i][j] = black
			}
		}
	}
	return grid
}

func resolve(h, w, k int, g [][]int) int {
	num := 0
	for i := 0; i < 1<<uint(h); i++ {
		for j := 0; j < 1<<uint(w); j++ {
			if fullfill(g, uint(i), uint(j), k) {
				num++
			}
		}
	}
	return num
}

func fullfill(g [][]int, xFilter, yFilter uint, k int) bool {
	h := len(g)
	if h == 0 {
		return k == 0
	}
	w := len(g[0])
	num := 0
	for i := range loop0(h) {
		if xFilter&(1<<uint(i)) != 0 {
			continue
		}
		for j := range loop0(w) {
			if yFilter&(1<<uint(j)) != 0 {
				continue
			}
			if g[i][j] == black {
				num++
			}
			if num > k {
				return false
			}
		}
	}
	return num == k
}

func loop0(n int) chan int {
	return loop(0, n-1, 1)
}

func loop1(n int) chan int {
	return loop(1, n, 1)
}

func loop(s, e, d int) chan int {
	ch := make(chan int)
	go func() {
		for i := s; i <= e; i += d {
			ch <- i
		}
		close(ch)
	}()
	return ch
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 11072
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b)cout << c << endl;
    else if(a==c) cout << b << endl;
    else cout << a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

class BinaryIndexcedTree
{
// 1-indexed
public:
    vector<int> data;
    BinaryIndexcedTree(int N):data(N+1,0){}
    void updata(int i,int x){
        for(;i<data.size();i+=i&-i) chmax(data[i],x);
    }
    int query(int i){
        int res=0;
        for(;i>0;i-=i&-i) chmax(res,data[i]);
        return res;
    }
};

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

    int N; cin>>N;
    vector<int> h(N),a(N);
    for(int i=0;i<N;i++) cin>>h[i];
    for(int i=0;i<N;i++) cin>>a[i];

    vector<int> dp(N+1);
    BinaryIndexcedTree bit(N);
    for(int i=0;i<N;i++){
        dp[h[i]]=bit.query(h[i]-1)+a[i];
        bit.updata(h[i],dp[h[i]]);
        // for(int i=1;i<=N;i++) cout<<bit.query(i)<<' '; cout<<endl;
    }
    cout<<bit.query(N)<<endl;
    return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>
long long mod = 1000000007;
long long f(long long x, long long y) {
    return ((x+y)*(y-x+1)/2)%mod;
}
int main() {
    int n, k;
    long long ans = 0;
    scanf("%d%d", &n, &k);
    for (int i = k; i <= n + 1; i++) {
        ans = (ans + f(n-i+1,n) - f(0,i-1)+1+mod) % mod;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1700
#include<stdio.h>

int main(void){
  int W, H, x, y, r;

  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

  if(x+r > W){
    printf("No\n");
  }else if(x-r < 0){
    printf("No\n");
  }else if(y+r > H){
    printf("No\n");
  }else if(y-r < 0){
    printf("No\n");
  }else{
    printf("Yes\n");
  }

  return 0;
}



Measured memory_bytes: 2104
a = input()
dd = int(input())
mod = 10**9 + 7
n = len(a)
dp = [[[0 for j in range(dd)] for k in range(2)] for i in range(n+1)]
dp[0][0][0] = 1
for i in range(n):
  for j in range(2):
    for k in range(dd):
      lim = 9 if j else int(a[i]) - 0
      for d in range(lim+1):
        dp[i+1][(j or d) <lim][(k+d)%dd] += dp[i][j][k]
        dp[i+1][(j or d) <lim][(k+d)%dd] %= mod
ans = 0
for j in range(2):
  ans += dp[n][j][0]
print((ans-1)%mod)

Measured memory_bytes: 65244
/*input
200000 200001

*/
#include <bits/stdc++.h>
using namespace std; 
#define int long long int
#define max(x, y) ((x) > (y) ? (x) :(y))
#define pii pair< int , int> 
#define vi vector<int>
#define REP( i , st , en ) for ( int i =st; i < (int)en; i++)
#define REPD( i , en , st ) for ( int i =en; i >= (int)st; i--)
#define SZ(a) (int)a.size()
#define all(v) v.begin() , v.end()
#define pb push_back
#define F first
#define S second
#define bitch_i_m_on_fiyaah_yeahhhh ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

// const int mod = 998244353;
const int mod = 1e9+7;
ostream& operator << ( ostream&  o, vector<int> s){for ( int i = 0;  i < (int)s.size() ; i++)o << s[i] << " ";o << "\n";return o;}
void  add( int &a, int b){a = a + b;if ( a< 0 ) a += mod; if ( a> mod ) a-= mod;}
void sub( int &a, int b){a = a - b;if ( a < 0) a += mod;}
int mul( int a , int b){return ((a %mod) * (b %mod) ) %mod;}
int exp( int a , int pow){ return (pow == 0 ? 1 : ( pow & 1  ? mul ( a ,exp( mul(a, a) , pow /2) ) : exp(mul(a ,a) , pow/2)));}
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
// const int inf = 1e18;
const int maxn = 3e5;
vector<int> g[maxn];
void solve(int test ) 
{		
	int n , k ; cin >> n >> k;
	vector<int> v(n+2, 0);
	int f =0 , b = n;
	for ( int i = 0 ; i < n ;i ++){
		v[i] = b - f +1 ;
		add( f , (i+1));
		add( b , n -i-1);
	}
	k--;
	int ans=0;
	for ( int i = k ; i <= n ; i++)
		add( ans , v[i]);
	cout << ans+1;

}
signed main(){
	bitch_i_m_on_fiyaah_yeahhhh
	int t =1; 
	// cin >> t;
	
	for ( int i = 0 ; i < t; i++)
	solve(i+1 );
	
}

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

int main(){
  int x,y;
  while(1){
    cin >> x >> y;
    if(x==0 && y==0){
      break;
    }else{
      if(y<x){
	cout << y << " " << x << '\n';
      }else{
	cout << x << " " << y << '\n';
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
typedef long long ll;

const int    INF = 1000000000;
const int    MOD = 1000000007;
const double EPS = 1e-8;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> sum(N + 1, 0);
    for(int i = 0; i < N; i++){
        cin >> A[i];
        sum[i + 1] = sum[i] + A[i];
    }

    static ll dp[4005][4005] = {}; // minimam of A[0..i] to js
    static int back[4005][4005] = {};
    for(int i = 0; i <= N + 1; i++)
        for(int j = 0; j <= N + 1; j++)
            dp[i][j] = INF;

    dp[0][0] = -INF;
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= i; j++){
            // a[j], a[j + 1], ... a[i]
            ll s = sum[i + 1] - sum[j];
            int k = lower_bound(dp[j], dp[j] + N + 1, s) - dp[j];
            if(k == 0) continue;
            if(dp[i + 1][k] > s){
                dp[i + 1][k] = s;
                back[i + 1][k] = j - 1;
                //printf("dp[%d][%d] = %lld back[%d][%d] = %d\n", i + 1, k, s, i + 1, k, j - 1);
            }
        }
        for(int k = i; k >= 0; k--) dp[i + 1][k] = min(dp[i + 1][k], dp[i + 1][k + 1]);
        //for(int k = 0; k <= i + 2; k++) cout << dp[i + 1][k] << " "; cout << endl;
    }
    int M = lower_bound(dp[N], dp[N] + N + 1, INF) - dp[N] - 1;
    int curi = N - 1;
    int curM = M;
    vector<int> C;
    while(curM >= 2){
        //printf("curi %d curM %d\n", curi, curM);
        curi = back[curi + 1][curM--];
        C.push_back(curi + 1);
    }
    reverse(C.begin(), C.end());
    assert(C.size() == M - 1);
    cout << M << endl;
    for(int i = 0; i < C.size(); i++){
        cout << C[i];
        if(i + 1 < C.size()) cout << " ";
    }
    cout << endl;
    return 0;
}

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

#define int long long
#define mod 1000000007

using namespace std;

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

    int cnt = (n+1)/2;

    if(cnt < k)
        cout << "NO";
    else
        cout << "YES";
}

Measured memory_bytes: 256
def examC():
    H, W, K = LI()
    S = [SI() for _ in range(H)]
    d = defaultdict(int)
    ans = [[0]*W for _ in range(H)]; k = 1
    for i in range(H):
        num = 0
        if "#" not in S[i]:
            d[i] = 1
        else:
            for j in range(W):
                if S[i][j] == "#":
                    num += 1
                    if num >= 2:
                        k += 1
                ans[i][j] = k
            k += 1

    for i in d:
        if i == 0:
            p = 0;
            l = 0
            while p == 0:
                l += 1
                if ans[l][0] == 1:
                    p = l
            for j in range(W):
                ans[i][j] = ans[l][j]
        else:
            for j in range(W):
                ans[i][j] = ans[i - 1][j]
    for v in ans:
        print(" ".join(map(str,v)))


def examD():
    return

def examE():
    return

import sys,copy,bisect,itertools
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()


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

using namespace std;

const int N =  1e5+10;
using ll = long long;

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

	int n;
	cin >> n;vector<int> a(n+1),freq(n+1);
	
	for (int i = 0 ; i < n; i++) cin >> a[i], ++freq[a[i]];
	
	ll ans = 0;
	
	for (int i = 0 ; i <= n; i++) 
		ans += (ll)freq[i]*(freq[i]-1)/2;

	for (int i = 0 ; i < n; i++) 
		cout << ans - freq[a[i]] + 1 << '\n';
	
	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main()
{
    int n;
    cin >> n;
    lli a[100500];
    rep(i, n) cin >> a[i];
    lli x = 0;
    rep(i, n) x ^= a[i];
    int ans = 0;
    for (int i = 32; i >= 1; i--) {
        rep(j, n)
        {
            if (((1LL << i) - 1)
                == (a[j] ^ (a[j] - 1))) {
                if ((x >> (i - 1)) & 1) {
                    x ^= a[j] ^ (a[j] - 1);
                    ans++;
                }
            }
        }
    }
    cout << (x == 0 ? ans : -1) << endl;
}


Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AOJ
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static void Main(string[] args)
        {
            var N = Sarray()[0];
            var Ai = Sarray();

            Action<long[], long[], int> countingsort = null;
            var am = Ai.Max();
            var C = new long[am + 1];
            var Bi = new long[Ai.Length];
            countingsort = (A, B, k) =>
              {
                  for (var j = 0; j < N; ++j)
                  { C[A[j]]++; }
                  for (var i = 1; i <= k; ++i)
                  { C[i] += C[i - 1]; }
                  for (var j = N-1; 0 <= j; --j)
                  {
                      B[C[A[j]] - 1] = A[j];
                      --C[A[j]];
                  }
              };
            countingsort(Ai, Bi, (int)am);
            WriteLine(string.Join(" ", Bi));
        }
    }
}


Measured memory_bytes: 170108
using System;

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

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

int main(){
    int i,A,B,K;
    bool ans=false;
    cin>>K;
    cin>>A>>B;
    for(i=1;K*i<=B;i++){
        if(K*i>=A&&K*i<=B){
        ans=true;
        break;
        }
        if(K*i>B)break;
    }

    if(ans==true)cout<<"OK";
    else cout<<"NG";

return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>

using namespace std;

// 入力
int A, B, C, D, E, F;

int main(void) {
    cin >> A >> B >> C >> D >> E >> F;

    vector<int> water;
    vector<int> sugar;

    for (int i = 0; i <= F / (100 * A); ++i) {
        for (int j = 0; j <= F / (100 * B); ++j) {
            water.push_back(100 * A * i + 100 * B * j);
        }
    }
    for (int i = 0; i <= F / C; ++i) {
        for (int j = 0; j <= F / D; ++j) {
            sugar.push_back(C * i + D * j);
        }
    }

//    for (int i = 0; i < water.size(); ++i) {
//        cout << water[i] << " ";
//    }
//    cout << endl;
//    for (int i = 0; i < sugar.size(); ++i) {
//        cout << sugar[i] << " ";
//    }
//    cout << endl;
    int maxSugarWaterWeight = 0, maxSugarWeight = 0;
    double maxConcentration = 0;
    for (int i = 0; i < water.size(); ++i) {
        for (int j = 0; j < sugar.size(); ++j) {
            int waterWeight = water[i];
            int sugarWeight = sugar[j];
            if (waterWeight + sugarWeight <= F) {
                if (waterWeight * ((double) (E) / 100) >= sugarWeight) {
                    if (waterWeight + sugarWeight != 0) {
                        double concentration = (double) (100 * sugarWeight) / (waterWeight + sugarWeight);
                        if (concentration >= maxConcentration) {
                            maxConcentration = concentration;
                            maxSugarWaterWeight = waterWeight + sugarWeight;
                            maxSugarWeight = sugarWeight;
                        }
                    }
                }
            }
        }
    }

    cout << maxSugarWaterWeight << " " << maxSugarWeight << endl;
    return 0;
}

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

int main(void) {
    int n, k;
    cin >> n >> k;
    vector<int> cnt(2e5);
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        cnt.at(--tmp)++;
    }
    sort(cnt.begin(), cnt.end(), greater<int>());
    cout << accumulate(cnt.begin() + k, cnt.end(), 0) << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    if (N % 1000 == 0){
        cout << 0 << endl;
    }
    else
    {   
        cout << 1000 - (N % 1000) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);

struct BIT {
private:
	vector<ll> node; int n;
public:
	BIT(int n_) {
		n = n_; node.resize(n, 0);
	}
	//0-indexed
	void add(int a, ll w) {
		for (int i = a; i < n; i |= i + 1)node[i] += w;
	}
	//[0,a)
	ll sum(int a) {
		ll ret = 0;
		for (int i = a - 1; i >= 0; i = (i&(i + 1)) - 1)ret += node[i];
		return ret;
	}
	//[a,b)
	ll sum(int a, int b) {
		return sum(b) - sum(a);
	}
};

void solve() {
	int n, k; cin >> n >> k;
	vector<int> p(n);
	rep(i, n) {
		cin >> p[i];
	}
	if (n == k) {
		rep(i, n) {
			if (p[i] == 1) {
				rep(j, n) {
					int id = (i + j) % n;
					if (p[id] != 1 + j) {
						cout << "No" << endl; return;
					}
				}
			}
		}
		cout << "Yes" << endl;
		return;
	}
	if (k % 2 == 0) {
		cout << "Yes" << endl;
	}
	else {
		BIT b(n + 1);
		ll num = 0;
		rep(i, n) {
			num += i - b.sum(p[i]);
			b.add(p[i],1);
		}
		if (num % 2 == 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;

		}
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}




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

int main(){
    int k, s, x, y, z, a=0;
    cin >> k >> s;

    rep(i,k+1){
        rep(j,k+1){
            
            if(0<=s-i-j&&s-i-j<=k)
                a++;
        }
    }
    cout << a << endl;
}

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

int main() {
	int n, x;
	cin >> n >> x;
	int sum=0;
	vector<int> m(n);

	for(int i=0;i<n;i++) {
		cin >> m[i];
		sum += m[i];
	}

	sort(m.begin(), m.end());
	int count = m.size();

	while(sum<=x) {
		sum += m[0];
		count++;
	}

	cout << count-1 << endl;
}


Measured memory_bytes: 256
N,K = map(int, input().split())
*X, = map(int, input().split())

min = float('inf')
for i in range(N-K+1):
    left_cost = X[i]
    right_cost  = X[i+K-1]
    right_course = abs(right_cost)+abs(right_cost-left_cost)
    if min > right_course:
        min = right_course
    left_course = abs(left_cost)+abs(right_cost-left_cost)
    if min > left_course:
        min = left_course
        
print(min)

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

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int m = scanner.nextInt();

        final Edge[] edges = new Edge[m];
        for (int i = 0; i < m; i++) {
            final int a = scanner.nextInt();
            final int b = scanner.nextInt();
            final int c = scanner.nextInt();

            edges[i] = new Edge(a, b, -c);
        }

        final long[] dist = new long[n + 1];
        Arrays.fill(dist, Long.MAX_VALUE);
        dist[1] = 0;

        for (int i = 0; i < n - 1; i++) {
            for (final Edge edge : edges) {
                if (dist[edge.from] != Long.MAX_VALUE && dist[edge.from] + edge.weight < dist[edge.to]) {
                    dist[edge.to] = dist[edge.from] + edge.weight;
                }
            }
        }

        final long answer = -dist[n];
        final boolean[] isClosed = new boolean[n + 1];
        for (int i = 0; i < n; i++) {
            for (final Edge edge : edges) {
                if (isClosed[edge.from]) {
                    isClosed[edge.to] = true;
                }
                if (dist[edge.from] != Long.MAX_VALUE && dist[edge.from] + edge.weight < dist[edge.to]) {
                    dist[edge.to] = dist[edge.from] + edge.weight;
                    isClosed[edge.to] = true;
                }
            }
        }

        if (isClosed[n]) {
            System.out.println("inf");
        } else {
            System.out.println(answer);
        }
    }

    static class Edge {
        int from;
        int to;
        long weight;

        Edge(final int from, final int to, final long weight) {
            this.from = from;
            this.to = to;
            this.weight = weight;
        }
    }
}


Measured memory_bytes: 28280
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;


int main(){

    int n; cin >> n;
    Graph to(n),co(n);
    rep(i,n-1){
        int a,b,w; cin >> a >> b >> w;
        a--;b--;
        to.at(a).push_back(b);
        to.at(b).push_back(a);
        co.at(a).push_back(w);
        co.at(b).push_back(w);
    }

    vector<int> ans(n,-1);
    queue<int> q;
    ans.at(0) = 0;
    q.push(0);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        rep(i,to.at(v).size()){
            int u = to.at(v).at(i);
            int w = co.at(v).at(i);
            if(ans.at(u) != -1) continue;
            ans.at(u) = (ans.at(v)+w)%2;
            q.push(u);
        }
    }
    rep(i,n) cout << ans.at(i) << endl;

    return 0;
}


Measured memory_bytes: 11904
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int ans = 0;
        for (int i = 0; i < n; i++) {
            ans += a[i];
        }
        ans = ans - a.length;

        System.out.println(ans);
    }
}

Measured memory_bytes: 27348
//　暑い日々　0579
#include<bits/stdc++.h>
using namespace std;
int dp[201][201];
int main(void)
{
	int d,n,t[201],a[201],b[201],c[201];
	int i,j,k,w=0,x,max;
	
	cin>>d>>n;
	for(i=1;i<=d;i++) cin>>t[i];
	for(i=1;i<=n;i++) cin>>a[i]>>b[i]>>c[i];
	
	for(i=1;i<=d;i++){
		for(j=1;j<=n;j++) dp[i][j]=-1;
	}
	
	for(i=1;i<=n;i++){
			if(t[1]<=b[i]&&t[1]>=a[i]) dp[1][i]=0;
	}
	
	for(i=1;i<d;i++){
		for(j=1;j<=n;j++){
			if(dp[i][j]!=-1){
				for(k=1;k<=n;k++){
					if(t[i+1]>=a[k]&&t[i+1]<=b[k]){
							w=abs(c[j]-c[k]);	
						if(dp[i+1][k]<dp[i][j]+w){
							dp[i+1][k]=dp[i][j]+w;
						}	
					}
				}
			}
		}
	}
	
	x=-1;
	for(i=1;i<=n;i++){
		if(x<dp[d][i]) x=dp[d][i];
	}
	
	cout<<x<<endl;
	
	return 0;
}	
					


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

int main(){
	int N, alice = 0, bob = 0;
  	cin >> N;
  	vector<int> a(N);
  	for(int i = 0; i < N ;i++)
      cin >>a[i];
    sort(a.begin(),a.end());
  	for(int i = N-1 ; i >= 0 ; i--){
    	alice += a[i];
      	if(i-1>=0){i--; bob += a[i];}
    }
  	cout << alice - bob << endl;
}


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

int main(){
  int h=0 ,w=0 ,sh=0 , sw=0,s=0;
  cin >> h >> w >> sh >> sw;
  s = h*w;
  s-=sh*w;//行分減らす
  s-=((h-sh)*sw);
  cout << s << endl;

}


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

int main()
{
    char s[100];
    int l,i,k=0;
    gets(s);
    l=strlen(s);
    for(i=0; i<l-1; i++)
    {
        if(s[i]=='A' && s[i+1]=='C')
        {
            k=1;
            break;
        }
    }
    if(k==1)printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  int rt = 1;
  for (int i=0; i<N; i++){
    if (2*rt < rt+K){
      rt*=2;
    }
    else{
      rt+=K;}
    }
    cout << rt << endl;
}

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

using namespace std;

const int N=1e6+3;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9;

int n,m,a[N],k,q,u,v,x,y,tc,c,l,r,ans,pre[N],suf[N];

char s[N];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),pre[i]=__gcd(pre[i-1],a[i]);
	for(int i=n;i>=1;i--)
		suf[i]=__gcd(suf[i+1],a[i]);
	for(int i=1;i<=n;i++)
		ans=max(__gcd(pre[i-1],suf[i+1]),ans);
	printf("%d\n",ans);
}
	



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

typedef long long ll;

int main()
{
	ll x;
	cin >> x;

	ll a = 100;

	for (int i = 0;; i++) {
		if (a >= x) {
			cout << i << endl;
			break;
		}
		a *= 1.01;
	}

	return 0;
}

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

int main(){
	long long n;
	cin >> n;
	long long ans = 1;
	vector<long long> a(n);
	for(long long i = 0; i < n; i++)cin >> a[i];
	sort(a.begin(),a.end());
	if(a[0] == 0){
		cout << 0 << endl;
		return 0;
	}
	for(long long i = 0;i < n;i++){
		if(a[i] > (long long)1e18 / ans){
			cout << -1 << endl;
			return 0;
		}else {
			ans *= a[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3976
#include<stdio.h>

int main(void){

int W,H,x,y,r;

   scanf("%d",&W);

 scanf("%d",&H);

  scanf("%d",&x);

  scanf("%d",&y);

  scanf("%d",&r);

     if(W>=x+r && H>=y+r && 0<=x-r && 0<=y-r){

  printf("Yes\n");

  }

  else{

   printf("No\n");

  }

  return 0;

 }

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define ll  long long int
int main() {
    ll n,m,c;
    cin>>n>>m>>c;
    ll b[m],a,count=0,pro;
    for(ll i=0;i<m;i++)
    {
        cin>>b[i];
    }
    for(ll i=0;i<n;i++)
    {
        pro=0;
        for(ll j=0;j<m;j++)
        {
            cin>>a;
            pro+=a*b[j];
        }
        if(pro+c>0)
        {
            count++;
        }
    }
    cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b){return (b==0?a:gcd(b,a%b));}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

int main(){
  ll N, M;
  cin >> N >> M;
  string S, T;
  cin >> S;
  cin >> T;

  if(N < M){
    swap(N, M);
    swap(S, T);
  }
  
  if(S[0] != T[0]){
    cout << -1 << endl;
    return 0;
  }
  
  ll L = lcm(N, M);

  rep(i,M){
    ll p = L/M*i;
    if(p%(L/N) != 0) continue;
    ll q = p/(L/N);

    if(S[q] != T[i]){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << L << endl;
  
  return 0;
}

Measured memory_bytes: 512
package main

import (
  "fmt"
)
type INT int
func main() {
  var a,b,c string
  fmt.Scan(&a, &b, &c)
  var tmp byte = a[0]
  a = a[1:]
  for {
    switch string(tmp) {
      case "a":
      if len(a) == 0 {
        fmt.Println("A")
        return
      }
      tmp = a[0]
      a = a[1:]
      case "b":
      if len(b) == 0 {
        fmt.Println("B")
        return
      }
      tmp = b[0]
      b = b[1:]
      case "c":
      if len(c) == 0 {
        fmt.Println("C")
        return
      }
      tmp = c[0]
      c = c[1:]
    }
  }
}

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

typedef struct Node {
    long key;
    struct Node *prev, *next;
} Node;

Node *nil;

void init() {
    nil = (Node *)malloc(sizeof(Node));
    nil->prev = nil;
    nil->next = nil;
}

void insert(long key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

Node* linearSearch(long key) {
    Node *p;
    for (p = nil->next; p != nil; p = p->next)
        if (p->key == key) return p;
    return nil;
}

void deleteNode(Node *p) {
    if (p == nil) return;
    p->prev->next = p->next;
    p->next->prev = p->prev;
    free(p);
}

void deleteKey(long key) {
    deleteNode(linearSearch(key));
}


void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void printList() {
    Node *p;
    int i = 0;
    for (p = nil->next; p != nil; p = p->next) {
        if (i++) printf(" ");
        printf("%ld", p->key);
    }
    printf("\n");
}



int main() {

    int n;
    long key;
    char s[12];
    init();
    scanf("%d", &n);
    for (int i = 0 ; i < n; i++) {
        scanf("%s%ld", s, &key);
        if (s[0] == 'i') insert(key);
        else if (strlen(s) > 6) {
            if (s[6] == 'F') deleteFirst();
            else if (s[6] == 'L') deleteLast();
        }
        else deleteKey(key);
    }
    printList();

    return 0;
}


Measured memory_bytes: 32964
#include<stdio.h>
char m[4][4];
int main(){
	int i,j,n;
	char c;
	for(;scanf("%s",m[0]);){
		n=0;
		if(m[0][0]=='0')break;
		for(i=1;i<3;i++)scanf("%s",m[i]);
		if(m[0][0]!='+'&&m[0][0]==m[0][1]&&m[0][1]==m[0][2]){printf("%c\n",m[0][2]);n=1;}
		else if(m[1][0]!='+'&&m[1][0]==m[1][1]&&m[1][1]==m[1][2]){printf("%c\n",m[1][2]);n=1;}
		else if(m[2][0]!='+'&&m[2][0]==m[2][1]&&m[2][1]==m[2][2]){printf("%c\n",m[2][2]);n=1;}
		else if(m[0][0]!='+'&&m[0][0]==m[1][0]&&m[1][0]==m[2][0]){printf("%c\n",m[2][0]);n=1;}
		else if(m[0][1]!='+'&&m[0][1]==m[1][1]&&m[1][1]==m[2][1]){printf("%c\n",m[2][1]);n=1;}
		else if(m[0][2]!='+'&&m[0][2]==m[1][2]&&m[1][2]==m[2][2]){printf("%c\n",m[2][2]);n=1;}
		else if(m[1][1]!='+'&&m[0][0]==m[1][1]&&m[1][1]==m[2][2]){printf("%c\n",m[1][1]);n=1;}
		else if(m[1][1]!='+'&&m[0][2]==m[1][1]&&m[1][1]==m[2][0]){printf("%c\n",m[1][1]);n=1;}
		if(n==0)printf("NA\n");
	}
	return 0;
}

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

using namespace std;
using ll = long long;

vector<int> ok;
vector<vector<int>> to, ot;

void dfs0(int v) {
    ok[v] |= 1;
    for(auto i : to[v]) {
        if(ok[i] & 1)continue;
        ok[i] |= 1;
        dfs0(i);
    }
}

void dfs1(int v) {
    ok[v] |= 2;
    for(auto i : ot[v]) {
        if(ok[i] & 2)continue;
        ok[i] |= 2;
        dfs1(i);
    }
}


const ll INF = 1e18;

int main()
{
    int n, m; cin >> n >> m;
    ok.resize(n), to.resize(n), ot.resize(n);
    vector<tuple<int,int,int>> edge; //辺集合
    for(int i = 0; i < m; i++) {
        int a, b, c; cin >> a >> b >> c; a--, b--; c = -c;
        to[a].push_back(b);
        ot[b].push_back(a);
        edge.emplace_back(a, b, c);
    }
    dfs0(0), dfs1(n - 1);

    {
        vector<ll> dist(n, INF);
        dist[0] = 0;
        bool res = 1; //更新？
        ll step = 0;
        while(res) {

            res = false;
            for(auto i : edge) {
                ll a, b, c; tie(a, b, c) = i;
                if(ok[a] != 3 || ok[b] != 3)continue; //通らない
                //cerr << "step : " << step <<  " a : " << a << " b : " << b << "dist[a] : " << dist[a] << " dist[b] : " << dist[b] << endl;
                if(dist[b] > dist[a] + c) {
                    res = true;
                    dist[b] = dist[a] + c;
                }
            }
            step++;
            if(step > 2 * n) {
                cout << "inf" << endl;
                return 0;
            }
        }
        cout << -dist[n - 1] << endl;
    }

}

Measured memory_bytes: 384