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

struct Strongly_Connected_Component {
  int vsize;
  vector<vector<int>> G, reverseG;
  vector<int> vs, cmp;
  vector<bool> used;
  Strongly_Connected_Component(int newv = 1) {
    vsize = newv;
    G.resize(vsize);
    reverseG.resize(vsize);
    used.resize(vsize, 0);
    cmp.resize(vsize);
  }

  bool add(int from, int to) {
    G[from].push_back(to);
    reverseG[to].push_back(from);
    return 1;
  }
  void dfs(int v) {
    used[v] = true;
    int gvsize = G[v].size();
    for(int i = 0; i < gvsize; ++i)
      if(!used[G[v][i]]) dfs(G[v][i]);
    vs.push_back(v);
  }
  void rdfs(int v, int k) {
    used[v] = true;
    cmp[v] = k;
    int rgvsize = reverseG[v].size();
    for(int i = 0; i < rgvsize; ++i)
      if(!used[reverseG[v][i]]) rdfs(reverseG[v][i], k);
  }
  int solve() {
    used.assign(vsize, 0);
    vs.clear();
    for(int v = 0; v < vsize; ++v)
      if(!used[v]) dfs(v);
    used.assign(vsize, 0);
    int k = 0;
    for(int i = (int)vs.size() - 1; i >= 0; --i)
      if(!used[vs[i]]) rdfs(vs[i], k++);
    return k;
  }
  bool issame(int l, int r) { return cmp[l] == cmp[r]; }
};

int n, m;
Strongly_Connected_Component scc;

int main() {
  cin >> n >> m;
  scc = Strongly_Connected_Component(n);
  for(int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    scc.add(--a, --b);
  }
  scc.solve();
  for(int i = 0; i < n; ++i) {
    vector<int> v;
    for(int j = 0; j < n; ++j)
      if(scc.issame(i, j)) v.push_back(j);
    for(int j = 0; j < v.size(); ++j) {
      if(j != 0) cout << " ";
      cout << v[j] + 1;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 4288
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

template<typename T> class union_find{
	unordered_map<T,T> parent;
	unordered_map<string,int> tbl;
public:
	T root(T a){
		if(parent.find(a)==parent.end())parent[a]=a;
		return parent[a]==a?a:(parent[a]=root(parent[a]));
	}
	int same(T a,T b){return root(a)==root(b);}
	int unite(T a,T b,int p,int q){
		T x=root(a),y=root(b);if(x==y)return 0;
		parent[x]=y;
		tbl[y]=min(min(tbl[x]?:1<<29,tbl[y]?:1<<29),min(p,q));
		tbl.erase(x);
		return 1;
	}
	int get(T a){
		return tbl[root(a)];
	}
};

int main(){
	int N;
	unordered_map<string,int>m;
	for(cin>>N;N--;){
		string s;int x;
		cin>>s>>x;
		m[s]=x;
	}
	union_find<string> uf;
	for(cin>>N;N--;){
		string s,t;
		cin>>s>>t;
		uf.unite(s,t,m[s],m[t]);
	}
	int r=0;
	for(auto &e:m){
		r+=uf.get(e.first)?:e.second;
	}
	cout<<r<<endl;
}

Measured memory_bytes: 2180
N, x = map(int,input().split())
A = list(map(int, input().split()))

ans = 0
for i in range(0, N-1):
    if A[i] + A[i+1] > x:
        t = A[i+1] + A[i] - x

        if A[i+1] < t:
            A[i+1] = 0
        else:
            A[i+1] -= t
        ans += t

print(ans)

Measured memory_bytes: 84932
n, m = map(int, input().split())
a = []
b = []
for i in range(m):
    a_, b_ = map(int, input().split())
    if a_ == 1 or a_ == n or b_ == 1 or b_ == n:
        a.append(a_)
        b.append(b_)

x_min=[]
x_max=[]
for i in range(len(a)):
    if a[i] == 1 or b[i] == 1:
        x_max.append(max(a[i], b[i]))
    if a[i] == n or b[i] == n:
        x_min.append(min(a[i], b[i]))
x = x_min + x_max
if len(x) == len(set(x)):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")


Measured memory_bytes: 31184
import heapq

n, m = map(int, input().split())
a = list(map(int, input().split()))

for i in range(0, n):
    a[i] *= -1
    
heapq.heapify(a)

for _ in range(m):
    c = heapq.heappop(a)
    heapq.heappush(a, -(-c // 2))
    
print(-sum(a))

Measured memory_bytes: 14380
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int n,a,b;
const LL mod=1e9+7;
LL km(LL a,LL b){
  LL ans=1;
  while(b){
    if(b&1)ans=a*ans%mod;
    b>>=1;
    a=a*a%mod;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>a>>b;
  LL tot=km(2,n)-1+mod;
  tot%=mod;
  //C(n,a)  C(n,b)
  LL l=1;
  for(int i=1;i<=a;i++){
    l=l*i%mod;
  }
  LL R=1;
  for(int i=n;i>n-a;i--){
    R=R*i%mod;
  }
  tot-=R*km(l,mod-2)%mod;
  tot+=mod;

  l=1;
  for(int i=1;i<=b;i++){
    l=l*i%mod;
  }
  R=1;
  for(int i=n;i>n-b;i--){
    R=R*i%mod;
  }
  tot-=R*km(l,mod-2)%mod;
  tot+=mod;
  cout<<(tot+10ll*mod)%mod<<'\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    ll n;
    cin >> n;
    if(n % 2 == 1) cout << 0 << endl;
    else{
        ll ans = 0;
        for(ll i = 1; i <= 30; i++){
            if(pow(5LL, i) > LINF) break;
            ans += n / (ll)(2 * pow(5LL, i));
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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 A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T>> &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

int n;
vv<vv<Pii>> G;
vii dist;

void dfs(int v, int p, int d) {
  if (dist[v] != -1) return;
  dist[v] = d;
  for (auto e : G[v]) {
    if (e.first != p) dfs(e.first, v, d + e.second);
  }
}

signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n;
  G.resize(n + 1);
  dist.resize(n + 1, -1);
  rep(i, 0, n-1) {
    int v, u, w;
    cin >> v >> u >> w;
    G[v].pb(mp(u, w));
    G[u].pb(mp(v, w));
  }
  dfs(1, -1, 0);
  erep(i, 1, n) {
    cout << dist[i] % 2 << endl;
  }
  return 0;
}




Measured memory_bytes: 9984
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
string s;
int n,a,b,c,d;
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>a>>b>>c>>d;
	cin>>s;
	s=" "+s+"#####";
	if(d>c){
		for(int i=min(a,b);i<=max(c,d)-1;i++){
			if(s[i]=='#'&&s[i+1]=='#')return puts("No")&0;
		}
		puts("Yes");
	}else{
		//d<c
		for(int i=a;i<=c-1;i++){
			if(s[i]=='#'&&s[i+1]=='#'){
				return puts("No")&0;
			}
		}
		for(int i=b-1;i<=d-1;i++){
			if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'){
				return puts("Yes")&0;
			}
		}
		puts("No");
	}
	return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
#define ll long long
using namespace std;
main(){
    ll n;
    cin >> n;
    n--;
    if(n == 0){
        cout<<'a';
        return 0;
    }
    vector<char> v;
    while(n > 0){
        v.push_back(n % 26);
        n /= 26;
        n--;
        if(n == 0) v.push_back(0);
    }
    reverse(v.begin(),v.end());
    for(ll i = 0; i < v.size(); i++)
        cout<<(char)('a'+v[i]);
    cout<<endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H,W;
  bool ans = 1;
  cin >> H >> W;
  char s[H+2][W+2];
  for(int i = 0;i < H+2;i++){
    for(int j = 0;j < W+2;j++){
      s[i][j] = '.';
    }
  }
  for(int i = 1;i <= H;i++){
    for(int j = 1;j <= W;j++){
      cin >> s[i][j];
    }
  }
  for(int i = 1;i <= H;i++){
    for(int j = 1;j <= W;j++){
      if(s[i][j] == '#' && s[i-1][j] == '.' && s[i][j-1] == '.' && s[i+1][j] == '.' && s[i][j+1] == '.')ans = 0;
    }
  }
  if(ans)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)
from heapq import heappush, heappop

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

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

n = int(input())
S = [ input() for _ in range(n)]

left = 0
right = 0

l_ok = [False] * n
r_ok = [False] * n
LMR = [0] * n
MIN_LMR = [0] * n

for i,s in enumerate(S):
    l = 0
    r = 0
    lok = True
    for j,c in enumerate(s):
        if c == "(":
            l += 1
        else:
            r += 1
            if r > l:
                lok = False
        MIN_LMR[i] = min(MIN_LMR[i], l-r)
    LMR[i] = l - r
    l = 0
    r = 0
    rok = True
    for j in range(len(s)-1, -1, -1):
        if s[j] == "(":
            l += 1
            if l > r:
                rok = False
                break
        else:
            r += 1

    left += s.count("(")
    right += s.count(")")

    l_ok[i] = lok
    r_ok[i] = rok

# log(l_ok)
# log(r_ok)

if left != right:
    print("No")
    exit()


positives = [ (MIN_LMR[i], LMR[i]) for i,x in enumerate(LMR) if x > 0 ]
zeros     = [ (MIN_LMR[i], LMR[i]) for i,x in enumerate(LMR) if x == 0 ]
negatives = [ (MIN_LMR[i], LMR[i]) for i,x in enumerate(LMR) if x < 0]
for i in range(len(negatives)):
    min_lmr, lmr = negatives[i]
    min_lmr = min_lmr - lmr
    lmr = -1 * lmr
    negatives[i] = (min_lmr, lmr)

positives.sort(reverse=True)
negatives.sort(reverse=True)

h = 0
for min_lmr, lmr in positives + zeros:
    if h+min_lmr < 0:
        print("No")
        exit()
    h += lmr

h = 0
for min_lmr, lmr in negatives:
    if h+min_lmr < 0:
        print("No")
        exit()
    h += lmr

print("Yes")

Measured memory_bytes: 208716
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int f[MAX_N]={};
int b[MAX_N]={};

int main() {
    int n,k;
    string s;
    cin>>n>>k>>s;
    s[k-1]=s[k-1]+32;
    cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int x,y,m,n,k;
scanf("%d%d",&x,&y);
if(x>=y){
m=x;
n=y;
}
else{
m=y;
n=x;
}
while(n!=0){
k=n;
n=m%n;
m=k;
}
printf("%d\n",m);
return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <cstdio>
using namespace std;
const int MAX = 12;
char field[MAX][MAX];

void dfs(int x, int y) {
  field[x][y] = '0';

  for(int dx = -1 ; dx <= 1 ; dx++) {
    int nx = x + dx;
    if(0 <= nx && nx < MAX && field[nx][y] == '1') dfs(nx, y);
  }
  for(int dy = -1 ; dy <= 1 ; dy++) {
    int ny = y + dy;
    if(0 <= ny && ny < MAX && field[x][ny] == '1') dfs(x, ny);
  }
}

int main() {
  int res;
  while(1) {
    res = 0;
    for(int i = 0 ; i < MAX ; i++) {
      for(int j = 0 ; j < MAX ; j++) {
	cin >> field[i][j];
      }
    }
    if(cin.eof()) break;
    
    for(int i = 0 ; i < MAX ; i++) {
      for(int j = 0 ; j < MAX ; j++) {
	if(field[i][j] == '1') {
	  dfs(i, j);
	  res++;
	}
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
  int n,i,j,d[100010],a;
  long long ans=1e18,s,c;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&d[i]);
  for(j=0;j<2;j++){
    s=c=0;
    for(i=0;i<n;i++){
      s+=d[i];
      if((i+j)%2==0&&s<=0){
	c+=1-s;
	s=1;
      }
      if((i+j)%2==1&&s>=0){
	c+=s+1;
	s=-1;
      }
    }
    if(ans>c)ans=c;
  }
  printf("%lld\n",ans);
  return 0;
}


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

int top, s[1000];

void push(int x){
  top++;
  s[top]=x;
}

int pop(){
  top--;
  return s[top+1];
}

int main(){
  int x,y;
  top=0;
  char t[100];

  while(scanf("%s",t)!=EOF){
    if(t[0]=='+'){
      x=pop();
      y=pop();
      push(x+y);
    }
    else if(t[0]=='-'){
      y=pop();
      x=pop();
      push(x-y);
    }
    else if(t[0]=='*'){
      x=pop();
      y=pop();
      push(x*y);
    }
    else push(atoi(t));
  }

  printf("%d\n",pop());

  return 0;
}



Measured memory_bytes: 2144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class37
    {
        static void Main()
        {
            var HN = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int H = HN[0], N = HN[1];
            int[] dp = new int[H + 1];
            for (int i = 1; i <= H; i++) dp[i] = int.MaxValue;
            dp[0] = 0;
            for(int i = 0; i < N; i++)
            {
                var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for(int j = 0; j < H; j++)
                {
                    if (dp[j] != int.MaxValue)
                    {
                        int k = Math.Min(H, j + ab[0]);
                        dp[k] = Math.Min(dp[k], dp[j] + ab[1]);
                    }
                }

            }
            Console.WriteLine(dp[H]);
        }
    }
}


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

int main() {
  int N,K;
  cin >> N >> K;
  
  vector<int> pole(N);
  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    pole[i] = a;
  }
  
  sort(pole.begin(), pole.end());
  reverse(pole.begin(),pole.end());
  
  int sum_max = 0;
  for(int i=0; i<K; i++) sum_max += pole[i];
  
  cout << sum_max << endl;
    
}

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


#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);


int main(void) {

	int     N,i=0;
	double   A,tmp=0.0;

	i_cin(N);
	rept (i,0,N){
		scanf("%lf",&A);
		tmp+=(double)1.0/A;
	}
	tmp = (double)1.0/tmp;
    printf("%lf\n",tmp);
	return 0;
}
	
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	rept(i, 0, n) {
		i_cin(*(a + i));
	}

	return 0;
}




Measured memory_bytes: 128
def main():
  N, X, Y = map(int, input().split())
  G = [[i] for i in range(1,N+1)]
  ans=[0]*(N-1)
  for i in range(1,N+1):
    for j in range(i+1,N+1):
      d = min(j-i, abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X))
      #print(i,j,d)
      ans[d-1]+=1
  for a in ans:
    print(a)

if __name__=='__main__':
  main()

Measured memory_bytes: 9304
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int divisors[10000005]={0};
int solve()
{
	int n;
	cin>>n;
	for(int  i=1;i<=n;i++){
		for(int j=i;j<=n;j+=i){
			divisors[j]++;
		}
	}
	int sum=0;
	for(int i=1;i<=n;i++){
		sum+=i*divisors[i];
	}
	cout<<sum<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fo(i, a, b) for(int i = a; i < b; i++)
#define SQ(a) (a)*(a)


int main(){
    int n, k; cin>> n;
    vector<int> cnt(n+1);
    for(int i = 0; i< n-1; i++){
        cin >> k;
        cnt[k]++;
    }
    for(int i = 1; i <= n; i++) cout<< cnt[i] << "\n";
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= n; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int k, n;
  cin >> k >> n;
  ivec a(n);
  REP(i, n) cin >> a[i];

  ll sum = 0;
  int ma = 0;
  REP(i, n) {
    int dist;
    if (i == n - 1) {
      dist = k - a[i] + a[0];
    } else {
      dist = a[i + 1] - a[i];
    }
    sum += dist;
    ma = max(ma, dist);
  }
  ll ans = sum - ma;
  print(ans);
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include<queue>
#include <string>
#include<algorithm>
#define N 250000
#define MOD 1000000007
using namespace std;
int cas;
int n,m,r,c;
int x1[N],y1[N],x2[N],y2[N];
int s[N];
struct ds{int x,y,num;}d[N];
bool cmp(ds d1,ds d2)
{
    if(d1.x==0&&d2.x==0)return d1.y<d2.y;
    if(d1.x==0)return 1;
    if(d2.x==0)return 0;
    if(d1.y==c&&d2.y==c)return d1.x<d2.x;
    if(d1.y==c)return 1;
    if(d2.y==c)return 0;
    if(d1.x==r&&d2.x==r)return d1.y>d2.y;
    if(d1.x==r)return 1;
    if(d2.x==r)return 0;
    return d1.x>d2.x;
}
int main()
{
    scanf("%d%d%d",&r,&c,&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d%d",&x1[i],&y1[i],&x2[i],&y2[i]);
        //if(x1[i]>x2[i])swap(x1[i],x2[i]);
        //if(y1[i]>y2[i])swap(y1[i],y2[i]);
        if(x1[i]!=0&&x1[i]!=r&&y1[i]!=0&&y1[i]!=c)continue;
        if(x2[i]!=0&&x2[i]!=r&&y2[i]!=0&&y2[i]!=c)continue;
        m++;
        d[m].x=x1[i];d[m].y=y1[i];d[m].num=i;
        m++;
        d[m].x=x2[i];d[m].y=y2[i];d[m].num=i;
    }
    sort(d+1,d+m+1,cmp);
    int cnt=0;
    for(int i=1;i<=m;i++)
    {
        if(cnt&&d[i].num==s[cnt])cnt--;
        else{s[++cnt]=d[i].num;}
    }
    if(cnt==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}
/*
 123
 043
 241
 
 12
 21
 100000
 000000
 000010
 000000
 000000
 000000
 */



Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <set>
#include <stack>
#include <cmath>

using namespace std;

int main()
{
    int n,t;
    cin >> n >> t;
    int ends = 0;
    int x;
    int ans = 0;
    for(int i=0; i<n; i++)
    {
        cin >> x;
        ans += (x<ends ? x+t-ends : t);
        ends = x+t;
    }
    cout << ans <<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int Lsearch(int[],int,int);

int main(){
  int data[10001],n,q,key,i,total=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&data[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(Lsearch(data,n,key)!=n)total++;
  }
  printf("%d\n",total);
  return 0;
}

int Lsearch(int data[],int n,int key){
  int i=0;
  data[n]=key;
  while(data[i]!=key){
    i++;
  }
  return i;
}




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

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

Measured memory_bytes: 256
import java.util.*

fun main() {
    val sc = Scanner(System.`in`)
    var k: Int = sc.nextInt()
    var a: Int = sc.nextInt()
    var b: Int = sc.nextInt()
    var i = k
    while (i <= b) {
        if (i in a..b) {
            println("OK")
            return
        }
        i += k
    }
    println("NG")
}


Measured memory_bytes: 36168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string S;
    cin >> S;
    for(int i=0;i<S.length();i++){
        if(i%2==0){
            if(S[i]=='R'||S[i]=='U'||S[i]=='D'){
                continue;
            }else{
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(S[i]=='L'||S[i]=='U'||S[i]=='D'){
                continue;
            }else{
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
  
int main(void){
int W,H,x,y,r;
do{
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
}while(!(x>=-100 && x<=100 && y>=-100 && y<=100 && W>=0 && W<=100 && H>=0 && H<=100 && r>=0 && r<=100));
if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
	printf("Yes\n");
}else{
	printf("No\n");
}
return 0;
}

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

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

        String s=scan.next();
        boolean app[]=new boolean[26];
        for(int i=0;i<s.length();i++){
            app[s.charAt(i)-'a']=true;
        }
        char ans;

        for(int i=0;i<26;i++){
            if(!app[i]){
                System.out.println((char)(i+'a'));
                break;

            }
            if(i==25){
                System.out.println("None");
            }
        }

    }
}

Measured memory_bytes: 27780
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int a; cin >> a;

    cout << a*a << ln;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define maxn 100
using namespace std;

int main() {
    char s[maxn + 1];
    int h, w;
    scanf("%d%d", &h, &w);
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++)
            cin >> s[j];
        for (int j = 1; j <= w; j++)
            cout << s[j];
        cout << '\n';
        for (int j = 1; j <= w; j++)
            cout << s[j];
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
C - Snack
https://atcoder.jp/contests/abc148/tasks/abc148_c

"""
import sys


from fractions import gcd

def solve(A, B):
    return A * B // gcd(A, B)


def main(args):
    A, B = map(int, input().split())
    ans = solve(A, B)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
vector<int>v;
string s;
int ary[100005] = {0};
int main(){
  int a,b,e_tree,def;


  cin >>a>>b;

  def = b-a;

  e_tree = (def*(def+1))/2;

  cout <<e_tree-b<<endl;
  return 0;
}


Measured memory_bytes: 256
def solve(s,t):
	if s==t:
		return 'IDENTICAL'
	s=s.split('"')
	t=t.split('"')
	if len(s)==len(t):
		k0=sum(s[i]!=t[i] for i in range(0,len(s),2))
		k1=sum(s[i]!=t[i] for i in range(1,len(s),2))
		if k0==0 and k1==1:
			return 'CLOSE'
	return 'DIFFERENT'

while True:
	s=input()
	if s=='.':
	    break
	t=input()
	print(solve(s,t))


Measured memory_bytes: 5592
#include<bits/stdc++.h>
#define _Max(a,b,c) Max(a,Max(b,c))
#define lop(i,a,b) for(int i=a;i<b; i++)
#define pb push_back
using namespace std;
/*
    *
    * Saroar Zahan Sojib
    * Green University - Bangladesh (GUB)
    *
*/
int main()
{
    long long A, B, N;
    cin >> A >> B >> N;
    long long x = min(B-1, N);
    cout << (A*x)/B - A*(x/B) << endl;
    return 0;
}


Measured memory_bytes: 3632
def prime?(n)
  (2 ... n).each do |i|
    return false if n % i == 0
    break if i * i > n
  end
  true
end

def solve(n, c)
  return (n == 1 ? 11 : "99"*n) if c < 0

  1.step(10**n, 2).map{|i|
    s = (("%0#{n}d"%i).reverse + c.to_s + "%0#{n}d"%i).to_i
    prime?(s) ? s : 0
  }.max
end

puts solve(*gets.split.map(&:to_i))

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

int main()
{
    int  k, a, b, c, sum = 0;
    cin >> a >> b >> c >> k;
    if(k >= a){
        k -= a;
        sum += a;
    } else {
        sum = k;
        k = 0;
    }

    if(k >= b){
        k -= b;
    } else {
        k = 0;
    }

    if(k != 0){
        sum -= k;
        k = 0;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3672
n, m, X = list(map(int, input().split()))

INF = 10**9
ans = INF


A = [[] for _ in range(n)]
C = [0] * n

for i in range(n):
    c_a = list(map(int, input().split()))
    C[i], A[i] = c_a[0], c_a[1:]



for s in range(0, 1 << n):
    smart = [0] * m
    cost_sum = 0
    for i in range(n):
        if (s >> i) % 2 == 0:
            continue
        cost_sum += C[i]
        for j in range(m):
            smart[j] += A[i][j]
    ok = True
    for j in range(m):
        if smart[j] < X:
            ok = False
    if ok:
        ans = min(ans, cost_sum)

if ans == INF:
    ans = -1

print(ans)


Measured memory_bytes: 9244
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

int main()
{
    std::string b;
    std::cin >> b;
    if(b[0] =='A'){
        std::cout << 'T' << std::endl;
    }else if(b[0] == 'T'){
        std::cout << 'A' <<std::endl;
    }else if(b[0] == 'G'){
        std::cout << 'C' <<std::endl;
    }else{
        std::cout << 'G' << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  if(A==B) cout << C << endl;
  else if(B==C) cout << A << endl;
  else cout << B << endl;
}

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

typedef long long ll;
typedef pair <int, int> pii;

#define NL cout<<"\n";
#define ALL(a) a.begin(), a.end()
#define DBG(a) cout<< #a <<" --> "<<(a)<<endl;
#define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define IN freopen("input.txt","r+",stdin)
#define OUT freopen("output.txt","w+",stdout)

template < class T1,class T2>
ostream &operator <<(ostream &os,const pair < T1,T2 > &p)
{
    os<<"{"<<p.first<<","<<p.second<<"}";
    return os;
}

const int N=3e5+5;
const int oo=1e9+7;

int32_t main()
{
    FastIO;
    int n,k;
    cin>>n>>k;
    if((n-1)*(n-2)/2  < k)
    {
        cout<<"-1\n";
    }
    else
    {
        vector<pii > ans;
        for(int i=1;i<=n-1;i++)
        {
            ans.push_back({i,n});
        }
        int x = (n-2)*(n-1)/2 - k  ;
        for(int i=1;i<=n-1;i++)
        {
            for(int j=1;j<i;j++)
            {
                if(x>0)
                {
                    ans.push_back({i,j});
                    x--;
                }
            }
        }
        cout<<ans.size()<<"\n";
        for(auto i: ans)
        {
            cout<<i.first<<" "<<i.second<<"\n";
        }
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<n;++i)
#define FOR(i,s) for(int i=s;i>=0;--i)

using ll = long long;
using namespace std;

const ll INF = 1010101010;
const ll MOD = 1000000007;

ll n, m, ans = 0; string A[101][101];
int main() {
	cin >> n >> m;
	rep(i, n) rep(j, m) cin >> A[i][j];
	rep(i, n) rep(j, m) {
		if (A[i][j] == "snuke") {
			char c = 'A' + j;
			cout << c << i + 1 << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n, m; cin >> n >> m;
  vl x(n), y(m);
  rep(i,n) cin >> x[i];
  rep(j,m) cin >> y[j];

  vl edge_x(n), edge_y(m);
  edge_x[0] = 0; edge_y[0] = 0;

  for (int i=1; i<n; ++i) {
    edge_x[i] = (edge_x[i-1] + (x[i] - x[i-1]) * i) % MOD;
  }
  for (int j=1; j<m; ++j) {
    edge_y[j] = (edge_y[j-1] + (y[j] - y[j-1]) * j) % MOD;
  }

  ll sum_x = 0, sum_y = 0;
  rep(i,n) (sum_x += edge_x[i]) %= MOD;
  rep(j,m) (sum_y += edge_y[j]) %= MOD;

  cout << sum_x * sum_y % MOD << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1;
const int inf=(1ull<<31)-1;
int n;
ld s=0;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>n;
	for (int i=0,t;i<n;i++)
		cin>>t,
		s+=(ld)(1/(ld)t);
	cout<<(ld)(1/s);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define reps(i,n) for(int i = 1; i <= (int)(n); 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 FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RFOR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
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; }
const int INF = INT_MAX;
const int MOD = 1000000007;

bool is_prime(int n) {
    if (n < 2) return false;
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    for (int i = 3; i*i <= n; i += 2){
        if (n % i == 0) return false;
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    int i = n;
    while (!is_prime(i)) i++; 
    cout << i <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define int long long
const int ofs = 12800;

int H, W;
int A[82][82], B[82][82];
bool dp[82][82][25610];
 
signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> H >> W;
    rep(i, H) rep(j, W) cin >> A[i][j];
    rep(i, H) rep(j, W) cin >> B[i][j];
    dp[0][0][A[0][0]-B[0][0]+ofs] = true;
    dp[0][0][B[0][0]-A[0][0]+ofs] = true;
    
    rep(i, H) rep(j, W) {
        if (i>0) rep(k, 25610) {
            if (!dp[i-1][j][k]) continue;
            int nk = k+A[i][j]-B[i][j];
            if (0<=nk && nk<25610) dp[i][j][nk] = true;
            nk = k+B[i][j]-A[i][j];
            if (0<=nk && nk<25610) dp[i][j][nk] = true;
        }
        if (j>0) rep(k, 25610) {
            if (!dp[i][j-1][k]) continue;
            int nk = k+A[i][j]-B[i][j];
            if (0<=nk && nk<25610) dp[i][j][nk] = true;
            nk = k+B[i][j]-A[i][j];
            if (0<=nk && nk<25610) dp[i][j][nk] = true;
        }
    }
    
    int ans = 1000000;
    rep(i, 25610) if (dp[H-1][W-1][i]) ans = min(ans, abs(i-ofs));
    cout << ans << endl;
}

Measured memory_bytes: 108944
n,a,b=map(int,input().split())
mod=10**9+7

def pow(x, n):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = ans*x%mod
    x = x*x%mod
    n = n >> 1 
  return ans

N=pow(2,n)
def comb(c,d):
  x=1
  for i in range(d):
    x=x*(c-i)%mod
  y=1
  for i in range(d):
    y=y*(i+1)%mod
  return x*pow(y,mod-2)%mod
A=comb(n,a)
B=comb(n,b)
print((N-A-B-1)%mod)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
template<typename T>
long long pow(T n, T x, T MOD=(T)(1e9)+7){
    long long res = 1LL;
    while(x){
        if(x%2==1) res = (res*n) % MOD;
        x = x>>1;
        n= (n*n) % MOD;
    }
    return res%MOD;
}

template<typename T>
long long factorial(T n, T MOD=(T)(1e9)+7) {
    ll res = 1;
    for(ll i=1; i<=n;i++){
        res = (res*i)%MOD;
    }
    return res%MOD;
}

template<typename T>
long long cmb(T n, T r, T MOD=(T)(1e9)+7){
    long long res = 1LL;
    if(r<0 or r>n) return res;
    r = (r<n-r? r: n-r);
    for(ll i=n-r+1; i<=n; i++) res = (res*i)%MOD;
    res = (res *pow(factorial(r), MOD-2, MOD))%MOD;
    return res % MOD;
}
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    int X, Y; cin>>X>>Y;
    ll res = 0;
    if((X+Y)%3!=0){
        res = 0;
    }
    else {
        ll N = (X+Y)/3;
        ll r = X-N;
        if(X<N or X>2*N or Y<N or Y>2*N) res = 0;
        else res = cmb(N, r);
    }
    cout << res % MOD << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll hoge[200][200];
vector<pair<pair<ll,ll>,ll>>fuga;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h,w,n;
  cin>>h>>w>>n;
  for(int i=0;i<200;i++)for(int j=0;j<200;j++)hoge[i][j]=-llINF;
  for(int i=0;i<n;i++){
    ll a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    fuga.pb(mp(mp(a,b),c));
    if(c<=hoge[a][b])continue;
    hoge[a][b]=c;
    queue<pair<pair<ll,ll>,ll>>que;
    que.push(mp(mp(a,b),c-1));
    while(!que.empty()){
      pair<ll,ll>po = que.front().F;
      ll height = que.front().S;
      que.pop();
      if(po.F-1>=0&&po.F-1<h)
	if(height>hoge[po.F-1][po.S]){
	   hoge[po.F-1][po.S] = height;
	   que.push(mp(mp(po.F-1,po.S),height-1));
	}
      if(po.S-1>=0&&po.S-1<w)
	if(height>hoge[po.F][po.S-1]){
	   hoge[po.F][po.S-1] = height;
	   que.push(mp(mp(po.F,po.S-1),height-1));
	}
      if(po.F+1>=0&&po.F+1<h)
	if(height>hoge[po.F+1][po.S]){
	  hoge[po.F+1][po.S] = height;
	  que.push(mp(mp(po.F+1,po.S),height-1));
	}
      if(po.S+1>=0&&po.S+1<w)
	if(height>hoge[po.F][po.S+1]){
	  hoge[po.F][po.S+1] = height;
	  que.push(mp(mp(po.F,po.S+1),height-1));
	}
    }
  
      
    
  }
  ll ans=0;
  bool fl=true;
  for(int i=0;i<n;i++){
    if(hoge[fuga[i].F.F][fuga[i].F.S] != fuga[i].S)fl=false;
  }
  if(fl){
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      ans+=hoge[i][j];
      //  cout<<hoge[i][j]<<" ";
    }
    //cout<<endl;

  }
  cout<<ans<<endl;
  }else cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 3524
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<((b/a)<c?b/a:c);
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll w; cin >> w;
    vector <ll> dp(1e3*n+1, 1e18);
    for(int i=1; i<=n ;i++){
        ll we; cin >> we;
        ll va; cin >> va;
        for(int j=1e3*n; j>va; j--) {
            dp[j] = min(dp[j], dp[j-va] + we);
        }
        for(int j=va; j>=0; j--) {
            dp[j] = min(dp[j], we);
        }
    }
    ll ans = 0;
    REP(i, 1e3*n+1){
        if (dp[i] <= w){
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    ll x, y;
    cin >> x >> y;
    if(abs(x - y) <= 1) cout << "Brown\n";
    else    cout << "Alice\n";
}

Measured memory_bytes: 256
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(4, 9, 2, 3), 2)

    def test_2(self):
        self.assertEqual(think(10, 40, 6, 8), 23)

    def test_3(self):
        self.assertEqual(think(314159265358979323, 846264338327950288, 419716939, 937510582), 532105071133627368)

    def test_4(self):
        self.assertEqual(count_multiple_between(4, 9, 2), 3)

    def test_5(self):
        self.assertEqual(count_multiple_between(4, 9, 3), 2)

    def test_6(self):
        self.assertEqual(count_multiple_between(4, 9, 6), 1)

    def test_7(self):
        self.assertEqual(count_multiple_between(10, 40, 6), 5)

    def test_8(self):
        self.assertEqual(count_multiple_between(10, 40, 8), 4)

    def test_9(self):
        self.assertEqual(count_multiple_between(10, 40, 24), 1)


def solve():
    a, b, c, d = read()
    result = think(a, b, c, d)
    write(result)


def read():
    return read_int(4)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a, b, c, d):
    if c > d:
        return think(a, b, d, c)

    if c == 1:
        return 0

    if d % c == 0:
        num_of_multiple = count_multiple_between(a, b, c)
        return b - a + 1 - num_of_multiple

    lcm = least_common_multiple(c, d)

    num_of_multiple_c = count_multiple_between(a, b, c)
    num_of_multiple_d = count_multiple_between(a, b, d)
    num_of_multiple_lcm = count_multiple_between(a, b, lcm)

    return b - a + 1 - (num_of_multiple_c + num_of_multiple_d - num_of_multiple_lcm)


def count_multiple_between(a, b, c):
    minimum_multiple = a if a % c == 0 else a + (c - (a % c))
    maximum_mulptile = b if b % c == 0 else b - (b % c)

    if maximum_mulptile < minimum_multiple:
        return 0

    return (maximum_mulptile - minimum_multiple) // c + 1


def least_common_multiple(a, b):
    return (a * b) // greatest_common_divisor(a, b)


def greatest_common_divisor(a, b):
    if a < b:
        return greatest_common_divisor(b, a)

    if a % b == 0:
        return b
    return greatest_common_divisor(b, a % b)


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 6460
#include <math.h>
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
	int n, s[1000] = { 0 }, sum = 0;
	double ave = 0.0, sigma = 0.0, standard_deviation = 0.0;
	while (true)
	{
		cin >> n;
		if (n == 0) break;
		sum = 0;
		for (int i = 0; i < n; i++) {
			cin >> s[i];
			sum += s[i];
		}
		ave = (double)sum / n;
		sigma = 0.0;
		for (int i = 0; i < n; i++) {
			double temp = s[i] - ave;
			sigma += temp * temp;
		}
		standard_deviation = sqrt(sigma / n);
		cout << fixed
			<< setprecision(8)
			<< standard_deviation << endl;
	}
	return 0;
}

Measured memory_bytes: 1240