akhauriyash/Code-Regression huggingface dataset:
//Pythonで解いたためこちらにはコードなし

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.Iterator;

public class Main {

	static BufferedReader reader;
	final static boolean MODE_DEBUG = false;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		int[] NM = readLineInt();
		int N = NM[0];
		String[] ss = new String[N];
		for(int k=0;k<N;k++) {
			ss[k]=readLine()[0];
		}
		int cnt = N;
		Arrays.sort(ss);
		for(int i=0;i<N-1;i++) {
			if(ss[i].equals(ss[i+1])) {
				cnt--;
			}
		}
		print(cnt);
	}
	
	//functions here
	//note that all methods should be STATIC

	private static boolean cps(String s1, String s2) {
		char[] s1c = s1.toCharArray();
		char[] s2c = s2.toCharArray();
		for(int i=0;i<s1c.length;i++) {
			if(i>=s2c.length) {return false;}
			if(s1c[i]>s2c[i]) {return false;}
			else if(s1c[i]<s2c[i]) {return true;}
		}
		return true;
	}

	private static <T> int arraySearch(T needle, T[] heystack) {
		for(int i=0;i<heystack.length;i++) {
			if(needle.equals(heystack[i])) {
				return i;
			}
		}
		return -1;
	}
	private static int[] sort(int[] base) {
		int[] copy = array_copy(base);
		Arrays.sort(copy);
		return copy;
	}
	private static int[] array_copy(int[] base) {
		int[] copy = new int[base.length];
		for(int i=0;i<base.length;i++) {
			copy[i] = base[i];
		}
		return copy;
	}
	private static int[] asArray(ArrayList<Integer> ints) {
		int[] intlist = new int[ints.size()];
		for(int i=0;i<intlist.length;i++) {
			intlist[i] = ints.get(i);
		}
		return intlist;
	}
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static int[] readLineInt(){
		try{
			String[] s = readLine();
			int[] ints = new int[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Integer.parseInt(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static byte[] readLineByte(){
		try{
			String[] s = readLine();
			byte[] bytes = new byte[s.length];
			for(int i=0;i<bytes.length;i++) {
				bytes[i] = Byte.parseByte(s[i]);
			}
			return bytes;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static char[] readLineChar(){
		try{
			String[] s = readLine();
			char[] chars = new char[s.length];
			for(int i=0;i<chars.length;i++) {
				chars[i] = (char)Integer.parseInt(s[i]);
			}
			return chars;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
	private static void printd(Object o){
		if(MODE_DEBUG)System.err.println(o);
	}
	private static void printd(){
		if(MODE_DEBUG)System.err.println();
	}
}


Measured memory_bytes: 62132
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int l=0,r,ans=0;
	string s;
	cin >> s;
	r = s.l_ength(); --r;
	while(r>l){
		if(s[l]!=s[r]){
			++ans;
		}
		++l; --r;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout<<endl
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

int main()
{
	int n; cin >> n;
	string s, t; cin >> s >> t;
	rep(i, n)cout << s[i] << t[i];
	el;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <time.h>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <iostream>
#include <bitset>
#include <algorithm>
using namespace std;
#define MP make_pair
#define PB push_back
#define ms(a,b) memset((a),(b),sizeof(a))
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<Pii> Vii;
const int inf = 0x3f3f3f3f;
const LL INF = (1uLL << 63) - 1;
const LL mod = 1000000007;
const int N = 150 + 5;
const double Pi = acos(-1.0);
const int maxn = 100005;
using namespace std;
char s[maxn];
int main() {
#ifdef local
    freopen("in","r",stdin);
#endif
    cin>>s;
    int len = strlen(s);
    int sf = len - 2;
    if(s[0] == s[len - 1]){
        sf++;
        if(sf&1){
            cout<<"First"<<endl;
        }
        else cout<<"Second"<<endl;
    }
    else {
        if(sf&1){
            cout<<"First"<<endl;
        }
        else cout<<"Second"<<endl;
    }
}


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

int main() {
    int sum = 0;
    int N;
    cin >> N;
    {
        int l, r;
        for (int i = 0; i < N; i++) {
            cin >> l >> r;
            sum += r - l + 1;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
   
int main(){
  string s;
  cin >> s;
  if((s[5]-'0')*10 + (s[6]-'0') < 5)
	  cout << "Heisei" << endl;
  else
      cout << "TBD" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

const ll INF=3e18;

void add(ll &a,ll b){
    a=(a+b)%MOD;
}

#include <functional>
#include <climits>

//SegmentTree<int> seg(N,[](int a,int b){return min(a,b);},INT_MAX);
template< typename T>
class SegmentTree{
public:

  using F = function<T(T,T)>;

  int n;
  vector<T> tree;
  F operation;
  T def;

  SegmentTree(int size,F _operation,T _def):operation(_operation),def(_def){
    n=1;
    while(n<size) n*=2;
    tree.resize(2*n-1,def);
  }

  SegmentTree(){}

  void embody(int size,F _operation,T _def){
    operation=_operation;
    def=_def;
    n=1;
    while(n<size) n*=2;
    tree.resize(2*n-1,def);
  }

  void initialize(vector<T> v){
    int vSize=v.size();
    n=1;
    while(n<vSize) n*=2;
    tree.resize(2*n-1,def);

    for(int i=0;i<vSize;i++) tree[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--) tree[i]=operation(tree[2*i+1],tree[2*i+2]);
  }

  void update(int index,T value){
    index+=n-1;

    tree[index]=value;
    while(index>0){
      index=(index-1)/2;
      tree[index]=operation(tree[2*index+1],tree[2*index+2]);
    }
  }

  T query(int a,int b,int k=0,int l=0,int r=-1){//[a,b),getMin(a,b,0,0,-1)
    if(r<0) r=n;

    if(r<=a||b<=l) return def;
    else if(a<=l&&r<=b) return tree[k];
    else{
      T lval=query(a,b,2*k+1,l,(l+r)/2);
      T rval=query(a,b,2*k+2,(l+r)/2,r);
      return operation(lval,rval);
    }
  }

  int find(int x,int k=0,int l=0,int r=-1){// a[0]+...+a[i]>=x (i:minimal)
    if(r<0) r=n;
    if(r-l==1) return k-(n-1);
    if(tree[2*k+1]>=x) return find(x,2*k+1,l,(l+r)/2);
    else return find(x-tree[2*k+1],2*k+2,(l+r)/2,r);
  }
};

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

  int N;
  ll A,B;
  cin>>N>>A>>B;
  if(A>B) swap(A,B);
  vector<ll> S(N+2);
  rep(i,N) cin>>S[i+1];
  S[0]=-INF;
  S[N+1]=INF;

  for(int i=2;i<=N;i++){
      if(S[i-2]+A>S[i]){
          cout<<0<<endl;
          return 0;
      }
  }

  vector<int> back(N+2,0);
  for(int i=0;i<N+2;i++){
      back[i]=i;
      if(i>0&&S[i-1]+A<=S[i]) back[i]=back[i-1];
  }

  vector<ll> dp(N+2,0);
  dp[0]=1;
  SegmentTree<ll> seg(N+2,[](ll a,ll b){return (a+b)%MOD;},0);
  seg.initialize(dp);
  for(int i=1;i<=N+1;i++){
      int z=upper_bound(S.begin(),S.end(),S[i]-B)-S.begin();
      z--;
      if(back[i-1]-1>z) continue;
      ll val=seg.query(max(0,back[i-1]-1),z+1);
      seg.update(i,val);
  } 

  cout<<seg.query(N+1,N+2)<<endl;

  return 0;
}


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

using namespace std;

int ans;
int n;
int tab[10][10]; // (i,j) i won against j?
bool fix[10][10];

void reset()
{
    for(int i=0; i<10; ++i)
    {
        for(int j=0; j<10; ++j)
        {
            fix[i][j]=false;
            tab[i][j]=0;
        }
    }
    ans=0;
}

void dfs(int now)
{
    if(now==n)
    {
        ans++;
        return;
    }

    int k=n-1-now;
    int win=now;

    for(int j=0; j<now; ++j)
    {
        win-=tab[j][now];
    }

    for(int s=0; s<1<<k; ++s)
    {
        bool ok=true;
        int poc=0;
        for(int i=0; i<k; ++i)
        {
            if(s>>i&1) poc++;
            int j=i+now+1;
            if(fix[now][j] and (s>>i&1)!=tab[now][j])
            {
                ok=false;
            }
        }
        if(ok and __builtin_popcount(s)+win==n/2)
        {
            for(int i=0; i<k; ++i)
            {
                int j=i+now+1;
                tab[j][now]=!(tab[now][j]=(s>>i&1));
            }
            dfs(now+1);
        }
    }
}

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

    while(true)
    {
        cin>>n;
        if(!n) break;
        reset();

        int m; cin>>m;
        while(m--)
        {
            int a,b; cin>>a>>b; --a,--b;
            tab[a][b]=1;
            tab[b][a]=0;
            fix[a][b]=fix[b][a]=1;
        }

        dfs(0);

        cout << ans << "\n";
    }
}


Measured memory_bytes: 3160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc151_a
{
  class Program
  {
    static void Main(string[] args)
    {
      var C = Console.ReadLine()[0];
      Console.WriteLine((char)(C + 1));
    }
  }
}


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

int N, D, X;
const int MAX_N = 100 + 10;
int A[MAX_N];

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

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int day = 1;
        int j = 0;
        while (day <= D) {
            ans++;
            j++;
            day = j*A[i] + 1;
        }
    }

    cout << ans + X << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
char a,b;
int main()
{
	cin>>a>>b;
	if(a=='H' && b=='H')
	{
		cout<<"H";
		cout<<endl;	
		return 0;
	}
	if(a=='D' && b=='D')
	{
		cout<<"H";
		cout<<endl;
		return 0;
	}
	if(a=='D' && b=='H')
	{
		cout<<"D";
		cout<<endl;
		return 0;
	}
	if(a=='H' && b=='D')
	{
		cout<<"D";
		cout<<endl;
		return 0;
	}

	
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1e18;
// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
    //末尾の要素(i&-i)をたす→一つ上の階層なので、要素の更新の時に使える
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
     //末尾の要素(i&-i)を引く→一つ上の一つ左の階層なので、要素の総和をとる時に使える
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
    T sum(int l, int r) {
        return sum(r-1) - sum(l-1);
    }
};



int main() {
  ll n,q;
  cin>>n>>q;
  vector<ll> c(n);
  rep(i,n){
    cin>>c[i];
    c[i]--;
  }
  vector<vector<P>>v(n);
  rep(i,q){
    ll l1,r1;
    cin>>l1>>r1;
    l1--;r1--;

    v[r1].push_back(make_pair(i,l1));
  }

  BIT <ll>bi(n);
  vector<ll> x(n,-1);
  vector<ll> ans(q,-1);

  ll now=0;
  rep(i,n){
  //  cout<<"i"<<i<<endl;
    ll col=c[i];
    if (x[col]!=-1){
      bi.add(x[col],-1);
    }
    x[col]=i;
    bi.add(i,1);
    rep(j,v[i].size()){
      ll lnow=v[i][j].second;
      ll idnow=v[i][j].first;

      ll a=bi.sum(lnow,i+1);
    //  cout<<a<<endl;
      ans[idnow]=a;
    }
  }
rep(i,q)cout<<ans[i]<<endl;

}



Measured memory_bytes: 44172
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
constexpr int MOD = 1000000007;

int mod(const ll &x){
    return x > 0 ? x % MOD : (x+MOD) % MOD;
}

int modm(const ll &x,const ll &m){
    return x * m % MOD;
}

int modpow(ll x, ll p) {
    int ret = 1;
    while(p > 0) {
        if (p & 1) ret = modm(ret,x);
        x = modm(x,x);
        p >>= 1;
    }
    return ret;
}

// x * modinv(d)
int modd(ll x,ll d) {
    return modm(x,modpow(d,MOD-2));
}

int main(void)
{
    IOS
    int x, y;
    cin >> x >> y;
    constexpr int FACT = 1000000;
    int fact[FACT];
    fact[0] = 1;
    FOR(i,1,FACT) fact[i] = modm(fact[i-1],i);
    auto comb = [&](int x,int y) {int r = fact[x];
    r = modd(r,fact[y]); r = modd(r, fact[x-y]); return r;};

    int mov = (x + y) / 3;
    int ans = 0;
    if (x >= mov && y >= mov && (x + y) % 3 == 0) {
        int x2 = x, y2 = y;
        int xmov = 0;
        while(x2 * 2 != y2) {
            xmov++;
            x2-= 2;
            y2--;
        }
        int ymov = mov - xmov;
        //cerr << mov << " " << xmov << " " << ymov << endl;
        // FOR(i,1,ymov+1) {
        //     ans = mod(ans+ modm(comb(xmov+1,i),comb(ymov-1,i-1)));
        //     //cerr << comb(xmov+1,i) << " " << comb(ymov-1,i-1) << endl;
        // }
        ans = comb(mov,ymov);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4224
from itertools import product

H,W,K = map(int,input().split())
c = [list(input()) for _ in range(H)]

ans = 0

for rowb in product(range(2),repeat = H):
    for colb in product(range(2),repeat = W):
        count = 0
        
        for r in range(H):
            for w in range(W):
                #print(rowb[r],colb[w])
                if c[r][w] == '#' and (rowb[r] and colb[w]):
                    count += 1
                    
        if count == K:
            ans += 1
            
print(ans)

Measured memory_bytes: 9152
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
#include <map>
using namespace std;

int main()
{
	string S, T;
	cin >> S >> T;

	
	int ans = 0;
	for (int i = 0; i < S.size() ; i++)
	{
		if (S[i] != T[i]) {
			ans++;
		}
		
	}
	cout << ans << endl;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (long (i) = 0; (i) < (n); (i)++)
using namespace std;

int K;
bool searched[100000];

void solve() {
  queue<pair<int, int>> q;
  q.push(make_pair(1, 1));
  while (1) {
    auto x_and_ans = q.front();
    q.pop();
    int x = x_and_ans.first;
    while (!searched[x]) {
      if (x == 0) {
        cout << x_and_ans.second << endl;
        return;
      }
      searched[x] = true;
      x = (x * 10) % K;
      pair<int, int> new_pair (x+1, x_and_ans.second+1);
      q.push(new_pair);
    }
  }
}

int main() {
  cin >> K;

  solve();
  return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

li a[200200];
li sum[200200];

int main() {
    li n;
    cin >> n;
    sum[0] = 0;
    rin{
        cin >> a[i];
        sum[i + 1] = sum[i] + a[i];
    }

    li res = INF;
    rin{
        res = min(res, abs(sum[n] - sum[i] - sum[i]));
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int n,a[100010],b[100010],maxx=0,sum=0;
int main()
{
	//freopen(".in","r",stdin);freopen(".out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	b[n]=0;
	for(int i=n-1;i>=1;--i){
		
		if(a[i]>=a[i+1])sum++;
		else sum=0;
		b[i]=sum;
	}
	for(int i=1;i<=n;i++){
		maxx=max(maxx,b[i]);
	}
	cout<<maxx<<endl;
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    string S,T;
    cin>>S>>T;
    ll s=S.size();
    ll t=T.size();
    if(t>s){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    //string res="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
    vector<string> vec;
    rep(j,s-t+1){
        rep(i,t){
            if(S[j+i]!='?'&&S[j+i]!=T[i]){
                break;
            }
            if(i==t-1){
                string Ans="";
                rep(k,s){
                    if(k-j<t&&k-j>=0){
                        Ans+=T[k-j];
                    }else if(S[k]=='?'){
                        Ans+='a';
                    }else{
                        Ans+=S[k];
                    }
                }
                vec.pb(Ans);
            }
        }
    }
    if(vec.empty())
    {
        cout<<"UNRESTORABLE"<<endl;
    }else{
        sort(all(vec));
        cout<<vec[0]<<endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int n;
int A[200000];

int main(){
  int i;
  scanf("%d", &n);
  for(i=0;i<n;i++) scanf("%d", A+i);

  for(i=n-1;i>=0;i-=2) printf("%d ", A[i]);
  for(i=n&1;i<n;i+=2) printf("%d ", A[i]);
  puts("");

  return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int main() {
    double n;
    while(cin >> n) {
        if(n <= 48.0) cout << "light fly" << endl;
        else if(48.0 < n && n <= 51.0) cout << "fly" << endl;
        else if(51.0 < n && n <= 54.0) cout << "bantam" << endl;
        else if(54.0 < n && n <= 57.0) cout << "feather" << endl;
        else if(57.0 < n && n <= 60.0) cout << "light" << endl;
        else if(60.0 < n && n <= 64.0) cout << "light welter" << endl;
        else if(64.0 < n && n <= 69.0) cout << "welter" << endl;
        else if(69.0 < n && n <= 75.0) cout << "light middle" << endl;
        else if(75.0 < n && n <= 81.0) cout << "middle" << endl;
        else if(81.0 < n && n <= 91.0) cout << "light heavy" << endl;
        else cout << "heavy" << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    string s;;
    cin >> s;
    
    if(s[0]!='A'){
        cout << "WA";
        return 0;
    }
    if(s[1]=='C'){
        cout << "WA";
        return 0;
    }
    if(s[s.size()-1]=='C'){
        cout << "WA";
        return 0;
    }
    
    int count = 0;
    rep2(i,1,s.size()){
            if(s[i]=='C')count++;
            else{
                if(isupper(s[i])){
                    cout << "WA";
                    return 0;
                }
            }
            if(count >= 2){
                cout << "WA";
                return 0;
            }
    }
    if(count == 0) cout << "WA";
    else cout << "AC";
    return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


int main(){
	ll n,m,x,y;
	cin>>n>>m;
	ll tmp1=0,tmp2=0,ans=0;
	rep(i,1,n+1){
		cin>>x;
		tmp1=(tmp1+(2*i-n-1)*x)%inf;
	}
	rep(i,1,m+1){
		cin>>y;
		tmp2=(tmp2+(2*i-m-1)*y)%inf;
	}
	ans=tmp1*tmp2%inf;
	print(ans);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int x[10];

int main() {
  //
  rep(i, 0, 5) {
    cin >> x[i];
    if (x[i] == 0) {
      cout << i + 1;
      return 0;
    }
  }
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 1005;

string s[maxn];
int n,m;
int dis[maxn][maxn];
int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
#endif
  cin>>n>>m;
  memset(dis,-1,sizeof(dis));
  queue<int>qx,qy;
  int ret = 0;
  for(int i=0;i<n;i++){
    cin>>s[i];
    for(int j=0;j<m;j++){
      if(s[i][j]=='#'){
        qx.push(i);
        qy.push(j);
        dis[i][j]=0;
      }
    }
  }
  while(!qx.empty()){
    int x=qx.front();
    qx.pop();
    int y=qy.front();
    qy.pop();
    for(int i=0;i<4;i++){
      int nx = x+dir[i][0];
      int ny = y+dir[i][1];
      if(nx<0||nx>=n||ny<0||ny>=m||dis[nx][ny]!=-1)continue;
      dis[nx][ny]=dis[x][y]+1;
      ret = max(ret, dis[nx][ny]);
      qx.push(nx);
      qy.push(ny);
    }
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 13440
/*******
 *   Author: Quamputer
 *   
 * ******/
#include <bits/stdc++.h>

using namespace std;
 
#define int long long
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define LOCAL
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
 
const int INF = LONG_LONG_MAX/2;
const double PI = 3.141592653589793238;
const int MOD = 1000000000 + 7;

bool many = false;
struct Solve {
	
	Solve() {
		int x;
		cin >> x;
		if (x) cout << 0 << endl;
		else cout << 1 << endl;
	}
};

signed main() {
	FAST_IO;
	int CASES=1;
	if (many)
		cin >> CASES;
	for (int i = 1; i <= CASES; i++) {
		Solve me;
	}
}
// g++ -Wall -Wextra -pedantic -std=c++17 -O2 -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover -fstack-protector


Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define rn return
#define fi first
#define se second
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;







// Vectorの使い方！　maxs追加
int main(){
    int N,L;
    cin >> N >> L; int a[N];
    rep(i,N) cin >> a[i];
    P p(0,0);
    rep(i,N-1) maxs(p,P(a[i]+a[i+1],i+1));

    if (p.fi<L){ cout << "Impossible"; rn 0;}
    
    cout << "Possible" << endl;
    rep(i,p.se-1) cout << i+1 << endl;
    FORR(i,p.se,N) cout << i << endl;
    rn 0;
}

Measured memory_bytes: 1152
#include<stdio.h>

int main(void){
        char name[16];
        int a, b, i;
        for(i=0; i<9; i++){
                scanf("%s %d %d", name, &a, &b);
                printf("%s %d %d\n", name, a+b, a*200+b*300);
        }
        return 0;
}


Measured memory_bytes: 1992
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

const ll INF = 1LL << 50;
ll N, A, B, C, L[8];
ll x[8];

ll dfs(ll p) {
  if (p == N) {
    vector<ll> l(4), cnt(4);
    REP(i, 0, N) {
      l[x[i]] += L[i];
      cnt[x[i]]++;
    }

    if (cnt[0] == 0) return INF;
    if (cnt[1] == 0) return INF;
    if (cnt[2] == 0) return INF;

    ll ans = INF;
    ll b = (cnt[0] + cnt[1] + cnt[2] - 3) * 10;

    vector<ll> z = { A, B, C };
    sort(z.begin(), z.end());
    do {
      ans = min(ans, b + abs(l[0] - z[0]) + abs(l[1] - z[1]) + abs(l[2] - z[2]));
    } while (next_permutation(z.begin(), z.end()));

    return ans;
  }

  ll ans = INF;
  REP(i, 0, 4) {
    x[p] = i;
    ans = min(ans, dfs(p + 1));
  }
  return ans;
}

int main(void) {
  cin >> N >> A >> B >> C;
  REP(i, 0, N) cin >> L[i];

  cout << dfs(0) << endl;
}

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

#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007

ll power(ll a,ll b){ll ans=1;while(b>0){if(b&1){ans = (ans*a);}b>>=1;a=a*a;}return ans;}
ll gcd(ll a,ll b){if(b==0){return a;}return gcd(b,a%b);}

int main() {
   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   // cout << fixed << setprecision(10);
   ll n,k;
   cin>>n>>k;
   ll arr[n+1];
   arr[0]=0;
   for(ll i=1;i<=n;i++){
       cin>>arr[i];
   }
   vector<ll> ans;
   ll ele=arr[1];
   unordered_map<ll,ll> unmp;
   while(unmp[ele]==0){
       ans.pb(ele);
       unmp[ele]++;
       ele=arr[ele];
   }
   ll index=0;
   for(ll i=0;i<(ll)ans.size();i++){
       if(ele==ans[i]){
           index=i;
           break;
       }
   }
   ll sz=ans.size();
   if(index==0){
       if(k%sz == 0){
           cout<<ans[sz-1]<<endl;
           return 0;
       }
       cout<<ans[(k%sz) - 1]<<endl;
       return 0;
   }else{
       ll d = k - index;
       if(d<=0 || k < sz){
           cout<<ans[k-1]<<endl;
           return 0;
       }
       ll nw_sz=sz - index;
       ll p=(ll)d%nw_sz;
       if(p == 0){
           cout<<ans[sz-1]<<endl;
           return 0;
       }
       cout<<ans[index + p - 1]<<endl;
       return 0;
   }
	return 0;
}


Measured memory_bytes: 14324
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = read().decode()

N, W, S, E = 'N' in S, 'W' in S, 'S' in S, 'E' in S

cond1 = not N ^ S
cond2 = not W ^ E

print('Yes' if cond1 and cond2 else 'No')

Measured memory_bytes: 9092
import java.util.*;
import java.io.*;
import java.lang.*;

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

        if (d==22)
            System.out.println("Christmas Eve Eve Eve");
        else if (d==23)
            System.out.println("Christmas Eve Eve");
        else if (d==24)
            System.out.println("Christmas Eve");
        else if (d==25)
            System.out.println("Christmas");

    }
}


Measured memory_bytes: 35736
from collections import defaultdict
import math

def combinations_count(n, r):
    if n == 1 or n == 0:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N = int(input())
A= [int(i.strip()) for i in input().split(' ')]

D =defaultdict(int)

for i in A:
    D[i] += 1

S = 0
for i in D.values():
    S += combinations_count(i,2)

result_dic ={}
for i in A:
    a = D[i] - 1
    print(S - a)

Measured memory_bytes: 26772
#include <iostream>

int main()
{
	int n;
	int ans = 0;
	int f_ans = 0;
	std::cin >> n;
	for (int i = 1; i <= n; i++)
	{
		if (i % 2 == 0)
			continue;
		for (int j = 1; j <= n; j++)
		{
			if (i % j == 0)
				++ans;
		}
		if (ans == 8)
			++f_ans;
		ans = 0;
	}
	std::cout << f_ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<math.h>

#define INF 2e9+1;

using namespace std;

int main(void){

    int n, s1 = 0, s2 = 0, t = 1, min = INF;

    cin >> n;

    vector<int> w(n);

    for(int i = 0;i < n;i++){
        cin >> w[i];
    }

    for(int i = 0;i < n;i++){
        for(int j = 1;j <= n;j++){
            if(j <= t){
                s1 += w[j-1];
            }else{
                s2 += w[j-1];
            }
        }

        if(abs(s1-s2) < min) min = abs(s1-s2);
        s1 = 0;
        s2 = 0;
        t++;
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
H, W = map(int,input().split())
a = [list(str(input())) for i in range(H)]
for i in range(0,H,1):
  a[i].insert(0,"#")
  a[i].insert(W+1,"#")
print("#"*(W+2))
for i in range(H):
  print(''.join(map(str, a[i])))
print("#"*(W+2))

Measured memory_bytes: 3064
#include <stdio.h>
#include <inttypes.h>

#define MOD_BY 998244353

int add(int a, int b) {
	return a + b - MOD_BY * (a + b >= MOD_BY);
}

int mul(int a, int b) {
	return (int)(((int64_t)a * b) % MOD_BY);
}

#define KI_MAX (1 << 19) /* 524288 */

int ki[KI_MAX * 2 - 1], ki_mul_all[KI_MAX * 2 - 1], ki_add_all[KI_MAX * 2 - 1];

int ki_get_i_i(int idx, int mult) {
	return add(mul(ki[idx], ki_mul_all[idx]), mul(ki_add_all[idx], mult));
}

void ki_addmul_i(int idx, int qs, int qe, int ss, int se, int mul_value, int add_value) {
	if (qe <= ss || se <= qs) { /* 完全に外れている */
		/* nop */
	} else if (qs <= ss && se <= qe) { /* セグメントがクエリに完全に含まれる */
		ki_mul_all[idx] = mul(ki_mul_all[idx], mul_value);
		ki_add_all[idx] = add(mul(ki_add_all[idx], mul_value), add_value);
	} else {
		int sm = ss + (se - ss) / 2;
		int lidx = idx * 2 + 1, ridx = idx * 2 + 2;
		ki_mul_all[lidx] = mul(ki_mul_all[lidx], ki_mul_all[idx]);
		ki_add_all[lidx] = add(mul(ki_add_all[lidx], ki_mul_all[idx]), ki_add_all[idx]);
		ki_mul_all[ridx] = mul(ki_mul_all[ridx], ki_mul_all[idx]);
		ki_add_all[ridx] = add(mul(ki_add_all[ridx], ki_mul_all[idx]), ki_add_all[idx]);
		ki_mul_all[idx] = 1;
		ki_add_all[idx] = 0;
		ki_addmul_i(lidx, qs, qe, ss, sm, mul_value, add_value);
		ki_addmul_i(ridx, qs, qe, sm, se, mul_value, add_value);
		ki[idx] = add(ki_get_i_i(lidx, sm - ss), ki_get_i_i(ridx, se - sm));
	}
}

void ki_addmul(int qs, int qe, int mul_value, int add_value) {
	if (qs < qe) ki_addmul_i(0, qs, qe, 0, KI_MAX, mul_value, add_value);
}

int ki_get_i(int idx, int qs, int qe, int ss, int se) {
	if (qe <= ss || se <= qs) { /* 完全に外れている */
		return 0;
	} else if (qs <= ss && se <= qe) { /* セグメントがクエリに完全に含まれる */
		return ki_get_i_i(idx, se - ss);
	} else {
		int sm = ss + (se - ss) / 2;
		int left = ki_get_i(idx * 2 + 1, qs, qe, ss, sm);
		int right = ki_get_i(idx * 2 + 2, qs, qe, sm, se);
		int target_left = qs < ss ? ss : qs, target_right = qe < se ? qe : se;
		return add(mul(add(left, right), ki_mul_all[idx]), mul(ki_add_all[idx], target_right - target_left));
	}
}

int ki_get(int qs, int qe) {
	return qs < qe ? ki_get_i(0, qs, qe, 0, KI_MAX) : 0;
}

int main(void) {
	int N, Q;
	int i;
	for (i = 0; i < KI_MAX * 2 - 1; i++) ki_mul_all[i] = 1;
	if (scanf("%d%d", &N, &Q) != 2) return 1;
	for (i = 0; i < N; i++) {
		int a;
		if (scanf("%d", &a) != 1) return 1;
		ki_addmul(i, i + 1, 1, a);
	}
	for (i = 0; i < Q; i++) {
		int type;
		if (scanf("%d", &type) != 1) return 1;
		if (type == 0) {
			int l, r, b, c;
			if (scanf("%d%d%d%d", &l, &r, &b, &c) != 4) return 1;
			ki_addmul(l, r, b, c);
		} else if (type == 1) {
			int l, r;
			if (scanf("%d%d", &l, &r) != 2) return 1;
			printf("%d\n", ki_get(l, r));
		}
	}
	return 0;
}


Measured memory_bytes: 12808
n = int(input())
w = [input() for i in range(n)]
if len(w) == len(set(w)):
  ok = True
  for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
      ok = False
      break
  if ok:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    vector<vector<int>> a(3, vector<int>(3, 0));
    REP(i, 3) {
        REP(j, 3) { cin >> a[i][j]; }
    }
    if(a[1][1] - a[0][1] != a[1][0] - a[0][0] or
       a[1][1] - a[0][1] != a[1][2] - a[0][2]) {
        cout << "No" << endl;
        return 0;
    }
    if(a[1][1] - a[2][1] != a[1][0] - a[2][0] or
       a[1][1] - a[2][1] != a[1][2] - a[2][2]) {
        cout << "No" << endl;
        return 0;
    }
    if(a[0][1] - a[0][0] != a[1][1] - a[1][0] or
       a[2][1] - a[2][0] != a[0][1] - a[0][0]) {
        cout << "No" << endl;
        return 0;
    }
    if(a[0][2] - a[0][1] != a[1][2] - a[1][1] or
       a[2][2] - a[2][1] != a[1][2] - a[1][1]) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
    char a[10],b[10],c[10];
    int A,B;
    scanf("%s",a);
    scanf("%s",b);
    scanf("%s",c);
    A = strlen(a);
    B = strlen(b);
    if(a[A-1] == b[0] && b[B-1] == c[0]){
        printf("YES");
    }
    else{
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;


int main(int argc, const char * argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int A,B,K;
	vector<int> yaku;
	int wrk;

	cin >> A >> B >> K;

	wrk = (A<B) ? A : B;

	for (int i = 1; i < wrk + 1; i++) {
		if((A%i==0) && (B%i==0)){
			yaku.push_back(i);
		}
	}

	sort(yaku.rbegin(),yaku.rend());

	cout << yaku[K-1] << endl;

	return 0;

}


Measured memory_bytes: 256
/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

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

template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }

template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : std::numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

void solve();

int main() {
  std::locale loc(std::locale(), new yes_no);
  std::cout << std::boolalpha << std::setprecision(12) << std::fixed;
  std::cout.imbue(loc);
  solve();
  return 0;
}

using namespace std;

/* -------------------------------- Library -------------------------------- */

class UnionFind {
  vector<int> p;
  int sz;
public:
  UnionFind (int n) : p(n, -1), sz(n) {}
  int root(int x) {
    return p[x] < 0 ? x : p[x] = root(p[x]);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (p[y] < p[x]) swap(x, y);
    if (p[x] == p[y]) --p[x];
    p[y] = x;
    --sz;
    return true;
  }
  int size() const { return sz; }
};

/* ---------------------------------- Main ---------------------------------- */

void solve() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> m(M);
  REP(i,N) {
    int K, L; cin >> K;
    REP(j,K) {
      cin >> L; --L;
      m[L].push_back(i);
    }
  }
  UnionFind uf(N);
  REP(i,M) {
    const int n = m[i].size();
    REP(j,n-1) {
      uf.unite(m[i][j], m[i][j+1]);
    }
  }
  cout << (uf.size() == 1) << endl;
  return;
}


Measured memory_bytes: 4608
//
// Created by Mahmoud Rashad on 11/27/19.
//


#include <bits/stdc++.h>

using namespace std;

typedef vector<pair<int, bool>> vii;

int n;
bool v[16];
vector<vii> data;
int ans = 0;

void solve(int idx) {
    if(idx == n) {
        bool f = true;
        int cnt = 0;
        for(int i = 0; i < n; i++) {
            if(!v[i]) continue;
            cnt++;
            for(auto p : data[i]) {
                int u = p.first;
                bool kind = p.second;

                f &= (v[u] == kind);
            }
        }
        ans = max(ans, cnt * f);
        return;
    }

    v[idx] = 0;
    solve(idx + 1);
    v[idx] = 1;
    solve(idx + 1);
}

int main(){

    cin >> n;
    data.resize(n, vii());
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        while (a--) {
            int u;
            bool kind;
            cin >> u >> kind;
            data[i].push_back({--u, kind});
        }
    }

    solve(0);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a,b = 0;
        while (true){
            a = scan.nextInt();
            if(a == 0){
                break;
            }else{
                b++;
            }
              System.out.printf("Case %d: %d\n",b,a);
        }
    }
}


Measured memory_bytes: 62428
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;



int main()
{
    int X;
    cin >> X;
    int ans=0;
    if(X<600) ans=8;
    else if(X<800) ans=7;
    else if(X<1000) ans =6;
    else if(X<1200) ans=5;
    else if(X<1400) ans=4;
    else if(X<1600) ans =3;
    else if(X<1800) ans=2;
    else if(X<2000) ans=1;

    cout << ans;


    return 0;
}

Measured memory_bytes: 3632
n=gets.to_i
a=gets.split.map(&:to_i)
cnt=0
(1..n-2).each do |i|
  if (a[i-1]<a[i] && a[i]<=a[i+1])||
      (a[i+1]<a[i] && a[i]<=a[i-1])
    cnt+=1
  end
end
puts cnt

Measured memory_bytes: 1788
#include<cstdio>
#include<cstring>

int Check(int x){
    char s[10];
    sprintf(s+1,"%d",x);
    int len=strlen(s+1);
    for(int i=1;i<=len/2;i++)
        if(s[i]!=s[len-i+1])
            return 0;
    return 1;
}

int main(){
    int A,B,Ans=0;
    scanf("%d%d",&A,&B);
    for(int i=A;i<=B;i++)
        Ans+=Check(i);
    printf("%d",Ans);
    return 0;
}
/**/

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

const long long MOD = (long long)1e+9 + 7;

long long factorial(long long n) {
	long long res = 1;
	while(n > 0) {
		res = (res * n) % MOD;
		n--;
	}
	return res;
}

void solve(long long N, long long M){
	if(N < M) swap(N, M);
	if(N - M > 1) {
		cout << 0 << endl;
		return;
	}
	int res = (factorial(N) * factorial(M)) % MOD;
	if(N == M) {
		res = (res * 2) % MOD;
	}
	cout << res << endl;
}

int main(){	
	long long M;
	long long N;
	scanf("%lld",&N);
	scanf("%lld",&M);
	solve(N, M);
	return 0;
}



Measured memory_bytes: 764