akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define fi first
#define se second
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pii pair<int,int>
#define mod 998244353

int lowbit(int x) {return x&(-x);}

const int N=1e5+11;

int n;
int f[N][3],h[N][3];

int main(){
	scanf("%d",&n);
	for (int i=0;i<n;i++)
		for (int j=0;j<3;j++) scanf("%d",&h[i][j]);
	for (int i=0;i<3;i++) f[0][i]=h[0][i];
	int ans=0;
	for (int i=1;i<n;i++)
		for (int j=0;j<3;j++) {
			int tmp=0;
			for (int k=0;k<3;k++)
				if (k!=j) tmp=max(tmp,f[i-1][k]);
			f[i][j]=tmp+h[i][j];
		}
	for (int i=0;i<3;i++) ans=max(ans,f[n-1][i]);
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


int main(){
  int a,b;
  cin>>a>>b;
  if(a==b){
    cout<<'0'<<endl;
  }
  else{
    cout<<max(a,b)-min(a,b)<<endl;
  }
}


Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean hasMore = true;
		do {
			int read1 = sc.nextInt();
			int read2 = sc.nextInt();
			if (read1 != 0 && read2 != 0) {
				final int n = read1, p = read2;
				int[] phas = new int[n];
				int count = p, posi = 0;
				boolean hasWinner = false;
				do {
					int player = posi;
					if (count > 0) {
						phas[posi]++;
						count--;
					} else {
						count = phas[posi];
						phas[player] = 0;
					}
					if (phas[player] == p) {
						hasWinner = true;
						System.out.println(player);
					} else {
						posi = (++posi == n) ? 0 : posi;
					}
					// System.out.println(count + ":" + Arrays.toString(phas));
				} while (!hasWinner);

			} else {
				hasMore = false;
			}
		} while (hasMore);
	}
}

Measured memory_bytes: 12000
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    s = {}
    for _ in range(n):
        a = input().rstrip()
        s[a] = 1
    res = 0
    for _ in s.keys():
        res += 1
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 35740
using System;

namespace A_PoisonousCookies
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();

            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);
            int C = int.Parse(s[2]);

            if (C <= A + B)
                Console.WriteLine((B + C).ToString());
            else
                Console.WriteLine((A + B + B +1).ToString());
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
/*******************??????********************/
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
double cross(const P& a, const P& b) {//??????
	return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {//??????
	return real(conj(a)*b);
}

struct L : public vector<P> {//??????
	L(const P &a, const P &b) {
		push_back(a); push_back(b);
	}
};

typedef vector<P> G;
struct C {//???
	P p; double r;
	C(const P &p, double r) : p(p), r(r) { }
};

int ccw(P a, P b, P c) {//??????????????????
	b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectLL(const L& l,const L& m){
	//non-parallel || sameline
	return abs(cross(l[1]-l[0],m[1]-m[0])) > EPS || abs(cross(l[1]-l[0],m[0]-l[0])) < EPS;
}
bool intersectLS(const L& l,const L& s){
	// s[0] is left of l,s[1] is right of l
	return cross(l[1]-l[0],s[0]-l[0]) * cross(l[1]-l[0],s[1]-l[0]) < EPS;
}
bool intersectLP(const L& l,const P& p){
	return abs(cross(l[1]-p,l[0]-p)) < EPS;
}
bool intersectSP(const L& s,const P& p){
	return abs(s[0]-p)+abs(s[1]-p) - abs(s[1]-s[0]) < EPS;// triangle inequality
}

P projection(const L& l,const P& p){
	double t = dot(p-l[0],l[0]-l[1]) / norm(l[0]-l[1]);
	return l[0] + t*(l[0]-l[1]);
}
P reflection(const L& l,const P& p){
	return p + 2. * (projection(l,p) - p);
}
double distanceLP(const L& l,const P& p){
	return abs(p - projection(l,p));
}
double distanceLL(const L& l,const L& m){
	return intersectLL(l,m) ? 0 : distanceLP(l,m[0]);
}
double distanceLS(const L& l,const L& s){
	if(intersectLS(l,s)) return 0;
	return min(distanceLP(l, s[0]),distanceLP(l, s[1]));
}

int main(void){
	int x1,y1,x2,y2;
	cin >> x1 >> y1 >> x2 >> y2;
	P p1(x1,y1),p2(x2,y2);
	L l(p1,p2);

	int q;
	cin >> q;
	for(int i=0;i<q;i++){
		int x,y;cin >> x >> y;
		P p3(x,y);
		P t = reflection(l,p3);
		cout << fixed << setprecision(20) << real(t);cout << " ";
		cout << fixed << setprecision(20) << imag(t) << endl;
	}

	return 0;
}

Measured memory_bytes: 3340
//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

void a(){
    string s;
    cin >> s;
    if(s=="ARC") cout << "ABC" << endl;
    else cout << "ARC" << endl;
}
void b(){
    
}

void c(){

}

void d(){
    
}
void e(){}
void f(){}
int main(){
    a();
    return 0;
}

Measured memory_bytes: 3600
// C.

#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int d[10];

int solve(int n, int x, int f) {
	if (f <= 0) {
		return x;
	}
	int a = (n % (f * 10)) / f;
	int b = (x % (f * 10)) / f;
	if (!d[b]) {
		return solve(n, x, f / 10);
	}
	int c = b;
	while (d[c]) {
		++c;
		while (c >= 10) {
			f *= 10;
			c = (x % (f * 10)) / f + 1;
		}
	}
	x -= x % (f * 10);
	x += c * f;
	for (int i = 0; i <= 9; ++i) {
		if (!d[i]) {
			while (f > 0) {
				f /= 10;
				x += i * f;
			}
			break;
		}
	}
	return x;
}

int main(int argc, char *argv[]) {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < k; ++i) {
		int x;
		cin >> x;
		d[x] = 1;
	}
	int f = 1;
	for (int i = n; i >= 10; i /= 10) {
		f *= 10;
	}
	cout << solve(n, n, f) << endl;
	return 0;
}


Measured memory_bytes: 256
// I/O
#include <iostream>
#include <iomanip>

// data structures
#include <set>
#include <queue>
#include <vector>

// manipulations
#include <algorithm>

#define rep(i,n) for(int i=0;i< (n);++i)
#define REP(i,n) for(int i=1;i<=(n);++i)
#define for_lowercase(c) for(int c='a';c<='z';++c)
#define for_uppercase(c) for(int c='A';c<='Z';++c)
#define ALL(a) (a).begin(),(a).end()
using LLI = long long int;
LLI GCD(LLI a,LLI b){ if(a<b) return GCD(b,a); else if(a%b==0) return b; else return GCD(b,a%b); }
LLI LCM(LLI a,LLI b){ return (a/GCD(a,b))*b; }
using VI  = std::vector<LLI>;
using PI  = std::pair<LLI,LLI>;
using VVI = std::vector<VI>;
using VPI = std::vector<PI>;
template<class T> bool is_odd (T x){ return   x%2 ; }
template<class T> bool is_even(T x){ return !(x%2); }

int main() {
    std::ios::sync_with_stdio(false);
    LLI N,T;
    std::cin >> N >> T;
    VI t(N);
    rep(i,N) std::cin >> t[i];

    LLI sum=0;
    rep(i,N-1){
        if(t[i+1]-t[i] < T)
            sum += t[i+1] - t[i];
        else
            sum += T;
    }
    sum += T;
    std::cout << sum << std::endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bitset>
#include <iostream>
#include <string>

using namespace std;

bitset<1000000 + 1> b, t;

int main()
{
    t.set();
    t[0] = false;
    t[1] = false;
    int i = 0;
    while (true) {
        bool done = false;
        while (!t[i]) {
            ++i;
            if (i == t.size()) {
                done = true;
                break;
            }
        }
        if (done) {
            break;
        }

        b[i] = true;
        for (int j = i; j < t.size(); j += i) {
            t[j] = false;
        }
    }

    while (true) {
        int a, d, n;
        cin >> a >> d >> n;
        if (a == 0 && d == 0 && n == 0) {
            return 0;
        }

        int count = 0;
        while (true) {
            if (b[a]) {
                count += 1;
                if (count == n) {
                    cout << a << endl;
                    break;
                }
            }
            a += d;
        }
    }
}

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

int main() {
    int p[105], i = 0;
    long long a, b, c;
    while(1) {
        string s;
        cin >> s;
        if(cin.eof())   break;
        switch (s[0]) {
            case '+':
                p[i-2] += p[i-1]; i--;
                break;
            case '-':
                p[i-2] -= p[i-1]; i--;
                break;
            case '*':
                p[i-2] *= p[i-1]; i--;
                break;
            case '/':
                p[i-2] /= p[i-1]; i--;
                break;
            default:
                p[i++] = stoi(s);
                break;
        }
    }
    cout << p[0] << endl;
    return 0;
}



Measured memory_bytes: 3200
n, x, y = map(int, input().split())
x = min(x - 1, y - 1)
y = max(x - 1, y - 1)
length = [0] * (n - 1)
for i in range(n - 1):
    for j in range(i, n):
        l = min(abs(i - j), abs(i - x) + 1 + abs(j - y), abs(i - y) + 1 + abs(j - x))
        if l != 0:
            length[l - 1] += 1
for l in length:
    print(l)

Measured memory_bytes: 48732
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  vector<vector<char>> board(h,vector<char>(w));
  int cnt=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>board[i][j];
      if(board[i][j]=='#')cnt++;
    }
  }
  if(cnt==h+w-1){
    cout<<"Possible"<<endl;
  }else{
    cout<<"Impossible"<<endl;
  }
  return 0;
}

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li k;

    cin>>k;

    li ans=0;

    f(i,1,k)
    {
        f(j,1,k)
        {
            f(l,1,k)
            {
                ans+=__gcd(i,__gcd(j,l));
            }
        }
    }

    cout<<ans;

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

struct mint {
	ll x;
	mint() :x(0) {}
	mint(ll x) :x((x% mod + mod) % mod) {}
	// mint(ll x):x(x){}
	mint& fix() { x = (x % mod + mod) % mod; return *this; }
	mint operator-() const { return mint(0) - *this; }
	mint operator~() const { return mint(1) / *this; }
	mint& operator+=(const mint& a) { if ((x += a.x) >= mod) x -= mod; return *this; }
	mint& operator-=(const mint& a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; }
	mint& operator*=(const mint& a) { (x *= a.x) %= mod; return *this; }
	mint& operator/=(const mint& a) { (x *= a.pow(mod - 2).x) %= mod; return *this; }
	mint operator+(const mint& a)const { return mint(*this) += a; }
	mint operator-(const mint& a)const { return mint(*this) -= a; }
	mint operator*(const mint& a)const { return mint(*this) *= a; }
	mint operator/(const mint& a)const { return mint(*this) /= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint res = pow(t / 2);
		res *= res;
		return (t & 1) ? res * x : res;
	}
	bool operator<(const mint& a)const { return x < a.x; }
	bool operator==(const mint& a)const { return x == a.x; }
};

template<typename T>
map<T, ll> factorize(T x) {
	map<T, ll> res;
	for (int i = 2; i * i <= x; i++) {
		while (x % i == 0) {
			x /= i;
			res[i]++;
		}
	}
	if (x != 1) res[x]++;
	return res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	map<ll, ll> LCM;
	rep(i, n) {
		for (auto& c : factorize(a[i])) {
			if (LCM[c.first] < c.second) {
				LCM[c.first] = c.second;
			}
		}
	}
	mint lcm = 1;
	for (auto& c : LCM) {
		rep(i, c.second) {
			lcm *= c.first;
		}
	}
	mint sum = 0;
	rep(i, n) {
		mint b = lcm / a[i];
		sum += b;
	}
	cout << sum.x << endl;
	return 0;
}


Measured memory_bytes: 896
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		sc.nextLine();
		
		final List<Integer> ls = new ArrayList<>();
		int max = -1;
		int maxId = -1;
		for (int i = 0; i < N; i++) {
			final int l = sc.nextInt();
			ls.add(l);
			
			if (l > max) {
				max = l;
				maxId = i;
			}
		}
		
		int sum = 0;
		for (int i = 0; i < N; i++) {
			if (i == maxId) {
				continue;
			}
			
			sum += ls.get(i);
		}
		
		if (max < sum) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 23124
n = int(input())
l = list(map(int, input().split()))
num_one = [0 for i in range(61)]
num_zero = [0 for i in range(61)]
for num in l:
    for i in range(61):
        if (num>>i)&1 == 1:
            num_one[i] +=1
        else:
            num_zero[i] +=1
ans  = 0
for i in range(61):
    ans += (num_one[i] *num_zero[i])%(10**9+7) * (2**i%(10**9+7))
    ans = ans%(10**9+7)
print(ans)

Measured memory_bytes: 125624
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
if sum(b)>sum(a):
    print(-1)
    exit()
p=[]
m=[]
sub=[]
for i in range(n):
    s=a[i]-b[i]
    if s>0:
        p.append(s)
    elif s<0:
        m.append(s)
p.sort(reverse=True)
ans=len(m)+min(len(m),1)
cnt=sum(m)
j=0
while cnt<0:
    if cnt+p[j]>=0:
        cnt+=p[j]
    else:
        cnt+=p[j]
        j+=1
        ans+=1
print(ans)


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

using namespace std;

int main(){
  int n; cin >> n;
  int a[2*n];
  for(int i = 0; i < 2*n; i++) cin >> a[i];
  int res = 0;
  sort(a, a+2*n);
  for(int i = 0; i < 2*n; i+=2){
    res += min(a[i], a[i+1]);
  }
  
  cout << res;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int w,h;
	char c;
	cin >> w >> h >> c;
	cout << '+';
	for(int i = 1; i < w - 1; i++) cout << '-';
	cout << '+' << endl;
	for(int i = 1; i < h - 1; i++){
		cout << '|';
		for( int j = 1; j < w - 1; j++){
			if(i == h / 2 && j == w / 2) cout << c;
			else cout << '.';
		}
		cout << '|' << endl;
	}
	cout << '+';
	for(int i = 1; i < w - 1; i++) cout << '-';
	cout << '+' << endl;
	return 0;
}


Measured memory_bytes: 3064
//BROWNIE TK

#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second

#define forz(i, n) for (int i = 0; i < n; i++)
#define forzm(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rforzm(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetlli tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order
using namespace std;

/*STD fucntions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        //y must be even now
        y = y >> 1; //y=y/2
        x = (x * x) % p;
    }
    return res;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{
    return a * b / gcd(a, b);
}
lli modi(lli a, lli m)
{
    // fermat little thm where m is prime
    return power(a, m - 2, m);
}
/*CODE BEGINS*/
int main()
{
    kira;
    lli n;
    cin>>n;
    ldb a[n];
    forz(i,n)cin>>a[i];
    ldb ans=0;
    sort(a,a+n);
    for(int i=0;i<n-1;i++)
    {
        a[i+1]=(a[i]+a[i+1])/2;
    }
    ans=a[n-1];
    cout<<deci(10)<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, m, q;
const int N = 2010;
char c[N][N];
int s1[N][N], s2[N][N], s3[N][N];
int main()
{
    scanf("%d%d%d", &n, &m, &q);
    for (int i = 1; i <= n; ++ i)
        scanf("%s", c[i] + 1);
    for (int i = 1; i <= n; ++ i)
        for (int j = 1; j <= m; ++ j)
        {
            s1[i][j] = s1[i - 1][j] + s1[i][j - 1] - s1[i - 1][j - 1] + (c[i][j] == '1');
            s2[i][j] = s2[i - 1][j] + s2[i][j - 1] - s2[i - 1][j - 1] + (c[i][j] == '1' && c[i - 1][j] == '1');
            s3[i][j] = s3[i - 1][j] + s3[i][j - 1] - s3[i - 1][j - 1] + (c[i][j] == '1' && c[i][j - 1] == '1');
        }
    for (int i = 1; i <= q; ++ i)
    {
        int x1, y1, x2, y2;
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
        int ss1 = s1[x2][y2] - s1[x1 - 1][y2] - s1[x2][y1 - 1] + s1[x1 - 1][y1 - 1],
            ss2 = s2[x2][y2] - s2[x1][y2] - s2[x2][y1 - 1] + s2[x1][y1 - 1],
            ss3 = s3[x2][y2] - s3[x1 - 1][y2] - s3[x2][y1] + s3[x1 - 1][y1];
        printf("%d\n", ss1 - ss2 - ss3);
    }
}


Measured memory_bytes: 53120
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define szxb 13
using namespace std;
int a[szxb];
inline void work(){sort(a,a+3),puts(((!((a[1]-a[0])-(a[2]-a[1])))?("YES"):("NO")));return;}
signed main()
{
	scanf("%d%d%d",&a[0],&a[1],&a[2]),work();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
using namespace std;
typedef long long ll;
template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INF = 1L << 60;
const int MOD = pow(10, 9) + 7;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N + 1);
    REP(i, 0, M) {
        int a;
        cin >> a;
        A[a] = -1;
    }

    vector<ll> dp(N + 1, 0);
    dp[0] = 1;
    REP(i, 1, N + 1) {
        if (A[i] == -1) continue;
        if (A[i - 1] != -1) dp[i] += dp[i - 1] % MOD;
        if (i > 1 && A[i - 2] != -1) dp[i] += dp[i - 2] % MOD;
    }
    cout << dp[N] % MOD << endl;

    return 0;
}

Measured memory_bytes: 1408
MAX = pow(10, 8)
N = 100
p = [None] * (N + 1)
m = [None] * (N + 1)
n = input()
for i in xrange(1, n + 1):
    m[i] = [None] * (N + 1)
    m[i][i] = 0
    p[i - 1], p[i] = map(int, raw_input().split())
    
for l in xrange(2, n + 1):
    for i in xrange(1, n - l + 2):
        j = i + l - 1
        m[i][j] = MAX
        for k in xrange(i, j):
            m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j])
print m[1][n]

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

int main()
{
    int a, b, dif, length = 0, ans;
    cin>>a>>b;
    dif = b - a;
    for(int i = dif; i > 0; i--)
        length += i;

    ans = length - b;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int zhuanhuan(string s)
{
	int k=0;
	for(int i=0;i<s.size();i++)
	{
		k=k*10+s[i]-'0';
	}
	return k;
}
int main()
{
	string a,b;
	cin>>a>>b;
	a=a+b;
	int ans=0;
	ans=zhuanhuan(a);
	if(sqrt(ans)==int(sqrt(ans))) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#-*- Coding: utf-8 -*-

S = input()
T = input()

X = []
for i in range(len(S)-len(T)+1):
    c = 0
    for j in range(len(T)):
        if S[i+j] == T[j]:
            c += 1
    X.append(c)
print(len(T) - max(X))


Measured memory_bytes: 9052
#include<stdio.h>
void insert_sort(int arr[],int len)
{
     for(int m=0;m<len;m++)//将原来的数组进行输出
                {
                     if(m>0) printf(" ");
                    printf("%d",arr[m]);
                }
                printf("\n");//换行，进行下一步输入
    for(int i=1;i<len;i++)
    {
        int key=arr[i];
        int j=i-1;
        while((j>=0)&&(key<arr[j]))
              {
                  arr[j+1]=arr[j];//此时while循环里只有j可以用啊
                  j--;
              }
              arr[j+1]=key;
            for(int k=0;k<len;k++)//将每一次的排序值输出
                {
                    if(k>0) printf(" ");
                    printf("%d",arr[k]);
                }

                printf("\n");
    }

}
int main()
{
    int n,A[1000];
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&A[i]);
    insert_sort(A,n);
    return 0;


}



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

#define ll long long
#define all(v) v.begin(), v.end()

double dist(pair<double, double> a, pair<double, double> b) {
	double d = 0;
	d = (a.first - b.first) * (a.first - b.first);
	d = d + ((a.second - b.second) * (a.second - b.second));
	return sqrt(d); 
}

int main() {
	
	long long f[10];
	double ans = 0;

	f[0] = 1;
	for(int i=1; i<=8; i++) {
		f[i] = f[i-1] * i;
	} 

	int n;
	cin >> n;
	vector<pair<double, double>> v(n+1);
	for(int i=1; i<=n; i++) {
		double x, y;
		cin >> x >> y;
		v[i] = {x, y};
	}

	for(int i=1; i<=n; i++) {
		for(int j=1; j<=n; j++) {
			ans = ans + (f[n-1] * dist(v[i], v[j]));
		}
	}

	cout << fixed << setprecision(8) << ans/f[n] << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    ll acc = 0, fac = 1;
    while(fac*(fac+1)/2 < n) {
        fac += 1;
    }
    while(n > 0) {
        if (n >= fac) {
            cout << fac << endl;
            n -= fac;
            fac--; 
        } else {
            cout << n << endl;
            break;
        }
    }
    return 0;
}


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

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            int n = Integer.parseInt(br.readLine());
            int k = Integer.parseInt(br.readLine());
            int ans = 1;
            for (int i = 0; i < n; i++) {
                int tmp1 = ans * 2;
                int tmp2 = ans + k;
                if (tmp1 > tmp2) {
                    ans = tmp2;
                } else {
                    ans = tmp1;
                }
            }
            System.out.println(ans);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
#define all(x) (x).begin(), (x).end()
using namespace std;
inline ll read()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N = 2e5 + 10;
int n, tot, head[N], To[N], Next[N], d[2][N];
void add(int x,int y)
{
	To[++ tot] = y; 
	Next[tot] = head[x]; 
	head[x] = tot;
}
void dfs(int x,int *d)
{
	for (int i = head[x]; i; i = Next[i])
	{
		int y = To[i];
		if (d[y] == -1)
			d[y] = d[x] + 1, dfs(y, d);
	}
}
int main()
{
	n = read();
	rep(i, 1, n - 1)
	{
		int x = read();
		int y = read();
		add(x, y); 
		add(y, x);
	}
	memset(d, -1, sizeof(d));
	d[0][1] = d[1][n] = 1;
	dfs(1, d[0]); 
	dfs(n, d[1]);
	int tmp = 0;
	rep(i, 1, n)
		if (d[0][i] <= d[1][i]) tmp ++; 
		else tmp --;
	puts((tmp > 0) ? "Fennec" : "Snuke");
	return 0;
}


Measured memory_bytes: 6912
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
int n;
using namespace std;
const int maxn=110;
int a[maxn];
int main(){
	std::ios::sync_with_stdio(false);
	memset(a,0,sizeof(a));
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		cout<<a[i];
		if(i==n-1){
			cout<<"\n";
		}
		else{
			cout<<" ";
		}
	}
	
	for(int i=1;i<n;i++){
		int key=a[i];
		int j=i-1;
		while(j>=0&&a[j]>key){
			a[j+1]=a[j];
			j--;
		}
		
		a[j+1]=key;
		for(int i=0;i<n;i++){
			cout<<a[i];
			if(i==n-1){
				
				cout<<"\n";
		}
			else{
				cout<<" ";
		}
			
		}
	
	}
	return 0;
}

Measured memory_bytes: 1200
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        int curMaxLength = 0;
        var hash = new RollingHash(s);
        for (int i = 0; i < s.Length; i++)
            for (int j = i; j < s.Length; j++)
                while (curMaxLength < j - i && j + curMaxLength < n && hash.Slice(i, curMaxLength + 1) == hash.Slice(j, curMaxLength + 1)) curMaxLength++;
        Console.WriteLine(curMaxLength);
    }
}

class RollingHash
{
    const ulong MASK30 = (1UL << 30) - 1;
    const ulong MASK31 = (1UL << 31) - 1;
    const ulong MOD = (1UL << 61) - 1;
    const ulong POSITIVIZER = MOD * ((1UL << 3) - 1);
    static uint Base;
    static ulong[] powMemo = new ulong[5000 + 1];
    static RollingHash()
    {
        Base = (uint)new Random().Next(129, int.MaxValue);
        powMemo[0] = 1;
        for (int i = 1; i < powMemo.Length; i++)
            powMemo[i] = CalcMod(Mul(powMemo[i - 1], Base));
    }

    ulong[] hash;

    public RollingHash(string s)
    {
        hash = new ulong[s.Length + 1];
        for (int i = 0; i < s.Length; i++)
            hash[i + 1] = CalcMod(Mul(hash[i], Base) + s[i]);
    }

    public ulong Slice(int begin, int length)
    {
        return CalcMod(hash[begin + length] + POSITIVIZER - Mul(hash[begin], powMemo[length]));
    }

    private static ulong Mul(ulong l, ulong r)
    {
        var lu = l >> 31;
        var ld = l & MASK31;
        var ru = r >> 31;
        var rd = r & MASK31;
        var middleBit = ld * ru + lu * rd;
        return ((lu * ru) << 1) + ld * rd + ((middleBit & MASK30) << 31) + (middleBit >> 30);
    }

    private static ulong Mul(ulong l, uint r)
    {
        var lu = l >> 31;
        var ld = l & MASK31;
        var rd = r & MASK31;
        var middleBit = lu * rd;
        return  ld * rd + ((middleBit & MASK30) << 31) + (middleBit >> 30);
    }

    private static ulong CalcMod(ulong val)
    {
        return val % MOD;
    }
}


Measured memory_bytes: 13264
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int A =a;
  while(a < 1<<30){
    if( a%b == c){
      cout << "YES";
      return 0;
    }
    else{
      a += A;
    }
  }
  cout << "NO";
    
}

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

int main() {
	multiset<string> s;
	int n, l;
	cin >> n >> l;

	for (int i = 0; i < n; i++) {
		string k;
		cin >> k;
		s.insert(k);
	}

	string ans;
	for (auto x : s) {
		ans = ans + x;
	}

	cout << ans << endl;

}

Measured memory_bytes: 3616
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next()) + 1;
        int y = Integer.parseInt(sc.next());
        int z = Integer.parseInt(sc.next());
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < y; i++) {
            set.add(Integer.parseInt(sc.next()));
        }
        HashMap<Integer, Boolean> map = new HashMap<>();
        for (int i = 0; i < x; i++) {
            if (set.contains(i)) {
                map.put(i, true);
            } else {
                map.put(i, false);
            }
        }
        int first_half = 0;
        int last_half = 0;
        for (int i = 0; i < x; i++) {
            if (i <= z) {
                if (map.get(i)) first_half++;
            } else {
                if (map.get(i)) last_half++;
            }
        }
        System.out.println(Math.min(first_half, last_half));
    }
}


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

int n;
string t[1002];

int main(){
  while(cin >> n){
    if(n == 0) break;

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

      int j = 0;

      for( ; j < t[i].size(); j++){
        if(t[i][j] != '.'){
          break;
        }
        t[i][j] = ' ';
      }

      j--;
      if(j >= 0){
        t[i][j] = '+';
      }

      for(int k = i - 1; k >= 0; k--){
        if(t[k][j] != ' '){
          break;
        }
        t[k][j] = '|';
      }
    }

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

Measured memory_bytes: 1984
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N),B(N+1);
    rep(i,N){
        cin >> A[i];
        A[i]--;
    }
    rep(i,N){
        B[i+1] += A[i] + B[i];
    }
    ll ans = 0;
    map<ll,ll> mp;
    for(int i=0;i<=N;i++){
        if(i>=K){
            mp[B[i-K]%K]--;
        }
        ans += mp[B[i]%K];
        mp[B[i]%K]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15872
S = input()
if S[0] != "A":
    print("WA")
    exit()
if S[2:-1].count("C") != 1:
    print("WA")
    exit()
c = S[2:-1].index("C") + 2
for i, s in enumerate(S):
    if i == 0 or i == c:
        continue
    if s.isupper():
        print("WA")
        exit()
print("AC")


Measured memory_bytes: 3060
array = []
3.times do
  a, b = gets.split(" ").map(&:to_i)
  array << a
  array << b
end

one = array.count(1)
two = array.count(2)
three = array.count(3)
four = array.count(4)

if one < 3 && two < 3 && three < 3 && four < 3
  puts "YES"
else
  puts "NO"
end

Measured memory_bytes: 1788
#include <cmath>
#include <complex>
#include <algorithm>
using namespace std;

#define PCR Point const &

typedef long double Real;
typedef complex<Real> Point;
struct Segment {
    Point p[2];
    Segment (PCR a = Point(), PCR b = Point()){
        p[0] = a, p[1] = b;
    }
    Point & operator [] (int k) { return p[k]; }
    Point const & operator [] (int k) const { return p[k]; }
};
typedef vector<Point> Polygon;
struct Circle { Real radius; Point center; };

#define X real()
#define Y imag()

Real dot(PCR a, PCR b){
    return a.X*b.X + a.Y*b.Y;
}
Real cross(PCR a, PCR b){
    return a.X*b.Y - a.Y*b.X;
}

Point pSP(Segment const & s, PCR p){
    Point base = s[1] - s[0];
    Real r = dot(p - s[0], base) / norm(base);
    return s[0] + base * r;
}

Point rSP(Segment const & s, PCR p){
    Point v = pSP(s,p) - p;
    return p + v * Real(2);
}

#include <iostream>
#include <cstdio>

int main(){
    Segment s;
    Real x,y;
    cin >> x >> y;
    s[0] = Point(x,y);
    cin >> x >> y;
    s[1] = Point(x,y);
    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        cin >> x >> y;
        Point p = rSP(s, Point(x,y));
        printf("%.10Lf %.10Lf\n", p.X, p.Y);
    }
}

Measured memory_bytes: 1248
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,n) for(int i=1; i<=(n); i++)

int main() {
    long long n,ans=0;
    cin>>n;
    vector<long long>a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    for(int i=0; i<n-1; i+=2){
        if(a[i]+a[i+1]<0){
            a[i]*=-1;
            a[i+1]*=-1;
        }
    }
    rep(j,n)ans+=a[j];
    cout<<ans;
	return 0;
}



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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
  int n,m;
  cin >> n >> m;
  //vector<int> x(m),y(m),z(m);
  UnionFind tree(n);
  for(int i=0;i<m;++i){
    int x,y,z;
    cin >> x >> y >> z;
    x--;
    y--;
    tree.unite(x,y);
  }
  set<int> se;
  for(int i=0;i<n;++i){
    se.insert(tree.root(i));
  }

  cout << se.size() << endl;

  return 0;
}


Measured memory_bytes: 8264
#include<stdio.h>
int main()
{
    int no;
    scanf("%d",&no);
    int a[no],min=101,i,sum=0;
    for(i=0;i<no;i++)
    {
        scanf("%d",&a[i]);
        sum=sum+a[i];
        if(a[i]%10!=0 && min>a[i])
        {
            min=a[i];
        }
    }
    if(sum%10!=0)
    {
        printf("%d\n",sum);
    }
    else if(sum%10==0)
    {
        if(min<100)
        {
            printf("%d\n",sum-min);
        }
        else
        {
            printf("0\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
from collections import defaultdict
from copy import deepcopy

N, W = map(int, input().split())

VW = []
for _ in range(N):
    VW.append(list(map(int, input().split())))

ans = 0
w2v = defaultdict(int)
w2v[0] = 0

for v, w in VW:
    new_w2v = deepcopy(w2v)
    for w_, v_ in w2v.items():
        new_w = w_ + w
        new_v = v_ + v
        if new_w <= W:
            ans = max(ans, new_v)
            new_w2v[new_w] = max(new_w2v[new_w], new_v)
    w2v = new_w2v
print(ans)




Measured memory_bytes: 7928
S = input()


slen = len(S)-1

ans = 0
for flag in range(1<<slen):
    j = 0
    for i in range(0,slen):
        if flag & 1<<i:
            ans += int(S[j:i+1])
            j = i + 1
    ans += int(S[j:])

print(ans)

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

using namespace std;

int main()
{
  int n,k;
  cin>>n>>k;
  int arr[n+3];
  for(int i=0;i<n;i++)
    cin>>arr[i];
  sort(arr,arr+n);
  int sum=0;
  for(int i=0;i<k;i++)
  {
    sum+=arr[i];
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3680
s = list(input())

a = 0
b = len(s) - 1

ans = 0
flag = True

while True:
    if a >= b:
        break
    if s[a] == s[b]:
        a += 1
        b -= 1
    else:
        if s[a] == 'x' :
            a += 1
            ans += 1
        elif s[b] == 'x':
            b -= 1
            ans += 1
        else:
            flag = False
            break

if flag:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 4084
H, W, D = map(int, input().split())

base = []
for h in range(H):
    num = list(map(int, input().split()))
    for w in range(W):
        base.append((num[w], h+1, w+1))

base.sort(key=lambda tup:tup[0])
dist = [0]*(W*H+D+1)
for i in range(W*H-D):
    wei1, h1, w1 = base[i]
    wei2, h2, w2 = base[i+D]
    dist[i+D] = dist[i] + abs(h1-h2) + abs(w1-w2)

Q = int(input())
for _ in range(Q):
    p0, p1 = map(int, input().split())
    print(abs(dist[p1-1]-dist[p0-1]))



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

int main(){
  string s;
  cin >> s;
  int l = s.size();
  for (int i = l-1; i > 0; i--) {
    if (i % 2 == 1) continue;
    for (int j = 0; j < i / 2; j++) {
      if (s[j] != s[j+i/2]) break;
      if (j == i/2-1) {
        cout << i << endl;
        return 0;
      }
    }
  }
  return 0;
}


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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////


//long long  Prime[3000000],nPrime;
//long long  mark[10000002];
//
//void seive(long long int n)
//{
//	long long int i,j,limit=sqrt(n*1.0)+2;
//	mark[1]=1;
//	for(i=4; i<=n ;i+=2)
//	mark[i]=1;
//	Prime[nPrime++]=2;
//	for(i=3; i<=n; i+=2)
//	{
//		if(!mark[i])
//		{
//			Prime[nPrime++]=i;
//			if(i<=limit)
//			{
//				for(j=i*i; j<=n ;j+=i*2)
//				{
//					mark[j]=1;
//				}
//			}
//		}
//	}
//}

int main()
{
    FASTIO;

    ll n , k;


    cin >> n >> k;


    ll a[n+1];

    for(int i=0; i<n; i++)
        cin >> a[i];

        sort(a,a+n);


        ll sum = 0;

        for(int i=0; i<k; i++)
            sum += a[i];

        cout << sum << endl;




    return 0;
}



Measured memory_bytes: 3672
if __name__ == '__main__':
    N, M = map(int, input().split())

    LR = [list(map(int, input().split())) for i in range(M)]

    LR1 = LR[0]
    maxL = LR1[0]
    minR = LR1[1]

    for tmp_LR in LR[1::]:
        tmp_L = tmp_LR[0]
        tmp_R = tmp_LR[1]

        if tmp_L >= maxL:
            maxL = tmp_L

        if tmp_R <= minR:
            minR = tmp_R

    my_list = range(maxL, minR + 1)

    answer = len(my_list)
    print(answer)


Measured memory_bytes: 28128
(n,),l = [list(map(int, s.split())) for s in open(0)]
ans = 0
for i in range(n):
    for j in range(i+1,n):
        if l[i] == l[j]:
            continue
        for k in range(j+1,n):
            if l[i] == l[k] or l[j] == l[k]:
                continue
            if l[i] + l[j] > l[k] and \
               l[i] + l[k] > l[j] and \
               l[k] + l[j] > l[i]:
                ans += 1
#                 print(i+1,j+1,k+1)
print(ans)

Measured memory_bytes: 9216
N = gets.to_i
ss, sst = [], Array.new(N){Array.new(N)}
N.times do |i|
    ss[i] = gets.chomp
    N.times {|j| sst[j][i] = ss[i][j]}
end
sst.map!{|row| row.join}
sum = 0
N.times do |i|
    sum += 1 if N.times.all?{|j|ss[j] == sst[j]}
    ss.map!{|str| str[-1] + str[0...-1]}
    sst.rotate!(-1)
end
puts sum*N

Measured memory_bytes: 27388
#include<bits/stdc++.h>
using namespace std;
int mod(int a , int b){
   if(a>b){
	return a-b;
   }
   else{
   	return b-a;
   }
}
int mincost( vector<int> &h , int n){
int dp[n];
dp[0]=0;
dp[1]=mod(h[0],h[1]);


for(int i=2;i<n;i++)
{
	dp[i]=min(dp[i-1]+mod(h[i],h[i-1]), dp[i-2]+mod(h[i],h[i-2]));
}
                
return dp[n-1];


}


int main(){
int n;
cin>>n;
vector<int> h;
int x;
for(int i=0;i<n;i++)
{
	cin>>x; 
	h.push_back(x);
}



cout<<mincost(h,n);

	return 0;
}

Measured memory_bytes: 1144
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        // Your code here!
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        String str = String.valueOf(a) + String.valueOf(b);
        
        int num = Integer.parseInt(str);
        
        // double result = Math.sqrt((double)num);
        // System.out.print(result);
        
        for(int i = 1; i<= 1000;i++){
            if(num == i * i){
                System.out.print("Yes");
                return;
            }
        }
        
        System.out.println("No");
    }
}


Measured memory_bytes: 39116
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a<b) {
        for (int i = 0; i < b; ++i) {
            cout<<a;
        }
    }
    else
        for (int j = 0; j < a; ++j) {
            cout<<b;
        }
}

Measured memory_bytes: 256