akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main()
{
    int n,k,i,j,t=0,sum=0;
    cin>>n>>k;
    int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if(a[i]>a[j])
            {
                t=a[i];
                a[i]=a[j];
                a[j]=t;
            }
        }
    }
    for(i=0;i<k;i++)
    {
        sum+=a[i];
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;


int main(){
    long long n,m;

    cin >> n >>m;

    if(n>m/2){
      cout << (long long)(m/2)<<endl;
    }
    else if(n==m/2)
      cout << n<<endl;
    else{
      cout << n+(long long)((m-2*n)/4)<<endl;
  }
}


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

class MainClass : Scanner
{
    static void Main()
    {
        int N = RInt();
        var xy = new long[N][];
        for (int i = 0; i < N; i++)
        {
            xy[i] = RLongs();
        }

        long a = xy[0][0] + xy[0][1];
        long b = xy[0][0] + xy[0][1];
        long c = xy[0][0] - xy[0][1];
        long d = xy[0][0] - xy[0][1];

        for (int i = 0; i < N; i++)
        {
            a = Math.Max(a, xy[i][0] + xy[i][1]);
            b = Math.Min(b, xy[i][0] + xy[i][1]);
            c = Math.Max(c, xy[i][0] - xy[i][1]);
            d = Math.Min(d, xy[i][0] - xy[i][1]);
        }
        WriteLine(Max(a-b,c-d));
    }
}



class Scanner
{
    public static string RString() => Console.ReadLine();
    public static int RInt() => ReadTuple<int>();
    public static long RLong() => ReadTuple<long>();
    public static double RDouble() => ReadTuple<double>();

    public static string[] RStrings() => Console.ReadLine().Split();
    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();

    public static T1 ReadTuple<T1>()
    {
        var r = RString();
        var r1 = (T1)Convert.ChangeType(r, typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadTuple<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadTuple<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> v1;

const ll mod = 1000000007;

ll n;
string s;

int main(){
  cin >> n;
  cin >> s;
  for(char c : s){
    cout << (char)('A'+(((c-'A')+n)%26));
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int x,y,z;
  cin>>x>>y>>z;
  if(y-z>=0){
	cout<<"delicious"<<endl;
    return 0;
  }
  else if(x+y-z>=0){
    cout<<"safe"<<endl;
    return 0;
  }
  else{
    cout<<"dangerous"<<endl;
    return 0;
  }
}

Measured memory_bytes: 256
def resolve():
    import sys
    input = sys.stdin.readline

    n = input().rstrip()
    past_a = 0

    ans = 0
    for a in input().rstrip().split(" "):
        a = int(a)
        ans += a * past_a
        past_a += a

    x = 1000000007

    ans = ans % x

    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 82468
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;


int n;
long long a[100];
long long b[200];	//i时刻买入 
long long s[200];	//i时刻卖出，所拥有的钱 

int main()
{
	scanf("%d", &n);
	for (int i = 1 ; i <= n ; i++) {
		scanf("%d", &(a[i]));
	}
	s[0] = 1000;
	s[1] = 1000;
	b[0] = 0;
	
	for (int i = 2 ; i <= n ; i++) {
		s[i] = s[i - 1];
		for (int j = i - 1 ; j >= 1 ; j--) {
			long long count = s[j] / a[j];
			long long r = s[j] % a[j];
			long long curVal = count * a[i] + r;
			
			if (curVal > s[i]) {
				s[i] = curVal;
			}
		}
	}
	
	printf("%lld\n", s[n]);
	
	return 0;
}



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

int main() {
  int N,K;
  cin >> N >> K;
  
  int A = K;
  int ans = 1;
  while (1) {
    if (N < A) break;
    A = pow(K,ans + 1);
    ans++;
  }
  
  cout << ans << endl;
}


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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()


int main() {
  string S;
  cin >> S;
  int ad=0;
  REP(i,3){
    if(S.at(i)=='o')ad++;
  }
  
  cout << 700+ad*100 << endl;
  
  return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
d = {}
k1 = [0 for i in range(10)]
for i in range(N-2):
    if k1[int(S[i])] != 0: continue
    k1[int(S[i])] += 1
    k2 = [0 for i in range(10)]
    for j in range(i+1, N-1):
        if k2[int(S[j])] != 0: continue
        k2[int(S[j])] += 1
        for k in range(j+1, N):
            st = ''.join([S[i], S[j], S[k]])
            d[st] = True
print(len(d))

Measured memory_bytes: 9184
<?php

ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_WARNING);
ini_set('display_errors', 'Off');

// define('DEBUG', true);
define('DEBUG', false);

$map = array(array());
fscanf(STDIN, "%d", $N);
fscanf(STDIN, "%d", $K);

$ans = 1;
for ($i = 0; $i < $N; $i++) {
    if ($ans <= $K) {
        // echo "A\n";
        $ans += $ans;
    } else {
        // echo "B\n";
        $ans += $K;
    }    
    // echo $ans . PHP_EOL;
}
echo $ans . PHP_EOL;


Measured memory_bytes: 4856
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


A, B = list(map(int, sys.stdin.readline().split()))
if (A + B) & 1:
    print('IMPOSSIBLE')
else:
    print((A + B)//2)


Measured memory_bytes: 23276
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	getline(cin, s);
	string str;
	bool b = false;
	for (int i = 0; i < s.size(); i++){
		if (s[i] == ' ' || s[i] == '.' || s[i] == ',') {
			if (str.size() >= 3 && str.size() <= 6) {
				if (b)cout << ' ';
				else b = true;
				cout << str;
			}
			str.clear();
		}
		else str += s[i];
	}
	if(b) cout << endl;
	return 0;
}

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

int main(){
    double a, b, x;
    cin >> a >> b >> x;
    double c = x / a;
    double rad;
    double h;
    if(a * b <= 2 * c){
        h = a * b - c;
        h = h / (a / 2);
        rad = a / h;
        rad = atan(rad);
    }else{
        h = c * 2;
        h = h / b;
        rad = atan(h / b);
    }
    double ans = 90 - rad * 45 / atan(1);
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 512
//59
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>

using namespace std;

int main(){
  for(int m,n,d;cin>>m>>n>>d,m|n|d;){
    vector<vector<int> > v(m*n,vector<int>(m*n+1));
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	for(int k=0;k<n;k++){
	  for(int l=0;l<m;l++){
	    int cd=abs(i-k)+abs(j-l);
	    v[i*m+j][k*m+l]=cd==0||cd==d;
	  }
	}
	cin>>v[i*m+j].back();
      }
    }
    int dn=0;
    for(int i=0;i<n*m;i++){
      int j;
      for(j=dn;j<v.size();j++){
	if(v[j][i])break;
      }
      if(j==v.size())continue;
      swap(v[dn],v[j]);
      for(int k=dn+1;k<v.size();k++){
	if(v[k][i]){
	  for(int l=0;l<v[k].size();l++){
	    v[k][l]^=v[dn][l];
	  }
	}
      }
      dn++;
    }
    int i;
    for(i=dn;i<v.size();i++){
      if(v[i].back())break;
    }
    cout<<(i==v.size())<<endl;
  }
  return 0;
}

Measured memory_bytes: 2656
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cctype>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <deque>
#include <map>
#include <bitset>
#include <functional>
#include <cmath>

#define INF 1000000000
using namespace std;

int main(){
    long long n, m, k;
    cin >> n >> m >> k;

    vector<long long> a(n), b(m);
    long long i, j;
    for(i = 0; i < n; i++) cin >> a[i];
    for(i = 0; i < m; i++) cin >> b[i];

    vector<long long> aa(n+1), bb(m+1);

    aa[0] = 0; bb[0] = 0;
    for(i = 1; i <= n; i++){
        aa[i] = aa[i-1] + a[i-1];
    }
    for(j = 1; j <= m; j++){
        bb[j] = bb[j-1] + b[j-1];
    }

    long long cnt = 0;

    for(i = 0; i < n+1; i++){
        if(aa[i] > k) break;
        long long tmp = 0;
        tmp += i;
        j = lower_bound(bb.begin(), bb.end(), k-aa[i]) - bb.begin();
        if(bb[j] == k-aa[i]) tmp+=j;
        else tmp += (j-1);
        cnt = max(cnt, tmp);
    }

    cout << cnt << endl;
}

Measured memory_bytes: 9596
#include<stdio.h>

int main(){
  int n,x=0,max=0;
  char s[110];
  scanf("%d",&n);
  scanf("%s",s);
  for(int i=0;i<n;i++){
    if(s[i]=='I')
      x++;
    else
      x--;
    if(max<x)
      max=x;
  }
  printf("%d\n",max);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main(){
	int n,l;
	cin>>n>>l;
	int icic[114514];
	icic[0]=0;
	icic[1]=0;
	for(int i=0;i<n;i++)cin>>icic[i+2];
	icic[n+2]=0;
	icic[n+3]=0;
	int t=0;
	
	priority_queue<P>Q;
	for(int i=1;i<=n+2;i++){
		if(icic[i]>icic[i-1]&&icic[i]>icic[i+1]){
			Q.push(P(icic[i],i));
			}
		}
		
		while(Q.size()){
			P p=Q.top();
			Q.pop();
			
			if(p.first==0)continue;
			t+=(l-p.first-t);
				
			icic[p.second]=0;	
			if(icic[p.second-2]<icic[p.second-1])Q.push(P(icic[p.second-1]-t,p.second-1));
			if(icic[p.second+2]<icic[p.second+1])Q.push(P(icic[p.second+1]-t,p.second+1));	
			}
			cout<<t<<endl;
			return 0;
	}

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

using namespace std;

typedef long long ll;

int t;
ll a, b, c, d;

ll gcd(ll a, ll b) {
    if (!b) return a;
    return gcd(b,a%b);
}

void print(int t) {
    if (t) printf("Yes\n");
    else printf("No\n");
}

int main() {
    int i;

    scanf("%d",&t);
    for (i=0;i<t;i++){
        scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
        if (b>d) print(0);
        else if (b==d) {
            if (a<b) print(0);
            else if (a%b<=c) print(1);
            else print(0);
        }
        else {
            if (a<b) print(0);
            else if (b<=c) print(1);
            else if ((a-c-1)%gcd(b,d)<=b-c-2) print(0);
            else print(1);
        }
    }

    return 0;
}


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

import javax.transaction.xa.Xid;

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static int n, m;
	static long mod = 998244353;
	static int[][] memo;
	static String s;
	static HashSet<Integer> nodes;
	static HashSet<Integer>[] ad, tree;
	static boolean[] vis, taken;
	static int[] a;
	static TreeSet<Long> al;
	static long[] val;
	static ArrayList<String> aa;
	static char[] b;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int n=sc.nextInt();
		long ans=0;
		for(int i=1;i<=n;i++)
			if(i%3!=0 && i%5!=0)
				ans+=i;
		System.out.println(ans);
		out.flush();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

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

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 33076
object Main extends App {

  override def main(args: Array[String]) {
    val milleniumDay = new Date(1000, 1, 1).toInt
    val n = io.StdIn.readLine.toInt
    (1 to n).map(_ => io.StdIn.readLine.split(' ')).map(spl => new Date(spl(0).toInt, spl(1).toInt, spl(2).toInt).toInt)
      .foreach(dayFrom1 => println(milleniumDay - dayFrom1))
  }

  case class Date(Y: Int, M: Int, D: Int) {
    val daysOfMonthBig = 20
    val daysOfMonthSmall = 19
    val monthToDayNormal: Int => Int = m => (m - 1) / 2 * daysOfMonthSmall + m / 2 * daysOfMonthBig
    val monthToDay3ish: Int => Int = m => (m - 1) * daysOfMonthBig
    val monthToDay: Int => Int => Int = y => if (y % 3 == 0) monthToDay3ish else monthToDayNormal
    val daysOfYearNormal = monthToDayNormal(11)
    val daysOfYear3ish = monthToDay3ish(11)
    val daysOf3Years = daysOfYearNormal + daysOfYearNormal + daysOfYear3ish
    val yearToDay: Int => Int = y => (y - 1) / 3 * daysOf3Years + (y - 1) % 3 * daysOfYearNormal
    val toInt = yearToDay(Y) + monthToDay(Y)(M) + D
  }
}

Measured memory_bytes: 43792
K=int(input())
a=K
while a%2==0:
    a//=2
while a%5==0:
    a//=5
if a==1:
    print(1)
else:
    mod=set([])
    a=1
    while a not in mod:
        mod.add(a)
        a*=10
        a%=K

    mod=list(mod)
    n=len(mod)
    wei=pow(2,K)-1
    check=1
    ans=0
    for j in range(0,n):
        ans=ans|(check<<mod[j])
    check=ans
    for i in range(1,46):
        if check>>0 &1==1:
            print(i)
            exit()
        ans=check
        for j in range(0,n):
            ans=ans|(check<<mod[j])
        ans1=ans&wei
        ans2=ans>>K
        check=ans1|ans2

Measured memory_bytes: 7916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string S;
    int A,B;
    cin >> A >> B >> S;
    bool ok = 1;
    REP(i,A+B+1){
        if(i == A){
            if(S[i] != '-')ok = 0;
        }else{
            if('0' > S[i] || S[i] > '9'){
                ok = 0;
            }
        }
    }
    cout << (ok ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b;
  char op;
  while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op=='+')printf("%d\n",a+b);
    if(op=='-')printf("%d\n",a-b);
    if(op=='*')printf("%d\n",a*b);
    if(op=='/')printf("%d\n",a/b);
    if(op=='?')break;
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, s, n) for (int i = s; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion
template <typename T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, 0, n){
        cin >> a[i] >> b[i] >> c[i];
        a[i]; b[i]; c[i];
    }

    vector<vector<int>> dp(n, vector<int>(3, 0));

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    rep(i, 1, n){
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
    }

    int ans = max(dp[n-1][0], dp[n-1][1]);
    ans = max(ans, dp[n-1][2]);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6912
#include<iostream>

using namespace std;
#define MAX_N 10000

int par[MAX_N];
void init(int n) {
  for (int i = 0; i < n; i++) par[i] = i;
}

int Find(int x) {
  if(par[x] == x) {
    return x;
  } else {
    return par[x] = Find(par[x]);
  }
}

bool Same(int x, int y) {
  return Find(x) == Find(y);
}

void Union(int x, int y) {
  x = Find(x);
  y = Find(y);
  if (x == y) return;

  par[x] = y;
  return;
}

int main() {
  int n, q, com, x, y;
  cin >> n >> q;
  init(n);
  while(q-- > 0) {
    cin >> com >> x >> y;
    if(com == 0) {
      Union(x, y);
    } else {
      cout << Same(x, y) << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3232
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  string s;
  cin >> s;
  ll n = s.size();
  bool is_ni=true;
  for(int i=1;i<n;i++){
    if(s[i]!='9'){
      is_ni = false;
    }
  }
  ll front = (s.front()-'0');
  if(is_ni){
    cout <<front+9*(n-1)<<endl;
    return 0;
  }
  front--;
  cout <<front+9*(n-1)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A,B,K;
    int count=0;
    int ans=0;
    cin >> A >> B >> K;
    for (int i=100; i>=1; i--){
        if (A%i==0 && B%i==0) count++;
        if (count == K){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
object Main extends App {

  val Array(n, a, b) = io.StdIn.readLine.split(" ").map(_.toInt)

  val ans = (1 to n).foldLeft(0)( (acc,i) => {

    val sum = {
      var m = i
      var t = 0
      while( m > 0 ) {
        t += m % 10
        m /= 10
      }
      t
    }

    if(a <= sum && sum <= b ) acc + i else acc
  })

  println(ans)
}

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

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

  if(N%1000/100 != N%100/10){
    cout << "No" << endl;
  }

  else if(N/1000 == N%1000/100 || N%100/10 == N%10){
    cout << "Yes" << endl;
  }

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


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    n=len(s)
    A=[0]*(n+1)
    for i in range(n):
        if s[i]=="<":
            A[i+1]=A[i]+1
    for i in range(n):
        if s[n-i-1]==">":
            A[n-i-1]=max(A[n-i-1],A[n-i]+1)
    print(sum(A))

if __name__=='__main__':
    main()

Measured memory_bytes: 23372
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	if (N % K == 0) cout << 0 << endl;
	else cout << 1 << endl;

	return 0;
}

Measured memory_bytes: 3612
s = input()

res=True
if s[0] != "A":
    res = False
cnt=0
for c in s[2:-1]:
    if c=="C":cnt+=1
if cnt != 1:
    res = False

big = "BDEFGHIJKLMNOPQRSTUVWXYZ"
for c in s:
    if c in big:
        res=False
    
    
if res:
    res="AC"
else :res="WA"
print(res)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
    long a,i,num,sum,high,low;
    high = -9999999999999;
    low = 99999999999999;
    i = 1;
    cin >>num;
    sum = 0;
    while(i <= num){
        cin >>a;
        if (a > high) high = a;
        if (a < low) low = a;
        sum += a;
        i += 1;
    }
    cout << low << " " << high << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3108
n,m = map(int,input().split())
ans = [0]*30
for i in range(n):
    a = list(map(int,input().split()))
    for j in range(a[0]+1):
        if j != 0:
            ans[a[j]-1] += 1
count = 0
for i in range(30):
    if ans[i] == n:
        count += 1
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
using namespace std;

int main(){
    int a,b,x;
    cin >> a >> b >> x;
    string ans;
    if ( x >= a && x <= a+b) ans = "YES";
    else ans = "NO";
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;

    map<ll, ll> memo;
    memo[0] = 1;
    memo[1] = 1;
    function<ll(ll)> fib = [&](ll m) {
        if (memo.count(m)) return memo[m];
        return memo[m] = fib(m - 1) + fib(m - 2);
    };
    cout << fib(n) << endl;
}




Measured memory_bytes: 3220
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

int main(){
    int r,g,b,k;
    cin>>r>>g>>b>>k;

    while(k){
        if(r>=g){
            g*=2;
            k--;
        }else{
            break;
        }
    }
    while(k){
        if(g>=b){
            b*=2;
            k--;
        }else{
            break;
        }
    }

    if(r<g&&g<b){
        cout<<"Yes";
    }else{
        cout<<"No";
    }


    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
 
typedef pair<int, int> P1;
bool pairCompare1(const P1& firstElof, const P1& secondElof)
{
    return firstElof.first > secondElof.first;
}

typedef pair<int, string> P2;
bool pairCompare2(const P2& firstElof, const P2& secondElof)
{
    return firstElof.first > secondElof.first;
}

int main() {

    int N, M;
    cin >> N >> M;

    vector<vector<pair<int, int>>> N_table(N+1);

    int P, Y;
    for (int i = 0; i < M; i++ ) {
        cin >> P >> Y;
        pair<int, int> p = make_pair(Y, i);
        N_table[P-1].push_back(p);
    }

    vector<pair<int, string>> ID_table;

    //for (int i = 0; i < N; i++ ) {
    //    if (N_table[i].size() > 0) {
    //        sort(N_table[i].begin(), N_table[i].end(), pairCompare1);
    //        for (int j = 0; j < N_table[i].size(); j++) {
    //            string pref = to_string(i+1), id = to_string(j+1);
    //            string str = string(6 - pref.size(), '0') + pref + string(6 - id.size(), '0') + id;
    //            //char id[20];
    //            //sprintf(id, "%06d%06d", (i+1),(j+1));
    //            //string str = id;
    //            pair<int, string> p = make_pair(N_table[i][j].second, str);
    //            ID_table.push_back(p);
    //        }
    //    }
    //}

    //sort(ID_table.begin(), ID_table.end(), pairCompare2);
    //for (int i = 0; i < ID_table.size(); i++)  cout << ID_table[i].second << endl;
    vector<string> res(M);
    for (int i = 0; i < N; i++) {
        sort(N_table[i].begin(), N_table[i].end());
        int n = N_table[i].size();
        for (int j = 0; j < n; j++) {
            string tmp = to_string(i + 1);
            string id (6 - tmp.size(), '0');
            id += tmp;
            tmp = to_string(j + 1);
            id.insert(id.end(), 6 - tmp.size(), '0');
            id += tmp;
            res[N_table[i][j].second] = id;
        }
    }
    for (int i = 0; i < M; i++) {
        cout << res[i] << endl;
    }


    return 0;
}

Measured memory_bytes: 12416
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, K: int):
    if A >= K:
        print("%d %d" % (A-K, B))
    elif A < K:
        print("%d %d" % (0, max(0, B-(K-A))))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, K)

if __name__ == '__main__':
    main()


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll r,g;
    cin >> r >> g;
    cout << 2*g-r << "\n";
    return 0;
}

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


int main(){
	int N,ans=0; cin >> N;
	int v[N+10],c[N+10];
	for(int i=0; i<N; i++){
		cin >> v[i];
	}for(int i=0; i<N; i++) cin >> c[i];
	for(int i=0; i<N; i++){
		if(v[i]-c[i]>=0) ans+=v[i]-c[i];
	}
	cout << ans << endl;
}

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

int main (){
    int a, b,c;
    cin >> a >> b;
    c= min(a,b);
    a = max(a,b);
    for(int i = 0; i< a;i++){
        cout << c ;
    }  
    cout <<""<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define ll long long
#define ar array
static auto _ = [] {
    std::ios::sync_with_stdio (0);
    std::cin.tie (0);
    std::cout.tie (0);
    std::cerr.tie (0);
    return 0;
}
();

void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b != c) {
        cout << "Yes" << endl;
    }
    else if (a == c && c != b) {
        cout << "Yes" << endl;
    }
    else if (b == c && c != a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" <<  endl;
    }
}
int main() {
    ios::sync_with_stdio (0);
    cin.tie (0);
    int testCases;
    testCases = 1;
    while (testCases --) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;


int main() {
    int n; cin >> n;
    if(n % 1000 == 0) cout << 0 << endl;
    else cout << 1000 - (n % 1000) << endl;
}

Measured memory_bytes: 3628
#if defined(__GNUC__)
#include <bits/stdc++.h>
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#if defined(__GNUC__)
#define __int32 __int32_t
#endif // __GNUC__

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) std::sort(ALL(x))
#define RSORT(x, T) std::sort(ALL(x), greater<T>())
#define REVERCE(x) std::reverce(ALL(x))
#define ACM(x, y) std::accumulate(ALL(x), y)

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)

itn main() {
	std::ios::sync_with_stdio(false);

	int s;

	cin >> s;

	int v, h;

	h = v = sqrtl(s);

	while (v * h < s) {
		if (v == 1'000'000'000) {
			++h;
		}
		else {
			++v;
		}
	}

	int dis = v * h - s;

	cout << 0 << ' ' << 0 << ' ' << h << ' ' << dis << ' ' << 1 << ' ' << v;

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n)cin >> p[i];
    int ans =0;

    rep(i,n-1){
        if(i > 0){  
            if(p[i-1] < p[i]){
                if(p[i] < p[i+1]){
                    ans++;
                }
            }
            else if(p[i-1] > p[i]){
                if(p[i] > p[i+1]){
                    ans++;
                }
            }
        }
    }


    cout << ans << endl;
}

Measured memory_bytes: 256
TAX = 1.08
value = int(input())

row_cost = int(value / TAX)

flag = False
echo_cost = 0
if int(row_cost * TAX) == value:
    flag = True
    echo_cost = int(row_cost )
elif int((row_cost + 1) * TAX) == value:
    flag = True
    echo_cost = int(row_cost + 1)

else :
    flag = False

if flag:
    print(echo_cost)
else:
    print(":(")




Measured memory_bytes: 38384
#include <iostream>

int main()
{
    int n;
    int cnt;  // 正解個数
    
    while (std::cin >> n){
        cnt = 0;
        for (int a = 0; a < 10; a++){
            for (int b = 0; b < 10; b++){
                for (int c = 0; c < 10; c++){
                    for (int d = 0; d < 10; d++){
                        if (a + b + c + d == n){
                            cnt++;
                        }
                    }
                }
            }
        }
        std::cout << cnt << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 1156
#include "bits/stdc++.h"
#include <iostream>
using namespace std;
#define ll = long long;
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 1e+9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main()
{
	long long x;
	cin >> x;
	for (int i = sqrt(x); i >0; i--) {
		if (x % i == 0) {
			cout << (i+(x/i))-2 << endl;
			return 0;
		}
	}
}
/*


  　　　 _」_
　 　×´　　　  _,,..-──-､,_ｧo､__　　  ｀メ.
　　/　    ,  '"´　 　　　   （-､__oヽ　　　_|__
　 　　　／　　　　　　　　 　 ｀ヽ.ヽﾊ）　 　ﾉ
　　　 ／　　　　　　　　　　　  　 Y⌒ヽ.
　　  /　　 /　　　　　　     ヽ.　 |　　',
　　 ,'　　!　　,　 /!　,| ＿   !.　|　　 !　　
　　　|　  |.__/|_ ,'| / ! __｀./! /|　　 |
　　　|　　|´/ |_/  ﾚ' ｧ'´￣` |／､ﾄ、 　|　　奇跡を起こして計算量をO(N)にします!
　　  '､　 |/ｧ'´￣`  　　　,,　|　|ｿ   　ﾊ　　
　　 　 ＼,ハ ,,　　 '　   　（ ＼|　 / .|
　　　 　 | ﾊ、　i7´￣｀i  ,/ ＼_）,'　 |
　　　　 ,'/｀＞ ､,｀   ,.イ/＼＿_! !　  !　　|
　　 　　/　 /｀     T7´／/ヽ､_＿ﾉ_| 　 |__,メ
　　 　　|  .|r/´`ｰ'-､／　,'./  /::/｀ヽ /
　　　　 八　i/      rﾉ,!￣ヽ､| /:/ 　  i_
　　  　,' X`;くﾄ  ､ノ､　/ﾍ｀ヽ．Y    ／::>
　　　　!　// |::|/.|::|＼/ﾉ 八__ノr:':::／/
　　　　|／　 |::|./|::|/　 ）'ﾉ:/--‐'','
　  　  /　　 八:' _ﾉ::ﾉ　 _,.ｲ／　　　　|
　　 　,'　　　 ＼_ ／,|　 　／　　　 　 !
　　　 |　　　　　　  /|　 ／ 　　　/ 　 |
*/


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

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String S = in.next();
        String[]  Day = new String[]{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
        int[] x = new int[]{7, 6, 5, 4, 3, 2, 1};
        for(int i = 0; i<7; i++)
        {
            if(S.equals(Day[i])){
                System.out.println(x[i]);
            }
        }







        }







    }
















Measured memory_bytes: 35428
#include <iostream>
#include <vector>
#include <cmath>


using namespace std;

int main(){
  int datasets = 0;
  cin >> datasets;

  for(int i=0;i<datasets;i++){
    double xa,ya,ra,xb,yb,rb;
    cin >> xa >> ya >> ra >> xb >> yb >> rb;

    //dis
    double dis = sqrt(pow(xa-xb, 2) + pow(ya-yb,2));
    
    if(ra+rb < dis){
      cout << "0" << endl;
      continue;
    }

    if(ra-rb > dis){
      cout << "2" << endl;
      continue;
    }

    if(rb-ra > dis){
      cout << "-2" << endl;
      continue;
    }

    if(ra+rb >= dis){
      cout << "1" << endl;
      continue;
    }
  }
}
      

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

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

  int n,m;
  cin >> n >> m;
  int x[m];
  rep(i,m) cin >> x[i];
  sort(x,x+m);
  if(m<=n){
    cout << 0 << endl;
    return 0;
  }
  int diff[m-1];
  //  priority_que<pair<int, int> > q;
  rep1(i,m-1){
    diff[i-1]=x[i]-x[i-1];
  }
  sort(diff,diff+m-1);
  int ans=0;
  rep(i,m-n){
    ans+=diff[i];
  }
  cout << ans << endl;
  
  /*  int lb=0;
  int ub=2e5+100;
  ll ans=x[m-1]-x[0];
  while((ub-lb)>1){
    int mid=(ub+lb)/2;
    // int s=x[0];
    int ckoma=1;
    ll tans=0;
    rep1(i,m-1){
      if(x[i]-x[i-1]>mid){
	ckoma++;
      }
      else tans+=x[i]-x[i-1];
    }
    //    cout << tans << endl;
    if(ckoma<=n && ans>=tans){
      ub=mid;
      ans=tans;
    }
    else lb=mid;
    }*/
  //  cout << ub << " ub"  << endl;
    /*    ll ans=0;
  int st=x[0];
  rep1(i,m-1){
    if(st+ub<x[i]){
      ans+=x[i-1]-st;
      st=x[i];
    }
    else if(i==m-1){
      ans+=x[i]-st;
    }
    }*/
  //  cout << ans << endl;
    

  return 0;
    

}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        sc.close();

        System.out.println(z + " " + x + " " + y);
    }
}


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

public class Main {


    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }




    public void execute(CustomReader in) throws IOException {
        final int N = Integer.parseInt(in.readLine());
        int [] value = in.readLineAsIntArray();
        int[] cost = in.readLineAsIntArray();
        int maxProfit = 0;
        for (int i=0; i<N; i++){
            int gp = value[i] - cost[i];
            if (gp > 0) {
                maxProfit += gp;
            }
        }
        System.out.println(maxProfit);
    }


    static class CustomReader extends BufferedReader {
        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in));
        }


        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public long[] readLineAsLongArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            long[] longArray = new long[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                longArray[i] = Long.parseLong(strArray[i]);
            }
            return longArray;
        }


        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }
    }

}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define maxn 205
#define INF 0x3f3f3f3f
#define mod 1000000007
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
using namespace std;

ll n, k, d, a, ans[maxn];

void slove()
{
	ll res = 0;
	memset(ans, 0, sizeof(ans));
	cin >> n >> k;
	rep(i,0,k) {
		cin >> d;
		a = 0;
		rep(i,0,d) {
			cin >> a;
			ans[a]=1;
		}
	}
	rep(i,1,n+1) if (ans[i]==0) res++;
	cout << res;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:\\Users\\Fish_Brother\\Desktop\\in", "r", stdin);
	//freopen("C:\\Users\\Fish_Brother\\Desktop\\out", "w", stdout);
#endif
	slove();

	return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    ll N, M; cin >> N >> M;
    if(N == 2 || M == 2) cout << 0 << endl;
    else if(N == 1 && M == 1) cout << 1 << endl;
    else if(N == 1 || M == 1) cout << max(N, M) - 2 << endl;
    else cout << (N-2) * (M-2) << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val ss = next().toList()
    val answer = mutableListOf<String>()

    var tmp = ""
    for (s in ss) {
        val str = tmp + s.toString()

        if (answer.size == 0) {
            answer.add(str)
            continue
        }

        if (answer.last() != str) {
            answer.add(str)
            tmp = ""
            continue
        }

        tmp += str
    }

    if (tmp == "") {
        println(answer.size)
    } else  {
        answer[answer.size-1] = answer.last() + tmp
        if (answer.size == 1) {
            println(1)
        } else {
            println(answer.size)
        }
    }
}

fun next() = readLine()!!

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 59564
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    public static void Main()
    {


        var line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var N = line[0];
        var D = line[1];

        List<int[]> list = new List<int[]>();

        for (int i = 0; i < N; i++)
        {
            var line1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            list.Add(line1);
        }

        int count = 0;

        for (int i = 0; i < N; i++)
        {
            for (int j = i + 1 ; j < N; j++)
            {
                //ルートの中身
                int h = 0;

                for (int p = 0; p < D; p++)
                {
                    h  = h + (int)Math.Pow(list.ElementAt(i).ElementAt(p) - list.ElementAt(j).ElementAt(p),2);
                }

                for (int s = 0; s <= h; s++)
                {
                    //二乗してルートと一致すれば　ルートは整数
                    if(Math.Pow(s,2) == h)
                    {
                        count = count + 1;
                    }
                }

            }
        }

        Console.WriteLine(count);

    }
}

Measured memory_bytes: 13396
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位


signed main() {
	int N,K;
	cin >> N>>K;
	vector<int> v;
	for (int i = 0; i < N; i++) {
		int inp;
		cin >> inp;
		v.push_back(inp);
	}
	int ans = LL_HALFMAX;
	sort(v.begin(), v.end());
	for (int i = 0; i <= N - K; i++){
		int sa = v[i + K - 1] - v[i];
		if (sa < ans) ans = sa;
	}
	cout << ans << "\n";



	return 0;
}

Measured memory_bytes: 1400
//ABC 128 D enque
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k,v[55];
ll solve(ll l,ll r){
   vector<ll> t;
   for(int i=0;i<=l;i++)
      t.push_back(v[i]);
   for(int i=r;i<n;i++)
      t.push_back(v[i]); 
   sort(t.begin(),t.end());
   ll lim=k-t.size();          
   if(lim<0)return 0;
   ll sum=0;
   for(int i=0;i<t.size();i++){
      if(t[i]<0&&lim>0){
         lim--;
      }else
	     sum+=t[i];
   }
   return sum;
}
int main(){
   cin>>n>>k;
   for(int i=0;i<n;i++)  cin>>v[i];
   ll ans=0;
   for(int i=-1;i<n;i++)
     for(int j=i+1;j<=n;j++){
        ans=max(ans,solve(i,j));
     }  
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
 
int main(){
    ll N, ans = 0;
    cin >> N;
    rep1(i,sqrt(N)) if(!(N%i)) ans = i;
    pr(ans+N/ans-2);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    string s, t, u;
    long int a, b, c;
    long int ans = 0;

    cin >> a >> b >>c;
    if (a == b && a != c){
        cout <<"Yes"<<"\n";
        return 0;
    }
    else if (c == b && a != c){
        cout <<"Yes"<<"\n";
        return 0;
    }
    else if (c == a && a != b){
        cout <<"Yes"<<"\n";
        return 0;
    }
    else{
        cout <<"No"<<"\n";
    }
    
    return 0;
}



Measured memory_bytes: 256