akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll MOD2=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);

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 (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

const int MAX = 200010;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD2;
        inv[i] = MOD2 - inv[MOD2%i] * (MOD2 / i) % MOD2;
        finv[i] = finv[i - 1] * inv[i] % MOD2;
    }
}

// 二項係数計算
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] % MOD2) % MOD2;
}
//main関数にCOMinit();を忘れない

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;
}

void solve(int ca){
    COMinit();

    ll ans=0ll;

    ll N,M,K;
    cin>>N>>M>>K;

    for (ll i = 0; i <= K; ++i) {
        (ans+=(M*modpow(M-1ll,N-1ll-i,MOD2))%MOD2*COM(N-1ll,i))%=MOD2;
    }
    cout<<ans<<endl;
}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 8328
#include <bits/stdc++.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    char a,b;
    scanf("%c %c",&a,&b);
    (a==b) ? puts("H") : puts("D");
    return 0;
}

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

void solve()
{
    int n;
    cin >> n;

    n = n%10;

    if(n == 2 || n==4 || n==7 || n==5 || n==9)
    {
        cout << "hon";
    }
    else if(n == 0 || n==1 || n==6 || n==8)
    {
        cout << "pon";
    }
    else
    {
        cout << "bon";
    }
}


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


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rev(a) reverse(all(a)
#define ld long double
const ll mod=1e9+7;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
int main() {
    ll n;
    cin >> n;
    ll ans=0;
    for(ll i=1; i<=n; i++){
        for(ll j=1; j<=n; j++){
            for(ll k=1; k<=n; k++){
                ans+=__gcd(__gcd(i,j),k);
            }
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>
#include <iomanip>
#include <set>
#include <queue>
const int MOD = 1000000007;


ll POWER(ll x,ll y)
{
	ll ret=1;
	ll p=x;
	for (ll i=y;i>0;i/=2)
	{
		if (i%2) ret=(ret*p)%MOD;
		p=(p*p)%MOD;
	}
	return ret;
}
ll gcm(ll a, ll b)
{
	if (b>a) {ll c=a; a=b; b=c;}
	while (b>0)
	{
		ll r=a%b;
		a=b;
		b=r;
	}
	return a;
}


int main(int argc, char *argv[])
{
	int n,m;
	cin>>n>>m;
	vector<int> c(n+1,0),d(n+1);

	vector<set<int>> ab(n+1);

	for (int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		ab[a].insert(b);
		ab[b].insert(a);
	}
	c[1]=1;
	int rest=n-1;
	queue<int> q;
	q.push(1);

	while (!q.empty())
	{

		int a=q.front();
		q.pop();
		auto it=ab[a].begin();
		while (it!=ab[a].end())
		{
			if (c[*it]==0)
			{
				c[*it]=c[a]+1;
				d[*it]=a;
				q.push(*it);
			}
			it++;
		}
	}
	
	cout<<"Yes"<<endl;
	for (int i=2;i<=n;i++)
	{
		cout<<d[i]<<endl;
	}
	return 0;
}



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

#define F first
#define S second

// for debug
unsigned long long xor128() {
    static unsigned long long rx = 123456789, ry = 362436069, rz = 521288629, rw = 88675123;
    unsigned long long rt = (rx ^ (rx << 11));
    rx = ry;
    ry = rz;
    rz = rw;
    return (rw = (rw ^ (rw >> 19)) ^ (rt ^ (rt >> 8)));
}


struct UnionFind{
  int n;
  vector<int> ran,p,cnt;
  UnionFind(){}
  UnionFind(int sz):n(sz),ran(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(ran[x]<ran[y]) swap(x,y);
    ran[x]+=ran[y];
    p[y]=x;
  }
  int sum(int x){
    return ran[find(x)];
  }
};




long long ans;
int n,root,x[100009],y[100009];
map<Pii,int>M;

class Node{
public:
  int location;
  int p,l,r;
  Node(){}
};

class Point{
public:
  int id,x,y;
  Point(){}
  Point(int id,int x,int y): id(id),x(x),y(y){}
  bool operator < (const Point &p){return id<p.id;}
};

static const int MAX =1000000;
static const int NIL = -1;

Point P[MAX];
Node T[MAX];
int np;

bool lessX(Point &p1,Point &p2){return p1.x<p2.x;}
bool lessY(Point &p1,Point &p2){return p1.y<p2.y;}

int makeKDTree(int l,int r, int d){
  if(!(l<r))return NIL;
  int mid=(l+r)>>1;
  int t=np++;
  nth_element(P+l,P+mid,P+r,(d&1 ? lessY : lessX));
  T[t].location=mid;
  T[t].l=makeKDTree(l,mid,d+1);
  T[t].r=makeKDTree(mid+1,r,d+1);
  return t;
}

void find(int v,int sx,int tx,int sy,int ty,int d,vector<Point> &ans){
  int x=P[T[v].location].x;
  int y=P[T[v].location].y;
  if(sx<=x&&x<=tx&&sy<=y&&y<=ty)ans.push_back(P[T[v].location]);
  if(d%2==0){
    if(T[v].l!=NIL)if(sx<=x)find(T[v].l,sx,tx,sy,ty,d+1,ans);
    if(T[v].r!=NIL)if(x<=tx)find(T[v].r,sx,tx,sy,ty,d+1,ans);
  }
  else{
    if(T[v].l!=NIL)if(sy<=y)find(T[v].l,sx,tx,sy,ty,d+1,ans);
    if(T[v].r!=NIL)if(y<=ty)find(T[v].r,sx,tx,sy,ty,d+1,ans);
  }
}

bool exist(int v,int sx,int tx,int sy,int ty,int d,int left){
  int x=P[T[v].location].x;
  int y=P[T[v].location].y;
  if(sx<=x&&x<=tx&&sy<=y&&y<=ty)return 1;
  if(d%2==0){
    if(T[v].l!=NIL&&sx<=x && exist(T[v].l,sx,tx,sy,ty,d+1,left))return 1;
    if(T[v].r!=NIL&&x<=tx && exist(T[v].r,sx,tx,sy,ty,d+1,left))return 1;
  }
  else{
    if(T[v].l!=NIL&&sy<=y && exist(T[v].l,sx,tx,sy,ty,d+1,left))return 1;
    if(T[v].r!=NIL&&y<=ty && exist(T[v].r,sx,tx,sy,ty,d+1,left))return 1;
  }
  return 0;
}


signed main(){
	int n;
	cin>>n;

	rep(i,n){
		int x,y;
		scanf("%d %d",&x,&y);
		P[i]=Point(i,x,y);
		T[i].l=T[i].r=T[i].p=NIL;
	}
	np=0;
	int root=makeKDTree(0,n,0);
	int q;
	cin>>q;
	int sx,sy,tx,ty;
	vector<Point>ans;
	rep(i,q){
		scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
		ans.clear();
		find(root,sx,tx,sy,ty,0,ans);
		sort(ans.begin(),ans.end());
		rep(j,ans.size())printf("%d\n",ans[j].id);
		cout<<endl;
	}
	return 0;

}


Measured memory_bytes: 16408
#include "bits/stdc++.h"
using namespace std;

using lli = long long int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
  int n,m;
  cin>>n>>m;
  vector<int> vi(n, 0);
  
  int a,b;
  rep(i, m) {
    cin>>a>>b;
    vi.at(a-1)++;
    vi.at(b-1)++;
  }

  rep(i, n) cout<<vi.at(i)<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int N;
    cin >> N;
    vector<int> A(N), B(N);
    rep(i,N) cin >> A[i] >> B[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end(), greater<int>());

    if (N % 2 == 1) cout << B[N / 2] - A[N / 2] + 1 << endl;
    else {
        int ans = 0;
        ans += B[N / 2] + B[N / 2 - 1];
        ans -= A[N / 2] + A[N / 2 - 1];
        ans += 1;
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4840
import java.util.ArrayList;
import java.util.Scanner;




class Main{


	static	ArrayList<Integer> one ;
	static	ArrayList<Integer> two ;
	static	ArrayList<Integer> three ;
	static	ArrayList<Integer> four ;
	static long pow = 1000000007;

	static int n;
	static int m;
	static int ans  = 0;
	static int[][] g;
	static boolean[] used;



	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);			//文字の入力
		n =sc.nextInt();
		m =sc.nextInt();
		g = new int[n+1][n+1];
		for(int i = 0;i < m;i++){
			int a  = sc.nextInt();
			int b = sc.nextInt();
			g[a][b] = 1;
			g[b][a] = 1;
		}
//
//		for(int i = 1;i <= m;i++){					//mapの確認
//			for(int j = 1;j <= m;j++){
//				System.out.print(g[i][j]);
//			}
//			System.out.println();
//		}

		used = new boolean[n+1];
	
		used[1] = true;
		dfs(1,1);
		System.out.println(ans);


	}
	static void dfs(int p,int num){			//numは通った頂点の個数
		if(num == n){
			ans++;
		}

		for(int i = 1;i <= n;i++){
			if(!(used[i]) && g[p][i] == 1){
				num++;
				used[i] = true;
				dfs(i, num);
				num--;
				used[i] = false;
			}

		}


	}

}



class Pair implements Comparable{
	Character from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}




Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define sort(v) sort(all(v))
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main() {
    IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
	    int k,n;
	    cin>>k>>n;
	    ll ans=0;
	    vector<int>a(n);
	    for(int i=0;i<n;i++) cin>>a[i];
	    //sort(a);
	    int ans1=0;
	    int ma=-1;
	    for(int i=1;i<n;i++) {
	        ans+=(a[i]-a[i-1]);
	        //if(i>=2) ans1+=(a[i]-a[i-1])
	        ma=max(ma,a[i]-a[i-1]);
	    }
	    ans+=(a[0]+k-a[n-1]);
	    ma=max(ma,a[0]-a[n-1]+k);
	    cout<<ans-ma;
	}
	return 0;
}

Measured memory_bytes: 1024
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    A=LIST()
    A=sorted(A,reverse=True)
    al=len(A)
    alice=0
    bob=0
    for i in range(al//2):
        alice+=A[2*i]
        bob+=A[2*i+1]
    if al%2==1:
        alice+=A[-1]
    print(alice-bob)    
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt int Q[100005]={0}
#define mp make_pair
#define test() int t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<int>()) 
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(int i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(int i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=mpowe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}

string s;
ll tree[400000+5];
ll a[100000+5];
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a;
    if(a==0)
        return b; 
    return gcd(b, a % b);  
      
}
void build(ll node,ll start,ll end)
{
    if(start==end)
    {
        tree[node]=a[start];
        
    }
    else
    {
        ll mid = (start+end)/2;
        build(2*node+1,start,mid);
        build(2*node+2,mid+1,end);
        tree[node]=gcd(tree[2*node+1],tree[2*node+2]);
    }
}
void update(ll tree[],ll node,ll start,ll end,ll idx)
{
    if(start==end)
    {
        tree[node] = max(0LL,tree[node]-1);
    }
    else
    {
        ll mid = (start+end)/2;
        if(start<=idx && mid>=idx)
        {
            update(tree,2*node+1,start,mid,idx);
        }
        else
        {
            update(tree,2*node+2,mid+1,end,idx);
        }
        tree[node] = tree[2*node+1]+tree[2*node+2];
    }
}
ll query(ll node,ll start,ll end,ll l,ll r)
{
    if(r<start || l>end)
    {
        return 0;
    }
    if(l<=start && r>=end)
    {
        return tree[node];
    }
    ll mid = (start+end)/2;
    ll p1 = query(2*node+1,start,mid,l,r);
    ll p2 = query(2*node+2,mid+1,end,l,r);
   return gcd(p1,p2);
}

int main()
{                       
    fastio();
   
    ll k,n;
    cin>>k>>n;
    ll a[n];
    cn(a,n);
    sort(a,a+n);
    ll d=0,p=0;
    for(int i=0;i<n-1;i++)
    {
        if(a[i+1]-a[i]>d)
        {
            d=a[i+1]-a[i];
            p=i;
        }
    }
    d=max(d,a[0]+k-a[n-1]);
    cout<<k-d<<endl;
}

Measured memory_bytes: 1792
n, k = map(int, input().split())
a = list(map(int, input().split()))

mod = 10 ** 9 + 7
N = n + 2

#逆元テーブル
inv_t = [0]+[1]
for i in range(2, N):
  inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]

#階乗計算
kai = [1, 1]
rev_kai = [1, inv_t[1]]
for i in range(2, N):
	kai.append(kai[-1] * i % mod)
	rev_kai.append(rev_kai[-1] * inv_t[i] % mod)

# コンビネーション計算
def cmb(n, r):
	return kai[n] * rev_kai[r] * rev_kai[n-r] % mod

ans = 0
a.sort(reverse = True)
for i in range(n-k+1):
    ans += cmb(n-1-i, k-1) * a[i]
    ans %= mod
a.reverse()
for i in range(n-k+1):
    ans -= cmb(n-1-i, k-1) * a[i]
    ans %= mod

print(ans % mod)


Measured memory_bytes: 72616
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
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;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int len;
char s[maxn];
int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
	//freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
	gbtb;
	cin>>s;
	len=strlen(s);
	rep(i,1,len)
	{
		if(s[i]==s[i-1])
		{
			cout<<i<<" "<<i+1<<endl;
			return 0;
		}else if(s[i]==s[i+1])
		{
			cout<<i+1<<" "<<i+2<<endl;
			return 0;
		}else if(s[i-1]==s[i+1])
		{
			cout<<i<<" "<<i+2<<endl;
			return 0;
		}

	}

	cout<<-1<<" "<<-1<<endl;
	
	
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define inf 1e18
#define err(x) cout<<x<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);



using namespace std;
int main()
{

    FASTIO
    ll n,l;
    vector <ll> ve;
    cin>>n>>l;
    bool ok = false;
    ll sum = 0;
    for(ll i=0;i<n;i++)
    {
        ll x = l+i;
        sum+=x;
        ve.pb(x);
        if(x==0ll)
        ok=true;
    }
    if(ok)
    cout<<sum;

    else
    {ll ans = inf;
        for(auto it:ve)
        {

        ans = min(abs(it),ans);
    }
    for(auto it:ve)
    {
        if(abs(it)==ans)
        {
            sum-=it;break;
        }
    }
    cout<<sum;

    }



cout << endl ;
return 0;
}


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

#define REP(i, M) for(int i = 0; i < M; i++)
#define R(p, k) for(int i = p; i <= k; i++)
#define RI(j, p, k) for(int j = p; j <= k; j++)
#define PB push_back
#define FI first
#define SE second
#define LL long long 
#define PII pair<int, int>

#define int long long

#define DEB 1

#if DEB
  #define CEN cerr << endl;
  #define CEL(a) cerr << #a << ": " << a << " "; 
  #define CES(s) cerr << s << endl;
#else
  #define CEN 
  #define CEL(a) 
  #define CES(s) 
#endif

string s, t;

const int MN = (LL)1000 * 1000 + 6, INF = (LL)1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 5; 
int n, m;
int res = 0;

int32_t main(){
  int i, j, a, b;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(7) << fixed;
   
  cin >> n >> m;
  cin >> s >> t;
  
  int d = __gcd(n, m);
  int l = n * m / d;
  
  unordered_map<int, int> let;
  
  for(int i = 0; i<n; i++) {
    let[l/n * i] = s[i];
  }
  
  
  for(int i = 0; i<m; i++) {
    auto it = let.find(l/m * i);
    if (it != let.end() && it->second != t[i]) {
      cout << "-1\n";
      return 0;
    }
  }
  
  cout << l << endl;
  return 0;
}


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

int main(){
	int n,a=0,b=0,c=0,o=0,x,y,z,w;
	char s[3];
	while(scanf("%d,%s",&n,s)!=EOF){
		if(s[1]=='B')c++;
		else if(s[0]=='A')a++;
		else if(s[0]=='B')b++;
		else o++;
	}
	cout<<a<<endl<<b<<endl<<c<<endl<<o<<endl;
}

Measured memory_bytes: 0
#include<stdio.h>
#define MAX 246913
int P[MAX],F[MAX]={0},i,j,p=0,r;
int main()
{
	int N;
	for(i=2;i<MAX;i++)
		if(!F[i])
		{
			P[p++]=i;
			for(j=i*2;j<MAX;j+=i)
				F[j]=1;
		}
	for(;scanf("%d",&N)*N;)
	{
		for(i=r=0;i<p;i++)
			if(P[i]>N&&P[i]<=2*N)
				r++;
		printf("%d\n",r);
	}
	return 0;
}

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

using namespace std;


int main() {
    int N;
    cin >> N;

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

    vector<int> a(N);
    vector<int> b(N);
    int B = 20005;
    for(int i = 0 ; i < p.size() ; i++){
        a[p[i]] = i + 1;
    }
    for(int i = 0 ; i < N ; i++){
        a[i] += i * B;
        b[i] -= i * B;
    }
    for(int i = 0 ; i < N ; i++){
        b[i] -= b[N-1] - 1;
    }
    for(int i = 0 ; i < N ; i++){
        cout << a[i] << " ";
    }
    cout << endl;
    for(int i = 0 ; i < N ; i++){
        cout << b[i ] << " ";
    }
    cout << endl;


}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
typedef pair<int,int> P;
vector<P> a;
int n;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        a.push_back(P(x,i));
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++) printf("%d ",a[i].se+1);
    return 0;
}



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

namespace ABC061A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a;
            int b;
            int c;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            if( c >= a && c <= b)
               Console.WriteLine("Yes");
            else 
               Console.WriteLine("No");

               Console.ReadKey();

        }
    }
}


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

const int N = 1e6+10; 

int vis[N];
int cnt[N];

void solve() {
    int n, m = 0;
    scanf("%d", &n);
    for (int i = 1, x; i <= n; i++) scanf("%d", &x), vis[x]++, m = max(m, x);

    for (int i = 1; i <= m; i++) {
        if (vis[i]) {
            for (int j = i; j <= m; j += i) cnt[j] += vis[i];
        }
    }

    int ans = 0;
    for (int i = 1; i <= m; i++) {
        if (cnt[i] == 1) {
            ans += vis[i];
        }
    }
    printf("%d\n", ans);

}

int main(){
    solve();

	return 0;
}


Measured memory_bytes: 11656
object Main extends App {
	val n = scala.io.StdIn.readInt
	
	var ans = 9999999

	for(x <- 1 until n){
		ans = math.min(ans, test(x)+test(n-x))
	}

	println(ans)

	def test(x: Int): Int = {
		var re = 0
		re += x/100000
		re += (x%100000)/10000
		re += (x%10000)/1000
		re += (x%1000)/100
		re += (x%100)/10
		re += x%10
		return re
	}

}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        vector<string> a(3); cin >> a;
        cout << a[0][0] << a[1][1] << a[2][2];
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3588
from collections import defaultdict
dic = defaultdict(int)

sl = list(input())
dic["a"] = 0
dic["b"] = 0
dic["c"] = 0
for s in sl:
    dic[s] += 1

if max(dic.values()) - min(dic.values()) <= 1:
    print("YES")
else:
    print("NO")



Measured memory_bytes: 49392
n,m,c=map(int,input().split())
b_list=list(map(int,input().split()))
count=0
for i in range(0,n):
    number=c
    a_list=list(map(int,input().split()))
    for j in range(0,m):
        number=number+a_list[j]*b_list[j]
    if number>0:
        count=count+1
print(count)



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

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define sz(a) int((a).size())
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define testcase int _;cin>>_;while(_--)


/*B-Minor Change*/
void Solve()
{
	string s,t;
	cin>>s>>t;
	int cnt=0;
	for(int i=0;i<sz(s);i++)
		cnt+=(s[i]!=t[i]);
	cout<<cnt<<"\n";
}

int main()
{
	fast
	Solve();
	return 0;
}

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if (a>b) swap(a,b);
    if (b>c) swap(b,c);
    if (a>b) swap(a,b);
    cout<<a<<' '<<b<<' '<<c<<endl;
    return 0;
}


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

namespace C_ABC131
{
    class MainClass
    {

        static long[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), long.Parse);
            long c = s[1] / s[2];
            c -= (s[0] - 1) / s[2];
            long d = s[1] / s[3];
            d -= (s[0] - 1) / s[3];
            long gcd = Koubai(s[2], s[3]);
            long katsu = s[1] / gcd;
            katsu -= (s[0] - 1) / gcd;

            long ans = s[1] - s[0] + 1 - c - d + katsu;

            //Console.WriteLine("c:{0} d:{1} katsu:{2} gcd:{3}", c, d, katsu, gcd);

            Console.WriteLine(ans);



        }

        public static long Koubai(long a, long b)
        {
            long tmp;
            // a<bにする
            if (a >= b)
            {
                tmp = a;
                a = b;
                b = tmp;
            }
            long x = a * b;

            long r = b % a;
            while (r != 0)
            {
                b = a;
                a = r;
                r = b % a;
            }
            return x / a;

        }
    }


}


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

using namespace std;

int n,k,min1;
int a[100001],dp[100001];
int go(int i)
{ if(i>=n)
    return 0;
  else
  { if(dp[i]==-1)
  	{
  	 dp[i]=INT_MAX;
  	 for(int j=1;j<=k;j++)
  	  {
  	  	 if(i+j<n)
  	  	   {
  	  	   	  dp[i]=min(dp[i],abs(a[i+j]-a[i])+go(i+j));
  	  	   }
  	  }   
  	if(i+1>=n)
  	   dp[i]=0;
    }
    return dp[i];
  }
}
int main()
{
  cin>>n>>k;
  for(int i=0;i<n;i++)
    cin>>a[i];
  memset(dp,-1,sizeof(dp));  
  cout<<go(0)<<'\n';  
  return 0;
}

Measured memory_bytes: 7808
function main(input) {
    const args = input.split(' ');
    const n = parseInt(args[0], 10);
    const a = parseInt(args[1], 10);
    const b = parseInt(args[2], 10);
  
   console.log(Math.min(n * a, b))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
N = int(input())
A = sorted(list(map(int, input().split())))

tmp = 0
sum_a = sum(A)
ind = N+1
for i in range(N-1):
    tmp += A[i]*2
    if tmp < A[i+1]:
        ind = i

if ind == N+1:
    print(N)
else:
    print(N-ind-1)

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

const int N = 1e5 + 10;
int a[N][3], dp[N][3];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < 3; j++)
            cin >> a[i][j];
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    for (int i = 1; i < n; i++)
        for (int j = 0; j < 3; j++)
            for (int k = 0; k < 3; k++)
                if (k != j)
                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);
    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << "\n";
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

ll n,a,b;
ll h[100010];

bool check(ll x){
	ll v[100010];
	FOR(i,n){
		v[i]=h[i]-x*b;
	}
	ll sum=0;
	FOR(i,n){
		if(v[i]>0){
			sum+=v[i]/a+1;
			if(v[i]%a==0)sum--;
		}
	}
	return sum<=x;
}

int main(){
	cin >> n >> a >> b;
	a-=b;
	FOR(i,n)cin >> h[i];
	ll l=0,r=10000000000,mid;
	while(l+1<r){
		mid=(l+r)/2;
		if(check(mid)){
			r=mid;
		}else{
			l=mid;
		}
	}
	cout << l+1 << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int>arr(n);
	rep(i, n)cin >> arr[i];
	int l = 0, r = 1e9;
	while (r - l> 1) {
		int m = (l + r) / 2;
		auto cut = [&](int m) {
			ll cnt = 0;
			rep(i, n)cnt += (arr[i] - 1) / m;
			return cnt <= k;
		};
		if (cut(m))r = m;else l = m;
	}
	cout << r << endl;
	return 0;
}



Measured memory_bytes: 4028
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int high[n];
    for(int i=0; i<n; i++){
        cin >> high[i];
    }
    int M=high[0];
    int ans=1;
    for(int i=1; i<n; i++){
        if(M<=high[i]){
            ans++;
            M=high[i];
        }
    }
    cout << ans;

    return 0;
}

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

int n, c;
ll ans = 1;
map<int, int> mp;

int main(){
	scanf("%d", &n);
	for(int x; n--; ){
		scanf("%d", &x);
		mp[-x]++;
	}
	for(auto &i : mp){
		if(!c && i.second >= 4){
			c = 2;
			ans = 1LL * i.first * i.first;
			break;
		}
		if(i.second >= 2){
			c++;
			ans *= i.first;
			if(c == 2) break;
		}
	}
	printf("%lld\n", ans * (c == 2));
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, p,k, sum = 0;
	cin >> n >> m >> p >> k;
	sum = max(sum, n);
	sum = max(sum, m);
	sum = max(sum, p);
	cout << n + m + p + sum * pow(2, k) - sum;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	int a=s.size();
	int js=0;
	for(int i=0;i<a;i++)
	{
		if(s[i]!=t[i]) js++;
	}
	cout<<js<<endl;
 } 

Measured memory_bytes: 3832
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long


vector<int> ch[1100];
int p[1100];
int v[1100];
int d[1100];
int dp[5100];

int main()
{
  int i,j,n,ma,x,y,tot,k;
  vector<int> q;
  scanf("%d",&n);
  for (i=0;i<n;i++)
    ch[i].clear();
  p[0]=-1;
  for (i=1;i<n;i++)
  {
    scanf("%d",&x);
    x--;
    p[i]=x;
    ch[x].push_back(i);
  }
  for (i=0;i<n;i++)
    scanf("%d",&v[i]);
  q.clear();
  q.push_back(0);
  for (i=0;i<q.size();i++)
  {
    x=q[i];
    for (j=0;j<ch[x].size();j++)
      q.push_back(ch[x][j]);
  }
  for (i=q.size()-1;i>=0;i--)
  {
    x=q[i];
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    ma=0;
    tot=0;
    for (j=0;j<ch[x].size();j++)
    {
      y=ch[x][j];
      //cout<<"x,y:"<<x<<" "<<y<<endl;
      tot+=d[y];
      tot+=v[y];
      for (k=ma;k>=0;k--)
        if (dp[k]==1)
        {
          dp[k]=0;
          if (k+v[y]<5100)
            dp[k+v[y]]=1;
          if (k+d[y]<5100)
            dp[k+d[y]]=1;
        }
      if (v[y]>d[y]) ma+=v[y];
      else ma+=d[y];
      if (ma>=5100) ma=5099;
    }
    for (j=v[x];j>=0;j--)
      if (dp[j]==1)
      {
        d[x]=tot-j;
        break;
      }
    if (j==-1)
    {
      printf("IMPOSSIBLE\n");
      return 0;
    }
    //cout<<x<<" "<<d[x]<<" "<<v[x]<<endl;
  }
  printf("POSSIBLE\n");
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
using ll = long long;

long m, n, l;
long a[111][111], b[111][111], c[111][111];

int main()
{
    cin >> n >> m >> l;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < l; j++)
        {
            cin >> b[i][j];
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < l; j++)
        {
            for (int k = 0; k < m; k++)
            {
                c[i][j] += a[i][k] * b[k][j];
            }
            cout << c[i][j] << (j == l - 1 ? "\n" : " ");
        }
    }
}


Measured memory_bytes: 3376
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, X: "List[int]"):
    ans = INF
    for i in range(1, 101):
        t = 0
        for j in range(N):
            t += (X[j]-i)**2

        ans = min(ans, t)

    print(ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long
#define vi vector<int>
#define mod 10000000
using namespace std;
int dp[100001];
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
 int n;
 cin>>n;
 int arr[100000];
 for(int i=0;i<n;i++)
 cin>>arr[i];
dp[2]=arr[1]-arr[0];
if(dp[2]<0)
dp[2]=arr[0]-arr[1];
 for(int i=3;i<=n;i++)
 {
 	int a=arr[i-1]-arr[i-2];
 	int b=arr[i-1]-arr[i-3];
 	if(a<0)
 	a=-a;
 	if(b<0)
 	b=-b;
 	dp[i]=min(dp[i-1]+a,dp[i-2]+b);
 }
 cout<<dp[n]<<endl;
    return 0;
}



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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;



  
int main() {
  string n;
  cin >> n;
  if(n[n.size()-1]=='s')
    cout << n << "es"<< endl;
  else{
    cout << n << "s"<< endl;
  }
    
}
      

Measured memory_bytes: 3624
#include <stdio.h>

int main(void)
{
    int H, W, i, j;
    while (1)
    {
        scanf("%d %d", &H, &W);

        if ((H == 0) && (W == 0))
        {
            break;
        }

        for (i = 0; i < H; i++)
        {
            for (j = 0; j < W; j++)
            {
                if ((i == 0) || (i == H - 1))
                {
                    printf("#");
                }

                else if((j==0)||(j==W-1))
                {
                    printf("#");
                }
                else
                {
                    printf(".");
                }
            }

            printf("\n");
        }

        printf("\n");
    }

    return 0;
}



Measured memory_bytes: 2044
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  private static Scanner sc = new Scanner(System.in);

  private void run() {
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int C = Integer.parseInt(sc.next());
    int D = Integer.parseInt(sc.next());

    int ans = Math.min(B, D) - Math.max(A, C);
    System.out.println(Math.max(ans, 0));
  }
}


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

using namespace std;


int main()
{
  int r, g, b, n;

  cin >> r >> g >> b >> n;

  int ret = 0;

  for(int i = n/r;
      i >= 0;
      --i)
    {
      if(i * r == n)
        {
          ++ret;
        }
      else
        {
          for(int j = (n - i*r)/g;
              j >= 0;
              --j)
            {
              if((i * r + j * g) == n)
                {
                  ++ret;
                }
              else
                {
                  if((n - i * r - j * g) % b == 0)
                    {
                      ++ret;
                    }
                }

            }
        }
    }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
typedef struct {
  int parent;
  int left; 
  int right;
  int depth;
} node;
 
 
void initializNodeArray(node* a, int n) {
  int i;
 
  for( i=0; i<n; i++) {
    a[i].parent = -1;
    a[i].left = -1;
    a[i].right = -1;
  }
 
}
 
 
void treeWalkForDepth(node* a, int root, int depth) {
  a[root].depth = depth;
   
  if( a[root].left != -1 ) {
    treeWalkForDepth( a, a[root].left, depth+1 ); 
  }
  if( a[root].right != -1) {
    treeWalkForDepth( a, a[root].right, depth );
  }
 
}
 
 
int rootNodeSearch(node* a, int n) {
  int i;
 
  for( i=0; i<n; i++) {
    if( a[i].parent == -1 ) {
      return i;
    }
  }
 
}
 
 
main() {
 
  int n, k, id, children, parent;
  node* a;
   
  int i, j;
 
  scanf("%d", &n);
 
  a = (node*)malloc( sizeof(node) * n );
 
  initializNodeArray( a, n);
 
  for( i=0; i<n; i++) {
    scanf("%d", &id);
 
    scanf("%d", &k);
 
    for( j=0; j<k; j++) {
      if( j==0 ) {
    scanf("%d", &a[id].left);
    children = a[id].left;
    a[children].parent = id;
      }else {
    scanf("%d", &a[children].right);
    children = a[children].right;
    a[children].parent = id;
      }
    }
 
  }
  treeWalkForDepth( a, rootNodeSearch( a, n), 0);
   
  for( i=0; i<n; i++) {
    printf("node %d: parent = %d, depth = %d, ", i, a[i].parent, a[i].depth);
 
    if( a[i].parent == -1 ) {
      printf("root, ");
    }else if( a[i].left == -1 ) {
      printf("leaf, ");
    }else {
      printf("internal node, ");
    }
 
    printf("[");
    if( a[i].left != -1){
      printf("%d",a[i].left);
      children = a[i].left;
 
      while(1) {
    if( a[children].right != -1) {
      printf(", %d", a[children].right);
      children = a[children].right;
    }else {
      break;
    }
      }
    }
    printf("]");
       
 
    printf("\n");
 
  }
 
    return 0;
 
}
  

Measured memory_bytes: 2168
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int kazu,i,j,cnt=0,hz;
		Scanner sca = new Scanner(System.in);
		kazu=sca.nextInt();
		int hai[]=new int[kazu];
		for(i=0;i<kazu;i++){
			hai[i]=sca.nextInt();
		}
       for(i=0;i<kazu-1;i++){
    	   for(j=kazu-1;j>0;j--){
    		   if(hai[j]<hai[j-1]){
    			   hz=hai[j];
    			   hai[j]=hai[j-1];
    			   hai[j-1]=hz;
    			   cnt++;
    		   }
    	   }
	}
     for(i=0;i<kazu;i++){
    if(i!=kazu-1){	 
     System.out.print(hai[i]+" ");
     }else{
    	 System.out.println(hai[i]);
     }
     }
     System.out.println(cnt);

}
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
const int MOD = 1e9+7;
const int MX = 2e5+5;
const ll  INF = 1e18;
const ld  PI = acos((ld) -1);
template<class T> inline void array_input(T a[], size_t n){for(size_t i = 0; i < n; i++)cin >> a[i];}

long long binExp(long long a, long long b, long long mod){
    long long res = 1;
    while(b > 0){
        if(b % 2) res = res * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return res;
}

ll gcd(ll a, ll b, ll &x, ll &y){
    x = 1, y = 0;
    int x1 = 0, y1 = 1;
    while(b){
        int q = a/b;
        tie(a, b) = make_tuple(b, a - q * b);
        tie(x, x1) = make_tuple(x1, x - q * x1);
        tie(y, y1) = make_tuple(y1, y - q * y1);
    }
    return a;
}
//#define FILE

int main(){
#ifdef FILE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // 0

    char x;
    int ans = 0;
    while(scanf("%c", &x) && isdigit(x)){
        ans += x -'0';
        ans %= 9;
    }
    if(ans % 9 == 0) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 3652
n = int(input())
h = list(map(int, input().split()))
ans = []
res = 0
nh = h[0]
for i in range(1, n):
    if nh >= h[i]:
        res += 1
        nh = h[i]
    else:
        ans.append(res)
        res = 0
        nh = h[i]
ans.append(res)
print(max(ans))

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

const int mod = 1000000007;
struct modint{
  ll x;
  modint(ll x = 0):x((x%mod+mod)%mod){}
  modint& operator+=(const modint a){
    x += a.x;
    if(x >= mod) x -= mod;
    return *this;
  }

  modint operator+(const modint a)const{
    modint res(*this);
    return res += a;
  }
};

int main(){
  int h,w;
  cin>>h>>w;
  vector<string> m(h);
  rep(i,h) cin>>m[i];
  vector<vector<modint>> dp(h+1,vector<modint>(w+1));
  
  dp[1][1] = 1;
  rep(i,h){
    rep(j,w){
      if(i == 0 && j == 0) continue;
      if(m[i][j] == '#') continue;
      dp[i+1][j+1] = dp[i][j+1] + dp[i+1][j];
    }
  }
  
  cout << dp[h][w].x << endl;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int N;
  cin >> N;
  vector<long> num(87);
  
  num.at(0) = 2;
  num.at(1) = 1;
  
  for(int i = 2; i < N + 1; i++){
    num.at(i) = num.at(i - 1) + num.at(i - 2);
  }
  
  cout << num.at(N) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		int n = stdIn.nextInt();
		int m = stdIn.nextInt();

		System.out.println(n*(n-1)/2+m*(m-1)/2);

		stdIn.close();
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  ll a,b,c=0,d=0,e,n,m,ans=0;
  string s,t;
  bool f=false;
  cin>>a>>b;
  int x[a];
  rep(i,0,a){
    cin>>x[i];
    c+=x[i];
  }
  sort(x,x+a); reverse(x,x+a);
  rep(i,0,b) if(4*b*x[i]>=c) ans++;
  if(ans==b) co("Yes");
  else co("No");
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef pair<LL, int> pii;
typedef long double LD;
const int INF = 0x3f3f3f3f;

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
        if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}

const int N = 200200;
int a[N];

int opt(int x, int y) {
	return a[x] < a[y] ? x : y;
}
struct ST {
  const static int MAXN = 200200;
  int u[MAXN][20], n;
  int mm[MAXN];
  void init() {
    mm[0] = -1;
    for (int i = 1; i < MAXN; ++i) {
      mm[i] = mm[i >> 1] + 1;
    }
  }
  void build(int n) {
    this->n = n;
    for (int i = 0; i < n; ++i) u[i][0] = i;
    for (int j = 1; (1 << j) <= n; ++j) {
      for (int i = 0; i + (1 << j) <= n; ++i) {
        u[i][j] = opt(u[i][j- 1 ], u[i + (1 << (j - 1))][j - 1]);
      }
    }
  }
  int ask(int a, int b) {
    if (a > b) std::swap(a, b);
    int k = mm[b - a + 1];
    return opt(u[a][k], u[b - (1 << k) + 1][k]);
  }
}A;
LL ans = 0;
void solve(int L, int R) {
	if(L > R) return ;
	int p = A.ask(L, R);
	ans += (p + 1 - L) * 1LL * a[p] * (R - p + 1);
	solve(L, p - 1);
	solve(p + 1, R);
}
int main() {
	int n;
	cin >> n;
	for(int i = 0; i < n; i ++) scanf("%d", &a[i]);
	A.init();
	A.build(n);
	solve(0, n - 1);
	cout << ans << endl;
}


Measured memory_bytes: 23680
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    cunt,ans=0,0
    min_a=10**9
    for a in A:
        if a<0:
            cunt+=1
            ans+=-a
            min_a=min(-a,min_a)
        else:
            ans+=a
            min_a=min(a,min_a)
    if cunt%2==1:
        print(ans-2*min_a)
    else:
        print(ans)

if __name__=='__main__':
    main()

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

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//マクロ
// forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
// FORAは範囲for文(使いにくかったら消す)
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000  // 10^12:∞
#define MOD 1000000007     // 10^9+7:合同式の法
#define MAXR 100000        // 10^5:配列の最大のrange
//略記
#define PB push_back  //挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素

typedef long long ll;

using namespace std;
int main() {
  string S, T;
  cin >> S >> T;
  REP(i, SIZE(S)) {
    if (S == T) {
      cout << "Yes";
      return 0;

    } else {
      string tmp = T;
      tmp.erase(SIZE(T) - 1);
      T = T[SIZE(T) - 1] + tmp;
    }
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 3528
# coding:utf-8

h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
# print(c)
black = 0
ans = 0

for bit_h in range(2**h):
    for bit_w in range(2**w):
        black = 0
        for i in range(h):
            for j in range(w):
                if ((bit_h >> i) & 1) and ((bit_w >> j) & 1) and c[i][j] == '#':
                    black += 1
        if black == k:
            ans += 1
print(ans)

Measured memory_bytes: 9200
#!/usr/bin/python3
# abc121_b

"""
Can you solve this?
"""

def main():
    """
    inputしたらすぐに計算して合否を判断、
    正解数を1増やす。
    """
    N, M, C = map(int, input().split())
    B = list(map(int, input().split()))

    counter = 0  # 正当数をカウントする
    temp_answer = 0

    for _ in range(N):
        temp_answer = 0
        A = list(map(int, input().split()))

        for i in range(M):
            temp_answer += A[i] * B[i]

        if temp_answer + C > 0:
            counter += 1

    print(counter)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
def evalList(a, b):
    try:
        i = a.index(b)
        a[i] = 0
    except ValueError:
        pass


def evalBingo(i, j, k):
    return True if sum([i, j, k]) == 0 else False


a1 = list(map(int, input().split(' ')))
a2 = list(map(int, input().split(' ')))
a3 = list(map(int, input().split(' ')))
n = int(input())
for i in range(n):
    b = int(input())
    evalList(a1, b)
    evalList(a2, b)
    evalList(a3, b)

isBingo = (
    evalBingo(a1[0], a1[1], a1[2]) or
    evalBingo(a2[0], a2[1], a2[2]) or
    evalBingo(a3[0], a3[1], a3[2]) or
    evalBingo(a1[0], a2[1], a3[2]) or
    evalBingo(a3[0], a2[1], a1[2]) or
    evalBingo(a1[0], a2[0], a3[0]) or
    evalBingo(a1[1], a2[1], a3[1]) or
    evalBingo(a1[2], a2[2], a3[2])
)

print('Yes' if isBingo else 'No')


Measured memory_bytes: 3064