akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
constexpr int INF = 1001001001;
constexpr int DEBUG = 0;
using ll = long long;
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w));
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      cin >> s[i][j];
  
  vector<vector<int>> d(h * w, vector<int>(h * w, INF));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '.' && j + 1 < w && s[i][j + 1] == '.') {
        d[w * i + j][w * i + j + 1] = 1;
        d[w * i + j + 1][w * i + j] = 1;
      }
      if (s[i][j] == '.' && i + 1 < h && s[i + 1][j] == '.') {
        d[w * i + j][w * (i + 1) + j] = 1;
        d[w * (i + 1) + j][w * i + j] = 1;
      }
    }
  }
  
  if (DEBUG >= 2) {
    for (int i = 0; i < h * w; i++) {
      for (int j = 0; j < h * w; j++) {
        cout << d[i][j] << " ";
        if (j % w == w - 1)
          cout << "| ";
      }
      cout<< endl;
    }
  }
  
  for (int k = 0; k < h * w; k++){
    for (int i = 0; i < h * w; i++) {
      for (int j = 0; j < h * w; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  for (int i = 0; i < h * w; i++) {
    d[i][i] = 0;
  }
  
  if (DEBUG >= 1) {
    cout << "--" << endl;
    for (int i = 0; i < h * w; i++) {
      for (int j = 0; j < h * w; j++) {
        cout << d[i][j] << " ";
        if (j % w == w - 1)
          cout << "| ";
      }
      cout<< endl;
    }
  }
  
  int dmax = 0;
  for (int i = 0; i < h * w; i++) {
    for (int j = 0; j < h * w; j++) {
      if (d[i][j] != INF)
        dmax = max(dmax, d[i][j]);
    }
  }
  
  cout << dmax << endl;
  
  return 0;
}

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

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	static final int P = 1_000_000_007;
	
	void solve() throws IOException {
		int n = nextInt();
		int[] dp = {1, 0, 0};
		
		int[] inv = new int[n + 7];
		inv[1] = 1;
		for (int x = 2; x < inv.length; x++) {
			inv[x] = P - (int)((long)(P / x) * inv[P % x] % P);
		}
		
		int coef = 1;
		long ret = 0;
		for (int k = 1; k <= n; k++) {
			int[] nxt = new int[3];
			for (int j1 = 0; j1 < 3; j1++) {
				for (int j2 = 0; j2 < 3; j2++) {
					if (j1 != j2) {
						nxt[j2] += dp[j1];
						if (nxt[j2] >= P) {
							nxt[j2] -= P;
						}
					}
				}
			}
			
			dp = nxt;
			
			coef = (int)((long)coef * (n - k + 1) % P * inv[k] % P);
			
			int ways = (int)((long)dp[1] * coef % P);
			
			int delta = (int)((long)inv[3] * inv[n] % P * inv[k] % P * ways % P);
			
			ret += delta;
		}
		
		ret %= P;
		
		for (int i = 1; i < n; i++) {
			ret = ret * inv[3] % P;
		}
		
		out.println(ret);
	}

	void inp() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main().inp();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

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

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

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


Measured memory_bytes: 46676
#dp[i][j] denotes subarray from i to j left
n=int(input())
l=input().split()
li=[int(i) for i in l]
dp=[[0 for i in range(n)]for i in range(n)]
for i in range(n):
	dp[i][i]=li[i]
for gap in range(1,n):
	for start in range(n-gap):
		end=start+gap
		dp[start][end]=max(li[start]-dp[start+1][end],li[end]-dp[start][end-1])
print(dp[0][n-1])


Measured memory_bytes: 119900
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	x1 := nextFloat(sc)
	y1 := nextFloat(sc)
	x2 := nextFloat(sc)
	y2 := nextFloat(sc)

	xDis := x2 - x1
	yDis := y2 - y1
	fmt.Println(math.Sqrt(xDis*xDis + yDis*yDis))
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextFloat(sc *bufio.Scanner) float64 {
	i, err := strconv.ParseFloat(nextString(sc), 64)
	if err != nil {
		panic(err)
	}
	return i
}



Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
 
typedef struct {int from, to, w;} Edge;
 
int parent[100], rank[100];
Edge edge[10000];
 
int compare(const void *a, const void *b) {
    return ((Edge *)a)->w - ((Edge *)b)->w;
}
 
void init(int n) {
    int i;
    for (i = 0; i < n; i++) {
        parent[i] = i;
        rank[i] = 0;
    }
}
 
int find(int x) {
    return parent[x] != x ? parent[x] = find(parent[x]) : x;
}
 
void unite(int x, int y) {
    const int xr = find(x), yr = find(y);
    if (rank[xr] < rank[yr])
        parent[xr] = yr;
    else if (xr != yr) {
        parent[yr] = xr;
        rank[xr] += rank[xr] == rank[yr];
    }
}
 
int kruskal(int v, int e) {
    int i;
    int sum;
 
    qsort(edge, e, sizeof(Edge), &compare);
 
    init(v);
 
    sum = 0;
    for (i = 0; i < e; i++)
        if (find(edge[i].from) != find(edge[i].to)) {
            unite(edge[i].from, edge[i].to);
            sum += edge[i].w;
        }
 
    return sum;
}
 
int main(void) {
    int i, j;
    int n;
    int e;
 
    scanf("%d", &n);
 
    e = 0;
    for (i = 0; i < n; i++)
        for (j = 0; j < n; j++) {
            int a;
            scanf("%d", &a);
            if (a != -1)
                edge[e++] = (Edge){i, j, a};
        }
 
    printf("%d\n", kruskal(n, e));
 
    return 0;
}

Measured memory_bytes: 820
# coding: utf-8
# Your code here!
import sys
input = sys.stdin.readline

A, B, C, X = [int(input()) for _ in range(4)]

cnt = 0
for i in range(A+1):
    X1 = X - 500 * i
    if X1 == 0:
        cnt += 1
        continue
    for j in range(B+1):
        X2 = X1 - 100 * j
        if X2 == 0:
            cnt += 1
            continue
        for k in range(C+1):
            X3 = X2 - 50 * k
            if X3 == 0:
                cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
string s2,s1;
int ans;
int main()
{
	//freopen(".in","r",stdin);freopen(".out","w",stdout);
	cin>>s1>>s2;
	for(int i=0;i<3;i++){
		if(s1[i]==s2[i])ans++;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <numeric>
#include <tuple>

using namespace std;


int main(){
	int x;
	cin >> x;
	if (x == 3 || x == 5 || x == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    int k;
    in(k);
    if(k%2==0||k%5==0){
        out(-1);
        return 0;
    }
    if(k==1||k==7){
        out(1);
        return 0;
    }if(k%7==0)k/=7;
    int keta=1,modv=10%k,value1=1,value2=0;
    for(int i=1;1;i++){
        value1=(value1*modv)%k;
        value2=value1+keta;
        keta=value2%k;
        if(keta==0){
            out(i+1);
            return 0;
        }
    }
    out(-1);
}

Measured memory_bytes: 3812
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n,m,k,out;
int f(int x,int y){
	x=min(x,n-x-1),y=min(y,m-y-1);
	if(x==0||y==0)return 0;
	int a=(x-1)/k;
	int b=(y-1)/k;
	return min(a,b)+1;
}
int main(){
	cin>>n>>m>>k;
	out=inf;
	vs in(n);
	rep(i,n)cin>>in[i];
	rep(i,n)rep(j,m)if(in[i][j]=='S'){
		queue<pair<int,pii> >que;
		vvi used(n,vi(m));
		used[i][j]=1;
		que.push({i,{j,0}});
		while(!que.empty()){
			pair<int,pii> t=que.front();
			que.pop();
			out=min(out,f(t.first,t.second.first));
			rep(q,4){
				int x=t.first+dx[q];
				int y=t.second.first+dy[q];
				int c=t.second.second+1;
				if(x<0||y<0||x>=n||y>=m)continue;
				if(in[x][y]=='#')continue;
				if(used[x][y])continue;
				if(c==k+1)continue;
				used[x][y]=1;
				que.push({x,{y,c}});
			}
		}
		cout<<out+1<<endl;
	}
}










Measured memory_bytes: 3584
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	while(1){
		int m,nmin,nmax; cin >> m >> nmin >> nmax; if(m==0) return 0;
		int a[205];
		for(int i=1;i<=m;i++) cin >>a[i];
		int X = -1,ans =-1;
		for(int i=nmin;i<=nmax;i++){
			if(X <= a[i]-a[i+1]){
				X=a[i]-a[i+1]; ans=i;
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3056
using System;

namespace CakesandDonuts
{
    class Program
    {
        static void Main(string[] args)
        {
            string result = "No";
            byte n = byte.Parse(Console.ReadLine());

            if (n % 7 != 0 && n % 4 != 0)
            {
                int sevenNum = n / 7;
                if (7 * sevenNum + 4 == n || (sevenNum > 0 && (7 * (sevenNum - 1) + 8 == n || 7 * (sevenNum - 1) + 12 == n)))
                {
                    result = "Yes";
                }

                int fourNum = n / 4;
                if (fourNum > 0 && 4 * (fourNum - 1) + 7 == n)
                {
                    result = "Yes";
                }
            }
            else
            {
                result = "Yes";
            }

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>

int main(void)
{
	int i, n, a[100];
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	while (n--) {
		printf("%d", a[n]);
		putchar(n ? ' ' : '\n');
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define unique(a)        (a).erase(unique((a).begin(), (a).end()),(a).end())
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define mod 1000000007
double tick() { static clock_t oldt; clock_t newt = clock(); double diff = 1.0*(newt - oldt) / CLOCKS_PER_SEC; oldt = newt; return diff; }
typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
inline LL add(LL x, LL y) { x += y; if (x >= mod) x -= mod; return x; }
inline LL moduloMultiplication(LL x, LL y) { return (x%mod * 1LL * y%mod) % mod; }
inline LL power(LL a, LL b) {
	LL x = 1 % mod;
	while (b) {
		if (b & 1) x = moduloMultiplication(x, a);
		a = moduloMultiplication(a, a);
		b >>= 1;
	}
	return x % mod;
}
inline LL inv(LL a) { return power(a, mod - 2) % mod; }
LL gcd(LL a, LL b)
{
	if (!a)
		return b % mod;
	return gcd(b%a, a) % mod;
}


int main()
{
	int a, b;
	cin >> a >> b;
	cout << (a + b - 1) / b << endl;

}



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

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

    int time[110] = {0};
    for (int i = a; i < b; i++) {
        time[i]++;
    }
    for (int i = c; i < d; i++) {
        time[i]++;
    }
    int count = 0;
    for (int i = 0; i < 100; i++) {
        if (time[i] == 2) {
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	int i=0,j=0,k=0;
	while(n--){
		int p;
		cin>>p;
		if(p<=a)
			i++;
		else if(p<=b)
			j++;
		else 
			k++;
	}
	cout<<min(min(i,j),k)<<endl;
	return 0;
}

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

int main(){
    int N,K;
    cin >> N;
    char s[N];
    cin >> s;
    cin >> K;
    
    for(int i=0;i<N;i++){
        if(s[K-1]!=s[i]){
                cout << "*";
        }else{
            cout << s[i];
        }
        

    }
    
}


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

#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define ALL(v) begin(v), end(v)

/* REPmacro */
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (s); i >= (n); i--)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define rrep(i, n) RFOR(i, n - 1, 0)
#define rrepi(i, n) RFOR(i, n, 1)

/* debug */
#define pp(v) cerr << #v "=" << (v) << endl;

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using vs = vector<string>;
using Graph = vvi;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* iostream */
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
#define UNIQUE(v) v.erase( unique(ALL(v)), v.end() );
#define TIME system("date +%M:%S.%N")
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }
template<class T> T div_ceil(const T &a, const T &b) { return (a + b - 1) / b; }

signed main() {
  int n,T;cin>>n>>T;
  vi t(n);cin>>t;

  int ans = T;
  rep(i,n-1) {
    ans += min(t[i+1]-t[i], T);
  }
  cout << ans << endl;
}

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

int main() {
    int n, a[100000], x, y, k;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n, greater<>());
    for(k = 0, x = a[k++]; k < n && x != a[k]; x = a[k++]) ;
    for(k++,   y = a[k++]; k < n && y != a[k]; y = a[k++]) ;
    if (k == n) y = 0;
    cout << (long long)x * y << endl;
    return 0;
}


Measured memory_bytes: 640
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;
using static System.Math;
using static System.Console;
class E { static void Main() => new J(); }
class J
{
	const int Mod = 1000000007;
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F();
		var a = G();
		var min = long.MaxValue;
		var s = 0L;
		foreach (var x in a) s += x;
		var t = 0L;
		for (var i = 1; i < N; i++)
		{
			t += a[i - 1];
			var y = s - t;
			min = Min(min, Abs(t - y));
		}
		WriteLine(min);
	}
	long GCD(long a, long b)
	{
		var n = (ulong)Abs(a); var m = (ulong)Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Min(zm, zn);
	}
}

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

int main() {
	int N; cin >> N;
	vector<int> a(N);
	for( int &k : a ) cin >> k;
	if( N % 2 == 1 ) a.push_back(0);
	
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	
	int ans = 0;
	for( int i = 0; i < N; i += 2 ){
		ans += a[i] - a[i+1];
	}
	
	cout << ans << endl;
}

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

int main() {
    long N, K;
    cin >> N >> K;

    vector <long> monsters(N);
    for(long i = 0; i < N; i++){
        long tmp;
        cin >> tmp;
        monsters[i] = tmp;
    }
    sort(monsters.begin(), monsters.end());

    long ans = 0;
    for(long i = 0; i < N - K; i++){
        ans += monsters[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <set>
#include <queue>
using namespace std;

int main()
{
    int i,j,n,flag=1;
    cin>>n;
    for(i=1;i<10&&flag;i++)
    {
        for(j=1;j<=i&&flag;j++)
        {
            if(n==i*j)
            {
                flag=0;
                cout<<"Yes";
                break;
            }
            else if(n<i*j)
                break;
        }
    }
    if(flag)cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int n, x, y,  t;
  string r = "Yes";
  cin >> n;
  rep(i, n) {
    cin >> t >> x >> y;
    if ((x + y) > t || (t % 2) != (x + y) % 2) r = "No";
  }
  cout << r << endl;
  return 0;
}


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

using namespace std;

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

    if( a + b > c + d)
        cout << "Left" << endl;
    else if(a + b < c + d)
        cout << "Right" << endl;
    else
        cout << "Balanced" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>

using namespace std;

template<typename T, typename S>
istream& operator >> (istream& is, pair<T, S>& p) {
    is >> p.first >> p.second;
    return is;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& v) {
    for (auto& x : v) {
        is >> x;
    }
    return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& v) {
    for (auto& x : v) {
        os << x << " ";
    }
    os << "\n";
    return os;
}

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);

#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, t;
    cin >> n >> t;
    t -= t % 2;
    vector<int> a(n);
    cin >> a;
    int max_p;
    {
        map<int, int> a_to_cnt;
        for (auto x : a) {
            a_to_cnt[x]++;
            int min_a = a_to_cnt.begin()->first;
            max_p = max(max_p, x - min_a);
        }
    }
    int ans = 0;
    {
        map<int, int> a_to_cnt;
        int cur_min = -1, min_cnt = 0, max_cnt = 0;
        for (auto x : a) {
            a_to_cnt[x]++;
            int min_a = a_to_cnt.begin()->first;
            if (x - min_a == max_p) {
                ++ans;
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 8324
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#ifdef _MSC_VER
#  define __builtin_popcount __builtin_popcountll
#  define __builtin_popcountll __popcnt
#endif
#define int long long
using namespace std;
using ll = long long;
using ld = long double;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
inline void my_io() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << fixed << setprecision(10);
}
signed main() {
	my_io();
	string str;
	cin >> str;
	int count = 0;
	for (int i = 0; i < (int)str.size(); i++) {
		if (str[i] == '2') {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
  int A, B; cin>>A>>B;
  if(A<10 && B<10){
    cout<<A*B<<endl;
  }
  else{
    cout<<"-1"<<endl;
  }
    
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ll A, B, C; cin >> A >> B >> C;
  C *= 2;
  ll X, Y; cin >> X >> Y;
  ll res{};
  if(C <= A + B){
    while(X > 0 && Y > 0){
      res += C;
      --X; --Y;
    }
  }
  if(C <= B){
    while(Y > 0){
      res += C;
      --X; --Y;
    }
  }
  if(C <= A){
    while(X > 0){
      res += C;
      --X; --Y;
    }
  }
  while(X > 0){
    res += A;
    --X;
  }
  
  while(Y > 0){
    res += B;
    --Y;
  }

  cout << res << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int main(){
 int n;
 cin>>n;
 vector<vector<int>> a(n,vector<int>(n));
 for(int i=0;i<n;i++){
  for(int j=0;j<n;j++){
   cin>>a[i][j];
  }
 }
 vector<int> dp(1<<n);
 dp[0]=1;
 for(int mask=0;mask<(1<<n)-1;mask++){
  int i=__builtin_popcount(mask);
  for(int j=0;j<n;j++){
   if(a[i][j]&&!(mask&(1<<j))){
    int m2=mask^(1<<j);
    dp[m2]+=dp[mask];
    if(dp[m2]>=mod) dp[m2]-=mod;
   }
  }
 }
 cout<<dp[(1<<n)-1]<<endl;
 return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,H,W;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>H>>W;
	
	cout<<(N+1-H)*(N+1-W)<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
  cout << fixed << setprecision(12) << endl;
  long double w,h;
  cin >> w >> h;
  long double x,y;
  cin >> x >> y;
  long double ans;
  ans=w*h/2;
  cout << ans << " ";
  if(x==w/2 && y==h/2){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define debug(x) cout<<x<<endl
#define int long long 
const int mod=1000000007;
int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) { return b?gcd(b,a%b):a;}
inline int read() {int num=0, w=0;char ch=0;while (!isdigit(ch)) {w|=ch=='-';ch = getchar();}while (isdigit(ch)) {num = (num<<3) + (num<<1) + (ch^48);ch = getchar();}return w? -num: num;}
// cin.tie(0);
// ios::sync_with_stdio(false);
// head
// long long *long long 		**
struct node{
	
};
//all 
int a[1200000];
int b[1200000];
signed main()
{
	int n,m,k;
	cin>>n>>m>>k;
	int minx=9999999999999,miny=999999999999999999;
	rep(i,1,n+1){
		cin>>a[i];
		minx=min(a[i],minx);
	}
	rep(i,1,m+1){
		cin>>b[i];
		miny=min(b[i],miny);
	}
	int ans=minx+miny;
	for(int i=1;i<=k;i++){
		int l=0,r=0,z=0;
		cin>>l>>r>>z;
		ans=min(ans,a[l]+b[r]-z);
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3072
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

const int N = 1e5;
std::vector<std::vector<pair<int, int>>> g;
int n;
int ans[N];
int mx = 0;

void dfs(int i, int p, int c) {
  int now = 1;
  for(auto e : g[i]) {
    int j, eid;
    tie(j, eid) = e;
    if(j == p) continue;
    while(now == c) now++;
    dfs(j, i, now);
    ans[eid] = now;
    now++;
  }
  mx = max(mx, now-1);
}

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  cin >> n;
  g.resize(n);
  for(int i = 0; i < n - 1; i++) {
    int a, b; std::cin >> a >> b;
    a--; b--;
    g[a].emplace_back(b, i);
    g[b].emplace_back(a, i);
  }
  dfs(0, -1, 0);
  cout << mx << "\n";
  for(int i = 0; i < n - 1; i++) {
    cout << ans[i] << "\n";
  }
  return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
#include <atcoder/all>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define all(v) v.begin(), v.end() // sort(all(array))
#define INF 1000000000
#define LINF 1LL << 60
#define mod 1000000007
#define EPS 0.0001
using namespace std;
using namespace atcoder;
using ll = long long;
using vi = vector<int>; //vi array(要素数, 初期値)
using vll = vector<ll>;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>; //vvi table(行数, vi(列数, 初期値))
using vvc = vector<vc>;
using vvs = vector<vs>;
using vvb = vector<vb>;

int main()
{
    int n, m;
    cin >> n >> m;
    int a, b;
    dsu d(n);
    rep(i, m)
    {
        cin >> a >> b;
        a--;
        b--;
        d.merge(a, b);
    }
    set<int> leaders;
    rep(i, n){
        leaders.insert(d.leader(i));
    }
    cout << leaders.size() - 1 << endl;
}

Measured memory_bytes: 7540
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;


long double ans;
int N;

int main(void) {
    scanf("%d", &N);

    if (N % 2 == 0) ans = (long double) (N/2) / N;
    else ans = (long double) (N/2+1) / N;
    
    printf("%.10Lf\n", ans);

	return 0;
}


Measured memory_bytes: 256
import sys
import numpy as numpy
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 5)

N,M = map(int,input().split())
XY = [[] for i in range(N + 1)]

path = [-1] * (N + 1)

for i in range(M):
  x,y = map(int,input().split())
  XY[x - 1].append(y - 1)

  
def recur(n):
  if path[n] != -1:
    return path[n]
  
  elif XY[n] == []:
    path[n] = 0
    return path[n]
        
  else:
    ret = 0
    for chi in XY[n]:
      ret = max(ret,recur(chi) + 1)
    
    path[n] = ret
    return path[n]
    
for i in range(N):
  recur(i)

print(max(path))

Measured memory_bytes: 67936
N, X, mod = map(int, input().split())

val = [-1] * (mod + 100)
val[X] = 1

a = X
idx = 2
memo = [X]

while True:
    a = a * a % mod
    if val[a] != -1:
        last = a
        break
    memo.append(a)
    val[a] = idx
    idx += 1

# print(memo)
# print(last)

if N <= len(memo):
    print(sum(memo[:N]))
else:
    ans = sum(memo)
    N -= len(memo)
    i = memo.index(last)
    L = len(memo) - i

    sm = sum(memo[i:])
    d, m = divmod(N, L)
    ans += sm * d
    for x in range(i, i + m):
        ans += memo[x]
    print(ans)

Measured memory_bytes: 13532
#include "bits/stdc++.h"

#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define INF ((ll)1e9+7)
#define c(a) cout<<a<<"\n";
using namespace std;
const int N = 100005;



int main() {
	speed;
	cout << fixed << setprecision(6);
	/*start*/
	string s;
	cin >> s;
	c(count(All(s), '1'));
	return 0;
}



Measured memory_bytes: 764
#pragma GCC optimize ("-O3")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define vl vector<ll>
#define pb push_back
#define el '\n'
#define pll pair<ll, ll>
#define mll map<ll,ll>
#define vpll vector<pll>
#define vvll vector<vector<ll> >
#define vvpll vector< vector<pll> >
#define ff first
#define ss second
#define bitcount(a) __builtin_popcountll(a)
#define Tanny_12 {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
#define MOD 1000000007
#define fr(i,a,b) for(ll i=a ; i<b ; i++)
#define maxS 10000005
using namespace std;
using namespace __gnu_pbds;
// using namespace boost::multiprecision;
typedef long long ll;
typedef tree<ll,null_type,less_equal <ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

template<typename T>
void print(T arr[], ll size)
{
    fr(i,0,size)
        cout<<arr[i]<<" ";
}

int main()
{
    Tanny_12;
    
    // ll t; cin>>t; while(t--)
    {
        ll n, m;
        cin>>n>>m;
        ll a[n], sum = 0;
        fr(i,0,n)
            cin>>a[i], sum += a[i];
        
        long double tmp = (long double)sum/(4*m);
        // cout<<tmp<<" ";
        ll ans = 0, flg=0;
        fr(i,0,n)
        {
            if(a[i] >= tmp)
                ans++;
            if(ans == m)
            {
                flg = 1;
                break;
            }
        }
        
        if(!flg)
            cout<<"No\n";
        else
            cout<<"Yes\n";
    }
    
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
X, Y = map(int, input().split())

a, s = divmod(2*X - Y, 3)
b, t = divmod(-X + 2*Y, 3)

mod = 10 ** 9 + 7
N = 10 ** 6
fac = [1, 1]
finv = [1, 1]
inv = [0, 1]

def cmb(n, r, mod):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fac[n] * ( finv[r] * finv[n-r] % mod ) % mod
 
for i in range(2, N + 1):
  fac.append(( fac[-1] * i ) % mod)
  inv.append(mod - ( inv[mod % i] * (mod // i)) % mod)
  finv.append( finv[-1] * inv[-1]  % mod)

if s != 0 or t !=0:
  print(0)
else:
  print(cmb(a+b, a, mod))

Measured memory_bytes: 122016
# -*- coding: utf-8 -*-
import numpy as np

x = int(input())

num_500 = 0
num_5 = 0

while x >= 500:
    x -= 500
    num_500 += 1

while x >= 5:
    x -= 5
    num_5 += 1

ans = num_500 * 1000 + num_5 * 5

print(ans)
    

Measured memory_bytes: 21152
program main
  implicit none
  integer :: N

  read (*,*) N

  if ( N/100 == 7 ) then
     write(*,'(a)') 'Yes'
     stop
  else if ( (N-N/100*100)/10 == 7 ) then
     write(*,'(a)') 'Yes'
     stop
  else if ( N - N/100*100 - (N-N/100*100)/10*10 == 7 ) then
     write(*,'(a)') 'Yes'
     stop
  end if
  write(*,'(a)') 'No'

end program main


Measured memory_bytes: 2924
n = int(input())
l = list(map(int,input().split()))
dp = [0]*n
dp[0] = 0
dp[1] = abs(l[1]-l[0])

for i in range(2,n):
    dp[i] = min((dp[i-1]+abs(l[i]-l[i-1])),(dp[i-2]+abs(l[i]-l[i-2])))

print(dp[-1])

Measured memory_bytes: 13928
_n, k = gets.chomp.split(' ').map(&:to_i)
s = gets.chomp

xss = []
s.split('').each do |x|
  if xss.empty?
    xss.push([x])
  else
    if xss.last[0] == x
      xss.last.push(x)
    else
      xss.push([x])
    end
  end
end

# p xss

def sum(xss)
  xss.map(&:size).reduce(0) { |acc, x| acc + x }
end

ans = 0
prev_sum = nil
prev_yss = nil
xss.each_with_index do |xs, i|
  next if i != 0 && xs[0] == '0'
  count = xs[0] == '0' ? 2 * k : 2 * k + 1
  yss = xss.slice(i, count)

  # p yss

  sum = nil
  if prev_sum
    prev_chunk = prev_yss[0][0] == '0' ? prev_yss.slice(0, 1) : prev_yss.slice(0, 2)
    current_chunk = yss[-1][0] == '0' ? yss.slice(-1, 1) : yss.slice(-2, 2)
    sum = prev_sum - sum(prev_chunk) + sum(current_chunk)
    # p "minus: #{prev_chunk}"
    # p "plus: #{current_chunk}"
    # p sum
  else
    sum = sum(yss)
    # p [sum]
  end
  # p yss
  ans = [ans, sum].max

  prev_sum = sum
  prev_yss = yss
  # p '-'
  break if i + count >= xss.size
end

puts ans


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

#define ll long long



void solve(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a-b==b-c)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;   
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 256
N,M = list(map(int,input().split()))
KS = [list(map(int,input().split())) for _ in range(M)]
P = list(map(int,input().split()))
ans = 0
for bit in range(1<<N):
    for i,ks in enumerate(KS):
        SUM = 0
        for s in ks[1:]:
            if bit & (1<<(s-1)):
                SUM += 1
        if SUM%2 != P[i]:
            break
    else:
        ans += 1
print(ans)


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

int main() {
    string S; long long K;
    cin >> S >> K;
    int n = S.length();

    long long ans = 0;
    long long tans = 0;

    vector<long long> retsu;
    long long renzoku = 1;
    char p = S[0];
    for(int i = 1; i < n; i++) {
        if (p == S[i]) {
            renzoku += 1;
        } else  {
            retsu.push_back(renzoku);
            renzoku = 1;
        }
        p = S[i];
    }
    if (n == 2 && retsu.size() == 1) retsu.push_back(1); 
    if (renzoku != 1) {
        retsu.push_back(renzoku);
    }
    if(retsu.size() <= 1) {
        ans = n * K / 2;
        cout << ans << endl;
    } else {
        for (int i=1; i < retsu.size()-1; i++) {
        ans += retsu[i] / 2;
        }
        ans *= K;
        if(S[0] == S[n-1]) {
            tans = ((retsu[0] + retsu[retsu.size()-1]) / 2) * (K-1);
            tans += retsu[0] / 2 + retsu[retsu.size()-1] / 2;
        } else {
            tans = (retsu[0] / 2 + retsu[retsu.size()-1] / 2) * K;
        }
        ans += tans;
        cout << ans << endl;
    }
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

ll gcd(ll a, ll b)
{
    ll r = a % b;
    if (r == 0)
        return b;
    return gcd(b, r);
}

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

    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int g = a[0];

    rep(i, n) g = gcd(g, a[i]);

    OP(g);

    return 0;
}

Measured memory_bytes: 640
import math
import fractions

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a,b=map(int,input().split())
k=fractions.gcd(a,b)

F=factorization(k)
if F==[[1,1]]:
  print(1)
else:
  print(len(F)+1)
  
      


Measured memory_bytes: 5088
#include <algorithm>
#include <iostream>
#include <stdio.h>

#define MAX_N 100
#define INF 1'000'000'000'000'000'000

typedef long long ll;

using namespace std;

int A[MAX_N];

int main() {
  int N;
  cin >> N;
  int up = -100;
  int low = 100;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    up = max(up, A[i]);
    low = min(low, A[i]);
  }
  ll res = INF;
  for (int i = low; i <= up; ++i) {
    ll t = 0;
    for (int j = 0; j < N; ++j) {
      t += (i - A[j]) * (i - A[j]);
    }
    res = min(res, t);
  }
  printf("%lld\n", res);
}

Measured memory_bytes: 3248
N = int(input())
p = list(map(int, input().split()))

cnt = 0
for n in range(1, N+1):
    if p[n-1] != n:
        cnt += 1
if cnt == 2 or cnt == 0:
    result = 'YES'
else:
    result = 'NO'
print(result)


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define ll long long
#define LIM 1000
using namespace std;
int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i += 2) {
    cout << s[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main{

	public static void main(String[] args) {
		// TODO 自动生成的方法存根
		Scanner sc=new Scanner(System.in);
		String s=sc.nextLine();
		//以" "分割
		String[] str=s.split(" ");
		for(int i=0;i<str.length;i++) {
			char up=Character.toUpperCase(str[i].charAt(0));
			System.out.print(up);
		}
		System.out.println();

	}

}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long int
#define db double
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define endl "\n"
#define mp make_pair
#define f first
#define s second
ll power(ll x, ll y, long long int mod = 1000000007){ ll ans = 1;x %= mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
ll modInverse(ll a, ll m){ll m0 = m;ll y = 0, x = 1;if (m == 1) return 0;while (a > 1){ ll q = a / m;ll t = m;m = a % m,a = t;t = y;y = x - q * y;x = t;}if(x < 0) x += m0;return x;}

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

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){

	int n;
	double t,w;
	int flg=0;
	while(scanf("%d,%lf,%lf",&n,&w,&t)!=EOF){
	if(w/t/t>=25.0)flg=1,cout<<n<<endl;
	}
	if(flg==0)cout<<"該当なし"<<endl;


	return 0;
}

Measured memory_bytes: 1232
#include<cstdio>
#include<algorithm>
#define N_ 101000
using namespace std;
int n, S, R[N_];
int X[N_], P[N_];
long long res;
int main() {
	int i;
	scanf("%d%d", &n, &S);
	for (i = 1; i <= n; i++) {
		scanf("%d%d", &X[i],&P[i]);
	}
	if (S < X[1]) {
		printf("%d\n", X[n] - S);
		return 0;
	}
	if (S > X[n]) {
		printf("%d\n", S - X[1]);
		return 0;
	}
	int b = 1, e = n, dir;
	long long sum = 0;
	if (P[1] >= P[n]) {
		R[n] = n;
		sum += P[n];
		e--;
		dir = 0;
	}
	else {
		R[n] = 1;
		sum += P[1];
		b++;
		dir = 1;
	}
	int pv = n - 1;
	while (1) {
		if (S < X[b] && S < X[e]) {
			for (i = e; i >= b; i--)R[pv--] = i;
			break;
		}
		if (S > X[b] && S > X[e]) {
			for (i = b; i <= e; i++)R[pv--] = i;
			break;
		}
		if (dir == 0) {
			if (sum + P[b] >= P[e]) {
				R[pv--] = e;
				sum += P[e];
				e--;
				dir = 0;
			}
			else {
				R[pv--] = b;
				sum += P[b];
				b++;
				dir = 1;
			}
		}
		else {
			if (P[b] >= P[e] + sum) {
				R[pv--] = e;
				sum += P[e];
				e--;
				dir = 0;
			}
			else {
				R[pv--] = b;
				sum += P[b];
				b++;
				dir = 1;
			}
		}
	}
	for (i = 1; i < n; i++) {
		res += abs(X[R[i + 1]] - X[R[i]]);
	}
	res += abs(X[R[1]] - S);
	printf("%lld\n", res);
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main() {
    int N; cin >> N;
    vector<long long> a(N*3);
    for (int i = 0; i < N*3; ++i) cin >> a[i];

    // 左から前処理
    vector<long long> S(N*2+1, 0);
    priority_queue<long long, vector<long long>, greater<long long> > que1;
    for (int i = 0; i < N; ++i) {
        S[i+1] = S[i] + a[i];
        que1.push(a[i]);
    }
    for (int i = N; i < N*2; ++i) {
        long long mi = que1.top();
        if (a[i] > mi) {
            S[i+1] = S[i] - mi + a[i];
            que1.pop();
            que1.push(a[i]);
        }
        else S[i+1] = S[i];
    }

    // 右から前処理
    vector<long long> T(N*2+ 1, 0);
    priority_queue<long long> que2;
    for (int i = 0; i < N; ++i) {
        T[i+1] = T[i] + a[N*3-1 - i];
        que2.push(a[N*3-1 - i]);
    }
    for (int i = N; i < N*2; ++i) {
        long long ma = que2.top();
        if (a[N*3-1 - i] < ma) {
            T[i+1] = T[i] - ma + a[N*3-1 - i];
            que2.pop();
            que2.push(a[N*3-1 - i]);
        }
        else T[i+1] = T[i];
    }

    // 集計
    long long res = -(1LL<<60);
    for (int i = N; i <= N*2; ++i) {
        res = max(res, S[i] - T[N*3-i]);
    }
    cout << res << endl;
}

Measured memory_bytes: 11120
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <sstream>
#include <random>
#include <queue>
#include <stack>
#include <limits>
#include <cmath>
#include <numeric>

int main(int argc, char* argv[]) {
	// 入力
	int n;
	std::cin >> n;

	int a = 2;
	int b = n;

	int x = a * b;
	int r = a % b;
	while(r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	// 出力
	std::cout << x/b << std::endl;

	return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define MAX 100000

vector<int> l[MAX], e[MAX];
vector<bool> b(MAX, false);

void dfs(int s){
	b[s]=true;
	for(int i=0; i<e[s].size(); i++){
		if(!b[e[s][i]]){
			dfs(e[s][i]);
		}
	}
	return;
}

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

	for(int i=0; i<n; i++){
		int k;
		cin >> k;
		for(int j=0; j<k; j++){
			int t;
			cin >> t;
			l[t-1].push_back(i);
		}
	}

	for(int i=0; i<MAX; i++){
		for(int j=1; j<l[i].size(); j++){
			e[l[i][j]].push_back(l[i][j-1]);
			e[l[i][j-1]].push_back(l[i][j]);
		}
	}

	int cnt=0;
	for(int i=0; i<n; i++){
		if(!b[i]){
			dfs(i);
			cnt++;
		}
	}
	if(cnt==1) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

int findSumOfDigits(int n){
        int sum = 0;
        while(n!=0){
                sum += n%10;
                n/=10;
        }
        return sum;
}

int N;

int main()
{       
        cin >> N;
        if(N%findSumOfDigits(N)==0){
                cout << "Yes\n";
        }else{  
                cout << "No\n";
        }       
}       

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <list>
#include <cmath>
#include <numeric>
#include <sstream>
#include <iomanip>
using ll = long long;
using namespace std;
#define INF 999999999

int main()
{
    typedef pair<ll, ll> p;
    int N, M;
    cin >> N >> M;
    vector<p> d(N);
    for (int i = 0; i < N; i++)
    {
        cin >> d[i].first;
        cin >> d[i].second;
    }
    sort(d.begin(), d.end());
    int m = 0;
    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans += d[i].first * d[i].second;
        m += d[i].second;
        if (m >= M)
        {
            ans -= d[i].first * (m - M);
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792