akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int n,A[2000];

  int souatari(int i,int x){
    int next;
    if(x==0)return 1;
    if(i>=n)return 0;
    next = souatari(i+1,x) || souatari(i+1,x-A[i]);
    return next;
}

int main(){
  int q,m,i;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);

  i=0;

  scanf("%d",&q);
  while(i<q){
    scanf("%d",&m);
    if(souatari(0,m)==1)printf("yes\n");
    else printf("no\n");
    i++;
  }
  return 0;
}



Measured memory_bytes: 2108
def resolve():
    n = int(input())
    dict = {"AC":0, "WA": 0, "TLE":0, "RE":0}
    for i in range(n):
        s = input()
        dict[s] += 1
    print("AC x {}".format(dict["AC"]))
    print("WA x {}".format(dict["WA"]))
    print("TLE x {}".format(dict["TLE"]))
    print("RE x {}".format(dict["RE"]))

resolve()

Measured memory_bytes: 8996
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

int main() {
    int X,Y; cin >> X >> Y;

    for(int s = 0; s <= X; s++){
        int t = X - s;
        int foot = 2*s + 4*t;
        if(foot == Y){
             cout << "Yes" << endl;
             return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define lld long long
#define nmax
#define pii pair<int,int>
#define pb push_back
using namespace std;

int main()
{
    string s;
    cin>>s;
    bool foundf = false, foundc = false;
    for (int i=0; i<s.size(); ++i)
    {
        if (s[i] != 'F' && s[i] != 'C')
        {
            continue;
        }
        if (foundc)
        {
            if (s[i] == 'F')
            {
                foundf = true;
                break;
            }
        }
        else
        {
            if (s[i] == 'C')
            {
                foundc = true;
            }
        }
    }
    if (foundf)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
const int maxn=2222;
const ll modn=1e9+7;
const int inf=2e9+7;
const double PI = acos(-1.0);
const double eps=1e-8;
inline int lowbit(int x){return x&-x;}
inline ll lowbit(ll x) {return x&-x;}
inline int CountOneBinary(ll num){int ans=0;while(num){if(num&1) ans+=1;num>>=1;}return ans;}
inline void read(int &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline void read(ll &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline ll qpow(ll x,ll y){ll ans=1;while(y){if(y&1) ans=ans*x%modn;x=x*x%modn;y>>=1;}return ans;}
inline double qpow(double x,ll y){double ans=1;while(y){if(y&1) ans=ans*x;x=x*x;y>>=1;}return ans;}
int main()
{
    int k;
    while(scanf("%d",&k)==1)
    {
        for(int i=111;i<1000;i+=111)
        {
            if(k>i-111&&k<=i)
            {
                printf("%d\n",i);
                break;
            }
        }
    }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
    int a,b;
    cin>>a>>b;
    cout<<(b%a==0?to_string(a+b):to_string(b-a))<<endl;
}
int32_t main(){
  IOS;
  solve();
  //debug();
 #ifdef LOCAL_DEFINE
 cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
 #endif	
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
struct UnionFind{
    vector <int> par;

    UnionFind(int N):par(N){
        for(int i=0;i<N;i++)par[i] = i;
    }
    int root(int x){
        if(par[x] == x)return x;
        return par[x] = root(par[x]);
    }
    void unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry)return;
        par[rx] = ry;
    }
    bool same(int x,int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    int n;cin >> n;
    int m;cin >> m;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    UnionFind tree(n);
    for(int i=0;i<m;i++){
        int x;int y;
        cin >> x >> y;
        x--;y--;
        tree.unite(x,y);
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        if(tree.same(i,p[i]-1)){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    if n == 1:
        return 'Hello World'
    a = I()
    b = I()

    return a + b


print(main())


Measured memory_bytes: 6476
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func searchMin(l int, r int) int {
	min := 2019
	for i := l; i < r; i++ {
		for j := i + 1; j <= r; j++ {
			mod := (i * j) % 2019
			if mod < min {
				min = mod
			}
			if min == 0 {
				return 0
			}
		}
	}
	return min
}

func main() {
	sc.Split(bufio.ScanWords)
	l := nextInt()
	r := nextInt()

	// min := searchMin(l, r)
	// fmt.Println(min)

	if r > l+2019 {
		r = l + 2019
	}
	min := 2019
	for i := l; i < r; i++ {
		for j := i + 1; j <= r; j++ {
			mod := (i * j) % 2019
			if mod < min {
				min = mod
			}
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include <map>
#include <set>
using namespace std;


int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	long long r = 0, g = 0, b = 0;
	for (int i = 0; i < n;i++) {
		if (s[i] == 'R') r++;
		else if (s[i] == 'G') g++;
		else b++;
	}
	long long  ans = r * g * b;
	for (int i = 0; i < n - 2;i++) {
		for (int j = 1; j <= n / 2;j++) {
			if (i + 2 * j < n && s[i] != s[i + j] && s[i] != s[i + 2 * j] && s[i + j] != s[i + 2 * j]) ans--;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3608
#include <cstdio>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

#define x first
#define y second
typedef pair<long long, long long> pLL;
const int N = 2 * 1e5;
vector<pLL> point, p;
int n, sizek;

pLL operator+ (pLL p1, pLL p2) {
    return make_pair(p1.x + p2.x, p1.y + p2.y);
}

pLL operator- (pLL p1, pLL p2) {
    return make_pair(p1.x - p2.x, p1.y - p2.y);
}

inline bool where(pLL p) {
    return !(p.y > 0LL or (p.y == 0LL and p.x > 0LL));
}

inline long long wektor(pLL p1, pLL p2) {
    return p1.x * p2.y - p1.y * p2.x;
}

inline long long dist(pLL p) {
    return p.x * p.x + p.y * p.y;
}

bool angleSort(pLL A, pLL B) {
    bool pA = where(A), pB = where(B);
    if(pA != pB)
        return pB;
    return wektor(A, B) > 0LL;
}

void read() {
    scanf("%d", &n);
    for(int i = 0; i < n; ++i) {
        long long X, Y;
        scanf("%lld%lld", &X, &Y);
        if(X != 0LL or Y != 0LL)
            p.push_back(make_pair(X, Y));
    }
}

void prepare() {
    sort(p.begin(), p.end(), angleSort);

    int it = 0;
    while(it < (int) p.size()) {
        pLL actualVector = p[it];
        while(it + 1 < (int) p.size() and wektor(actualVector, p[it + 1]) == 0) {
            if(dist(actualVector + p[it + 1]) >= dist(actualVector - p[it + 1])) {
                ++it;
                actualVector = actualVector + p[it];
            }
            else
                break;
        }
        point.push_back(actualVector);
        ++it;
    }

    sizek = (int) point.size();
    for(int i = 0; i < sizek; ++i) {
        point.push_back(point[i]);
    }
}

void solve() {
    int start = 0, finish = 0;
    long long result = 0LL;
    pLL startVector, actualVector;
    if(sizek > 0) {
        startVector = actualVector = point[0];
        result = max(result, dist(actualVector));
    }

    while(start < sizek) {
        if(finish < start) {
            finish = start;
            actualVector = point[start];
            result = max(result, dist(actualVector));
        }

        while(finish + 1 < start + sizek and wektor(startVector, point[finish + 1]) > 0LL) {
            ++finish;
            actualVector = actualVector + point[finish];
            result = max(result, dist(actualVector));
        }

        actualVector = actualVector - point[start];
        ++start;
        startVector = point[start];
        result = max(result, dist(actualVector));
    }

    printf("%.16Lf", sqrtl(result));
}

int main()
{
    read();
    prepare();
    solve();

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;



int main() {
	int k;
	cin >> k;
	vector<ll> a;
	for (int i = 1; i <= 9; ++i) a.push_back(i);
	while (true) {
		if (k <= a.size()) {
			cout << a[k - 1] << endl;
			return 0;
		}
		k -= a.size();
		vector<ll> old;
		swap(old, a);
		for (long long x : old) { //oldの初めから終わりまでの数でループ
			for (int i = -1; i <= 1; i++) {
				int d = x % 10 + i;//dは桁
				if (d < 0 || d>9) continue;
				ll nx = x * 10 + d;
				a.push_back(nx);
			}
		}
	}
		return 0;
}

Measured memory_bytes: 1712
// https://atcoder.jp/contests/abc089/tasks/abc089_b
#include <bits/stdc++.h>
using namespace std;

int main(void)
{
  int N;
  cin >> N;
  string judge="Three";

  for (int i = 0; i < N;i++){
    string color;
    cin >> color;
    if (color=="Y")
      judge = "Four";
  }

  cout << judge << endl;
}

Measured memory_bytes: 256
h,w,m=map(int,input().split())
s=[0]*m
t=[0]*m
temp=set()
for i in range(m):
  sm,tm=map(int,input().split())
  s[i]=sm
  t[i]=tm
  temp.add((s[i],t[i]))
st=[0]*h
tt=[0]*w
for i in range(m):
  st[s[i]-1]=st[s[i]-1]+1
  tt[t[i]-1]=tt[t[i]-1]+1
smax=max(st)
tmax=max(tt)
ans=smax+tmax
maxs=[]
maxt=[]
for i in range(h):
  if st[i]==smax:
    maxs.append(i)
for i in range(w):
  if tt[i]==tmax:
    maxt.append(i)

if len(maxs)*len(maxt)>m:
  print(ans)
else:
  for i in range(len(maxs)):
    for j in range(len(maxt)):
      if (maxs[i]+1,maxt[j]+1) not in temp:
        print(ans)
        exit()
  else:
    print(ans-1)

Measured memory_bytes: 88236
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	long long a, b, c, output;

	scanf("%lld", &a);
	scanf("%lld.%lld", &b, &c);


	output = a * (b*100+c);

	output /= 100;

	printf("%lld", output);

	return 0;
}

Measured memory_bytes: 1732
import Foundation


func readStr() -> String {
  return readLine()!
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readTwoInts() -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: " ").map { Int($0)! }
    return (a: ints[0], b: ints[1])
}

print(readStr().map { Int(String($0))! }.reduce(0, +) % 9 == 0 ? "Yes" : "No")


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

int main() {
    string N;
    cin >> N;

    if (N.at(0) == '7' || N.at(1) == '7' || N.at(2) == '7') {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3572
//
// Created by Yoshiki Shino on 2018/07/01.
//

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int N;
    cin >> N;
    vector<ll> A;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        A.push_back(a);
    }


//    ll A_multi = A[0];
//    for (int i = 1; i < N; i++) {
//        A_multi *= A[i];
//    }
//    int f_m_max = 0;
//    for (int i = 0; i < N; ++i) {
//        f_m_max += (A_multi - 1) % A[i];
//    }

        int f_m_max = 0;
        rep(i, N) {
        f_m_max += A[i] - 1;
    }

    cout << f_m_max;
    return 0;
}

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

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

void solve(long long N, long long K, std::vector<long long> h){
    sort(h.begin(), h.end());
    ll ans = INF;
    rep(i, N-K+1){
        ans = min(ans, h[i+K-1]-h[i]);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 1024
using System;

namespace ARC068
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var X = long.Parse(Console.ReadLine());
            var ans = X / 11 * 2;
            if (1 <= X % 11 && X % 11 <= 6) ans += 1;
            else if (7 <= X % 11) ans += 2;
            Console.WriteLine(ans);
        }
    }
}

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


int main(){
  ll A,B,Q;
  cin >> A >> B >> Q;
  vector<ll> s(A),t(B);
  rep(i,A) cin >> s.at(i);
  rep(i,B) cin >> t.at(i);
  rep(i,Q){
    ll x,m=INF;
    cin >> x;
    auto a=lower_bound(all(s),x);
    auto b=t.begin();
    if(a!=s.end()){
      auto b=lower_bound(all(t),*a);
      if(b!=t.end()){
        m=min(m,abs(x-*a)+abs(*b-*a));
      }
      if(b!=t.begin()){
        b--;
        m=min(m,abs(x-*a)+abs(*b-*a));
      }
    }
    if(a!=s.begin()){
      a--;
      b=lower_bound(all(t),*a);
      if(b!=t.end()){
        m=min(m,abs(x-*a)+abs(*b-*a));
      }
      if(b!=t.begin()){
        b--;
        m=min(m,abs(x-*a)+abs(*b-*a));
      }
    }
    a=lower_bound(all(t),x);
    if(a!=t.end()){
      auto b=lower_bound(all(s),*a);
      if(b!=s.end()){
        m=min(m,abs(x-*a)+abs(*b-*a));
      }
      if(b!=s.begin()){
        b--;
        m=min(m,abs(x-*a)+abs(*b-*a));
      }
    }
    if(a!=t.begin()){
      a--;
      b=lower_bound(all(s),*a);
      if(b!=s.end()){
        m=min(m,abs(x-*a)+abs(*b-*a));
      }
      if(b!=s.begin()){
        b--;
        m=min(m,abs(x-*a)+abs(*b-*a));
      }
    }
    cout << m << endl;
  }
    
}


Measured memory_bytes: 4772
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define f first
#define s second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector < vector <pii> > graph;

signed main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   int h, w, n;
   cin >> h >> w >> n;
   int mx = max(h, w);
   cout << (n + mx - 1) / mx << '\n';
   return 0;
}


Measured memory_bytes: 256
def two(x):
    lis=[]
    for i in range(50):
        lis.append(x%2)
        x=x//2
    return lis

n=int(input())
a=list(map(int,input().split()))

tl=[]
for i in range(50):
    tl.append(2**i)

lis=[0 for i in range(50)]

for ai in a:
    twoi=two(ai)
    for j in range(50):
        lis[j]=(lis[j]+twoi[j])%2

ans=[]
for ai in a:
    ansi=0
    twoi=two(ai)
    for j in range(50):
        if twoi[j]!=lis[j]:
            ansi+=tl[j]
    ans.append(ansi)

print(*ans)

Measured memory_bytes: 107820
#include <stdio.h>
int main(void){
    char number[1001];
    int i,j,sum;
    
    while(1){
        sum=0;
        for(i=1; ; i++){
            scanf("%c",&number[i]);
            if(number[i] == '\n') break;
        }
        
        for(j=1; j<i; j++){
            sum += number[j] - '0';
        }
        
        if(sum==0)break;
        printf("%d\n",sum);
    }
    
    return 0;
}

Measured memory_bytes: 536
#include <stdio.h>

int main()
{
  int a, b, ans, err;
  int s, e;

  err = scanf("%d %d", &a, &b);

  a--;
  s = b - a;
  e = b + a;
  for (int c = s; c <= e; c++)
  {
    printf("%d ", c);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb1(x) cout<<#x<<" :: "<<x<<"\n";
#define deb2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define deb3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define lli long long int
#define pii pair<lli,lli>
#define f first
#define sE second
lli dp[100005];
int n,v[105],ww;
lli w[105];
int main(){
	cin>>n>>ww;
	for(int i=1;i<=n;i++) cin>>w[i]>>v[i];
	for(int i=0;i<100005;i++) dp[i] = 1e18;
	dp[0] = 0; 
	for(int i=1;i<=n;i++){
		for(int j=100000;j>=v[i];j--){
			dp[j] = min(dp[j],dp[j-v[i]]+w[i]);
		}
	}
//        for(int i=0;i<=100000;i++)
//            if(dp[i]!=1e18)
//            cout<<dp[i]<<" "<<i<<endl;
	lli ans = 0;
	for(int i=100000;i>=0;i--) if(dp[i] <= ww) ans=max(ans,1LL*i);
cout<<ans<<endl;}

Measured memory_bytes: 1024
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 9000000000000000000 //9e18:極めて大きい値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define LOGMAXR 18 // floor(log2(10^5)) + 1: 配列の最大のrangeのlog
//略記
//#define PB push_back //vectorヘの挿入
//#define MP make_pair //pairのコンストラクタ
//#define F first //pairの一つ目の要素
//#define S second //pairの二つ目の要素

int main(){
  ll N;
  cin >> N;
  ll ret = 0;
  FOR(i, 1, N){
    if(i % 3 == 0) continue;
    if(i % 5 == 0) continue;
    ret += i;
  }
  cout << ret << endl;
  return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct Vertex
{
    vector<pll> node;
};
struct Cost
{
    ll to;
    ll num = 0;
    ll l = 0;
};

ll N, M, L;
Vertex V[305];
pll B[305][305];

int main()
{
    cin >> N >> M >> L;
    REP(i, M)
    {
        ll a, b, c;
        cin >> a >> b >> c;
        if (c > L)
            continue;
        a--;
        b--;
        V[a].node.push_back(pll(b, c));
        V[b].node.push_back(pll(a, c));
    }

    REP(i, N)
    {
        REP(j, N)
        {
            B[i][j] = pll(INF, INF);
        }
    }

    REP(i, N)
    {
        //! iからスタートした時の各町店への最短距離を求める
        priority_queue<Cost, vector<Cost>, function<bool(Cost, Cost)>> q([](Cost a, Cost b) { return a.num == b.num ? a.l < b.l : a.num > b.num; });
        q.push(Cost{i, 0, L});
        B[i][i] = pll(0, L);
        while (!q.empty())
        {
            Cost t = q.top();
            int index = t.to;
            ll num = t.num;
            ll li = t.l;
            q.pop();
            if (B[i][index].first < num)
                continue;
            if (B[i][index].first == num && B[i][index].second > li)
                continue;
            REP(j, V[index].node.size())
            {
                ll n = V[index].node[j].first;
                ll cost = V[index].node[j].second;

                ll nxtN = num;
                ll nxtL = li - cost;
                if (nxtL < 0)
                {
                    nxtL = L - cost;
                    nxtN++;
                }
                if (B[i][n].first < nxtN)
                    continue;
                if (B[i][n].first == nxtN && B[i][n].second >= nxtL)
                    continue;
                B[i][n] = pll(nxtN, nxtL);
                q.push(Cost{n, nxtN, nxtL});
            }
        }
    }

    ll Q;
    cin >> Q;
    REP(i, Q)
    {
        ll s, t;
        cin >> s >> t;

        ll n = B[s - 1][t - 1].first;
        if (n == INF)
            cout << -1 << endl;
        else
            cout << n << endl;
    }
    return 0;
}

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

int main() {
	int m, d, cnt = 0;
	cin >> m >> d;
	for (int i=4; i<=m; i++) {
		for (int j=22; j<=d; j++) {
			if ((j%10)> 1 && (j/10)>1 && (j/10)*(j%10)==i)
				cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

class Node
{
public:
	unsigned long cost;
	unsigned int shortcutRoom;
	bool isEnd;
	vector<int> nextRoom;

	Node()
	{
		cost = 10000000000;
		shortcutRoom = -1;
		isEnd = false;
	}

	void AddNextRoom(int i)
	{
		nextRoom.push_back(i);
	}

	void SetRoom(unsigned long nextCost, unsigned int room)
	{
		if (nextCost < cost)
		{
			cost = nextCost;
			shortcutRoom = room;
		}
	}
};



int main(void)
{
	int n, m;

	cin >> n >> m;

	vector<Node> map;

	map.resize(n + 1);

	for (int i = 0; i < m; ++i)
	{
		int a, b;
		cin >> a >> b;

		map[a].AddNextRoom(b);
		map[b].AddNextRoom(a);
	}

	map[1].cost = 0;

	int nowRoom = 1;
	queue<int> searchRoom;


	for (int i = 1; i <= n; ++i)
	{
		int nowCost = map[nowRoom].cost;
		for (int j = 0; j < map[nowRoom].nextRoom.size(); ++j)
		{
			int nextRoom = map[nowRoom].nextRoom[j];

			map[nextRoom].SetRoom(nowCost + 1, nowRoom);
			searchRoom.push(nextRoom);
		}

		map[nowRoom].isEnd = true;

		while (!searchRoom.empty())
		{
			int nextRoom = searchRoom.front();
			searchRoom.pop();

			if (!map[nextRoom].isEnd)
			{
				nowRoom = nextRoom;
				break;
			}
		}

	}

	bool isRoot = true;
	for (int i = 2; i <= n; ++i)
	{
		if (map[i].shortcutRoom == -1)
		{
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	for (int i = 2; i <= n; ++i)
	{
		cout << map[i].shortcutRoom << endl;
	}



	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000; //
const ll LINF = (ll) 4000000000000000000; //
const ll MOD = (ll) 1000000007; //
const double PI = acos(-1.0); //

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

int main() {
    ll n;
    cin >> n;
    vector<ll> v;

    ll subsum = 0;

    rep(i, n) {
        ll a;
        cin >> a;
        if (a == 0) {
            v.push_back(subsum);
            subsum = 0;
        } else if (i == n - 1) {
            subsum += a;
            v.push_back(subsum);
        } else {
            subsum += a;
        }
    }

    ll ans = 0;
    for (auto sub : v) {
        ans += sub / 2;
    }

    cout << ans << endl;

    return 0;
}


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

int f(int n) {
    int ans = 0;
    while (n) {
        ans += n%10;
        n/=10;
    }
    return ans;
}

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

    int n;
    cin >> n;
    if ( n % f(n) == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Sheryang main
const int maxn=1e6+7;
typedef long long ll;
const int mod=1e9+7;
int read(){int c = getchar(),Nig = 1,x = 0;while(!isdigit(c))c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
#define read read()

int Sheryang()
{
    int a[10];
    for(int i=0;i<4;i++){
        a[i]=read;
    }
    sort(a,a+4);
    if(a[0]==1 && a[1]==4 && a[2]==7 && a[3]==9) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
def main():    
    N = int(input())
    a = list(map(int,input().split()))
    res = 1
    if 0 in a:
        print(0)
        return
    for i in a:
        res *= i
        if res > 10**18:
            print(-1)
            return
    print(res)
if __name__ == "__main__":
    main()

Measured memory_bytes: 21604
#include <bits/stdc++.h> 
using namespace std; 
int main() { 
	int A; 
	cin >> A;
	int B;
	cin >> B;   
	if (A >= 13) { 
		cout << B << endl; 
	} 
	else if (6 <= A) { 
		cout << B / 2 << endl; 
	} 
	else { cout << 0 << endl; 
	} 
} 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <functional>
using namespace std;

int main() {
    int n, count[2] = {};
    cin >> n;
    vector<int> graph[n + 1], path;
    stack<int> nodes[2];
    for (int a, b; cin >> a >> b; ) {
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }
    vector<bool> visited(n + 1);
    function<void(int, int)> dfs = [&](int root, int parent) {
        path.emplace_back(root);
        if (root == n) {
            for (int i = 0, j = 0, k = path.size() - 1; i < path.size(); i++) {
                visited[path[i]] = true;
                if (i % 2 == 0) {
                    nodes[0].emplace(path[j]);
                    j++;
                } else {
                    nodes[1].emplace(path[k]);
                    k--;
                }
            }
            return;
        }
        for (int i : graph[root]) {
            if (i != parent) {
                dfs(i, root);
            }
        }
        path.pop_back();
    };
    dfs(1, -1);
    for (int j : {0, 1}) {
        do {
            count[j]++;
            auto top = nodes[j].top();
            nodes[j].pop();
            for (int i : graph[top]) {
                if (!visited[i]) {
                    visited[i] = true;
                    nodes[j].emplace(i);
                }
            }
        } while (!nodes[j].empty());
    }
    if (count[1] >= count[0]) {
        cout << "Snuke";
    } else {
        cout << "Fennec";
    }
    return 0;
}


Measured memory_bytes: 12792
#include <stdio.h>
#include <math.h> 
int main(void)
{
    int deg;
    double a,b;
    double rad;
    double PI=acos(-1);
    scanf("%lf %lf %d",&a,&b,&deg);
    rad=deg*PI/180;
    printf("%f %f %f\n",a*b*sin(rad)/2,a+b+sqrt(a*a+b*b-2*a*b*cos(rad)),b*sin(rad));
    return 0;
}



Measured memory_bytes: 2068
import sys
input=sys.stdin.readline
D=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(D):
    sub=list(map(int,input().split()))
    s.append(sub)

last=[-1]*26

t=[]

for i in range(D):
    m=-10**9
    change=-1
    for j in range(26):
        temp=0
        temp+=s[i][j]
        for k in range(26):
            if k!=j:
                temp-=c[k]*(i-last[k])
        if temp>m:
            m=temp
            change=j
    t.append(change+1)

m=100000
import random
for _ in range(m):
    h=0
    d=random.randint(1,D)
    q=random.randint(1,26)
    h+=s[d-1][q-1]-s[d-1][t[d-1]-1]
    o=t[d-1]

    pre=1
    for i in range(d-2,-1,-1):
        if t[i]==o:
            break
        pre+=1
    post=1
    for j in range(d,D):
        if t[j]==o:
            break
        post+=1
    h-=c[o-1]*pre*post

    pre = 1
    for i in range(d - 2, -1, -1):
        if t[i] == q:
            break
        pre += 1
    post = 1
    for j in range(d, D):
        if t[j] == q:
            break
        post += 1
    h += c[q - 1] * pre * post

    if h>0:
        t[d-1]=q

for i in t:
    print(i)

Measured memory_bytes: 81728
# ABC139E - League
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)


def dfs(x: int, y: int) -> None:
    scheduled[x] = 1
    for i in range(cur[x], N - 1):
        z = A[x][i]  # scheduled i-th opponent of player x
        if z == y:
            cur[x] = i + 1
            scheduled[x] = 0
            days[x] += 1
            days[z] += 1
            days[x] = days[z] = max(days[x], days[z])
            return
        if scheduled[z]:  # the schedule contradicts
            print(-1)
            exit()
        dfs(z, x)


def main():
    global N, A, cur, days, scheduled
    N = int(input())
    A = [0] + list(list(map(int, input().split())) for _ in range(N))
    cur, days, scheduled = [0] * (N + 1), [0] * (N + 1), [0] * (N + 1)
    for i in range(1, N + 1):
        dfs(i, 0)
    ans = max(days)  # the last day of games
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 55644
#include <stdio.h>

int main (int argc, char* argv[])
{
  int a, b, sum=0, i;

  while (scanf("%d %d", &a, &b) != EOF) {
    sum = a + b;
    for (i=0; sum!=0; i++) {
      sum /= 10;
    }
    printf("%d\n", i);
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    string S;
    cin >>S;
    N=S.size();

    ll ans=0;
    rep(i,N){
        ll num=S[i]-'0';
        rep(j,N-i){
            ans+=num*pow(10,j)*pow(2,max(N-i-j-2,0LL))*pow(2,i);
        }
        
    }

    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3956
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N = sc.nextInt();
        // スペース区切りの整数の入力
        int[] A=new int[N];
        long result=0;
        A[0]=sc.nextInt();
        if(A[0]>0){
            System.out.println(-1);
            return;
        }
        for(int i=1;i<N;i++){
            A[i]=sc.nextInt();
            if(A[i]>A[i-1]+1){
                System.out.println(-1);
                return;
            }
            if(A[i]<=A[i-1]){
                result+=(long)A[i-1];
            }
        }
        result+=(long)A[N-1];
        System.out.println(result);


    }
}

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

int h, w;
vector<string> field;
vector<vector<int>> times;
queue<pair<int, int>> q;
vector<vector<bool>> seen;

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

void bfs () {
    while (!q.empty()) {
        int noy = q.front().first;
        int nox = q.front().second;
        q.pop();
        for (int i=0; i<4; ++i) {
            int ney = noy + dy[i];
            int nex = nox + dx[i];
            if (ney < 0 || h <= ney) continue;
            if (nex < 0 || w <= nex) continue;
            if (seen[ney][nex] == false) {
                q.push(make_pair(ney, nex));
                seen[ney][nex] = true;
                times[ney][nex] = times[noy][nox] + 1;
            }
        }
    }
}

int main() {
    cin >> h >> w;
    field.resize(h);
    times.resize(h, vector<int>(w, 1e9));
    seen.resize(h, vector<bool>(w, false));
    for (int i=0; i<h; ++i) cin >> field[i];
    for (int i=0; i<h; ++i) {
        for (int j=0; j<w; ++j) {
            if (field[i][j] == '#') {
                times[i][j] = 0;
                seen[i][j] = true;
                q.push(make_pair(i, j));
            }
        }
    }
    bfs();
    int ans = 0;
    for (int i=0; i<h; ++i) {
        for (int j=0; j<w; ++j) {
            ans = max(ans, times[i][j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 13584
import bisect
def 解():
    N = int(input())
    aA=[int(_) for _ in input().split()]
    aB=[int(_) for _ in input().split()]
    aD =[aA[i]-aB[i] for i in range(N)]

    if sum(aD) < 0:
        print(-1)
        exit()
    else:
        aD.sort()
        i0 = bisect.bisect_left(aD,0)
        if i0 == 0:
            print(0)
        elif i0 == N-1 :
            print(N)
        else:
            iM = sum(aD[:i0])
            for i in range(N-1,i0 - 1 ,-1):
                iM += aD[i]
                if iM > 0:
                    print(i0 + (N - i))
                    exit()
解()


Measured memory_bytes: 18652
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,q; cin>>n>>q;
    string s; cin>>s;
    vector<int> l(q),r(q);
    REP(i,q) cin>>l[i]>>r[i];
    vector<int> memo(s.length());
    int cnt=0;
    memo[0] = 0;
    FOR(i,1,s.length()){
        if(s.substr(i-1,2)=="AC"){
            cnt++;
            memo[i]=cnt;
        } else {
            memo[i]=cnt;
        }
    }
    REP(i,q){
        cout<<memo[r[i]-1]-memo[l[i]-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 2256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int a = 0;
        for(int i = 0;i < N;i++){
            int b = sc.nextInt();
            if(b == 1)  a = i;
        }
        if(N == K){
            System.out.println(1);
            return;
        }
        int ans = 1;
        N -= K;
        ans += N/(K-1);
        if(N%(K-1) != 0)    ans++;
        System.out.println(ans);
    }
}

Measured memory_bytes: 48472
N = int(input())
A = [0]+[int(x) for x in input().split()]
dp = [10**9]*(N+1)
dp[1] = 0
for i in range(1,N):
  if (i+2)<=N:
    dp[i+1] = min(dp[i+1],dp[i]+abs(A[i]-A[i+1]))
    dp[i+2] = min(dp[i+2],dp[i]+abs(A[i]-A[i+2]))
  elif i+1<=N:
    dp[i+1] = min(dp[i+1],dp[i]+abs(A[i]-A[i+1]))
print(dp[N])



Measured memory_bytes: 14052
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cassert>
#include<iomanip>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define eps (1e-8)
#define equals(a,b) (fabs((a)-(b)) < eps)
#define MAX 2000000
#define all(n) (n).begin(),(n).end()
using namespace std;
struct Circle
{
  double x,y,r;
  Circle(double x=inf,double y=inf,double r=inf):x(x),y(y),r(r){}
  bool operator < (const Circle& c)const
  {
    if(!equals(x,c.x))return x < c.x;
    return y < c.y;
  }
};

bool compare_y(Circle a,Circle b)
{
  return a.y < b.y;
}

int N;
Circle A[MAX];

double compute(Circle *a,int n)
{
  if(n <= 1)return inf;
  int m = n/2;
  double x = a[m].x;
  double y = a[m].y;
  double r = a[m].r;
  double d = min(compute(a,m),compute(a+m,n-m));
  inplace_merge(a,a+m,a+n,compare_y);

  vector<Circle> b;

  rep(i,n)
    {
      double nx = a[i].x - x;
      double ny = a[i].y - y;
      double ndist = sqrt(nx*nx + ny*ny) - a[i].r - r;
      //if(equals(ndist,d) || ndist > d)continue;
      //if(nx >= d)continue;
     
      rep(j,(int)min((int)b.size(),10))
	{
	  int last = b.size()-j-1;
	  double dx = a[i].x - b[last].x;
	  double dy = a[i].y - b[last].y;
	  double dist = sqrt(dx*dx + dy*dy) - a[i].r - b[last].r;

	  if(equals(dist,d) || dist > d)continue;
	  d = min(d,sqrt(dx*dx + dy*dy) - a[i].r - b[last].r);
	}
      b.push_back(a[i]);
    }
  return d;
}



int main()
{
  while(cin >> N,N)
    {
      assert(N < MAX);
      rep(i,N)cin >> A[i].r >> A[i].x >> A[i].y;
      sort(A,A+N);


      cout << setiosflags(ios::fixed) << setprecision(8) << compute(A,N) << endl;
    }
  return 0;
}

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

int main()
{
    char a, b;
    cin >> a >> b;
    if (a == 'H')
    {
        cout << b << endl;
    }
    else
    {
        if (b == 'H')
            cout << 'D' << endl;
        else
            cout << 'H' << endl;
    }
}

Measured memory_bytes: 256
#if 0
PDFに記載されている方針がわかりやすかったので、比較的簡単に解くことができた。
#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int Q;
int L[1000+10][1000+10];

int main() {
  cin >> Q;
  string X, Y;
  for (int i = 0; i < Q; i++) {
    for (int j = 0; j < 1000+10; j++) {
      L[0][j] = 0; L[j][0] = 0;
    }
    cin >> X >> Y;
    for (int x = 1; x <= X.length(); x++) {
      for (int y = 1; y <= Y.length(); y++) {
        if (X[x-1] == Y[y-1])
          L[x][y] = L[x-1][y-1] + 1;
        else
          L[x][y] = max(L[x-1][y], L[x][y-1]);
      }
    }
    cout << L[X.length()][Y.length()] << endl;
  }
}



Measured memory_bytes: 7136
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

struct Ans {
	int r1, c1, r2, c2;
};

int H, W, A[501][501];
vector<Ans> res;
int main() {
	scanf("%d %d", &H, &W);
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			scanf("%d", &A[i][j]);
		}
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j < W; j++) {
			if (A[i][j] % 2) {
				res.push_back({i, j, i, j + 1});
				A[i][j + 1]++;
				A[i][j]--;
			}
		}
	}
	for (int i = 1; i < H; i++) {
		if (A[i][W] % 2) {
			res.push_back({i, W, i + 1, W});
			A[i + 1][W]++;
			A[i][W]--;
		}
	}
	printf("%d\n", (int)res.size());
	for (Ans ans : res) {
		printf("%d %d %d %d\n", ans.r1, ans.c1, ans.r2, ans.c2);
	}
	return 0;
}


Measured memory_bytes: 5104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#define loop(n) for(int i = 0; i < n; i++)
#define FOR(x,y,z) for(int x = y; x < z; x++)
#define INF 999999999;
#define VEC vector<int>
#define in push_back
#define ans(x) cout<<x<<endl
#define ll long long

using namespace std;

int main()
{
	int n[3];
	int fc = 0, sc = 0;
	loop(3)
	{
	cin >> n[i];
	if (n[i] == 5)fc++;
	else if(n[i] == 7)sc++;
	}
	if (fc == 2 && sc == 1)ans("YES");
	else ans("NO");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1000000007;

signed main(){
    int N,M;
    cin >> N >> M;
    
    int s[M];
    char c[M];
    for(int i=0;i<M;i++){
        cin >> s[i] >> c[i];
    }
    
    int MAX = 0,MIN = 0;
    if(N == 1){
        MIN = 0;
        MAX = 9;
    }else if(N == 2){
        MIN = 10;
        MAX = 99;
    }else{
        MIN = 100;
        MAX = 999;
    }
    
    string ans;
    int cnt = 0;
    for(int i=MIN;i<=MAX;i++){
        ans = to_string(i);
        for(int k=0;k<M;k++){
            if(ans[s[k]-1] != c[k]) cnt++;
        }
        if(cnt == 0){
            cout << i << endl;
            return 0;
        }
        cnt = 0;
    }
    
    cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i = x; i < (int)(n); i++)
#define rep_ll(i,x,n) for(ll i = x; i < (ll)(n); i++)
using namespace std;
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
const long double PI = (acos(-1));
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, -1, 0, 1};
ll mod = 1000000007;
int main(){
    int n;
    cin >> n;
    int test=n/1000;
    if(n%1000!=0){
        cout << (test+1)*1000-n;
    }
    else {
        cout << "0";
    }
    
    return 0;
}

Measured memory_bytes: 3600
def main():
    S = input()
    stack1, stack2 = [], []
    
    sum = 0
    N = len(S)
    for i in range(N):
        if S[i] == "\\":
            stack1.append(i)
        elif S[i] == "/" and stack1:
            j = stack1.pop()
            tmp = i - j
            sum += tmp
            
            while stack2 and stack2[-1][0] > j:
                tmp += stack2.pop()[1]
            stack2.append([j, tmp])
            
    print(sum)
    print(len(stack2), *[a for j, a in stack2])
    

if __name__=="__main__":
    main()


Measured memory_bytes: 6168
#include<iostream>

using namespace std;

char put_str(const char s[],int k){
    char same;
    for(int i=0;s[i]!=0;i++){
        if(i+1 == k){
            same =s[i];
        }
    }
    return same;
}

int main(){
    int n,k;
    char s[10];
    char same;
    cin >> n;
    cin >> s;
    cin >> k;
    same = put_str(s,k);
    for(int i=0;s[i]!=0;i++){
        if(s[i]!=same){
            cout << "*";
        }
        else{
            cout << s[i];
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <regex>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
typedef long long LL;

const int MAX = 100000;
const LL INF = 1LL << 60;

void dijkstra(vector<pair<LL, int>> g[], LL d[], int n,int v) {
	priority_queue<pair<LL, int>, vector<pair<LL, int>>, greater<pair<LL, int>> > q;

	for (int i = 0; i < n; i++)d[i] = INF;
	q.push(make_pair(0, v));

	while (!q.empty()) {
		pair<LL, int> p = q.top(); q.pop();

		if (d[p.second] != INF)continue;
		d[p.second] = p.first;

		for (int i = 0; i < g[p.second].size(); i++) {
			if (d[g[p.second][i].second] != INF)continue;
			q.push(make_pair(d[p.second] + g[p.second][i].first, g[p.second][i].second));
		}
	}
}

int main() {
	int n, m, s, t;
	LL yenDist[MAX];
	LL snkDist[MAX];
	vector<pair<LL,int>> yen[MAX];
	vector<pair<LL,int>> snk[MAX];

	cin >> n >> m >> s >> t;
	s--; t--;

	for (int i = 0; i < m; i++) {
		int u, v, a, b;

		cin >> u >> v >> a >> b;
		u--; v--;

		yen[u].push_back(make_pair(a, v));
		yen[v].push_back(make_pair(a, u));
		snk[u].push_back(make_pair(b, v));
		snk[v].push_back(make_pair(b, u));
	}

	dijkstra(yen, yenDist, n, s);
	dijkstra(snk, snkDist, n, t);

	LL ans[MAX];
	LL minCost = INF;
	for (int i = n - 1; i >= 0; i--) {
		minCost = min(minCost, yenDist[i] + snkDist[i]);
		ans[i] = minCost;
	}

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

	return 0;
}

Measured memory_bytes: 20780
#include <bits/stdc++.h>
    using namespace std;
    
    int main(){
      int a , b;
      cin >> a >> b;
      if(a <= 5){
          cout << 0 << endl;
          
      }else if(a >= 13){
          cout << b << endl;
      }else{
          cout << (b/2) << endl;
      }
      
      return 0;
    }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int l = scan.nextInt();
		int r = scan.nextInt();
		int d = scan.nextInt();
		int ans = 0;
		for(int i = l; i < r+1; i++) {
			if(i % d == 0) {
				ans++;
			}
		}
		System.out.print(ans);
	}

}


Measured memory_bytes: 35728
#include<bits/stdc++.h>
using namespace std;
string S, T="keyence", a, b;
int main(){
	cin >> S;
	for(int i = 0; i <= 7; i++){
		a = T.substr(0, i); 
		b = T.substr(i, 7-i);
		if(a == S.substr(0, i) && b == S.substr(S.size()-(7-i), 7-i)){
				cout << "YES"<< endl;
				return 0;
		}
	}
	cout << "NO" << endl;
}


Measured memory_bytes: 256