akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;

template <int mod>
struct ModInt{
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p){
        if ((x += p.x) >= mod)
            x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p){
        if ((x += mod - p.x) >= mod)
            x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p){
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p){
        *this *= p.inverse();
        return *this;
    }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0){
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }

    ModInt pow(int e){
        long long a = 1, p = x;
        while (e > 0){
            if (e % 2 == 0){
                p = (p * p) % mod;
                e /= 2;
            }
            else{
                a = (a * p) % mod;
                e--;
            }
        }
        return ModInt(a);
    }

    friend ostream &operator<<(ostream &os, const ModInt<mod> &p){
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a){
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

using modint = ModInt<mod>;

int n;
modint dp[2][d5];
vector<int> edge[d5];
bool done[d5];
void dfs(int x){
    done[x]=true;
    for(auto e:edge[x]){
        if(done[e])continue;
        dfs(e);
        dp[0][x]*=(dp[0][e]+dp[1][e]);
        dp[1][x]*=dp[0][e];
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    for(int i=0;i<2;i++)fill(dp[i],dp[i]+d5,1);
    fill(done,done+d5,false);
    dfs(0);
    cout<<dp[0][0]+dp[1][0]<<endl;
}

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

int a[100];
int main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	reverse(a, a + n);
	rep(i, n) {
		if (i)cout << ' ';
		cout << a[i];
	}
	cout << endl;
}


Measured memory_bytes: 3108
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }

        // 主処理
        // s中のa-zまでの使用回数の最小値を保持
        int[] count = new int[26];
        char c = 'a';
        for (int i = 0; i < 26; i++) {
            String str = String.valueOf((char) (c + i));
            int min = 50;
            for (int j = 0; j < s.length; j++) {
                min = Math.min(min, s[j].length() - s[j].replace(str, "").length());
            }
            count[i] = min;
        }

        // 使用する文字
        String word = "";
        for (int i = 0; i < count.length; i++) {
            for (int j = 0; j < count[i]; j++) {
                word += (char) (c + i);
            }
        }

        // 辞書順で最小になるようソート
        String[] array = word.split("");
        Arrays.sort(array);
        String result = String.join("", array);

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 25940
#include <stdio.h>
#define N 100000

struct donarudo{
  char string;
  int num;
  int order;
};

struct donarudo L[N/2+2], R[N/2+2];

int partition(struct donarudo *, int, int);
void quickSort(struct donarudo *, int, int);
int judge(int, int);

int main(){
  int i, j, n, v, fc=0, rs=1;
  struct donarudo A[N];
  char c[2];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %d", c, &v);
    A[i].string=c[0];
    A[i].num=v;
    A[i].order=i;
  }

  quickSort(A, 0, n-1);

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(A[i].num!=A[j].num) break;

      if(A[i].num==A[j].num){
         rs=judge(A[i].order, A[j].order);
         if(rs==0) fc++;
      }
    }
  }

  if(fc==0) printf("Stable\n");
  else printf("Not stable\n");

  for(i=0;i<n;i++){
    printf("%c %d\n", A[i].string, A[i].num);
  }
  return 0;
}

int partition(struct donarudo *A, int p, int r){
  int i, j;
  struct donarudo t, x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].num<=x.num){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}

void quickSort(struct donarudo *A, int p, int r){
  int q;
  if(p<r){
    q=partition(A, p, r);
    quickSort(A, p, q-1);
    quickSort(A, q+1, r);
  }
}

int judge(int a, int b){
  if(a<b) return 1;
   else return 0;
}



Measured memory_bytes: 2904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


int main(){
	
	int n,m,k;
	cin >> n;
	vector<int> a(n);
	for(auto &x:a)cin >> x;
	cin >> m;
	vector<int> b(m);
	for(auto &x:b)cin >> x;
		b.push_back(MOD);
	for(auto x:a){
		int i = POSL(b,x);
		if(b[i] == x){
			cout << x << "\n";
		}
	}
}



Measured memory_bytes: 5144
import  numpy   as  np
i_N =   int(input())
s_input =   input().split()
H   =   np.array(s_input).astype(type(i_N))

for i in range(1,i_N):
    if(H[i-1] > H[i] and abs(H[i-1] - H[i]) == 1):
        H[i] += 1
    elif(H[i-1] > H[i] and abs(H[i-1] - H[i]) != 1):
        print("No")
        exit()
print("Yes")



Measured memory_bytes: 28792
begin
	writeln('1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1');
end.


Measured memory_bytes: 1376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    int a,b;cin>>a>>b;
    if(a<=b){
        rep(i,b)cout<<a;
        cout<<endl;
    }
    else{
        rep(i,a)cout<<b;
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int h,w;

    cin >> h >> w;
    string s[55];
    for (int i = 0; i < h; i++){
        cin >> s[i];
    }

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

    bool can = true;
    for (int i = 0; i < h; i++){
        for (int k = 0; k < w; k++){
            if (s[i][k] != '#'){
                continue;
            }
            int cnt = 0;
            for (int p = 0; p < 4; p++){
                const int x = k + dx[p];
                const int y = i + dy[p];
                if (x >= 0 && x < w && y >= 0 && y < h){
                    if (s[y][x] == '#'){
                        cnt++;
                    }
                }
            }
            if (cnt == 0){
                can = false;
            }
        }
    }

    if (can) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int N;

bool is_yakusu8(int n)
{
    int sum = 0;
    for (int i = 1; i <= N; i++) {
        if ((n % i) == 0)
            sum++;
    }

    return (sum == 8) ? true : false;
}

int main() {
    cin >> N;

    int sum = 0;
    for (int i = 1; i <= N; i += 2) {
        if (is_yakusu8(i))
            sum++;
    }

    cout << sum << endl;
}

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

#define MAX 1000000010
#define INF 99999999
#define MIN -99999999
#define in(a,b)  ( (b).find(a) != (b).end())
#define clr(a,b) memset((a), (b), sizeof((a)))
#define pb       push_back
#define all(a)   a.begin(), a.end()
#define mp       make_pair
#define ll	long long
#define FI	first
#define SE second

using namespace std;
int n;
int main() {
  cin >> n;
  cout << abs(n-48) << endl;
  return 0;
}


Measured memory_bytes: 256
n, (T, A),  *D,  = [list(map(int, s.split())) for s in open(0)]
n = n[0]
D = D[0]
di = {}
for i in range(len(D)):
    di[i] = abs(A  - T + D[i] * 0.006)
   
di = sorted(di.items(), key = lambda x:x[1])
print(di[0][0] + 1)
    

Measured memory_bytes: 3572
n, x = map(int, input().split())
a = [int(m) for m in input().split()]
#x=kのときを考える
#f(i,k)を考える，メモ化しておく
memos = []
for k in range(n):
    memos.append([float("INF") for i in range(n)])

def f(i,k):
    if k == 0:
        memos[k][i] = a[i]
        return a[i]
    if memos[k][i] != float("INF"):
        return memos[k][i]
    else:
        memos[k][i] = min(f(i, k - 1), a[i - k])
        return memos[k][i]

ansli = []
tmpsum = 0
for k in range(n):
    for i in range(n):
        tmpsum += f(i, k)
    ansli.append(x * k + tmpsum)
    tmpsum = 0

print(min(ansli))

Measured memory_bytes: 138632
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

int main()
{
    IOS();
    ll a,b;
    cin>>a>>b;
    if((a*b)&1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

int n,m;

bool check(int x[], int y){
    x[n] = y;
    int i = 0;
    while(x[i] != y){
        i++;
    }
    if(i == n) return 0;
    else return 1;
    
    
}




int main(){
    cin >> n;
    int a[n];
    
    rep(i,n) cin >> a[i];
    
    cin >> m;
    int b[m];
    
    rep(i,m) cin >> b[i];
    
    int ans = 0;
    rep(i,m){
        ans += check(a,b[i]);
    }
    
    cout << ans << endl;
    
}














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

using namespace std;

typedef pair<long, long> P;
bool pairCompare(const P& firstElof, const P& secondElof)
{
  if(firstElof.second == secondElof.second){
    return firstElof.first > secondElof.first;
  }else{
    return firstElof.second < secondElof.second;
  }
}

int main() {
  long n;
  cin >> n;
  
  vector<P> pairs(n);
  for (long i = 0; i < n; ++i) {
    int a,b;
    cin>>a>>b;
    pairs[i]=make_pair(a,b);
  }
  sort(pairs.begin(),pairs.end(),pairCompare);
  int time=0;
  for (long i = 0; i < n; ++i) {
    time+=pairs[i].first;
    if(time>pairs[i].second){
      cout<<"No"<<endl;
      exit(0);
    }
    
  }
  cout<<"Yes"<<endl;

}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b; cin >> a >> b;
    cout << max(0,a-(2*b)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
vector<int>edge[100005];
vector<int>edge2[100005];
string s;
int m;
bool in[100005];
int dfs(int v,int u){
    int cnt = (s[v] == 'W');
    for(int i=0;i<edge2[v].size();i++){
        if(edge2[v][i] == u) continue;
        cnt += dfs(edge2[v][i],v);
    }
    if(cnt && u != -1) {
        edge[v].pb(u);
        edge[u].pb(v);
    }
    if(cnt){
        in[v] = true;
        m++;
    }
    return cnt;
}
int dp[100005],mx;
int par[100005];
void dfs2(int v,int u){
    priority_queue<int,vector<int>,greater<int> >que;
    int MX = 0;
    for(int i=0;i<edge[v].size();i++){
        if(edge[v][i] == u) continue;
        dfs2(edge[v][i],v);
        que.push(dp[edge[v][i]]);
        while(que.size() > 2) que.pop();
        MX = max(MX,dp[edge[v][i]]);
    }
    dp[v] = MX+par[v];
    int path = 0;
    while(!que.empty()){
        path += que.top();
        que.pop();
    }
    path += par[v];
    mx=max(mx,path);
}
int main(){
    cin>>n;
    rep(i,n-1){
        int a,b;
        cin>>a>>b; a--; b--; 
        edge2[a].pb(b);
        edge2[b].pb(a);
    }
    cin>>s;
    int v = -1;
    for(int i=0;i<n;i++) if(s[i] == 'W') v = i;
    if(v == -1){
        puts("0"); return 0;
    }
    dfs(v,-1);
    if(m == 1){
        cout<<1<<endl; return 0;
    }
    int ans = 2*(m-1);
    for(int i=0;i<n;i++){
        if(!in[i]) continue;
        int x = (s[i] == 'W');
        x ^= (edge[i].size()%2);
        if(x == 1) ans++;
        par[i] = x;
    }
    dfs2(v,-1);
    cout<<ans-2*mx<<endl;
}

Measured memory_bytes: 23040
#include<stdio.h>
#include<math.h>

int main(){
        int total_sand,instant_time,remaining;
        do{
            scanf("%d",&total_sand);
        }while(total_sand<1 || total_sand>pow(10,9));
        do{
            scanf("%d",&instant_time);
        }while(instant_time<1 || instant_time>pow(10,9));

        if(instant_time<total_sand) printf("%d",remaining=total_sand-instant_time);
        else printf("0");
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N, K; cin >> N >> K;
  int h[N]; rep(i,N) cin >> h[i];
  int result[N] = {};
  repr(i,1,N) {
    result[i] = INF;
    repr(j,1,min(i+1,K+1)) result[i] = min(result[i], result[i-j]+abs(h[i]-h[i-j]));
  }
  // debug(result,result+N);
  cout << result[N-1] << endl;
  return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

int N, M;
int p[20001];
int a[20001];

int main() {
    scanf("%d\n", &N);
    M = N + 1;
    FOR(i, 1, N) scanf("%d", p + i);
    FOR(i, 1, N) {
        a[i] += i * M;
        a[p[i]] += i;
    }
    FOR(i, 1, N) printf("%d%c", a[i], i==N?'\n':' ');
    DOWN(i, N, 1) printf("%d%c", i * M, i==0?'\n':' ');
	return 0;
}

Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Linq;

class MainClass
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());

        long ans = 0;
        for (int i = 1; i < N+1; i++)
        {
            long num = N / i;
            ans += i * num * (num + 1) / 2;
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 27472
from sys import stdin
H,W,K= [int(x) for x in stdin.readline().rstrip().split()]
data = []
for i in range(H):
    data.append(input())
ans = [[0]*W for i in range(H)]
flag = False
cnt = 1
first_flag = False
f_cnt = 0

for h in range(H):
    if data[h] == "."*W and h == 0:
        first_flag = True
        f_cnt += 1
        continue
    elif data[h] == "."*W and first_flag:
        f_cnt += 1
        continue
    elif data[h] == "."*W:
        ans[h] = ans[h-1]
        continue
    for w in range(W):
        if data[h][w] == "#" and flag:
            cnt += 1
            
        elif data[h][w] == "#":
            flag = True
        
        ans[h][w] = cnt
        if w == W-1:
            cnt += 1
            flag = False
    if first_flag:
        for m in range(f_cnt):
            ans[m] = ans[h]
        first_flag = False
    
for i in ans:
    for j in i:
        print(j,end=" ")
    print("")

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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k, s;
    cin >> n >> k >> s;
    REP(i, 0, k) cout << s << " ";
    REP(i, 0, n-k) {
    	if(s == int(1e9)) cout << 1 << " ";
    	else cout << int(1e9) << " ";
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 1280
n = int(input())
l = list(map(int, input().split()))
ans = 0
for x in range(n):
    for y in range(x+1, n):
        for z in range(y+1, n):
            if l[x]==l[y] or l[x] == l[z] or l[y] == l[z]: continue
            if l[x] + l[y] > l[z] and l[y] + l[z] > l[x] and l[z] + l[x] > l[y]: ans += 1
print(ans)

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

int main(){
    int A, B, C, D;

    cin >> A >> B >> C >> D;
    if(A + B == C + D)
        cout << "Balanced" << endl;
    else if (A + B < C + D)
        cout << "Right" << endl;
    else
        cout << "Left" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <assert.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <iostream>
#include <list>
#include <set>
#include <stack>
#include <string>
#include <vector>

 
using namespace std;
 
typedef string str;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<long long> vl;

#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define trav(a, x) for (auto &a : x)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define PRINT_ARRAY(a, N)        \
  F0R(z, N) cout << a[z] << " "; \
  cout << "\n"
 
const int MOD = 1000000007;  // 998244353
const ll INF = 1e18;
const ld PI = 4 * atan((ld)1);

int main() {
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		ll n;
		cin >> n;
		vl a(n);
		F0R(i, n) cin >> a[i];
		// a[i] >= a[i + 1]
		ll cost = 0;
		for (int i = 0; i < n - 1; ++i) {
				if (a[i] > a[i + 1]) {
						ll delta = a[i] - a[i + 1];
						cost += delta;
						a[i + 1] = a[i];
				}
		}
		cout << cost << endl;

}


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec x = ivec(n);
    int me = sum_(x) / n;
    int one = 0, two = 0;
    repall (e, x) {
        one += (e - me) * (e - me);
        two += (e - me - 1) * (e - me - 1);
    }
    print(min(one, two));

    return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n,m;
bool edge[11][11];
int ord[11];

int main(){
	cin.sync_with_stdio(false);
	cin>>n>>m;
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--; b--;
		edge[a][b]=edge[b][a]=true;
	}
	ll cnt=0;
	rep(i,n)ord[i]=i;
	do{
		if(ord[0]!=0)continue;
		bool ok=true;
		rep(i,n-1){
			if(!edge[ord[i]][ord[i+1]])ok=false;
		}
		if(ok){
			cnt++;
		}
	}while(next_permutation(ord,ord+n));
	cout<<cnt<<endl;
	return 0;
}


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

int main () {
  int n, d, x;
  cin >> n >> d >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    while (cnt * a[i] + 1 < d + 1) {
      ans++;
      cnt++;
    }
  }
  cout << ans + x << endl;
  return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
	N = int(input())
	ls = [int(a) for a in input().split()]
	c = 0
	dic = {}
	for i in range(N):
		h = ls[i]
		if i > 0:
			c += dic.get(i-h,0)
		v = dic.get(i+h,0)
		if v == 0:
			dic[i+h] = 1
		else:
			dic[i+h] += 1

	print(c)

Measured memory_bytes: 111708
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

N = int(input())
list =make_divisors(N)
list_rev=sorted(list, reverse=True)

ans = 10**15
for i in range(len(list)//2 + 1):
  tmp = (list[i]-1)+(list_rev[i]-1)
  if tmp < ans:
    ans=tmp

print(ans)


Measured memory_bytes: 3296
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(b / a, c) << endl;
}



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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

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

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int mod_pow(int a,int b,int m)
{
	int x=1;
	for(;b;b>>=1){
		if(b&1)
			x=(ll)x*a%m;
		a=(ll)a*a%m;
	}
	return x;
}

vl f(100000),g(100000);
ll choose(int n,int r)
{
	if(r<0||n<r)
		return 0;
	return f[n]*g[n-r]%MOD*g[r]%MOD;
}

int main()
{
	f[0]=g[0]=1;
	repi(i,1,f.size()){
		f[i]=i*f[i-1]%MOD;
		g[i]=mod_pow(f[i],MOD-2,MOD);
	}

	for(int n;cin>>n&&n;){
		vi a(n+1);
		rep(i,n+1) cin>>a[i];

		int l=0,c=0,r=0;
		{
			vi cnt(n+1);
			rep(i,n+1) cnt[a[i]]++;
			int x=find(all(cnt),2)-begin(cnt);
			rep(i,n+1) if(cnt[i]==2) x=i;
			l=find(all(a),x)-begin(a);
			c=find(l+1+all(a),x)-begin(a)-l-1;
			r=n-1-l-c;
		}

		repi(i,1,n+2){
			ll x=choose(n-1,i);
			ll y=(choose(n-1,i-1)*2-choose(l+r,i-1)+MOD)%MOD;
			ll z=choose(n-1,i-2);
			cout<<(x+y+z)%MOD<<endl;
		}
	}
}


Measured memory_bytes: 3192
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e9
typedef long long ll;
typedef pair<ll,ll> P;

ll n,A,B;
ll h[100010];

bool check(ll x){
    ll res=0;
    for(ll i=0;i<n;i++){
        ll t=h[i]-B*x;
        if(t<=0)continue;
        else{
            res+=t/(A-B);
            if(t%(A-B)!=0)res++;
        }
    }
    return (res>x);
}

int main(void){
    cin>>n>>A>>B;
    for(ll i=0;i<n;i++)cin>>h[i];
    ll ng=0,ok=(ll)INF;
    while(ok-ng>1){
        ll mid=(ok+ng)/2;
        if(check(mid))ng=mid;
        else ok=mid;
  }
    cout<<ok<<endl;
    return 0;
}

Measured memory_bytes: 1024
'''input
1
1
50
'''

N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))
D=[0]*N
ans=0

for i in range(N):
	D[i]=V[i]-C[i]
	if D[i]>0:
		ans+=D[i]


print(ans)

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

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    vector<long long> S(N+1, 0);
    for (int i = 0; i < N; i++)
    {
        S[i+1] = S[i] + a[i];
    }
    long long ans;
    ans = LONG_LONG_MAX;
    for (int i = 1; i < N; i++)
    {
        ans = min(ans, abs(S[N] - 2 * S[i]));
    }
    
    cout << ans << endl;
}

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

Measured memory_bytes: 5528
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
#define all(v) v.begin(),v.end()
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, m, total = 0;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int a;
    cin >> a;
    total += a;
  }
  if (total > n) cout << -1;
  else cout << (n-total);
}


Measured memory_bytes: 3660
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int n;
   cin >> n;
   int p[n];
   rep(i,n) cin >> p[i];

   int cnt = 0;
   int tmp_th = p[0];

   rep(i,n){
      int tmp = p[i];
      if(tmp <= tmp_th){
         cnt++;
         tmp_th = tmp;
      }
   }

   cout << cnt << endl;



   return 0;
}

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N, K; cin >> N >> K;

	int ans = 1;
	FOR(i,1,N){
		ans *= (K-1);
	}
	ans *= K;

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&(a!=c)) cout<<"Yes"<<endl;
     else if(c==b&&(a!=c)) cout<<"Yes"<<endl;
     else if(a==c&&(a!=b)) cout<<"Yes"<<endl;
       else cout<<"No"<<endl;

 return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef pair<int,int> ii;
struct Data { short h,w,index; };

short H,W,n,b[20],k[20],s[20][20],ans[20][20],buf[20][20];
vector<Data> edge[20][20];
short found;

bool isValid(int x,int y){ return 0 <= x && x < W && 0 <= y && y < H; }

inline void makeEdge(){
  rep(y,H) rep(x,W) {
    rep(i,n){
      for(int hy=1;hy<=k[i];hy++){ 
        if( k[i] % hy ) continue;
        int hx = k[i] / hy;
        bool failed = false, check = false;          
        for(int cy=y;cy<y+hy;cy++)for(int cx=x;cx<x+hx;cx++){
            if( !isValid(cx,cy) ) {
              failed = true;
              goto Skip;
            }
            if( !( s[cy][cx] == 0 || s[cy][cx] == b[i] ) ) {
              failed = true;
              goto Skip;
            }
            if( s[cy][cx] == b[i] ) check = true;
          }
        if( check ) { edge[y][x].push_back((Data){hy,hx,b[i]}); }
      Skip:;
        
      }
    }
  }
}

bool BackTracking(int cx,int cy){
  if( cx == W-1 && cy == H-1 && ans[cy][cx] != 0 ) {
    ++found;
    if( found == 1 ) rep(i,H) rep(j,W) buf[i][j] = ans[i][j];
    return found >= 2;
  }
  
  rep(i,(int)edge[cy][cx].size()){
    int h = edge[cy][cx][i].h, w = edge[cy][cx][i].w, index = edge[cy][cx][i].index;
    ii next = ii(-1,-1);
    ii memo = ii(-1,-1);
    rep(y,h) rep(x,w) {
      if( ans[y+cy][x+cx] != 0 ){
        memo = ii(x,y);
        goto Skip2;
      }
      ans[cy+y][cx+x] = index;
    }
    next = ii(-1,-1);
    rep(y,H) rep(x,W){
      if( ans[y][x] == 0 ) {
        next = ii(x,y);
        goto Skip2;
      }
      if( x == W-1 && y == H-1 ) next = ii(W-1,H-1);
    }
  Skip2:;

    if( next != ii(-1,-1) && BackTracking(next.first,next.second) ) return true;
    rep(y,h) rep(x,w) {
      if( x == memo.first && y == memo.second ) goto Skip3;
      ans[cy+y][cx+x] = 0;
    }
  Skip3:;
  }
  return false;
}

inline void compute(){
  makeEdge();
  rep(i,H) rep(j,W) ans[i][j] = 0;
  found = 0;
  if( !BackTracking(0,0) && found == 1 ) {
    rep(i,H) { 
      rep(j,W) {
        if( j ) cout << " ";
        cout << buf[i][j]; 
      } 
      cout << endl; 
    }
  } else puts("NA");
  rep(i,H) rep(j,W) edge[i][j].clear();
}

int main(){
  while( cin >> W >> H >> n, W|H|n ){
    int sum = 0;
    rep(i,n) {
      cin >> b[i] >> k[i];
      sum += k[i];
    }
    rep(i,H) rep(j,W) cin >> s[i][j];
    if( sum != H*W ) { puts("NA"); continue; }
    compute();
  }
  return 0;
}

Measured memory_bytes: 1228
n = int(input())
ss = [input() for i in range(n)]

last = ""
a = set() 
check = True
for i in range(n):
  s = ss[i]
  if i == 0:
    last = s[len(s) - 1]
    a.add(s)
    continue

  if s in a:
    check = False
    break
  if last != s[0]:
    check = False
    break

  last = s[len(s) - 1]
  a.add(s)

if check:
  print('Yes')
else:
  print('No')
  

Measured memory_bytes: 3064
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
ll a[4];
int main()
{
    ll i,n,t,k,j,x=0,y=0,m;
    FAST
    cin>>t;

    string str;
    while(t--)
    {
        cin>>str;
        if(str=="AC")
            a[0]++;
        else if(str=="WA")
            a[1]++;
        else if(str=="TLE")
            a[2]++;
        else if(str=="RE")
            a[3]++;

    }
    cout<<"AC"<<" x "<<a[0]<<endl;
    cout<<"WA"<<" x "<<a[1]<<endl;
    cout<<"TLE"<<" x "<<a[2]<<endl;
    cout<<"RE"<<" x "<<a[3]<<endl;

    return 0;
}



Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <vector>
#include <climits>
#include <queue>
#include <utility>
#include <iomanip>
#include <sstream> 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
template<typename T1, typename T2>
inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2>
inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
const ll MOD = 1000000007;
const ll INF = 1LL << 60;


int main()
{
	
	int n, m;
	cin >> n >> m;

	vector<int> p(m), y(m);

	rep(i, m) {
		cin >> p[i] >> y[i];
		p[i]--; y[i]--;
	}

	vector<vector<pair<int, int>>> dat(n);
	rep(i, m) {
		dat[p[i]].push_back(make_pair(y[i],i));
	}

	vector<pair<int, int>> ans(m);

	rep(i, n) {
		sort(dat[i].begin(), dat[i].end());
		rep(j, dat[i].size()) {
			ans[dat[i][j].second] = make_pair(i, j);
		}
	}

	rep(i, m) {
		printf("%06d%06d\n", ans[i].first+1, ans[i].second+1);
	}


}




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

using namespace std;
#define ll long long
#define int long long

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

int ro[500][500];
int sum[501][501];
int N, Q, M;

void init()
{
	reps(i, 1, N+1) {
		reps(j, 1, N+1) {
			sum[i][j] = ro[i-1][j-1] + sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
		}
	}
}

signed main()
{
	cin >> N >> M >> Q;
	rep(i, M) {
		CIN(int, L);
		CIN(int, R);
		ro[L-1][R-1]++;
	}
	init();
	rep(i, Q) {
		CIN(int, l);
		CIN(int, r);
		int res = sum[r][r] - sum[l-1][r] - sum[r][l-1] + sum[l-1][l-1];
		cout << res << endl;
	}
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S, T;
  cin >> S >> T;
  vector<int> datas(26, 0), datat(26, 0);
  int counts, countt;
  string alp = "abcdefghijklmnopqrstuvwxyz";
  for (int i = 0; i < 26; i++) {
    counts = 0;
    countt = 0;
    for (int j = 0; j < S.size(); j++) {
      if (alp.at(i) == S.at(j)) counts += j;
      if (alp.at(i) == T.at(j)) countt += j;
    }
    datas.at(i) = counts;
    datat.at(i) = countt;
  }
  sort(datas.begin(),datas.end());
  sort(datat.begin(),datat.end());
  int flag = 1;
  for (int i = 0; i < 26; i++) {
    if (datas.at(i) != datat.at(i)) {
      flag = 0;
      break;
    }
  }
  if (flag == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int N;
ll A[20][20],dp[1<<16] = {},value[1<<16] = {};

int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			cin >> A[i][j];
		}
	}
	for(int S=1;S<(1<<N);S++){
		for(int i=0;i<N;i++){
			if(S & (1<<i)){
				int T = S & ~(1<<i);
				value[S] = value[T];
				for(int j=0;j<N;j++){
					if(T & (1<<j)) value[S] += A[i][j];
				}
				break;
			}
		}
	}
	for(int S=1;S<(1<<N);S++){
		for(int T=S;T>0;T=((T-1)&S)){
			dp[S] = max(dp[S|S],dp[S^T]+value[T]);
		}	
	}
	cout << dp[(1<<N)-1] << endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long X=1000000000+7;

int main() {
  char x,y;
  cin>>x>>y;
  if(x>y) cout<<">"<<endl;
  else if(x<y) cout<<"<"<<endl;
  else cout<<"="<<endl;
}

Measured memory_bytes: 256
n = gets.to_i
row1 = gets.split(" ").map(&:to_i)
row2 = gets.split(" ").map(&:to_i)

if n == 1
  puts row1[0] + row2[0]
  exit
end

score1 = [0]
(n-1).times do |i|
  score1 << score1[-1].to_i + row1[1..-1][i]
end

score2 = []
(n-1).times do |i|
  score2 << score2[-1].to_i + row2[0..-1][i]
end

max = 0
n.times do |i|
  if i == 0
    max = [max, score1[i] + score2[-1]].max
  else
    max = [max, score1[i] + score2[-1] - score2[i-1]].max
  end
end

max += row1[0]
max += row2[-1]

puts max

Measured memory_bytes: 1788
def main():
    K = int(input())
    cnt = 1
    now_mod10 = 1
    mod10 = 1
    while cnt <= K:
        md = 7 * now_mod10
        if md % K == 0:
            return cnt
        mod10 = (mod10 * 10) % K
        now_mod10 = (now_mod10 + mod10) % K
        cnt += 1
    return -1

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 62900
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, m, n) for (int i = m; i < n; i++)
#define repr(i, m, n) for (int i = m; i >= n; i--)
#define db(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD   998244353
#define PI (acos(-1))
#define EPS 1e(-9);
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    int X,Y; 
    cin >> X>>Y;

    int ans=0;

    if(X==1 and Y==1) ans+=400000;
    if(X==1) ans+=300000;
    if(Y==1) ans+=300000;
    if(X==2) ans+=200000;
    if(Y==2) ans+=200000;
    if(X==3) ans+=100000;
    if(Y==3) ans+=100000;

    cout<< ans<<"\n";

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    HashMap<Integer,Integer> a = new HashMap<Integer,Integer>();
    for (int i=0;i<n;i++){
      a.put(i+1,1);
    }

    for (int i=2;i<=n;i++){
      ArrayList<Integer> b = factor(i);
      for (int y : b){
        int g = a.get(y);
        a.put(y,g+1);
      }
    }

    long ret = 1;
    long limit = 1000000007;

    for (int j=1;j<=n;j++){
      int gg = a.get(j);
      ret *= (long) gg;
      ret = (long) ret%limit;
    }

    System.out.println(ret);
  }

  static ArrayList<Integer> factor(int n){
    ArrayList<Integer> a = new ArrayList<Integer>();
    while (n > 1){
      for (int i=2;i<=n;i++){
        if (n%i == 0){
          a.add(i);
          n = (int) n/i;
          break;
        }
      }
    }
    return a;
  }

}


Measured memory_bytes: 36904