akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static string S;
        static long N;
        static void Main(string[] args)
        {
            N = long.Parse(Console.ReadLine());
            //var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            S = Console.ReadLine();
            var ans = 0;
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    for (int k = 0; k < 10; k++)
                    {
                        if (IsPossible(i, j, k))
                        {
                            ans++;
                        }
                        
                    }
                }
            }

            Console.WriteLine(ans);
        }
        
        static bool IsPossible(int i,int j, int k)
        {
            bool ans = true;
            var now = 0;
            for (; now < N; now++)
            {
                if(S[now] - '0' == i)
                {
                    break;
                }
            }

            for (now++; now < N; now++)
            {
                if (S[now] - '0' == (char)j)
                {
                    break;
                }
            }

            for (now++; now < N; now++)
            {
                if (S[now] - '0' == (char)k)
                {
                    break;
                }
            }

            if ((now >= N))
            {
                return false;
            }
            else
            {
                return true;
            }
        }
    }


}


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

int x[100001], y[100001];
int t[100001];

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);


    int n; cin >> n;
    t[0] = x[0] = y[0] = 0;
    for (int i = 1; i <= n; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }

    for (int i = 0; i < n; i++) {
        int d = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
        int dt = t[i + 1] - t[i];
        if (d <= dt && (d % 2) == (dt % 2)) {
            continue;
        } else {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
int main()
{
	int N;
	scanf("%d",&N);
	int copy=N;
	int sum=0;
	while(copy>0)
	{
		int num=copy%10;
		sum+=num;
		copy=copy/10;
	}
	if(N%sum==0)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int sum = a * (int)Math.pow(10, String.valueOf(b).length()) + b;
        int sqrt = (int)Math.sqrt(sum);
        System.out.println(sqrt * sqrt == sum ? "Yes" : "No");
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int t1 = 0;
	int x1 = 0;
	int y1 = 0;
	int t, x, y;
	bool f = true;
	for (int i = 0; i < N; i++) {
		cin >> t >> x >> y;
		if ((x + x1 + y + y1 + t + t1) % 2 == 0) {
			if (abs(x - x1) + abs(y - y1) > t - t1) {
				f = false;
			}
		}
		else {
			f = false;
		}
		x1 = x;
		y1 = y;
		t1 = t;
	}
	if (f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No"<< endl;
	}

}

Measured memory_bytes: 256
# editorialを参考に作成
S = input()
lenS = len(S)
DP = [0] * 13
ans = [0]*13
i_mod = [1] * lenS
if S[lenS-1] == "?":
    for j in range(10):
        ans[j % 13] += 1
else:
    ans[int(S[lenS-1]) % 13] += 1

for i in range(1, len(S)):
    DP = [0]*13
    for r in range(13):
        DP[r] += ans[r] % (10**9+7)
    ans = [0]*13
    i_mod[i] = (i_mod[i - 1] * 10) % 13
    i_now = 0
    i_now += i_mod[i]
    if S[lenS-i-1] == "?":
        for p in range(13):
            for h in range(10):
                ans[(p+h * i_now) % 13] += DP[p]

    else:
        for q in range(13):
            ans[(q+i_now * int(S[lenS-i-1])) % 13] = DP[q]


print(ans[5] % (10**9+7))
# print(DP)


Measured memory_bytes: 43884
#include<bits/stdc++.h>
using namespace std;
bitset<4000005> f;
int n,sum;
int main()
{
	cin>>n;
	f[0] = 1;
	for(int a,i=1;i<=n;i++)
		scanf("%d",&a),f|=(f<<a),sum+=a;
	int k=(sum+1)>>1;
	while(!f[k]) k++;
	cout<<k;
	return 0;
}


Measured memory_bytes: 1664
package main

import "fmt"

func main() {
	var (
		N int
		K int
	)
	fmt.Scan(&N, &K)

	owners := make(map[int]bool)

	for i := 0; i < K; i++ {
		var d int
		fmt.Scan(&d)
		for j := 0; j < d; j++ {
			var owner int
			fmt.Scan(&owner)
			owners[owner] = true
		}
	}
	fmt.Println(N - len(owners))
}


Measured memory_bytes: 2548
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <ostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define rev(i,a,b) for (int i=(a)-1;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef queue< pair<int, int> > qpii;
typedef vector<int> vi;
typedef vector<int, int> vii;
typedef vector<string> vs;
typedef vector< pair<int, int> > vpii;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

int n[10];
int h, w;

bool dfs(int b, int c, int cnt) {
  if(cnt == 10) return true;
  if(n[cnt] > n[b]) {
    if(dfs(cnt, c, cnt+1)) return true;
  }
  if(c == -1 || n[cnt] > n[c]) {
    if(dfs(b, cnt, cnt+1)) return true;
  }
  return false;
}

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

  int num;
  cin >> num;
  rep(i,0,num) {
    rep(j,0,10) cin >> n[j];

    if(dfs(0, -1, 1)) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }

	return 0;
}

Measured memory_bytes: 1184
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<stdlib.h>
using namespace std;


int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(b<c){
        b=b+c;
        c=b-c;
        b=b-c;
    }

    if(a<b){
        a=a+b;
        b=a-b;
        a=a-b;
    }

    a=b+c;



    cout<<a;


    return 0;

}


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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

constexpr double eps = 1e-8;
inline constexpr bool eq(double a, double b) { return fabs(a - b) < eps; }

//-----点-----//
struct Point
{
    double x, y;

    constexpr Point(double x = 0.0, double y = 0.0) : x(x), y(y) {}

    Point &operator+=(const Point &p) { x += p.x, y += p.y; return *this; }
    Point &operator-=(const Point &p) { x -= p.x, y -= p.y; return *this; }
    Point &operator*=(const double k) { x *= k, y *= k; return *this; }
    Point &operator/=(const double k) { x /= k, y /= k; return *this; }
};

inline Point operator+(const Point &p, const Point &q) { return Point(p) += q; }
inline Point operator-(const Point &p, const Point &q) { return Point(p) -= q; }
inline Point operator*(const Point &p, const double k) { return Point(p) *= k; }
inline Point operator/(const Point &p, const double k) { return Point(p) /= k; }

inline Point operator+(const Point &p) { return p; }
inline Point operator-(const Point &p) { return Point(-p.x, -p.y); }

inline constexpr bool operator==(const Point &p, const Point &q) { return eq(p.x, q.x) && eq(p.y, q.y); }
inline constexpr bool operator!=(const Point &p, const Point &q) { return !(p == q); }

inline double norm2(const Point &p) { return p.x * p.x + p.y * p.y; }
inline double norm(const Point &p) { return sqrt(p.x * p.x + p.y * p.y); }
inline double arg(const Point &p) { return atan2(p.y, p.x); }

inline double dot(const Point &p, const Point &q) { return p.x * q.x + p.y * q.y; }
inline double cross(const Point &p, const Point &q) { return p.x * q.y - p.y * q.x; }

istream &operator>>(istream &is, Point &p) { is >> p.x >> p.y; return is; }

//-----直線-----//
struct Line
{
    Point a, b;
    Line(Point a, Point b) : a(a), b(b) {} /* 2点a, bを通る直線 */
};

/* 
 * "射影" (直線 l に点 p から垂線を引いた交点を求める)
 */
Point projection(const Line &l, const Point &p)
{
    Point d = l.b - l.a; // 直線 l の方向ベクトル
    Point h = d * (dot(p - l.a, d) / norm2(d)); // 正射影ベクトル
    return l.a + h;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    Point p1, p2; cin >> p1 >> p2;
    Line l(p1, p2);
    int q; cin >> q;
    while (q--) {
        Point p; cin >> p;
        Point x = projection(l, p);
        cout << x.x << ' ' << x.y << '\n';
    }
    return 0;
}



Measured memory_bytes: 3300
#include<bits/stdc++.h> 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ifor(n) for(int i=0;i<n;i++) 
#define jfor(n) for(int j=0;j<n;j++)
#define Ifor(n) for(int i=1;i<n;i++) 
#define Jfor(n) for(int j=1;j<n;j++)
const int inf=0x3f3f3f3f;
int main(){
   int a,b;
   cin>>a>>b;
   double l=a/0.08,h=(a+1)/0.08;
   int w=h;
   if(w==h)w--;
   int q=l;
   if(q<l)q++;
   l=b/0.1,h=(b+1)/0.1;
   int e=h;
   if(e==h)e--;
   int r=l;
   if(r<l)r++;
   if(e<q||w<r)cout<<-1<<endl;
   else{
		cout<<max(q,r)<<endl;
   }
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void N(int a[102][10], int t,int i) {
	t = a[i][0];
	a[i][0] = a[i][1];
	a[i][1] = a[i][5];
	a[i][5] = a[i][4];
	a[i][4] = t;
}

void S(int a[102][10], int t,int i) {
	t = a[i][0];
	a[i][0] = a[i][4];
	a[i][4] = a[i][5];
	a[i][5] = a[i][1];
	a[i][1] = t;
}

void E(int a[102][10], int t, int i) {
	t = a[i][0];
	a[i][0] = a[i][3];
	a[i][3] = a[i][5];
	a[i][5] = a[i][2];
	a[i][2] = t;
}

void W(int a[102][10], int t, int i) {
	t = a[i][0];
	a[i][0] = a[i][2];
	a[i][2] = a[i][5];
	a[i][5] = a[i][3];
	a[i][3] = t;
}

int main(void) {
	int a[102][10], t = 0, p = 0, c = 0, count = 0,flug=0,same = 0,flug2 = 0,ppp2 =0;
	char NEWS[100];

	for (int i = 0; i < 100; i++) {
		for (int k = 0; k < 6; k++) {
			a[i][k] = 0;
		}
	}
	
	scanf("%d", &c);
	for (int i = 0; i < c; i++) {
		for (int k = 0; k < 6; k++) {
			scanf("%d", &a[i][k]);
		}
	}

	for (int i = 0; i < c; i++) {
		for (int k = 0; k < 6; k++) {
			if (a[i][0] != a[k][0]);
		}
	}


	for (int i = 0; i < c; i++) {
		for (int k = i+1; k < c; k++) {
			flug = 0;
			for (int ppp = 0; ppp < 6; ppp++) {
				for (int ppp2 = ppp + 1; ppp2 < 6; ppp2++) {
					if ((a[i][ppp] == a[i][ppp2])) {
						same += 1;
					}
				}
				for (int r = 0; r < 6; r++) {
					if ((a[i][ppp] == a[k][r])) {
						break;
					}
					else if(r == 5){
						flug = 1;
					}
				}
			}
			if (flug == 0) {
				while ((a[i][0] != a[k][0] || a[i][1] != a[k][1])) {
					p = rand() % 4 + 1;
					if (p == 1) {
						N(a, t, i);
					}
					else if (p == 2) {
						E(a, t, i);
					}
					else if (p == 3) {
						W(a, t, i);
					}
					else if (p == 4) {
						S(a, t, i);
					}
					if ((same%c == 0) && (same/c >= 5)) {
						count += 1;
						break;
					}
					else if (same%c != 0) {
						break;
					}
					if (a[i][0] == a[k][0]) {
						if (a[i][5] == a[k][1]) {
							break;
						}
					}
				}
				if ((a[i][2] == a[k][2]) && (a[i][3] == a[k][3]) && (a[i][4] == a[k][4]) && (a[i][5] == a[k][5])) {
					count += 1;
				}else if (a[i][0] == a[k][0]) {
					if (a[i][5] == a[k][1]) {
						break;
					}
				}
			}
		}
	}
		
		if (count != 0) {
			printf("No\n");
		}else{
			printf("Yes\n");
		}
}



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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

int main() {
  _upgrade;
  int n, m;
  cin >> n >> m;
  int cnt = 0;
  double threshold = (double)1 / (4 * m);
  vector<int> A(n);
  int sum = 0;
  for (auto &a : A) {
    cin >> a;
    sum += a;
  }
  threshold *= sum;
  for (auto &a : A) {
    if (a >= threshold) {
      cnt++;
    }
  }
  if (cnt >= m) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<cstdio>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<functional>
#define pi 3.14159
#define Inf (int)pow(2., 12.)

using namespace std;
typedef std::pair<int, int> mypair;
queue<mypair> qu;
#define M 1000000
const int dy[4] = {0, 1, 0, -1}, dx[4] = {1, 0, -1, 0};
#define N 123456 
int num = 0;

int ToInt(string str) {
	int a = 0, n = (int)str.size();
	for(int i = 0; i < n; i++) {
		a += (str[i]-'0') * (int)pow(10., (double)(n-i-1));
	}
	return a;
}

string ToString(int a, int l) {
	string str;
	if(l == 6) str = "000000";
	if(l == 5) str = "00000";
	if(l == 4) str = "0000";
	if(l == 3) str = "000";
	if(l == 2) str = "00";
	if(l == 1) str = "0";
	for(int i = 0; i < l; i++) {
		int n = a / (int)pow(10., (double)(l-i-1));
			str[i] = n + '0';
			a -= n * (int)pow(10., (double)(l-i-1));
			}

	return str;
}

int main(){
	int l;
	string str;
	while(cin >> str >> l) {
		if(l == 0) break;
		int a[21], i, j;
		a[0] = ToInt(str);
		str = ToString(a[0], l);
		for(i = 0; i < 20; i++) {
			int max, min;
			sort(str.begin(), str.end());
			min = ToInt(str);
			reverse(str.begin(), str.end());
			max = ToInt(str);
			a[i+1] = max - min;
			bool bo = false;
			for( j = 0; j < i+1; j++) {
				if(a[j] == a[i+1]) {
					bo = true;
					break;
				}
			}
			if(bo) break;
			str = ToString(a[i+1], l);
		}
		cout << j << " " << a[j] << " " << i+1-j <<endl;
 	}
	return 0;
}

Measured memory_bytes: 1276
n= int(input())
a =list(map(int,input().split()))
a.sort()
a.reverse()
ans=0
if n%2==0:
    for i in range(0,int(n/2)):
        ans+= (a[i]*2)
    ans-= a[0]
else:
    for i in range(0,int((n-1)/2)):
        ans+=(a[i]*2)
    ans-= a[0]
    ans+=a[int((n-1)/2)]
print(ans)

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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp std::make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

#define fcout(n) std::cout << std::fixed << std::setprecision((n))

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::pair<int,int> PII;

typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::vector<PII> VPII;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

std::string S;
int w;
int main() {
    std::cin >> S;
    std::cin >> w;

    int len = S.length();
    for(int i=0; i<len/w+(len%w > 0); ++i) {
        std::cout << S[i*w];
    }
    std::cout << std::endl;
}

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

int main(void){
	int H,W;

	while (cin >> H >> W){
		if(H==0&&W==0) break;
		if(H>300||W>300||H<0||W<0) continue;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(i==0||i==H-1||j==0||j==W-1) cout << "#" ;
				else cout << "." ;
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
N = int(raw_input())
s = raw_input()
# 0: S, 1: W

def init():
    if s[0] == 'o':
        v = [-1 for i in range(N)]
        v[0], v[1], v[N-1] = 0, 1, 1
        yield v
        v = [-1 for i in range(N)]
        v[0], v[1], v[N-1] = 0, 0, 0
        yield v
        v = [-1 for i in range(N)]
        v[0], v[1], v[N-1] = 1, 0, 1
        yield v
        v = [-1 for i in range(N)]
        v[0], v[1], v[N-1] = 1, 1, 0
        yield v
    else:
        v = [-1 for i in range(N)]
        v[0], v[1], v[N-1] = 0, 0, 1
        yield v
        v = [-1 for i in range(N)]
        v[0], v[1], v[N-1] = 0, 1, 0
        yield v
        v = [-1 for i in range(N)]
        v[0], v[1], v[N-1] = 1, 1, 1
        yield v
        v = [-1 for i in range(N)]
        v[0], v[1], v[N-1] = 1, 0, 0
        yield v

def run():
    ok = False
    for v in init():
        ok = True
        for i in range(1, N):
            if s[i] == 'o':
                if v[i] == 0:
                    nv = v[i-1]
                else:
                    nv = 1-v[i-1]
            else:
                if v[i] == 0:
                    nv = 1-v[i-1]
                else:
                    nv = v[i-1]
            ni = (i+1) % N
            if (v[ni] > -1) and (v[ni] != nv):
                ok = False
                break
            v[ni] = nv 
        if ok:
            return ''.join(['S' if _ == 0 else 'W' for _ in v])
    return "-1"

print run()

Measured memory_bytes: 7540
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**18
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

H,W,A,B = map(int,input().split())
fac = [0]*(H+W)
finv = [0]*(H+W)
inv = [0]*(H+W)
fac[0]=fac[1]=1
finv[0]=finv[1]=1
inv[1]=1
for i in range(2,H+W):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i]*(mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
def comb(n,r):
    if n < r:
        return 0
    if n < 0 or r < 0 :
        return 0
    return fac[n]*(finv[r]*finv[n-r]%mod)%mod
ans = 0
for x in range(W-B):
    if x == 0:
        ans += ((comb(H-A-1+B+x,B+x))*comb(A+W-1-B-x,A))
    else:
        ans += ((comb(H-A-1+B+x,B+x)-comb(H-A-1+B+x-1,B+x-1))*comb(A+W-1-B-x,A))
    ans %= mod
print(ans)

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

int main() {
        int N, A, B, K;

        cin >> N;
        cin >> A >> B;
        cin >> K;
        vector<int> T(N);

        rep(n, N) {
                cin >> T.at(n);
        }
        sort(T.begin(), T.end());
        T.push_back(K);
        reverse(T.begin(), T.end());

//      rep (n, N+1) {
//              cout << T.at(n) << endl;
//      }
        int best = 0;
        rep (n, N+1) {
                if (accumulate(T.begin(), T.begin()+n+1, 0) / (A + (n*B)) > best) {
                        best = accumulate(T.begin(), T.begin()+n+1, 0) / (A + (n*B));
                }
        }
        cout << best << endl;

        return 0;
}



Measured memory_bytes: 3144
Imports System

Module Program
    Sub Main(args As String())

        Dim N As Long = Long.Parse(Console.ReadLine())

        Console.WriteLine(Ts(N))

    End Sub

    Public Function Ts(n As Long) As String

        Ts = ""
        If n = 0 Then Exit Function
        n -= 1
        Return (Ts(n \ 26) & Chr(Asc("a") + n Mod 26))

    End Function

End Module


Measured memory_bytes: 28300
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

int main(){
  int N; cin >> N;
  vector<vector<int>> to(N);vector<vector<int>> cost(N);
  
  for(int i = 1; i < N; i++){
    int a,b,w; cin >> a >> b >> w; a--; b--;
    to[a].push_back(b); cost[a].push_back(w);
    to[b].push_back(a); cost[b].push_back(w);}
  
  vector<int> ans(N,-1); queue<int> q;
  
  ans[0] = 0;
  q.push(0); 
  
  while(!q.empty()){
    int v = q.front();
    q.pop();
    
    for(int i = 0; i < to[v].size(); i++){
      int u = to[v][i]; int x = cost[v][i];
      if( ans[u] != -1){continue;}
      ans[u] = ( ans[v] + x ) % 2;
      
      q.push(u);}}
  
  for(int i = 0; i < ans.size(); i++){
    cout << ans[i] << endl;}
  
  return 0;}
      
  


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

int main() {
	string a;
	int ans=0;
	cin >> a;
	if (a[0] == '1') {
		ans=++ans;
	}
	if (a[2] == '1') {
		ans=++ans;
	}
	if (a[1] == '1') {
		ans=++ans;
	}
	cout <<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  ll dp[51][2] = {};
  ll a[50];
  int p, n;
  cin >> n >> p;
  REP(i, n)
  {
    cin >> a[i];
  }

  dp[0][0] = 1;
  dp[0][1] = 0;

  FOR(i, 1, n + 1)
  {

    if (a[i - 1] % 2 == 0)
    {
      dp[i][0] = dp[i - 1][0] * 2;
      dp[i][1] = dp[i - 1][1] * 2;
    }
    else
    {
      dp[i][1] = dp[i - 1][0] + dp[i - 1][1];
      dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
    }
  }
  cout << dp[n][p] << endl;
}


Measured memory_bytes: 256
s1=int(input())
s2=int(input())
s3=int(input())
s4=int(input())
s5=int(input())
s6=int(input())
s7=int(input())
s8=int(input())
s9=int(input())
s10=int(input())
print(s1+s2+s3+s4+s5+s6+s7+s8+s9+s10)


Measured memory_bytes: 5588
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;


int main(){
    int A, B, Q;
    vector<long long> s;
    vector<long long> t;
    vector<long long> x;
    
    // 入力
    cin >> A >> B >> Q;
    long long temp;
    for (int i=0;i<A;i++) {cin >> temp; s.push_back(temp);}
    for (int i=0;i<B;i++) {cin >> temp; t.push_back(temp);}
    for (int i=0;i<Q;i++) {cin >> temp; x.push_back(temp);}
    
    for (int i=0;i<Q;i++) {
        vector<long long>::iterator itr_s = upper_bound(s.begin(),s.end(),x[i]);
        vector<long long>::iterator itr_t = upper_bound(t.begin(),t.end(),x[i]);
        
        long long s_0,s_1,t_0,t_1;
        s_1 = *itr_s;
        if (itr_s!=s.begin()) {itr_s--; s_0 = *itr_s;}
        else {s_0 = -20000000000;}
        t_1 = *itr_t;
        if (itr_t!=t.begin()) {itr_t--; t_0 = *itr_t;}
        else {t_0 = -20000000000;}
        
        vector<long long> result(8);
        result[0] = abs(x[i]-s_0) + abs(t_0-s_0);
        result[1] = abs(x[i]-s_0) + abs(t_1-s_0);
        result[2] = abs(x[i]-s_1) + abs(t_0-s_1);
        result[3] = abs(x[i]-s_1) + abs(t_1-s_1);
        result[4] = abs(x[i]-t_0) + abs(s_0-t_0);
        result[5] = abs(x[i]-t_0) + abs(s_1-t_0);
        result[6] = abs(x[i]-t_1) + abs(s_0-t_1);
        result[7] = abs(x[i]-t_1) + abs(s_1-t_1);
        
//            vector<long long>::iterator itr_result = min_element(result.begin(),result.end());
//            cout << *itr_result << endl;
        
        cout << *min_element(result.begin(),result.end()) << endl;
    }
    
   
    
    
    // 出力
    //cout << MP_min << endl;
    //for (int i=0;i<A+B;i++) cout << u[i].a << " " << u[i].index << endl;
    //for (int i=0;i<Q;i++) cout << result[i].a << endl;
    
    return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int A[105];

int main() {
    int s=0,n,m,p,x;
    scanf("%d",&n);
    for(int i=1;i<=n;++i) {
        scanf("%d",&A[i]);
        s+=A[i];
    }
    scanf("%d",&m);
    for(int i=1;i<=m;++i) {
        scanf("%d %d",&p,&x);
        int r = A[p] - x;
        printf("%d\n", s-r);
    }
    return 0;
}

Measured memory_bytes: 256
using namespace std;
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define debug(x) cout << #x <<" = " << x << endl
#define MOD 1000000007
void solve()
{
ll n;
cin>>n;
ll arr[n];
ll sum=0;
for (int i = 0; i < n; i++)
{
    cin>>arr[i];
    sum+=arr[i];
    sum%=MOD;
}
ll ans=0;
for (int i = 0; i < n; i++)
{
    sum-=arr[i];
    sum=(sum+MOD)%MOD;
    ans=(ans+sum*arr[i])%MOD;
}
cout<<ans%MOD<<endl;
}
int main()
{
FASTIO
 long long int t;
 t=1;
 while(t--)
  solve();
  return 0;
}


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

int n;
int L[N];
int maxi;
int maxnumber;
int sum;
int main(){
    scanf("%d",&n);
    REP(i,n)scanf("%d",&L[i]);
    REP(i,n){
        if(maxi<L[i]){
            maxi=L[i];
            maxnumber=i;
        }
        sum+=L[i];
    }
    if(sum>maxi*2){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = RD!string;
	if (S[0] != 'A' || !inside(S[1]-'a', 0, 26) || !inside(S[$-1]-'a', 0, 26))
	{
		debug writeln("A", " ", S[1]-'a');
		writeln("WA");
	}
	else
	{
		debug writeln("B");
		bool ok = true;
		long cnt;
		foreach (c; S)
		{
			if (c == 'C')
				++cnt;
			else if (!inside(S[1]-'a', 0, 26))
				ok = false;
		}
		debug writeln(cnt, " ", ok);
		if (cnt != 1) ok = false;
		writeln(ok ? "AC" : "WA");
	}

	stdout.flush();
	debug readln();
}


Measured memory_bytes: 256
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    s=list(input())

# アルファベット小文字→(97, 123)を入力に入れる
# アルファベット大文字→(65, 91)
# 半角数字→(48, 58)
# ひらがな→(12353, 12436)
# カタカナ→(12449, 12532+1)
# 全角数字→(65296, 65306)



    def moji_list(*args):
        moji = []
        for i in range(len(args)):
            moji.extend([chr(j) for j in range(args[i][0], args[i][1])])
        return moji

    lowercase = moji_list((97,123))

    print(min(set(lowercase)-set(s) or ['None']))

resolve()

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

ll pow(ll a, ll n, ll m) {
	ll ret = 1LL;
	for (; n > 0LL; n >>= 1LL, a = a * a % m) {
		if (n % 2LL == 1LL) {
			ret = ret * a % m;
		}
	}
	return ret;
}

ll gcd(ll x, ll y) {
    if (x % y == 0) {
        return y;
    }
    else {
        return gcd(y, x % y);
    }
}


int main() {
  ll N;
  cin>>N;
  map<pair<ll,ll>,ll> m;
  ll cnt = 0LL;
  ll cnto = 0LL;
  ll cntb=0LL;
  for(ll i = 0LL;i < N; i++){
    ll A,B;
    cin>>A>>B;
    if(A==0LL&&B!=0LL) {cnt++;continue;}
    if(A==0LL&&B==0LL) {cnto++;continue;}
    if(A!=0LL&&B==0LL) {cntb++;continue;}
    else {
      ll t = (abs(A)/A)*(abs(B)/B);
      pair<ll,ll> p = make_pair(t*abs(B)/gcd(abs(A),abs(B)),abs(A)/gcd(abs(A),abs(B)));
      m[p]++;
    }
  }
  for(auto x:m) {
    ll a = x.first.first;
    ll b = x.first.second;
    pair<ll,ll> p = make_pair(-b*(abs(a)/a),abs(a));
    m[p];
  }
  ll ans = 1LL;
  for(auto x:m) {
    ll A = x.first.first;
    ll B = x.first.second;
    pair<ll,ll> p =  make_pair(-B*(abs(A)/A),abs(A));
    ll a = x.second;
    ll &b = m[p];
    ans*=(pow(2LL,a,mod)+pow(2LL,b,mod)-1LL)%mod;
    ans%=mod;
    m[x.first]=0LL;
    b=0LL;
  }
  ans*=(pow(2LL,cnt,mod)+pow(2LL,cntb,mod)-1LL)%mod;
  ans%=mod;
  ans+=cnto%mod;
  ans%=mod;
  ans--;
  if(ans<0LL) ans+= mod;
  cout<<ans<<endl;
}

Measured memory_bytes: 28496
x = int(input())

def Eratosthenes(x):
    n = [i for i in range(2,x+1)]
    prime_list = []

    while True:
        if n[0] >= x**0.5:
            prime_list.extend(n)
            break
        tmp = n.pop(0)
        prime_list.append(tmp)
        n = [i for i in n if i % tmp != 0]

    return prime_list

primes = Eratosthenes(10**5+3)

ans = x
while True:
    if x in primes:
        print(x)
        break
    else:
        x += 1

Measured memory_bytes: 48176
#include<bits/stdc++.h>
using namespace std;
int g1[100010],g2[100010],a[100010];
int gcd(int a,int b)
{
	int x=max(a,b),y=min(a,b);
	while(min(x,y)!=1)
	{
		x%=y;
		if(x==0)
		{
			return y;
		}
		int tmp=x;
		x=y;
		y=tmp; 
	}
	return 1; 
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	g1[0]=a[0];
	for(int i=1;i<n;i++)
	{
		g1[i]=gcd(g1[i-1],a[i]);
	}
	g2[n-1]=a[n-1];
	for(int i=n-2;i>=0;i--)
	{
		g2[i]=gcd(g2[i+1],a[i]);
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(i==0)
		{
			ans=max(ans,g2[i+1]);
		}
		else
		{
			if(i==n-1)
			ans=max(ans,g1[i-1]);
			else
			ans=max(gcd(g1[i-1],g2[i+1]),ans);	
		}
	}
	cout<<ans;
	return 0;	
}

Measured memory_bytes: 1408
#include <stdio.h>

int main(void)
{
	int num;
	float bmi;
	float kg;
	float h;
	
	while (scanf("%d,%f,%f", &num, &kg, &h) != EOF){
		if (25 <= kg / (h * h)){
			printf("%d\n", num);
		}
	}
	
	return (0);
}

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

typedef long long ll;

int main(){
  string s; cin >> s;
  int n=s.length();

  ll ans=0;
  for(int i=0; i<(1<<(n-1)); i++){
    int index=0;
    for(int j=0; j<(n-1); j++){
      if((i>>(n-2-j)) & 1){
        ans += stol(s.substr(index, j-index+1));
        index = j+1;
      }
    }
    ans += stol(s.substr(index, n-index));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a[4],b[4];
	while(cin >> a[0] >> a[1] >> a[2] >> a[3]){
		int hit = 0 , bro = 0;
		for(int i=0;i<4;i++)	cin >> b[i];
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				if(a[i]==b[j]){
					if(i==j)	hit++;
					else	bro++;
				}
			}
		}
		cout << hit << ' ' << bro << endl; 
	}
}


Measured memory_bytes: 3060
n = int(input())
a = input().split()
even = []
even_counter = 0
div = 0

for i in a:
  int_a = int(i)
  if int_a % 2 == 0:
    even.append(int_a)
    even_counter += 1

for i in range(even_counter):
  if int(even[i]) % 3 == 0 or int(even[i]) % 5 == 0:
    div += 1

if div == even_counter:
  print("APPROVED")
else:
  print("DENIED")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int32_t main()
{
set<string>s;
  string a;
  int n;cin>>n;
  for(int i=0;i<n;i++)
  {cin>>a;s.insert(a);
  }
  cout<<s.size();
  return 0;
}
  


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

int N, M;
int A[1002], B[1002];

void solve(){
  int vote[1002] = {0};
  int ans = -1;
  int ansVote = -1;

  for(int i = 0; i < M; i++){
    for(int j = 0; j < N; j++){
      if(A[j] <= B[i]){
        vote[j]++;
        if(vote[j] > ansVote){
          ans = j + 1;
          ansVote = vote[j];
        }
        break;
      }
    }
  }

  cout << ans << endl;
}

int main(){
  while(cin >> N >> M){
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < M; i++) cin >> B[i];
    solve();
  }
}

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

int H, W;
int field[60][60];


void dfs(int h, int w) {
    field[h][w]=0;
    
    for (int dx = -1; dx <= 1; dx++) {
        for(int dy=-1;dy<=1;dy++){
            int nh = h + dx;
            int nw = w + dy;

            // 場外アウトしたり、移動先が壁の場合はスルー
            if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
            if (field[nh][nw] == 0) continue;

            // 再帰的に探索
            dfs(nh, nw);
        }
        
    }
}

int main() {

    while(1){
        cin >> W >> H;
        if(H==0 && W==0) break;
        rep(i,H) rep(j,W) cin>>field[i][j];

        int ans=0;
        rep(i,H){
            rep(j,W){
                if(field[i][j]==0) continue;
                dfs(i,j);
                ans++;
            }
        }

        cout<<ans<<endl;
    }
}





Measured memory_bytes: 3168
#include <stdio.h>

int main(void)
{
    int i,n;
    int num[3][8] ,s=0,fn1[4],fn2[4];
    double times[3][100] ,ft1[4]={0},ft2[4]={0},ot[18],on[18];
    for(i=0;i<3;i++){
        for(n=0;n<8;n++){
            scanf("%d %lf", &num[i][n] ,&times[i][n]);
        }
    }
    for(i=0;i<3;i++){
        for(n=0;n<8;n++){
            if(times[i][n]<ft1[i]||ft1[i] == 0){
                if(ft2[i] != 0.0){
                    ot[s] = ft2[i];
                    on[s] = fn2[i];
                    s++;
                }
                ft2[i] = ft1[i];
                fn2[i] = fn1[i];
                ft1[i] = times[i][n];
                fn1[i] = num[i][n];
            }else if(times[i][n]<ft2[i]||ft2[i] == 0){
                if(ft2[i] != 0){
                    ot[s] = ft2[i];
                    on[s] = fn2[i];
                    s++;
                }
                ft2[i] = times[i][n];
                fn2[i] = num[i][n];
            }else{
                ot[s] = times[i][n];
                on[s] = num[i][n];
                s++;
            }
        }
        printf("%d %.2f\n" ,fn1[i],ft1[i]);
        printf("%d %.2f\n" ,fn2[i],ft2[i]);
    }
    for(i=0;i<s;i++){
        if(ot[i]<ft1[3] || ft1[3] == 0){
            ft2[3] = ft1[3];
            fn2[3] = fn1[3];
            ft1[3] = ot[i];
            fn1[3] = on[i];
        }else if(ot[i]<ft2[3] || ft2 == 0){
            ft2[3] = ot[i];
            fn2[3] = on[i];
        }
    }
    
    printf("%d %.2f\n" ,fn1[3] ,ft1[3]);
    printf("%d %.2f\n" ,fn2[3] ,ft2[3]);
    return 0;
}

Measured memory_bytes: 652
#include <cstdio>
main(){int A,B,C,D,i;scanf("%1d%1d%1d%1d",&A,&B,&C,&D);for(i=0;i<8;i++)if(A+(i/4%2?-B:B)+(i/2%2?-C:C)+(i%2?-D:D)==7){char p[]={'+','-'};printf("%d%c%d%c%d%c%d=7\n",A,p[i/4%2],B,p[i/2%2],C,p[i%2],D);return 0;}}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    
    int n = 0, s = 0;
    cin >> n;
    int nn = n;
    
    while(n > 0){
        s += (n % 10);
        n /= 10;
    }
    cout << ((nn % s == 0) ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int h,w;
  int a,b;
  cin>>h>>w>>a>>b;
  if(h==a && w==b){
  cout<<"0";
  return 0;}
  cout<<(h*w)-(a*w+b*h-a*b);
}

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

using namespace std;

const int MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;
#define rep(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)


ll dp[1000100][2];

int main() {
    string L;
    cin >> L;
    int n = L.length();

    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        if (L[i - 1] == '1') {
            dp[i][0] += 2 * dp[i - 1][0] % MOD;
            dp[i][1] += dp[i - 1][0] % MOD;
        } else {
            dp[i][0] += dp[i - 1][0] % MOD;
        }
        dp[i][1] += dp[i - 1][1] * 3 % MOD;
    }
    cout << (dp[n][0] + dp[n][1]) % MOD << endl;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

ll x[2000],y[2000],z[2000],ans;
int n,m;
void solve(){
    for(int a = 1; a>=-1; a-=2){
        for(int b=1; b>=-1; b-=2){
            for(int c=1; c>=-1; c-=2){
                ll tx[2000],ty[2000],tz[2000],val[2000];
                for(int i=1;i<=n;i++){
                    tx[i] = x[i] * a;
                    ty[i] = y[i] * b;
                    tz[i] = z[i] * c;
                    val [i] = tx[i] + ty[i] + tz[i];
                }
                sort(val+1,val+1+n);
                ll sum = 0;
                for(int i=n;i>=n-m+1;i--){
                    sum += val[i];
                }
                ans = max(ans,sum);


            }
        }
    }

}
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>x[i]>>y[i]>>z[i];
    solve();
    cout<<ans<<newl;
}


Measured memory_bytes: 256
<?php
$n = intval(trim(fgets(STDIN)));
$a = intval(trim(fgets(STDIN)));
$yn = "No";

for($i = 0; $i <= $a; $i++) {
		if(($n - $i) % 500 == 0) {
			$yn = "Yes";
			break;
		} 
}
echo $yn."\n";
?>


Measured memory_bytes: 4604
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin >> n;
    int x[n];
    int y[n];
    for(int i = 0;i<n;i++){
        cin >> x[i];
        y[i] = x[i];
    }
    sort(y,y+n);
    int ans1 = y[n/2-1];
    int ans2 = y[n/2];
    for(int i = 0;i<n;i++){
        if(ans2<=x[i]) cout << ans1 << endl;
        else cout << ans2 << endl;
    }
}

Measured memory_bytes: 3712
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#define N 5005
using namespace std;
typedef long long ll;
const ll mod = 1000000007LL;
int n, k;
int a[N];
ll dp[N][N];
int main() {
	cin>>n>>k;
	for (int i = 0; i < n; ++i) {
		cin>>a[i];
	}
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < k; ++j) {
			dp[i+1][j] += dp[i][j];
			dp[i+1][min(j+a[i],k)] += dp[i][j]; 
		}
		dp[i+1][k] += dp[i][k];
	}
	int ans=0;
	for (int i = 0; i < n; ++i) {
		ll tmp[N];
		for (int j = 0; j <= k; ++j) {
			tmp[j] = dp[n][j];
		}
		for (int j = 0; j < k; ++j) {
			if (j < k-a[i]) {
				tmp[j+a[i]] -= tmp[j];
			} else {
				if (tmp[j]) {
					ans++;
				//	cout<<i<<endl;
					break;
				}
			}
		}
	}
	cout<<n-ans<<endl;
	return 0;
}

Measured memory_bytes: 195968
import java.util.*;
 
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String date = sc.next();

        if (date.equals("SUN")) {
            System.out.println(7);
        } else if (date.equals("MON")) {
            System.out.println(6);
        } else if (date.equals("TUE")) {
            System.out.println(5);
        } else if (date.equals("WED")) {
            System.out.println(4);
        } else if (date.equals("THU")) {
            System.out.println(3);
        } else if (date.equals("FRI")) {
            System.out.println(2);
        } else if (date.equals("SAT")) {
            System.out.println(1);
        }
	}
}


Measured memory_bytes: 21844
from math import sqrt

Q = int(input())

for i in range(Q):
    A,B = map(int, input().split())
    m=A*B

    C = int(sqrt(m))
    if C*C==m:
        C=C-1

    if A==B or B==A+1:
        ans = 2*A-2
    elif A==B+1:
        ans = 2*B-2
    elif C*(C+1)<m:
        ans = 2*C-1
    else:
        ans = 2*C-2
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    map<ll, ll> mp;
    int a;
    rep(0, i, N)
    {
        cin >> a;
        if (a >= 3200)
        {
            a = 3200;
        }
        a /= 400;
        mp[a]++;
    }

    int min_ans, max_ans;
    if (mp[8] == 0)
    {
        min_ans = mp.size() - 1;
        max_ans = mp.size() - 1;
    }
    else
    {
        min_ans = mp.size() - 1;
        max_ans = mp.size() - 1 + mp[8];
        if (min_ans == 0)
        {
            min_ans++;
        }
    }

    cout << min_ans << ' ' << max_ans << endl;
}

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

class Mod{
    static final long MOD = 1000_000_007;
    static final long[] fact = makeFactorialArray(1000000);
    static final long[] factInv = makeInversedArray(fact);

    public static long add(long a, long b){
        long tmp = (a+b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long adds(long... ar){
        long ans=0;
        for(long x:ar) ans = Mod.add(ans, x);
        return ans;
    }
    public static long sub(long a, long b){
        return add(a,-b);
    }
    public static long mult(long a, long b){
        long tmp = (a*b)%MOD;
        return tmp>=0 ? tmp : tmp+MOD;
    }
    public static long mults(long... ar){
        long ans=1;
        for(long x:ar) ans = Mod.mult(ans, x);
        return ans;
    }
    public static long power(long a, long x){ //calculate a^x
        if(x<0)return 0;
        if(x==0)return 1;
        if(x%2==0) {
            long half = power(a,x/2);
            return mult(half,half);
        }
        return (a*power(a,x-1)) % MOD;
    }
    public static long inverse(long a){
        return power(a,MOD-2);
    }
    public static long div(long a, long b){
        return mult(a, inverse(b));
    }
    public static long[] makeFactorialArray(int size){
        long[] array = new long[size];
        array[0]=1;
        for(int i=1;i<size;i++){
            array[i]=mult(array[i-1],i);
        }
        return array;
    }
    public static long[] makeInversedArray(long[] original){
        long[] array = new long[original.length];
        for(int i=0;i<original.length;i++){
            array[i] = inverse(original[i]);
        }
        return array;
    }
    public static long combination(long n, long r){
        int N = (int)n,  R = (int)r;
        if(n<0 || r<0 || n<r) return 0;
        return mults(fact[N],factInv[R],factInv[N-R]);
    }
    public static long permutation(long n, long r){
        int N = (int)n,  R = (int)r;
        if(n<0 || r<0 || n<r) return 0;
        return mult(fact[N], factInv[N-R]);
    }
}

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] x = new long[N];
        for(int n=0; n<N; n++) x[n]=sc.nextLong();
        long[] d = new long[N-1];
        for(int n=0; n<N-1; n++) d[n]=x[n+1]-x[n];

        long[] c = new long[N-1];
        Arrays.fill(c,0L);


        long[] unitfracsum = new long[110000];
        for(int i=1; i<110000; i++) unitfracsum[i] = Mod.add(unitfracsum[i-1], Mod.inverse(i));

        for(int i=0; i<N-1; i++){
            c[i] = Mod.mults(Mod.fact[i+1], unitfracsum[i+1], Mod.permutation(N-1, N-i-2));
        }


        long ans = 0;
        for(int n=0; n<N-1; n++) ans = Mod.add(ans, Mod.mult(d[n], c[n]));
        System.out.println(ans);


    }

}


Measured memory_bytes: 80652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
using static CS_Contest.Utils;

namespace CS_Contest {
	using Li = List<int>;
	using LLi = List<List<int>>;
    class Program {
        static void Main(string[] args) {
			new Calc().Solve();
			return;
        }

		private class Calc {
			Li NM;
			Tree g;
			public void Solve() {
				NM = ReadInt(' ');
				g = new Tree(NM[0]);
				string IMP = "IMPOSSIBLE", POS = "POSSIBLE";
				REP(NM[1], x => {
					var ab = ReadInt(' ').Select(y=>y-1).ToList();
					g.Add(ab[0], ab[1]);
				});
				if (dfs(0, 0)) POS.WL();
				else IMP.WL();
				return;
			}
			bool dfs(int from,int step) {
				if (step > 2) return false;
				if (step == 2) return from == NM[0] - 1;
				return g.Graph[from].Any(x => dfs(x, step + 1));
			}
		}
    }

	
	
    public static class Utils {
        public static void WL(this object obj) => WriteLine(obj);
        public static void WL(this string obj) => WriteLine(obj);
        public static void WL<T>(this IEnumerable<T> list) => list.ToList().ForEach(x => x.WL());
		public static int ReadInt() => int.Parse(ReadLine());
		public static List<int> ReadInt(char s) => ReadLine().Split(s).Select(int.Parse).ToList();
		public static long ReadLong() => long.Parse(ReadLine());
		public static List<long> ReadLong(char s) => ReadLine().Split(s).Select(long.Parse).ToList();
		public static void REP(int n,Action<int> act) {
			for (int i = 0; i < n; i++) {
				act(i);
			}
		}
		public static void RREP(int n,Action<int> act) {
			for (int i = n-1; i >=0; i--) {
				act(i);
			}
		}
		public static void Yes() => "Yes".WL();
		public static void No() => "No".WL();

		public class Tree {
			public LLi Graph;
			public Tree(int nodes) {
				Graph = new LLi();
				REP(nodes, x => {
					Graph.Add(new Li());
				});
			}
			public void Add(int x,int y) {
				Graph[x].Add(y);
				Graph[y].Add(x);
			}
		}
    }
}


Measured memory_bytes: 40544