akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

const ll INF = 1e9;

struct edge{
    int to;
    int cost;
};

vecveci dist(210,veci(100010,INF)); 
vector<vector<edge>> G(100010,vector<edge>());

void dijkstra(const vector<vector<edge>> &G, int s) {
    priority_queue<P,vector<P>,greater<P>> que;
    dist[s][s] = 0;
    que.push(P(0,s));

    while(!que.empty()) {
        P p1 = que.top();
        que.pop();
        int v = p1.second;
        if(dist[s][v] < p1.first) continue;

        for (auto e : G[v]) {  
            if (dist[s][e.to] > dist[s][v] + e.cost) {
                dist[s][e.to] = dist[s][v] + e.cost;
                que.push(P(dist[s][e.to], e.to));
            }
        }
    }
}

int main() {
    int N,M,R; cin >> N >> M >> R;
    veci r(R);
    REP(i,R) cin >> r[i];
    REP(i,R) r[i]--;
    REP(i,M) {
        int a,b,c; cin >> a >> b >> c;
        a--; b--;
        G[a].push_back({b,c});
        G[b].push_back({a,c});
    }

    REP(i,R) {
        dijkstra(G,r[i]);
    }

    int ans = INF;

    sort(r.begin(),r.end());

    do{
        //REP(i,R) cout << r[i] << " ";
        //cout << endl;
        int total = 0;
        REP(i,R-1) {
            total += dist[r[i]][r[i+1]];
        }
        //cout << total << endl;
        chmin(ans,total);
    }while(next_permutation(r.begin(),r.end()));

    cout << ans << endl;
}


Measured memory_bytes: 88308
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;

int main(){
  long long N,M;
  cin >> N >> M;
  vector<long long> A(M);
  long long sum=0;
  for(int i=0; i<M; i++){
    cin >> A.at(i);
    sum += A.at(i);
  }

  if(N<sum){
    cout << -1 << endl;
  }
  else{
    cout << N-sum << endl;
  }
  
  return 0;
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 200009, mod = 1000000007;
int n, c[N];

int pow(int a, int b) {
    if(b == 0) return 1;
    if(b%2) return a*pow(a, b-1)%mod;
    return pow(a*a%mod, b/2)%mod;
}

int32_t main() {

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

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

    sort(c, c+n, greater<int>());

    int ans = 0;
    for(int i = 0; i < n; ++i) {
        ans = (ans + c[i]*(i+2))%mod;
    }

    ans = (ans*pow(4LL, n-1))%mod;

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


Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;

int main() {
	int64_t a, b, n;
	cin >> a >> b >> n;

	int c = n / b;
	int m = 0;
	for (int i = 0; i < c; i++) {
		int64_t f = 0;
		f = floor(a*(b - 1) / b) - a * i;

		if (m < f) m = f;
	}

	if (m < (floor(a*n / b) - a * floor(n / b))) m = floor(a*n / b) - a * floor(n / b);

	cout << m << endl;
}

Measured memory_bytes: 3644
uses crt;
const m = 100000;
var
        g,s: array [0..m,0..3] of longint;
        i,j,k,n,s1: longint;

begin
        clrscr;
        readln (n);
        for i:=1 to n do
        readln ( g[i, 1], g[i,2], g[i,3]);

        for i:=1 to 3 do s[1,i]:= g[1,i];
        for i:=2 to n do
        begin
                j:=0;
                repeat
                        inc(j); k:=0; s1:=0;

                        repeat
                                inc(k);
                                if ( k <> j) and ( s[i-1,k] >= s1) then s1:= s[i-1,k];
                        until k = 3;

                        s[i,j]:= s[i,j] + s1 + g[i,j];
                until j=3;

        end;

        s1:= 0;
        for i:=1 to 3 do if  s[n,i] > s1 then s1:= s[n,i];
        write (s1);
        readln;
end.

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

int main(){
	int n;
	int min=10000;
	int max=0;
	int x[100];
	int sum=0;
	int result=0;
	int i=0;
	int j=0;
	int k=0;
	int d=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x[i];
		if(max<=x[i]) max=x[i];
		if(min>=x[i]) min=x[i];
	}
	
	for(i=min;i<max+1;i++){// i=place
		for(j=0;j<n;j++){//j=people
			sum=sum+(x[j]-i)*(x[j]-i);
		}
		if(i==min){
			result=sum;
		}else{
			if(sum<result){
				result=sum;
			}
		}
		sum=0;
	}
	cout<<result;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
void Xtox(char *c) {
	int n = 0;
	while(c[n] != '\0') ++n;
	rep(i,n) {
		if(c[i] - 'a' < 0 || c[i] - 'a' >= 26) {
			if(c[i] - 'A' >= 0 && c[i] - 'A' < 26) {
				c[i] = (char) ('a' + (c[i] - 'A'));
			}
		}
	}
}
int main() {
	char s[20], p[1010];
	int ret = 0;
	scanf("%s", s);
	Xtox(s);
	while(1) {
		scanf("%s", p);
		if(!strcmp(p, "END_OF_TEXT")) break;
		Xtox(p);
		if(!strcmp(s, p)) ret++;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1156
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

const double PI=3.14159265358979323846;

int main() {
    int R; cin >> R;
    printf("%.10f\n",2 * PI * R);
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+500;
int X;
bool vis[maxn];
int main(){
	for(int i=0;i<=5;i++)vis[100+i]=1;
	cin>>X;
	if(X<100){
		cout<<0<<endl;return 0;
	}
	for(int i=2;i<=1000;i++)
	{
		for(int j=100;j<=X;j++)
		if(vis[j]){
			for(int k=100;k<=105;k++)
			vis[j+k]=1;
		}
	}
	if(vis[X])cout<<1<<endl;
	else cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 384
N = int(input())
S = [input() for _ in range(N)]
B1 = []
B2 = []
for s in S:
    ncl = nop = 0
    for c in s:
        if c=='(':
            nop+=1
        else:
            if nop>0: nop-=1
            else: ncl+=1

    if nop-ncl>=0:
        B1.append((nop, ncl))
    else:
        B2.append((nop, ncl))

#print(B)
    
Bl = sorted(B1, key=lambda x:x[1])
Br = sorted(B2, key=lambda x:x[0])

xl = 0
for nop, ncl in Bl:
    if ncl>xl:
        print('No')
        exit()
    xl+=nop-ncl

xr = 0
for nop, ncl in Br:
    if nop>xr:
        print('No')
        exit()
    xr+=ncl-nop

print('Yes' if xl==xr else 'No')

Measured memory_bytes: 99724
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<math.h>

//#define DIV 1000000007
using namespace std;
using ll = long long;

typedef struct {
	int par = 0;
	int hei = 1;
	ll mem = 1;
}node_t;
vector<node_t> node;

int root(int a) {
	if (node[a].par == 0) return a;
	else {
		node[a].par = root(node[a].par);
		return node[a].par;
	}
}
//changed
void unite(int root_a, int root_b) {
	int up, low;
	if (node[root_a].hei >= node[root_b].hei)
		up = root_a, low = root_b;
	else
		up = root_b, low = root_a;

	node[up].hei = max(node[up].hei, node[low].hei + 1);
	node[low].par = up;
	node[up].mem += node[low].mem;
}
int main(void) {
	ll N, M;
	cin >> N >> M;

	vector<pair<int, int>> bri(M);
	for (int i = 0; i < M; i++) {
		cin >> bri[i].first >> bri[i].second;
	}

	node = vector<node_t>(N + 1);
	vector<ll> ans(M);
	ans[M - 1] = N * (N - 1) / 2;
	for (int i = M - 1; i >= 1; i--) {
		ans[i - 1] = ans[i];
		int a = bri[i].first, b = bri[i].second;
		int art = root(a), brt = root(b);
		if (art == brt) continue;
		ll temp = node[art].mem * node[brt].mem;
		ans[i - 1] -= temp;
		unite(art, brt);
	}

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

}


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

const int MX = 100005;

pair<int, int> A[2 * MX];

int s[MX];
int cnt[MX];


int main()
{
	int n;
	ignore = scanf("%d", &n);
	
	ll sumA = 0, sumB = 0;
	
	for (int i = 0; i < n; i++) {
		int a, b;
		ignore = scanf("%d %d", &a, &b);
		sumA += a;
		sumB += b;
		A[2 * i] = {a, i};
		A[2 * i + 1] = {b, i};
		s[i] = a + b;
	}

	ll ans = min(sumA, sumB);
		
	sort(A, A + 2 * n);
	
	ll sum = 0;
	int mx1 = 0, mx2 = 0;
	for (int i = 0; i < n; i++) {
		sum += A[i].first;
		cnt[A[i].second]++;
			
		if (A[i].first >= mx1) {
			mx2 = mx1;
			mx1 = A[i].first;
		}
		else if (A[i].first >= mx2) {
			mx2 = A[i].first;
		}
	}
	
	bool found = false;
	for (int i = 0; i < n; i++) {
		if (cnt[i] == 2) {
			found = true;
			break;
		}
	}
	
	if (found) {
		ans = min(ans, sum);
	}
	else {		
		for (int i = 0; i < n; i++) {
			if (A[i].first == mx1) {
				ans = min(ans, sum + s[A[i].second] - A[i].first- mx2);
			}
			else {
				ans = min(ans, sum + s[A[i].second] - A[i].first - mx1);
			}
		}
	}
	
	cout << ans;
}


Measured memory_bytes: 2560
#include<stdio.h>

int main(){
  char a[4];
  int i;
  int count = 0;
  for(i = 0;i<4;i++){
    scanf("%c",&a[i]);
    if(a[i] == '+'){
      count++;
    }
  }
    if(count == 0){
      printf("-4\n");
    }else if(count == 1){
      printf("-2\n");
    }else if(count == 2){
      printf("0\n");
    }else if(count == 3){
      printf("2\n");
    }else if(count == 4){
        printf("4\n");
    }
    return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)



int main() {

    int n,c; cin >> n >> c;

    vector<vector<int>> D(c, vector<int>(c, 0));
    vector<vector<int>> C(3, vector<int>(c,0));

    int tmp;
    rep(i, c) rep(j, c) cin >> D[i][j];
    rep(i, n) rep(j, n) {
        cin >> tmp;
        C[(i+j)%3][tmp-1]++;
    }

    // 適当に大きい値を
    int ans = INT_MAX;

    // 30 * 29 * 28通りの色の組み合わせを見立て行く
    rep(i, c) rep(j, c) if(i != j) rep(k, c) {
        if(i != k && j != k) {
            tmp = 0;
            rep(l, c) tmp += D[l][i] * C[0][l];
            rep(l, c) tmp += D[l][j] * C[1][l];
            rep(l, c) tmp += D[l][k] * C[2][l];
            ans = min(ans, tmp);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
### subroutines

def get_div(prev, n)
  prev = n if prev > n
  return $gdcache[prev][n] if ! $gdcache[prev][n].nil?

  n0 = [prev, n].min
  ret = []

  while n0 >= 1
    nn = n - n0
    if nn == 0
      ret << [n0]
    else
      ret0 = get_div(n0, nn)
      for r in ret0
        ret << ([n0] + r)
      end
    end

    n0 -= 1
  end

  $gdcache[prev][n] = ret
end

### main

loop do
  n = gets.strip.to_i
  break if n == 0

  $gdcache = (n + 1).times.map{[]}

  for i in (1..n)
    $gdcache[i][1] = [[1]]
  end

  ret = get_div(n, n)

  for ns in ret
    puts ns.join(' ')
  end
end

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

int main()
{
    int r, g, b, n;
    scanf("%d %d %d", &r, &g, &b);
    n = 100 * r + 10 * g + b;
    if (n % 4 == 0) {
        printf("YES");
    }
    else {
        printf("NO");
    }
}


Measured memory_bytes: 256
using System;
using System.Linq;    
class Program
    {
        static void Main(string[] args)
        {
            //C - Streamline
            //https://atcoder.jp/contests/abc117/tasks/abc117_c
            var readArray = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
            int n = readArray[0];
            int m = readArray[1];
            int[] intArray = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
            Array.Sort(intArray);

            if (n >= m)
            {
                Console.WriteLine(0);
                return;
            }

            //差の配列
            int[] diff = new int[m - 1];
            for (var i = 0; i < m - 1; i++)
            {
                diff[i] = intArray[i + 1] - intArray[i];
            }
            Array.Sort(diff);

            //移動しなければならない分だけ差を足す
            Int64 total = 0;
            for (var i = 0; i < m - n; i++)
            {
                total += diff[i];
            }

            Console.WriteLine(total);
        }
    }

Measured memory_bytes: 20704
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int cost = scanner.nextInt();
    int total = scanner.nextInt();
    int max = scanner.nextInt();
 
    if (cost == 0) {
	  System.out.println(0);
    } else {
      System.out.println(Math.min(max, total / cost));
    }
  }
}

Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {

	void main() {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int c = sc.nextInt();
		int[][] table = new int[r+1][c+1];
		for(int i=0;i<r;i++) {
			for(int j=0;j<c;j++) {
				table[i][j] = sc.nextInt();
				}
		}
		for(int i=0;i<r;i++) {
			for(int j=0;j<=c;j++) {
				if(j!=c) {
					table[i][c] += table[i][j];
				}
				table[r][j] += table[i][j];
			}
		}
		for(int i=0;i<=r;i++) {
			for(int j=0;j<=c;j++) {
				if(j==0) {
					System.out.print(table[i][j]);
				}
                         else {
					System.out.print(" "+table[i][j]);
				}
			}
			System.out.println();
		}
		
	}
	
	public static void main(String[] args) {
		new Main().main();
        }
}


  

 





Measured memory_bytes: 41912
#include<iostream>

using namespace std;

int main() {
	int mon, date;
	while (cin >> mon >> date) {
		if (mon == 0) {
			break;
		}
	int year = 2004, tmp;
		if (0 < mon && mon <= 2) {
			year -= 1;
			mon += 12;
		}
		tmp = year;
		tmp += int(year / 4);
		tmp -= int(year / 100);
		tmp += int(year / 400);
		tmp += int((mon * 13 + 8) / 5);
		tmp += date;
		tmp %= 7;
		if (tmp == 0) {
			cout << "Sunday" << endl;
		}
		if (tmp == 1) {
			cout << "Monday" << endl;
		}
		if (tmp == 2) {
			cout << "Tuesday" << endl;
		}
		if (tmp == 3) {
			cout << "Wednesday" << endl;
		}
		if (tmp == 4) {
			cout << "Thursday" << endl;
		}
		if (tmp == 5) {
			cout << "Friday" << endl;
		}
		if (tmp == 6) {
			cout << "Saturday" << endl;
		}




	}
}


Measured memory_bytes: 3076
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
int a,b;
cin>>a>>b;
if(a%2==0||b%2==0)cout<<"No"<<endl;
else cout<<"Yes"<<endl;
}

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

typedef long long ll;
const int N = 3010;
const int mod = 1e9 + 7;

char s[N];
int f[N][N], sum[N], n;

/*
f[i][j]表示位置i，然后位置i的数在已填入的数中排名为j
'>' f[i][j] = \sum_{k < j} f[i - 1][k] 
'<' f[i][j] = \sum_{k >= j} f[i - 1][k]
 */

int main() {
	scanf("%d", &n);
	scanf("%s", s + 2);
	f[1][1] = sum[1] = 1;
	for(int i = 2; i <= n; ++i) {
		for(int j = 1; j <= i; ++j) {
			if(s[i] == '<') (f[i][j] += sum[j - 1]) %= mod;
			else (f[i][j] += sum[i - 1] - sum[j - 1] + mod) %= mod;
		}
		for(int j = 1; j <= i; ++j) sum[j] = (sum[j - 1] + f[i][j]) % mod;
	}
	printf("%d\n", sum[n]);
}

Measured memory_bytes: 34304
import java.util.*;
import java.awt.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();

    int max = Math.max(A, Math.max(B, C));

    System.out.println(A + B + C + 9 * max);
  }
}


Measured memory_bytes: 25300
function makeMultiplyTable(n) {
  var ans = 0 ;
  for (var i = 1; i < 10; i++){
    ans = n * i;
    console.log(n.toString(10) + "x" + i.toString(10) + "=" + ans.toString(10));
  }
}

for (var i = 1; i < 10; i++){
    makeMultiplyTable(i)
}

Measured memory_bytes: 15552
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




class comb{
private:
    ll mod;
    ll mx;
    vector<ll> F;
    vector<ll> FR;
    
public:
    comb(ll mod=1000000007,ll mx=100000):mod(mod),mx(mx),F(mx+1,1),FR(mx+1,1){
        mk_F();
    }
    
    ll mod_pow(ll a,ll x){
        a%=mod;
        ll ans=1;
        while(x>0){
            if(x&1){ans*=a; ans%=mod;}
            a*=a;
            a%=mod;
            x>>=1;
        }
        return ans;
    }
    
    pll Ex_gcd(ll a,ll b){
        if(b==0){return {1,0};}
        pll ret=Ex_gcd(b,a%b);
        ret.F-=a/b*ret.S;
        return {ret.S,ret.F};
    }
    
    ll prime_R(ll a){
        return mod_pow(a,mod-2);
    }
    
    ll R(ll a){
        ll ret=Ex_gcd(a,mod).F;
        ret%=mod;
        if(ret<0){ret+=mod;}
        return ret;
    }
    
    void mk_F(){
        for(ll i=1;i<=mx;i++){F[i]=F[i-1]*i%mod; FR[i]=R(F[i]);}
    }
    
    ll c(ll n,ll k){
        if(n<k){return 0;}
        if(n==k || k==0){return 1;}
        return F[n]*FR[n-k]%mod*FR[k]%mod;
    }
    
    //mod must be prime
    ll Lucas_C(ll n,ll m){
        ll ret=1;
        while(n>0 || m>0){
            ret*=c(n%mod,m%mod);
            ret%=mod;
            n/=mod; m/=mod;
        }
        return ret;
    }
    
    ll Stirling(ll n,ll k){
        ll ret=0;
        for(ll i=1;i<=k;i++){
            if((k-i)%2){ret-=c(k,i)*mod_pow(i,n)%mod;}
            else{ret+=c(k,i)*mod_pow(i,n)%mod;}
            ret%=mod;
        }
        ret*=R(F[k]);
        ret%=mod;
        if(ret<0){ret+=mod;}
        return ret;
    }
    
    ll Bell(ll n,ll k){
        ll ret=0;
        for(ll i=1;i<=k;i++){ret+=Stirling(n,i); ret%=mod;}
        return ret;
    }
};

comb Comb;


int main(){
    ll n;
    cin>>n;
    const ll C=2100;
    vector<vector<ll>> A(2*C,vector<ll>(2*C,0));
    vector<pll> p(n);
    for(int i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        A[C-a][C-b]++;
        p[i]={a,b};
    }
    for(int i=0;i+1<2*C;i++){
        for(int t=0;t+1<2*C;t++){
            A[i][t]%=MOD;
            A[i+1][t]+=A[i][t];
            A[i][t+1]+=A[i][t];
        }
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=A[C+p[i].F][C+p[i].S];
    }
    ans%=MOD;
    for(int i=0;i<n;i++){
        ans-=Comb.c((p[i].F+p[i].S)*2,p[i].F*2);
    }
    ans%=MOD;
    ll inv=(MOD+1)/2;
    ans*=inv;
    ans%=MOD;
    if(ans<0){ans+=MOD;}
    cout<<ans<<endl;
    
    
    
    return 0;
}


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

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

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

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

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

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

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

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

//memo
// setprecision()

int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s,t,ans;
  cin >> s >> t;
  int n=SZ(s),m=SZ(t);
  
  VVI DP(n+1,VI(m+1));
  
  REP(i,n){
    REP(j,m){
      if(s.at(i) == t.at(j)){
        DP.at(i+1).at(j+1) = DP.at(i).at(j)+1;
      }else{
        DP.at(i+1).at(j+1) = max(DP.at(i+1).at(j),DP.at(i).at(j+1));
      }
    }
  }
  int i = n-1,j=m-1;
  while((i+1)*(m+1)!=0){
    if(DP.at(i+1).at(j+1) == DP.at(i).at(j+1)){
      i--;
    }else if(DP.at(i+1).at(j+1) == DP.at(i+1).at(j)){
      j--;
    }else{
      ans += s.at(i);
      i--, j--;
    }
 //   cout << i << " " << j << endl;
  }
  int l = SZ(ans);
  REP(i,l){
    cout << ans.at(l-i-1);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 35584
if __name__ == '__main__':

	dic = {}

	while True:
		try:
			s,n = input().split()
			dic.setdefault(s,[]).append(int(n))
		except EOFError:
			break

#	print(dic)

	tmp = sorted(list(dic))
	for word in tmp:
		print(word)
		print(*sorted(dic[word]))




Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int sum=0;
  cin>>n;
  vector<int> jewel(n);
  vector<int> value(n);
  for(int i=0;i<n;i++){
    cin>>jewel.at(i);
  }
    for(int i=0;i<n;i++){
    cin>>value.at(i);
  }
  for(int i=0;i<n;i++){
    if(jewel.at(i)>value.at(i)){
      sum+=jewel.at(i)-value.at(i);
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};

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

void solve() {
    lli n, ans = 0;
    cin >> n;
    lli b[n - 1], a[n];
    memset(a, -1, sizeof(a));
    for (int i = 0; i < n - 1; ++i) {
        cin >> b[i];
    }

    a[0] = b[0];

    for (int i = 0; i < n - 1; ++i) {
        if (a[i] > b[i]) {
            a[i] = b[i];
        }
        a[i + 1] = b[i];
    }

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

int main()
{
    IOS;

    lli t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
S=str(input())
N=len(S)
p=0
a=0
c=0
for i in range(int((N-1)/2)):
        if S[i]==S[-i-1]:
            p+=1
if p==(N-1)/2:
    for i in range(int((N-1)/4)):
        T=S[:int((N-1)/2)]
        if T[i]==T[-i-1]:
                a+=1
    if a==int((N-1)/4):
        for y in range(int((N-(N+3)/2)/2)):
            F=S[int((N+3)/2)-1:]
            if F[y]==F[-y-1]:
                c+=1
        if c==(int((N-(N+3)/2)/2)):
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 3064
n = gets.to_i

weights = gets.chomp.split(" ").map(&:to_i)

sum_from_left = []
sum_from_right = []

sum_left = 0
weights.each do |weight|
  sum_left += weight
  sum_from_left.push(sum_left)
end

sum_right = 0
weights.reverse.each_with_index do |weight|
  sum_right += weight
  sum_from_right.push(sum_right)
end

sum_from_left.pop
sum_from_right.pop

sum_from_right.reverse!

minimum = 100000
# answer = 0

(n - 1).times do |index|
  if minimum > (sum_from_left[index] - sum_from_right[index]).abs
    minimum = (sum_from_left[index] - sum_from_right[index]).abs
    # answer = index + 1
  end
end

puts minimum

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int a, b; cin >> a >> b;
    cout << a*b-a-b+1 << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7744
#include <algorithm>
#include <climits>
#include <iostream>
#include <iomanip>
#include <random>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using std::cin;
using std::cerr;
using std::cout;
using std::endl;
using std::make_pair;
using std::pair;
using std::stack;
using std::string;
using std::unordered_map;
using std::unordered_set;
using std::vector;
using std::lower_bound;
using std::upper_bound;

int distance(int i, int j, int x, int y) {
  return std::min(j - i, std::abs(x - i) + std::abs(y - j) + 1);
}

int main(int argc, char* argv[]) {
  int n, x, y;
  cin >> n >> x >> y;
  --x; --y;
  vector<int> count(n, 0);
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      ++count[distance(i, j, x, y) - 1];
    }
  }
  for (int d = 0; d < n - 1; ++d) {
    cout << count[d] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int main() {
  int s, hrs, mins, secs;
  scanf("%d", &s);
  hrs = s/3600;
  mins = (s-hrs*3600)/60;
  secs = s-hrs*3600-mins*60;
  printf("%d:%d:%d\n", hrs, mins, secs);
  return 0;
}



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

int main() {
    int s;
    cin >> s;
    int a,b,c;
    a = s / 100;
    b = (s - a * 100) / 10;
    c = s - a * 100 - b * 10;
    cout << a + b + c << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<cmath>
#include<map>
#define ll long long

using namespace std;


int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
 ll int n,i=0,j=0,count=0,ans,p=10,s=0,b[10000],z=0;
 char a[2000000][100];
 
 vector <string> v;
 cin>>n;
 for(i=0;i<n;i++)
 {
     cin>>a[i];
     sort(a[i],a[i]+10);
     v.push_back(a[i]);
     
 }
 //sort(a,a+n);
// for(i=0;i<10;i++)
   //  cout<<a[0][i];
   
   
   sort(v.begin(),v.end());
 // for(i=0;i<n;i++)
   {
 //      cout<<v[i]<<endl;
   }
   
   s=1;
   for(i=0;i<n-1;i++)
   {
      // p=strcmp(v[i],v[i+1]);
       if(v[i]==v[i+1])
       {
           s++;
          // count++;
       }
       if(v[i]!=v[i+1] || i==n-2)
       {
           b[z]=s;
           z++;
           s=1;
       }
   }
   for(i=0;i<z;i++)
   {
      // cout<<b[i]<<endl;
       count=count+(((b[i])*(b[i]-1))/2);
       
   }
   
 
 cout<<count<<endl;
 
     return 0;
}

Measured memory_bytes: 17396
N = int(input())
H = [int(n) for n in input().split()]
reached = [False] * N 

max_count = 0
for i in range(N):
    if reached[i] == True:
        continue
    else:
        count = 0
        for j in range(0, N-i-1):
            if H[i+j+1] <= H[i+j]:
                count += 1
                reached[i+j+1] = True
            else:
                max_count = max(max_count, count)
                break
        else:
            max_count = max(max_count, count)
print(max_count)

Measured memory_bytes: 20432
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    dp = [0] * (N + 1)
    rt = int(N ** 0.5) + 1
    for i in range(1, rt):
        ii = i ** 2
        for j in range(1, i + 1):
            iji = ii + j ** 2 + i * j
            if iji + 1 + i + j > N:
                break
            for k in range(1, j + 1):
                c = iji + k ** 2 + i * k + j * k
                if c <= N:
                    l = 6
                    if i == j or j == k:
                        l = 3
                        if i == k:
                            l = 1
                    dp[c] += l
                else:
                    break
    print(*dp[1:N + 1], sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9304
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll h,n;
    cin>>h>>n;
    for(int i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        h=h-x;
    }
    if(h<=0)
    cout<<"Yes";
    else
    cout<<"No";}

Measured memory_bytes: 3636
import heapq as hq
from collections import defaultdict
N, Q = map(int, input().split())
event = []
for i in range(N):
    si, ti, xi = map(int, input().split())
    event.append([si - xi, ti - xi, xi])
#STX = [list(map(int, input().split())) for i in range(N)]
Dlist = [int(input()) for i in range(Q)]
#for s,t,x in STX:
#    event.append([s - x, t-x, x])
event.sort(key=lambda x:x[0])
h = []
tdic = defaultdict(int)
ind = 0
for Di in Dlist:
    while ind<N and event[ind][0] <= Di:
        #Diまでに始まった工事を追加
        hq.heappush(h, event[ind][2])
        tdic[event[ind][2]] = event[ind][1]
        ind += 1
    while h and Di >= tdic[h[0]]:
        #Diまでに終わった工事を削除
        hq.heappop(h)
    if h:
        print(h[0])
    else:
        print(-1)

Measured memory_bytes: 72640
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n, d; cin >> n >> d;
	vector<vector<Int>> x(n, vector<Int>(d, 0));
	for(auto &i:x)
		for(auto &j:i)
			cin >> j;
	Int ans = 0;
	for(Int i=0; i<n; ++i)
		for(Int j=i+1; j<n; ++j){
			Int l = 0;
			for(Int k=0; k<d; ++k)
				l += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			Int r = sqrt(l);
			if(r*r > l-1e-10) ++ans;
		}
	cout << ans << "\n";
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = ll(1e9)+7;
const ll inf = ll(5e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class ADuplexPrinting {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    in >> n;
	    if(n %2 == 1) out << n/2 +1 << endl;
	    else out << n/2 << endl;
	}
};


int main() {
	ADuplexPrinting solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
use io::*;
use std::*;

fn solve(s: String, t: String) {
    let mut dp = vec![vec![0; t.len()]; s.len()];
    for i in (0..s.len()) {
        for j in (0..t.len()) {
            let ii = i as i32;
            let jj = j as i32;
            let left = if ii - 1 < 0 {0} else {dp[i-1][j]};
            let up = if jj - 1 < 0 {0} else {dp[i][j-1]};
            let diag = if jj - 1 < 0 || ii - 1 < 0 {0} else {dp[i-1][j-1]};
            if t.as_bytes()[j] == s.as_bytes()[i] {
                dp[i][j] = cmp::max(dp[i][j], diag + 1);
            }
            dp[i][j] = cmp::max(dp[i][j], cmp::max(up, left));
        }
    }
    let mut i = s.len() as i32 -1;
    let mut j = t.len() as i32 -1;
    let mut res = String::new();
    while i >= 0 && j >= 0 {
        let ii = i as usize;
        let jj = j as usize;
        if (s.as_bytes()[ii] == t.as_bytes()[jj]) {
            res.push(s.as_bytes()[ii] as char);
            i-=1;
            j-=1;
        } else {
            let left = if i - 1 < 0 {0} else {dp[ii-1][jj]};
            let up = if j - 1 < 0 {0} else {dp[ii][jj-1]};
            if left > up {
                i-=1;
            } else {
                j-=1;
            }
        }
    }
    println!("{}", res.chars().rev().collect::<String>());
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut s: String;
    s = scanner.next();
    let mut t: String;
    t = scanner.next();
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(s, t)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 45436
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<bitset>
#include<unordered_map> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include "boost/algorithm/string.hpp"
#define fio ios_base::sync_with_stdio(false)
#define mod 998244353
#define mod1 mod
#define mod2 1000000007
#define li long long int
#define ll li
#define readi(x) scanf("%d",&x)
#define  reads(x)  scanf("%s", x)
#define readl(x) scanf("%I64d",&x)
#define rep(i,n) for(i=0;i<n;i++)
#define revp(i,n) for(i=(n-1);i>=0;i--)
#define myrep1(i,a,b) for(i=a;i<=b;i++)
#define myrep2(i,a,b) for(i=b;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define MAXN 1000000000010000005
#define MINN -1000000000000000000
#define INTMAX 1000001000
#define pii pair<ll,ll> 
#define pdd pair<double,double>
#define pic pair<int,char>
#define N 200105
#define lgn 20
#define ddouble long double
#define minus minu
#define PI 2*acos(0)
#define lgn 20
 
 
// #define INTMAX 200000000 
 
// using namespace boost;
// #define si short int
 
using namespace std;
using namespace __gnu_pbds;             
typedef priority_queue<pii, vector<pii > > max_pq;
typedef priority_queue<pii, vector<pii> , greater<pii>  > min_pq;
ll toint(const string &s) {stringstream ss; ss << s; ll x; ss >> x; return x;}
string tostring ( ll number ){stringstream ss; ss<< number; return ss.str();}
 
// using namespace __gnu_pbds;         
// typedef priority_queue<pair<ll,char> , vector<pair<ll , char> > > max_pq;
// typedef priority_queue<pii , vector<pii > ,greater<pii > > min_pq;
typedef tree<pair<string,string> , null_type, less<pair<string,string> >, rb_tree_tag, tree_order_statistics_node_update> OST;
// typedef priority_queue<pair < ll , pair < pii , ll > >  , vector<pair < ll , pair < pii , ll > >  > ,greater<pair < ll , pair < pii , ll > >  > > min_pq;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif
#define nn 2000005
ll ar[ 6 ];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll x,y;
    cin >> x >> y;
    if ( (4*x-y)>=0 and (4*x-y)%2 == 0 and (4*x-y)/2 <= x){
        cout <<"Yes";
    }
    else{
        cout <<"No";
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード
 
//ループ
#define rep(i, n) for(int i = 0; i < (n); i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ
 
//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;
const double PI = acos(-1); //π
 
using namespace std;
 
//ソート
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 
//#include "./lib/generic/search.h"

//文字列入力した小数値を小数点なくして返す
int changeDoubleToInt(string decimal){ 
    decimal.erase(1, 1); //小数点削除
    int n_decimal = atoi(decimal.c_str()); //c_strでchar*に変換後、atoiでintに変換
    return n_decimal;
}

//最大公約数
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

int main(){
   ll n, k;
   cin >> n >> k;
   vector<ll> a(n);
   rep(i,n){
       cin >> a[i];
   }
   for(int i=k+1; i<=n; i++){
       ll point_k = a[i-1];
       ll point_k_1 = a[i-k-1];
       //cout << i << " " << k << " " << a[i-1] << " " << a[i-k-1] << " " << point_k << " " << point_k_1 << endl;
       if(point_k>point_k_1) cout << "Yes" << endl;
       else if(point_k<=point_k_1) cout << "No" << endl;
       point_k_1 = point_k;
   }
   return 0;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int n; cin>>n; int arr[n+2]; for(int i=0;i<n;i++)cin>>arr[i];
  int brr[n+2],j=0,t=0;ll g=1000000007,ans=0;
  for(int i=n-1;i>0;i--){
    t=(t+arr[i])%g;
    brr[i-1]=t;j++;
  }
  for(int i=0;i<n-1;i++){
    ans=(ans+(((arr[i])%g)*((brr[i])%g)))%g;
  }
  cout<<ans;
}


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

int main() {
	int a, b, c, n = 0;
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++) {
		if (c%i == 0)n++;
	}
	cout << n << endl;

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>

using namespace std;
typedef long long ll;

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

Measured memory_bytes: 256
N, K = map(int, input().split())
MOD = 10**9 + 7
kai = []
kai.append(1)
for idx in range(1, N+5):
	kai.append((kai[-1] * idx) % MOD)

#Mod pow
def modpow(ori, po):
	res = 1;
	while(po > 0):
		if(po&1):
			res *= ori
			res %= MOD
		ori *= ori
		ori %= MOD
		po >>= 1
	return res

def comb(n, k):
	if(n == 0 and k == 0):
		return 1
	if(n < k or n < 0):
		return 0
	ans = kai[n]
	ans *= modpow(kai[k], MOD-2)
	ans %= MOD
	ans *= modpow(kai[n-k], MOD-2)
	ans %= MOD
	return ans

for i in range(K):
	blue=comb(K-1, i)%MOD
	red=comb(N-K+1, i+1)%MOD
	print((blue*red)%MOD)

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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int64_t gcd(int64_t p, int64_t q)
{
    if (p < q)
        swap(p, q);

    if (p % q == 0)
        return q;
    else
        return gcd(q, p % q);
}

int main()
{
    int X;
    cin >> X;
    cout << 360 / gcd(360, X);
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  
  vector<int>L(N);
  
  for(int i=0;i<L.size();i++){
    cin>>L.at(i);
  }
  
  int sum=0;
  int max=0;
  
  for(int i=0;i<N;i++){
    if(max<=L.at(i)){
      max=L.at(i);
        sum+=L.at(i);
    }
    else{
      sum+=L.at(i);
  }
  }
  
  
  if(sum-max>max){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }


}

 


Measured memory_bytes: 256
fn main() {
    let n: Vec<char> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().chars().collect()
    };

    let sum = n.iter().fold(0, |acc, c| (acc + c.to_digit(10).unwrap()) % 9);
    if sum == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 2968
#include <iostream>
#include <algorithm>
using namespace std;
int main(){	
	double amax, amin, tmp;
	cin >> tmp;
	amax = tmp;
	amin = tmp;
	while (cin >> tmp){
		amin = min(tmp, amin);
		amax = max(tmp, amax);
	}
	cout << amax - amin << endl;
}

Measured memory_bytes: 1280
#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 drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

int x;
cin >> x;

cout << lcm(x,360) / x << endl;

return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define mz 1000000007

using namespace std;

bool life[105];

int main()
{
    for(int i=1;i<=9;i++)
        for(int j=1;j<=9;j++)
            life[i*j]=1;
    int a;
    scanf("%d",&a);
    if(life[a])
        printf("Yes\n");
    else
        printf("No\n");
	return 0;
}


Measured memory_bytes: 256