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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = atan(1.0) * 4.0;
// const int MOD = 998244353;
const ll LINF = 9e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

signed main() {
    LCIN(A, B);
    cout << max({A + B, A * B, A - B}) << "\n";
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    fscanf(stdin, "%d", &v[n - 1 - i]);
  }
  for (int i = 0; i < n; ++i) {
    fprintf(stdout, "%d", v[i]);
    if (i != n - 1) { fprintf(stdout, " "); }
  }
  fprintf(stdout, "\n");
  return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    for (ll r = 1; r * r <= N; r++) {
        ll m = (N - r) / r;
        if ((N - r) % r == 0 && m > r) ans += m;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
S=input()
T=input()
if (not S.isalpha()) or (not T.isalpha()):
    print('No')
elif len(S)>10:
    print('No')
elif len(S)+1!=len(T):
    print('No')
elif T[:len(S)]!=S:
    print('No')
else:
    print('Yes')

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

int main() {
    long long const mod = 1e9+7;
    int n, k, rn = 1;
    vector<int> v, op;
    vector< vector<long long> > dp;
    cin >> n >> k;
    while(rn*rn <= n){
        v.push_back(rn);
        rn++;
    }
    if(rn-1 != n/(rn-1))v.push_back(n/(rn-1));
    for(int i=rn-3;i>=0;i--){
        v.push_back(n/v[i]);
    }
    int vs = v.size();
    op.assign(vs, 0);
    for(int i=0;i<vs;i++){
        op[i] = vs-1-i;
    }
    dp.assign(2, vector<long long>(vs));

    for(int i=0;i<vs;i++){
        dp[0][i] = v[i];
    }
    for(int i=1;i<k;i++){
        int ni = i%2;
        int bi = 1-i%2;
        dp[ni][0] = dp[bi][vs-1];
        for(int j=1;j<vs;j++){
            long long res = dp[bi][op[j]];
            res *= (v[j] - v[j-1]);
            res += dp[ni][j-1];
            dp[ni][j] = res % mod;
        }
    }
    cout << dp[(k+1)%2][vs-1] << endl;
	return 0;
}


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

long long a, b, c, d;

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

bool solve() {
  if (a < b) return false;
  if (d < b) return false;
  if (c >= b-1) return true;

  long long g = GCD(b, d);

  // g で割って a%g あまる数で、c より大きく b 未満な整数があるかどうか
  // g で割って a%g あまる数で、b 未満の最大の数
  long long Max = (b - a%g + g-1)/g*g + a%g - g; // b が g の倍数であることを考慮して、Max = b + a%g - g でも OK
  if (Max > c) return false;
  else return true;
}

int main() {
  int T; cin >> T;
  for (int CASE = 0; CASE < T; ++CASE) {
	cin >> a >> b >> c >> d;
	if (solve()) cout << "Yes" << endl;
	else cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#ifndef _TEMPLATE_ROOT
#define _TEMPLATE_ROOT
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define repl(i, a, b) for(ll i = a; i < (b); ++i)
#define repd(i, a, b) for(int i = a; i >= (b); --i)
#define repdl(i, a, b) for(ll i = a; i >= (b); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
#endif
#ifndef _TEMPLATE_IO
#define _TEMPLATE_IO

template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void writef(T ...tail) { write(tail...); cout << flush; }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  if (v.size()) {
    rep(i, 0, sz(v) - 1)
      out << v[i] << " ";
    out << v.back();
  }
  return out;
}
#endif
using namespace std;

ll dp[3005][3005][4];
ll item[3005][3005];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  rep(i, 0, 3005) rep(j, 0, 3005) rep(k, 0, 4) dp[i][j][k] = -0x3f3f3f3f3f3f3f3fll;
  dp[0][0][0] = 0;

  int n, m, k; read(n, m, k);
  rep(i, 0, k) {
    int r, c, v; read(r, c, v);
    --r, --c;
    item[r][c] = v;
  }

  rep(i, 0, n) {
    rep(j, 0, m) {
      rep(k, 0, 4) {
        chmax(dp[i + 1][j][0], dp[i][j][k]);
        chmax(dp[i][j + 1][k], dp[i][j][k]);
        // pick up object
        if (k != 3) {
          chmax(dp[i + 1][j][0], dp[i][j][k] + item[i][j]);
          chmax(dp[i][j + 1][k + 1], dp[i][j][k] + item[i][j]);
        }
      }
    }
  }

  ll ans = 0;
  chmax(ans, dp[n][m - 1][0]);
  write(ans);
}



Measured memory_bytes: 356136
#include <bits/stdc++.h>
using namespace std;
//useful library
int long long gcd(int long long a, int long long b){
    return b?gcd(b,a%b):a;
} //最大公約数
int long long lcm(int long long a, int long long b){
    return a/gcd(a,b)*b;
} //最小公倍数
int long long GetDigit(int long long num){
    int long long digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
} //桁数
int long long GetDigitN(int long long num, int long long N){
    int long long digit=0;
    while(num!=0){
        num /= N;
        digit++;
    }
    return digit;
} //十進数でnumの際のN進数における桁数

int main(){
    int A, B;
    cin >> A >> B;
    cout << A * B <<endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	VgetIII(a,b,t);
	printf("%d\n",t/a*b);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

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

const int INF = 1<<30;

int main(){
  int n;cin>>n;
  vector<int> p(n), q(n), perm(n);
  rep(i, n)cin>>p[i];
  rep(i, n)cin>>q[i];
  rep(i, n)perm[i]=i+1;
  int a, b, c=0;
  do{
    c++;
    if(p==perm)a=c;
    if(q==perm)b=c;
  }while(next_permutation(perm.begin(), perm.end()));
  cout<<abs(a-b)<<endl;
  return 0;
}


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

using namespace std;
using ll = long long;


int main(){
    string s, t;
    cin >> s >> t;

    cout << t << s << endl;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 100000;
int n, x;
int ans[2 * MAX_N - 1];

int main() {
    fastio();

    cin >> n >> x;

    if (x == 1 || x == 2 * n - 1) {
        cout << "No\n";
        return 0;
    }

    set<int> s;
    for (int i = 2; i <= 2 * n - 2; i++) {
        if (i != x)
            s.insert(i);
    }

    ans[n - 2] = 1;
    ans[n - 1] = x;
    ans[n] = 2 * n - 1;

    if (n > 2) {
        if (x == 2 * n - 2) {
            ans[n + 1] = 2;
            s.erase(2);
        } else {
            ans[n - 3] = 2 * n - 2;
            s.erase(2 * n - 2);
        }
    }

    forn(i, 2 * n - 1) {
        if (ans[i] > 0) continue;
        auto it = s.begin();
        ans[i] = *it;
        s.erase(it);
    }

    cout << "Yes\n";
    forn(i, 2 * n - 1) {
        cout << ans[i] << '\n';
    }

    return 0;
}

Measured memory_bytes: 11648
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 101010101000;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
Graph g(101010);
vector<int> dist(101010);

int bfs(int s){
  if(dist[s]>0) return dist[s];
  int ans=0;
  for(auto x : g[s]){
    ans = max(ans, bfs(x)+1);
  }
  return dist[s]=ans;
}

int main(){
  int n, m;
  cin >> n >> m;
  rep(i,m){
    int x,y;
    cin >> x >> y;
    x--;y--;
    g[x].push_back(y);
  }
  int ans=0;
  rep(i,n){
    bfs(i);
  }
  rep(i,n){
    if(ans<dist[i]) ans = dist[i];
  }
  cout << ans;
}

Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;

#define LL long long
#define FOR(i,l,r) for(int i = l; i <= r; ++i)
#define REP(i,l,r) for(int i = l; i < r; ++i)

const int maxN = 1e5 + 123;

int N;
int A[2345];
LL D[2345];
string s;

int count(int x){
    int l = 1,r = N;
    while(l + 1 < r){
        int mid = (l + r)/2;
        if(A[mid] <= x) l = mid;
        else r = mid - 1;
    }
    for(int i = r; i >= l; --i) if(A[i] <= x) return i;
    return 0;
}

void bruteforce(){
    int rr = 0;
    FOR(i,1,N)
    FOR(j,i + 1,N)
    FOR(k,j + 1,N){
        bool c1 = A[i] + A[j] > A[k];
        bool c2 = A[j] + A[k] > A[i];
        bool c3 = A[i] + A[k] > A[j];
        if(c1 && c2 && c3){
            ++rr;
            //cout << A[i] << " & " << A[j] << " & " << A[k] << endl;
        }
    }
    cout << rr << endl;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    //
    //freopen("D.INP","r",stdin);
    //freopen("D.OUT","w",stdout);

    cin >> N;
    FOR(i,1,N){
        cin >> A[i];
        D[A[i]] += 1;
    }

    sort(A + 1,A + 1 + N);
    //bruteforce();

    LL res = 0;
    FOR(i,1,1000) if(D[i] > 2){
        LL x = D[i];
        res += (x * (x - 1) * (x - 2))/6;
        //cout << i << " =>>> c3 = " << (x * (x - 1) * (x - 2))/6 << endl;
    }

    FOR(i,1,1000)
        if(D[i] > 1){
            int x = D[i];
            LL z = (x * (x - 1))/2;
            //
            LL r = count(2 * i - 1);
            r -= x;

            //cout << "ok c2 " << i << " => " << D[i] << " : " << z << " & " << r << endl;
            //
            res += z * r;
        }
    
    //
    FOR(j,2,N) FOR(k,j + 1,N)
        if(A[j] < A[k]){
            //
            res += max(0,count(A[j] - 1) - count(A[k] - A[j]));
            //cout << A[j] << " & " << A[k] << " =>>>> " << max(0,count(A[j] - 1) - count(A[k] - A[j])) << endl;
        }

    cout << res;

    return 0;

}

Measured memory_bytes: 256
#coding: utf-8

def checkStr():
    sA = s1
    for i in range(len(s1)):
        sA = sA[len(s1) - 1:len(s1)] + sA[0:len(s1) - 1]
        if sA == s2:
            return True
    return False

s1 = input()
s2 = input()
if checkStr():
    print ("Yes")
else:
    print ("No")


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const int MAXS = 114514;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    int n,m;
    cin>>n>>m;
    int s[11][11];
    for(int i=0;i<11;i++){
        for(int j=0;j<11;j++){
            s[i][j]=0;
        }
    }
    for(int i=0;i<m;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++)cin>>s[i][j];
    }
    int p[11];
    for(int i=0;i<m;i++)cin>>p[i];
    int res = 0;
    for(int i=0;i<(1<<n);i++){//スイッチの状態を全探索
        int tmp = 0;
        for(int k=0;k<m;k++){//各電球について調べる
            int on = 0;
            int m = i;
            for(auto sw : s[k]){
                if((m>>sw-1)&1){
                    on++;
                }
            }
            if(on%2==p[k])tmp++;
        }
        if(tmp==m)res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    #参考：https://qiita.com/Kiri8128/items/a011c90d25911bdb3ed3
    #というかマルパクリ...
    
    N,M=MI()
    adj=[[]for _ in range(N)]
    for i in range(N-1):
        x,y=MI()
        x-=1
        y-=1
        adj[x].append(y)
        adj[y].append(x)
        
    import queue
    
    P=[-1]*N#親リスト
    Q=queue.Queue()#BFSに使う
    R=[]#BFSでトポソしたものを入れる
    
    Q.put(0)#0を根とする
    
    #トポソ########################
    while not Q.empty():
        v=Q.get()
        R.append(v)
        for nv in adj[v]:
            if nv!=P[v]:
                P[nv]=v
                adj[nv].remove(v)#親につながるを消しておく
                Q.put(nv)
                
    #setting#############
    
    #merge関数の単位元
    unit=1
    #子頂点を根とした木の結果をマージのための関数
    merge=lambda a,b: (a*b)%M
    
    
    #マージ後の調整用(bottom-up時)，今回，木の中の要素が全部白というパターンがあるので+1
    adj_bu=lambda a,v:a+1
    #マージ後の調整用(top-down時)
    adj_td=lambda a,v,p:a+1
    #マージ後の調整用(最終結果を求める時)，今回，全部白はダメなので，aをそのまま返す
    adj_fin=lambda a,i:a
    
    #今回の問題では，調整においてvやpは不要だが，必要な時もあるため，残している．
    
    #Bottom-up#############
    #merge関数を使ってMEを更新し，adjで調整してdpを埋める
    #MEは親ノード以外の値を集約したようなもの
    
    ME=[unit]*N
    dp=[0]*N
    
    
    for v in R[1:][::-1]:#根以外を後ろから
        dp[v]=adj_bu(ME[v],v)#BU時の調整
        p=P[v]
        ME[p]=merge(ME[p],dp[v])#親に，子の情報を伝えている．ME[p]の初期値はunit
        #print(v,p,dp[v],ME[p])
        
    #最後だけ個別に考える
    dp[R[0]]=adj_fin(ME[R[0]],R[0])
    
    #print(ME)
    #print(dp)
    
    #Top-down##########
    #TDは最終的に，Top-down時のdpを入れるが，途中においては左右累積和の左から累積させたものを入れておく
    #メモリの省略のため
    
    TD=[unit]*N
    
    for v in R:
        #左からDP（結果をTDに入れておく）
        ac=TD[v]
        for nv in adj[v]:
            TD[nv]=ac
            ac=merge(ac,dp[nv])
            
        #右からDP(結果をacに入れて行きながら進めていく)
        ac=unit
        for nv in adj[v][::-1]:
            TD[nv]=adj_td(merge(TD[nv],ac),nv,v)##TDときの調整
            ac=merge(ac,dp[nv])
            dp[nv]=adj_fin(merge(ME[nv],TD[nv]),nv)#最終調整
        
        
    for i in range(N):
        print(dp[i])
        
    
    
        

main()


Measured memory_bytes: 95388
#include<bits/stdc++.h>
using namespace std;
long long mod=1e9+7;
long long fac[500005],rev[500005];
long long h,w,a,b,ans=0;
long long power(long long x,long long y,long long mod){
	if(y==0){
		return 1;
	}else{
		long long dm=power(x,y/2,mod);
		if(y%2==1){
			return ((dm*dm)%mod*x)%mod;
		}else{
			return (dm*dm)%mod;
		}
	}
}
long long inverse_mod(long long a,long long mod){
	return power(a,mod-2,mod);
}
long long C(int k,int n){
	return ((fac[n]*rev[k]%mod)*rev[n-k])%mod;
}
long long path(long ax,long ay,long bx,long by){
	if(ax>bx||ay>by){
		return 0;
	}
	long long m=bx-ax+1;
	long long n=by-ay+1;
	return C(m-1,m+n-2);
}
int main(){
	cin>>h>>w>>a>>b;
	fac[0]=1;
	rev[0]=inverse_mod(fac[0],mod);
	for(int i=1;i<=h+w;i++){
		fac[i]=(fac[i-1]*i)%mod;
		rev[i]=inverse_mod(fac[i],mod)%mod;
	}
	ans=path(1,1,h,w);
	for(int i=1;i<=b;i++){
		long long tmp=(path(1,1,h-a,i)%mod*path(h-a+1,i,h,w)%mod)%mod;
		ans=(ans-tmp+mod*mod)%mod;
	}
	cout<<ans;
}

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

int main() {
	cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int ans = 0;
	for(int i = 0, j = 1; i < N; ++i){
		int a;
		cin >> a;
		if(a==j)++j;
		else ++ans;
	}
	if(ans==N)ans = -1;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=2010;
inline bool ask(int a,int b){
	printf("? %d %d\n",a,b);
	fflush(stdout);
	char c;
	while(!isalpha(c=getchar()));
	return c=='Y';
}
int stk[N],ss=0;
char s[N];
int main(){
	int n;
	{
		int a=ni,b=ni;
		if(a<=b){
			puts("Impossible");
			return 0;
		}
		n=a+b;
	}
	for(int i=0;i<n;i++){
		if(ss==0||ask(stk[ss-1],i)){
			stk[ss++]=i;
		}else if(ss){
			ss--;
		}
	}
	int t=stk[ss-1];
	for(int i=0;i<n;i++){
		s[i]=i==t||ask(t,i)?'1':'0';
	}
	s[n]=0;
	printf("! %s\n",s);
	return 0;
}

Measured memory_bytes: 724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int a, b, c, d, e, f;

int main(){
	while (cin >> a >> b >> c >> d >> e >> f){
		if (a + b * 5 + c * 10 + d * 50 + e * 100 + f * 500 >= 1000){
			cout << 1 << endl;
		}
		else cout << 0 << endl;
	}
}

Measured memory_bytes: 1164
program main
   implicit none
   integer n,a,b
   integer dat(3)
   integer,allocatable,dimension(:)::p
   integer i
   read(*,*)n
   read(*,*)a,b
   allocate(p(n))
   read(*,*)p
   dat=0
   do i=1,n
      if(p(i)<=a)dat(1)=dat(1)+1
            if(p(i)>a .and. p(i)<=b)dat(2)=dat(2)+1
                  if(p(i)>b)dat(3)=dat(3)+1
   enddo
   write(*,*)minval(dat)
end program main


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}
const int NM = 1e5+10;

ll dp[NM][3]; // a,b,c,
int a[NM][3];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    rep(i, n){
        rep(j, 3){
            cin>>a[i][j];
        }
    }

    // 0日目は0
    rep(i,n){
        rep(j, 3){
            rep(k, 3){
                if(j==k) continue;
                chmax(dp[i+1][k], dp[i][j]+a[i][k]);
            }
        }
    }
    ll ans = 0;
    rep(i, 3) chmax(ans, dp[n][i]);
    cout<<ans<< endl;
}
// dp_c

Measured memory_bytes: 3840
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll n,m;
    cin >> n >> m;
    for (ll i=m/n;i>=1;i--){
        if (m%i==0 and m/i>=n){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

// 入力
int N;
vector<long long> h(100010, INF);
// DP テーブル
vector<long long> dp(100010, INF);

int main() {
    int N, K;
    cin >> N ;
    for (int i = 0; i < N; i++)
	cin >> h[i];

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N; i++) {
        chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }

    // 答え
    cout << dp[N-1] << endl;
}


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

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    static int dx[]={-1,0,1,0};
    static int dy[]={0,-1,0,1};
    static long pl,mi;

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt();
        int m=sc.nextInt();
        int a[]=sc.nextIntArray(n);
        int b[]=sc.nextIntArray(m);

        sort(a);
        sort(b);
//        db(a);
//        db(b);
        long r=0,c=0,ans=1;
        int ir=n-1,ic=m-1;
        
        for (int i = n*m,u=0; 0 < i; i--,u++) {
        	int x=0,y=0;
			while(0<=ir && i<=a[ir]) {
				if(a[ir]==i) {x++;}
				r++;
				ir--;
			}
			while(0<=ic && i<=b[ic]) {
				if(b[ic]==i) {y++;}
				c++;
				ic--;
			}
			if(x>1 || y>1) {ans=0;break;}
			if(x==0 && y==1) {ans*=r; ans%=mod;  }
			else if(x==1 && y==0) {ans*=c;  ans%=mod;}
			else if(x==0 && y==0) {ans*=r*c-u;  ans%=mod;}
//			db(i,ir,ic,r,c,x,y, ans);
		}
        
	     
        out.println(ans);
        out.flush();
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//    public int compareTo(P p){
//        return d-p.d; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 24148
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;
int x,y;
int a[310][310];

signed main(){

    cin >> x >> y;
    cout << x + y/2 << endl;
    

    

    
    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(10);
}

#define int ll
void solve() {
	while (true) {
		string s = "qazwsxedcrfvtgb";
		string a;
		cin >> a;
		if (a == "#") return;
		int now = -1;
		int go = -1;
		REP(q, a.length()) {
			int ok = 0;
			REP(j, s.length()) {
				if (s[j] == a[q]) ok = 1;
			}
			if (go != ok) {
				go = ok;
				now++;
			}
		}
		cout << now << endl;
	}
}
#undef int

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


Measured memory_bytes: 3220
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	while(cin>>n,n){
		int in[15][15]={0};
		rep(i,n)rep(j,n)cin>>in[i][j];
		rep(i,n){
			int sum=0;
			rep(j,n)sum+=in[i][j];
			in[i][n]=sum;
		}
		rep(i,n+1){
			int sum=0;
			rep(j,n)sum+=in[j][i];
			in[n][i]=sum;
		}
		rep(i,n+1){
			rep(j,n+1)printf("%5d",in[i][j]);
			cout<<endl;
		}
	}
}

Measured memory_bytes: 1192
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))


B_sum = sum(B)
ex = 0

for n in range(N-1):
    if A[n] == A[n+1]-1:
        ex += C[A[n]-1]
    else:
        pass
ans = B_sum + ex

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i=0; i<(long long)(n); i++)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const ll inf = 1020304050607080910;
const int mod = 1000000007;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x,ll y){if(x>y)swap(x, y);while(x!=0){y%=x;swap(x, y);}return y;}
ll mpow(ll x,ll r){if(r==0)return 1;if(r%2==1){return x*mpow(x,r-1)%mod;}else{ll aa=mpow(x,r/2);return aa*aa%mod;}}

int main(){
	int N; cin >> N;
	int p = N%10;
	if(p == 3){
		cout << "bon" << endl;
	}else if(p == 0 || p == 1 || p == 8 || p == 6){
		cout << "pon" << endl;
	}else{
		cout << "hon" << endl;
	}
	return 0;
}


Measured memory_bytes: 3672
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;

int main() {
    abdelrahman010
    long double r;
    cin >> r;
    cout << fixed << setprecision(9) << 2 * acos(-1) * r;
    return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    string s;
    cin >> s;
    bool ok = false;
    if(s[0] == 'A' && islower(s[1]) && islower(s.back()))
        ok = true;

    if(ok){
        string t = s.substr(2, s.size()-3);
        int cnt = 0;
        for(auto c:t){
            if(c == 'C')
                cnt++;
            else if(isupper(c))
                ok = false;
        }
        if(cnt != 1)
            ok = false;
    }
    cout << (ok ? "AC" : "WA") << endl;
}


Measured memory_bytes: 256
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 100005
#define INF (ll)1e18
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define vv vector
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); //cout.tie(0);
#define pi 3.1415926535897L
#define db long double  /* print with %Lf */
#define EPS 1e-9
#define flu fflush(stdout)
#define imp {cout<<"No\n"; return 0;}
#define yup {cout<<"Yes\n"; return 0;}
#define debug_vec(vec,n) {rep(idxi,n) cout<<vec[idxi]<<" "; cout<<"\n";}
#define debug_pvec(vec,n) {rep(idxi,n) cout<<vec[idxi].fi<<"-"<<vec[idxi].se<<"  "; cout<<"\n";}
#define debug_set(seta) {cout<<seta.size()<<"\n"; for(auto idxi:seta) cout<<idxi<<" "; cout<<"\n";}
#define debug_map(mappa) {cout<<mappa.size()<<"\n";for(auto idxi:mappa) cout<<idxi.fi<<"-"<<idxi.se<<"  "; cout<<"\n";}
#define debug_vecvec(vec,n) {rep(idxi,n) {for(auto idxi2:vec[idxi]) cout<<idxi2<<" "; cout<<"\n";}}
 
// LOOK AT THESE BEFORE SUBMISSION
// LOOK AT THESE BEFORE SUBMISSION
// ============================================================
// Nmax value and is index access offset taking it beyond Nmax.
// Precision error in case of real numbers.
// N vs N2 chosen correctly.
// Modulo applied everywhere.
// Flush in case of interactive.
// Don't erase value in multiset.
// Check for array indices out of bound (in pre or suff sums).
// Correct return value for functions.
// Confirm the letter case of yes and no.
// Dont paste code two times in the text file.
// ============================================================


int main() {

    get(n);
    fill_nums(A,n);

    map<ll,ll> ma;
    for(auto i:A) ma[i]++;

    ll ans = 0;
    for(auto i:ma) ans += i.se*(i.se-1)/2;

    rep(i,n) {
        ll val = ans;
        val -= ma[A[i]]*(ma[A[i]]-1)/2;
        val += (ma[A[i]]-1)*(ma[A[i]]-2)/2;
        printf("%lld\n", val);
    }
    
    return 0;  
}   


Measured memory_bytes: 11008
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

const ll INF = 1e9+7;

// 各桁の和
template<typename T>
T digit(T num){
  T sum = 0;
  while(num){
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

template<typename T>T gcd(T a,T b){
  if(b == 0)
    return a;
  return gcd(b,a%b);
}
template<typename T>T lcm(T a, T b){
  T g = gcd(a,b);
  return a/g*b; 
}
template<typename T>T power(T a,T b){
  T tmp = 1;
  rep(i,b){
    tmp *= a;
  }
  return tmp;
}
int main(){
  string s;
  cin>>s;
  vector<int> alpha(26,0);
  
  rep(i,s.size()){
    int tmp = s[i] - 'a';
    if(tmp < 0 || tmp > 26)continue;
    alpha[tmp]++;
  }
  
  rep(i,alpha.size()){
    if(alpha[i] != 0)continue;
    print((char)('a' + i))
    return 0;
  }
  print("None")
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
    cout<<"hon"<<endl;
    if(n%10==0||n%10==1||n%10==6||n%10==8)
    cout<<"pon"<<endl;
    if(n%10==3)
    cout<<"bon";
	return 0;
}

Measured memory_bytes: 3608
n=int(input())
ans=0
g=[[-1 for i in range(n)] for j in range(n)]
for i in range(n):
  a=int(input())
  for j in range(a):
    x,y=map(int,input().split())
    g[i][x-1]=y
for i in range(2**n):
  ok=True
  for j in range(n):
    if (i>>j)&1:
      for k in range(n):
        if g[j][k]==-1:
          continue
        if (i>>k)&1!=g[j][k]:
          ok=False
  if ok:
    d=i
    t=str(bin(d)).count('1')
    ans=max(t,ans)
print(ans)

Measured memory_bytes: 3064
// D - Static Sushi

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

ll x[100001];
ll d[100001];
ll r_d[100001];

ll v[100001];
ll r_v[100001];

ll cum_v[100001];
ll r_cum_v[100001];

ll max_cal[100001];
ll r_max_cal[100001];

int main() {
	ll N, C;
	cin >> N >> C;

	for (int i=0; i<N; i++) {
		cin >> x[i] >> v[i];
		r_v[i] = v[i];
	}
	reverse(r_v, r_v+N);

	for (int i=0; i<N; i++) {
		d[i+1] = x[i];
		r_d[i+1] = C - x[N-1-i];
	}

	for (int i=0; i<N; i++) {
		cum_v[i+1] = cum_v[i] + v[i];
		r_cum_v[i+1] = r_cum_v[i] + r_v[i];
	}

	ll tmp_max_cal = 0;
	for (int i=1; i<=N; i++) {
		ll cal = cum_v[i] - d[i];
		tmp_max_cal = max(tmp_max_cal, cal);
		max_cal[i] = tmp_max_cal;
	}

	tmp_max_cal = 0;
	for (int i=1; i<=N; i++) {
		ll cal = r_cum_v[i] - r_d[i];
		tmp_max_cal = max(tmp_max_cal, cal);
		r_max_cal[i] = tmp_max_cal;
	}

	ll ans = 0;

	// 時計回りのみ
	for (int i=0; i<=N; i++) {
		ll cal = cum_v[i] - d[i];
		ans = max(ans, cal);
	}

	// 反時計回りのみ
	for (int i=0; i<=N; i++) {
		ll cal = r_cum_v[i] - r_d[i];
		ans = max(ans, cal);
	}

	// 反時計回り→時計回り
	for (int i=0; i<N; i++) {
		ll cal = r_cum_v[i] - r_d[i]; // 反時計回り
		cal -= r_d[i]; // 原点に戻る
		cal += max_cal[N-i]; // 時計回り
		ans = max(ans, cal);
	}

	// 時計回り→反時計回り
	for (int i=0; i<N; i++) {
		ll cal = cum_v[i] - d[i];// 時計回り
		cal -= d[i]; // 原点に戻る
		cal += r_max_cal[N-i]; // 反時計回り
		ans = max(ans, cal);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10664
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    var ans = 1L
    for (i in 1..N) {
        ans = (ans * i) % 1000000007
    }
    println(ans)
}

Measured memory_bytes: 33620
numbers = input()
numbers

def dfs(i, indices):
    total = 0

    if i == len(numbers) - 1:
        indices = [0] + indices + [None]
        for n in range(len(indices) - 1):
            total += int(numbers[indices[n]:indices[n+1]])
        return total

    total += dfs(i+1, indices)
    total += dfs(i+1, indices + [i+1])

    return total
  
print(dfs(0, []))

Measured memory_bytes: 3064
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n , m ;
    cin >> n >> m ;
    vector<int> v(n) ;
    for(int i = 0; i < n; i++){
        cin >> v[i] ;
        v[i] %= m ;
    }
    vector<int> sum(n + 1) ;
    for(int i = 0; i < n; i++){
        sum[i + 1] = sum[i] + v[i] ;
        sum[i + 1] %= m ;
    }
    debug() << imie(sum) ;
    map<int,int> mp ;
    mp[0] = 1;
    int ans = 0 ;
    for(int i = 1; i < n + 1; i++){
        ans += mp[sum[i]];
        mp[sum[i]]++;
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 8628
function main(input) {
  let inputs = input.split(/\n/);
  let args = inputs[2].split(/\s/);
  let minDifference;
  let result;
  let tempretures = [];
  for (let i = 0;i < inputs[0];i++) {
    tempretures[i] = inputs[1].split(' ')[0] - args[i] * 0.006;
    if (minDifference === undefined) {
      minDifference = Math.abs(inputs[1].split(' ')[1] - tempretures[i]);
    }
    if (Math.abs(inputs[1].split(' ')[1] - tempretures[i]) <= minDifference) {
      minDifference = Math.abs(inputs[1].split(' ')[1] - tempretures[i]);
      result = i;
    }
  }
  console.log(result + 1);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30396
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;


////???????????? - ???????????????????????? O(Flow|E|)

typedef int Weight;

const Weight INF = INT_MAX/2;
const Weight ZERO = 0;
struct Edge {
	int src, dst;
	Weight weight;
	int rev;
	int id;
	Edge(int src_, int dst_, Weight weight_, const int rev_, const int id_) :
		src(src_), dst(dst_), weight(weight_), rev(rev_), id(id_) { }
	Edge(int src_, int dst_, Weight weight_, const int rev_) :
		src(src_), dst(dst_), weight(weight_), rev(rev_) { }
	Edge() :src(0), dst(0), weight(0) {
	}
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph&g, int from, int to, int cap)
{
	g[from].push_back(Edge(from, to, cap, (int)g[to].size()));
	g[to].push_back(Edge(to, from, 0, (int)g[from].size() - 1));
}

//??????????????????????????¨????¶????
void erase_edge(Graph&g, int from, int to) {
	g[from].erase(remove_if(g[from].begin(), g[from].end(), [=](const Edge&e) {return e.dst == to; }),g[from].end());
	g[to].erase(remove_if(g[to].begin(), g[to].end(), [=](const Edge&e) {return e.dst == from; }),g[to].end());
}
int dfs(vector<int>&used, Graph&g, int now, int t, int f)
{
	if (now == t) {
		return f;
	}
	used[now] = true;
	for (int i = 0; i<g[now].size(); ++i) {
		Edge &e = g[now][i];
		if (!used[e.dst] && e.weight>0) {
			int d = dfs(used, g, e.dst, t, min(f, e.weight));
			if (d > 0) {
				e.weight -= d;
				g[e.dst][e.rev].weight += d;
				return d;
			}
		}
	}
	return 0;
}
Weight fold_falc(Graph g, const int start, const int goal) {
	Weight ans = 0;
	while (1) {
		vector<int>used(g.size());
		int flow = dfs(used, g, start, goal, INF);
		if (!flow)return ans;
		else ans += flow;
	}
}

int main() {
	int N, M; cin >> N >> M;
	int start = 0;
	int in = start + 1;
	int out = in + N;
	int goal = out + N;
	Graph g(goal + 1);
	for (int i = 1; i < N; ++i) {
		add_edge(g, in + i, out + i, 1);
	}
	add_edge(g, start, out, 2);
	for (int i = 0; i < M; ++i) {
		int a, b; cin >> a >> b; a--; b--;
		add_edge(g, out + a, goal, 1);
		add_edge(g, out + b, goal, 1);
		int flow = fold_falc(g, start, goal);
		bool ok = flow >= 2;
		if (ok) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		erase_edge(g, out + a, goal);
		erase_edge(g, out + b, goal);
		add_edge(g, out + a, in + b, 1);
		add_edge(g, out + b, in + a, 1);
	}
	return 0;
}

Measured memory_bytes: 3860
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <random>

#define BIG 998244353
#define LLMAX 9223372036854775807
#define LLMIN (-9223372036854775808)

using namespace std;

bool search(long x,long y){
    if(x < y){
        long z = x;
        x = y;
        y = z;
    }
    if(x <= 1 && y <= 1)return false;
    bool flag = true;
    for(int i = 1;i <= x / 2;++i){
        flag &= search(x - i * 2,y + i);
    }
    return !flag;
}

int main() {
    long x,y;
    cin >> x >> y;
   /* string out;
    for(x = 0;x <= 15;++x){
        cout << x << endl;
        string s;
        for(y = 0;y <= 15;++y){
            cout << x << ":" << y << endl;
            s += search(x,y) ? "T" : "F";
            if(y != 20)s += " | ";
        }
        out += s;
        out += '\n';
    }
    cout << out << endl;*/
    cout << ((abs(x - y) >= 2) ? "Alice" : "Brown") << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MD=998244353;
const int N=2e5+5;
pair<int,int> p[N];
stack<pair<int,int> > st;
int f[N];
int main() {
    //freopen("in.txt","r",stdin);
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
        scanf("%d%d",&p[i].first,&p[i].second);
    }
    sort(p+1,p+n+1);
    f[n+1]=1;
    for(int i=n;i>=1;i--) {
        int t=p[i].first+p[i].second,nex=i+1;
        while(!st.empty()&&t>p[st.top().first].first) {
            nex=st.top().second;
            st.pop();
        }
        st.push({i,nex});
        f[i]=(f[i+1]+f[nex])%MD;
    }
    printf("%d\n",f[1]);
    return 0;
}



Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
    cin>>a>>b;
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    sort(a.begin(),a.end());
    if(b>a)
        puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256