akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <set>
using namespace std;
const int INF = 1<<29;

// グラフ
using Edge = pair<int,long long>; // {辺の行き先, 重み}
using Graph = vector<vector<Edge> >; // グラフ

// 使われうる辺集合
set<pair<int,int> > use;

// s を始点とする Dijkstra
vector<long long> Dijkstra(const Graph &G, int s) {
    vector<long long> dist((int)G.size(), INF);
    vector<vector<int> > prev((int)G.size()); // prev[v] := v から復元できる辺たち
    dist[s] = 0;
    priority_queue<pair<long long,int>, vector<pair<long long,int> >, greater<pair<long long,int> > > que;
    que.push({0, s});
    while (!que.empty()) {
        auto cur = que.top(); que.pop();
        long long cur_dist = cur.first;
        int v = cur.second;
        if (cur_dist > dist[v]) continue; // 効く枝刈り
        for (auto e : G[v]) {
            if (dist[e.first] > dist[v] + e.second) {
                dist[e.first] = dist[v] + e.second;
                que.push({dist[e.first], e.first});

                // 復元のための
                prev[e.first].clear();
                prev[e.first].push_back(v);
            }
            else if (dist[e.first] == dist[v] + e.second) {
                prev[e.first].push_back(v);
            }
        }
    }

    // 使われうる辺集合
    for (int v = 0; v < (int)G.size(); ++v) {
        for (auto u : prev[v]) {
            use.insert(make_pair(min(u, v), max(u, v)));
        }
    }
    return dist;
}

int main() {
    int N, M; cin >> N >> M;
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b; long long c;
        cin >> a >> b >> c;
        --a, --b;
        G[a].push_back(Edge(b, c));
        G[b].push_back(Edge(a, c));
    }
    for (int v = 0; v < N; ++v) Dijkstra(G, v);
    cout << M - (int)use.size() << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int n;
double v[50000];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> n >> s;
    if (n >= 3200)
    {
        cout << s;
        return 0;
    }
    cout << "red";
}


Measured memory_bytes: 256
from statistics import mean, median,variance,stdev
import sys
import math

a = input().split()
#y = input().split()

for i in range(len(a)):
    a[i] = int(a[i])

#x = int(input())
#y = int(input())
if abs(a[2]-a[0]) > abs(a[1]-a[0]):
    print("A")
else: print("B")

Measured memory_bytes: 5400
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(A: int, B: int, M: int, a: "List[int]", b: "List[int]", x: "List[int]", y: "List[int]", c: "List[int]"):
    mn = min(a) + min(b)

    for i in range(M):
        t = a[x[i]-1] + b[y[i]-1] - c[i]
        mn = min(t, mn)

    print(mn)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(A)]  # type: "List[int]"
    b = [int(next(tokens)) for _ in range(B)]  # type: "List[int]"
    x = [int()] * (M)  # type: "List[int]"
    y = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(A, B, M, a, b, x, y, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 24612
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

class UF {
private:
    int sz; vector<int> par,nrank;
public:
    UF(){}
    UF(int node_size){ sz = node_size; par.resize(sz),nrank.resize(sz); rep(i,sz){ par[i] = i; nrank[i] = 0; } }
    int find(int x){ if(par[x] == x){ return x; }else{ return par[x] = find(par[x]); } }
    void unite(int x,int y)
    { x = find(x),y = find(y); if(x == y) return;
    	if(nrank[x] < nrank[y]){ par[x] = y; }else{ par[y] = x; if(nrank[x] == nrank[y]) nrank[x]++; } }
    bool same(int x,int y){ return find(x) == find(y); }
};

template<typename T> class Kruskal{
public:
	struct edge{
		int u,v;
		T cost;
		bool operator<(const edge& another) const {
			return cost < another.cost;
		}
	};
	vector<edge> es;
	vector<int> par,rrank;
	int V;
    Kruskal(int node_size){
        V = node_size;
		par.resize(node_size), rrank.resize(node_size);
	}
	void add_edge(int u,int v,T cost){
		es.push_back((edge){u,v,cost});
	}
	void solve(){
		UF uf(V);
		T res = 0;
		int cnt = 0;
        sort(es.begin(),es.end());
		rep(i,es.size()){
			edge e = es[i];
			if(!uf.same(e.u,e.v)){
				uf.unite(e.u,e.v);
				res += e.cost;
				cnt++;
				if(cnt == V/2){
					cout << e.cost << endl;
					return;
				}
				if(cnt == V-1){
					break;
				}
			}
		}
		return;
	}
};


int main(){
	int n,m;
	
	while(cin >> n >> m&&n!=0){
		Kruskal<int> kr(n);
		rep(i,m){
			int s,t,c;
			cin >> s >> t >> c;
			s--;
			t--;
			kr.add_edge(s,t,c);
		}
		kr.solve();
	}
	return 0;
}

Measured memory_bytes: 3220
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	int N, X, T;
	cin >> N >> X >> T;

	int ans = ((N - 1) / X + 1) * T;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(ll i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	ll sum=0;
	for(ll i=0;i<k;i++){
		sum+=a[i];
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
const int x2 = 1e9 ;

signed main() {
  int x3, y3 ;
  ll S ;
  cin >> S ;
  x3 = (x2 - S % x2) % x2 ;
  y3 = (S + x3) / x2 ;
  cout << "0 0 1000000000 1 " << x3 << " " << y3 << endl ;
  return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
template<typename T, int N>
struct SegTree
{
public:
    SegTree()
    {
        dat = vector<T>(N * 2 - 1, 0);
    }

    T comp(T& a, T& b) { return max(a, b); }

    void update(int i, T x)
    {
        i += N - 1;
        dat[i] = x;
        while (i > 0)
        {
            i = (i - 1) / 2;
            dat[i] = comp(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }

    T query(int a, int b, int k = 0, int l = 0, int r = N)
    {
        if (r <= a || b <= l) return 0;
        if (a <= l && r <= b) return dat[k];
        else
        {
            T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return comp(vl, vr);
        }
    }

    vector<T> dat;
};

/*------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
------------------------------------------------------------------------------*/











//------------------------------------------------------------------------------

int N, H[201010], A[201010];
SegTree<ll, 1 << 18> dp;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> H[i];
    rep(i, 0, N) cin >> A[i];

    rep(i, 0, N)
    {
        ll opt = dp.query(0, H[i]) + A[i];
        dp.update(H[i], max(dp.query(H[i], H[i] + 1), opt));
    }

    cout << dp.query(0, 1 << 18) << endl;
}


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

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

  int R=L+N-1;

  int eat;
  if(R<=0)eat=R;
  else if(L>=0)eat=L;
  else eat=0;

  int ans=(R+L)*(R-L+1)/2-eat;

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 256
N, M, K = map(int, input().split())
mod = 998244353
ans = 0
tmp = M

P = mod
inv_t = [0]+[1]
# for i in range(2, M+1):
#     inv_t += [inv_t[P % i] * (P - int(P / i)) % P]


t = [0]*N
t[0] = M
for i in range(1, N):
    t[i] = t[i-1]*(M-1) % mod
# for i in range(K+1):
#     if i == 0:
#         ans += tmp
#     else:

#         tmp *= M-1-i
#         tmp *= inv_t[i]
#         tmp *= inv_t[M-1]
#         tmp %= mod
#         ans += tmp
#         ans %= mod
# print(ans)
MAX_N = N

fact = [1]
fact_inv = [0]*(MAX_N+4)
for i in range(MAX_N+3):
    fact.append(fact[-1]*(i+1) % mod)

fact_inv[-1] = pow(fact[-1], mod-2, mod)
for i in range(MAX_N+2, -1, -1):
    fact_inv[i] = fact_inv[i+1]*(i+1) % mod


def mod_comb_k(n, k, mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] % mod


for i in range(K+1):
    ans += mod_comb_k(N-1, i, mod) * t[-1-i]


print(ans % mod)


Measured memory_bytes: 32500
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    ll n,k;
    cin>>n>>k;
    if(n>=k){
        n=n%k;
    }
    while(1){
        ll tmp=llabs(n-k);
        if(tmp<n){
            n=tmp;
        }
        else{
            break;
        }
    }
    cout<<n<<endl;
}

Measured memory_bytes: 256
N, M = list(map(int, input().split()))
AB = []
for i in range(N):
	AB.append(list(map(int, input().split())))

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

for i in range(N):
	L = []
	for j in range(M):
		L.append(abs(AB[i][0] - CD[j][0]) + abs(AB[i][1] - CD[j][1]))
	print(L.index(min(L)) + 1) 
		

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

//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>PII;
typedef vector<PII>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
typedef priority_queue<int>PQL;
typedef map<int,int>MP;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
const int mod=1e9+7;
const int sze=1e5+2;
signed main(){
  string a,b,c;
  cin>>a>>b>>c;
  int lena=a.length();
  int lenb=b.length();
  int lenc=c.length();
  int i=0,j=0,k=0;
  char current='a';
  
  
  while(true){
	   if(current=='a'){
		   if(i==lena){
			   cout<<"A"<<endl;
			   return 0;
		   }
		   else{
			  current=a[i];
			  i++;
		   }
	   }
	   else if(current=='b'){
		   if(j==lenb){
			   cout<<"B"<<endl;
			   return 0;
		   }
		   else{
			   current=b[j];
			   j++;
		   }
		   
	   }
	   else if(current=='c'){
		 if(k==lenc){
			 
			 cout<<"C"<<endl;
			 return 0;
		 }
		 else {
			 current=c[k];
			 k++;
		 }   
		   
	   }
	  
  }
  
  return 0;
}


Measured memory_bytes: 256
a, b, c= map(int, input().split())
if a >= b:
    big = a
    mid = b
else:
    big = b
    mid = a
if c >= big:
    small = big
    big = c
else:
    small = c
if small >= mid:
    small_1 = mid
    mid = small
    small = small_1

print("{0} {1} {2}".format(small, mid, big))



Measured memory_bytes: 5596
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    int min_pos = (int)(min_element(all(A)) - A.begin());
    int ans = 1 << 30;
    rep(i, min_pos, N) {
        int l = max(i - K + 1, 0);
        int r = i;
        int l_cnt = l;
        int r_cnt = N - r - 1;
        int now_ans = 1 + (l_cnt + K - 2) / (K - 1) + (r_cnt + K - 2) / (K - 1);
        chmin(ans, now_ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int main(){
    while(true){
        int h,w;
        cin >> h >> w;
        if(h==0 && w==0){
            break;
        }
        for(int i=0; i<h; i++){
            
            if(i==0 || i==h-1){
                for(int j=0; j<w; j++){
                    cout<<"#";
                }
            }
            
            else{
                cout<<"#";
                for(int j=1; j<w-1; j++){
                cout<<".";
                }
                cout<<"#";
            }
            
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}




Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  ll a[n];
  for(ll i=0;i<n;i++) cin>>a[i];
  ll sum1=a[0];
  ll sum2=0;
  for(ll i=1;i<n;i++) sum2+=a[i];
  ll m=abs(sum2-sum1);
  for(int i=1;i<n-1;i++){
    sum1+=a[i];
    sum2-=a[i];
    m=min(m,abs(sum2-sum1));
  }
  cout<<m<<endl;
}

Measured memory_bytes: 1792
from collections import Counter
s = input()
n = len(s)
dp = [0]
mod = 2019
a = 0
for i in range(n):
    a = a + int(s[n-i-1]) * pow(10, i, mod)
    a %= mod
    dp.append(a%mod)
ans = 0
c = Counter(dp)
for value in c.values():
    ans += value * (value-1) / 2
print(int(ans))

Measured memory_bytes: 77904
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    string s_f = s.substr(0, n), s_b = s.substr(n);
    reverse(all(s_b));
    map<pair<string, string>, lint> sep_f, sep_b;
    //前の分割
    for (int i = 0; i < (1 << n); i++) {
        string temp_f = "", temp_b = "";
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) {
                temp_f = temp_f + s_f[j];
            } else {
                temp_b = temp_b + s_f[j];
            }
        }
        sep_f[make_pair(temp_f, temp_b)]++;
    }
    //後ろの分割
    for (int i = 0; i < (1 << n); i++) {
        string temp_f = "", temp_b = "";
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) {
                temp_b = temp_b + s_b[j];
            } else {
                temp_f = temp_f + s_b[j];
            }
        }
        sep_b[make_pair(temp_f, temp_b)]++;
    }
    lint ans = 0;
    for (auto itr = sep_f.begin(); itr != sep_f.end(); itr++) {
        auto now = (*itr);
        ans += now.second * sep_b[now.first];
    }
    cout << ans << endl;
}

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

using namespace std;

int main( )
{
	string cards, tmp;
	int m, h;
	
	while( cin>>cards ) {
		if( "-" == cards ) { break; }
	
		cin>>m;
		while( m-- ) {
			cin>>h;
			cards = cards.substr( h ) + cards.substr( 0, h );
		}
		cout<<cards<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1216
n = int(input())
h = list(map(int, input().rstrip().split(" ")))

ans = 0

for i in range(len(h)):
    flag = True
    for j in range(len(h) - i):
        if h[len(h)-i-1] < h[j]:
            flag = False
            break
    if flag:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
  int n; cin >> n; int a[n]; for(int i=0; i<n; i++ )cin>>a[i];
  int an=0, pc=1;
  for(int i=0; i<n && pc<=n; i++) {
    if (a[i] == pc) pc++;
    else an++;
  }
  //cout << pc << endl;
  if (pc == 1) cout << -1 << endl;
  else cout << an << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    string str;
    cin >> str;
    
    int cnt=1;
    int ans=0;
    char c=str[0];
    for(int i=1; i<str.size(); i++) {
        if(c==str[i]) {
            ans++;
        } else {
            cnt++;
        }
        c = str[i];
    }

    if((cnt-1)%2!=0) {
        if(K>(cnt-1)/2) {
            ans = str.size()-1;
        } else {
            ans += K*2;
        }
    } else {
        if(K>=(cnt-1)/2) {
            ans = str.size()-1;
        } else {
            ans += K*2;
        }
    }
    
    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void) {
	char str[20];
	int cnt = 0, max = 0;
	int flg = 0;
	int i, j, k;

	scanf("%s", str);
	for (i = 0; str[i] != '\0'; i++) {
		if (flg == 0) {
			if (str[i] == 'A' || str[i] == 'C' || str[i] == 'G' || str[i] == 'T') {
				cnt++;
				flg = 1;
			}
		}
		else {
			if (str[i] != 'A' && str[i] != 'C' && str[i] != 'G' && str[i] != 'T') {
				if (max < cnt) {
					max = cnt;
				}
				cnt = 0;
				flg = 0;
			}
			else {
				cnt++;
			}
		}
	}
	if (max < cnt) {
		max = cnt;
	}
	printf("%d\n", max);
	return 0;
}

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

public class Main {
    static StringTokenizer st;
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws IOException {
        int input = nextInt();
        HashSet <String> kinds = new HashSet<>();
        for (int x=0; x<input; x++) {
            String cur = next();
            if (!kinds.contains(cur)) {
                kinds.add(cur);
            }
        }
        System.out.println(kinds.size());
    }
    
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

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

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

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

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()

const double eps=1e-5;
const long long INF=(LL)(1e9)*(LL)(1e9);


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    if(s[0]=='Y' && s[1] == 'A' && s[2] == 'K' && s[3]=='I')
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <utility>
#include <queue>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, a, b, c, q, x, y;
  scanf("%lld", &n);
  vector< pair<ll, ll> > vec[n];
  ll dis[n];
  for(i = 0; i < n; ++i) dis[i] = -1;
  for(i = 0; i < n - 1; ++i) {
    scanf("%lld%lld%lld", &a, &b, &c);
    a--, b--;
    vec[a].push_back(make_pair(b, c));
    vec[b].push_back(make_pair(a, c));
  }
  scanf("%lld%lld", &q, &k);
  k--;
  dis[k] = 0;
  queue<ll> que;
  que.push(k);
  while(!que.empty()) {
    queue<ll> qt;
    while(!que.empty()) {
      ll t = que.front();
      que.pop();
      for(i = 0; i < vec[t].size(); ++i) if(dis[vec[t][i].first] == -1) dis[vec[t][i].first] = dis[t] + vec[t][i].second, qt.push(vec[t][i].first);
    }
    while(!qt.empty()) {
      que.push(qt.front());
      qt.pop();
     }
  }
  for(i = 0; i < q; ++i) {
    scanf("%lld%lld", &x, &y);
    x--, y--;
    printf("%lld\n", dis[x] + dis[y]);
  }
  return 0;
}

Measured memory_bytes: 9984
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
 //    String[] nyu=sc.nextLine().split(" ");

     String nyu=sc.nextLine();
//int A=Integer.parseInt(nyu[0]);
//int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu[2]);
int D=Integer.parseInt(nyu);



//StringBuffer sb = new StringBuffer(nyu);
//		String dst = sb.reverse().toString();

//     String nyu2=sc.nextLine();
//int E=Integer.parseInt(nyu2);



//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(nyu){
case "H H":
System.out.println("H") ;
break;

case "D D":
System.out.println("H") ;
break;

case "H D":
System.out.println("D") ;
break;

case "D H":
System.out.println("D") ;
break;


default:
System.out.println("NO") ;

break;
}
*/

//int res=Math.min((A*B),C);

//for(String tem:nyu){
//if(tem.equals("1"))res++;
//}
//int res=0;
//for(int i=0;i<300;i++){
//if(num[i]==1)res=i;
//}

//char[] c = nyu.toCharArray();


//System.out.println(nyu+"-"+line_r_2+"-"+nyu2+"-"+line_r_1);



//if(B-A==C-B){
//double res=Math.ceil((AB)/2);

//System.out.println("YES");
//}else if((C-B)<A){
//System.out.println("safe");

//}else{
System.out.println( D * 800 - (D/15)*200);

//}




	}
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>

int mycompare(const void *a, const void *b){
    return *(int *)a - *(int *)b;
}

int main()
{
    int N,K,i;
    int min,height[100001];
    scanf("%d%d",&N,&K);

    for(i=0;i<N;i++){
        scanf("%d",&height[i]);
    }

    qsort(height,N,sizeof(height[0]),mycompare);

    min = height[K-1] - height[0];
    for(i=1;i<N-K+1;i++){
        if((height[i+K-1] - height[i]) < min){
            min = height[i+K-1] - height[i];
        }
    }

        printf("%d ",min);
    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <math.h>
using namespace std;

int main()
{
	int A, B, K;
	bool flag = false;

	cin >> K;
	cin >> A >> B;


	for(int i=A; i<=B; i++){
		if(i%K == 0){
			flag = true;
			break;
		}
	}


	
	cout << (flag?"OK":"NG");

	return 0;
	
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...) 42
#endif
#define y0 y12345
#define y1 y54321

#define INF 1e+9
#define MAX_V 410

struct edge {
    int to;
    int cost;
};
using P = pair<int, int>;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];
void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

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

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

typedef unsigned long ul;
typedef long long ll;
//typedef pair<int, int> mpair;
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;}
using namespace std;

int dp(){
	return 0;
}

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int n,m;int h,w;cin>>h>>w;
	string s[h];
	V = 0;
	rep(i, h){
		cin >> s[i];
	}
	int box[h][w];


	int num = 0;
	rep(i, h){
		rep(j, w){
			if(s[i][j] == '.'){
				box[i][j] = 97+num;
				num++;
			}else{
				box[i][j] = '#';
			}
		}
	}
	rep(i, h){
		//cout << box[i] << endl;
	}
	V = num;
	rep(i, h){
		rep(j, w){
			if(box[i][j] == '#')continue;
			if(i-1 >= 0 && box[i-1][j] != '#'){
				edge e = {(int)(box[i-1][j]-97),1};
				edge f = {(int)(box[i][j]-97),1};
				G[(int)(box[i][j]-97)].push_back(e);
				G[(int)(box[i-1][j]-97)].push_back(f);
			}if(j-1 >= 0 && box[i][j-1] != '#'){
				edge e = {(int)(box[i][j-1]-97),1};
				edge f = {(int)(box[i][j]-97),1};
				G[(int)(box[i][j]-97)].push_back(e);
				G[(int)(box[i][j-1]-97)].push_back(f);
			}if(i+1 <= h-1 && box[i+1][j] != '#'){
				edge e = {(int)(box[i+1][j]-97),1};
				edge f = {(int)(box[i][j]-97),1};
				G[(int)(box[i][j]-97)].push_back(e);
				G[(int)(box[i+1][j]-97)].push_back(f);
			}if(j+1 <= w-1 && box[i][j+1] != '#'){
				edge e = {(int)(box[i][j+1]-97),1};
				edge f = {(int)(box[i][j]-97),1};
				G[(int)(box[i][j]-97)].push_back(e);
				G[(int)(box[i][j+1]-97)].push_back(f);
			}
		}
	}
	int ma = 0;
	rep(j, V){dijkstra(j);
	rep(i, V){
		if(d[i]!=INF){
			chmax(ma, d[i]);
		}
	}
	}
	cout << ma << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int H, W;
    cin >> H >> W;
    VI A;

    int n;
    cin >> n;

    for(int i=0; i<n; i++) {
        int a;
        cin >> a;
        for(int j=0; j<a; j++) A.PB(i+1);
    }

    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            if(i%2) {
                cout << A[W*i+W-1-j];
            } else {
                cout << A[W*i+j];
            }
            cout << " \n"[j==W-1];
        }
    }

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

void strInit(char str[]);//str[]を0で初期化
void extIntStr(char str[],int data[]);//str[]から数値(int)を抽出しdata[]に順次格納
void incsort(int data[],int len);//data[]を昇順ソート
void decsort(int data[],int len);//data[]を降順ソート
void printIntArray(int data[],int len);//data[]をprint
int* inputArray(int n);//文字列を受け取り数値を抽出、n個の数値(int)を格納した配列のポインタをreturn
int* cpyArray(int data[],int len);//配列(int)を複製した配列のポインタをreturn

//don't forget free(data);

int main(){
    int n;
    scanf("%d",&n);
    printf("%d",(int)pow((double)n,3.0));
    return 0;
}

//temp##############################################

void strInit(char str[]){
    int len=strlen(str);
    for(int i=0;i<len;i++){
        str[i]=0;
    }
}

void extIntStr(char str[],int data[]){
    int length=strlen(str);
    str[length-1]=' ';
    char buff[12];
    int j,index;
    index=j=0;
    for(int i=0;i<length;i++){
        if(str[i]!=' '){
            buff[j++]=str[i];
        }else{
            data[index++]=atoi(buff);
            strInit(buff);
            j=0;
        }
    }
}

void incsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]>data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void decsort(int data[],int len){
    for(int i=0;i<len-1;i++){
        for(int j=i+1;j<len;j++){
            if(data[i]<data[j]){
                int tmp=data[i];
                data[i]=data[j];
                data[j]=tmp;
            }
        }
    }
}

void printIntArray(int data[],int len){
    for(int i=0;i<len;i++){
        printf("%d\n",data[i]);
    }
}

int* inputArray(int n){
    int *data;
    data=(int*)malloc(sizeof(int)*n);
    char *get;
    get=(char*)malloc(sizeof(char)*11*n+1);
    fgets(get,11*n+1,stdin);
    extIntStr(get,data);
    free(get);
    return data;
}

int* cpyArray(int data[],int len){
    int *cp;
    cp=(int*)malloc(sizeof(int)*len);
    for(int i=0;i<len;i++){
        cp[i]=data[i];
    }
    return cp;
}

//temp##############################################


Measured memory_bytes: 128
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
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 (b<a) { a=b; return 1; } return 0; }

int N, K;

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

    int a = N / K;
    int b = N % K;

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

    return 0;
}


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


void solve(long long N, long long T, std::vector<long long> c, std::vector<long long> t){
  long long mymin = LLONG_MAX;

  for(long long i = 0; i < N; i++){
    if(mymin > c[i] && T >= t[i]) {
      mymin = c[i];
    }
  }

  if( mymin == LLONG_MAX){
    cout << "TLE" << endl;
  }
  else {
    cout << mymin << endl;
  }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  long long T;
  scanf("%lld",&T);
  std::vector<long long> c(N);
  std::vector<long long> t(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&c[i]);
    scanf("%lld",&t[i]);
  }
    solve(N, T, std::move(c), std::move(t));
    return 0;
}


Measured memory_bytes: 256
//encoding:utf-8
//#include <iostream> //c++
//#include<stack> //スタックに関して　最新のデータから捨てる
//#include<queue> //キューに関して　最古のデータから捨てる
//#include<math.h>
//#include<vector>
//#include<algorithm> //sort とかにいる
#include<bits/stdc++.h>//vector,algorithm,que
#include<time.h> //時間にかんして

#define ll long long
#define MOD 1000000007
#define INF (1<<29)
using namespace std;
int main(){
  string s;
  cin>>s;
  string ans[2];
  int cnt = 0;
  for(int i=0;i<s.length();i++){
    if(i==0){
      ans[0] = s[0];
    }
    else if(i==s.size()-1){
      ans[1] = s[i];
    }
    else{
      cnt +=1;
    }
  }
  // ans[1] = cnt;
  cout<<ans[0]<<cnt<<ans[1]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N(2222);
vector<int> adj[N];
int dis[N];
int main() {
	int n, k;
	cin >> n >> k;
	for(int i(0); i + 1 < n; i++) {
		int x, y;
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	int ans(n - 1);
	for(int i(1); i <= n; i++) {
		for(int j : adj[i]) {
			static vector<int> q;
			q.clear();
			q.push_back(i);
			fill(dis + 1, dis + 1 + n, -1);
			dis[i] = 0;
			if(k % 2 == 1) {
				q.push_back(j);
				dis[j] = 0;
			}
			for(int _(0); _ < (int)q.size(); _++) {
				int v(q[_]);
				for(int y : adj[v]) {
					if(dis[y] == -1) {
						dis[y] = dis[v] + 1;
						q.push_back(y);
					}
				}
			}
			int tmp(0);
			for(int i(1); i <= n; i++) {
				if(dis[i] > k / 2) {
					tmp++;
				}
			}
			ans = min(ans, tmp);
		}
	}
	cout << ans << endl;
}


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

int main(void){
    int x,y;
    int group1[7]={1,3,5,7,8,10,12};
    cin>>x>>y;
    if(x==2||y==2)
        cout<<"No"<<endl;
    else{
        int cnt=0;
        for(int i=0;i<7;i++){
            if(x==group1[i]||y==group1[i])
                cnt++;
        }
        if(cnt==0||cnt==2)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
/*contest A*/
int main(void)
{
  int M,D;/*M<1--,D<99*/
  int d,d1;
  int count=0;

  scanf("%d%d",&M,&D );
  d = D/10;
  d1= D%10;
  if(d != 1 && M>3){
    for(int m=4; m<=M ; m++){
      for(int  i=2; i<d ;i++){
        for (int  k = 2; k <= 9; k++) {
          if(i*k == m)count++;
        }
      }
      if(d1>1){
        for(int i=2;i<=d1;i++){
          if(d*i==m)count++;
        }
      }
    }
    printf("%d\n",count );
  }else{
    printf("0\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

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

    int n;
    cin >> n;
    vi v(n), c(n);
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];
    int ans = 0;
    rep(i, n) if (v[i] > c[i]) ans += v[i] - c[i];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
char RB[46]=".,!? abc  def  ghi  jkl  mno  pqrs tuv  wxyz ";char fuego(int here, int len) {int mod;if (here==1) mod=5; else if (here==9 || here==7) mod=4; else mod=3;return RB[(here-1)*5+len%mod];}
int main() {int len=0,val=0,N;char T;scanf("%d%*c",&N);while (N) {T=getchar();if (T>='0' && T<='9') {if (val!=T-48) {if (val) printf("%c",fuego(val,len));val=T-48,len=0;} else len++;} else {val=0,len=0,N--;puts("");}} return 0;}

Measured memory_bytes: 1016
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {

		sugoroku();

	}

	public static void sugoroku() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Integer []X = new Integer[N];

		for (int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
		}
   List<Integer> l = Arrays.asList(X);
		int M = sc.nextInt();
		int []A = new int[M];
		for (int i = 0; i < M; i++) {
			A[i] = sc.nextInt();
		}

		for (int num : A) {
			if (X[num - 1] < 2019 && !(l.contains(X[num - 1]+1))) {
				X[num - 1]++;
			}
		}
		for (int num : X) {
			System.out.println(num);
		}
	}
}



Measured memory_bytes: 26464
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; 
typedef string str;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
typedef vector<int> vi; 
typedef vector<bool> vb; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
 
#define sz(x) (int)(x).size()
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define sor(x) sort(all(x))
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define endl '\n'
 
const ll MOD = 998244353;
const ll INF = 1e18;
const int n = 5e5;

int pow(ll a, int b, int m) {
   a = a % m;
   ll ret = 1;
   while (b > 0) {
      if (b & 1) ret = ret * a % m;
      a = a * a % m;
      b /= 2;
   }
   return ret;
}

int inv (int a, int p) {
   return pow(a, p - 2, p);
}

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   int n, m, k; cin >> n >> m >> k;
   vl pre(k + 1);
   pre[0] = 1;
   for (int i = 1; i <= k; i++)
      pre[i] = (pre[i - 1] * (n - i) % MOD) * inv(i, MOD) % MOD;
   ll ans = 0;
   vl pre_pow(k + 1);
   pre_pow[k] = pow(m - 1, n - 1 - k, MOD);
   for (int i = k - 1; i >= 0; i--)
      pre_pow[i] = pre_pow[i + 1] * (m - 1) % MOD;
   for (int i = 0; i <= k; i++)
      ans = (ans + pre[i] * pre_pow[i]) % MOD;
   cout << ans * m % MOD;
   return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<vector<vector<int>>> dp(n+1, vector<vector<int>>(10, vector<int>(10, 0)));
  for (int i = 1; i <= n; ++i) {
    rep(j, 10) rep(k, 10) dp[i][j][k] = dp[i-1][j][k];
    int hd = i;
    while (hd >= 10) hd /= 10;
    int ld = i % 10;
    dp[i][hd][ld]++;
  }

  int ans = 0;
  rep(j, 10) rep(k, 10) ans += dp[n][j][k] * dp[n][k][j];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 151552
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
#define A first
#define B second
#define pb(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define Itype(a) typeof(a.begin()) 
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(Itype(t) i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define abs(x) (x < 0 ? -x : x) 
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
const int MOD = 1000000007;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);

    FORO(i, N) {
        cin >> V[i];
    }
    FORO(i, N) {
        cin >> C[i];
    }

    int ans = 0;
    FORO(i, N) {
        if(V[i] - C[i] > 0) ans += V[i] - C[i];
    }

    cout << ans << endl;

    return 0;
}

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


signed main() {
    int n,a,b,c,d;
    cin>>n>>a>>b;
    int ans=0;
    for(int i=1;i<=n;i++){
        c=0;d=i;
        while(d!=0){
            c+=d%10;d/=10;
        }
        if(a<=c&&c<=b)ans+=i;
        
    }
    cout<<ans;
    
return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <cstdio>
 
using namespace std;
using ll = long long;
 
#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
 
#define MOD 1000000007
void init();
void solve();

signed main()
{
    init();
    solve();
}

int N, M;
vector<ll> x, y;
vector<ll> xc, yc;

void init()
{
	cin >> N >> M;
	x.RS(N-1);
	y.RS(M-1);
	vector<ll> tx, ty;
	CINV(tx, N);
	CINV(ty, M);
	xc.RS(N-1);
	yc.RS(M-1);
	rep(i, N-1) {
		x[i] = tx[i+1] - tx[i];
	}
	rep(i, M-1) {
		y[i] = ty[i+1] - ty[i];
	}
	rep(i, N-1) {
		xc[i] = (ll) (i + 1) * (N - i - 1);
	}
	rep(i, M-1) {
		yc[i] = (ll) (i + 1) * (M - i - 1);
	}
}

void solve()
{
	ll H = 0;
	rep(i, M-1) {
		H += y[i] * yc[i];
		H %= MOD;
	}
	ll ans = 0;
	rep(i, N-1) {
		ans += x[i] * xc[i] % MOD * H % MOD;
		ans %= MOD;
	}
	cout << ans << endl;
}



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

int main(){
    int n, k;
    cin >> n >> k;
    double res = 0.0;
    if(n >= k){
        res += (n-k+1.0)/n;
    }
    for(int i=1;i<k && i<=n;i++){
        int times = 0;
        int s = i;
        while(s < k){
            s <<= 1;
            times++;
        }
        res += (1.0/n)*pow(0.5, times);
    }
    printf("%.10f\n", res);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
	int A[4],p=1;
	vector<int> B(4, 0);
	for (size_t i = 0; i < 4; i++)
	{
		cin >> A[i];
		if (A[i]==1)
		{
			B.at(0)++;
		}
		else if (A[i]==9)
		{
			B.at(1)++;
		}else if(A[i] == 7)
		{
			B.at(2)++;
		}
		else if (A[i] == 4)
		{
			B.at(3)++;
		}
	}
	for (size_t i = 0; i < 4; i++)
	{
		p *= B.at(i);
	}
	if (p==1)
	{
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B, N;
    cin >> A >> B;
    if(1 <= B && B <= 9) N = 10*A + B; 
    else if(10 <= B && B <= 99) N = 100*A + B; 
    else N = 10 * A + 1; 
    if(pow(N, 0.5) * pow(N, 0.5) == N) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
// 解き直し.
// https://img.atcoder.jp/m-solutions2020/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
LL dp[88]; // x日目に, 株の売却が終了した時点の所持金の最大値.
LL A[88];  // 株価.

int main(){

    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    rep(i, N) scanf("%lld", &A[i]);
    
    // 2. 所持金の最大値は？
    dp[0] = 1000;
    repx(i, 1, N){
        // (i - 1)日目から何もしない場合.
        dp[i] = max(dp[i], dp[i - 1]);
        
        // j日目に株を購入し, i日目に売却.
        repx(j, 0, i) dp[i] = max(dp[i], dp[j] / A[j] * A[i] + dp[j] % A[j]);
    }
    
    // 3. 出力.
    printf("%lld\n", dp[N - 1]);
    return 0;
    
}
// ex.
// 56
// 44 62 77 80 40 93 91 56 54 3 71 69 39 26 20 38 72 41 7 56 86 95 57 50 39 29 91 35 22 95 7 2 27 74 57 31 91 28 90 7 33 52 34 78 86 19 57 94 73 10 46 34 36 24 12 69
// -> 58692414048158 と推定されるが, 以下の実装だと, TLEとなる.
// TLE版.
// #include <bits/stdc++.h>
// using namespace std;
// using LL = long long;
// #define repex(i, a, b, c) for(int i = a; i < b; i += c)
// #define repx(i, a, b) repex(i, a, b, 1)
// #define rep(i, n) repx(i, 0, n)
// #define repr(i, a, b) for(int i = a; i >= b; i--)
// int A[88]; // 株価.
// 
// // 最終的な所持金を計算.
// // @param b: 売買フラグ
// // @param i: インデックス
// // @param N: 取引日数
// // @param m: 所持金
// // @param s: 株式数
// // @return : 最終的な所持金を返却.
// LL recursive(bool b, int i, int N, LL m, LL s){
//     
//     // 1. 終了条件.
//     if(i == N)  return m;
//     
//     // 2. 売買フラグに応じて処理.
//     // 2-1. A[i] を 購入する場合.
//     if(b){
//         LL nm = m % A[i], ns = s + m / A[i], ret = nm;
//         int maxA = A[i];
//         repx(j, i + 1, N){
//             if(maxA < A[j]){
//                 ret = max(ret, recursive(!b, j, N, nm, ns));
//                 maxA = max(maxA, A[j]);
//             }
//         }
//         return ret;
//     }
//     // 2-2. A[i] を 売却する場合.
//     if(!b){
//         LL nm = m + A[i] * s, ns = 0, ret = nm;
//         int maxA = A[i];
//         repx(j, i + 1, N){
//             if(maxA > A[j]){
//                 ret = max(ret, recursive(!b, j, N, nm, ns));
//                 maxA = max(maxA, A[j]);
//             }
//         }
//         return ret;
//     }
//     
//     // 3. 返却(※到達しないはず).
//     assert(0);
//     return -1;
// }
// 
// int main(){
// 
//    // 1. 入力情報.
//     int N;
//     scanf("%d", &N);
//     rep(i, N) scanf("%d", &A[i]);
//     
//     // 2. 所持金の最大値は？
//     LL ans = 1000;
//     rep(i, N) ans = max(ans, recursive(true, i, N, 1000, 0));
//     
//     // 3. 出力.
//     printf("%lld\n", ans);
//     return 0;
//     
// }

Measured memory_bytes: 3836
let a, b, k = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let c = ref 1
let _ = for i = min a b downto 1 do if a mod i = 0 && b mod i = 0 then (if !c >= k then (Printf.printf "%d\n" i; exit 0); incr c) done

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

int main(){
  int H,W,flag=0,A=0,B=0;
  cin >> H >> W;
  vector<vector<char>> vec(H,vector<char>(W,0));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> vec[i][j];
    }
  }
  for(int k=0;k<H;k++){
    for(int l=0;l<W;l++){
      if(vec[k][l]=='#'){
        A=1;
      }
      if(l==W-1&&A==0){
        for(int m=0;m<W;m++){
          vec[k][m]='0';
        }
      }
    }
    A=0;
  }
  for(int n=0;n<W;n++){
    for(int o=0;o<H;o++){
      if(vec[o][n]=='#'){
        B=1;
      }
      if(o==H-1&&B==0){
        for(int p=0;p<H;p++){
          vec[p][n]='0';
        }
      }
    }
    B=0;
  }
  for(int q=0;q<H;q++){
    for(int r=0;r<W;r++){
      if(vec[q][r]!='0'){
        cout << vec[q][r];
        flag=1;
      }
      if(r==W-1){
        if(flag){
          flag=0;
          cout << endl;
        }
      }
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 2e5 + 7;
const int maxm = 1e6 + 7;
const int ALP = 26;
const long long mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-8;

int n;
int a[maxn];
int cur_num;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		if(cur_num+1==a[i])
			cur_num++;
	printf("%d\n",cur_num==0?-1:n-cur_num);
	return 0;
}


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

int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(a[i]==a[i+1]){
    	a[i+1]=a[i+1]-(1000-i);
      	ans++;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256