akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <numeric>
using namespace std;

long long sai(long long a, long long b)
{
  if (a % b == 0) {
    return b;
  }
  else {
    return sai(b, sai(b, a % b));
  }
}

long long lcm(long long a, long long b)
{
  return a * b / sai(a, b);
}

int main()
{
  long long a, b;
  long long ans;
  cin >> a >> b;

  ans = lcm(a, b);

  cout << ans << endl;

  return 0;
}


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

using namespace std;


int main(void){
  string s, rs;
  cin >> s;

  int cnt = 0;
  int len = s.size();

  for (int i = 0; i < len; ++i){
    if(i >= len - i - 1)
      break;
    if(s[i] != s[len-i-1])
      ++cnt;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>

int main() {
	int n,s;
	std::cin >> n;

	for (int i = 1; i <= 9; i++) {

		s = 111 * i;

		if (n <= s) {
			std::cout << s << std::endl;
			exit(0);
		}
	}

	

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define endl '\n'
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 <<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* coma = strchr(names + 1, ',');cerr.write(names, coma - names) << " : " << arg1<<" | ";__f(coma+1, args...);
}
#else
#define trace(...)
#endif
 
void file() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

void fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
}

void lcs( string X, string Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
   int index = L[m][n]; 
   char lcs[index+1]; 
   lcs[index] = '\0';
   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs[index-1] = X[i-1];  
          i--; j--; index--;
      } 

      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
   cout <<lcs; 
} 

int main(int argc, char const *argv[])
{
    // file();
    fast();
    string a, b;cin>>a>>b; 
    int m = a.size(); 
    int n = b.size(); 
    lcs(a, b, m, n); 
}

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

int main()
{
	long long N;
	scanf("%lld", &N);
	
	stack<char> chars;
	while(N > 0)
	{
		long long lastDigit = N % 26;
		if(lastDigit == 0)
			lastDigit = 26;
			
		char lastChar = 'a' + (lastDigit - 1);
		chars.push(lastChar);
		
		N -= lastDigit;
		N /= 26;
	}
	
	while(!chars.empty())
	{
		printf("%c", chars.top());
		chars.pop();
	}
}


Measured memory_bytes: 3708
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;

    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);

    int N = in.nextInt();
    int arr[] = new int[N];

    for (int i = 0; i < N; i++) {
      arr[i] = in.nextInt();
    }

    out.println(Frog.frogOne(N, arr));

    out.close();
  }
}

class InputReader {
  public BufferedReader reader;
  public StringTokenizer tokenizer;

  public InputReader(InputStream stream) {
    reader = new BufferedReader(new InputStreamReader(stream), 32768);
    tokenizer = null;
  }

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

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

}

class Frog {
  public static int frogOne(int N, int[] h) {
    int[] dp = new int[N];

    Arrays.fill(dp, Integer.MAX_VALUE);
    dp[0] = 0;

    for (int i = 0; i < N; i++) {
      for (int j : new int[]{i + 1, i + 2}) {
        if (j < N) {
          dp[j] = Math.min(dp[j], dp[i] + Math.abs(h[i] - h[j]));
        }
      }
    }

    return dp[N - 1];
  }
}


Measured memory_bytes: 33940
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    string s;
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Read();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        if((s[0] == s[s.Length-1] && s.Length % 2 == 0) || (s[0] != s[s.Length-1] && s.Length % 2 == 1)){
            sb.Append("First\n");
        }
        else{
            sb.Append("Second\n");
        }
    }
    void Read(){
        s = Console.ReadLine();
    }    
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

bool palin(string s){
  int n = s.length();
  for(int i=0;i<n/2;i++) if(s[i]!=s[n-i-1]) return 0;
  return 1;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  string s;cin >> s;
  int n = s.length();
  if(palin(s) && palin(s.substr(0,(n-1)/2)) && palin(s.substr((n+1)/2,(n-1)/2))){
    cout << "Yes\n";
  }else cout << "No\n";
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}


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

int main(void)
{
    int n, m, x_now, y_now;
    cin >> n;
    cin >> m;
    cin >> x_now;
    cin >> y_now;
    int x_want[n];
    int y_want[m];
    for (int i = 0; i < n; i++)
    {
        cin >> x_want[i];
    }
    for (int i = 0; i < m; i++)
    {
        cin >> y_want[i];
    }
    int x_max = -1000;
    int y_min = 1000;
    for (int i = 0; i < n; i++)
    {
        if (x_want[i] > x_max)
        {
            x_max = x_want[i];
        }
    }
    for (int i = 0; i < m; i++)
    {
        if (y_want[i] < y_min)
        {
            y_min = y_want[i];
        }
    }

    if (x_now > x_max)
    {
        x_max = x_now;
    }
    if (y_now < y_min)
    {
        y_min = y_now;
    }

    if (x_max >= y_min)
    {

        cout << "War" << endl;
    }
    else
    {

        cout << "No War" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  bool ok = [scanElem,scanElem,scanElem,scanElem].sort().array==[1,4,7,9];
  if(ok)end("YES");end("NO");
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N, A, B;
		N = sc.nextLong();
		A = sc.nextLong();
		B = sc.nextLong();
		sc.close();
		long a = N / (A + B);

		if (N % (A + B) == 0) {
			long b = a;
			System.out.println(A * b);
		} else {
			long b = a + 1;
			long c = b * (A + B);
			if (c > N) {
				c = c - B;
				if (c > N) {
					c = c - N;
					c=A-c;
					System.out.println(A * (b-1) + c);
				} else {
					System.out.println(A * b);
				}
			}
		}
	}
}


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

const long long MOD = 1e9 + 7;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> d(H, vector<char>(W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> d[i][j];
        }
    }
    vector<vector<long long>> dp(H, vector<long long>(W, 0));
    dp[0][0] = 1;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (d[i][j] == '#') continue;
            if (i > 0) dp[i][j] += dp[i - 1][j];
            if (j > 0) dp[i][j] += dp[i][j - 1];
            dp[i][j] %= MOD;
        }
    }
    cout << dp[H - 1][W - 1] << endl;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
char S[3][102];
char res[4];
int main(){
  int i;
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<3;Lj4PdHRW++){
      rd(S[Lj4PdHRW]);
    }
  }
  for(i=0;i<3;i++){
    res[i] = S[i][0];
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// char S[3][102];
// char res[4];
// {
//   int i;
//   rd(S(3));
//   rep(i,3) res[i] = S[i][0];
//   wt(res);
// }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,x,y;
    cin >> n >> k >> x >> y;
    if(n<=k){
        cout << n*x << endl;
    }else if(n>k){
        cout << k*x + (n-k)*y << endl;
    }
}




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

int main(){
    long N;
    cin >> N;
    vector<pair<long, long>> D(N);
    for(auto& i : D)cin >> i.first >> i.second;

    sort(D.rbegin(), D.rend(), [](auto a, auto b){return a.first + a.second < b.second + b.first;});

    long long A(0), B(0), d(0);
    for(auto i : D){
        if(!d)A += i.first;
        else B += i.second;
        d ^= 1;
    }
    cout << A - B << endl;
}

Measured memory_bytes: 1792
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <ostream& out = cout, class... T> void prints(T&&...){ }
template <ostream& out = cout, class... T> void printd(T&&...){ }
template <ostream& out = cout, class... T> void printb(T&&...){ }
template <ostream& out = cout, class... T> void printArr(T&&...){ }
#endif

ll modPow(ll base, ll ex, ll m) {
	ll ret = 1;
	while(ex){
		if(ex & 1){
			ret = ret * base % m;
		}
		ex >>= 1;
		base = base * base % m;
	}
	return ret;
}

ll modFact(ll n, ll m){
	if(!n){ return 1; }
    static vector<ll> memo = {1, 1};
    if(n < (ll)memo.size()){ return memo[n]; }
    for(int i=memo.size();i<=n;i++){
        memo.push_back(memo.back() * i % m);
    }
    return memo[n];
}

ll modInv(ll n, ll m){
	return modPow(n, m-2, m);
}

ll modC(ll n, ll k, ll m){
	return modFact(n, m) * modInv(modFact(k, m) * modFact(n-k, m) % m, m) % m;
}

int main(){
    int n; cin >> n;
    vector<int> as(n + 1);
    unordered_map<int, int> us;
    int p1, p2;
    for(int i = 0; i < n + 1; i++){
        cin >> as[i];
        if(us.count(as[i])){
            p1 = us[as[i]];
            p2 = i;
        }
        us[as[i]] = i;
    }
    int w = p2 - p1 + 1;
    for(int k = 1; k <= n + 1; k++){
        printd(n + 1, k, n + 1 - w, k - 1);
        ll ans = modC(n + 1, k, M);
        if(n + 1 - w >= k - 1){
            ans -= modC(n + 1 - w, k - 1, M);
            ans = (ans + M) % M;
        }
        cout <<  ans  << '\n';
    }
    return 0;
}


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

int main() {
  int sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;
  int y = ty - sy;
  int x = tx - sx;
  
  string s;
  for (int i = 0; i < x; i++) s = s + 'R';
  for (int i = 0; i < y; i++) s = s + 'U';
  for (int i = 0; i < x; i++) s = s + 'L';
  for (int i = 0; i < y+1; i++) s = s + 'D';
  for (int i = 0; i < x+1; i++) s = s + 'R';
  for (int i = 0; i < y+1; i++) s = s + 'U';
  s = s + 'L' + 'U';
  for (int i = 0; i < x+1; i++) s = s + 'L';
  for (int i = 0; i < y+1; i++) s = s + 'D';
  s = s + 'R';
  
  cout << s << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main(){
  char s[6],sunuke[]="snuke";
  int h,w,i,j;
  scanf("%d%d",&h,&w);
  for(i=1;i<=h*w;i++){
    scanf("%s",s);
    if(strcmp(s,sunuke)==0) break;
  }
  printf("%c%d",i%w?i%w+64:w+64,(i-1)/w+1);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <unordered_map>
using namespace std;

static int x[256];
int main(void) {
	// 自分の得意な言語で
	// Let's チャレンジ！！

	string str;

	cin >> str;
	for(int i = 0; i < 4;i++)
		x[str[i]]++;
	int j;
	for ( j = 0; j < 256; j++)
		if (x[j] != 0 && x[j] != 2)
			break;
	cout << ((j != 256) ? "No" : "Yes") << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <cctype>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	vector<int> n(5);
	REP(i, 5) cin >> n[i];
	vector<int> P = { 0,1,2,3,4 };
	int final_answer = 1012345678;
	do {
		int ans = 0;
		for (int i = 0; i < 5; i++) {
			while (ans % 10 != 0) ans++;
			ans += n[P[i]];
		}
		final_answer = min(final_answer, ans);
	} while (next_permutation(P.begin(), P.end())); //順列を生成
	cout << final_answer << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
#define debug(var) cout << "[" << #var << "] " << var << endl
const ll mod = 1000000007;
const int INF = 1001001001;

int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    sort(h.begin(), h.end());
    ll ans = INF;

    rep(i, n-k+1) {
        ans = min(ans, h[i+k-1]-h[i]);
    }
    

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


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

int main() {
  string a;
  cin >> a;
  vector<vector<int>> al(26);
  rep(i, a.size()) al[a[i]-'a'].emplace_back(i);
  ll b = 0;
  rep(i, al.size()) {
    ll s = al[i].size();
    b += s * (s - 1) / 2;
  }
  ll as = a.size();
  ll total = as * (as - 1) / 2;
  cout << total - b + 1 << endl;
}


Measured memory_bytes: 1908
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

bool dp1[8000];
bool dp2[8000];
signed main() {
	int a,b,c,d,e,f;cin>>a>>b>>c>>d>>e>>f;
	dp1[0]=true;
	dp2[0]=true;
	rep(i,4000){
		if(!dp1[i])continue;
		dp1[i+100*a]=true;
		dp1[i+100*b]=true;
	}
	rep(i,4000){
		if(!dp2[i])continue;
		dp2[i+c]=true;
		dp2[i+d]=true;
	}
	double Max=0;
	int A=100*a,B=0;
	rep(i,4000){
		rep(j,4000){
			if(j&&dp1[i]&&dp2[j]&&i+j<=f&&(i/100)*e>=j&&j/(double)(i+j)>=Max){
				Max=j/(double)(i+j);
				A=i+j;
				B=j;
			}
		}
	}
	cout<<A<<' '<<B<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long a[200005],b[200005]={0},c[200005],d[200005];
int main()
{
    long long n,i,j,x,k=1,total=0,z,l,m;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        x=a[i];
        if(b[x]==0)
        {
            c[k]=x;
            k++;
        }
        b[x]=b[x]+1;
    }
    for(j=1;j<k;j++)
    {
        x=c[j];
        d[x]=(b[x]*(b[x]-1))/2;
        total+=d[x];
    }
    for(i=1;i<=n;i++)
    {
        x=a[i];
        z=total-d[x];
        l=b[x]-1;
        m=(l*(l-1))/2;
        cout<<(z+m)<<endl;        
    }
    return 0;    
}

Measured memory_bytes: 9288
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
#include <stdlib.h>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define m_t make_tuple
#define rep(i,n)  for(int i=0; i<(int) (n); i++)


const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 1000000021;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	return lower_bound(all(vec), xx) - vec.begin();
}
template<typename T>
void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>
void vecin(vector<TT>& vec) {
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}


// テーブルを作る前処理
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;
	}
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す
// 二項係数計算
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;
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx <= 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int n, w,a,b,ans=0;
	cin >> n >> w;
	vector<vector<int>>vec(n+1, vector<int>(w+1));
	for(int i=1; i<=n; i++) {
		cin >> a >> b;
		rep(j, w+1) {
			vec[i][j]=vec[i-1][j];
			if (j - a >= 0) vec[i][j] = max(vec[i][j] , vec[i-1][j - a] + b);
		}
	}
	rep(i, w + 1) {
		ans = max(ans, vec[n][i]);
	}
	cout <<ans<< endl;
}


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

int main() {
	int A, B;
	cin >> A >> B;
	int ans = 0;
	for (int i = 0;i < 2;++i) {
		if (A < B ) {
			ans += B;
			B = B - 1;
		}
		else {
			ans += A;
			A = A - 1;
		}
	}
	cout << ans << endl;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		scanner.nextLine();
		System.out.println(Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).map(i -> i - 1).sum());;
	}
}


Measured memory_bytes: 26960
#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[]) {
    
    
    int Cards[4][13],i,j,n,number;
    char suit;
    
    for (i = 0; i < 4; i++) {
        for (j =0 ; j < 13; j++) {
            Cards[i][j] = 1;
        }
    }

    scanf("%d",&n);
    
    for (i = 0; i < n*2; i++) {
        
        scanf("%c %d",&suit,&number);
        if(suit == 'S') {
            Cards[0][number-1] = 0;
        } else if (suit == 'H') {
            Cards[1][number-1] = 0;
        } else if (suit == 'C') {
            Cards[2][number-1] = 0;
        }  else if (suit == 'D') {
            Cards[3][number-1] = 0;
        }
        
    }
    
    for (i = 0; i < 4; i++) {
        for (j = 0; j < 13; j++) {
            
            if (Cards[i][j] == 1) {
                
                if (i == 0) {
                    printf("S ");
                } else if (i == 1) {
                    printf("H ");
                } else if (i == 2) {
                    printf("C ");
                } else if (i == 3) {
                    printf("D ");
                }
                
                printf("%d\n",j+1);
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
int n,a[27],m[27];
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    memset(m,0x3f,sizeof(m));
    for(int i=1;i<=n;i++)
    {
        memset(a,0,sizeof(a));
        string s;
        cin>>s;
        for(int j=0;j<s.length();j++)
            a[s[j]-'a'+1]++;
        for(int j=1;j<=26;j++)
            m[j]=min(m[j],a[j]);
    }
    for(int i=1;i<=26;i++)
        for(int j=1;j<=m[i];j++)
            cout<<char(i+'a'-1);
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a,b,c,x,i,j,k,r=0;
    scanf("%d%d%d%d",&a,&b,&c,&x);
    for(i=0;i<=x/500;i++)for(j=0;j<=(x-500*i)/100;j++){
        k=x-500*i-100*j;
        r+=k%50==0&&c>=k/50&&a>=i&&b>=j;
    }
    printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

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

    int takahashi_attack_times = c / b;
    if (c % b) {
        takahashi_attack_times++;
    }

    int aoki_attack_times = a / d;
    if (a % d) {
        aoki_attack_times++;
    }

    if (takahashi_attack_times <= aoki_attack_times) {
        cout << "Yes" << endl;
    }

    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<ctime>
#include<map>
#define R(i, n) for(int i = 0;i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", a + i)
#define SAL(i, n, a) R(i, n) scanf("%lld", a + i)
#define SC(a) scanf("%c", &a);
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
#define PY printf("Yes");
#define PN printf("No");
#define Py printf("yes");
#define Pn printf("no");
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;
const double PI = acos(-1);

int A, B, H, M;

int main() {
	S3(A, B, H);
	S(M);
	double ax = A * cos(2 * M_PI * (60 * H + M) / 720);
	double ay = A * sin(2 * M_PI * (60 * H + M) / 720);
	double bx = B * cos(2 * M_PI * M / 60);
	double by = B * sin(2 * M_PI * M / 60);
	double ans = sqrt(pow(ax - bx, 2.0) + pow(ay - by, 2.0));
	printf("%.12lf", ans);
}

Measured memory_bytes: 4172
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> x(N);
    for (auto &&i : x) {
        cin >> i.first >> i.second;
    }

    SORT(x);
    ll ans  = 0;
    int cnt = 0;
    for (auto &&i : x) {
        if (cnt < M) {
            ans += (ll)i.first * i.second;
            cnt += i.second;
        }
        if (M <= cnt) {
            ans -= (ll)i.first * (cnt - M);
            break;
        }
    }
    print(ans);

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

void solve(int test_case) {
	int n;
	cin>>n;
	unordered_map<int,int> m;
	int mx = 0;
	while(n--) {
		int val;
		cin>>val;
		m[val]++;
		mx=max(mx,val);
	}
	int ans=0;
	for(int i=0;i<=mx;i++) {
		ans=max(ans,m[i]+m[i-1]+m[i+1]);
	}
	cout<<ans;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 7368
#include<bits/stdc++.h>
#define ll long long
#define nes ios_base :: sync_with_stdio(0); cin.tie(0);
using namespace std;
ll product(ll n){
	return (n*(n+1))/2;
}
int main(){
	nes;
	ll x;
	cin>>x;
	ll l=0,h=1e9+5;
	while(l<=h){
		ll mid=l+(h-l)/2;
		ll check=product(mid);
		if(check==x){
			//indx=mid;
			//break;
			h=mid-1;
		}
		else if(check<x) l=mid+1;
		else h=mid-1;
	}
	cout<<l;
	return 0;
}

Measured memory_bytes: 3628
n, m = list(map(int, input().split()))
ipy = []
num = [1 for i in range(n+1)]
ans = ["" for i in range(m)]
for i in range(m):
  p, y = list(map(int, input().split()))
  ipy.append([i, p, y])
ipy.sort(key=lambda x: x[2])
for i in range(m):
  ans[ipy[i][0]] = str(ipy[i][1]).zfill(6)+str(num[ipy[i][1]]).zfill(6)
  num[ipy[i][1]] += 1
for e in ans:
  print(e)

Measured memory_bytes: 32624
#include<bits/stdc++.h>
using namespace std;
int N,M;
vector<int> w;
vector<long long int> v;
long long int arr[101][100001];
long long int ks(int m,int n){
	if(m<=0||n<0){
		return 0;
	}
	
	if(arr[n][m]!=-1){
		return arr[n][m];
	}
	if (w[n] > m) 
       return ks(m, n-1);
    else
		return arr[n][m]= max((v[n]+ks(m-w[n],n-1)),ks(m,n-1));
	
}

int main(){
	cin>>N>>M;
	long long int x;
	for(int i=0;i<N;i++){
		cin>>x;
		w.push_back(x);
		cin>>x;
		v.push_back(x);
	}
	for(int i=0;i<=N;i++){
		for(int j=0;j<=M;j++){
			arr[i][j]=-1;
		}
	}
	cout<<ks(M,(N-1));
}

Measured memory_bytes: 79104
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
 
using namespace std;
 
typedef unsigned long long ll;

ll toNum(char c){
  if(c >= 'A') return c-'A'+10;
  return c-'0';
}

ll convert(const string& s, ll base){
  ll res = 0;
  for(int i = 0; i < (int)s.length(); i++){
    res *= base;
    res += toNum(s[i]);
  }
  return res;
}

vector<int> prime_factor(int n){
  vector<int> res;
  for(int i = 2; i*i <= n; i++){
    while(n % i == 0){
      res.push_back(i);
      n /= i;
    }
  }
  if(n != 1) res.push_back(n);
  sort(res.begin(),res.end());
  return res;
}

ll find(ll num, ll base){
  long double end = num;
  long double now = base;
  ll res = 0;
  ll b = base;
  while(now <= end){
    res += num/b;
    if(num/base+1 < b) break;
    b *= base;
    now *= base;
  }
  return res;
}

vector<int> make(int N){
  vector<int> v = prime_factor(N);
  v.erase(unique(v.begin(),v.end()), v.end());
  return v;
}

int main(){
  int N;
  string M;
  while(cin >> N >> M && N){
    vector<int> v = prime_factor(N);
    vector<int> prime = make(N);
    vector<ll> need(prime.size(), 0);
    
    for(int i = 0; i < (int)prime.size(); i++){
      need[i] = upper_bound(v.begin(),v.end(),prime[i])
	-lower_bound(v.begin(),v.end(),prime[i]);
    }
    
    
    
    vector<ll> have(prime.size(),0);
    ll tmp = convert(M,N);
    for(int i = 0; i < (int)prime.size(); i++){
      have[i] = find(tmp, prime[i]);
    }
    
    for(int i = 0; i < (int)prime.size(); i++) have[i]/=need[i];
    ll ans = have[0];
    for(int i = 0; i < (int)prime.size(); i++) ans = min(ans, have[i]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" "<<x<<"\n";
#define lli long long int
long long int mod= 1000000007,modd=998244353;
lli pow(lli n1,lli n2,lli n3)
{ if(n1==0) return 0;
  if(n2==0) return 1;
  lli nn;
  if(n2%2 == 0)
  { nn=pow(n1,n2/2,n3);
    nn=( (nn*nn) % n3 ) ;
  }
  else
  { nn=n1%n3;
    nn= ( nn * ( pow (n1,n2-1,n3) % n3  ) ) % n3 ;

  }
  return ( ( nn + n3) % n3 ) ;
}
int32_t main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);  cout.tie(0);
   lli n,ans=0,p1,p2,p3;
   cin>>n;
   p1=pow(10,n,mod);
   p2=pow(9,n,mod);
   p3=pow(8,n,mod);
   ans=( ( (p1+p3-p2-p2)%mod  ) + mod ) % mod;
   cout<<ans<<"\n";
   return 0;
}//main


Measured memory_bytes: 3592
#include<stdio.h>
int main (void)
{
    int i,a=0,k;
    int s;
    int b[2019]={0};
    int l[2019];
    while(1){
        s=getchar();
        if(s==10)break;
        k=s-'0';
        for(i=0;i<2019;i++)l[(i*10+k)%2019]=b[i];
        l[k]++;
        a+=l[0];
        for(i=0;i<2019;i++)b[i]=l[i];
    } 
    printf("%d",a);
}

Measured memory_bytes: 1612
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<ll, char> pc; 

const ll Mod = 1e9 + 7;
const ll Delta = 10889;
const int Maxn = 2e5 + 10;
const int Maxm = 1e3 + 10;
const ll Inf = 1e16;

ll f[Maxn], iv[Maxn];

ll mul(ll a, ll b){
	return (a * b) % Mod;
}
ll bin_pow(ll b, ll p){
	ll res = 1;
	for(ll pw = b, j = 1; j <= p; j <<= 1, pw = mul(pw, pw)) if(p & j) res = mul(res, pw);
	return res;
}
ll inv(ll x){
	return bin_pow(x, Mod - 2);
}
ll nCr(ll n, ll r){
	if((r < 0) || (n < r)) return 0;
	return mul(f[n], mul(iv[r], iv[n - r]));
}
ll solve(ll a, ll b){
	//cerr << a << " " << b << " " << nCr(a + b - 2, a - 1) << '\n';
	return nCr(a + b - 2, a - 1);
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);	
	f[0] = 1; iv[0] = 1;
	for(int i = 1; i < Maxn; i++) f[i] = mul(f[i - 1], i), iv[i] = inv(f[i]);
	ll h, w, a, b;
	cin >> h >> w >> a >> b;
	ll ans = 0;
	for(int i = 1; i <= h - a; i ++){
		ans += mul(solve(i, b), solve(w - b, h - i + 1));
		ans %= Mod;
	}
	cout << ans;
	return 0;
}



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

int main() {
    int count_five = 0;
    int count_seven = 0;
    int n = 3;

    for(int i=0; i<n; i++){
        int m;
        cin >> m;
        if(m != 5 && m != 7){
            cout << "NO" << endl;
            return 0;
        }else{
            switch (m)
            {
            case 5:
                count_five = count_five + 1;
                break;
            case 7:
                count_seven = count_seven + 1;
                break;
            }
            if(2 <= count_seven){
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define Fst first
#define Snd second
#define RG register
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef unsigned long long ULL;
template<typename T> inline void read(T& x) {
	char c = getchar();
	bool f = false;
	for (x = 0; !isdigit(c); c = getchar()) {
		if (c == '-') {
			f = true;
		}
	}
	for (; isdigit(c); c = getchar()) {
		x = x * 10 + c - '0';
	}
	if (f) {
		x = -x;
	}
}
template<typename T, typename... U> inline void read(T& x, U& ... y) {
	read(x), read(y...);
}
int n;
LL A[100010],S[100010];
//#define rua
int main() {
//	ios::sync_with_stdio(false);
#ifdef rua
	freopen("GG.in","r",stdin);
#endif
  read(n);
  for(int i=1;i<=n;++i) read(A[i]);
  sort(A+1,A+n+1); A[n+1]=2e18;
  for(int i=1;i<=n;++i) S[i]=S[i-1]+A[i];
  int res=0;
  for(int i=1;i<=n;++i) {
    LL a=A[i]; int b=0;
    while(1) {
      int p=lower_bound(A+1,A+n+2,a*2+1)-A;
      --p;
      if(p==b||p==n) {
        b=p;
        break;
      }
      b=p;
      a=S[b];
    }
    res+=(b==n);
  }
  printf("%d\n",res);
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define debug(x) cout<<#x<<"::"<<x<<endl;
using namespace std;
typedef long long ll;

void solve()
{
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    vector<int>c(n,0);
    for(int i=1;i<n;i++)
    {
        int x=max(0,i-k);
        int cost=INT_MAX;
        for(int j=x;j<i;j++)
        {
            cost=min(cost,c[j]+abs(h[j]-h[i]));
        }
        c[i]=cost;
    }
    cout<<c[n-1]<<'\n';
}

int main()
{
    
    int t;
    t=1;
    while(t--)
        solve();
    return 0;
}

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

int main()
{
  string N;
  cin >> N;
  
  if(N[0] == '7' || N[1] == '7' || N[2] == '7')
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int n;
	while(cin >> n, n){
		int maxi = 0;
		int pati = -1;;
		rep(i, n){
				int num, p, q;
				cin >> num >> p >> q;
				p += q;
				if(p > maxi){
					maxi = p;
					pati = num;
				}
		}
		cout << pati << " " << maxi << endl;
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1160
N,K = map(int, input().split())
d, A = [], []
for i in range(K):
  d.append(int(input()))
  A.append(list(map(int, input().split())))

all_people = [i for i in range(1,N+1,1)]
all_people = set(all_people)

sweet_people = []
for i in range(K):
  for j in range(d[i]):
  	sweet_people.append(A[i][j])
diff = all_people ^ set(sweet_people)
diff = list(diff)
print(len(diff))

Measured memory_bytes: 9248
#include<bits/stdc++.h>
using namespace std;
struct Node
{
	int data;
	Node *next;
};
struct Queue
{
	Node *head;
	Node *la;
	Queue()
	{
		head=(Node *)malloc(sizeof (Node));
		la=(Node *)malloc(sizeof (Node));
		head =NULL;
	}
	bool empty()
	{
		if(head==NULL) return 1;
		else return 0;
	}
	void push(int x)
	{
		Node *p1;
		p1=(Node *)malloc(sizeof (Node));
		p1->data=x;
		if(head==NULL) 
		{
			head=p1;
			la=p1;
		}
		else
		{
			la->next=p1;
			la=p1;
		}
		la->next=NULL;
	}
	void pop()
	{
		Node *p1;
		p1=head->next;
		delete head;
		head=p1;
	}
	int front()
	{
		return head->data;
	}
	void clear()
	{
		while(head!=NULL) head=head->next;
	}
}; 
vector<pair<int,int> > nei[1000005],cit[1000005];
vector<int>comp;
int vis[1000005];
vector<int>newnei[1000005];
int dp[1000005];
int par[1000005];
void init(int x)
{
	par[x]=x;
}
int find(int x)
{
	return (par[x]==x)?x:par[x]=find(par[x]);
}
void merge(int x,int y)
{
	x=find(x);y=find(y);
	par[x]=y;
}
Queue q;
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y,c;
		scanf("%d %d %d",&x,&y,&c);
		x--,y--,c--;
		cit[c].push_back(make_pair(x,y));
		comp.push_back(c);
	}
	sort(comp.begin(),comp.end());
	comp.erase(unique(comp.begin(),comp.end()),comp.end());
	int newci=n;
	for(int i=0;i<comp.size();i++)
	{
		int cmp=comp[i];
		for(int j=0;j<cit[cmp].size();j++)
		{
			int v=cit[cmp][j].first,u=cit[cmp][j].second;
			init(v);init(u);
			vis[v]=vis[u]=0;
		}
		for(int j=0;j<cit[cmp].size();j++)
		{
			merge(cit[cmp][j].first,cit[cmp][j].second);
		}
		for(int j=0;j<cit[cmp].size();j++)
		{
			int v=cit[cmp][j].first;
			v=find(v);
			if(!vis[v])
			{
				vis[v]=newci;
				newnei[v].push_back(newci);
				newnei[newci].push_back(v);
				newci++;
			}
			if(!vis[cit[cmp][j].first])
			{
				int u=cit[cmp][j].first;
				newnei[vis[v]].push_back(u);
				newnei[u].push_back(vis[v]);
				vis[cit[cmp][j].first]=newci;
			}
			if(!vis[cit[cmp][j].second])
			{
				int u=cit[cmp][j].second;
				newnei[vis[v]].push_back(u);
				newnei[u].push_back(vis[v]);
				vis[cit[cmp][j].second]=newci;
			}
		}
	}
	for(int i=0;i<newci;i++) dp[i]=-2;
	dp[0]=1;
	q.push(0);
	while(!q.empty())
	{
		int v=q.front();
		q.pop();
		for(int k=0;k<newnei[v].size();k++)
		{
			int u=newnei[v][k];
			if(dp[u]==-2)
			{
				dp[u]=dp[v]+1;q.push(u);
			}
		}
	}
	cout<<dp[n-1]/2;
}

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

using namespace std;

int main(){
	string s;
	bool x = 0;
	cin>>s;
	string hitachi = "";
	
	for(int i = 0; i < s.size(); i+=2){
		
		hitachi += "hi";
		
		if(s == hitachi)
			x = 1;
	}
	
	if( x == 1)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int n;
    while (cin >> n) {
        map<string,int> ls;
        int mx = 0;
        for(int i = 0; i < n; i++){
            string temp;
            cin>>temp;
            auto iter = ls.find(temp);
            if(iter == ls.end()){
                ls.insert({temp,1});
                mx = max(1,mx);
            }
            else{
                iter->second++;
                mx = max(mx,iter->second);
            }
        }
        vector<string> fin;
        for(auto i:ls){
            if(i.second == mx){
                fin.push_back(i.first);
            }
        }
        sort(fin.begin(),fin.end());
        for(auto i:fin){
            cout<<i<<'\n';
        }
    }
}

Measured memory_bytes: 26868
#include <iostream>
#include <algorithm>
using namespace std;
int min(int a,int b){
    return a<b?a:b;
}
int main(void){
    int N;
    cin >> N;
    int A[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A,A+N);
    string ans = "YES";
    for(int i=0;i<N-1;i++){
        if(A[i] == A[i+1])ans="NO";
    }
    cout << ans << endl;
}


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

int main() {
	int a[1000001];
	cin >> a[0];
	bool found = false;
	
	for(int i=0;i<1000000;i++){
		if(a[i]%2==0){
			a[i+1] = a[i] / 2;
		}
		else{
			a[i+1] = a[i] * 3 + 1;
		}
		for(int j=0;j<i+1;j++){
			if(a[j]==a[i+1]){
				cout << i+2 << endl;
				found = true;
				break;
			}
		}
		if(found == true){
			break;
		}
	}
	
	return 0;
}

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


class Main{
  public static void main(String[] args)throws IOException{
	 int w,h;//size of map
	 int x=0,y=0;//temp
   	 int c=0;
   	 int map[][]=new int[50][50];//map[???][?¨?]
   	 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	  while(true){		  
		  c=0;
    	 
    	 String str = br.readLine();
    	 //System.out.println(str);
    	 String[] a=str.split(" ");
    	 w=Integer.parseInt(a[0]);
    	 h=Integer.parseInt(a[1]);
    	 if(w==0&&h==0){
    		 
    		 break;
    	 }
    	 
    	 //??????????????\????????????
    	 for(int i=0;i<h;i++){
    		 str=br.readLine();
    		 a=str.split(" ");
    		 for(int j=0;j<w;j++){
    			 map[i][j]=Integer.parseInt(a[j]);
    		 }
    	 }
    	 //??°??????
    	 for(int i=0;i<h;i++){
    		 for(int j=0;j<w;j++){
    			 if(map[i][j]==1){
    				 c++;
    				 //System.out.println(i+","+j);
    				 count(map,i,j);
    			 }
    		 	
    		 	
    		 }
    	 }
    	 System.out.println(c);
     }      
   
  }
  static void count(int map[][],int x,int y){
	  if(x<0||y<0||49<x||49<y){
		  return;
	  }else if(map[x][y]==0){
		  return;
	  }
	  else if(map[x][y]==1){
		  map[x][y]=0;
		  count(map,x+1,y+1);
		  count(map,x+1,y);
		  count(map,x,y+1);
		  count(map,x-1,y-1);
		  count(map,x-1,y);
		  count(map,x,y-1);
		  count(map,x-1,y+1);
		  count(map,x+1,y-1);
	  }
	  
  }
}

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

int main(){
  int N; cin >> N;
  ll x[N + 1], y[N + 1], h[N + 1];
  vector< tuple< ll, ll, ll > > v;
  tuple<ll,ll,ll> temp;
  for(int i = 1; i <= N; ++i){
    cin >> x[i] >> y[i] >> h[i];
    if(h[i] >= 1)temp = {x[i],y[i],h[i]};
  }

    for(int i = 0; i <= 100; ++i){
      for(int j = 0; j <= 100; ++j){
        ll H = get<2>(temp) + abs(get<0>(temp) - i) + abs(get<1>(temp) - j);
        H = max(H,0LL); bool can = true;
        for(int k = 1; k <=N; ++k){
          ll z = H - abs(x[k] - i) - abs(y[k] - j);
          z = max(z,0LL);
          if(h[k] != z){can = false; break;}
        }
        if(can)v.push_back({i,j,H});
      }
    }
    if(v.size() == 1)cout << get<0>(v[0]) << ' ' << get<1>(v[0]) << ' ' << get<2>(v[0]) << '\n';
}


Measured memory_bytes: 3616
let readIntArray () =
    stdin.ReadLine().Split(" ") |> Array.map int64

readIntArray ()
|> fun [| a; b; k |] ->
    if a >= k then [| a - k; b |]
    else if b >= k - a then [| 0L; b - (k - a) |]
    else [| 0L; 0L |]
|> Array.map string
|> String.concat " "
|> printfn "%s"


Measured memory_bytes: 29712
package main

import "fmt"

func main() {
	// Code for B - Digit Sums
	var N int
	fmt.Scanf("%d", &N)

	var NN int = N
	var S int
	for {
		S += NN % 10
		A := NN / 10
		if A == 0 {
			break
		} else {
			NN = A
		}
	}
	if N%S == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1836
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var s = cin.Read;
            var we = "";
            if(s=="Sunny"){
              	we = "Cloudy";
            }else if(s=="Cloudy"){
              	we = "Rainy";
            }else{
              	we = "Sunny";
            }
          	WriteLine($"{we}");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 13268
#include<stdio.h>
int main(void){
    int a,b,c;
    int ab,bc,ca;
    scanf("%d %d %d",&a,&b,&c);
    ab=a+b;
    bc=b+c;
    ca=c+a;
    if(ab<bc&&ab<ca){
        printf("%d\n",ab);
    }else if(bc<ca){
        printf("%d\n",bc);
    }else{
        printf("%d\n",ca);
    }
    return 0;
}

Measured memory_bytes: 128