akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string.h>
using namespace std;
const int mo = 1e9 + 7;
const int ma = 200005;
#define int long long
struct mint
{
    int x;
    mint() : x(0) {}
    mint(int x) : x((x % mo + mo) % mo) {}
    mint &fix()
    {
        x = (x % mo + mo) % mo;
        return *this;
    }
    mint operator-() const { return mint(0) - *this; }
    mint &operator+=(const mint &a)
    {
        if ((x += a.x) >= mo)
            x -= mo;
        return *this;
    }
    mint &operator-=(const mint &a)
    {
        if ((x += mo - a.x) >= mo)
            x -= mo;
        return *this;
    }
    mint &operator*=(const mint &a)
    {
        (x *= a.x) %= mo;
        return *this;
    }
    mint operator+(const mint &a) const { return mint(*this) += a; }
    mint operator-(const mint &a) const { return mint(*this) -= a; }
    mint operator*(const mint &a) const { return mint(*this) *= a; }
    bool operator<(const mint &a) const { return x < a.x; }
    bool operator==(const mint &a) const { return x == a.x; }
};
istream &operator>>(istream &i, mint &a)
{
    i >> a.x;
    return i;
}
ostream &operator<<(ostream &o, const mint &a)
{
    o << a.x;
    return o;
}
vector< vector< int > > to(ma);
mint dp[ma][2];
void dfs( int v, int p = -1 )
{
    mint a = 1, b = 1;
    for(int i = 0; i < to[v].size(); i++ )
    {
        int u = to[v][i];
        if( u == p ) continue;
        dfs( u,v  );
        a *= dp[u][0] + dp[u][1];
        b *= dp[u][0];
    }
    dp[v][0] = a;
    dp[v][1] = b;
}
main()
{
    int n;cin >> n;
    for(int i = 0; i < n - 1; i++ )
    {
        int a,b;
        cin >> a >> b;
        --a,--b;
        to[a].emplace_back(b);
        to[b].emplace_back(a);
    } 
    dfs( 0 );
    mint ans = dp[0][0] + dp[0][1];
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 18176
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    ll h,w;
    cin>>h>>w;
    ll ans=0x3f3f3f3f3f3f3f3f;
    for(int i=1;i<h;i++)
    {
        ll cc=w*i;
        ll aa=w/2*(h-i);
        ll bb=(w-w/2)*(h-i);
        vc<ll> cur={aa,bb,cc};
        sort(cur.begin(),cur.end());
        ans=min(ans,(*cur.rbegin())-(*cur.begin()));
        aa=(h-i)/2*w;
        bb=((h-i)-(h-i)/2)*w;
        cur={aa,bb,cc};
        sort(cur.begin(),cur.end());
        ans=min(ans,(*cur.rbegin())-(*cur.begin()));
    }
    swap(h,w);
    for(int i=1;i<h;i++)
    {
        ll cc=w*i;
        ll aa=w/2*(h-i);
        ll bb=(w-w/2)*(h-i);
        vc<ll> cur={aa,bb,cc};
        sort(cur.begin(),cur.end());
        ans=min(ans,(*cur.rbegin())-(*cur.begin()));
        aa=(h-i)/2*w;
        bb=((h-i)-(h-i)/2)*w;
        cur={aa,bb,cc};
        sort(cur.begin(),cur.end());
        ans=min(ans,(*cur.rbegin())-(*cur.begin()));
    }
    cout<<ans<<'\n';

}

Measured memory_bytes: 256
#入力
n, q = map(int, input().split())
G = [[] for _ in range(n+1)]
for i in range(n-1):
    x, y = map(int, input().split())
    G[x].append(y)
    G[y].append(x)

counter = [0 for _ in range(n+1)]
for _ in range(q):
    x, y = map(int, input().split())
    counter[x] += y

"""
#再帰
ans_dfs = [0 for _ in range(n)]
def dfs(now, parent, S):
    ans_dfs[now] = S + counter[now]
    for to in G[now]:
        if to == parent: continue
        dfs(to, now, ans_dfs[now])

"""
#非再帰
class p:
    num = -1
    parent = -1

    def __init__(self, x, y):
        self.num = x
        self.parent = y
#dfsでの探索順
node_list = []
ans = [0 for _ in range(n+1)]

def main():

    #dfs(1, -1, 0)
    #dfsでの探索順の作成
    stack = []
    stack.append(p(1, -1))
    while len(stack) != 0:
        now = stack.pop()
        node_list.append(now)
        for to in G[now.num]:
            if to == now.parent: continue
            stack.append(p(to, now.num))

    for now in node_list:
        ans[now.num] = counter[now.num] + ans[now.parent]

    for i in range(1, n+1): print(ans[i], end=' ')
    print()



if __name__ == '__main__':
    main()


Measured memory_bytes: 121420
import java.util.*;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        
        int[] nums = new int[4];
        
        String text = scanner.next();
        
        for(int i=0; i<nums.length; i++){
            nums[i] = text.charAt(i)-'0';
           // System.out.print(nums[i]+" ");
        }
       
        
        int n = nums.length-1;
        Character[] str = new Character[n];
        
        int result = 0;
        for(int bit=0; bit < Math.pow(2,n); bit++){
            
        
            for(int i=0;i<n;i++){
                if((bit & (1<<i))!=0){
                    str[i] = '+';
                    
                }else{
                    str[i] = '-';
                    
                }
                
            }
            int[] str_nums = nums.clone();
            result = caluclator(str,str_nums);
            
            
            if(result==7){
                for(int i=0;i<3;i++){
                    System.out.print(nums[i]);
                    System.out.print(str[i]);
                }
                
                System.out.print(nums[3]+"=7");
                break;
            }
            
            
            
            
        }
    }
    
    static int caluclator(Character operator[],int nums2[]){
        
        for(int i=0;i<3;i++){
            
            if(operator[i]=='+'){
                
                nums2[i+1] = nums2[i]+nums2[i+1];
            }else{
               
                 nums2[i+1] = nums2[i]-nums2[i+1]; 
            }
        }
        return nums2[3];
        
    }
        
        
}

Measured memory_bytes: 38540
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,c,d;
  cin >> n;
  a = n / 1000;
  b = n % 1000 / 100;
  c = n % 1000 % 100 / 10;
  d = n % 1000 % 100 % 10;
  if((b ==c)&&(a ==b || c == d)){
        cout <<"Yes"<<endl;
  }else{
    cout << "No" <<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>
#define ll long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define MOD 1000000007
using namespace std;

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


Measured memory_bytes: 3136
from math import floor, sqrt
from collections import Counter

MOD = 10 ** 9 + 7

# xを素因数分解する
def getPrimeFactor(x):
    ans = []
    for d in range(2, floor(sqrt(x)) + 1):
        while x % d == 0:
            ans.append(d)
            x //= d
    if x != 1:
        ans.append(x)
    return ans

def comb(n, k):
    k = min(k, n - k)
    ans = 1
    for i in range(n, n - k, -1):
        ans *= i
    for i in range(1, k + 1):
        ans //= i 
    return ans


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

PFs = getPrimeFactor(M)
cnt = Counter(PFs)

ans = 1
for num in cnt.values():
    ans *= comb(N + num - 1, num)
print(ans % MOD)


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

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));

        //ArrayList myList = new ArrayList<>();

        String S = next();
        int len = S.length();

        char[] myList = S.toCharArray();
        int[] mod = new int[len];

        int temp = myList[len-1]-'0';
        mod[len-1] = temp;
        int tenPower = 1;
        for(int i = len-2; i>=0; i--){
            tenPower *= 10;
            tenPower %=2019;
            temp = myList[i]-'0';
            mod[i] = (temp*tenPower + mod[i+1]) % 2019;
        }

        int[] fq = new int[2019];
         
        for(int i = 0; i<len; i++){
            fq[mod[i]] ++;
        }

        // A - B = 0 --> A % 2019 = B % 2019
        // 1817181712114
        // A = 1817181712114 % 2019 = 1165
        // B =      81712114 % 2019 = 1165
        // A - B = 18171 * 10000000
        // 10000000 can never % 2019, so 18171 must % 2019
        
        long count = fq[0]; // handle special case
        for(int i = 0; i<2019; i++){
            if(fq[i]>1){
                count += fq[i] * (fq[i]-1) /2;
            }
            
        }
        System.out.println(count);
    }
    
      
    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: 37224
#include <bits/stdc++.h>

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  std::vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  sort(v.begin(), v.end());

  int res=0;
  for(int i=0;i<n;i++){
    int p=v[i];
    int k=0;
    while(p==v[i]&&i<n){
      i++;
      k++;
    }
    i--;
    if(p==k){
    } else if(p<k){
      res+=(k-p);
    }else{
      res+=k;
    }
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
	ll N;
	cin >> N;
	vl A(N);
	FOR(i,0,N)cin >> A[i];
	FOR(i,0,N)A[i] %= 2;
	sort(ALL(A));
	bool ans = COUNT(A,1)%2;
	YES(!ans);
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<iomanip>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
vector < vector<int>> chi;
vector<int>pha;
vector<int>dist;
vector<int>ans;
void dfs(int n) {
	if (chi[n].size() == 0)return;
	int X = chi[n].size();
	for (int i = 0; i < X; ++i) {
		int Y = chi[n][i];
		pha[Y]--;
		if (dist[Y] < dist[n] + 1) {
			ans[Y] = n;
			dist[Y] = dist[n] + 1;
		}
		if (pha[Y] == 0)dfs(Y);
	}
}
int main() {
	int N, M;
	cin >> N >> M;
	int root;
	chi = vector<vector<int>>(N + 1);
	pha = vector<int>(N + 1, 0);
	vector<bool>V(N + 1, true);
	for (int i = 0; i < N + M - 1; ++i) {
		int A, B;
		cin >> A >> B;
		chi[A].push_back(B);
		pha[B]++;
		V[B] = false;
	}
	for (int i = 1; i <= N; ++i) {
		if (V[i])root = i;
	}
	dist = vector<int>(N + 1, 0);
	ans = vector<int>(N + 1, 0);
	dfs(root);
	for (int i = 1; i <= N; ++i) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e15

template <typename T>
struct Graph {
    int V, E;
    struct Edge {
        int from, to;
        T cost;
    };
    vector<vector<Edge>> edge;
    vector<vector<T>> dist;
    vector<Edge> es;

    Graph(int V, int E) : V(V), E(E) {
        edge.assign(V, vector<Edge>(0));
        dist.assign(V, vector<T>(0));
    }

    void input(bool is_direct, bool inputc, bool index0 = false) {
        int a, b;
        T c = 0;
        for (int i = 0; i < E; i++) {
            cin >> a >> b;
            if (inputc) cin >> c;
            if (!index0) a--, b--;
            edge[a].push_back((Edge){a, b, c});
            es.push_back((Edge){a, b, c});
            if (!is_direct) {
                edge[b].push_back((Edge){b, a, c});
                es.push_back((Edge){b, a, c});
            }
        }
        if (!is_direct) E *= 2;
    }

    void add_edge(int from, int to, T cost, bool is_direct) {
        edge[from].push_back({from, to, cost});
        es.push_back({from, to, cost});
        if (!is_direct) {
            edge[to].push_back({to, from, cost});
            es.push_back({to, from, cost});
            E++;
        }
        E++;
    }
    typedef pair<T, int> P;  // (first,second) := (最短距離,頂点番号)
    // 頂点rからの最小距離
    void dijkstra(int r = 0) {
        dist[r].assign(V, INF);

        priority_queue<P, vector<P>, greater<P>> que;
        que.push(P(0, r));
        dist[r][r] = 0;

        while (que.size()) {
            P p = que.top();
            que.pop();
            int v = p.second;
            if (dist[r][v] < p.first) continue;
            for (int i = 0; i < edge[v].size(); i++) {
                Edge e = edge[v][i];
                if (dist[r][v] + e.cost < dist[r][e.to]) {
                    dist[r][e.to] = dist[r][v] + e.cost;
                    que.push(P(dist[r][e.to], e.to));
                }
            }
        }
    }
};

int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--, t--;
    Graph<ll> gy(n, 0), gs(n, 0);
    for (int i = 0; i < m; i++) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--, v--;
        gy.add_edge(u, v, a, false);
        gs.add_edge(u, v, b, false);
    }
    gy.dijkstra(s);
    gs.dijkstra(t);
    vector<ll> min_cost(n, INF);
    min_cost[n - 1] = gy.dist[s][n - 1] + gs.dist[t][n - 1];
    for (int i = n - 2; i >= 0; i--) {
        min_cost[i] = min(min_cost[i + 1], gy.dist[s][i] + gs.dist[t][i]);
    }
    for (int i = 0; i < n; i++) {
        cout << (ll)INF - min_cost[i] << endl;
    }
    return 0;
}

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

#define ll long long
#define arr array

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll n, a ,b;
	cin >> n >> a >> b;
	cout << n/(a+b)*a+min(n%(a+b), a);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int flag = 0;
        for(int i = 1; i <= 9; i++) {
            if(n % i == 0 && n / i < 10){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

void solve(){
  int n; cin >> n;
  vector<vector<int> > a(2, vector<int>(n));
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < n; j++){
      cin >> a[i][j];
    }
  }
  int sum = 0;
  vector<int> ans1(n), ans2(n);
  for(int i = 0; i < n; i++){
    sum += a[0][i];
    ans1[i] = sum;
  }
  sum = 0;
  for(int i = n - 1; i >= 0; i--){
    sum += a[1][i];
    ans2[i] = sum;
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    ans = max(ans1[i] + ans2[i], ans);
  }
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}


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

using namespace std;

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2 

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

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

int main(){

    bool flag=false;

    ll ans=0,sum=0;
    
    int a,b,c;
    cin >>a>>b>>c;
    
  	if(a < c && c < b)flag=true;
  	if(b < c && c < a)flag=true;

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    if(flag)cout << "Yes" <<endl;
    else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;


public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        final int N=scanner.nextInt();
        if(N<1000){
            System.out.println("ABC");
        }else{
            System.out.println("ABD");
        }


    }
}


Measured memory_bytes: 22612
s = ("","Man","Oku","Cho","Kei","Gai","Jo",
	"Jou","Ko","Kan","Sei","Sai","Gok","Ggs",
	"Asg","Nyt","Fks","Mts")

while True:
	m,n = map(int,input().split())
	if m == 0 and n == 0:
		break
	ans = ""
	for i in range(0,len(str(m**n)),4):
		x = m**n//(10**i)%10000#m^n / 10^i
		if x > 0:
			ans = str(x) + s[i//4] + ans
	print(ans)

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

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back

using namespace std;

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

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }

inline void proc_status()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) <<endl;
}

template <typename T> T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

const int Maxn = 1000 + 10, Mod = 1e9 + 7;

int N, M;
int A[Maxn][Maxn], Dp[Maxn][Maxn];

inline void Solve ()
{
	Dp[1][1] = 1;
	for (int i = 1; i <= N; ++i)
		for (int j = 1; j <= M; ++j)
		{
			if (A[i][j]) continue;
			if (!A[i + 1][j]) (Dp[i + 1][j] += Dp[i][j]) %= Mod;
			if (!A[i][j + 1]) (Dp[i][j + 1] += Dp[i][j]) %= Mod;
		}
	cout<<Dp[N][M]<<endl;
}

inline void Input ()
{
	N = read<int>(), M = read<int>();
	for (int i = 1; i <= N; ++i)
	{
		char S[Maxn];
		scanf("%s", S + 1);
		for (int j = 1; j <= M; ++j)
			if (S[j] == '.') A[i][j] = 0;
			else A[i][j] = 1;
	}
}

int main()
{
#ifdef hk_cnyali
	freopen("H.in", "r", stdin);
	freopen("H.out", "w", stdout);
#endif
	Input();
	Solve();
	return 0;
}


Measured memory_bytes: 8192
#include <iostream>
using namespace std;
int main(void){
	long long int n,a[200010],temp[200010],i,t,s=0;
	cin >> n;
	for (i=0;i<n;i++) {
		cin >> a[i];
	}
	t = 0;
	for (i=n-1;i>0;i--) {
		temp[i] = (a[i] + t)%1000000007;
		t = temp[i];
	}
/*for (i=0;i<n;i++) {
cout<<temp[i]<<'\n';
}*/
	for (i=0;i<n-1;i++) {
		s += a[i]*temp[i+1];
		s = s%1000000007;
//cout<<s<<'\n';
	}
	cout << s << '\n';
}


Measured memory_bytes: 6768
<?php
list($n) = ints();
list($s) = strs();
foreach (['S', 'W'] as $a0) {
    foreach (['S', 'W'] as $a1) {
        if (check($a0, $a1)) {
            echo implode('', $a);
            exit;
        }
    }
}
exit('-1');
function check($a0, $a1)
{
    global $n, $s, $a;
    $a = [$a0, $a1];
    for ($i = 1; $i <= $n; ++$i) {
        if ($a[$i % $n] === 'S') {
            if ($s[$i % $n] === 'o') $a[($i + 1) % $n] = $a[$i - 1];
            else $a[($i + 1) % $n] = $a[$i - 1] === 'S' ? 'W' : 'S';
        } else {
            if ($s[$i % $n] === 'o') $a[($i + 1) % $n] = $a[$i - 1] === 'S' ? 'W' : 'S';
            else $a[($i + 1) % $n] = $a[$i - 1];
        }
    }
    return $a[0] === $a0 && $a[1] === $a1;
}
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 10868
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
  long n;
  long a[100000];

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

  sort(a, a+n);

  long max_a = a[n-1];
  double half_a = a[n-1]/2.0;
  long near_half_a = a[0];
  for(long l = 1; l < n; l++){
    if( fabs(near_half_a -half_a) > fabs(a[l]-half_a)) near_half_a = a[l];
    
  }
  
  cout << max_a << " " << near_half_a << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};


int main(){
    ll ans = 0;
    int n;
    cin >> n;
    ll a[200];
    REP(i, 200) a[i] = 0;
    REP(i, n){
        string s;
        cin >> s;
        a[s[0]]++;
    }
    a[0] = a['M'];
    a[1] = a['A'];
    a[2] = a['R'];
    a[3] = a['C'];
    a[4] = a['H'];
    REP(i, 5){
        REP(j, 5){
            if(i >= j) continue;
            REP(k, 5){
                if(j >= k || i >= k) continue;
                ans += a[i] * a[j] * a[k];
            }
        }
    }
    cout << ans << endl;
}

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


int main() {
  int A, V, B, W, T;
  cin >> A >> V >> B >> W >> T;
  int dist = abs(A - B);
  if (V <= W) {
    cout << "NO" << endl;
    return 0;
  }
  int s = V - W;
  if (dist <= (ll)s * T) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 3616
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;
#define int ll
bool validate(vi vec, int flag_even) {
	if (flag_even) {
		for (auto e : vec) {
			if (e != 2) {
				return false;
			}
		}
	}
	else {
		for (int i = 0; i < vec.size(); i++) {
			if (vec[0] != 1) {
				return false;
			}
			if (i != 0 && vec[i] != 2) {
				return false;
			}
		}
	}

	return true;
}

ll mpow(ll x, ll n) { //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % MOD;
		x = x * x % MOD;
		n = n >> 1;
	}
	return ans;
}

inline int ctoi(char c) {
	return c - '0';
}

ll acc(vi v) {
	ll res = 0;
	for (auto e : v) {
		res += e;
	}
	return res;
}
signed main() {
	string s; cin >> s;
	int N = s.size();
	ll ans = 0;
	vector<vi> check;
	vi checki;
	for (int i = 0; i < (1 << N-1); i += 1) {
		bitset<10> bs = i;
		int cnt = 0;
		int u = 0;
		vector<int> vec(10);

		for (int j = s.size() - 1; j  >= 0; j--) {
			vec[u] += mpow(10, cnt) * ctoi(s[j]);
			if (bs[s.size() - 1 -j] == true) {
				u++;
				cnt = 0;
			}
			else {
				cnt++;
			}
		}
		check.push_back(vec);
		checki.push_back(i);
		ans += acc(vec);
	}
	
	std::cout << ans << endl;
}

Measured memory_bytes: 3676
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    int MAX(int a,int b){
      if(a<b){
        int tmp = a;
        a = b;
        b = tmp;
      }
      int r = a%b;
      while(!r){
        a = b;
        b = r;
        r = a%b;
      }
      return r;
    }

    int main(){
      long n;
      cin>>n;
      long m = pow(n,0.5)+1;
      long res,r;
      while(m>0){
        m--;
        if(n%m == 0){
          r = n/m;
          break;
        }
      }
      res = m+r-2;
      cout<<res<<endl;
    }


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define int long long
using namespace std;

const int P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
  cout << fixed << setprecision(10);
  int M1, D1, M2, D2;
  cin >> M1 >> D1 >> M2 >> D2;
  bool answer = false;
  if (M2-M1==1)
  {
    cout << 1 << endl;
    answer = true;
  }
  if (answer==false)
  {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
/*input
5 5
1 2
3 5
5 1
3 4
2 3
*/
#include<bits/stdc++.h>
using namespace std;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int fast_ex(int a,int n,int m){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= fast_ex(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int n,m;
int a[100001];

void solve(){
	 cin >> n >> m;
     REP(i,m){
     	int x,y;cin >> x >> y;
     	a[x]++;
     	a[y]++;
     }
     RE(i,n){
     	if(a[i]%2){
     		cout << "NO";
     		return;
     	}
     }
     cout << "YES";
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;//cin >> t;
  WL(t)solve();
  return 0;
}

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

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int At,Bt,Ct;
    cin >> At >> Bt >> Ct;
    vector<int> A;
    A.push_back(At);
    A.push_back(Bt);
    A.push_back(Ct);
    sort(A.begin(),A.end());
    int sum=0,i;
    for(i=1;i<3;i++)
        sum+= A[i] -A[i-1];
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         UNIQUE(v)                   v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
//int dx[]={0,0,1,-1,1,1,-1,-1};
//int dy[]={1,-1,0,0,1,-1,1,-1};


int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll a,b,c,d,ans;
    sfl(a),sfl(b),sfl(c),sfl(d);
    ans = a*c;
    ans = max(ans,a*d);
    ans = max(ans,b*c);
    ans = max(ans,b*d);
    pfl(ans);
    return 0;
}

Measured memory_bytes: 3776
//32
#include<iostream>
#include<cmath>

using namespace std;

char t[128];
int n;
int l[11];
char *p;

int prs(){
  if(*p!='('){
    return l[*p++-'0'];
  }else{
    p++;
    int a=prs();
    char o=*p++;
    int b=prs();
    p++;
    switch(o){
    case 'A':
      return a&b;
    case 'O':
      return a|b;
    case 'X':
      return a^b;
    }
  }
}

int dfs(char *s){
  while(*s!=' '&&*s!='\0'){
    s++;
  }
  if(*s!='\0'){
    int r=0;
    for(int i=0;i<3;i++){
      const char *o="AOX";
      *s=o[i];
      r+=dfs(s);
    }
    *s=' ';
    return r;
  }else{
    p=t;
    return 15==prs();
  }
}

int main(){
  while(cin.getline(t,128),t[0]!='E'){
    cin>>n;
    for(int i=0;i<n;i++){
      int tl=0;
      for(int j=0;j<4;j++){
	int b;
	cin>>b;
	tl=tl<<1|b;
      }
      l[i+1]=tl;
    }
    cin.ignore();
    cout<<dfs(t)<<endl;
  }
  return 0;
}
  

Measured memory_bytes: 1164
while true
   i=gets.split
   x=i[0].to_i
   y=i[1].to_i
   if (x==0 && y==0)
      break
   end
   if (y>x)
      print "#{x} #{y}\n"
   elsif (x>y)
      print "#{y} #{x}\n"
   else
      print "#{x} #{y}\n"
   end
end

Measured memory_bytes: 6100
def main():
    N = int( input())
    ANS = [0]*(N+1)
    for x in range(1,101):
        for y in range(1,101):
            for z in range(1,101):
                t = x**2 + y**2 + z**2 +x*y + y*z + z*x
                if t <= N:
                    ANS[t] += 1
    print("\n".join( map(str, ANS[1:])))
if __name__ == '__main__':
    main()


Measured memory_bytes: 71132
i,a,t[27];
main(){
    char c[1201];
    for(i=0,scanf("%[^\r]",c);c[i]!='\0';i++,t[a]++){
        a=64<c[i]&&c[i]<91?c[i]-'A'
         :96<c[i]&&c[i]<123?c[i]-'a'
         :26;
    }
    for(i=0;i<26;printf("%c : %d\n",i+97,t[i]),i++);
}

Measured memory_bytes: 1764
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <bitset>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <boost/math/common_factor_rt.hpp>

#define ll long long
using namespace std;
ll l = 1000000007;
vector<int> a[1000] = {};
vector<int> b[1000] = {};
vector<int> ans[1000] = {};


int main()
{
	int A, B, K;
	cin >> A >> B >> K;

	a->push_back(1);
	b->push_back(1);



	int x = A;
	int y = B;

	for (int i = 2; i <= A; i++) {
		if(A%i == 0) { // 素数で割り切れなくなるまで割っていく
			a->push_back(i);
		}
	}

	for (int i = 2; i <= B; i++) {
		if (B%i == 0) { // 素数で割り切れなくなるまで割っていく
			b->push_back(i);
		}
	}
	
	if (a->size() >= b->size()) {
		for (int i = 0; i < a->size(); i++)
		{
			for (int j = 0; j < b->size(); j++)
			{
				if (a->at(i) == b->at(j)) {
					ans->push_back(a->at(i));
				}
			}
		}
	}
	else {
		for (int i = 0; i < b->size(); i++)
		{
			for (int j = 0; j < a->size(); j++)
			{
				if (b->at(i) == a->at(j)) {
					ans->push_back(b->at(i));
				}
			}
		}
	}
	
	int s = ans->size() - 1;
	sort(ans->begin(), ans->end(), greater<int>());

	cout << ans->at(K - 1) << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

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

		int N = scan.nextInt();

		String S = scan.next();
		int count = 0;

		for(int i=0;i<N-2;i++) {

			if(S.charAt(i)=='A' && S.charAt(i+1)=='B' && S.charAt(i+2)=='C') {

				count++;
			}

		}

		System.out.println(count);

		scan.close();

	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
using ll = long long;

int main(){
  int n;
  string s;
  cin>>n>>s;
  vector<set<int>>is(26);
  rep(i,s.size()){
    is[s[i]-'a'].insert(i);
  }
  int q;
  cin>>q;
  rep(i,q){
    int com;
    cin>>com;
    if(com==1){
      int x;
      char c;
      cin>>x>>c;
      x--;
      is[s[x]-'a'].erase(x);
      s[x]=c;
      is[c-'a'].insert(x);
    }
    else{
      int l,r;
      cin>>l>>r;
      l--;r--;
      int ans=0;
      rep(j,26){
        auto it=is[j].lower_bound(l);
        if(it!=is[j].end()&&*it<=r)ans++;
      }
      cout<<ans<<endl;
    }
  }
  return(0);
}

Measured memory_bytes: 24196
MODULE primeFactorizationMod
! 素因数分解のためのモジュール．
! O( sqrt(N) )
      implicit none
      integer, parameter, private :: p = 8
      
      contains
! 整数Nを受け取り，素因数分解の結果をfact,powに
! 昇順で割り付け配列として格納して返すサブルーチン．
! N>=2
      subroutine primeFactorization( n,fact,pow )
        implicit none
        integer(p),intent(in) :: n
        integer(p),allocatable,intent(out) :: fact(:), pow(:)
        integer(p),allocatable :: fBuffer(:), pBuffer(:)
        integer(p) :: nn, i, iEnd, cnt
        
        
        if( n<=1 )then
          fact = [0];pow = [0]
        end if
        
        iEnd = ceiling( sqrt(real(n)) )
        allocate( fBuffer(iEnd), pBuffer(iEnd), source=0_p )
        
        nn  = n
        cnt = 0
        do i = 2,iEnd
          if( mod(nn,i)/=0 ) cycle
          
          cnt = cnt + 1
          fBuffer(cnt) = i
          do while( .true. )
            nn = nn / i
            pBuffer(cnt) = pBuffer(cnt) + 1
            if( mod(nn,i)/=0 ) exit
          end do
        end do
        
        if( nn/=1 )then
          cnt = cnt + 1
          fBuffer(cnt) = nn
          pBuffer(cnt) = 1
        end if
        
        if( .not.allocated(fact) ) allocate( fact(cnt) )
        if( .not.allocated(pow ) ) allocate( pow(cnt ) )
        
        fact(1:cnt) = fBuffer(1:cnt)
        pow(1:cnt ) = pBuffer(1:cnt)
        
      end subroutine
      END MODULE primeFactorizationMod
      
! Procedure List
! primeFactorization( int(in)::n, int(out),alloc::fact,pow )
      
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


      PROGRAM piyo
      use primeFactorizationMod
      IMPLICIT NONE
      INTEGER,PARAMETER :: prec = 8
      integer(prec) :: n, ans=0
      integer(prec),allocatable :: fact(:),pow(:)
      integer(prec) :: lenF, i,e
      read*,n
      
      call primeFactorization( n,fact,pow )
      
      lenF = size( fact )
      
      do i = 1,lenF
        e = 1
        do while( .true. )
          
          if( pow(i)<e ) exit
          
          ans = ans + 1
          pow(i) = pow(i) - e
          e = e + 1
        end do
      end do
      
      print*,ans
      
   !   print*,fact
   !   print*,pow
      
      END PROGRAM

Measured memory_bytes: 17956
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    int dp[3001][3001],n,m;
    char ar[3001][3001];
    int x1,y11,x2,y2;

    inline bool chk(int x,int y,int z)
    {
        if(x<=0 || y<=0 || x>n || y>m || ar[x][y]=='#' || dp[x][y]<=z)
            return false;
        return true;
    }

    class comp
    {
    public:
        bool operator() (pair<int,pii>& i, pair<int,pii>& j)
        {
            return i.f>j.f;
        }
    };

    void bfs()
    {
        priority_queue<pair<int,pii>,vector<pair<int,pii>>,comp> pq;
        pq.push({0,{x1,y11}});
        dp[x1][y11]=0;
        pair<int,pii> x;
        while(!pq.empty())
        {
            x=pq.top();
            pq.pop();
            pii loc = x.s;
            int i=loc.f,j=loc.s;
            if(dp[loc.f][loc.s]!=x.f)
                continue;
            if(chk(i-1,j,x.f))
            {
                dp[i-1][j]=x.f;
                pq.push({x.f,{i-1,j}});
            }
            if(chk(i+1,j,x.f))
            {
                dp[i+1][j]=x.f;
                pq.push({x.f,{i+1,j}});
            }
            if(chk(i,j-1,x.f))
            {
                dp[i][j-1]=x.f;
                pq.push({x.f,{i,j-1}});
            }
            if(chk(i,j+1,x.f))
            {
                dp[i][j+1]=x.f;
                pq.push({x.f,{i,j+1}});
            }
            for(int l=i-2;l<=i+2;++l)
            {
                for(int k=j-2;k<=j+2;++k)
                {
                    if(chk(l,k,x.f+1))
                    {
                        dp[l][k]=x.f+1;
                        pq.push({x.f+1,{l,k}});
                    }
                }
            }
        }
    }

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int i,j;
            cin>>n>>m;
            cin>>x1>>y11>>x2>>y2;
            for(i=1;i<=n;++i)
            {
                for(j=1;j<=m;++j)
                {
                    cin>>ar[i][j];
                    dp[i][j]=1e9;
                }
            }
            bfs();
            if(dp[x2][y2]==1e9)
                dp[x2][y2]=-1;
            cout<<dp[x2][y2]<<endl;
        }
        return 0;
    }


Measured memory_bytes: 14440
import java.util.Scanner;
public class Main{
	public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
      int X=sc.nextInt();
      int A=sc.nextInt();
      
      if(X<A){
      System.out.println(0);
      }
      else{
      System.out.println(10);
      }
      
      
    }
}

Measured memory_bytes: 23636
import sys
input = sys.stdin.readline

mod = 10**9+7

N = int(input())
A = [int(input()) for _ in range(N)]
B = [int(input()) for _ in range(N)]

A.sort(reverse=True)
B.sort(reverse=True)

P = []
while A or B:
    if len(A) == 0:
        b = B.pop()
        P.append(0)
    elif len(B) == 0:
        a = A.pop()
        P.append(1)
    else:
        a = A.pop()
        b = B.pop()
        if a > b:
            P.append(0)
            A.append(a)
        else:
            P.append(1)
            B.append(b)

a = 0
b = 0
ans = 1
for p in P:
    if p == 0:
        if b > 0:
            ans = ans * b % mod
            b -= 1
        else:
            a += 1
    else:
        if a > 0:
            ans = ans * a % mod
            a -= 1
        else:
            b += 1
print(ans)



Measured memory_bytes: 12164
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
int main() {
	int n;
	double sum = 0;
	cin >> n;
	vector <double> l(n);
	vector<double> x(n);
	vector<double> y(n);
	rep(i, n)
		cin >> x[i] >> y[i];
	rep(i, n) {
		for (int j = i+1; j < n; j++) {
			l[i] = sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
			sum += l[i];
		}
	}
	double ans;
cout << fixed;
	cout <<sum*2/n  << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	char t,c;
	int abc[52],a,b,d;
	for(a=0;a<52;a++){
		abc[a]=0;
	}
	scanf("%d",&a);
	for(b=0;b<=a;b++){
		scanf("%c %d%c",&t,&d,&c);
		switch(t){
			case 'S':
				abc[d-1]=1;
				break;
			case 'H':
				abc[d+12]=1;
				break;
			case 'C':
				abc[d+25]=1;
				break;
			case 'D':
				abc[d+38]=1;
				break;
		}
	}
	for(a=0;a<52;a++){
		if(abc[a]!=1){
			switch(a/13){
				case 0:
					printf("S %d\n",a%13+1);
					break;
				case 1:
					printf("H %d\n",a%13+1);
					break;
				case 2:
					printf("C %d\n",a%13+1);
					break;
				case 3:
					printf("D %d\n",a%13+1);
					break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll K;
    cin >> K;

    deque<ll> que;
    que.push_back(1);

    ll INF = 1e18;
    vector<ll> d(K, INF);
    d[1] = 1;

    // 01BFS
    while (que.size() > 0) {
        auto p = que.front();
        if (p % K == 0) {
            break;
        }
        que.pop_front();

        ll c = d[p];
        if (c < d[(10 * p) % K]) {
            d[(10 * p) % K] = c;
            que.push_front((10 * p) % K);
        }
        c = d[p] + 1;
        if (c < d[(p + 1) % K]) {
            d[(p + 1) % K] = c;
            que.push_back((p + 1) % K);
        }
    }

    put(d[0]);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 4504
import math

def main():
    n,k = map(int,input().split())

    ans = 0.0

    for i in range(1,n+1):
        p = 1 / n
        while i < k:
            i *= 2
            p /= 2
        ans += p
    print("{:.10f}".format(ans))

if __name__ == "__main__":
    main()


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

int main() {
  string N;
  cin >> N;
  if (N.at(0)==N.at(2)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3600
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <set>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;

int n, k;
string str[10];

int main(){
	while(scanf("%d", &n),n){
		set<string> s;
		scanf("%d", &k);
		rep(i,n) cin >> str[i];
		if(k == 2){
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					if(i == j) continue;
					s.insert(str[i]+str[j]);
				}
			}
		} else if(k == 3){
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					if(j == i) continue;
					for(int u = 0; u < n; u++){
						if(u == i || u == j) continue;
						s.insert(str[i]+str[j]+str[u]);
					}
				}
			}
		} else{
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					if(i == j) continue;
					for(int u = 0; u < n; u++){
						if(u == i || u == j) continue;
						for(int v = 0; v < n; v++){
							if(v == i || v == j || v == u) continue;
							s.insert(str[i]+str[j]+str[u]+str[v]);
						}
					}
				}
			}
		}
		cout << s.size() << endl;
	}
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef unsigned long long ll;

int gcd(int a, int b) {
  if(a < b) return gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}


int main() {
  ll a, b;
  cin >> a >> b; 
  
  ll ans = 0;
  ans = a * b;
  int com_div = gcd(a,b);
  if ((ans % com_div) == 0) {
      ans /= com_div;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256