akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	class P {
		long x;
		long y;

		P(long x, long y) {
			this.x = x;
			this.y = y;
		}

		P org(P a) {
			return new P(x - a.x, y - a.y);
		}
		
	}

	void run() {
		for (;;) {
			int n = sc.nextInt();
			int m = sc.nextInt();

			if ((n | m) == 0) {
				break;
			}

			P b[] = new P[n];
			P w[] = new P[m];

			for (int i = 0; i < n; i++) {
				b[i] = new P(sc.nextLong(), sc.nextLong());
			}
			for (int i = 0; i < m; i++) {
				w[i] = new P(sc.nextLong(), sc.nextLong());
			}

			boolean ok = false;

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {

					boolean check = true;
					P rot = b[i].org(w[j]);
					
					for (int x = 0; x < n && check; x++) {
						if(i == x){
							continue;
						}
						
						P org = b[x].org(w[j]);
						
						long v = org.y * rot.x - org.x *rot.y;
						if(v < 0){
							check = false;
						}
						if(v == 0){
							long v2 =rot.x * org.x + rot.y*org.y;
							if(v2 < 0){
								check = false;
							}
						}
						
					}
					for (int x = 0; x < m && check; x++) {
						if(j == x){
							continue;
						}
						
						P org = w[x].org(w[j]);
						long v = org.y * rot.x - org.x *rot.y;
						if(v > 0){
							check = false;
						}
						if(v == 0){
							long v2 =rot.x * org.x + rot.y*org.y;
							if(v2 > 0){
								check = false;
							}
						}
						
					}

					if(check){
//						System.out.println(i+" " + j);
						ok = true;
						break;
					}
				}
				if (ok) {
					break;
				}
			}
			System.out.println(ok ? "YES" : "NO");

		}

	}

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

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

int main() {
	int n;
	cin >> n;
	vector<int> x(n);
	rep(i, n) cin >> x[i];
	int ans = 1001001001;
	rep(p, 101){
		// pで集会
		int tmp = 0;
		rep(i, n){
			tmp += (p - x[i]) * (p - x[i]);
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
a = Counter(A)
sides = [0, 0]

for i in a.keys():
    if a[i] >= 4:
        sides.append(i)
        sides.append(i)
    elif a[i] >= 2:
        sides.append(i)

sides.sort()
print(sides.pop() * sides.pop())

Measured memory_bytes: 18600
#include<stdio.h>

int main(){
  int i,f,s,t;
  int a[10];
  for(i=0;i<10;i++)
    {
      scanf("%d",&a[i]);
      switch(i)
	{
	case 0: 
	  f=i;
	  break;
	case 1:
	  if(a[i]>a[f]){f=1;s=0;}
	  else s=i;
	  break;
	case 2:
	  if(a[i]>a[f]){t=s;s=f;f=i;}
	  else if(a[i]>a[s]){t=s;s=i;}
	  else t=i;
	  break;
	default:
	  if(a[i]>a[f]){t=s;s=f;f=i;}
	  else if(a[i]>a[s]){t=s;s=i;}
	  else if(a[i]>a[t]){t=i;}
	  break;
	}		 
    }
  printf("%d\n%d\n%d\n",a[f],a[s],a[t]);
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define debug(x) cerr << #x << " " << x << endl;
#define debug_p(x) cerr << #x << " [" << x.fi << " " << x.se << "]"<<endl;
#define debug_v(x) {cerr << #x << " "; for (auto ioi : x) cerr << ioi << " "; cerr << endl;}
#define debug_vp(x) {cerr << #x << " "; for (auto ioi : x) cerr << '[' << ioi.fi << " " << ioi.se << ']'; cerr << endl;}
#define debug_v_v(x) {cerr << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cerr << ioi2 << " "; cerr << '\n';} cerr << "*/" << #x << endl;}
#define gen_clock(x) ll x = clock(); cerr << "Clock " << #x << " created" << endl;
#define check_clock(x) cerr << "Time spent in " << #x << ": " << (double)(clock() - x)/CLOCKS_PER_SEC << endl; x = clock();
#define reset_clock(x) x = clock()

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	ll a,b,n;
	cin>>a>>b>>n;
	ll x=min(max(0LL,b-1),n);
	cout<<-a*(x/b)+a*x/b;
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int main() {
  int n, H, max, cnt;
  int result;
  cin >> n;
  max = 0;
  cnt = 0;
  for(int i = 0; i < n; i++){
      cin >> H;
      if(H >= max){
          max = H;
          cnt++;
      }
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
int h[N], f[N];

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> h[i];
	f[0] = 0;
	f[1] = abs(h[0] - h[1]);
	for(int i = 2; i < n; i++){
		f[i] = min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2]));
	}
	cout << f[n-1];
}


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

int main() {
  int N;
  cin>>N;
  int s=0,t=N;
  while (t>0) { 
    s+=t%10;
    t/=10;
  }
  if(N%s==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <numeric>
#include <vector>
#include <array>

#include <tuple>
#include <queue>

template <class T, size_t N, size_t I = 0>
decltype(auto) gen_vec(const size_t (&list)[N], typename std::enable_if<(I == N), const T&>::type value = T()) { 
  return value; 
}

template <class T, size_t N, size_t I = 0>
decltype(auto) gen_vec(const size_t (&list)[N], typename std::enable_if<(I != N), const T&>::type value = T()) { 
  return std::vector(list[I], gen_vec<T, N, I + 1>(list, value)); 
}

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

constexpr i32 inf32 = (i32(1) << 30) - 1;
constexpr i64 inf64 = (i64(1) << 62) - 1;

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

int main() {
  i32 H, W, K;
  std::cin >> H >> W >> K;
  i32 x1, y1, x2, y2;
  std::cin >> x1 >> y1 >> x2 >> y2;
  auto water = gen_vec<bool>({ H + 2, W + 2 });
  for (i32 i = 1; i <= H; ++i) {
    for (i32 j = 1; j <= W; ++j) {
      char c;
      std::cin >> c;
      water[i][j] = (c == '.');
    }
  }
  auto dist = gen_vec<std::pair<i32, i32>>({ H + 2, W + 2, 4 }, std::make_pair(inf32, inf32));
  using state = std::tuple<i32, i32, i32, i32, i32>;
  std::priority_queue<state, std::vector<state>, std::greater<state>> que;
  auto push = [&](i32 d, i32 r, i32 x, i32 y, i32 k) {
    if (!water[x][y]) {
      return;
    }
    if (dist[x][y][k] > std::make_pair(d, r)) {
      dist[x][y][k] = std::make_pair(d, r);
      que.emplace(d, r, x, y, k);
    }
  };
  for (i32 k = 0; k < 4; ++k) {
    push(0, 0, x1, y1, k);
  }
  while (!que.empty()) {
    auto [d, r, x, y, t] = que.top();
    que.pop();
    if (std::make_pair(d, r) > dist[x][y][t]) {
      continue;
    }
    if (r < 0) {
      push(d, r + 1, x + dx[t], y + dy[t], t);
    }
    for (i32 k = 0; k < 4; ++k) {
      push(d + 1, -(K - 1), x + dx[k], y + dy[k], k);
    }
  }
  std::pair<i32, i32> ans(inf32, inf32);
  for (i32 k = 0; k < 4; ++k) {
    if (ans > dist[x2][y2][k]) {
      ans = dist[x2][y2][k];
    }
  }
  if (ans.first == inf32) {
    std::cout << "-1\n";
  }
  else {
    std::cout << ans.first << '\n';
  }
  return 0;
}


Measured memory_bytes: 284816
#B - *e**** ********e* *e****e* ****e**

len_of_s = int(input())
s = input()
k = int(input())

remain = s[k-1]
s_list = [i for i in s]

for i in range(len_of_s):
	if s_list[i] != remain:
		s_list[i] = "*"

result = "".join(s_list)
print(result) 

Measured memory_bytes: 3316
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
#include <algorithm>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
//#define cocount cout << count << endl;
#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 Cinint(n) int n;\
cin >> n;
#define Cinvecint(a, n) vector<int> a(n);\
for (int i = 0; i < (int)(n); i++) {\
  int num;\
  cin >> num;\
  a.at(i) = num;\
}
#define Cinstring(s) string s;\
cin >>s;

  

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n) {
    int num;
    cin >> num;
    p.at(i) = num;
  }
  sort(p.begin(), p.end());
  int sum = 0;
  rep(i, k) {
    sum += p.at(i);
  }
  cout << sum << endl;
}


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

int main() {
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  for (;K>0 && B<=A;K--) B*=2;
  for (;K>0 && C<=B;K--) C*=2;
  cout<<(A<B && B<C?"Yes":"No")<<endl;
  return 0;
}


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

using namespace std;

int main()
{
  int n;
  scanf("%d",&n);
  static int a[100000];
  for(int i=0;i<n;i++){
    scanf("%d",a+i);
  }
  int C=0;
  static bool B[100000]={0};
  for(int t=29;t>=0;t--){
    bool b=0;
    for(int i=0;i<n;i++){
      b^=(a[i]>>t)&1;
    }
    if(b==0){
      continue;
    }
    bool F=0;
    for(int i=0;i<n;i++){
      if(((a[i]>>t)&1)&&((a[i]&((1<<t)-1))==0)&&!B[i]){
	F=1;
	a[i]--;
	C++;
	B[i]=1;
	break;
      }
    }
    if(!F){
      C=-1;
      break;
    }
  }
  printf("%d\n",C);
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

#define NIL -1

typedef struct{int parent,left,right;}Node;
Node T[100];

void pre(int x){
	if(x==NIL)return;

	printf(" %d",x);
	pre(T[x].left);
	pre(T[x].right);
}
void in(int x){
	if(x==NIL)return;

	in(T[x].left);
	printf(" %d",x);
	in(T[x].right);
}
void post(int x){
	if(x==NIL)return;

	post(T[x].left);
	post(T[x].right);
	printf(" %d",x);
}

int main(){
	int i,n,id,l,r;	scanf("%d",&n);
	for(i=0;i<n;i++)T[i].parent=T[i].left=T[i].right=NIL;

	for(i=0;i<n;i++){
		scanf("%d%d%d",&id,&l,&r);
		if(l!=-1){
			T[id].left=l;
			T[l].parent=id;
		}
		if(r!=-1){
			T[id].right=r;
			T[r].parent=id;
		}
	}

	int root;
	for(i=0;i<n;i++){
		if(T[i].parent==NIL){
			root=i;
			break;
		}
	}
	printf("Preorder\n");
	pre(root);
	printf("\nInorder\n");
	in(root);
	printf("\nPostorder\n");
	post(root);
	printf("\n");

	return 0;
}



Measured memory_bytes: 2148
l, r = map(int, input().split())
if r - l >= 2019:
    print(0)
else:
    l %= 2019
    r %= 2019
    if r < l:
        print(0)
    else:
        ans = 2019
        for i in range(l, r):
            for j in range(i + 1, r + 1):
                ans = min(ans, i * j % 2019)
        print(ans)


Measured memory_bytes: 2940
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
n=int(input())
memo=[0]*(10**5+1)

for i in range(1,10**5+1,2):
    if is_prime(i) and is_prime((i+1)/2):
        memo[i]=1
from itertools import accumulate
ac=list(accumulate(memo))

for i in range(n):
    l,r=map(int,input().split())
    print(ac[r]-ac[l-1])


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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

int main(void){
    int a, b;
    scanf("%d %d", &a, &b);
    
    if (a*b%2 == 0){
        printf("Even\n");
    }else{
        printf("Odd\n");
    }

    return 0;
}


Measured memory_bytes: 128
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

void main(){
	auto ip = readln.split.to!(int[]);
	((ip[0] + ip[1]) >= ip[2] ? "Yes" : "No").writeln;
}

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


public class Main{


	
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner();
		PrintWriter out=new PrintWriter(System.out);
		long K = sc.nextLong();
		int n=50;
		long x=(K+n*n-n)/n;
		long []arr=new long [n];
		for(int i=0;i<n;i++)
			arr[i]=x;
		long rem=K - (x * n - n*n + n);
		for(int i=0;i<rem;i++) {
			arr[i]+=n;
			for(int j=0;j<n;j++)
				if(i!=j)
					arr[j]--;
		}
		out.println(n);
		for(long z:arr)
			out.println(z);
		out.close();

	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		Scanner(String fileName) throws FileNotFoundException{
			br=new BufferedReader(new FileReader(fileName));
		}
		String next() throws IOException {
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		String nextLine() throws IOException {
			return br.readLine();
		}
		int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		long nextLong()  throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>

using namespace std;
int main(int argc, const char * argv[]) {
    
    long n;
    cin >> n;

    unsigned long m = 0;

    for (long i=1; i*i <= n; ++i) {
        // cout << i << endl;
        if(n % i == 0) {
            long a = i-1;
            // // cout << a << endl;
            if ( a != 0 && n/a == n%a ) m += a;
            if (i*i != n ) {
                long b = n/i-1;
                if ( n/b == n%b ) m += b;
            }
        }
    }

    cout << m << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
map<string,int> mp;
int main()
{
scanf("%d",&n);
for (int i=1;i<=n;i++)
{
string s;
cin>>s;
mp[s]++;
}
scanf("%d",&m);
for (int i=1;i<=m;i++)
{
string s;
cin>>s;
mp[s]--;
}
int ans=0;
for (map<string,int>::iterator it=mp.begin();it!=mp.end();it++)
ans=max(ans,it->second);
cout<<ans<<endl;
}

Measured memory_bytes: 256
from collections import deque
h,w=map(int,input().split())
ch,cw=map(int,input().split())
dh,dw=map(int,input().split())
s=[list(input()) for i in range(h)]
 
#幅優先で解く。
dx=[1,0,-1,0]
dy=[0,1,0,-1]
def bfs():
  maze=[[-1]*w for i in range(h)]
  maze[ch-1][cw-1]=0
  qu=deque([])
  qu.append((cw-1,ch-1))
  magic=0
  
  while qu:
    x,y=qu.popleft()
    for i in range(4):
      nx=dx[i]+x
      ny=dy[i]+y
      if 0<=nx<=w-1 and 0<=ny<=h-1 and s[ny][nx]=="." and (maze[ny][nx]==-1 or maze[ny][nx]>maze[y][x]):
        qu.appendleft((nx,ny))
        maze[ny][nx]=maze[y][x]
    for i in range(x-2,x+3):
      for j in range(y-2,y+3):
        nx=i
        ny=j
        if 0<=nx<=w-1 and 0<=ny<=h-1 and s[ny][nx]=="." and (maze[ny][nx]==-1 or maze[ny][nx]>maze[y][x]+1):
          qu.append((nx,ny))
          maze[ny][nx]=maze[y][x]+1
  return maze
    
maze = bfs()
print(maze[dh-1][dw-1])

Measured memory_bytes: 130020
/**
 *   author: malviyanshiv
 *   created: 27 July 2019  17:32:38
**/

#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for(int i = a; i < b; i++)
#define RREP(i, a, b) for(int i = a-1; i >= b; i--)
#define FORE(a) for(auto ele : a )
#define ALL(a) begin(a), end(a)
#define RPB(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define PB push_back
#define MP make_pair
#define MOD 1000000007
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define F first
#define S second
#define TC int t; cin >> t; while(t--)
#define SET(a,b) memset(a,b,sizeof(a))

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

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


void optimizeIO(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
}

int main(){
	optimizeIO();

	int n;
	cin >> n;
	vector<int> org(n), dup(n);
	REP(i, 0, n){
		cin >> org[i];
		dup[i] = org[i];
	}
	sort(dup.begin(), dup.end());
	int dif = 0;
	REP(i, 0, n)
		if( org[i] != dup[i] )
			dif++;
	if( dif <= 2 )
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define ull unsigned long long int
#define boost ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0)
#define vi vector<int>
#define P push_back
#define F first
#define S second
#define debug(x) cout<<x<<" "
#define pi vector<pair<int,int> >
#define FOR(i,x,n) for(int i=x;i<n;i++)
#define all(a) a.begin(),a.end()
ll mod=1e9+7;
#define N 99999999
//#define int ll
using namespace std;
#define int ll
void trans(int i,int sum,vi &value,int par,vector<vi> &a){
    value[i]+=sum;
    sum=value[i];
    for(int j=0;j<a[i].size();j++){
        if(a[i][j]!=par)trans(a[i][j],sum,value,i,a);
    }
    return;
}
signed main(){
    boost;
    int n,q;
    cin>>n>>q;
    vector<vi> a(n);
    for(int i=0;i<n-1;i++){
        int x,y;
        cin>>x>>y;
        x--,y--;
        a[x].P(y);
        a[y].P(x);
    }
    vi vis(n);
    vi value(n);
    for(int i=0;i<q;i++){
        int x,y;
        cin>>x>>y;
        x--;
        value[x]+=y;
    }
    trans(0,0,value,-1,a);
    for(auto i:value)cout<<i<<" ";
    


    return 0;
}

Measured memory_bytes: 32128
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int mod = 1e9 + 7;
ll a[2020];

void solve()
{
    int s;
    cin >> s;
    a[3] = 1;
    a[4] = 1;
    a[5] = 1;
    for (int i = 6; i <= s; i++)
    {
        a[i] = a[i - 3] % mod + a[i - 1] % mod;
    }
    a[s] %= mod;
    // rep(i, s + 1) cout << a[i] << endl;
    cout << a[s] << endl;
}

int main()
{
    // srand((unsigned)time(NULL));
    // int t = clock();
    solve();
    // double et = 1.0 * (clock() - t) / CLOCKS_PER_SEC;
    // printf("Execution Time: %.4lf sec\n", et);
    return 0;
}

Measured memory_bytes: 3552
#include <iostream>
    #include <stdio.h>
    #include <stdlib.h>
    #include <vector>
    #include <algorithm>
    #include <string>
     
    using namespace std;
     
     
    int main(void){
     
    	int ans = 0;
    	for( int i = 0; i < 4; i++ ) {
    		int n;
    		scanf("%d", &n);
    		ans += n;
    	}
    	cout << ans / 60 << endl;
    	cout << ans % 60 << endl;
     
        return 0;
    }

Measured memory_bytes: 1208
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

ll m;
V< V<int> > edges;
vll subans;
vll ans;

void dfs_pre(int i, int p) {
    subans[i] = 1;
    for (int e: edges[i]) {
        if (e == p) continue;
        dfs_pre(e, i);
        (subans[i] *= (subans[e] + 1)) %= m;
    }
}

void dfs_rer(int i, int p) {
    ans[i] = subans[i];
    int sz = edges[i].size();
    vll lacc(sz + 1, 1), racc(sz + 1, 1);
    for (int j = 0; j < sz; j++) {
        lacc[j + 1] = lacc[j] * (subans[edges[i][j]] + 1) % m;
        racc[sz - j - 1] = racc[sz - j] * (subans[edges[i][sz - j - 1]] + 1) % m;
    }
    ll cur = subans[i];
    for (int j = 0; j < sz; j++) {
        if (edges[i][j] == p) continue;
        subans[i] = lacc[j] * racc[j + 1] % m;
        (subans[edges[i][j]] *= (lacc[j] * racc[j + 1] % m) + 1) %= m;
        dfs_rer(edges[i][j], i);
    }
    subans[i] = cur;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n >> m;
    edges.resize(n);
    for (int i = 1; i < n; i++) {
        int x, y; cin >> x >> y;
        x--, y--;
        edges[x].emplace_back(y), edges[y].emplace_back(x);
    }

    subans.resize(n, 0);
    dfs_pre(0, -1);
    // DEBUG_VLL(subans)
    ans.resize(n, 0);
    dfs_rer(0, -1);
    for (int i = 0; i < n; i++) cout << ans[i] << '\n';
    return 0;
}


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

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

int main(){
	int N;
	while( cin >> N, N ){
		int pos[200][2] = {};
		for(int i=1; i<N; i++){
			int n, d;
			cin >> n >> d;
			pos[i][0] = pos[n][0];
			pos[i][1] = pos[n][1];
			pos[i][d%2] += (d<2 ? -1 : 1);
		}
		int minX=0, maxX=0, minY=0, maxY=0;
		for(int i=1; i<N; i++){
			if( pos[i][0] > maxX )	maxX = pos[i][0];
			if( pos[i][0] < minX )	minX = pos[i][0];
			if( pos[i][1] > maxY )	maxY = pos[i][1];
			if( pos[i][1] < minY )	minY = pos[i][1];
		}
		cout << (maxX-minX+1) << " " << (maxY-minY+1) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

struct unionfind
{
    vector<long long> d;

    unionfind(long long n) : d(n, -1) {}

    long long root(long long x)
    {
        if (d[x] < 0)
        {
            return x;
        }
        else
        {
            return d[x] = root(d[x]);
        }
    }

    bool unite(long long x, long long y)
    {
        x = root(x);
        y = root(y);

        if (x == y)
        {
            return false;
        }

        if (d[x] > d[y])
        {
            swap(x, y);
        }

        d[x] += d[y];
        d[y] = x;
        return true;
    }

    bool same(long long x, long long y)
    {
        return root(x) == root(y);
    }

    long long size(long long x)
    {
        return -d[root(x)];
    }
};

int main(void)
{
    int n, m;
    cin >> n >> m;

    unionfind u(n);

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

        if (!u.same(a, b))
        {
            u.unite(a, b);
        }
    }

    ll ans = 0;

    if (m == 0)
    {
        cout << 1 << endl;
    }
    else
    {
        for (int i = 0; i < n; i++)
        {
            ans = max(u.size(i), ans);
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 4772
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	int a, b;

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

	if (a % 3 == 0 && a >= 3) {
		printf("Possible\n");
	}
	else if(b % 3 == 0 && b >= 3){
		printf("Possible\n");
	}
	else if ((a + b) % 3 == 0 && a + b >= 3) {
		printf("Possible\n");
	}
	else {
		printf("Impossible\n");
	}

	return 0;
}


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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), k = fs.nextInt();
		int h[] = fs.nextIntArray(n);
		rsort(h);
		int cnt = 0;
		long ans = 0;
		for(int i=0;i<n;i++) {
			if(cnt<k)cnt++;
			else {
				ans += h[i];
			}
		}
		System.out.println(ans);
	}
	//reverseOrderSort : O(NlogN)
	static void rsort(int[] ar) {
		Arrays.sort(ar);
		int len = ar.length;
		for (int i = 0; i < len / 2; i++) {
			int tmp = ar[i];
			ar[i] = ar[len - 1 - i];
			ar[len - 1 - i] = tmp;
		}
	}

	static void rsort(long[] ar) {
		Arrays.sort(ar);
		int len = ar.length;
		for (int i = 0; i < len / 2; i++) {
			long tmp = ar[i];
			ar[i] = ar[len - 1 - i];
			ar[len - 1 - i] = tmp;
		}
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 57240
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"
// #define M 421412341324321
#define MOD 998244353

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	
	int n;
	cin>>n;
	int N = 1<<n;
	int a[N];
	multiset <int , greater <int>> s;
	rep(i,N) 
	{
		cin>>a[i];
		s.insert(a[i]);
	}
	sort(a,a+N, greater <int> ());
	multiset <int, greater <int> > x;
	x.insert(a[0]);
	s.erase(s.begin());
	// for (auto j:x) debug1(j);
	rep(i,n)
	{
		multiset <int, greater <int> > temp;
		for (auto j:x)
		{
			auto it = s.upper_bound(j);
			// debug2(j,i);
			if (it==s.end())
			{
				cout<<"No";
				return 0;
			}
			else
			{
				temp.insert(*it);
				s.erase(it);
			}
		}
		for (auto j:temp)
		{
			x.insert(j);
		}
	}
	cout<<"Yes";
}


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


using namespace std;

int main() {

	int a, b, c, x, y, res, res1, res2, mini;
	cin >> a >> b >> c >> x >> y;
	
	mini = min(x, y);
	res = (max(x,y) * 2 * c);
	res1 = a*x + b*y ;
	res2 = mini * 2 * c;
	x -= mini;
	y -= mini;
	res2 += x*a + y*b;
	cout << min(res, min(res1, res2));

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	int a;
	int Min=1000000,Max=-1000000;
	long long Sum=0;
	scanf("%d",&n);
	
	int i;
	for(i=1;i<=n;i++){
		scanf("%d",&a);
		if(Min>a)Min=a;
		if(Max<a)Max=a;
		Sum+=a;
	}
	
	printf("%d %d %lld\n",Min,Max,Sum);
return 0;
}



Measured memory_bytes: 2048
#pragma GCC optimize("trapv")
#include<bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using vi = vector<int>;
using ll = long long;
const int maxn = 1<<20, mod = 924844033;
ll n, k, a[maxn], b[maxn], c[maxn];
ll ans = 0;
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) b[i] = max(a[i], 0ll) + b[i-1];
	for(int i = n; i; i--) c[i] = max(a[i], 0ll) + c[i+1];
	for(int i = 1; i <= n; i++) a[i] += a[i-1];
	for(int i = k; i <= n; i++) {
		ll t = max(0ll, a[i] - a[i-k]);
		t += b[i-k] + c[i+1];
		ans = max(ans, t);
	}
	cout << ans;
}


Measured memory_bytes: 5120
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	string s;
	cin>>s;
	int ans = INF;
	rep(i,26){
		char t = 'a'+i;
		string a = s;
		int cnt = 0;
		while(a.size()){
			bool ok = true;
			rep(i,a.size()){
				if(a[i]!=t) ok=false;
			}
			if(ok) break;
			cnt++;
			string next;
			rep(i,a.size()-1){
				if(a[i]==t||a[i+1]==t) next+=t;
				else next+=a[i];
			}
			a = next;
		}
		mins(ans, cnt);
	}
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;

public class Main {
	static long MOD = 1000000007L;
	long[] array;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		long X = Long.parseLong(tokens[0]);
		long Y = Long.parseLong(tokens[1]);
		if (!checkCond(X, Y)) {
			System.out.println("0");
		} else {
			long A = (2 * Y - X) / 3;
			long B = (2 * X - Y) / 3;
			long result = calcCombi(A + B, Math.min(A, B));
			System.out.println(result);
		}
	}

	static long inv(long val) {
		long result = 1L;
		long k = MOD - 2L;
		long y = val;
		while (k != 0) {
			if ((k & 1L) > 0) {
				result = (result * y) % MOD;
			}
			y = (y * y) % MOD;
			k /= 2;
		}
		return result;

	}

	static long calcCombi(long n, long c) {
		if (c == 0) {
			return 1L;
		}
		// まず階乗の配列を計算する
		long[] array = new long[(int) (n + 1)];
		array[0] = 0L;
		array[1] = 1L;
		for (long i = 2; i <= n; ++i) {
			int index = (int) i;
			array[index] = array[index - 1] * i % MOD;
		}

		long val = array[(int) (n)];
		val *= inv(array[(int) (n - c)]);
		val %= MOD;
		val *= inv(array[(int) (c)]);
		val %= MOD;
		return val;
	}

	static boolean checkCond(long X, long Y) {
		boolean cond = true;
		if ((2 * Y - X) % 3 != 0 || (2 * Y - X) < 0) {
			cond = false;
		}
		if ((2 * X - Y) % 3 != 0 || (2 * X - Y) < 0) {
			cond = false;
		}
		return cond;
	}
}


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

using namespace std;

int main(){

  	int a, b, c;
  	int yakusu =0;
  	cin >> a >> b >> c;
  
  	while(a<=b){
    	if(c%a==0) yakusu++;
      a++;
    }
  
  	cout << yakusu << endl;
    return 0;
}


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

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

	int N; cin >> N;

	int a[210000];
	int b[210000];
	vector<int> x;
	int c = 0;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}
	for (int i = N; i > 0; i--) {
		int z = 2;
		int sum = 0;
		while (z * i <= N) {
			sum += b[z * i];
			z++;
		}
		if (sum % 2 == a[i])b[i] = 0;
		else {
			b[i] = 1;
			x.push_back(i);
			c++;
		}
	}
	cout << c << endl;
	for (int i = 0; i < c; i++) {
		cout << x[i] << " ";
	}
}

Measured memory_bytes: 3192
import sys
input = sys.stdin.readline
def main():
    S = input().rstrip("\r\n")
    T = input().rstrip("\r\n")
    if S == T[:-1] and len(S) + 1 == len(T):
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()

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

using namespace std;

bool visited[1010][1010];
int angka[1010][1010];
char matrix[1010][1010];
long long maks,b,k,i,j;
pair<pair<int,int>,int> temp,sekarang;
pair<int,int> posisi;
queue <pair<pair<int,int>,int> > antri;
int main()
{
	cin >> b >> k;
	for(i=0;i<b;i++)
	{
		for(j = 0; j< k ;j++)
		{
			visited[i][j] = false;
			cin >> matrix[i][j];
			if(matrix[i][j] == '#')
			{
				posisi = make_pair(i,j);
				temp = make_pair(posisi,0);
				antri.push(temp);
			}
		}
	}
	while(!antri.empty())
	{
		sekarang = antri.front();
		antri.pop();
		if(!visited[sekarang.first.first][sekarang.first.second])
		{
			visited[sekarang.first.first][sekarang.first.second] = true;
			angka[sekarang.first.first][sekarang.first.second] = sekarang.second;
			if(sekarang.first.first+1 < b)
			{
				posisi = make_pair(sekarang.first.first+1,sekarang.first.second);
				temp = make_pair(posisi,sekarang.second+1);
				antri.push(temp);
			}
			if(sekarang.first.first-1 >= 0)
			{
				posisi = make_pair(sekarang.first.first-1,sekarang.first.second);
				temp = make_pair(posisi,sekarang.second+1);
				antri.push(temp);
			}
			if(sekarang.first.second+1 < k)
			{
				posisi = make_pair(sekarang.first.first,sekarang.first.second+1);
				temp = make_pair(posisi,sekarang.second+1);
				antri.push(temp);
			}
			if(sekarang.first.second-1 >= 0)
			{
				posisi = make_pair(sekarang.first.first,sekarang.first.second-1);
				temp = make_pair(posisi,sekarang.second+1);
				antri.push(temp);
			}
		}
	}
	maks = 0;
	for(i=0;i<b;i++)
	{
		for(j=0;j<k;j++)
		{
			if(maks < angka[i][j])
			{
				maks = angka[i][j];
			}
		}
	}
	cout << maks << endl;
}

Measured memory_bytes: 55752
from sys import stdin


inp = stdin.readline

n, k = [int(x) for x in inp().strip().split()]

array = [int(x) for x in inp().strip().split()]

distance = [0]*(k * 2)

for i in range(k - 1):
    distance[i] = array[i+1] - array[i]

distance[k-1] = n-array[k-1] + array[0]

print(n-max(distance))

Measured memory_bytes: 26444
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;

 int main(){
	 int a,b,c,d[1001],e[1001],f,g,cunt=0;

	 scanf("%d %d %d",&a,&b,&c);


	 for(int i=0;i<c;i++) scanf("%d %d",&d[i],&e[i]);

	 for(int i=0;i<c-1;i++){
		 g=d[i]-d[i+1];
		 f=e[i]-e[i+1];
		 if(g<0 && f<0){
			if(g*-1>f*-1){
				cunt+=g*-1;
			}else cunt+=f*-1;
		 }else if(g>=0 && f<=0){
			 cunt+=g+f*-1;
		 }else if(g<=0 && f>=0){
			cunt+=g*-1+f;
		 }else if(g>0 && f>0){
			if(g>f){
				cunt+=g;
			}else cunt+=f;
		 }else{
			 cunt+=g+f;
		 }
	 }
	 printf("%d\n",cunt);
	return 0;
 }

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


int main(){
    int N,K;
    cin >> N >> K;
    string s;
    cin >> s;
    
    vector<int> num;
    num.push_back(0);
    num.push_back(0);
    for(int i=0; i<s.size()-1; i++){
        if(s[i] != s[i+1]){
            num.push_back(i+1);
        }
    }
    num.push_back(N);
    num.push_back(N);
    
    int max111=0;
    if(s[0]=='1'){
        int i=1,x=0;;
        
        while(i+2*K+1< num.size()){
            x=0;
            x = num[i+2*K+1] - num[i];
            i +=2;
            //cout << "x: " <<x << endl;
            max111=max(max111, x);
        }
    }
    
    if(s[0]=='0'){
        int i=0,x=0;;
        
        while(i+2*K+1< num.size()){
            x=0;
            x = num[i+2*K+1] - num[i];
            i +=2;
            //cout << "x: " <<x << endl;
            max111=max(max111, x);
        }
    }
    
    
    if(2*K+1 >= num.size()-2) max111=N;
    
    cout << max111 << endl;
    
    
    /*
    for(int x:num){
        cout << x << " ";
    }cout << endl;
    */
    
}


Measured memory_bytes: 1020
#include <iostream>
#include <string>

using namespace std;

int time2sec(string s) {
    int hour = stoi(s.substr(0,2), nullptr, 10);
    int minute = stoi(s.substr(3,2), nullptr, 10);
    int sec = stoi(s.substr(6,2), nullptr, 10);

    return hour * 3600 + minute * 60 + sec;
}

int main() {
    int table[24*3600+1];

    int n;
    while (cin >> n, n) {
        fill_n((int *)table, 24*3600+1, 0);
        
        int max = 0;
        for (int i = 0; i < n; i++) {
            string s, e;
            cin >> s >> e;

            int ss = time2sec(s);
            int es = time2sec(e);

            for (int t = ss; t < es; t++) {
                table[t]++;
                if (max < table[t]) {
                    max = table[t];
                }
            }
        }
        cout << max << endl;
    }

    return 0;
}

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

int main()
{
  string S;
  cin >> S;
  vector<string> weather = {
    "Sunny",
    "Cloudy",
    "Rainy"
  };
  rep(i, weather.size()) {
    if (weather.at(i) == S) {
      if (S == "Rainy") {
        cout << "Sunny" << endl;
        break;
      }
      cout << weather.at(i+1) << endl;
    }
  }

}

Measured memory_bytes: 256
n=gets.to_i
a=gets.split.map(&:to_i)
b=gets.split.map(&:to_i)
c=0
(n-1).downto(0){|i|
1.downto(0){|k|
  if a[i+k]>=b[i]
    c+=b[i]
    a[i+k]-=b[i]
    b[i]=0
  else
    c+=a[i+k]
    b[i]-=a[i+k]
    a[i+k]=0
  end
}
}
puts c


Measured memory_bytes: 15380
from itertools import permutations
from math import factorial

N = int(input())
coord = []
for _ in range(N):
   x,y = map(int, input().split())
   coord.append((x,y))

def dist(a, b):
   x1, y1 = a
   x2, y2 = b
   return pow((x1-x2) ** 2 + (y1-y2) ** 2, 1/2)

res = 0
div = factorial(N)
idx = [i for i in range(N)]
for line in permutations(idx, N):
   for i in range(N-1):
      res += dist(coord[line[i]], coord[line[i+1]]) / div

print(res)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
struct weight
{
	int w;
	int v;
};
int main()
{
	int n,m;
	cin>>n>>m;
	struct weight a[n+1],t;
	long long int b[n+1][m+1];
	a[0].w=0,a[0].v=0;
	for(int i=1;i<n+1;i++)
	{
		cin>>a[i].w>>a[i].v;
	}
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<n-i;j++)
		{
			if(a[j].w>a[j+1].w)
			{
				t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;
			}
		}
	}
	for(int i=0;i<n+1;i++)
	{
		for(int j=0;j<m+1;j++)
		{
			if(j==0 || i==0)
			b[i][j]=0;
			else if(a[i].w>j)
			{
				b[i][j]=b[i-1][j];
			}
			else if(a[i].w<=j)
			{
				b[i][j]=max((a[i].v+b[i-1][j-a[i].w]),b[i-1][j]);
			}
		}
	}
	cout<<b[n][m];
	return 0;
}

Measured memory_bytes: 79104
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

typedef long long int lli;

void swap(int* a, int* b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void ll_swap(lli* a, lli* b)
{
    lli tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int gcd(int a, int b)
{
    if (a < b)
        swap(&a, &b);

    if (a % b == 0)
        return b;
    else
        return gcd(b, a % b);
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

long power(long x, int n) {
    long ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

lli comb(lli n, lli r)
{
    if (n == 0)
        return 0;

    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (comb(n - 1, r - 1) + comb(n - 1, r));
}

/*
#define MAX 100000
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*/   

int main()
{
    int M, N, K, L;
    int X, Y,Z;
   int A[200000];

    lli count = 0;
    lli temp, temp2;
    lli max = -LLINF,min = LLINF;
    lli sum = 0;

    scanf("%d%d",&N,&M);

    for (int i = 0; i < N; i++)
    {
        scanf("%d", &A[i]);
        sum += A[i];
    }
      

    for (int i = 0; i < N; i++)
    {
        if (A[i] >= (double)sum / (4 * M))
            count++;
    }

    if (count >= M)
        printf("Yes");
    else
        printf("No");
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	_ = nextInt()

	S := make([]string, N)
	for i := range S {
		sc.Scan()
		S[i] = sc.Text()
	}
	sort.Strings(S)
	fmt.Println(strings.Join(S, ""))
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}


Measured memory_bytes: 640
n,m=map(int,input().split())

if n %2 == 1:
    for i in range(1,m+1):
        print(i,n-i)
else:
    for i in range(m//2):
        print(n//2-i,n//2+1+i)
        print(i+1,n-i-1)
    if m%2 == 1:
        print(n//2-m//2,n//2+1+m//2)
        

Measured memory_bytes: 9292
#include <stdio.h>

#define STRING_LENGTH 3
#define ARRAY_SIZE (STRING_LENGTH + 1)

void solve(char s[ARRAY_SIZE]);


int main()
{
  char s[ARRAY_SIZE];

  scanf("%s", &s);
  solve(s);

  return 0;
}

void solve(char s[ARRAY_SIZE])
{
  int i;
  int price = 700;

  for (i = 0; i < 3; i++)
    {
      if (s[i] == 'o')
	{
	  price += 100;
	}
    }

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


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0238
{
    class Program
    {
        static void Main(string[] args)
        {

            while (true)
            {
                int t = RInt();
                if (t == 0) break;

                int n = RInt();
                int time = 0;
                for (int i = 0; i < n; i++)
                {
                    int[] vs = RArInt();
                    time += vs[1] - vs[0];
                }
                Console.WriteLine(time >= t ? "OK" : (t-time).ToString());
            }
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 15888
from math import ceil
N, K = [int(i) for i in input().split()]
mod = 10 ** 9 + 7
ans = 0
n = m = 0
for i in range(1, N + 2):
    n += N + 1 - i
    m += i - 1
    if i >= K:
        ans += n - m + 1
        ans %= mod
print(ans)

Measured memory_bytes: 64628