akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>

int main() {
  int N;
  int flag = 0;
  std::string str;
  std::cin >> N;
  std::cin >> str;
  if (str.size() % 2 == 1) {
    flag = 1;
  }
  else {
    for (int i = 0; i < str.size()/2; i++) {
      if (str.at(i) != str.at(i + str.size()/2)) {
        flag = 1;
        break;
      }
    }
  }
  
  if (flag) {
    std::cout << "No" << std::endl;
  }
  else {
    std::cout << "Yes" << std::endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

int k, a, b;

int main() {
  scanf("%d%d%d", &k, &a, &b);
  if (b - a > 2 && k > a - 1) {
    long long result = (k - (a - 1)) / 2 * 1LL * (b - a) + a + (k - (a - 1)) % 2;
    printf("%lld\n", result);
  } else {
    printf("%d\n", k + 1);
  }
}


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

static const int MOD=1000000007;
typedef long long ll;

int main(){
    int N;
    string s;
    cin >> N;
    cin >> s;
    map<char,int> m;
    ll ans=1;
    for(int i=0;i<N;i++){
        m[s[i]]++;
    }
    for(auto it=m.begin();it!=m.end();it++){
        ans*=(it->second+1);
        ans%=MOD;
    }
    cout << ans-1 << endl;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>

int main()
{
    char S[100001];
    int l;
    
    scanf("%s",S);
    l =strlen(S);
    
    if(S[l-1]!='s'){
        S[l]='s';
    }
    
    
    if(S[l-1]=='s'){
        S[l]='e';
        S[l+1]='s';
    }
    
    printf ("%s",S);


}


Measured memory_bytes: 1740
#include<bits/stdc++.h>
using namespace std;
const int N=205;
int n,i,j,k,s[N][N],f[N][N],col[N],ans;
char c[N];
bool dfs(int u){
	for(int i=1;i<=n;++i)if(s[u][i]){if(col[i]==-1 && s[u][i]){
		col[i]=col[u]^1;
		if(!dfs(i))return 0;
	}else if(col[i]==col[u])return 0;}
	return 1;
}
int main(){
	scanf("%d",&n);
	memset(col+1,-1,n<<2);
	for(i=1;i<=n;++i){
		for(j=1;j<=n;++j)f[i][j]=i==j?0:1<<25;
		scanf("%s",c+1);
		for(j=1;j<=n;++j)if(c[j]=='1')f[i][j]=s[i][j]=1;
	}
	col[1]=0;
	if(!dfs(1)){puts("-1");return 0;}
	for(i=1;i<=n;++i)for(j=1;j<=n;++j)for(k=1;k<=n;++k)
		f[j][k]=std::min(f[j][k],f[j][i]+f[i][k]);
	for(i=1;i<=n;++i)for(j=1;j<=n;++j)ans=max(ans,f[i][j]);
	printf("%d\n",ans+1);
	return 0;
}

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

const int N = 100050;
int dp[N];
int n,k;
int arr[N];


int main()
{
   scanf("%d %d",&n,&k);
   for(int i=1; i<=n; i++) scanf("%d",&arr[i]);

   dp[0]=0;
   for(int i=1; i<=k; i++)
   {
       for(int j=1; j<=n; j++)
       {

           if(arr[j]<=i)
           {
               dp[i]|=1-dp[i-arr[j]];
           }
       }
   }


   if(dp[k]==1) printf("First\n");
   else printf("Second\n");


}


Measured memory_bytes: 640
rows,cols = map(int, input().split())
matrix = [[0 for cols in range(cols+1)] for rows in range(rows+1)]

for row in range(rows):
    vs = list(map(int, input().split()))
    for col in range(cols):
        matrix[row][col] = vs[col]
    matrix[row][cols] = sum(vs)

for col in range(cols + 1):
    total = 0
    for row in range(rows):
        total += matrix[row][col]
    matrix[rows][col] = total

for row in range(rows+1):
    for col in range(cols+1):
        if col == 0:
            print(f"{matrix[row][col]}", end="")
        else:
            print(f" {matrix[row][col]}", end="")
    print("")


Measured memory_bytes: 6232
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < n; ++i)
#define fore(i, a, b) for(int i = a; i < b; ++i)

#define endl '\n'

const int MOD = 1000000007;
const int MOD2 = 998244353;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<string> ar(n);
    for (int i = 0; i < n; ++i) cin >> ar[i];
    static int q[2 * 1000 * 1000];
    static int cnt[1000][1000] = {};
    int beg = 0;
    int end = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (ar[i][j] == '#') {
                cnt[i][j] = 1;
                q[end++] = i;
                q[end++] = j;
            }
        }
    }
    pair<int, int> moves[4] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
    int ans = 1;
    while (beg < end) {
        int i = q[beg++];
        int j = q[beg++];
        for (auto d: moves) {
            int x = i + d.first;
            int y = j + d.second;
            if (x >= 0 && x < n && y >= 0 && y < m && cnt[x][y] == 0) {
                ans = cnt[x][y] = cnt[i][j] + 1;
                q[end++] = x;
                q[end++] = y;
            }
        }
    }
    cout << ans - 1 << endl;
}

Measured memory_bytes: 13564
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int n;
  cin >> n;
  set<string> s;
  for(int i=0;i<n;i++){
    string cur;
    cin >> cur;
    s.insert(cur);
  }
  cout << (int)s.size() << endl;

return 0;
}
///....


Measured memory_bytes: 19140
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> suki(m + 1);
  rep (i, n) {
    int tmp;
    cin >> tmp;
    rep (j, tmp) {
      int tmp2;
      cin >> tmp2;
      suki[tmp2]++;
    }
  }
  int ans = 0;
  for (int i = 1; i < m + 1; i++) {
    if (suki[i] == n) ans++;
  }
  P(ans);
  return 0;

}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main {

	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		System.out.println(c >= a && c <= b ? "Yes" : "No");
	}
}

Measured memory_bytes: 23252
/*
ID: thanhvq1
LANG: C++14
PROB: namenum
*/

#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;

// defines
#define int long long
typedef long long ll;
#define double long double
#define vec vector
#define vi vector<int>
#define vvi vector<vector<int>>
#define FZ(n) memset((n),0,sizeof())
#define FMO(n) memset((n),-1,sizeof(n))
#define unset unordered_set
#define ii pair<int, int>
#define vii vector<ii>
#define F first;
#define S second
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)(x).size())
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)

//permanent constants
const long long ZERO = 0LL;
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;  const ll MOD2 = (ll)MOD * (ll)MOD;
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int dx[4] = {0, 1, 0, -1}; const int dy[4] = {1, 0, -1, 0};
//const ll INF = (ll)(1e18 + 239);
const int BIG = (int)(1e9 + 239);

//random
mt19937 rnd(239); //(chrono::high_resolution_clock::now().time_since_epoch().count());

void FILEIO() {  freopen("in.txt", "r", stdin);  freopen("out.txt", "w", stdout); }
//void FILEIO() {  freopen("namenum.in", "r", stdin);  freopen("namenum.out", "w", stdout); }
void input() {   }

void solve() {
	int n; cin >> n;
	vi a(n); FOR(i, 0, n) {cin >> a[i];}
	set<int> st(ALL(a));

//	cout << st.size() << endl;
//	for(auto x : st) cout << x << endl;

	if(st.size()>3) {cout<<"No"<< endl; return;}
	if(st.size()==1) {
		if(*st.begin()==0) {cout<<"Yes"<< endl; return;}
		else {cout<<"No"<< endl; return;}
	}
	if(st.size()==2) {
		int cnt1=0, cnt2=0, a1=*st.begin();
		FOR(i, 0, n) {
			if(a[i]==a1) cnt1++; else cnt2++;
		}

//		cout << cnt1 << ", " << cnt2 << endl;

		if(*st.begin()==0 and 2*cnt1==cnt2) {cout<<"Yes"<< endl; return;}
		else {cout<<"No"<< endl; return;}
	}
	// now st.size==3
	vi b(ALL(st));
	int cnt[3]; FOR(i, 0, 3) cnt[i]=0;
	FOR(i, 0, n) {
		FOR(j, 0, 3) {
			if(a[i]==b[j]) cnt[j]++;
		}
	}
	if(cnt[0]!=cnt[1] or cnt[1]!=cnt[2] or cnt[2]!=cnt[0]) {cout<<"No"<<endl; return;}
	if((b[0]^b[1])==b[2]) {cout<<"Yes"<< endl; return;}
	else {cout<<"No"<< endl; return;}
}

signed main() {
  ios_base::sync_with_stdio(false); cin.tie();
//  FILEIO();
//auto beginProgram = chrono::steady_clock::now();

// int t, test=0; cin >> t;
//  while(t--)
  {
		solve();
  }

  //auto endProgram = chrono::steady_clock::now();

  return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <numeric>
#include <vector>
#include <cmath>
#include <map>
#include <ctype.h>
using namespace std;

int main(){
   for(int x=1; x<10; x++) {
    for(int y=1; y<10; y++){
        cout << x  << "x" << y << "=" << x*y << endl;
    }
   }
}



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

int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		--a[i];
	}
	// find 1
	int presses = 0;
	int pos = 0;
	vector<bool> visited(n, false);
	while (!visited[pos]) {
		if (pos == 1) {
			cout << presses << endl;
			break;
		}
		presses++;
		visited[pos] = true;
		pos = a[pos];
	}
	if (pos != 1) cout << -1 << endl;
	
	return 0;
}


Measured memory_bytes: 640
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int count = std.nextInt();
        List<Integer> bs = IntStream.range(0, count - 1).map(it -> std.nextInt()).boxed().collect(Collectors.toList());

        int res = min(bs);
        System.out.println(res);
    }

    private static int min(List<Integer> bs) {
        List<Integer> cs = IntStream.range(0, bs.size()).map(it -> 0).boxed().collect(Collectors.toList());
        cs.set(0, bs.get(0));

        for (int i = 1; i < cs.size(); i++) {
            int minVal = Math.min(bs.get(i - 1), bs.get(i));
            cs.set(i, minVal);
        }
        cs.add(bs.get(bs.size() - 1));
        return cs.stream().mapToInt(it -> it).sum();
    }
}

Measured memory_bytes: 26964
#include <stdio.h>
#include <algorithm>

using namespace std;
int cost[101][101][2];
int d[101];   //始点固定は最初
bool used[101];
int n,m;    //mは頂点数


void dijkstra(int s,int r){
	for(int j=0;j<m;j++){
	d[j]=1000000;
	used[j]=false;
	}


    d[s]=0;
	while(true){
		int v=-1;
		for(int u=0; u<m;u++){
			if(!used[u] && (v == -1 || d[u] < d[v]))
				 v=u;
		}
		
		if(v == -1)
			break;
		used[v] = true;
		for ( int u =0; u < m; u++){
			d[u] = min(d[u], d[v] + cost[v][u][r]);
		}
	}
}

int main(void){
	for(;;){
		int a,b,time,cos;
    	scanf("%d %d",&n,&m);
	if(!(n|m))
		break;
		for(int i=0;i<m;i++){
				for(int j=0;j<m;j++){
    						cost[i][j][0]=1000000;
							cost[i][j][1]=1000000;
				}
		}
    	for(int i=0;i<n;i++){
    		scanf("%d %d %d %d",&a,&b,&cos,&time);
			a--; b--;
			cost[a][b][0]=cos;
			cost[b][a][0]=cos;
			cost[a][b][1]=time;
			cost[b][a][1]=time;
		}
		
		int p,q,r;
		scanf("%d",&n);
		for(int i=0;i<n;i++){
		scanf("%d %d %d",&p,&q,&r);
		p--;q--;
		dijkstra(p,r);
		printf("%d\n",d[q]);
		}
	}

	return 0;
}

Measured memory_bytes: 1108
#include <iostream>
#include <algorithm>
#include <cmath>

int n;
char a[105], b[105], c[105];
int main()
{
	std::cin >> n;
	for (int i = 0; i < n; ++i)
		std::cin >> a[i];
	for (int i = 0; i < n; ++i)
		std::cin >> b[i];
	for (int i = 0; i < n; ++i)
		std::cin >> c[i];

	int ans = 0;
	for (int i = 0; i < n; ++i) {
		auto t1 = a[i], t2 = b[i], t3 = c[i];
		bool s1 = false, s2 = false, s3 = false;
		if (t1 == t2)
			s1 = true;
		if (t2 == t3)
			s2 = true;
		if (t1 == t3)
			s3 = true;
		if (s1&&s3)
			continue;
		if (!s1 && !s2 && !s3)
			ans += 2;
		else
			++ans;
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		
		double r = s.nextDouble();
		double pi = Math.PI;
		
		System.out.printf("%.5f %.5f",r*r*pi,2*r*pi);
				
	}

}

Measured memory_bytes: 28240
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int n,d,x;
	cin >> n >> d >> x;
	int a[n];
	REP(i,n) cin >> a[i];
	int cnt=0;
	REP(i,n){
		cnt+=(d-1)/a[i]+1;
	}
	cout << cnt+x << endl;
/////////////////////////////////////////////
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
#define SET(a,c) memset(a,c,sizeof(a))

#define DEBUG(x) cout<<"#x"<<": "<<x<<endl

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll INF = INT_MAX/3;
const ll MOD = 1000000007;
const double EPS = 1e-14;
const int dx[] = {1,0,-1,0} , dy[] = {0,1,0,-1};

const int MAX_P = 800;
const int MAX_Q = 800;
const int MAX_N = 8;

int p,q,a,n;
double pdq;
int gcd(int a,int b){return a%b==0 ? b : gcd(b , a%b) ;}

pair<int,int> calDiv(int p,int q,int tq){
    return MP(p*tq + q , q*tq);
    // int a = p * tq + q;
    // int b = q * tq;
    // int c = gcd(a,b);
    // return MP(a/c,b/c);
}

int dfs(int tp,int tq,int tn,int prev,int pro){
    double tpdq = double(tp)/tq;
    if( tpdq > pdq) return 0;
    if(tpdq - pdq > tn) return 0;
    if(tpdq == pdq ) return 1;
    // if( tp == p && tq == q) {
    //     return 1;
    // }
    if( tn <= 0 ) return 0;
    int ret = 0;

    int f = 0,s = 0;
    for(int i=prev;i*pro<=a;i++){
        auto temp = calDiv(tp,tq,i);
        f = temp.first;
        s = temp.second;
        ret += dfs(f,s,tn-1,i,pro*i);

    }
    return ret;
}

int main(){


    while(true){
        cin >> p >> q >> a >> n;
        if(p == 0 && q == 0 && a == 0 && n == 0) break;

        int ta = p/gcd(p,q);
        int tb = q/gcd(p,q);
        p = ta;q = tb;
        pdq = double(p)/double(q);


        int ans = dfs(0,1,n,1,1);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 2996
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int x;
	cin >> x;
	string s = to_string(x);
	int fx = 0;
	for (int i = 0;i < s.size();i++) {
		fx += s[i]-'0';
	}

	if (x%fx == 0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/ruby
while(a,b=gets.split.map(&:to_i))!=[0,0]do
	r=99999999
	1.step(Math.sqrt(a).to_i){|i|
		if a%i>0 then next end
		1.step(Math.sqrt(b).to_i){|j|
			if b%j>0 then next end
			x=[i,a/i,j,b/j].sort
			p=(x[3]-x[2])**2+(x[2]-x[1])**2+(x[1]-x[0])**2
			if r>p then r=p end
		}
	}
	p r
end

Measured memory_bytes: 2604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

void solve(){
  int n;
  cin >> n;
  cout << 48-n << endl;
}

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

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	bs := make([]int, n)
	for i := range as {
		fmt.Scan(&as[i], &bs[i])
	}

	ans := 0
	for i := n - 1; i >= 0; i-- {
		a := as[i]
		b := bs[i]
		if c := (a + ans) % b; c != 0 {
			ans += bs[i] - c
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

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

    int n; cin >> n;
    vector<ll> plus(n), minus(n);
    for (int i = 0; i < n; i++)
    {
        ll x, y; cin >> x >> y;
        plus[i] = x+y;
        minus[i] = x-y;
    }
    sort(plus.begin(), plus.end());
    sort(minus.begin(), minus.end());

    ll result = max(plus.back()-plus.front(), minus.back()-minus.front());
    cout << result << endl;

    return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//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 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())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

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

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL h(n);
	cin >> h;
	int ans = 0;
	int now = 0;
	for (int i = 0; i < n-1; i++) {
		if (h[i+1] <= h[i]) {
			now++;
		}
		else {
			ans = max(ans, now);
			now = 0;
		}
	}
	cout << max(ans,now) << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;

const int m=1000000007;

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main(){
  Sieve sieve(1e6);
  int n;
  cin >> n;
  vi a(1005);
  for(int i=1;i<=n;i++){
    auto f = sieve.factor(i);
    for(auto j : f){
      a[j.first]+=j.second;
    }
  }
  ll ans=1;
  for(int i=2;i<=n;i++){
    if(a[i]==0) continue;
    ans*=a[i]+1;
    ans%=m;
  }
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 7648
#include<stdio.h>

int main(void){
  int n,m;
  scanf("%d %d",&n,&m);
  
  int a[m];
  for(int i=0;i<m;i++){
    scanf("%d",&a[i]);
    n-=a[i];
  }
  if(n>=0){
    printf("%d",n);
  }else{
    printf("-1");
  }
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
 
using namespace std;
#define LOCAL  1
#define UPLOAD 2
#define ll long long
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
 
int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
 
  int N = input(); 
  map<int,int> m;

  for(int i=0;i<N;i++){
    int a = input();
    m[a]++;
    if(m[a] == 2){
      output("NO");
      return 0;
    }
  }

  output("YES");
 
  return 0;
}

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

int main() {
  string A, B;
  cin >> A >> B;
  
  cout << (A.at(0) == B.at(2)&&A.at(1) == B.at(1)&&A.at(2) == B.at(0) ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <iostream>

#define FOR(i,l,n) for(int (i)=(l);(i)<(n);(i)++)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(){
    long int x,y,z,e,m;
    while(cin>>e,e){
        m=e;
      for(y=0;y*y<=e;y++){
          for(z=0;z*z*z+y*y<=e;z++){
              x = e-y*y-z*z*z;
              m = m<x+y+z?m:x+y+z;
          }
      }  
        cout<<m<<endl;
    }
    return 0;
}


Measured memory_bytes: 2980
import sys

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


# rstrip().decode('utf-8')
# INF=float("inf")
# MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
#import numpy as np
# import operator
# import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
from fractions import gcd
# from collections import deque
# from collections import defaultdict
# from collections import Counter
# from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())


def main():
	N=int(input())
	A=list(map(int,input().split()))
	
	L=[0]*N
	R=[0]*N
	M=[0]*N
	
	L[0] = A[0]
	R[N-1]=A[N-1]
	
	for i in range(1,N):
		L[i]=gcd(A[i],L[i-1])
	for i in range(N-2,0,-1):
		R[i]=gcd(A[i],R[i+1])
	
	M[0]=R[1]
	M[N-1]=L[N-2]
	
	for i in range(1,N-1):
		M[i]=gcd(L[i-1],R[i+1])
	
	print(max(M))
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
if __name__ == '__main__':
	main()


Measured memory_bytes: 14556
from fractions import gcd
from functools import reduce
import sys
input = sys.stdin.readline

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    T = [int(input()) for _ in range(N)]
    print(lcm(T))

if __name__ == '__main__':
    main()

Measured memory_bytes: 63980
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
	int n, k;
	cin >> n >> k;
    int ans = 0;
    while (n > 0) {
        n /= k;
        ans++;
    }
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;

bool comp(int a,int b){
return a>b;
}
const ll INF_=1e13;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main()
{
	fast;
	ll n,W;
	cin>>n>>W;
	ll a[n+1],w[n+1],tt=0;
	rep(i,1,n+1){
		cin>>w[i]>>a[i];
		tt+=a[i];
		
	}
//	cout<<tt<<endl;
	ll dp[tt+1];
	rep(i,1,tt+1)
	dp[i]=INF_;
	
	dp[0]=0;
	rep(i,1,n+1)
	{
		per(j,a[i],tt+1)
		{
			dp[j]=min(dp[j],dp[j-a[i]]+w[i]);
	
		//	cout<<dp[j]<<" ";
		}
	//2	cout<<endl;
	}
	per(i,0,tt+1)
	
	
	
	
	{
		if(dp[i]<=W)
		{
			cout<<i<<endl;
			break;
		}
	}
	
	
	
	
	
	


}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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<ll> get_path(const vl &prev, ll t) {
    vector<ll> path;
    for (ll cur = t; cur != -1LL; cur = prev[cur]) {
        path.push_back(cur);
    }
    reverse(path.begin(), path.end()); // 逆順なのでひっくり返す
    return path;
}
int main(){
    ll n,m;cin >> n >>m;
    vvpl g(n);
    rep(i,m){
        ll a,b;cin >> a >>b;
        a--;b--;
        g[a].pb({b,1});g[b].pb({a,1});
    }
    vl prev(n,-1);
    vl d(n,inf);
    pqueue(pl) que;
    que.push({0,0});
    d[0]=0;
    while(!que.empty()){
        pl p=que.top();
        que.pop();
        ll v=p.se;
        if(d[v]<p.fi)continue;
        rep(i,g[v].size()){
            pl ed=g[v][i];
            if(d[ed.fi]>d[v]+ed.se){
                prev[ed.fi]=v;
                d[ed.fi]=d[v]+ed.se;
                que.push({d[ed.fi],ed.fi});
            }
        }
    }
    bool check=true;
    rep(i,n){
        if(i==0)continue;
        if(prev[i]==-1)check=false;
    }
    if(check){
        cout <<"Yes" <<endl;
        rep(i,n){
            if(i==0)continue;
            cout << prev[i]+1 <<endl;
        }
    }
    else cout <<"No" <<endl;
}

Measured memory_bytes: 19612
def main():
    S = input()
    counter = len(S)

    while True:
        # print(S[0:counter//2], "===", S[counter//2:counter])
        if counter%2 == 1:
            counter-=1
            continue
        if S[0:counter//2] == S[counter//2:counter] and counter!=len(S):
            break

        counter-=1
    
    print(abs(counter))

main()


Measured memory_bytes: 2940
/**
 *   author: Shubham Srivastava
 *   created: 29 January 2019  00:47:28
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    long long n,k;
    cin>>n>>k;
    long long height[n],dp[n] = {0};
    for(int i=1;i<=n;i++)
    	cin>>height[i];
    if(n < k){
    	k = n;
    }
    for(int i=1;i<=k;i++)
    	dp[i] = abs(height[i] - height[1]);
    for(int i=k+1;i<=n;i++)
    {
    	long long temp = INT_MAX;
    	for(int j=1;j<=k;j++)
    	{
    		temp = min(temp, dp[i-j]+abs(height[i]-height[i-j]));
    	}
    	dp[i] = temp;
    }
    cout<<dp[n];
return 0;
}

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

using namespace std;

int main() {

	int n;
	cin >> n;

	map<long long,long long> a;

	long long in1;
	long long res=0;
	for (int i = 0; i < n; i++) {
		cin >> in1;
		a[in1]++;
		res += in1;
	}

	int q;
	cin >> q;

	long long in2, in3;

	for (int i = 0; i < q; i++)
	{
		cin >> in2 >> in3;
		
		res = res - a[in2] * in2 + a[in2] * in3;
		
		a[in3] += a[in2];
		a[in2] = 0;
	
		cout << res << endl;

	}


	return 0;

}

Measured memory_bytes: 9496
import collections
H, W = map(int, input().split())
N = int(input())
As = list(map(int, input().split()))
anss = [collections.deque() for _ in range(H)]
state = 0
i = 0
cnt = 0
for j in range(N):
    for k in range(As[j]):
        if cnt == W:
            state += 1
            cnt = 0
            i += 1
        if state % 2 == 0:
            anss[i].append(j+1)
            cnt += 1
        else:
            anss[i].appendleft(j+1)
            cnt += 1
for ans in anss:
    print(*ans)

Measured memory_bytes: 4304
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long;

int main()
{
    
    char a;
    scanf("%c",&a);
    if((a>= 'a') &&a <= 'z')
        cout <<"a"<< endl;
    else
        cout <<"A"<< endl;
    return 0;
}


Measured memory_bytes: 3684
#include <iostream>
#include <cstdio>

using namespace std;

long long fib[45];

int main(void) {

    fib[0] = fib[1] = 1;
    for (int i = 2; i < 45; ++i) {
        fib[i] = fib[i - 1] + fib[i - 2];
    }

    int n;
    cin >> n;
    printf("%lld\n", fib[n]);

    return 0;
}

Measured memory_bytes: 1148
//author: Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
ll addmod(ll a, ll b){
   if (0 == b)
       return a;
   b = mod - b;
   if (a >= b)
       return a - b;
   else
       return mod - b + a;
}
ll modexp(ll x, ll y, ll p){
 ll res = 1;
 x = x % p;
 while (y > 0)
 {
     if (y & 1)
         res = (res * x) % p;
     y = y >> 1;
     x = (x * x) % p;
 }
 return res;
}
ll mulmod(ll a, ll b){
   ll res = 0;
   a = a % mod;
   while (b > 0){
       if (b % 2 == 1)
           res = (res + a) % mod;
       a = (a * 2) % mod;
       b /= 2;
   }
   return res % mod;
}
int main()
{
    fastio;
    ll n=0;
    cin>>n;
    ll ar[n+1]={0};
    for(ll i=0;i<n;++i) cin>>ar[i];
    ll ans=0;
    for(ll i=0;i<64;++i){
        ll set_bits=0;
        for(ll j=0;j<n;++j){
            if(ar[j]&1) ++set_bits;
            ar[j]>>=1;
        }
        //ans+=((1<<i)*set_bits*(n-set_bits));
        ans=addmod(ans,mulmod(modexp(2,i,mod),mulmod(set_bits,n-set_bits)));
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 2560
n=1
while n>0:
 n=input();r=range(n)
 if n>0:A=[map(int,raw_input().split())for i in r];a={min(A[i])for i in r}&{max(A[j][i]for j in r)for i in r};print a.pop()if len(a)>0 else 0


Measured memory_bytes: 4656
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5010;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

//long longしか使わない
//素数は1より大きい
int main() {
	ll n, k;
	cin >> n >> k;
	for (ll i = 1;i <= k;++i) {
		COMinit();
		ll ans= COM(n - k + 1, i);
			ans %= MOD;
		if (i!=1&&i!=k)ans *= COM(k - 1, i - 1);
		ans %= MOD;
		cout << ans << endl;
	}
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--) 
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
const int N = 310, mod = 1e9 + 7;
bitset<N> c[N];
int n, C = 0;
bool vis[N];
void init() {
	rep(i,1,n) {
		int t = 0;
		rep(j,1,n) if (!vis[j] && c[j][i]) { t = j; break; }
		if (!t) continue; if (t != i) swap(c[t], c[i]);
		vis[i] = true, C++; 
		rep(j,1,n) if (!vis[j] && c[j][i]) c[j] ^= c[i];
	}
}

int pw[N * N], f[N][N];

int F[N][N];

int Pw(int a, int b) {
	int w = 1; 
	for(;b;b >>= 1, a = 1LL * a * a % mod) if (b & 1) 
		w = 1LL * w * a % mod; 
	return w; 
}
int g(int n, int r) { return 1LL * f[n][r] * Pw(f[r][r], mod - 2) % mod; }

int main() {
	scanf("%d",&n);
	rep(i,1,n) rep(j,1,n) { int x; scanf("%d",&x); c[i][j] = x; }
	init();
	pw[0] = 1; rep(i,1,n * n) pw[i] = (pw[i - 1] << 1) % mod;

	rep(i,0,n) {
		F[i][0] = 1;
		rep(j,1,i) 
			F[i][j] = (1LL * F[i - 1][j - 1] * (pw[n] - pw[j - 1]) + 1LL * F[i - 1][j] * pw[j]) % mod;
	}

	rep(i,0,n) {
		f[i][0] = 1;
		rep(j,1,i) 
			f[i][j] = 1LL * f[i][j - 1] * (pw[i] - pw[j - 1]) % mod;
	}

	int ans = 0;
	rep(j,C,n) ans = (ans + 1LL * F[n][j] * g(j, C) % mod * 1LL * Pw(g(n, C), mod - 2) % mod * pw[n * (n - j)]) % mod;

	if (ans < 0) ans += mod;
	cout <<ans<<endl;
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
        using namespace std;
         
        int main(void){
        	int a,b,c,s=0;
        	int arr[101]={};
        	cin >> a >> b >> c;
        	arr[a]=1;
        	arr[b]=1;
        	arr[c]=1;
        	for(int i=0;i<101;i++){
        		s+=arr[i];
        	}
        	cout << s;
        	return 0;
        }

Measured memory_bytes: 888
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	//defer profile.Start(profile.ProfilePath(".")).Stop()
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)

	str := oneStr()

	//str := strings.Repeat("ABC", 26666)

	runeStr := []rune(str)

	ans := calc(runeStr)
	fmt.Println(ans)
}

func calc(runeStr []rune) int {
	ans := 0
	cntA := 0
	for i := 0; i < len(runeStr)-1; i++ {
		if runeStr[i] == 'A' {
			cntA++
			continue
		}
		if runeStr[i] == 'B' && runeStr[i+1] == 'C' {
			ans += cntA
			i++
			continue
		}
		cntA = 0
	}
	return ans
}

func oneInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func oneStr() string {
	sc.Scan()
	return sc.Text()
}

func scanNums(len int) (nums []int) {
	for i := 0; i < len; i++ {
		nums = append(nums, oneInt())
	}
	return nums
}

func scanStrings(len int) (strs []string) {
	for i := 0; i < len; i++ {
		strs = append(strs, oneStr())
	}
	return strs
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}


Measured memory_bytes: 2048
# coding: utf-8
N = int(input())
d = {}
alp = "abcdefghijklmnopqrstuvwxyz"
cnt = {}
for s in alp:
    cnt[s] = 0
for i in range(N):
    d[i] = {}
    s = input()
    for j in range(len(alp)):
        d[i][alp[j]] = 0
    for j in range(len(s)):
        d[i][s[j]] += 1
for s in alp:
    l = []
    for k in d.keys():
        l.append(d[k][s])
    cnt[s] = min(l)
ans = ""
# print(cnt)
for a in alp:
    ans += a * cnt[a]
print(ans)

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

int main() {

    long long a,b;
    

    cin >> a >> b;

    for(int i = 1;i <= b;i ++){

        if((a * i) % b == 0){
        cout << a * i <<endl;
      break;
        }
        
    }


}


Measured memory_bytes: 256
s = list(input())

n = len(s)

a = [0] * n

MOD = 998244353

for i in range(n):
    a[i] = ord(s[i]) - ord('a')

if max(a) == min(a):
    print(1)
    exit()
elif n == 3:
    def solver(m):
        x = m // 100
        y = ( m % 100 ) // 10
        z = m % 10
        if x != y:
            c = (3 - x - y) % 3
            temp = c * 110 + z
            if temp not in ans:
                ans.add(temp)
                solver(temp)
        if y != z:
            c = (3 - y - z) % 3
            temp = x * 100 + c * 11
            if temp not in ans:
                ans.add(temp)
                solver(temp)

    t = a[0] * 100 + a[1] * 10 + a[2]
    ans = set()
    ans.add(t)
    solver(t)
    print(len(ans))
    exit()
elif n == 2:
    print(2)
    exit()

dp = [[0,0,0] for _ in range(3)]

dp[0][0] = 1
dp[1][1] = 1
dp[2][2] = 1

for i in range(n-1):
    T = [[0,0,0] for _ in range(3)]
    T[0][0] = (dp[1][0] + dp[2][0]) % MOD
    T[0][1] = (dp[1][1] + dp[2][1]) % MOD
    T[0][2] = (dp[1][2] + dp[2][2]) % MOD
    T[1][0] = (dp[0][2] + dp[2][2]) % MOD
    T[1][1] = (dp[0][0] + dp[2][0]) % MOD
    T[1][2] = (dp[0][1] + dp[2][1]) % MOD
    T[2][0] = (dp[0][1] + dp[1][1]) % MOD
    T[2][1] = (dp[0][2] + dp[1][2]) % MOD
    T[2][2] = (dp[0][0] + dp[1][0]) % MOD
    dp, T = T, dp

m = sum(a) % 3

ans = 3 ** (n-1) - (dp[0][m] + dp[1][m] + dp[2][m])

check = 1
for i in range(n-1):
    if a[i] == a[i+1]:
        check = 0
        break

ans += check

#print(dp, 2 ** (n-1))

print(ans % MOD)


Measured memory_bytes: 6460
#include <iostream>
using namespace std;
int main() {
	string S;
	cin >> S;
	if (S[0]==S[1] || S[1]==S[2] || S[2]==S[3] ) {
		cout << "Bad" << endl;
    } 
	else {
		cout << "Good" << endl;
	}
	return 0;
}

Measured memory_bytes: 3608
function Main(input) {
	var input = input.split(" ");
	var n = parseInt(input[0]);
	var r = parseInt(input[1]);
	var rate = 0;

	if(n >= 10) {
		rate = r;
	} else {
		rate = r + (100 * (10 - n));
	}
	console.log(rate);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

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

    int D;
    cin >> D;
    vector<int> c(26), cc(26);
    rep(i, 26) {
        cin >> c[i];
        cc[i] = c[i];
    }
    vector<vector<int>> s(D);
    rep(i, D) {
        s[i].resize(26);
        rep(j, 26) cin >> s[i][j];
    }

    rep(d, D) {
        int x = -1;
        int best = -1000000;
        rep(i, 26) {
            int tmp = s[d][i] + cc[i];
            if (best < tmp) {
                x = i;
                best = tmp;
            }
        }
        cout << (x+1) << endl;
        rep(i, 26) {
            if (i == x) {
                cc[i] = c[i];
            } else {
                cc[i] += c[i];
            }
        }
    }

    return 0;
}




Measured memory_bytes: 3672
def main():
    N = int(input())
    max_d = 1
    while N >= sum([26**i for i in range(max_d + 1)]):
        max_d += 1
    digits = [0 for _ in range(max_d)]
    for k in range(max_d - 1, -1, -1):
        r = N - sum([26**i for i in range(k)])
        digits[k] = r // (26 ** k)
        N -= digits[k] * (26 ** k)
    digits.reverse()
    ans = ''
    for d in digits:
        ans += chr(d - 1 + ord('a'))
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		String a=sc.next();
		String b=sc.next();
		String c =sc.next();
		System.out.println(String.valueOf(a.charAt(0))+b.charAt(0)+c.charAt(0));
	}

}

Measured memory_bytes: 9680
#include<cstdio>
#define MAX 10000
#define NIL -1

struct Node {int parent,left,right;};

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
	if(u==NIL)return;
	D[u]=d;
	setDepth(T[u].left,d+1);
	setDepth(T[u].right,d+1);
}

int setHeight(int u){
	int h1=0,h2=0;
	if(T[u].left!=NIL)
	h1=setHeight(T[u].left)+1;
	if(T[u].right!=NIL)
	h2=setHeight(T[u].right)+1;
	return H[u]=(h1>h2?h1:h2);
}

int getSibling(int u){
	if(T[u].parent==NIL)return NIL;
	if(T[T[u].parent].left!=u&&T[T[u].parent].left!=NIL)
	return T[T[u].parent].left;
	if(T[T[u].parent].right!=u&&T[T[u].parent].right!=NIL)
	return T[T[u].parent].right;
	return NIL;
}

void print(int u){
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].parent);
	printf("sibling = %d, ",getSibling(u));
	int deg=0;
	if(T[u].left!=NIL)deg++;
	if(T[u].right!=NIL)deg++;
	printf("degree = %d, ",deg);
	printf("depth = %d, ",D[u]);
	printf("height = %d, ",H[u]);
	
	if(T[u].parent==NIL){
		printf("root\n");
	}else if(T[u].left==NIL&&T[u].right==NIL){
		printf("leaf\n");
	}else{
		printf("internal node\n");
	}
}

int main(){
	int v,l,r,root=0;
	scanf("%d",&n);
	
	for(int i=0;i<n;i++)T[i].parent=NIL;
	
	for(int i=0;i<n;i++){
		scanf("%d %d %d",&v,&l,&r);
		T[v].left=l;
		T[v].right=r;
		if(l!=NIL)T[l].parent=v;
		if(r!=NIL)T[r].parent=v;
	}
	
	for(int i=0;i<n;i++)if(T[i].parent==NIL)root=i;
	
	setDepth(root,0);
	setHeight(root);
	
	for(int i=0;i<n;i++)print(i);
	
	return 0;
}


Measured memory_bytes: 2760