akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long LL;
const int INF = int(1e9);

int main()
{
    int N,M,K;
    cin>>N>>M>>K;
    for(int i = 0;i<=N;i++){
        for(int j = 0;j<=M;j++){
            int temp = i*M+j*N -2*i*j;
            if(temp==K)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }

    cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <queue>
using namespace std;
typedef long long ll;
ll x;
int main() {
	scanf("%lld",&x);
	int i;
	for (i=1;i<=50000;i++)
		if (((i+1)*i)/2>=x)
			break;
	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
As = list(map(int, input().split()))

As.sort()
minA = min(As)
maxA = max(As)

anss = []
x = maxA
x2 = minA
for A in As[1:-1]:
    if A <= 0:
        anss.append((x, A))
        x -= A
    else:
        anss.append((x2, A))
        x2 -= A

anss.append((x, x2))
x -= x2

print(x)
print('\n'.join(map(lambda x: str(x[0])+' '+str(x[1]), anss)))


Measured memory_bytes: 27236
//17D8103015J Kobayashi Ikuko Mingwon23 C++

#include <iostream>
#include <vector>
#include <stack>
#include <string>
#include <cstdlib>
#include <cstdio>

using namespace std;
int main(){
  int i,j,a,b;
  stack <int> s;
  string str;

  while(cin >> str){
    if(str == "+"){
      a=s.top();
      s.pop();
      b=s.top();
      s.pop();
      s.push(a+b);
    }

    else if(str == "-"){
      a=s.top();
      s.pop();
      b=s.top();
      s.pop();
      s.push(b-a);
    }

    else if(str == "*"){
      a=s.top();
      s.pop();
      b=s.top();
      s.pop();
      s.push(a*b);
    }

    else{
      s.push(atoi(str.c_str()));
    }

    if(getchar() == '\n'){
      cout << s.top();
      cout << "\n";
      break;
    }
  }

  return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
static const ll LOGN=55;




int main(void) {
  ll N;
  cin >> N;
  ll x[111], y[111], h[111];
  ll i;
  ll ma=0;
  for(i=0; i<N; i++) {
    cin >> x[i] >> y[i] >> h[i];
    chmax(ma, h[i]);
  }
  
  for(ll cx=0; cx<=100; cx++) {
    for(ll cy=0; cy<=100; cy++) {
      
      for(ll H=ma; H<=ma+200; H++) {
        ll f=1;
        for(i=0; i<N; i++) {
          ll t=max(H-abs(cx-x[i])-abs(cy-y[i]), 0LL);
          if(t!=h[i]) f=0;
        }
        
        if(f) {
          pt(cx<<" "<<cy<<" "<<H);
          return 0;
        }
        
        
        
      }
      
    }
  }
  
  
  
}






Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define N 1000000
int main(){	
	int i, j, n, answer;
	int a[N];
	for(i=0; i<N; ++i) a[i]=0;
	a[2] = 1;
	for(i=3; i<N; i+=2) a[i]=1;							
	for(i=3; i<=N; i+=2){
		if(a[i]==0) continue;
		for(j=i+i; j<N; j+=i) a[j] = 0;				
	}
	while(scanf("%d", &n) != EOF){
		answer = 0;
		for(i=0;i<=n;++i){
			answer+=a[i];
		}
		printf("%d\n", answer);
	}
	return 0;
}

Measured memory_bytes: 4504
# include<iostream>
#include <iomanip>

using namespace std;
int main() {
	double a = 0;
	double pi = 3.14159265358979323846;
	cin >> a;
	cout << fixed;
	cout << setprecision(1000) <<a*a*pi << " " << a * 2 * pi << endl;
	return 0;
}

Measured memory_bytes: 3256
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func main() {
	n, k := nextInt(), nextInt()
	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = nextInt()
	}

	if n <= k {
		fmt.Println(0)
		return
	}
	sort.Sort(sort.Reverse(sort.IntSlice(h)))
	h = h[k:]
	ans := 0
	for _, hp := range h {
		ans += hp
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
long long  A[100005];
long long  B[100005];
long long  C[300005];

bool cmp(long long x,long long y)
{
    if(x!=y)
        return x>y;
    else
      return x<y;
}
int main()
{
    int X,Y,NA,NB,NC;
    long long sum=0;
    int j;
    cin>>X>>Y>>NA>>NB>>NC;
    for(int i=1; i<=NA; i++)
        scanf("%lld",&A[i]);
    for(int i=1; i<=NB; i++)
        scanf("%lld",&B[i]);
    for(j=1; j<=NC; j++)
        scanf("%lld",&C[j]);
    sort(A+1,A+NA+1,cmp);
    sort(B+1,B+NB+1,cmp);
    for(int i=1; i<=X; i++)
    {
        C[j++]=A[i];
    }
    for(int i=1; i<=Y; i++)
    {
        C[j++]=B[i];
    }
    sort(C+1,C+j+1,cmp);
    for(int i=1; i<=X+Y; i++)
    {
        sum+=C[i];
    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 3968
#include <stdio.h>
#include <stdlib.h>

int main() {
  int n = 0, m = 0;
  scanf("%d %d\n", &n, &m);
  int *count = (int *)malloc(sizeof(int) * m);
  for (int i=0; i<m; i++) {
    count[i] = 0;
  }
  for (int i=0; i<n; i++) {
    int num = 0;
    scanf("%d", &num);
    for (int j=0; j<num; j++) {
      int buf = 0;
      scanf("%d", &buf);
      count[buf-1]++;
    }
  }
  int out = 0;
  for (int i=0; i<m; i++) {
    if (count[i] == n) {
      out++;
    }
  }
  printf("%d\n", out);
  return 0;
}
    

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<vector>
#define N 400005
using namespace std;
vector<int> G[N];
int n,m=1,a[N],b[N],head[N],nxt[N],num[N],op[N],vis[N],dex[N],X[N],rt;
void link(int x,int y,int z)
{
	num[++m]=y,dex[m]=z,nxt[m]=head[x],head[x]=m;
	num[++m]=x,dex[m]=z,nxt[m]=head[y],head[y]=m;
}
void dfs(int t)
{
	int i;
	while(head[t]){
		i=head[t];
		head[t]=nxt[i];
		if(vis[i]) continue;
		vis[i]=vis[i^1]=1;
		dfs(num[i]);
		if(~dex[i]&1)
			X[dex[i]/2]=(i&1 ? 1 : -1);
	  }
}
void DFS(int t)
{
	int i;
	for(i=0;i<G[t].size();i++)
		X[t]-=X[G[t][i]],DFS(G[t][i]);
}
int main()
{
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d",&a[i]);
	for(i=1;i<=n;i++) scanf("%d",&b[i]);
	for(i=1;i<=n;i++){
		if(a[i]!=-1) G[a[i]].push_back(i); else rt=i;
		link(i,(a[i]==-1 ? n+1 : a[i]),2*i);
		link((b[i]==-1 ? n+1 : b[i]),i,2*i+1);
		if(a[i]>0) op[a[i]]^=1;
		if(b[i]>0) op[b[i]]^=1;
	  }
	for(i=1;i<=n;i++)
		if(op[i]){
			printf("IMPOSSIBLE");
			return 0;
		  }
 	dfs(n+1);
	DFS(rt);
	printf("POSSIBLE\n");
	for(i=1;i<=n;i++)
		printf("%d ",X[i]);
	return 0;
}


Measured memory_bytes: 30464
import math

def simple_prime_factrize(x):
    pfs = []
    s = math.sqrt(x)
    for y in range(2, math.ceil(s)):
        if x == 1: break
        while True:
            if x%y == 0:
                pfs.append(y)
                x = x/y
            else:
                break
    if len(pfs) == 0:
        pfs.append(x)
    elif x > s:
        pfs.append(int(x))
    return pfs
    
n = int(input())
print(str(n) + ': ' + ' '.join([str(x) for x in simple_prime_factrize(n)]))


Measured memory_bytes: 5672
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<queue>
#include<algorithm>
#define ll long long
#define re register
using namespace std;
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
int l[110],ans,n;
int main(){
	n=gi();n*=2;
	for(re int i=1;i<=n;i++)l[i]=gi();
	sort(l+1,l+n+1);
	for(re int i=1;i<=n;i+=2)ans+=l[i];
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int S,h,m,s;
	scanf("%d",&S);
	h = S / 3600;
	m = (S % 3600) / 60;
	s = S % 60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
#include<iostream>

int main(){
  long long int n,ans=1;
  std::cin >> n;
  if(n==0){
    std::cout << 1 <<std::endl;
    return 0;
  }
  while(n>0){
    ans *= n;
    --n;
  }
  std::cout << ans << std::endl;
}

Measured memory_bytes: 2948
#coding: utf-8
#coding: utf-8
N, M = map(int, input().split())
H = list(map(int, input().split()))
d = {i:H[i-1] for i in range(1, N+1)}
F = [True for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    if d[a] <= H[b-1]:
        F[a-1] = False
    if d[b] <= H[a-1]:
        F[b-1] = False
print(sum(F))

Measured memory_bytes: 24520
w=sorted(list(input()))
s="No"
for i in range(len(w)//2):
    if w[2*i]!=w[2*i+1]:
        break
    if i==len(w)//2-1:
        s="Yes"

print(s)

#breakしてない時はelse文実行使えそうだけど無理やったわ


Measured memory_bytes: 2940
Public Class Compiler
  Shared Sub Main()
        Dim n As Integer = Integer.Parse(Console.ReadLine())
        Dim arrayA() As Integer = Array.ConvertAll(Of String, Integer)(Console.ReadLine().Split(" "), AddressOf Integer.Parse)
        Dim s As Integer = 0
        For i As Integer = 0 To n - 1
            s += arrayA(i)
        Next
        Dim output(0 To n - 1) As Integer
        Dim a As Integer = 0
        For i As Integer = 2 To n - 1 Step 2
            a += arrayA(i - 1)
        Next
        output(0) = s - 2 * a
        For i As Integer = 1 To n - 1
            output(i) = 2 * arrayA(i - 1) - output(i - 1)
        Next
        Console.WriteLine(String.Join(" ", Array.ConvertAll(Of Integer, String)(output, AddressOf OutputToString)))
  End Sub
  
  Shared Function OutputToString(o As Integer) As String
      Return o.ToString()
  End Function
End Class

Measured memory_bytes: 38480
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

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

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const ll MOD = 1000000007;
const int MSIZE = 100007;
const double Pi = 3.14159265358979323146;

int main(){
  int n;  cin >> n;
  vector<string> domino(2);
  REP(i, 2){
    cin >> domino[i];
  }
  bool isVertical=(domino[0][0]==domino[1][0]);
  ll ans = (isVertical?3:6);
  int cur=(isVertical?1:2);
  while(cur<n){
    if(domino[0][cur]==domino[1][cur]){
      if(isVertical){
        ans *= 2;
        ans %= MOD;
      }
      isVertical=true;
      cur++;
    }
    else{
      if(isVertical){
        ans *= 2;
        ans %= MOD;
      }else{
        ans *= 3;
        ans %= MOD;
      }
      isVertical=false;
      cur+=2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();//1円玉の数
    if(n % 500 > a){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }
  }
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<int, ll> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
// const ll MAXN = 

string s;
bool fs;
/********** Good Luck :) **********/
int main()
{
    TIME(main);
    IOS();

    cin >> s;
    int len = 0;
    for (auto c : s) {
        if (!fs && c == s.front()) {
            fs ^= 1;
        } else if (fs && c == s.back()) {
            fs ^= 1;
        } else {
            len++;
        }
    }

    debug(len);

    if (s.front() == s.back()) {
        int cnt = 0;
        for (auto c : s) {
            cnt += c == s.front();
        }

        cout << ((len-cnt) & 1 ? "Second" : "First") << endl;
    } else {
        cout << (len & 1 ? "First" : "Second") << endl;
    }
    return 0;
}


Measured memory_bytes: 512
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
A = list(map(int, input().split()))

cur = 1000
left = 0
right = 1
while left < N:
    while right < N and A[right] > A[right - 1]:
        right += 1
    if right - left > 1:
        stocks = cur // A[left]
        cur = cur % A[left]
        cur += A[right - 1] * stocks
    left = right
    right = left + 1
print(cur)

Measured memory_bytes: 9372
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)

A = np.sort(A)
zero = A[A == 0]
pos = A[A > 0]
neg = A[A < 0]


def test(x):
    cnt = 0

    if x >= 0:
        cnt += len(zero) * N

    cnt += np.searchsorted(A, x // pos, side='right').sum()
    cnt += (N - np.searchsorted(A, (-x - 1) // -neg, side='right')).sum()
    cnt -= np.count_nonzero(A * A <= x)

    cnt //= 2

    return K <= cnt


l = -(10 ** 19)  # NG
r = 10 ** 19  # OK

while l + 1 != r:
    mid = (l + r) // 2

    if test(mid):
        r = mid
    else:
        l = mid

print(r)


Measured memory_bytes: 34556
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N, M = MI()
    S, C = [], []
    for i in range(M):
        s, c = MI()
        S.append(s - 1)
        C.append(c)

    ans = [-1] * N

    for i in range(M):
        if ans[S[i]] != -1 and ans[S[i]] != C[i]:
            print(-1)
            exit()

        ans[S[i]] = C[i]

    if ans[0] == 0:
        if N != 1:
            print(-1)
            exit()
        else:
            print(0)
            exit()

    if N == 1 and ans[0] == -1:
        print(0)
        exit()

    for i in range(N):
        if ans[i] == -1:
            ans[i] = 0 if i != 0 else 1
        ans[i] = str(ans[i])

    print("".join(ans))


main()


Measured memory_bytes: 65040
n=int(input())
al=list('MARCH')
d=[0]*5
for i in range(n):
    s=list(input())
    if s[0] in al:
        d[al.index(s[0])]+=1
op=['0','1']
for i in range(4):
    tmp=[]
    for j in op:
        tmp.append(j+'0')
        tmp.append(j+'1')
    op=tmp
k=[]
for i in op:
    g=list(i)
    c=0
    for j in g:
        if j=='1':
            c+=1
    if c==3:
        k.append(i)
ans=0
for i in k:
    t=1
    for j in range(5):
        if i[j]=='1':
            t*=d[j]
    ans+=t
print(ans)
            


Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[][] d = new int[n][2];
			IntStream.range(0, n).forEach(i -> {
				d[i][0] = scanner.nextInt();
				d[i][1] = scanner.nextInt();
			});
			for (int i = 0; i < n - 2; i++) {
				if ((d[i][0] == d[i][1]) && (d[i + 1][0] == d[i + 1][1]) && (d[i + 2][0] == d[i + 2][1])) {
					System.out.println("Yes");
					return;
				}
			}
			System.out.println("No");
		}
	}
}


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

using namespace std;

map <int64_t, int64_t> m1;
int64_t res = 0;




int main(){
    int n, m;
    cin >> n >> m;
    if(n >= 10) cout << m << endl;
    else{
        cout << m+100*(10-n) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
  
int main(void){
    int x,y,z;
    while(1){
        scanf("%d %d %d",&x,&y,&z);
        if(x==-1&&y==-1&&z==-1){
            break;
        }
        if(x==-1||y==-1){
            printf("F\n");
            continue;
        }
        if(x+y>=80){
            printf("A\n");
        }
        if(x+y>=65&&x+y<80){
            printf("B\n");
        }
        if(x+y>=50&&x+y<65){
            printf("C\n");
        }
        if(x+y>=30&&x+y<50){
            if(z>=50){
                printf("C\n");
            }
            else{
                printf("D\n");
            }
        }
        if(x+y<30){
            printf("F\n");
        }
    }
    return 0;
}


  

 



Measured memory_bytes: 2048
#include <bits/stdc++.h>
  
using namespace std;
  
#define MAX_N 25
#define INF (1<<29)
  
struct Edge{
    int to,cost;
    Edge(int to,int cost) : to(to),cost(cost) {}
};
  
int V,maxi,start,sum;
int dist[MAX_N];
bool leaf[MAX_N],visited[MAX_N];
vector<Edge> G[MAX_N];
  
void getStart(int v,int d){
    for(int i = 0 ; i < (int)G[v].size() ; i++){
	Edge e = G[v][i];
	if(!leaf[e.to] && dist[e.to] == INF){
	    dist[e.to] = d + e.cost;
	    sum += e.cost*2;
	    getStart(e.to,d+e.cost);
	}
    }
}
 
int getTreeDiameter(int v){
    int res = 0;
    for(int i = 0 ; i < (int)G[v].size() ; i++){
	Edge e = G[v][i];
	if(!visited[e.to]){
	    visited[e.to] = true;
	    if(!leaf[e.to]){
		res = max(res,e.cost+getTreeDiameter(e.to));
	    }
	}
    }
    return res;
}
  
int main(){
    int N,a,b,c;
    while(cin >> N,N){
	for(int i = 0 ; i < N ; i++){
	    G[i].clear();
	    visited[i] = leaf[i] = false;
	}
	for(int i = 0 ; i < N-1 ; i++){
	    cin >> a >> b >> c; a--; b--;
	    G[a].push_back(Edge(b,c));
	    G[b].push_back(Edge(a,c));
	}
	for(int i = 1 ; i < N ; i++){
	    leaf[i] = (G[i].size() == 1);
	}
	sum = maxi = start = 0;
	fill(dist,dist+N,INF);
	dist[0] = 0; getStart(0,0);
	visited[start] = true;
	cout << sum-getTreeDiameter(start) << endl;
    }
    return 0;
}

Measured memory_bytes: 3112
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++) {
		if(s[i] == '7') {
			cout << "Yes";
			exit(0);
		}
	}

	cout << "No";

	return 0;
}


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

int main()
{
	unsigned a,b;
	while(cin>>a>>b)
	{
		int n = a+b;
		int i=0;
		for(; 0<n; ++i)
		{
			n/=10;
		}
		cout << i << '\n';
	}
}

Measured memory_bytes: 1156
main = do
  [_, _, x, y] <- map read . words <$> getLine  :: IO [Int]
  xs <- map  read . words <$> getLine :: IO [Int]
  ys <- map  read . words <$> getLine :: IO [Int] 
  putStrLn $ if not $ null [z | z<-[(x+1)..y], (all (<z) xs) && (all (>=z) ys)] then "No War" else "War"

Measured memory_bytes: 1020
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000001
using namespace std;
typedef long long ll;

int calc_num(vector<int> v, int i, int n){

  int ret_val = 0;
  vector<int> w,e;
  rep(j,0,i){
    w[j] = v[j];
  }

  rep(j,0,n){
    if(j==i){
    }else if(j > i){
      if(v[j]==1)ret_val++;
    }else if(j < i){
      if(v[j]==0)ret_val++;
    }
  }
  return ret_val;
}

int main(){
  int n; cin>>n;
  string s; cin >> s;
  std::vector<int> left(n,0), right(n,0);
  if(s[0]=='W')left[0]=1;
  if(s[n-1]=='E')right[n-1]=1;
  rep(i,1,n){
    left[i] += left[i-1];
    if(s[i] == 'W') left[i]++;
    right[n-1-i] += right[n-i];
    if(s[n-1-i]=='E')right[n-1-i]++;
  }
  int ans = MAX;
  rep(i,0,n){
    // std::cout << left[i]<<' '<<right[i] << '\n';
    if(i==0)ans = min(ans, right[1]);
    else if (i==n-1) ans=min(ans, left[n-2]);
    else ans = min(ans, left[i-1]+right[i+1]);
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 2948
#include<stdio.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>
#include<memory.h> 
#include<sstream>
#include<time.h>
using namespace std;
const long long BIGER=1000000000000000;
const int BIG=1000000000;
long long a[101];
long long g=1;
string st;
long long s=0;
long long ypa(long long k)
{
	if(k==st.size())
	{
		for(long long i=1;i<=g;i++)
		{
			cerr<<a[i]<<" ";
			s+=a[i];
		}
		cerr<<endl;
	}
	else
	{
		a[g]=a[g]*10+st[k]-'0';
		ypa(k+1);
		a[g]=(a[g]-st[k]+'0')/10;
		g++;
		a[g]=a[g]*10+st[k]-'0';
		ypa(k+1);
		a[g]=(a[g]-st[k]+'0')/10;
		g--;
	}
	return 19260817;
}
int main()
{
	cin>>st;
	a[1]=st[0]-'0';
	ypa(1);
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = k; i < n; i++) {
			if (a[i - k] < a[i]) {
				pw.println("Yes");
			} else {
				pw.println("No");
			}
		}
		pw.flush();
	}
}


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

const int maxn = 1e5+100;

typedef long long LL;
LL X[maxn];

int q;
int n;
LL len;

const int STEP = 200;

int reach[maxn][STEP+5];

int cal(int L,int R)
{
    int cur = L;
    int res = 0;
    while(cur < R)
    {
        if(reach[cur][STEP] < R)
        {
            res += STEP;
            cur = reach[cur][STEP];
        }
        else
        {
            int id = lower_bound(reach[cur]+1,reach[cur]+STEP+1,R)-reach[cur];
            res += id;
            cur = reach[cur][id];
        }

    }
    return res;
}

int main()
{
   // freopen("./test.txt","r",stdin);
    scanf("%d",&n);
    for(int i = 1;i <= n;++i)
        scanf("%lld",&X[i]);
    scanf("%lld",&len);
    int cur = 1;
    LL now = 0;
    while(cur+1 <= n && now + X[cur+1]-X[cur] <= len)
    {
        now += X[cur+1]-X[cur];
        cur++;
    }
    reach[1][1] = cur;
    for(int i = 2;i <= n;++i)
    {
        now -= X[i]-X[i-1];
        while(cur+1 <= n && now + X[cur+1]-X[cur] <= len)
        {
            now += X[cur+1]-X[cur];
            cur++;
        }
        reach[i][1] = cur;
      //  printf("*** %d  %d\n",i,reach[i]);
    }



    for(int j = 2;j <= STEP;++j)
    {
        for(int i = 1;i <= n;++i)
            reach[i][j] = reach[reach[i][1]][j-1];
    }

    scanf("%d",&q);
    while(q--)
    {
        int L,R;
        scanf("%d %d",&L,&R);
        if(L > R) swap(L,R);
        int res = cal(L,R);
        printf("%d\n",res);
    }

    return 0;
}


Measured memory_bytes: 81664
#include<stdio.h>

int main(void){

  int n, m, x;
  int a[100]={0};
  int i;
  int cnt1=0, cnt2=0;

  scanf("%d %d %d", &n, &m, &x);
  for(i=0; i<m; i++){
    scanf("%d", a+i);
  }

  for(i=0; i<m; i++){
    if(a[i]<x)
      cnt1++;
    else
      cnt2++;
  }

  if(cnt1>=cnt2){
    printf("%d\n", cnt2);
  }else{
    printf("%d\n", cnt1);
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>

using namespace std;
const int maxn = 3010;
const int mod = 1000000007;

int n;
char niz[maxn];
int dp[maxn];
int sum[maxn];

int main() {
    scanf("%d%s", &n, niz);
    for (int i = 1; i <= n; i++) sum[i] = i;
    for (int i = 0; i < n - 1; i++) {
        memset(dp, 0, sizeof dp);
        for (int j = 1; j < n - i; j++) {
            if (niz[i] == '<') dp[j] = sum[j];
            else dp[j] = sum[n] - sum[j] + mod, dp[j] %= mod;
        }
        //memset(sum, 0, sizeof sum);
        for (int j = 1; j <= n; j++) sum[j] = sum[j - 1] + dp[j], sum[j] %= mod;
    }
    printf("%d\n", sum[n]);
    //system("pause");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	int n,i,j,k,s,t,u;
	int carry = 0;
	string a, b,d;
	vector<int> c;
	cin >> n;
	for (i = 0; i < n; i++) {
		c.clear();
		cin >> a;
		cin >> b;
		while (a.size() > b.size()) {
			b = "0" + b;
		}
		while (b.size() > a.size()) {
			a = "0" + a;
		}
		s = a.size();
		for (j = s-1; j >=0; j--) {
			t = a[j]-'0' + b[j]-'0';
			if (carry == 1) {
				carry = 0;
				t += 1;
			}
			while (t >= 10) {
				t -= 10;
				carry += 1;
			}
			c.push_back(t);
		}
		while (carry == 1) {
			carry = 0;
			c.push_back(1);
		}
		u = c.size();
		if (u > 80||a.size()>80||b.size()>80) {
			cout << "overflow" << endl;
		}
		else if(u<=80){
			for (k = u - 1; k >= 0; k--) {
				cout << c[k];
			}
			cout << endl;
		}
	}
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  string s;
  cin>>s;
  ll ans=1;
  int before=0;
  rep(i,n) {
    if (i==n-1||s[i]!=s[i+1]) {
      if (before==0) {
	ans*=3;
      }
      else if (before==1) {
	ans*=2;
      }
      before=1;
      ans%=mod;
    }
    else {
      if (before==0) {
	ans*=6;
      }
      else if (before==1) {
	ans*=2;
      }
      else {
	ans*=3;
      }
      before=2;
      ans%=mod;
      i++;
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		 //sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    string A;
    cin>>A;
    int N = A.size();
    ll ans = 1;
    map<char, ll> map;
    for(int i = 0; i < N; ++i){
        map[A[i]]++;
    }
    for (int i = 0; i < 26; i++)
    {
        for (int j = i+1; j < 26; j++)
        {
            ans += map[char('a'+i)] * map[char('a'+j)];
        }
        
    }    
    cout<<ans<<endl;
}

Measured memory_bytes: 768
from collections import deque
import sys

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), int(input_raw[1])]
    score=[]
    for i in range(N):
        input_raw = read_func().strip().split()
        [x, y, z] = [long(input_raw[0]), long(input_raw[1]), long(input_raw[2])]
        score.append((x,y,z))
    sc_max = 0L
    for i in range(8):
        sc = []
        for j in range(N):
            x = score[j][0]
            y = score[j][1]
            z = score[j][2]
            sc.append(((-1)** ((i & 4)>>2)) * x + ((-1)** ((i & 2)>>1)) * y + ((-1)** ((i & 1))) * z)
        sc.sort(reverse = True)
        sum_sc = sum(sc[0:M])
        if sum_sc > sc_max:
            sc_max = sum_sc

    print sc_max

##    max_xyz = (0, 0, 0)
##    done_idx = set([])
##    for i in range(M):
##        max_idx = 0
##        max_score = 0
##        new_max_xyz = (0, 0, 0)
##        for j in range(N):
##            if j not in done_idx:
##                s = abs(max_xyz[0] + score[j][0]) + abs(max_xyz[1] + score[j][1]) + abs(max_xyz[2] + score[j][2])
##                if max_score < s:
##                    max_idx = j
##                    max_score = s
##                    new_max_xyz =(max_xyz[0] + score[j][0],max_xyz[1] + score[j][1],max_xyz[2] + score[j][2])
##        max_xyz = new_max_xyz
##        done_idx.add(max_idx)
        



if __name__ == '__main__':
    main()


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int indexOf(const string& s, char c) {
  REP(i, s.size()) if (s[i] == c) return i;
  return s.size();
}


int f(ll n, ll p) {
  int res = 0;
  while (n % p == 0) {
    res++;
    n /= p;
  }
  return res;
}


const int MAX_K = 70;
ll table[MAX_K][MAX_K];
ll acc[MAX_K + 1][MAX_K + 1];


int get(int x, int y) {
  return acc[MAX_K][MAX_K] - acc[x][MAX_K] - acc[MAX_K][y] + acc[x][y];
}

int main2() {

  CLR(table, 0);
  CLR(acc, 0);

  int N = nextLong();
  vector< pair<int,int> > B(N);


  REP(i, N) {
    string line; cin >> line;
    if (count(ALL(line), '.') == 0) line += ".0000";
    while (indexOf(line, '.') > (int)line.size() - 10) line += "0";

    ll n = 0;
    REP(i, line.size()) {
      if (line[i] == '.') continue;
      n = n * 10 + (line[i] - '0');
    }
    int c2 = f(n, 2);
    int c5 = f(n, 5);

    B[i] = {c2, c5};

    table[c2][c5]++;
  }

  REP(i, MAX_K) REP(j, MAX_K) {
    acc[i+1][j+1] = acc[i][j+1] + acc[i+1][j] - acc[i][j] + table[i][j];
  }

  // REP(i, MAX_K+1) {
  //   REP(j, MAX_K+1) {
  //     cout << acc[i][j] << " ";
  //   }
  //   cout << endl;
  // }

  ll ans = 0;
  REP(i, N) {
    int c2 = B[i].first;
    int c5 = B[i].second;
    int x = max(0, 18 - c2);
    int y = max(0, 18 - c5);
    ans += get(x, y);
  }

  // cout << "ans_t1=" << ans << endl;

  REP(i, N) {
    if (min(B[i].first * 2, B[i].second * 2) >= 18) ans--;
  }
  // cout << "ans_t2=" << ans << endl;


  ans /= 2;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 4844
#include <iostream>
using namespace std;
 
uint64_t ans(uint64_t x)
{
    if(x==1){
        return 1;
    } else if(x%2 == 1){
        return 1 + 2*ans((x-1)/2);
    } else {
        return 1 + 2*ans(x/2);
    }
}
 
int main()
{
    uint64_t h;
    cin >> h;
    cout << ans(h) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;


int main()
{
    int N;
    std::cin >> N;
    std::vector<int> us(N);
    std::vector<int> vs(N);
    std::vector<int> reverse(N);
    std::vector<int> is_white(N, -1);
    for (int i = 0; i < N - 1; i++) {
        bint w;
        std::cin >> us.at(i) >> vs.at(i) >> w;
        if (w % 2 == 0) {
            reverse.at(i) = false;
        } else {
            reverse.at(i) = true;
        }
    }
    is_white.at(us.at(0) - 1) = 0;
    if (reverse.at(0)) {
        is_white.at(vs.at(0) - 1) = 1;
    } else {
        is_white.at(vs.at(0) - 1) = 0;
    }

    std::vector<int> indexes{};
    for (int i = 1; i < N - 1; i++) {
        indexes.emplace_back(i);
    }
    while (true) {
        std::vector<int> indexes_new{};
        for (const auto& i : indexes) {
            bool u_decided  = is_white.at(us.at(i) - 1) != -1;
            bool v_decided  = is_white.at(vs.at(i) - 1) != -1;
            if (not u_decided and not v_decided) {
                indexes_new.emplace_back(i);
                continue;
            } else if (not u_decided) {
                if (reverse.at(i)) {
                    is_white.at(us.at(i) - 1) = 1 - is_white.at(vs.at(i) - 1);
                } else {
                    is_white.at(us.at(i) - 1) = is_white.at(vs.at(i) - 1);
                }
            } else if (not v_decided) {
                if (reverse.at(i)) {
                    is_white.at(vs.at(i) - 1) = 1 - is_white.at(us.at(i) - 1);
                } else {
                    is_white.at(vs.at(i) - 1) = is_white.at(us.at(i) - 1);
                }
            }
        }
        indexes = indexes_new;
        bool is_all_decided = true;
        for (const auto& i : is_white) {
            if (i == -1) {
                is_all_decided = false;
                break;
            }
        }
        if (is_all_decided) {
            break;
        }
    }
    for (int i = 0; i < N; i++) {
        std::cout << is_white.at(i) << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3160
def make_list(L, R):
    mod_list = list()

    if R - L <= 2019:
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                mod_list.append((i * j) % 2019)
    else:
        for i in range(L, L + 2020):
            for j in range(i + 1, i + 2021):
                mod_list.append((i * j) % 2019)

    return mod_list


def main():
    L, R = map(int, input().split())

    mod_list = make_list(L, R)

    print(min(mod_list))

    return


if __name__ == "__main__":
    main()


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

int main () {
	int x,n,p[110];
	cin>>x>>n;
	int ans=0, sum=0;
	for(int i=1;i<=n;++i) {
		cin>>p[i];
	}
	for(int i=x;i>=-100;--i) {
		bool f=true;
		for(int j=1;j<=n;++j) {
			if(p[j]==i) {
				f=false;break;
			}
		}
		if(f) {
			ans=i;break;
		}
	}
	for(int i=x;i<=200;++i) {
		bool f=true;
		for(int j=1;j<=n;++j) {
			if(p[j]==i) {
				f=false;break;
			}
		}
		if(f) {
			sum=i;break;
		}
	}
	if(abs(ans-x)<abs(sum-x)||(abs(ans-x)==abs(sum-x)&&ans<sum))cout<<ans;
	else cout<<sum;
	return 0;
}

Measured memory_bytes: 3620
INF = 10 ** 9 + 7
N, K = map(int, input().split())


def create_factorial(n):
    """
    階乗を事前計算した配列を作成します。
    :param n: [0, n]の配列を作成します
    """
    f = list()
    for i in range(n + 1):
        if i in [0, 1]:
            f.append(1)
        else:
            f.append(f[i - 1] * i)
    return f


def combination(n, m, factorial):
    """
    nCmの値を計算します。
    nCm = n! / (m! * (n-m)!) より階乗計算が必要なため、階乗を事前に計算して渡してください。
    """
    if n == m:
        return 1
    else:
        return factorial[n] // factorial[m] // factorial[n - m]


f = create_factorial(2000)

for i in range(1, K + 1):
    print(combination(N - K + 1, i, f) * combination(K - 1, i - 1, f) % INF)

Measured memory_bytes: 5748
import math

n,d=map(int,input().split())
x=[list(map(int,input().split())) for i in range(n)]

cnt = a = b = 0
for i in range(n):
	for j in range(i+1, n):
		for k in range(d):
			a += (x[i][k]-x[j][k])**2
		b = math.sqrt(a)
		a=0
		if b == int(b):
			cnt+=1
print(cnt)

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

int main() {
  int N;
  cin >> N;
  
  vector<int> d(N);
  for (int i=0; i<N; i++) {
    cin >> d.at(i);
  }
  
  int dan = N;
    
  for (int i=1; i<N; i++) {
    for (int j=0; j<i; j++) {
      if (d.at(i) == d.at(j)) {
        dan--;
        break;
      }
    }
  }
      
  cout << dan << endl;    
           
}

Measured memory_bytes: 256
#include <stdio.h>

void ans(int a,int b,int c);

int main(){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    ans(a,b,c);
    return 0;
}

void ans(int a,int b,int c){
    int max = 0;
    if(b<c){
        max = c;
        c = b;
        b = max;
    }
    if(a<b){
        max = b;
        b = a;
        a = max;
    }
    printf("%d", a*10+b+c);
}

Measured memory_bytes: 128
import std.stdio,std.string,std.conv,std.math;

int main()
{
	int n;
	while((n = readln.chomp.to!int) != -1)
	{
		double q = n/2.0;

		while(fabs((q*q*q) - n) >= 0.00001*n)
		{
			q -= ((q*q*q - n) / (3*q*q));
		}
		writefln("%.6f",q);
	}
	return 0;
}

Measured memory_bytes: 1116
x,k,d = map(int, input().split())
x=abs(x)

if x>=k*d:
    print(x-k*d)
    exit()


# x< k*d
ans1=x%d
ans2=abs((x%d)-d)

moved=x//d
nokori=k-moved
if nokori==0:
    print(ans1)
    exit()

if nokori%2==0:
    print(ans1)
else:
    print(ans2)

Measured memory_bytes: 61828
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N+1), B(N);
    for(int i = 0; i < N+1; ++i){
        cin >> A[i];
    }
    for(int i = 0; i < N; ++i){
        cin >> B[i];
        // mp.emplace(B[i], i);
    }
    
    long long ans = 0;
    for(int i = 0; i < N; ++i){
        if(A[i] >= B[i]){
            A[i] -= B[i];
            ans += B[i];
            B[i] = 0;
        }else{
            ans += A[i];
            B[i] -= A[i];
            A[i] = 0;
            if(A[i+1] >= B[i]){
                A[i+1] -= B[i];
                ans += B[i];
                B[i] = 0;
            }else{
                ans += A[i+1];
                B[i] -= A[i+1];
                A[i+1] = 0;
            }
        }
    }
    cout << ans << endl;





    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
bool palindrome(string s){
    bool check = true;
    rep(i,s.size()){
        if(s[i] != s[s.size()-i-1]){
            check = false;
        }
    }
    return check;
}
int main(){
    string s;
    cin >> s;
    bool res = true;
    if(!palindrome(s)) res = false;
    if(!palindrome(s.substr(0,s.size()/2))) res = false;
    cout << (res ? "Yes" : "No") << endl;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const int INF = 1e9;

int main(void){

	int N; cin >> N;
	cout << (N+2-1)/2 << endl;


	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
int D;
int N=17;
ll ans,a,b=1;
int main()
{
    cin>>D;
    if(D%9)
    {
        puts("0");
        return 0;
    }
    D/=9;
    for(int i=1;i<=N;i++)
    {
        ll res=1,temp=D,all=a*10+1,l=b,r=1;
        for(int j=0;j<=i/2;j++)
        {
            ll tmp=temp%(r*10)/r;            
            ll x=10-abs(tmp);
            if(!j)  x--;
            res*=x;
            temp-=all*tmp;
            all-=l+r;
            l/=10;r*=10;
        }
        b*=10;a=a*10+1;
        if(!temp)
        {
            ans+=res;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
using System;

namespace AizuOnline
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inp = Console.ReadLine().Split();
            int w = Int32.Parse(inp[0]);
            int h = Int32.Parse(inp[1]);
            int x = Int32.Parse(inp[2]);
            int y = Int32.Parse(inp[3]);
            int r = Int32.Parse(inp[4]);
            string arranged = "Yes";

            if (x < r || x > w-r)
            {
               arranged = "No";
            }
            if (y < r || y > h-r)
            {
               arranged = "No";
            }
            Console.WriteLine(arranged);
        }
    }
}


Measured memory_bytes: 8992
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
int n;
int main(void){
	cin>>n;
	if(n/100==7||n/10%10==7||n%10==7)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3620
/*  
    Come feed the rain
	Cos I'm thirsty for your love
	Dancing underneath the skies of lust
	Yeah feed the rain...
	Cos without your love my life
	Ain't nothing but this carnival of rust
    _________________________
    _________________________
    840 Hours of Solitude
    Quarantine_Day : 35
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef pair<int, int>      pii;
typedef pair<ll, ll>		pll;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<int>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 50005
#define MOD 1000000007

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string a, b; cin>>a>>b;
	
	if(a.size() == b.size()){
		REP(i, (int)a.size()){
			if(a[i] == b[i]) continue;
			if(a[i] > b[i]){
				cout<<"GREATER\n";
				return 0;
			}
			else {
				cout<<"LESS\n";
				return 0;
			}
		}
		cout<<"EQUAL\n";
		return 0;
	}
	else cout<<(a.size() > b.size()?"GREATER\n":"LESS\n");

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

if sum(a) < sum(b):
    print(-1)
    exit()

d = [0] * n

m = []
p = []
for i in range(n):
    d[i] = a[i] - b[i]
    if d[i] > 0:
        p.append(d[i])
    if d[i] < 0:
        m.append(d[i])

if sorted(d)[0] >= 0:
    print(0)
    exit()

p.sort(reverse=True)
m.sort()

for i in range(1, len(p)):
    p[i] += p[i - 1]

sum_m = sum(m)

for i in range(len(p)):
    if p[i] >= abs(sum_m):
        print(len(m) + i + 1)
        exit()

Measured memory_bytes: 85808
#include<bits/stdc++.h>
    /* Dear Judge :i Tried Hard for Solving this problem
      please accept My solution I will remain grateful for that */
#define ON(x, k)    ((x)|(1<<(k)))
#define isOn(x, k)    ((x)&(1<<(k)))
//#define isOn(x, k)    ((x>>k)&1)
#define OFF(x, k)   ((x)&(~(1<<(k))))
#define TOGGLE(x, k)   ((x)^(1<<(k)))

    using namespace std ;
    int const c =1e4+5;
    int A[c];
  int cnt ;
  int sum;
  int sumofdigits(int n ){
    if(n==0)
        return cnt ;
    cnt+=n%10;
    return sumofdigits(n/10);
   }

     int main (){
  int n ;
  cin >> n ;
  if(n%sumofdigits(n)==0)
  cout << "Yes";
  else
    cout << "No";
    return 0;
     }


Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>
 
using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
 
 
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
 
//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n;
	cin>>n;

	if(n%2==0){
		ll sum=0;
		ll x=n;
		while(x>0){
			//cout<<x<<"/"<<5<<"="<<x/5LL<<endl;
			x/=5LL;
			sum+=x/2;
		}
		cout<<sum<<endl;
	}else{
		cout<<0<<endl;
	}

	return 0;
}




Measured memory_bytes: 256