akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  // if encounter smol on x, decrease left x by 1 then set all right to 9. you have your answer.

  string s;
  cin >> s;

  if (s.size() == 1) {
    cout << s << endl;
  } else {
    bool all9 = true;

    for (int i = s.size()-1; i >= 1; --i) {
      if (s.at(i) != '9') {
        all9 = false;
	break;
      }
    }

    if (!all9) {
	    for (int i = 0; i < s.size(); ++i) {
	      char c = s.at(i);

	      if (c != '9') {
		if (i == 0) {
		  s.at(i) -= 1;
		  for (int j = i+1; j < s.size(); ++j) {
		    s.at(j) = '9';
		  }
		  break;
		} else {
		  s.at(i-1) -= 1;
		  for (int j = i; j < s.size(); ++j) {
		    s.at(j) = '9';
		  }
		  break;
		}
	      }
	    }

	    int sum = 0;
	    for (char c : s) {
	      sum += (c-'0');
	    }
	    cout << sum << endl;
    } else {
	    cout << s.at(0)-'0' + 9*(s.size()-1) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import numpy as np
import sys
sys.setrecursionlimit(500000)


N = int(input())
a = np.array([int(input()) for i in range(N)])


#回数i,インデックスn
def button(i,n):
    n_new = a[n-1]
    
    if i == N:
        if n != 2:
            print(-1)
            return
    if n_new == 2:
        print(i)
        return 
    else:
        return button(i+1,n_new)

button(1,1)

Measured memory_bytes: 112756
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    ll a, b, n;
    cin >> a >> b >> n;
    ll c = min(n, b-1);
    cout << c*a/b << endl;
    return 0;
}

Measured memory_bytes: 3624
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]
s=0
c=0
for i in range(n):
  for j in range(i+1,n):
    x1,y1=xy[i]
    x2,y2=xy[j]
    s+=((x1-x2)**2+(y1-y2)**2)**.5
    c+=1
print(s*(n-1)/c)

Measured memory_bytes: 3188
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter
    M = int(readline())
    C = Counter()

    for _ in range(M):
        d, c = map(int, readline().split())
        C[d] += c
    ans = 0
    ans += C[0]
    s = ""
    for i in range(1, 10):
        p = str(i) * 10 + "*"
        cnt = 0
        while len(p) > 2:
            p = str(int(p[0]) + int(p[1])) + p[2:]
            cnt += 1

        while C[i] >= 10:
            k = C[i] // 10
            C[i] = C[i] % 10 + k
            ans += k * cnt
        s += str(i) * C[i]

    s += "*"
    while len(s) > 2:
        s = str(int(s[0]) + int(s[1])) + s[2:]
        ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68472
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
using namespace std;

void solve(){
  int n; cin >> n;
  vector<vector<pair<int, int> > > v(n);
  for(int i = 0; i < n; i++){
    int u, k; cin >> u >> k;
    for(int j = 0; j < k; j++){
      int a, b; cin >> a >> b;
      v[u].push_back(make_pair(a, b));
    }
  }
  int d[n];
  bool c[n];
  for(int i = 0; i < n; i++){
    c[i] = 0;
    d[i] = 10000000;
  }
  priority_queue<pair<int, int > > pq;
  pq.push(make_pair(0, 0));
  d[0] = 0;
  while(pq.empty() == false){
    int x = pq.top().second;
    pq.pop();
    c[x] = 1;
    for(int i = 0; i < v[x].size(); i++){
      int y = v[x][i].first;
      if(c[y] == 0){
        if(d[y] > d[x] + v[x][i].second){
          d[y] = d[x] + v[x][i].second;
          pq.push(make_pair(d[y] * (-1), y));
        }
      }
    }
  }
  for(int i = 0; i < n; i++){
    cout << i << " " << d[i] << endl;
  }
  return;
}

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



Measured memory_bytes: 7784
using System;
using System.Linq;
class Program
{
static void Main(string[] argv)
{
  var v = Console.ReadLine().Split(' ');
  var t = int.Parse(v[0]);
  var n = int.Parse(v[1]);
  var r=(n-t)/(t-1)+1;
  while(((r-1)*(t-1)+t)<n) 
  {
    r++;
  }
    
  Console.WriteLine(
	r
  );
  v=null;
  return;
}
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n){
        cin >> h[i];
    }

    vector<int> dp(n+1, 1e9);
    dp[0] = 0;
    rep(i,n){
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i]-h[i+1]));
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i]-h[i+2]));
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
h,w=map(int,input().split())
s=[]
for i in range(h):
  t=input()
  if t.count('.')!=len(t):
    s.append(t)

l=[list(x) for x in zip(*s)]
t2=[]
for e in l:
  if e.count('.')!=len(e):
    t2.append(e)

ans=[list(x) for x in zip(*t2)]
for e in ans:
  print(''.join(e))

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    double acc = 1;
    for (int i = 0; i < n; i++) acc *= a[i];
    double div = 0;
    for (int i = 0; i < n; i++){
        double tmp = 1;
        for (int j = 0; j < n; j++){
            if (i != j) tmp *= a[j];
        }
        div += tmp;
    }
    cout << setprecision(15) << acc / div << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
#define pii pair < ll , ll >
#define vi vector < int >
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define init(x, a) memset(x, a, sizeof(x))
#define vll vector < long long int >
#define sll set < long long int >
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
/*int main()
{
    fastIO;
    ll a,b,n,i,j,k;
    cin>>a>>b;
    i = min(a,b);
    a -= i;
    b -= i;
    k = 16-2*i;
    if(a>k/2 or b>k/2)
    {
        cout<<":("<<endl;
        return(0);
    }
    cout<<"Yay!"<<endl;
    return(0);
}*/
int main()
{
    fastIO;
    ll n,m,i=0,init,prog,ans;
    cin>>n>>m;
    init = pow(100,n);
    prog = pow(100,n);
    while(i<m)
    {
        ans = init;
        if(init%(prog*100)==0){init+=prog;continue;}
        i++;init+=prog;
    }
    cout<<ans;
    return(0);
}
/*int main()
{
    fastIO;
    ll ans=0,n,i,j,k,l,m,temp,a[10001];
    cin>>n;
    fo(i,n)
    {
        cin>>a[i];
        j = 0;k = pow(2,32);
        temp = 0;
        while(j<=k)
        {
            l = j + (k-j)/2;
            m = pow(2,l);
            if(a[i]%m==0)
            {
                temp = max(temp,l);
                j = l+1;
            }
            else k = l-1;
        }
        ans += temp;
    }
    cout<<ans;
    return(0);
}*/
/*int main()
{
    fastIO;
    ll ans=0,n,m,i,j,k,l,b[1001],t[1001],p[1001];

    return(0);
}*/

Measured memory_bytes: 384
#include<iostream>                                                     
#include<cstdio>                                                       
#include<string>                                                       
#include<set>                                                          
using namespace std;                                                   
int main() {                                                           
  int n;                                                               
  string query, word;                                                  
  set<string> dict;                                                    
  cin >> n;                                                            
  while (n--) {                                                        
    cin >> query >> word;                                              
    if (query=="insert") {                                             
      dict.insert(word);                                               
    } else {                                                           
      if (dict.find(word)==dict.end()) {                               
        puts("no");                                                    
      } else {                                                         
        puts("yes");                                                   
      }                                                                
    }                                                                  
  }                                                                    
  return 0;                                                            
}                                                                      
                                                                       
                                                                       
                                                                       
                                                                       
         

Measured memory_bytes: 32564
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

#define MOD 1000000007

int main(){
  ll m, n;
  cin >> m >> n;
  int result = 1;
  while(n > 0){
    if(n & 1) result = result * m % MOD;
    m *= m;
    m %= MOD;
    n >>= 1;
  }
  cout << result << endl;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------



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

  int x,y,a,b,c; cin >> x >> y >> a >> b >> c;
  vector<ll> p(a),q(b),r(c);
  rep(i,a) cin >> p[i];
  rep(i,b) cin >> q[i];
  rep(i,c) cin >> r[i];

  sort(rall(p));
  sort(rall(q));
  sort(rall(r));

  vector<ll> R(x),G(y);

  rep(i,x) R[i] = p[i];
  rep(i,y) G[i] = q[i];


  sort(all(R));
  sort(all(G));

  int i = 0,j = 0,k = 0;
  while(k<c && ((i<x)||(j<y))){
    if(i<x && j<y){
      if(R[i]<=G[j]){
        if(r[k]>R[i]){
           R[i] = r[k];
           k++;
           i++;
         }else break;
      }else{
        if(r[k]>G[j]){
           G[j] = r[k];
           k++;
           j++;
         }else break;
      }
    }else if(i<x){
      if(r[k]>R[i]){
        R[i] = r[k];
        k++;
        i++;
      }else break;
    }else if(j<y){
      if(r[k]>G[j]){
         G[j] = r[k];
         k++;
         j++;
       }else break;
    }
  }

  ll ans = 0;
  rep(i,x) ans += R[i];
  rep(j,y) ans += G[j];
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3968
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            if (n < 1200) {
                out.println("ABC");
            } else if (n < 2800) {
                out.println("ARC");
            } else {
                out.println("AGC");
            }
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }
}



Measured memory_bytes: 20820
import java.math.*;
import java.util.*;
import java.io.*;

class Main {
	public static void main(String[] args) throws FileNotFoundException {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		System.out.println(N==M?"Yes":"No");
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


Measured memory_bytes: 23760
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	int h, w, n;
	cin >> h >> w >> n;
	int x = max(h, w);
	int ans = (n + x - 1) / x;
	cout << ans << endl;
	return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


int main() {
    int n, m; cin >> n >> m;
    V<int> s(m), c(m);
    for(int i = 0; i < m; i++) cin >> s[i] >> c[i];

    for(int i = 0; i < 1000; i++){
        string tmp = to_string(i);
        if((int)tmp.size() != n) continue;
        bool flag = true;
        for(int j = 0; j < m; j++){
            if(tmp[s[j] - 1] - '0' != c[j]){
                flag = false;
                break;
            }
        }
        if(flag){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 3696
# -*- coding:utf-8 -*-
N = int(input())
A_list = list(map(int,input().split()))

ans_list = []
temp_ans = 0

for value in A_list:
    temp_value = value
    temp_ans = 0
    while temp_value%2 == 0:
        temp_value /= 2
        temp_ans += 1

    ans_list.append(temp_ans)

print(min(ans_list))

Measured memory_bytes: 9176
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def dfs(p, v, num):
    global g, plus_list, ans
    tmp = num + plus_list[v]
    for x in g[v]:
        if x == p:
            continue
        dfs(v, x, tmp)
    ans[v] = tmp
    
def main():
    global g, plus_list, ans
    N, Q = map(int, input().split())
    g = [[] for i in range(N)] 
    for i in range(N-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        g[a].append(b)
        g[b].append(a)

    plus_list = [0] * N
    for i in range(Q):
        q, y = map(int, input().split())
        plus_list[q-1] += y

    ans = [0] * N
    
    dfs(-1, 0, 0)
    print(*ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 236912
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a[90],n;
  a[0]=2;
  a[1]=1;
  cin >> n;
  for(int i=2;i<=n;i++){
    a[i]=a[i-1]+a[i-2];
  }
  cout << a[n];
}


Measured memory_bytes: 256
N=int(input())
ans=[0]*10001

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            tmp=x**2+y**2+z**2
            tmp+=x*y+y*z+z*x
            if tmp<=N:
                ans[tmp]+=1
                
for i in range(1,N+1):
    print(ans[i])
    

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

using namespace std;

using int64 = long long;
const int mod = 998244353;

const int64 infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

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

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

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

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int64 H;
  cin >> H;
  int64 ret = 0;
  int64 sz = 1;
  while(H >= 1) {
    ret += sz;
    sz *= 2;
    H /= 2;
  }
  cout << ret << endl;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

void add(ll &a, ll b) {
	a += b;
	if (a >= MOD) {
		a -= MOD;
	}
}

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

	int n;
	cin >> n;

	vector<int> c(n);
	for (auto &v : c) {
		cin >> v;
	}

	vector<vector<int>> places(210000);
	for (int i = 0; i < n; i++) {
		places[c[i]].push_back(i);
	}

	vector<ll> dp(210000);
	dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		add(dp[i], dp[i - 1]);

		int color = c[i - 1];
		int it = lower_bound(places[color].begin(), places[color].end(), i - 1)
			- places[color].begin();

		if (it <= 0) {
			continue;
		}

		int j = places[color][it - 1];
		if ((i - 1) - j > 1) {
			add(dp[i], dp[j + 1]);
		}
	}

	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 13824
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int A, B;
  
 cin >> A >> B;
 
 if (A == 1 && B == 2) cout << 3 << endl;
 else if (A == 1 && B == 3) cout << 2 << endl;
 else if (A == 2 && B == 1) cout << 3 << endl;
 else if (A == 2 && B == 3) cout << 1 << endl;
 else if (A == 3 && B == 1) cout << 2 << endl;
 else if (A == 3 && B == 2) cout << 1 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
//cout << fixed << setprecision(8) << a << endl;
#define Fast_Input ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define pb push_back
#define mem(a, b)     memset(a, b, sizeof(a))
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*sort(v.begin(), v.end(),
     [](const pair<int, int>& x, const pair<int, int>& y)
{
    if (x.first != y.first)
        return x.first < y.first;
    return x.second < y.second;
});
*/
int const fx[]= {+1,+0,-1,+1};
int const fy[]= {-1,+1,+0,+0};
const int inf = numeric_limits<int>::max();
const int mx=1e9;
const ll mod=1e9+7;
ll pow(ll x,ll n)
{
    ll res=1;
    while(n)
    {
        if(n%2)
        {
            res=((res%mod)*(x%mod))%mod;
            n--;
        }
        x=((x%mod)*(x%mod))%mod;
        n/=2;
    }
    return res;
}
int main()
{
    ll n,i;
    cin >> n;
    ll one=pow(ll(10),n);
    ll zero=pow(ll(9),n);
    ll nine=zero;
    ll intersection=pow(ll(8),n);
    ll z=(zero+nine-intersection)%mod;
    ll ans=(one-z)%mod;
    if(ans<0)ans+=mod;
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

ll dp[305][90005];
ll p[305];

void init() {
  dp[0][0] = 1;
  p[0] = 1;
  FOR(i, 1, 305) p[i] = p[i - 1] * 2 % mod;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  init();

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

  rep(i, n) {
    repr(j, i) {
      repr(k, 300 * j) {
        dp[j + 1][k + a[i]] = (dp[j + 1][k + a[i]] + dp[j][k]) % mod;
      }
    }
  }
  ll v = accumulate(a.begin(), a.end(), 0LL), ans = 1;
  rep(i, n) ans = ans * 3 % mod;
  bool even = (v % 2 == 0);
  v = (v + 1) / 2;
  rep(i, n + 1) {
    FORR(j, 300 * i, v) {
      ans = (ans + mod * mod - dp[i][j] * p[n - i] * 3) % mod;
      if (even && j == v) ans = (ans + dp[i][j] * 3) % mod;
    }
  }
  cout << ans << '\n';
  


  




  
  return 0;
}

Measured memory_bytes: 110632
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

		int i = 1;
		int x = 0;

		// ??\???????????¨???
		int n = 0;

		n = sc.nextInt();
		sc.close();

		// if(x) goto CHECK_NUM????????????
		while (i <= n) {

			// System.out.printf("x: %d i; %d\n", x, i);
			x = i;

			if (x % 3 == 0) {
				System.out.printf(" %d", i);
				// END_CHECK_NUM??????????????????
				// ??¨????????¨?????????continue??????????????????i????????????????????????????????????????????????????????????
				i++;
				continue;
			}

			// if(x) goto INCLUDE3????????????
			while (x != 0) {
				if (x % 10 == 3) {
					System.out.printf(" %d", i);
					// END_CHECK_NUM??????????????????
					break;
				}
				x /= 10;
			}

			i++;
		}

		System.out.printf("\n");
	}
}

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

int main() {
  int r,g,b;
  cin >> r >> g >> b;
  int a=0;
  a = r*100 + g*10 + b;
  if(a%4==0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n, m, l;
		n = scan.nextInt();
		m = scan.nextInt();
		l = scan.nextInt();
		long[][] matA = new long[n][m];
		long[][] matB = new long[m][l];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				matA[i][j] = scan.nextInt();
			}
		}
		for (int j = 0; j < m; j++) {
			for (int k = 0; k < l; k++) {
				matB[j][k] = scan.nextInt();
			}
		}
		for (int i = 0; i < n; i++) {
			for (int k = 0; k < l; k++) {
				long c = 0;
				for (int j = 0; j < m; j++) {
					c += matA[i][j] * matB[j][k];
				}
				if (k != l - 1) {
					sb.append(c + " ");
				} else {
					sb.append(c + "\n");
				}
			}
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 52552
let () =
  let get_t x = x/3600 and
      get_h x = (x/60 mod 60) and
      get_s x = x mod 60 in
  let rec read () =
    let t,h,s = Scanf.scanf " %d %d %d\n" (fun x y z -> x,y,z)in
    if t = -1 && h = -1 && s = -1 then ()
    else
      begin
        let sec = t*3600 + h*60 + s in
        let rem1 = 120*60 - sec in
        let rem2 = rem1*3 in
        Printf.printf "%02d:%02d:%02d\n" (get_t rem1) (get_h rem1) (get_s rem1);
        Printf.printf "%02d:%02d:%02d\n" (get_t rem2) (get_h rem2) (get_s rem2);
        read ()
      end
  in read ()
;;

Measured memory_bytes: 2248
import java.util.Scanner;

public class Main {

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

		int n = in.nextInt();
		int x = in.nextInt();

		int ans = 0;
		int sum = 0;
		int[] l = new int[n];
		for ( int i = 0; i < n; i++ ) {
			l[i] = in.nextInt();
		}

		for ( int i = 0; i < n; i++ ) {
			sum += l[i];

			if ( sum == x ) {
				ans = i + 2;
				System.out.println(ans);
				return;
			} else if ( sum > x ) {
				ans = i + 1;
				System.out.println(ans);
				return;
			}
		}

		System.out.println(n + 1);
		in.close();
	}
}


Measured memory_bytes: 23764
function Main(input){
  input = input.split(' ');
  var K = input[0];
  var S = input[1];
  var count=0;
  for(var i=0;i<=K;i++){
    for(var j=0;j<=K;j++){
      if((S-(i+j)<=K)&&(S-(i+j)>=0)){
        count++;
      }
    }
  }
  console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11596
a[999],t,i,j,r;main(n){
	for(scanf("%d",&n);i<n;i++)scanf("%d",a+i);
	for(i=0;i<n;i++)for(j=0;j<n-i-1;j++)if(a[j]>a[j+1])t=a[j],a[j]=a[j+1],a[j+1]=t,r++;
	for(i=0;i<n;i++)printf(i<n-1?"%d ":"%d\n",a[i]);
	printf("%d\n",r);
	exit(0);
}

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

def comb(n,r, mod):
    res = 1
    fac = 1
    for i in range(r):
        res *= n-i
        res %= mod
        fac *= i+1
        fac %= mod
    return res * pow(fac, mod-2, mod) % mod

def main():
    ans = pow(2, n, MOD) - 1
    ans -= comb(n=n, r=a, mod=MOD)
    ans -= comb(n=n, r=b, mod=MOD)
    ans %= MOD
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n;i>0;i--)
#define rep1(i,s,n) for(int i=s;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c) 
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<string> svec;

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a,b)<<" "<<max(0,a+b-n)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{ 
  int a,b,c,i,buf;
  cin >> a >> b >> c;
  for(i=100;i>=0;i--){
    if(a%i==0 && b%i==0){
      c--;
      if(c==0){
        buf=i;
        break;
      }
    }
  }
  cout << buf << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <utility>
using namespace std;



int main()
{
    int H, W, N;
    cin >> H >> W >> N;


    // 黒になった点を含む正方形 9 つをチェックして答えを更新する
    vector<long long> ans(10);
    ans[0] = (long long) (H-3+1) * (W-3+1);
    map<pair<int,int>,bool> isBlack;
    for( int n = 0; n < N; ++n ){
        int a, b;
        cin >> a >> b;
        // 9 つの正方形を順にチェックして黒に塗られているものの個数 numBlack を求め、
        // --numPaintedBlack[numBlack], ++numPaintedBlack[numBlack+1] する
        for( int i = 0; i < 3; ++i ){  // (a+i, b+j) は正方形の右下の位置に対応
            for( int j = 0; j < 3; ++j ){
                int numBlack = 0;
                if( a-2+i <= 0 or a+i > H ) continue;  // 列方向のはみ出しチェック
                if( b-2+j <= 0 or b+j > W ) continue;  // 行方向のはみ出しチェック
                for( int k = a-2+i; k <= a+i; ++k ){
                    for( int l = b-2+j; l <= b+j; ++l ){
                        if( isBlack[make_pair(k,l)] ) ++numBlack;
                    }
                }
                --ans[numBlack];
                ++ans[numBlack+1];
            }
        }
        isBlack[make_pair(a,b)] = true;
    }

    for( int i = 0; i < 10; ++ i ) cout << ans[i] << endl;


    return 0;
}

Measured memory_bytes: 156672
/* kadai4_1
   nabe9393 */

#include<stdio.h>
#include<math.h>
 
int main(void){
  //各監視員が監視する範囲と監視員の数
  int range, watchman_num;
  //小数が関わってくる木の数と監視員の人数（少数）は倍精度
  double tree,watchman;
  scanf("%lf %d", &tree, &range);
  //一人当たり監視できる数で木の数をわる
  watchman = tree / (range * 2 + 1);
  //小数点切り上げ
  watchman_num = ceil(watchman);
  printf("%d\n",watchman_num);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e16;
typedef long long ll;

int main(){

  int N; cin >> N;

  vector < vector<int> > graph(N);
  for (int i = 0; i < N - 1; i++){
    int A, B; cin >> A >> B;
    A--; B--;
    graph[A].push_back(B);
    graph[B].push_back(A);
  }
  
  vector <int> C(N);
  for (int i = 0; i < N; i++) cin >> C[i];
  sort(C.begin(), C.end(), greater<int>());

  int cnt = 1;
  vector <int> D(N);
  D[0] = C[0];
  queue <int> que;
  for (int i = 0; i < graph[0].size(); i++){
    que.push(graph[0][i]);
  }
  
  while (!que.empty()){
    int now = que.front(); que.pop();
    if (D[now] == 0){
      D[now] = C[cnt];
      cnt++;
    }
    
    for (int i = 0; i < graph[now].size(); i++){
      if (D[graph[now][i]] == 0){
        que.push(graph[now][i]);
      }
    }
  }
  
  int M = 0;
  for (int i = 0; i < N; i++){
    int now = i;
    for (int j = 0; j < graph[now].size(); j++){
      int next = graph[now][j];

      if (now < next){
        M += min(D[now], D[next]);
      }
    }
  }
  
  cout << M << endl;

  for (int i = 0; i < N - 1; i++) cout << D[i] << " " ;
  cout << D[N - 1] << endl;
  

  return 0;
}


Measured memory_bytes: 1024
n = gets.to_i
as = gets.split.map(&:to_i)
bs = gets.split.map(&:to_i)

ans = 0

(0..n-1).each do |i|
  b1 = [as[i], bs[i]].min
  bs[i] -= b1
  as[i] -= b1
  b2 = [bs[i], as[i+1]].min
  as[i+1] -= b2
  ans += b1 + b2
end

puts ans

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

using namespace std;
using ll = long long;

vector<vector<int>> G;
vector<bool> seen;
vector<int> group_size;

int cnt;

void dfs(int v) {
	cnt++;
	seen[v] = true;
	for (int nv : G[v]) {
		if (seen[nv]) continue;
		dfs(nv);
	}
}

int main() {
	int N, M;
	cin >> N >> M;
	G.resize(N);
	seen.resize(N, false);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--; 
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	for (int i = 0; i < N; i++) {
		if (seen[i]) continue;
		cnt = 0;
		dfs(i);
		group_size.push_back(cnt);
	}
	sort(group_size.begin(), group_size.end());
	int s = group_size.size();
	int ans = 0;

	/*
	これはTLEするからボツ

	for (int i = 0; i < s - 1; i++) {
		int num = group_size[i];
		for (int j = i; j < s; j++) group_size[j] -= num;
		ans += num;
	}
	if (group_size[s - 1] != 0) ans += group_size[s - 1];
	*/

	int num = 0;
	for (int i = 0; i < s; i++) {
		if (group_size[i] > num) {
			ans += (group_size[i] - num);
			num = group_size[i];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 20308
#include <bits/stdc++.h>
 
using namespace std;
 
#define x first
#define y second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
 
const ll MOD = 1e9+7;
const ll INF = 1e9+5;
 
int main() {
	int a, b, c, d, n, m;
	string s, t, r;
	cin >> n >> m;
  int sum = 0;
	for (int i=0 ; i<m ; i++) {
      int x;
      cin >>x;
      sum += x;
    }
  	if (sum >= n) cout <<"Yes\n";
  	else cout <<"No\n";
	return 0;
}

Measured memory_bytes: 256
/**
 * Created by Wangzhe on 2020/1/12 19:56.
 * Description: 
 **/


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a, b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;

const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;

const ll maxn = 1e5 + 10, MOD = 1e9 + 7;

void init() {

}

void solve() {

}

int main() {
    init();
    solve();
    char a ;cin >>a;
    printf("%c", a == 'z' ? 'a' : a + 1);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace AOJ
{
	class Program
	{
		public static void Main(string[] args)
		{
			var arr = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).OrderByDescending(i => i).ToArray();
			Console.WriteLine("{0} {1} {2} {3} {4}", arr[0], arr[1], arr[2], arr[3], arr[4]);
		}
	}
}

Measured memory_bytes: 20764
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val n: Int = sc.nextLine.toInt

    def go(i: Int, prev: BigInt, post: BigInt): BigInt ={
      if (i == 0) prev
      else{
        go(i-1, post, prev+post)
      }
    }
    println(go(n, 2, 1))
  }
}


Measured memory_bytes: 25544
from scipy.sparse.csgraph import floyd_warshall as wf
from itertools import permutations
import sys
input = sys.stdin.readline

def main():
    N, M, R = map(int, input().split())
    r = list(map(int, input().split()))

    MAX = int(1e9)
    link = [[MAX if i != j else 0 for j in range(N)] for i in range(N)]

    for i in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        link[a][b] = c
        link[b][a] = c
    
    link = wf(link)

    ans = -1
    for t in permutations(r):
        tmp = 0
        for i in range(1, R):
            tmp += link[t[i-1]-1][t[i]-1]
        if ans == -1:
            ans = tmp
        else:
            ans = min(ans, tmp)
    print(int(ans))

if __name__ == "__main__":
    main()

Measured memory_bytes: 18916
n = gets.to_i
a = gets.split.map(&:to_i)

p = 0
r = n-1

x = a[r]
i = p - 1

for j in p .. r - 1
    if a[j] <= x then
        i += 1
        k = a[i]
        a[i] = a[j]
        a[j] = k
    end
end
k = a[i + 1]
a[i + 1] = a[r]
a[r] = k

for k in 0..a.length-1
    if k == i+1 then
        printf("[%d]", a[k])
    else
        printf("%d", a[k])
    end
    if k != a.length-1 then
        printf(" ")
    end
end
printf("\n")


Measured memory_bytes: 13484
#define min(a,b) ((a)<(b)?(a):(b))
main2(){
  int m[99][99],x,y,i,j,n,a,b,c,d;
  memset(m,0,sizeof(m));
  m[0][0]=1;

  scanf("%d%d%d",&x,&y,&n);
  for(;n;n--){
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a==c)m[2*a][2*min(b,d)+1]=1;
    else m[2*min(a,c)+1][2*b]=1;
  }

  for(i=0;i<=2*x;i+=2)
    for(j=0;j<=2*y;j+=2){
      if(i>0&&!m[i-1][j])m[i][j]+=m[i-2][j];
      if(j>0&&!m[i][j-1])m[i][j]+=m[i][j-2];
    }

  printf(m[2*x][2*y]?"%d\n":"Miserable Hokusai!\n",m[2*x][2*y]);
  return 0;
}
main(n){for(scanf("%d",&n);n--;)main2();exit(0);}

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

using namespace std;

int n;
string s[55];
int cnt[55][26];
int acnt[26];

int main(void)
{
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> s[i];
	}
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < s[i].size(); j++){
			cnt[i][s[i][j] - 'a']++;
		}
	}
	
	for(int i = 0; i < 26; i++) acnt[i] = 100000000;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 26; j++){
			acnt[j] = min(acnt[j], cnt[i][j]);
		}
	}
	
	string ans;
	for(int i = 0; i < 26; i++){
		for(int j = 0; j < acnt[i]; j++) ans += (char)('a' + i);
	}
	
	cout << ans << endl;
	return 0;
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> b = new ArrayList<>();
		int[] a = new int[n];
		a[0] = 1;
		boolean able = true;
		for(int i = 0; i < n; i++) {
			b.add(sc.nextInt());
			if(b.get(i) > i + 1) able = false;
		}
		if(!able) System.out.println(-1);
		else {
			for(int i = n-1; i >= 0; i--) {
				for(int j = b.size()-1; j >= 0; j--) {
					if(b.get(j) == j + 1) {
						a[i] = b.get(j);
						b.remove(j);
						break;
					}
				}
			}
			for(int i = 0; i < n; i++)
				System.out.println(a[i]);
		}
	}

}

Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] L = new int[M];
		int[] R = new int[M];
		int Lmax = 1;
		int Rmin = N;
		for(int i=0;i<M;i++) {
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
			Lmax = Math.max(Lmax,L[i]);
			Rmin = Math.min(Rmin, R[i]);
		}
		
		int count = 0;
		for(int i=1;i<=N;i++) {
			if(i>=Lmax && i<=Rmin) {
				count++;
			}
		}
		
		System.out.println(count);
		sc.close();		
	}

}

Measured memory_bytes: 65368
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	bool ok = 1;
	int H,W,N,x,y;
	string A,B;
	cin >> H >> W >> N;
	cin >> x >> y;
	cin >> A;
	cin >> B;
	x--;y--;
	//まずは横方向に出す事を考える
	//left,right
	int left = 0,right = W; //[left,r-1]の範囲にyが存在すると横方向生存
	for(int i=N-1;i>=0;i--){
		if(B[i]=='L')right = min(right+1,W);
		else if(B[i]=='R') left = max(0,left-1);
		
		if(A[i]=='L')left = left + 1;
		else if(A[i]=='R') right = right - 1;
		
		if(left>=right)ok = 0;
	}
	if(y<left || y>=right)ok = 0;
	//up,down
	left = 0,right = H;
	for(int i=N-1;i>=0;i--){
		if(B[i]=='U')right = min(right+1,H);
		else if(B[i]=='D')left = max(left-1,0);
		if(A[i]=='U')left++;
		else if(A[i]=='D')right--;
		if(left>=right)ok = 0;
	}
	if(x<left || x>=right)ok = 0;
	if(ok)cout << "YES" << endl;
	else cout << "NO" << endl;
	
}

Measured memory_bytes: 920
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 1e6 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll arr[N], a[N];
ll pre[N];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n;
  ll m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    arr[i] /= 2;
  }
  ll ans = arr[0];
  for (int i = 1; i < n; i++)
      ans = (((arr[i] * ans)) / (__gcd(arr[i], ans)));
//  cerr << ans << endl;
  if(ans > m) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    if((ans / arr[i]) % 2 == 0) {
      cout << 0;
      return 0;
    }
  }
  m = m - ans;
  m /= (ans + ans);
  ++m;
  cout << m;
  return 0;
}


Measured memory_bytes: 4352
N, K = map(int, input().split())

n = (N-1)*(N-2) // 2 - K

if n < 0:
  print(-1)
else:
  M = N-1 + n
  print(M)
  for i in range(2, N+1):
    print(1, i)
  
  if n > 0:
    count = 0
    for i in range(2, N+1):
      for j in range(i+1, N+1):
        print(i, j)
        count += 1
        if count == n:
          break

      if count == n:
        break

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main(void){
    int n, nmax=-10000000, nmin=10000000;
    cin>> n;
    long long int nsum=0;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        nmax=max(nmax,x);
        nmin=min(nmin,x);
        nsum+=x;
    }
    cout<< nmin << " " << nmax << " " << nsum <<endl;
    
}



Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

ll mod = 1000000007;
ll modsize = 100010;

ll modinv(ll a) {
	ll b = mod, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}

ll modpow(ll a, ll b) {
	ll ans = 1;
	a %= mod;
	while (b) {
		if (b & 1) ans = ans * a%mod;
		a = a * a%mod;
		b >>= 1;
	}
	return ans;
}

vector<ll> fac(modsize + 5);
vector<ll> inv(modsize + 5);
vector<ll> facinv(modsize + 5);

void modcalc() {
	fac[0] = fac[1] = 1; inv[1] = 1;
	facinv[0] = facinv[1] = 1;
	for (int i = 2; i < modsize; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		facinv[i] = facinv[i - 1] * inv[i] % mod;
	}
}

ll modcomb(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[k] % mod * facinv[n - k] % mod;
}

ll modperm(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[n - k] % mod;
}

ll modhom(ll n, ll k) {
	if (n < 0 || k < 0) return 0;
	if (n == 0 && k == 0) return 1;
	return modcomb(n + k - 1, k);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	modcalc();

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int bs = 0;
	for (int i = 1; i <= n; i++) {
		bs += inv[i];
		if (bs > mod) bs -= mod;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		a[i] *= bs; a[i] %= mod;
		ans += a[i];
		if (ans > mod) ans -= mod;
		bs += inv[i + 2];
		bs -= inv[n - i];
		if (bs < 0) bs += mod;
		if (bs > mod) bs -= mod;
	}
	for (int i = 1; i <= n; i++) {
		ans *= i; ans %= mod;
	}
	cout << ans << endl;
}

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

#pragma GCC diagnostic warning "-Wconversion"

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) begin(a), end(a)
#define has(a, b) (a.find(b) != a.end())
#define fora(i, n) for(int i = 0; i < n; i++)
#define forb(i, n) for(int i = 1; i <= n; i++)
#define forc(a, b) for(const auto &a : b)
#define ford(i, n) for(int i = n; i >= 0; i--)
#define maxval(t) numeric_limits<t>::max()
#define minval(t) numeric_limits<t>::min()
#define imin(a, b) a = min(a, b)
#define imax(a, b) a = max(a, b)

#define dbgs(x) #x << " = " << x
#define dbgs2(x, y) dbgs(x) << ", " << dbgs(y)
#define dbgs3(x, y, z) dbgs2(x, y) << ", " << dbgs(z)
#define dbgs4(w, x, y, z) dbgs3(w, x, y) << ", " << dbgs(z)

using ll = long long;

vector<int> succ[100007];
int col[100007];
int parent[100007];
int n;

int dfs1(int c)
{
        if (c == n - 1)
                return 0;

        forc(next, succ[c])
        {
                if (next == parent[c])
                        continue;

                parent[next] = c;
                int val = dfs1(next);
                if (val != -1)
                        return val + 1;
        }
        return -1;
}
int dfs2(int c, int from, int no)
{
        if (col[c] == no)
                return 0;

        int res = 1;
        forc(next, succ[c])
        {
                if (next == from)
                        continue;
                res += dfs2(next, c, no);
        }
        return res;
}

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

        cin >> n;

        fora(i, n - 1)
        {
                int a, b;
                cin >> a >> b;

                --a; --b;

                succ[a].pb(b);
                succ[b].pb(a);
        }

        int dep = dfs1(0);
        int tod = (dep + 1) / 2;
        int cur = n - 1;

        while (cur != 0)
        {
                col[cur] = (tod > 0) ? 2 : 1;
                --tod;
                cur = parent[cur];
        }
        col[0] = 1;
        int fe = dfs2(0, -1, 2);
        int sn = dfs2(n - 1, -1, 1);

        cout << ((fe > sn) ? "Fennec" : "Snuke") << endl;
}


Measured memory_bytes: 11264
using System;
using System.Linq;

class B
{
	static void Main()
	{
		var s = Console.ReadLine();
		var h = s.Length / 2;
		Console.WriteLine(string.Join("", s.Reverse()) == s && s.Substring(0, h) == s.Substring(s.Length - h) ? "Yes" : "No");
	}
}


Measured memory_bytes: 26612
#!/usr/bin/env python3
import sys
INF = float("inf")


def f(n):
    ans = 1
    while True:
        if n < 2:
            break
        ans *= n
        n -= 2
    return ans


def solve(N: int):
    if N % 2 == 1:
        print(0)
        return

    # a = f(15)
    # print(a)
    # print("個数: ", str(a).count("0"))

    # a = f(150)
    # print(a)
    # print("個数: ", str(a).count("0"))

    # a = f(150)
    # print(a)
    # print("個数: ", str(a).count("0"))
    # ans = 0
    # n = N
    # while True:
    #     n //= 10
    #     ans += n
    #     if n < 10:
    #         break
    # print(ans)

    tot = 0
    base = 5
    while base <= N:
        tot += (N//base)//2
        base *= 5
    print(tot)

    # tot2 = 0
    # base = 10
    # while base <= N:
    #     tot2 += N//base
    #     base *= 10
    # print(tot-tot2)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import scala.util.control.Breaks

object Main extends App {
  val n =  scala.io.StdIn.readInt()
  var result = "No"
  val b = new Breaks
  b.breakable {
    (1 to 9).foreach { i =>
      if (n % i == 0) {
        val i2 = n / i
        if(i2 < 10) {
          result = "Yes"
          b.break
        }
      }
    }
  }
  println(result)
}

Measured memory_bytes: 27324