akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.Random;
import java.util.Scanner;
public class Main {
    static int[] dice;
    static int[] diceb;
    static int a;
    static int b;
    static int c;
    static int d;
    static int tmp;
    public static void main(String[] args) throws IOException{
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        tmp = 0;

        // first_dice
        dice = new int[6];
        for(int i=0; i<6; i++) {
            dice[i] = sc.nextInt();
        }

        for(int j=0; j<x-1; j++) {
	        diceb = new int[6];
	        for(int i=0; i<6; i++) {
	            diceb[i] = sc.nextInt();
	        }

	        int a = diceb[0];
	        int b = diceb[1];
	        int c = diceb[2];
	        int d = diceb[3];
	        int e = diceb[4];
	        int f = diceb[5];
	        int count = 0;
	        while(true) {
	            diceRoll();
	            count++;
	            if(dice[0]==a && dice[1]==b  && dice[2]==c  && dice[3]==d  && dice[4]==e  && dice[5]==f) {
	            	tmp++;
	            	break;
	            }else if(count==1000) {
	            	break;
	            }
	        }
        }

        if(tmp>0) {
        	System.out.println("No");
        }else {
        	System.out.println("Yes");
        }

        sc.close();
    }

    public static void diceRoll() {
        Random rand = new Random();
        int num = rand.nextInt(4);
        if(num==0) {
            s();
        }else if(num==1) {
            n();
        }else if(num==2) {
            w();
        }else if(num==3){
            e();
        }
    }

    public static void s() {
        a = dice[0];
        b = dice[1];
        c = dice[4];
        d = dice[5];

        dice[0] = c;
        dice[1] = a;
        dice[4] = d;
        dice[5] = b;
    }

    public static void w() {
        a = dice[0];
        b = dice[2];
        c = dice[3];
        d = dice[5];

        dice[0] = b;
        dice[2] = d;
        dice[3] = a;
        dice[5] = c;
    }

    public static void e() {
        a = dice[0];
        b = dice[2];
        c = dice[3];
        d = dice[5];

        dice[0] = c;
        dice[2] = a;
        dice[3] = d;
        dice[5] = b;
    }

    public static void n() {
        a = dice[0];
        b = dice[1];
        c = dice[4];
        d = dice[5];

        dice[0] = b;
        dice[1] = d;
        dice[4] = a;
        dice[5] = c;
    }
}


Measured memory_bytes: 31860
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
const int MAXN = 500005;
const int MAXS = 42 * MAXN;
struct PersistentSegTree {
	int nid = 0;
	ll seg[MAXS];
	int L[MAXS], R[MAXS];
	void build(int id, int s, int e) {
		if (s == e) return;
		int m = (s + e) / 2;
		L[id] = ++nid;
		R[id] = ++nid;
		build(L[id], s, m);
		build(R[id], m + 1, e);
	}
	int update(int id, int s, int e, int p) {
		int cid = ++nid;
		if (s == e) {
			++seg[cid];
			return cid;
		}
		int m = (s + e) / 2;
		L[cid] = L[id];
		R[cid] = R[id];
		if (p <= m) {
			L[cid] = update(L[id], s, m, p);
		} else {
			R[cid] = update(R[id], m + 1, e, p);
		}
		seg[cid] = seg[L[cid]] + seg[R[cid]];
		return cid;
	}
	ll query(int id, int s, int e, int qs, int qe) {
		if (qs <= s && e <= qe) {
			return seg[id];
		}
		int m = (s + e) / 2, ret = 0;
		if (qs <= m) ret += query(L[id], s, m, qs, qe);
		if (qe > m) ret += query(R[id], m + 1, e, qs, qe);
		return ret;
	}
} pseg;
struct RangeDistinct {
	int tree[MAXN], N;
	map<int, int> pre;
	vector<int> ends[MAXN];
	int count(int l, int r) {
		if (l > r) return 0;
		return pseg.query(tree[l], 1, N, l, r);
	}
	void init(int N, int *A) {
		this->N = N;
		for (int i = 1; i <= N; ++i) {
			ends[pre[A[i]] + 1].push_back(i);
			pre[A[i]] = i;
		}
		pseg.build(0, 1, N);
		for (int i = 1; i <= N; ++i) {
			tree[i] = tree[i - 1];
			for (int e : ends[i]) {
				tree[i] = pseg.update(tree[i], 1, N, e);
			}
		}
	}
} distinct;
int main() {
	int n, q;
	scanf("%d%d", &n, &q);
	vector<int> A(n + 1);
	for (int i = 0; i < n; ++i) scanf("%d", &A[i + 1]);
	distinct.init(n, A.data());
	while (q--) {
		int l, r;
		scanf("%d%d", &l, &r);
		printf("%d\n", distinct.count(l, r));
	}
}


Measured memory_bytes: 208820
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define inf 1e9+1

void d_m_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input_dp.txt", "r", stdin);
	freopen("output_dp.txt", "w", stdout);
#endif
}
#define MAX 3000
int dp[MAX + 1][MAX + 1];

string compute_lcs(string& s, string& t, int len)
{
	string LCS;
	int i = 0, j = 0;

	while (len > 0)
	{
		if (s[i] == t[j])
		{
			LCS.push_back(s[i]);
			i++; j++;
			len--;
		}
		else
		{
			if (dp[i + 1][j] > dp[i][j + 1])
				i++;
			else j++;
		}
	}

	return LCS;
}

int lenLCS(string& s, string& t, int i, int j)
{
	if (i >= s.length() or j >= t.length())
		return 0;

	if (dp[i][j] != -1)
		return dp[i][j];

	if (s[i] == t[j])
		return dp[i][j] = 1 + lenLCS(s, t, i + 1, j + 1);
	else
	{
		int op1 = lenLCS(s, t, i + 1, j);
		int op2 = lenLCS(s, t, i, j + 1);

		return dp[i][j] = max(op1, op2);
	}
}

string solve(string s, string t)
{
	memset(dp, -1, sizeof dp);
	int len = lenLCS(s, t, 0, 0);
	string ans = compute_lcs(s, t, len);

	return ans;
}


int32_t main()
{
	d_m_c();

	string s, t;
	cin >> s >> t;

	cout << solve(s, t);


	return 0;
}

Measured memory_bytes: 74356
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second
#define Mat vector<vector<ll>>
#define Arr vector<ll>
#define Matd vector<vector<ld>>
#define Arrd vector<ld>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    Arr a(n);
    forn(i, n) cin >> a[i];
    ll ans = 0;
    fori(i, 1, n - 1) if (a[i - 1] < a[i] && a[i] < a[i + 1] || a[i - 1] > a[i] && a[i] > a[i + 1]) ans++;
    cout << ans << endl;
    return 0;
}

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

using lint = long long;

vector<int> lp, primes, pw;
vector<lint> cnt;
void run_sieve(int n) {
	lp.resize(n+1); cnt.resize(n+1); pw.resize(n+1);
	int p;
	for (int i = 0; i <= n; ++i) {
		cnt[i] = 2;
		pw[i] = 1;
		lp[i] = i;
	}
	cnt[1] = 1;
	for (int i = 2; i <= n; ++i){
		if (lp[i] == i)  primes.push_back(i);
		for (int j = 0; j < primes.size() && (p = primes[j]*i) <= n; ++j) {
			lp[p] = primes[j];
			cnt[p] = 2 * cnt[i];
			pw[p] = 1;
			if (i % primes[j] == 0) { 
				pw[p] = pw[i] + 1;
				cnt[p] = cnt[i]/pw[p] * (pw[p] + 1);
				break;
			}
		} 
	}	
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    run_sieve(n+10);
    lint res = 0;
    for (int i = 1; i <= n; ++i) {
    	res += i * cnt[i];
    }
    cout << res << '\n';
}

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

using namespace std;

int main(){
  string s, ans;
  cin >> s;
  
  for (auto &c:s) {
    if (c=='0') ans+='0';
    else if (c=='1') ans+='1';
    else {
      if (ans.size()>0) ans.pop_back();
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
  ll x,y,z;
  cin>>x>>y>>z;
  ll k=0;
  while(x>=y*k+z*(k+1))k++;
  cout<<k-1<<endl;
}

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

typedef long long ll;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n,m,k,a,i;
  cin>>n>>m;
  int ara[m+5];
  memset(ara,0,sizeof(ara));
  for(i=0;i<n;i++)
  {
    cin>>k;
    while(k--)
    {
      cin>>a;
      ara[a]++;
    }
  }
  int cnt=0;
  for(i=1;i<=m;i++)
  {
    if(ara[i]==n)
    {
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<stdio.h>
#include<algorithm>
#define ll long long
using namespace std;
const int N=1000100;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
int a[N],n,k;
ll sum1[N],sum2[N];
int main(){
    n=read();k=read();ll ans=0;
    for (int i=1;i<=n;++i) {
        a[i]=read(),sum1[i]=sum1[i-1]+a[i];sum2[i]=sum2[i-1];if (a[i]>0) sum2[i]+=a[i];
    }ans=max(ans,sum1[n]);
    for (int i=1;i<=n-k+1;++i){
        ll tmp1=sum2[i-1],tmp2=sum2[n]-sum2[i+k-1];
        ans=max(ans,tmp1+tmp2);ans=max(ans,tmp1+tmp2+sum1[i+k-1]-sum1[i-1]);
    }printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 7040
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray(), t = sc.next().toCharArray();
		Arrays.sort(s);
		Arrays.sort(t);
		String s1 = new String(s);
		String t1 = new String(new StringBuilder(new String(t)).reverse().toString());
		System.out.println(s1.compareTo(t1) < 0 ? "Yes":"No");
	}
}


Measured memory_bytes: 23252
#include<stdio.h>
int main(void)
{
  char ch[1200];
  int count[26],num,i;
  for(i=0;i<26;i++) count[i]=0;
  i=0;
  while(scanf("%c",&ch[i])!=EOF)
  {
    if('a'<=ch[i]&&ch[i]<='z')
    {
      num=ch[i]-'a';
      count[num]++;
    }
    else if('A'<=ch[i]&&ch[i]<='Z')
    {
      num=ch[i]+32-'a';
      count[num]++;
    }
  }
  for(i=0;i<26;i++)
    printf("%c : %d\n",'a'+i,count[i]);
  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n, k;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> f(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++)
    {
        cin >> f[i];
    }

    ll INF = 1e18;
    ll h = INF;
    ll l = -1;
    sort(a.begin(), a.end());
    sort(f.begin(), f.end());
    reverse(f.begin(), f.end());
    ll ans = 0;
    while(h - l > 1)
    {
        ll mid = (h + l) >> 1;
        ll count = k;
        ll tmp = 0;
        ll flag = true;
        for(int i = 0; i < n; i++)
        {
            ll ac = a[i];
            ll fc = f[i];
            if(ac * fc > mid)
            {
                ll bound = mid / fc;
                if(count < ac - bound)
                {
                    flag = false;
                    break;
                }
                else
                {
                    count -= ac-bound;
                }
            }
        }
        if(flag)
        {
            h = mid;
        }
        else
        {
            l = mid;
        }
    }
    cout << h << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>

using namespace std;

int gcd(int a, int b){
  while (a >= 1 && b >= 1){
   if (a == b){
     return a;
    }
   else if (a > b){
    a -= b;
   }
   else if (a < b){
    b -=a;
   }
   else if (a == 1 || b == 1){
    return 1;
  }
 }
}
int main(){
  int a, b;
  cin >> a >> b;

  cout << (long long)a*b/gcd(a, b) << "\n";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
 
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;
 
#define ll  long long
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define ppi pair<pii,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)
 
#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)
 
#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount
#define die() return 0;
#define sz() size() 


 
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define MD          1000000007
#define M 			100011
#define LN             14
#define fftmod      998244353
#define EPS         (double)1e-10
 
long long  md=MD;
ll inf=1e18;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
 
inline ll exp(ll a,ll b){if(a==0&&b==0)return 1ll;if(a==0)return 0ll;ll r=1LL;while(b>0){if(b&1){r=(r%md)*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}
 
using cd=complex<double>;
const double PI=acos(-1);
 
inline ll rand(ll l,ll r){
    return l+rng()%(r-l+1);
 
}

vii g[M],w[M];
ll a[M];
ll go(ll u,ll p){
	for(ll i=0;i<g[u].sz();++i){
		ll v=g[u][i],wt=w[u][i];
		if(v==p)continue;
		if(wt%2==0)a[v]=a[u];
		else a[v]=!a[u];
		go(v,u);

	}
}
int main(){
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
 
   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p;string s1,s2;ll q;ll x,y;
    cin>>n;
    lp(1,n-1){
    	cin>>x>>y>>z;
    	g[x].pb(y);g[y].pb(x);
    	w[x].pb(z);w[y].pb(z);
    }
    go(1,0);
    lp(1,n)cout<<a[i]<<"\n";


}



Measured memory_bytes: 14848
def isok(A, X, k):
    cnt = 0
    for a in A:
        cnt += (a+X-1)//X-1
    return True if cnt <= k else False


N, K = map(int, input().split())
A = list(map(int, input().split()))

# 答えを二分探索
left = 0 # 条件をみたさない
right = 10**9 # みたす

while right-left > 1:
    mid = left + (right-left)//2
    if isok(A, mid, K):
        right = mid
    else:
        left = mid

print(right)


Measured memory_bytes: 30660
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
struct Edge {
    int to, cost;
    Edge(int to, int cost): to(to), cost(cost) {}
};

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<Edge>> AdjList;
AdjList graph;

const int INF = 100000000;

int N, M;
LL dp[100010];
int arr[100010];
int main() {
    //cout << fixed << setprecision(15);
    cin >> N >> M;

    REP(i, 100010) arr[i]=true;
    REP(i, M){
        int a = readInt();
        arr[a] = false;
    }

    dp[0] = 1;

    for(int i=0; i<=N; ++i){
        if(arr[i+1]) dp[i+1] += dp[i];
        if(arr[i+2]) dp[i+2] += dp[i];

        dp[i+1] %= MOD;
        dp[i+2] %= MOD;
    }

    cout << dp[N] << endl;


}

Measured memory_bytes: 1408
#include<stdio.h>
#define SIZE 100000
void Swap(int a[],int b[],int i,int j);
void Qsort(int a[],int b[],int bottom,int up);

int main(){
  int n,m,a[SIZE],b[SIZE];
  int i;
  int x,counter=1;
  scanf("%d%d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d%d",&a[i],&b[i]);
  }
  Qsort(a,b,0,m-1);
  x=b[0]-1;
  for(i=1;i<m;i++){
    if(x<a[i]){
      counter++;
      x=b[i]-1;
    }
  }
  printf("%d\n",counter);


  return 0;
}

void Swap(int a[],int b[],int i,int j){
  int temp;
  temp=a[i];
  a[i]=a[j];
  a[j]=temp;
  temp=b[i];
  b[i]=b[j];
  b[j]=temp;
}  

void Qsort(int a[],int b[],int bottom,int up){
  int i,j,k;
  int pivot;
  
  i=bottom;
  j=up;
  pivot=b[(bottom+up+1)/2];
  
  while(1){
    while(b[i]<pivot) i++; //左からpivot以上をサーチ
    while(b[j]>pivot) j--; //右からpivot以下をサーチ
    if(i>=j) break; //左が右と交差したら終了
    
    Swap(a,b,i,j);
    i++;
    j--;
  }
  if(bottom<i-1) Qsort(a,b,bottom,i-1); //分割した左の要素が2つ以上なら左でQsort
  if(i<up) Qsort(a,b,i,up); //分割した右の要素2つ以上なら右でsort
}


Measured memory_bytes: 896
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;

const ll mod197 = 1000000007LL;
const ll INF = 200LL * 200 * 100000 + 10;

const double PI11 = 3.14159265359;

// (a ^ b) % mod
ll powMod(ll x, ll k, ll m) {
	if (k == 0)     return 1;
	if (k % 2 == 0) return powMod(x*x % m, k / 2, m);
	else            return x*powMod(x, k - 1, m) % m;
}

int main() {

	int h, w, d;
	cin >> h >> w >> d;

	char arr[2][2] = {'R','Y','G','B'};

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			//cout << i + j << " " << i - j + w << endl;

			cout << arr[(i + j)/d % 2][(i - j + w)/d % 2];

		}
		cout << endl;
	}


	return 0;
}



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

#define mod 1000000007

int main() {
    int N;
    cin >> N;
    vector<int>A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    ll ans = 1;
    multiset<int>se{0, 0, 0};
    for (int i = 0; i < N; ++i) {
        ans *= se.count(A[i]);
        if(se.count(A[i]) == 0){
            cout << 0 << "\n";
            return 0;
        }
        ans %= mod;
        auto iter = se.lower_bound(A[i]);
        se.erase(iter);
        se.insert(A[i]+1);
    }
    cout << ans << "\n";
    return 0;
}

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

int main() {
long long N,A,B,C;
  int flag = 1;
  cin >> N >> A >> B >> C;
  vector<string>s(N);
  vector<string>S(N);
  for(int a = 0;a < N;a++)cin >> s[a];
for(int a = 0;a < N;a++){
  if(s[a] == "AB"){
   if(A == 0&&B == 0){
     flag = 0;
     break;
   }else if(A == 0){
     A++;
     B--;
     S[a] = "A";
   }else if(B == 0){
     A--;
     B++;
     S[a] = "B";
   }else if(A == 1&&B == 1&&C == 0){
     if(a == N - 1){
       A--;
     B++;
     S[a] = "B";
     }else{
      if(s[a + 1] == "BC"){
        A--;
     B++;
     S[a] = "B";
      }else{
        A++;
     B--;
     S[a] = "A";
      }
     }
   }else if(A >= B){
    A--;
     B++;
     S[a] = "B";
   }else{
     A++;
     B--;
     S[a] = "A";
   }
  }
  if(s[a] == "AC"){
   if(A == 0&&C == 0){
     flag = 0;
     break;
   }else if(A == 0){
     A++;
     C--;
     S[a] = "A";
   }else if(C == 0){
     A--;
     C++;
     S[a] = "C";
   }else if(A == 1&&B == 0&&C == 1){
     if(a == N - 1){
       A--;
     C++;
     S[a] = "C";
     }else{
      if(s[a + 1] == "BC"){
        A--;
     C++;
     S[a] = "C";
      }else{
        A++;
     C--;
     S[a] = "A";
      }
     }
   }else if(A >= C){
    A--;
     C++;
     S[a] = "C";
   }else{
     A++;
     C--;
     S[a] = "A";
   }
  }
  if(s[a] == "BC"){
   if(B == 0&&C == 0){
     flag = 0;
     break;
   }else if(B == 0){
     B++;
     C--;
     S[a] = "B";
   }else if(C == 0){
     B--;
     C++;
     S[a] = "C";
   }else if(A == 0&&B == 1&&C == 1){
     if(a == N - 1){
       B--;
     C++;
     S[a] = "C";
     }else{
      if(s[a + 1] == "AB"){
        B++;
     C--;
     S[a] = "B";
      }else{
        B--;
     C++;
     S[a] = "C";
      }
     }
   }else if(B >= C){
    B--;
     C++;
     S[a] = "C";
   }else{
     B++;
     C--;
     S[a] = "B";
   }
  }
}
  if(flag == 0){
   cout << "No" << endl; 
  }else{
    cout << "Yes" << endl; 
    for(int a = 0;a < N;a++)cout << S[a] << endl; 
  }
}

Measured memory_bytes: 9592
//* AuThOr GaRyMr *//
//Codeforces ID: GaryMr
//Atcoder ID: Gary
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
vector<int> each[100000+10];
int dis1[100000+10],dis2[100000+10];
void dfs(int now,int p,int col,int diss){
	if(col) dis2[now]=diss;
	else dis1[now]=diss;
	for(auto it: each[now]){
		if(it!=p) dfs(it,now,col,diss+1);
	}
}
int main(){
	int n;
	cin>>n;
	rep(i,n-1){
		int xi,yi;
		scanf("%d %d",&xi,&yi);
		each[xi].PB(yi),each[yi].PB(xi);
	}
	dfs(1,-1,0,1),dfs(n,-1,1,1);
	int tot1,tot2;
	tot1=tot2=0;
	rb(i,1,n){
		if(dis1[i]<=dis2[i]) tot1++;
		else tot2++;
	}
	if(tot1>tot2) cout<<"Fennec";
	else cout<<"Snuke";
	return 0;
}


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

const int M = 1e9 + 7;
long long dp[100100][4];

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

    for (int i = s.size(); i >= 0; i--) {
        for (int j = 3; j >= 0; j--) {
            if (i == s.size()) {
                dp[i][j] = (j == 3 ? 1 : 0);
            } else {
                dp[i][j] = dp[i + 1][j] * (s[i] == '?' ? 3LL : 1LL);
                if (j < 3 && (s[i] == '?' || s[i] == "ABC"[j])) {
                    dp[i][j] += dp[i + 1][j + 1];
                }
                dp[i][j] %= M;
            }
        }
    }
    cout << dp[0][0] << endl;
}

Measured memory_bytes: 3584
import java.util.*;
import java.lang.*;

public class Main{

    public static long solve(long n , String[] arr){//healt , str
        HashSet<String> set = new HashSet<>();
        long sum = 0;
        for(int i = 0 ; i < arr.length ; i++){
            if(!set.contains(arr[i])){
                sum++;
                set.add(arr[i]);
            }
        }

        return sum;
    }

    public static void gora(){
        Scanner scn = new Scanner(System.in);

        // long test = scn.nextLong();

        long n = scn.nextLong();

        String[] arr = new String[(int)n];
        // long b = scn.nextLong();


        // long c = scn.nextLong();

        // long d = scn.nextLong();
        // long arr[] = new long[n];
        scn.nextLine();
        for(int i = 0 ; i < arr.length ; i++){
            arr[i] = scn.nextLine();
        }

        System.out.println(solve(n , arr));
    }

    public static void main(String args[]){
        gora();
    }
}




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

int main(){
  int d,g;
  cin>>d>>g;
  vector<int> p(d),c(d);
  for (int i=0;i<d;i++){
    int P,C;
    cin>>P>>C;
    p.at(i)=P;
    c.at(i)=C;
  }
  int problems=100000;
  for (int i=0;i<(1<<d);i++){
    int point=0,cnt=0,rest_max=-1;
    for (int j=0;j<d;j++){
      if (i&(1<<j)){
        point+=(j+1)*100*p.at(j)+c.at(j);
        cnt+=p.at(j);
      }else{
        rest_max=j;
      }
    }
    if (point>=g){
      problems=min(problems,cnt);
    }else{
      int s1=(rest_max+1)*100;
      int need=(g-point-1)/s1+1;
      if (need<p.at(rest_max)){
        cnt+=need;
        problems=min(problems,cnt);
      }else{
        continue;
      }
    }
  }
  cout<<problems<<endl;
}
      

Measured memory_bytes: 256
#include<iostream>

int N;
int a[10];

int main()
{
	std::cin >> N;
	
	while( N-- )
	{
		for( int i = 0; i < 10; i++ )
			std::cin >> a[i];

		int lm = 0, rm = 0;

		bool f = true;

		for( int i = 0; i < 10; i++ )
		{
			if( a[i] > lm )
				lm = a[i];
			else if( a[i] > rm )
				rm = a[i];
			else 
				f = false;
		}

		if( f ) 
			std::cout << "YES" << std::endl;
		else
			std::cout << "NO" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1152
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

#[allow(unused_macros)]
macro_rules! invec {
    ( $ t : ty ) => {{
        let mut s = String::new();
        match std::io::stdin().read_line(&mut s) {
            Ok(0) => Vec::<$t>::new(),
            Ok(n) => s
                .trim()
                .split_whitespace()
                .map(|s| s.parse::<$t>().unwrap())
                .collect::<Vec<$t>>(),
            Err(_) => Vec::<$t>::new(),
        }
    }};
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (n, m) = input!(usize, usize);

    let mut keys = Vec::with_capacity(m);

    for _ in 0..m {
        let (a, b) = input!(u64, usize); 
        let targets = invec!(usize);
        let mut s = 0;
        for t in targets {
            s += 1 << (t - 1);
        }
        keys.push((a, s));
    }

    let mut dp = vec![1_000_000_000; 1 << n];
    dp[0] = 0;

    for s in 0..(1 << n) {
        for key in &keys {
            let t = s | key.1;
            let cost = dp[s] + key.0;
            // println!("s = {} cost = {}", s, cost);
            dp[t] = std::cmp::min(cost, dp[t]);
        }
    }

    let ans = dp[(1 << n) - 1];
    if ans == 1_000_000_000 {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}

fn main() {
    solve();
}


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


using namespace std;

const int maxn=5000*5000+233;
long long f[maxn];
void add(int w,int c)
{
	if(c<=0) return;
	for(int i=0;i<=5000*5000-w;i++)
	{
		f[i+w]=max(f[i+w],f[i]+c);
	}
}
int main()
{
	int n,ga,gb,sa,sb,ba,bb;
	cin>>n>>ga>>sa>>ba>>gb>>sb>>bb;
	memset(f,0,sizeof(f));
	add(ga,gb-ga);
	add(sa,sb-sa);
	add(ba,bb-ba);
	n=n+f[n];
	memset(f,0,sizeof(f));
	add(gb,ga-gb);
	add(sb,sa-sb);
	add(bb,ba-bb);
	cout<<n+f[n]<<endl;
	return 0;
}


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

using namespace std;
const int INF=1e9+5;
typedef long long ll;
const int MOD=1e9+7;
int main(){
	string s;
	cin>>s;
	if(s=="ARC")
		cout<<"ABC\n";
	else 
	cout<<"ARC\n";
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include<algorithm>

using namespace std;

long long int num[200001];
long long int n,k,h;
long long int i;
long long int ans=0;

int main()
{
    cin>>n>>k;
    for(i=0;i<n;i++)
        cin>>num[i];
    sort(num,num+n);
    if(k>=n)
    {
        cout<<0<<endl;
        return 0;
    }
    else
    {
        for(i=0;i<n-k;i++)
            ans+=num[i];
        cout<<ans<<endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> a(51,1),p(51,1);

ll f(ll n,ll x)
{
  if(x==0) return 0;
  else if(x==a[n]) return p[n];
  else if(x<=a[n-1]+1)
  {
    return f(n-1,x-1);
  }
  else if(x==a[n-1]+2)
  {
    return p[n-1]+1;
  }
  else
  {
    return p[n-1]+1+f(n-1,x-a[n-1]-2);
  }
}

int main()
{
  ll n,x;
  cin>>n>>x;
  for (int i = 1; i < 51; ++i)
  {
    a[i]=2*a[i-1]+3;
    p[i]=2*p[i-1]+1;
  }
  cout<<f(n,x)<<endl;
}

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

int main() {
    int N;
    string S;
    cin >> N >> S;
    for (int i = 0; i < S.length(); i++){
        if((S.at(i) + N) > 'Z') S.at(i) -= 26;
        S.at(i) += N;
    }
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
 int w;
 int hundou;


 while(scanf("%d",&w)!=EOF){

  hundou=1;

  while(w!=0){
   if(w==1)printf("%d\n",hundou);
   else if( (w & 1)==1 )printf("%d ",hundou);
   w=w>>1;
   hundou*=2;
  }

 /* printf("\b\n");*/

 }

return 0;
}


Measured memory_bytes: 1940
#include<stdio.h>
int main(void){
  int S;
  int h;
  int m;
  int s;

  scanf("%d",&S);

  h = S/(60*60);
  m = (S-h*60*60)/60;
  s = S-h*60*60-m*60;

  printf("%d:%d:%d\n",h,m,s);

  return 0;
}

Measured memory_bytes: 592
while True:
    cou = 0
    n,x = map(int,input().split())
    if n==0 and x==0:
        break
    for i in range(1,x//2):
        for j in range(i+1,x//2):
            k = x - i - j
            if i<=n and j<=n and k<=n and k>j:
                cou += 1
    print(cou)
                


Measured memory_bytes: 5592
#include <stdio.h>

int main(void) {
  double a, b, c, d, e, f;
  while(scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f) != EOF) {
    double ee = e / b, dd = d / a;
    double ax = a * ee, cx = c * ee;
    printf("%.3f ", (cx - f) / (ax - d) == -0 ? 0 : (cx - f) / (ax - d));
    b *= dd, c *= dd;
    printf("%.3f\n", (c - f) / (b - e) == -0 ? 0 : (c - f) / (b - e));
  }
  return 0;
}


Measured memory_bytes: 2512
#include<bits/stdc++.h>
using namespace std ;
int main()
{
  int n,k;
  cin>>n>>k;
  for(int i=n-1;i>=1;i--)
    cout<<k-i<<' ';
  cout<<k<<' ';
  for(int i=1;i<=n-1;i++)
    cout<<k+i<<' ';
}


Measured memory_bytes: 256
import sys
S = input()
Q = int(input())
key = 1

for i in sys.stdin:
    if i[0] == '0':
        break

    if i[0] == '1':
        key = -key
    
    elif key == 1:
        if i[2] == '1':
            S = i[4] + S
        else:
            S = S + i[4]

    else:
        if i[2] == '2':
            S = i[4] + S
        else:
            S = S + i[4]


print(S[::key])

Measured memory_bytes: 9904
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

        while ((line = br.readLine()) != null) {
            String[] input = line.split(" ");
            int s = 0;
            int a = Integer.parseInt(input[0]);
            int b = Integer.parseInt(input[1]);
            int n = Integer.parseInt(input[2]);

            int q = a;
            q -= (q / b) * b;

            for (int i = 0; i < n; i++) {
                s += (q * 10) / b;
                q = (q * 10) % b;
                if (q == 0)
                    break;
            }

            System.out.println(s);
        }
    }
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pn(n) cout << (n) << endl;

int main() {
	int n;
	cin >> n;
	pn(n*n*n)
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;

int main(){
	int a, b, c;
	int cnt = 0;
	cin >> a >> b >> c;
	if (a != b) cnt++;
	if (b != c) cnt++;
	if (a != c) cnt++;
	if (cnt == 0){
		cnt = 1;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * author: Behradm
 * Created: 2020.09.13 16:25:12
 * In The Name of God
**/
#include <bits/stdc++.h>

using namespace std;

int main() {   
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long best = -1e9;
  best = b * d;
  best = max(best, a * c);
  best = max(best, a * d);
  best = max(best, b * c);
  if ((0 >= a && 0 <= b) || (0 >= c && 0 <= d))
    best = max(best, 0LL);
  cout << best << '\n';
  return 0;
}


Measured memory_bytes: 3684
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#define ll long long 
#define PI 3.14159265358979323846
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(x,n) for(ll x=1;x<(ll)n+1;x++)
using namespace std;

int main() {
	ll N, X, T;
	ll ans;
	cin >> N >> X >> T;
	if (N % X == 0) ans = (N / X) * T;
	else ans = ((N / X) + 1) * T;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cstdlib>
#include <string>
#include <cassert>
using namespace std;

struct Node {
    int num;
    int leaf;
    Node *left,*right;
};

int p,inm;
Node* parse(string &s) {
    Node *ret = new Node();
    if(isdigit(s[p])) {
        ret->num = s[p] - '0' -1;
        ret->left = ret->right = NULL;
        p++;
        return ret;
    }else if(s[p] == '(') {
        p++;
        ret->num = inm++;
        ret->left = parse(s);
        if(s[p] == ' ') p++;
        ret->right = parse(s);
        if(s[p] == ')') p++;
        return ret;
    }

    assert(false);
}

void track(Node *v,int n,int m) {
    if(v->right == NULL && v->left == NULL && v->num == n) {
        v->leaf = m;
        return;
    }else if(v->right == NULL && v->left == NULL) {
        return;
    } else {
        track(v->left,n,m);
        track(v->right,n,m);
    }
}

int check(string &s,Node *root) {
    if(root->left == NULL && root->right == NULL) return root->leaf;
    int l = check(s,root->left);
    int r = check(s,root->right);

//    cout<<root->num<<" "<<l<<" "<<r<<endl;
    if(s[root->num] == 'A') return l&r;
    else if(s[root->num] == 'O') return l|r;
    else if(s[root->num] == 'X') return l^r;
    assert(false);
}

int ok;
void dfs(int d,string &s,Node *root) {
    if(d == inm) {
        int k = check(s,root);
//        cout<<s<<" "<<k<<endl;
        if(k == 15) ok++;
        return;
    }

    s[d] = 'A';
    dfs(d+1,s,root);
    s[d] = 'O';
    dfs(d+1,s,root);
    s[d] = 'X';
    dfs(d+1,s,root);
}

int main() {
    string s;
    int n,l,m;
    while(getline(cin, s)) {
        if(s == "END") break;
        ok = p = inm = 0;
        Node *root = parse(s);
        cin>>n;

        for(int i=0; i<n; ++i) {
            m = 0;
            for(int k=0; k<4; ++k) {
                cin>>l;
                if(l == 1) {
                    m |= (1<<k);
                }
            }
            track(root,i,m);
        }


        string s(inm,'.');
        dfs(0,s,root);
        cout<<ok<<endl;
        cin.ignore();
    }
}

Measured memory_bytes: 0
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
template<typename V> typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  vvi t(10, vi(10));
  int x, y, s;
  char gomiiiiiii;
  while (cin >> x >> gomiiiiiii >> y >> gomiiiiiii >> s) {
    t[x][y]++;
    switch (s) {
      case 3:
        if (x > 1) t[x - 2][y]++;
        if (x < 8) t[x + 2][y]++;
        if (y > 1) t[x][y - 2]++;
        if (y < 8) t[x][y + 2]++;
      case 2:
        if (x > 0 && y > 0) t[x - 1][y - 1]++;
        if (x > 0 && y < 9) t[x - 1][y + 1]++;
        if (x < 9 && y > 0) t[x + 1][y - 1]++;
        if (x < 9 && y < 9) t[x + 1][y + 1]++;
      case 1:
        if (x > 0) t[x - 1][y]++;
        if (x < 9) t[x + 1][y]++;
        if (y > 0) t[x][y - 1]++;
        if (y < 9) t[x][y + 1]++;
    }
  }
  int hai = 0, yarudake = 0;
  rep(i, 10) rep(j, 10) {
    hai += !t[i][j];
    cmax(yarudake, t[i][j]);
  }
  cout << hai << '\n'
       << yarudake << endl;
}

Measured memory_bytes: 3048
#include <iostream>
using namespace std;
using ll = long long;
int main(void) {
    ll A,B,K; cin >> A >> B >> K;
    ll ans_A = 0, ans_B=0;
    if(A+B < K) {
        ans_A = 0; 
        ans_B = 0;
    }
    else if(A < K) {
        ans_A = 0; 
        ans_B = B - (K - A);
    }
    else {
        ans_A = A - K;
        ans_B = B;
    }
    cout << ans_A << " " << ans_B << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define mp make_pair
 
typedef long long ll;
typedef unsigned long long int ull;
typedef long double ld;
 
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<string, string> ss;
typedef pair<int, ss> iss;
 
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pair<int, pii>> vpiii;
 
typedef map<string, string> mss;
typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, ll> mill;
typedef map<int, vpii> mivpii;

const int MAXN = 1e5;
const int MOD = 1e9 + 7;
const int COLORS = 2;
const int B = 0;
const int W = 1;

int dp[MAXN + 1][COLORS];
vi g[MAXN + 1];

void fast_io() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

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

void mul(int &a, int b) {
	a = (1LL * a * b) % MOD;
}

void dfs(int u, int p) {
	dp[u][B] = dp[u][W] = 1;
	for(int v : g[u]) {
		if(v != p) {
			dfs(v, u);
			mul(dp[u][B], dp[v][W]);
			mul(dp[u][W], dp[v][B] + dp[v][W]);
		}
	}
}

int main() {
	fast_io();
//	freopen("input/DP_P.txt", "r", stdin);
	
	int n, u, v;
	cin >> n;
	for(int i = 1; i < n; i++) {
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}
	dfs(1, 1);

	int ans = dp[1][B] + dp[1][W];
	if(ans >= MOD) ans -= MOD;
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 13440
import sys
readline = sys.stdin.readline
write = sys.stdout.write

class KMP:
    def __init__(self, W):
        L = len(W)
        T = [0] * (L+1)
        T[0] = -1
        c = 0
        for p in range(1, L):
            if W[p] == W[c]:
                T[p] = T[c]
            else:
                T[p] = c
                c = T[c]
                while c >= 0 and W[p] != W[c]:
                    c = T[c]
            c += 1
        T[L] = c
        self.T = T
        self.W = W

    def search(self, S):
        W = self.W; T = self.T
        R = []
        LS = len(S); LW = len(W)
        # S[i], W[j]
        i = j = 0
        while i < LS:
            if S[i] == W[j]:
                i += 1; j += 1
                if j == LW:
                    R.append(i-j)
                    j = T[j]
            else:
                j = T[j]
                if j < 0:
                    i += 1
                    j += 1
        return R

def solve():
    T = readline().strip()
    P = readline().strip()
    kmp = KMP(P)
    res = kmp.search(T)
    for p in res:
        write("%d\n" % p)
solve()


Measured memory_bytes: 5584
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	int n; cin>>n;
	vl a(n);
	rep(i,0,n)cin>>a[i];
	ll memo=0;
	ll now=1000;
	ll kabu=0;
	vector<bool> p(n);
	for(ll i=n-1;i>=1;--i){
		if(a[i-1]<a[i])p[i-1]=true;
	}
	rep(i,0,n){
		if(p[i]){
			ll j=now/a[i];
			kabu+=j;
			now-=j*a[i];
		}
		else{
			now+=kabu*a[i];
			kabu=0;
		}
	}
	cout<<now<<endl;
	return 0;
}


Measured memory_bytes: 3604
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll fun(string s)
{
	string r = s;
	reverse(s.begin(), s.end());
	return r==s;
}

int solve()
{
	string s;cin>>s;
	ll n = sz(s);
	if(fun(s))
	{
		string r = "";
		rep(i,0,(n-1)/2) r+=s[i];
		if(fun(r))
		{
			r="";
			rep(i,(n+3)/2-1,n) r+=s[i];
			if(fun(r))
			{
				cout<<"Yes\n";
				return 0;
			}
		}
	}
	cout<<"No\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	constexpr long long int MOD = 1000000007;
	int n; std::cin >> n;
	std::vector<long long int> numbers(n); for (auto& a : numbers) std::cin >> a;
	std::vector<int> zero_count(n, 0), one_count(n, 0);
	long long int result = 0;
	for (long long int digit = 0LL; digit < 60LL; ++digit) {
		std::fill(zero_count.begin(), zero_count.end(), 0);
		std::fill(one_count.begin(), one_count.end(), 0);
		for (auto i = 0; i < n; ++i) {
			if (i > 0) {
				zero_count[i] += zero_count[i - 1];
				one_count[i] += one_count[i - 1];
			}
			if ((numbers[i] & (1LL << digit)) == 0) {
				zero_count[i]++;
				result = (result + (1LL << digit) % MOD * one_count[i] % MOD) % MOD;
			}
			else {
				one_count[i]++;
				result = (result + (1LL << digit) % MOD * zero_count[i] % MOD) % MOD;
			}
		}
	}
	std::cout << result << std::endl;
}

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

int main(){
    int a;
    cin >> a;
    int h,m,s;
    h=a/3600;
    m=(a%3600)/60;
    s=(a%3600)%60;
    cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if ((a<c && b>c) || (a>c && b<c)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 384