akhauriyash/Code-Regression huggingface dataset:
#include <string>
#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";
  }
  else
  {
    cout << "Good";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
	int n;
    cin>>n;
    int count=0;
  	for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
        for(int k=1;k<=n;k++){
          count += __gcd(i,__gcd(j,k));
        }
      }
    }
  cout<<count<<'\n';
}

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

int main(){
                                                                     

    long long n, m, i, j;

    
    cin >> n >> m;


    vector<long long> x(n + 1);

    vector<long long> y(m + 1);
    

    long long sx = 0;

    long long sy = 0;


    for( i = 1 ; i <= n ; i = i + 1 ){

         cin >> x.at(i);         

         }


    for( i = 1 ; i <= n ; i = i + 1 ){
 
         sx += ( ( i - 1 ) * x.at(i) - ( n - i ) * x.at(i) );
 
         sx = sx % 1000000007;

         }


    for( i = 1 ; i <= m ; i = i + 1 ){

         cin >> y.at(i);

         }


    for( i = 1 ; i <= m ; i = i + 1 ){
 
         sy += ( ( i - 1 ) * y.at(i) - ( m - i ) * y.at(i) );
 
         sy = sy % 1000000007;

         }


    cout << ( sx * sy ) % 1000000007 << endl;

    return 0;

    }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  cout << a + b + c + 9 * max(a, max(b, c)) << endl;

  return 0;
}


Measured memory_bytes: 256
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		FastScanner sc=new FastScanner();
		int n=sc.nextInt();
		long a[]=new long[n+1];
		for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j+=i)
		a[j]++;
		
		long ans=0;
		for(int i=0;i<=n;i++)
		ans+= i*a[i];
		
		System.out.println(ans);
		
		
	}
		static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
}
}


Measured memory_bytes: 112592
#include<stdio.h>
int main()
{
int W,H,x,y,r;
scanf ("%d%d%d%d%d",&W,&H,&x,&y,&r);
if( x>=r && (W-x)>=r && y>=r && (H-y)>=r )
printf ("Yes\n");
else printf ("No\n");
return 0;
}


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

namespace ABC115A
{
    class Program
    {
        static void Main(string[] args)
        {
            var d = Console.ReadLine();
            if (d == "25")
            {
                Console.WriteLine("Christmas");
            }
            else if (d == "24")
            {
                Console.WriteLine("Christmas Eve");
            }
            else if (d == "23")
            {
                Console.WriteLine("Christmas Eve Eve");
            }
            else
            {
                Console.WriteLine("Christmas Eve Eve Eve");
            }
        }
    }
}


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

const ll inf = 0x3f3f3f3f3f3f3f3f;
const int mx = 100005;

ll dist[mx];
vector<pair<ll, int> > adj[mx];
bitset<mx> inq;
int v, e, r;
int q[mx], qh, qt;

int qpop() {
  int v = q[qh++];
  if (qh > mx) qh = 0;
  return v;
}

void qpush(int v) {
  q[qt++] = v;
  if (qt > mx) qt = 0;
}

int main() {
  qh = qt = 0;
  cin >> v >> e >> r;
  for (int i = 0; i < v; i++)
    dist[i] = inf;
  for (int i = 0; i < e; i++) {
    int s, t, d; cin >> s >> t >> d;
    adj[s].push_back({ d, t });
  }
  dist[r] = 0;
  qpush(r);
  while (qh != qt) {
    int p = qpop();
    inq[p] = false;
    for (auto h : adj[p]) {
      int t = h.second;
      ll d = h.first + dist[p];
      if (d < dist[t]) {
	dist[t] = d;
	if (!inq[t])
	  inq[t] = true, qpush(t);
      }
    }
  }
  for (int i = 0; i < v; i++) {
    if (dist[i] < inf / 2) cout << dist[i] << endl;
    else cout << "INF" << endl;
  }
}



Measured memory_bytes: 18036
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int AB = sc.nextInt();
        int BC = sc.nextInt();
        int CA = sc.nextInt();
        
        int ans = (AB * BC) / 2;
        
        System.out.println(ans);
        
        sc.close();
        
    }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
//const ll MOD=(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};


void solve(int ca){
    int N,M; cin>>N>>M;
    vector<ll> x(N),y(M);
    for (int i = 0; i < N; ++i) {
        cin>>x[i];
        x[i]+=1e9;
    }
    for (int j = 0; j < M; ++j) {
        cin>>y[j];
        y[j]+=1e9;
    }

    ll xsum=x[0], ysum=y[0];
    ll xlen=0ll,ylen=0ll;

    for (int i = 1; i < N; ++i) {
        (xlen+=((x[i]*i)%MOD-xsum+MOD))%=MOD;
        (xsum+=x[i])%=MOD;
    }


    for (int i = 1; i < M; ++i) {
        (ylen+=((y[i]*i)%MOD-ysum+MOD))%=MOD;
        (ysum+=y[i])%=MOD;
    }

    cout<<(xlen*ylen)%MOD<<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: 1792
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define vint vector<int>
#define vvint vector<vector<int>>

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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
  int n;cin >> n;
  if(n>88 || n%10==9) cout << "Yes" << endl;
  else cout << "No" << endl;


  return 0;
}


Measured memory_bytes: 256
line = gets
num = line.split(" ")
n,m = num[0].to_i , num[1].to_i
line = gets
coin = []
coin = line.split(" ")
dp = Array.new(50001,100000000)
dp[0] = 0
n.times{|i|
	m.times{|j|
		nx = coin[j].to_i + i.to_i
		dp[nx] = dp[nx] > dp[i] + 1 ? dp[i] + 1 : dp[nx] if nx <= n
	}
}
p dp[n]

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

int main() {
	string S;
	cin >> S;
	string abc = "abcab cbacb";
	if (abc.find(S) != string::npos) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

/**
 * <pre>
 * NumberOfIsland
 *
 * ??¶?????°???????????????
 * </pre>
 *
 * @author ?????????????????§???
 *
 */
public class Main{

	static boolean map[][] = new boolean[12][12];
	static int ans = 0;

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
		      for(int i=0;i<12;i++){
	                char[] c = sc.next().toCharArray();
	                for(int j=0;j<12;j++){
	                    map[i][j]=c[j]=='1';
	                }
	            }
	            int ans=0;
	            for(int i=0;i<12;i++){
	                for(int j=0;j<12;j++){
	                    if(map[i][j]){
	                        test(i, j);
	                        ans++;
	                    }
	                }
	            }
	            System.out.println(ans);
		} // ?????????????????????
	}// ?????????????????????????????????

	public static void test(int mh, int mw) {
		map[mh][mw] = false;
		int move_h[] = { 1, 0, -1, 0 };
		int move_w[] = { 0, 1, 0, -1 };
		for (int cnt = 0; cnt < 4; cnt++) {
			int tmp_h = mh + move_h[cnt];
			int tmp_w = mw + move_w[cnt];
			if (0 <= tmp_h && 0 <= tmp_w && tmp_h < map.length && tmp_w < map[0].length && map[tmp_h][tmp_w])//
				test(tmp_h, tmp_w);
		}
	}
}// ??????????????????????????????

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int n;
    vector<ll> a, b;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int ta, tb;
        cin >> ta >> tb;
        a.push_back(ta);
        b.push_back(tb);
    }

    int cnt = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        // cout << "next:" << a[i] + cnt << "," << b[i] << endl;
        if ((a[i] + cnt) % b[i])
        {
            // cout << "(a[i]+cnt)/b[i]+1:" << (a[i] + cnt) / b[i] + 1 << endl;
            // cout << (b[i] * ((a[i] + cnt) / b[i] + 1) - a[i]) << endl;
            cnt += (b[i] * ((a[i] + cnt) / b[i] + 1) - (a[i] + cnt));
        }
        // cout << "=" << cnt << endl;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 2036
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
typedef pair<int, int> P;

int p[29], ans = 0,a[29], b[29];
const int nmax = 8;
bool graph[nmax][nmax];
bool pairCompare(const P& firstElof, const P& secondElof)
{
	return firstElof.second < secondElof.second;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M;
	scanf("%d %d", &N ,&M);

	vector<P> warsP(M);
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		warsP[i] = P(a,b);
	}
	sort(warsP.begin(), warsP.end(), pairCompare);
	int ans = 1;
	int brk = 0;
	REP (i, warsP.size()) {
		int x = warsP[brk].second;
		if (x <= warsP[i].first) {
			brk = i;
			ans++;
		}
	}

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


Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){

  int X, Y, Z;
  cin >> X >> Y >> Z;

  cout << Z << " " << X << " " << Y << endl;

  return 0;
}

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

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

    vector<int> valueVec, costVec;

    for (int i = 0; i < n; ++i)
    {
        int input;
        cin >> input;
        valueVec.push_back(input);
    }

    for (int i = 0; i < n; ++i)
    {
        int input;
        cin >> input;
        costVec.push_back(input);
    }

    int result = 0;

    for (int i = 0; i < n; ++i)
    {
        int singleResult = valueVec.at(i) - costVec.at(i);

        result += max(0, singleResult);
    }

    cout << result << endl;
}

Measured memory_bytes: 256
//HovalHaq!
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxN = 1 << 17, INF = 1000 * 1000 * 1000 + 7;

int A[maxN], F[maxN], G[maxN];

int Rev(int x, int p = INF - 2) {
	if(p == 0) return 1;
	ll a = Rev(x, p / 2);
	a = (a * a) % INF;
	return (a * (p & 1 ? x : 1)) % INF;
}

ll C(int n, int k) {
	return (((ll(F[n]) * G[k]) % INF) * G[n - k]) % INF;
}

int main() {
	//Input
	int n, k; cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> A[i];
	sort(A, A + n);

	//Pre-Process
	F[0] = G[0] = 1;
	for(ll i = 1; i <= n; i++) F[i] = (F[i - 1] * i) % INF, G[i] = Rev(F[i]);
//	for(int i = 0; i <= n; i++) cout << F[i] << " " << G[i] << " " << F[i] * G[i] << "\n";
	

	//Process
	ll s = 0;
	for(int i = 0; i <= n - k; i++) {
//		cout << A[i] << " " << C(n - i - 1, k - 1) << "\n";
		s = (s - (A[i] * C(n - i - 1, k - 1)) % INF + INF) % INF;
	}
	for(int i = k - 1; i < n; i++) {
//		cout << A[i] << " " << C(i, k - 1) << "\n";
		s = (s + (A[i] * C(i, k - 1)) % INF) % INF;
	}

	//Output
	cout << s % INF;
}


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

int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    int top = y + r;
    int bottom = y - r;
    int right = x + r;
    int left = x - r;
    if ((top <= h) && (right <= w) && (bottom >= 0) && (left >= 0)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
        }
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int ans = max(0, (h2 * 60 + m2) - (h1 * 60 + m1) - k);
    cout << ans << endl;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String in = sc.nextLine();
		String [] inArray = in.split(" ");

		if (inArray[0].equals(inArray[1])) {
			System.out.println(inArray[2]);
		} else {
			if (inArray[0].equals(inArray[2])) {
				System.out.println(inArray[1]);
			} else {
				System.out.println(inArray[0]);
			}
		}


	}


}

Measured memory_bytes: 21844
def has_circuit(g: list, s: int, ng: int) -> bool:
    stack = []
    stack.append((s, -1))  # (現在の頂点, 親)

    while len(stack) > 0:
        u, p = stack.pop()

        if u == s and p >= 0:
            return True

        for v in g[u]:
            if v == ng:
                continue
            if v == p:
                continue
            stack.append((v, u))
    return False


def three_circuit(N: int, M: int, edges: list) -> bool:
    g = [[] for _ in range(N)]

    for u, v in edges:
        g[u-1].append(v-1)
        g[v-1].append(u-1)

    dims = [len(p) for p in g]

    if not all(d % 2 == 0 for d in dims):
        # オイラー閉路でない
        return False

    if max(dims) >= 6:
        # 次元数が 6 以上の頂点があるならそいつを利用して
        # 3 つのサーキットが作れる。
        return True

    # 次元数 4 の頂点集合
    vertexes = [v for v in range(N) if dims[v] == 4]

    if len(vertexes) >= 3:
        # 次元数 4 の頂点が 3 つ以上存在するなら OK
        return True

    if len(vertexes) == 2:
        # 次元数 4 の頂点が 2 つのみ存在する場合、ありうるのは、この
        # 2 頂点の間にパスが 4 つある場合と 2 つある場合。
        # 前者は図を書けばすぐわかるが高々 2 つのサーキットしか作れな
        # い。後者の場合は、この 2 頂点を含むサーキットが 1 つとそれ
        # ぞれの頂点しか含まないサーキットが 1 つずつ、計 3 つ作れる。

        # 次数 4 の頂点からスタートしてほかの次数 4 の頂点に出会わずに
        # 帰ってこれるパスが存在すれば次数 4 の頂点間にはパスがちょうど
        # 2 つとなる。
        return has_circuit(g, vertexes[0], vertexes[1])
    # 残りは 次数 4 の点が 1 つ、あるいはすべての頂点の次数が 2 となる。
    # 前者の場合、高々 2 つのサーキット、後者の場合は高々 1 つのサーキッ
    # トしか作れないのは自明。
    return False


if __name__ == "__main__":
    M = 0
    N, M = map(int, input().split())
    edges = [tuple(int(s) for s in input().split()) for _ in range(M)]

    yes = three_circuit(N, M, edges)
    print('Yes' if yes else 'No')


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
typedef pair<li, li> PI;


inline li calc(li n, li a, li b) {
	li bunbo = 4 * a * b - n * a - n * b;
	li bunshi = n * a * b;
	if (bunbo <= 0) {
		return -1;
	}
	if (bunshi % bunbo != 0) {
		return -1;
	}
	return bunshi / bunbo;
}

int main(void)
{
	li n;
	cin >> n;

	for (li a = 1; a <= 3500; ++a) {
		for (li b = 1; b <= 3500; ++b) {
			li c = calc(n, a, b);
			if (c > 0) {
				cout << a << " " << b << " " << c << endl;
				return 0;
			}
		}
	}

	return 0;
}

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

int main(void){
    string s;
    cin >> s;
    
    string first, second;
    int i;
    for(i = (s.length() - 1) / 2; i >= 1; i--){
        first = s.substr(0, i);
        second = s.substr(i, i);
        if(first == second){
            cout << i * 2 << endl;
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

 

using namespace std;

 

int main()
{
   int a , b;
   cin >> a >> b;
   if (a > b)
       cout << "a > b" <<endl;
      else if ( a < b )
      cout << "a < b" << endl;
      else if (a == b)
       cout << "a == b" << endl;
   
   return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

vector<int> h;
int water(int l,int r,int n){
	int p = *min_element(h.begin()+l,h.begin()+r);

	int sl=-1,a=p;
	for(int i=l;i<r+1;i++){
		int v;
		if(i<r){
			h[i] -= p;
			v = h[i];
		}
		else v = 0;
		if(v==0 && sl!=-1){
			a+=water(sl,i,n+p);
			sl = -1;
		}
		else if(v>0 && sl==-1){
			sl = i;
		}
	}
	return a;
}

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

	int N=in();
	h.resize(N);
	for(auto& x:h) x=in();

	cout << water(0,N,0) << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    int w,h,n;
    cin >> w >> h >> n;
    int x,y,a;
    int xl=0,xh=w,yl=0,yh=h;
    for(int i=0;i<n;i++){
        cin >> x >> y >> a;
        if(a==1){if(xl<x)xl=x;}
        if(a==2){if(xh>x)xh=x;}
        if(a==3){if(yl<y)yl=y;}
        if(a==4){if(yh>y)yh=y;}
    }
    if(xh-xl<0||yh-yl<0)cout << 0 << endl;
    else cout << (xh-xl)*(yh-yl) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    while(1)
    {
        int a,b;
        cin >> a >> b;
        if(a == 0 && b == 0)
        {
            break;
        }

        if(a > b)
        {
            int t;
            t = a;
            a = b;
            b = t;
        }
        
        cout << a << " " << b << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

bool isIN(int y, int x){
    return 0<=y&&y<100 && 0<=x&&x<100;
}

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

    int m[100][100];
    rep(i, 100){
        rep(j, 100) m[i][j] = (i < 50);
    }

    int cnt = 0;
    for(int i=0; i<50; i+=2){
        for(int j=0; j<100; j+=2){
            if(a == 1) i=50, j=100;
            m[i][j] = 0;
            cnt++;
            if(cnt == a-1) i=50, j=100;
        }
    }

    cnt = 0;
    for(int i=99; i>50; i-=2){
        for(int j=0; j<100; j+=2){
            if(b == 1) i=0, j=100;
            m[i][j] = 1;
            cnt++;
            if(cnt == b-1) i=0, j=100;
        }
    }

    cout << 100 << " " << 100 << endl;
    rep(i, 100){
        rep(j, 100) cout << (m[i][j] ? "#" : ".");
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n, a, b, c, d[100], i, j, saikou;
    scanf("%d\n%d %d\n%d", &n, &a, &b, &c);
    for (i=0; i<n; i++)
        scanf("%d", &d[i]);
    for (i=0; i<n; i++)
        for(j=n-1; j>i; j--)
            if (d[j] > d[j-1]){
                int tmp = d[j];
                d[j] = d[j-1];
                d[j-1] = tmp;
            }
    for (i=0; i<=n; i++){
        int cal = c;
        for (j=0; j<i; j++)
            cal += d[j];
        int price = a + i * b;
        int cpd = cal / price;
        if (cpd > saikou)
            saikou = cpd;
    }
    printf("%d\n", saikou);
    return 0;
}

Measured memory_bytes: 596
import numpy as np
pi=np.pi
a,b,x=map(int,input().split())
if 0<=2*x/(a**2)-b<=b:
  y=2*x/(a**2)-b
  print(np.arctan((b-y)/a)/pi*180)
else:
  y=(2*x)/(a*b)
  z=(b*b+y*y)**(1/2)
  h=(b*y)/z
  print(np.arccos(h/b)/pi*180)

Measured memory_bytes: 20004
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <complex>
//定数
#define MOD 1000000007
//マクロ
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

#define vsort(v) sort((v).begin(), (v).end());

typedef unsigned long long int ull;
typedef long long lint;

using namespace std;




int main(){
    int a;
    string s;


    //入力
    cin >> a >> s;

    if(a<3200) cout << "red" << endl;
    else       cout <<   s   << endl;
 

    return 0;
}

Measured memory_bytes: 256
n = int(input())

a = 0
while 4 * a <= 100:
    b = 0
    while 4 * a + 7 * b <= 100:
        if (4 * a + 7 * b) == n:
            print("Yes")
            exit()
        b += 1
    a += 1
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int tmp;
const int N=55;
const int mod=1e9+7;
char s1[1000],s2[1000],s3[1000];
int main()
{
    int a,b,c;
    int long_a,long_b,long_c;
    while(cin>>s1>>s2>>s3)
	{
        long_a=strlen(s1);
		long_b=strlen(s2);
		long_c=strlen(s3);
        tmp=1,a=b=c=-1;
        while(true)
		{
            if(a==long_a)
			{
                cout<<"A"<<endl;
                break;
            }
            else if(b==long_b)
			{
                cout<<"B"<<endl;
                break;
            }
            else if(c==long_c)
			{
                cout<<"C"<<endl;
                break;
            }
            if(tmp==1)
			{
                a++;
                tmp=s1[a]-'a'+1;
            }
            else if(tmp==2)
			{
                b++;
                tmp=s2[b]-'a'+1;
            }
            else if(tmp==3)
			{
                c++;
                tmp=s3[c]-'a'+1;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
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<typename T>
T sum_of_floor(T n,T m,T a,T b){//sum{(a*i+b)/m}(i=1,2...n-1)
  T res=0;
  if(a>=m){
    res+=(n-1)*n*(a/m)/2;
    a%=m;
  }
  if(b>=m){
    res+=n*(b/m);
    b%=m;
  }
  T y=(a*n+b)/m;
  T x=y*m-b;
  if(y==0) return res;
  res+=(n-(x+a-1)/a)*y;
  res+=sum_of_floor(y,a,m,(a-x%a)%a);
  return res;
}

ll a,b,n,m;

void solve(){
  cout << sum_of_floor(n,m,a,b) << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    int t;cin >> t;
    rep(_,t) {
      cin >> n >> m >> a >> b;
      solve();
    }
}

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

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

int main() {
  int64_t n, d;
  cin >> n >> d;
  vector<vector<int>> vec(n, vector<int>(d, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >>vec.at(i).at(j);
    }
  }
  int y, z, cnt=0, check;
  double dis = 0.0;
  for (y = 0; y < n; y++) {
    for (z = y+1; z < n; z++) {
      dis = 0.0;
      for (int i = 0; i < d; i++) {
        dis += pow(vec.at(y).at(i) - vec.at(z).at(i), 2.0);
      }
      dis = sqrt(dis);
      int64_t a = dis;
      if (dis-a == 0) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n; cin >> n;
  string s; cin >> s;
  if (n % 2 == 1) no();
  rep(i, n / 2) {
    if (s[i] != s[i + n / 2]) no();
  }
  yes();
}


Measured memory_bytes: 256
/** Bismillahir Rahmanir Rahim **/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define Fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define print(x) cout << "#x - " << x << endl;

int main()
{
   int a, b, cnt = 0;
   cin >> a >> b;
   if (a > b) swap(a, b);
   cout << (((a - 1)*a) / 2) + (((b - 1) * b) / 2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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


vi d;
vector<vi> g;

void dfs(int now, int a, int old){
    if(d[now] == old)d[now] = a;
    else return;
    rep(i,g[now].size())dfs(g[now][i],a,old);
}

signed main(void) {
    int n,q;
    while(1){
        scanf("%lld %lld",&n,&q);
        if(n == 0)return 0;
        g = vector<vi>(n);
        loop(i,1,n){
            int a;
            scanf("%lld",&a);
            a--;
            g[a].push_back(i);
        }
        d = vi(n,1);
        int ans = 0;
        while(q--){
            char s[5];
            scanf("%s",s);
            int v;
            scanf("%lld",&v);
            v--;
            if(s[0] == 'M'){
                dfs(v,v+1,d[v]);
            }else{
                ans += d[v];
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 15372
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<vector<ll> > G(N, vector<ll>(N));
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) cin >> G[i][j];

    ll ans = 0;
    // floyd
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
        if (i == j) continue;
        bool use = true;
            for (int k = 0; k < N; k++) {
                if (k == i || k == j) continue;
                ll d = G[i][k] + G[k][j];
                if (d < G[i][j]) {
                    cout << -1 << '\n';
                    return 0;
                }
                else if (d == G[i][j]) use = false;
            }
        if (use) ans += G[i][j];
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int> > s(m);
    for(int i=0;i<m;i++){
        int k;
        cin>>k;
        for(int j=0;j<k;j++){
            int tmp;
            cin>>tmp;
            tmp--;
            s[i].push_back(tmp);
        }
    }
    vector<int> p(m);
    for(int i=0;i<m;i++){
        cin>>p[i];
    }
    int ans=0;
    for(int i=0;i<1<<n;i++){
        string tmp="";
        for(int j=0;j<n;j++){
            tmp+=(bool)((1<<j)&i)+'0';
        }
        //cout<<tmp<<endl;
        bool flag=true;
        for(int j=0;j<m;j++){
            int count=0;
            for(int k=0;k<s[j].size();k++){
                count+=tmp[s[j][k]]-'0';
            }
            if(count%2!=p[j])flag=false;
        }
        if(flag)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#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 = 100010;
 
int main() {
    string s;
    cin >> s;
 
    ll ans = 0;
    rep(i, s.size()) {
        if(s[i] == '+') {
            ans++;
        }
        else {
            ans--;
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    s = IS()
    n = len(s)
    dp = DD2(n,2)
    # dp[x][0]: x番目の文字に1文字選択で到達した場合の最大分割数
    # dp[x][1]: x番目の文字に2文字選択で到達した場合の最大分割数
    dp[0][0] = 1
    dp[0][1] = -1
    for i in range(1, n):
        if s[i-1] != s[i]:
            dp[i][0] = max(dp[i-1][0]+1, dp[i-1][1]+1)
        else:
            dp[i][0] = dp[i-1][1]+1
        if i-2>=0:
            dp[i][1] = max(dp[i-2][0]+1, dp[i-2][1]+1)
    print(max(dp[-1][0],dp[-1][1]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 36760
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).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; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, v, b, w, t; cin >> a>>v>>b>> w>> t;
    if (abs(b - a) <= t * (v - w)) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
#define KMAX 2299709

bool isprime[KMAX];

void cp(){
  for(int i=0; i < KMAX; i++){
    isprime[i] = true;
  }
  isprime[0] = isprime[1] = false;
  for(int i = 2; i*i <= KMAX; i++){
    if(isprime[i]){
      for(int j = i+i; j < KMAX; j += i){
        isprime[j] = false;
      }
    }
  }
}

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cp();
  int k;
  while(cin >> k, k){
    int a, b;
    for(int i = k; i >= 0; i--){
      if(isprime[i]){
        a = i;
        break;
      }
    }
    for(int i = k; i < KMAX; i++){
      if(isprime[i]){
        b = i;
        break;
      }
    }
    cout << b - a << endl;
  }
  return 0;
}

Measured memory_bytes: 3440
process.stdin.resume();
process.stdin.setEncoding('utf8'); 
var lines = [];
var reader = require('readline').createInterface({
	input: process.stdin,
	output: process.stdout
});
 
reader.on('line', (line) => {
	lines.push(line);
});

reader.on('close', () => {
	"use strict"
	const AB=lines[0].split(" ").map(Number);
	const A=AB[0];
	const B=AB[1];
	
	var ans=Math.ceil((B-1)/(A-1))
	console.log(ans);
});

Measured memory_bytes: 21320
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
#define scl(n) scanf("%lld", &n)
#define pcl(n) printf("%lld\n", n)
#define pcl1(n) printf("%lld ", n)
#define nln printf("\n")
#define dev(x) cout << #x << " " << x << " ";
#define PTT pair<ll, ll>

map<ll, ll> mp, mp1;
map<ll, ll>::iterator itr;

int main()
{
    ll t, n, x;
    string s;
    cin >> s;
    ll cnt = 0;
    ll mx = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'R')
        {
            cnt++;
        }
        else
        {
            mx = max(cnt, mx);
            cnt = 0;
        }
    }
    mx = max(cnt, mx);
    pcl(mx);
    return 0;
}

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

#define mp(x, y) make_pair((x), (y))

typedef long long ll;

int n;
set<int> nex[100005];
int d[100005];
int l[100005];
int beg, End;
int m[100005];

int main()
{
	scanf("%d", &n);
	if(n%2==1) {
		printf("First\n");
		return 0;
	}
	for(int i=0; i<n-1; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		u--; v--;
		nex[u].insert(v);
		nex[v].insert(u);
		d[u]++;
		d[v]++;
	}
	for(int i=0; i<n; i++) {
		if(d[i]==1) {
			l[End++]=i;
		}
	}
	while(beg<End) {
		int cur=l[beg++];
		if(m[cur]) continue;
		m[cur]=1;
		int nei=*nex[cur].begin();
		if(m[nei]) {
			printf("First\n");
			return 0;
		} else {
			m[nei]=1;
			for(set<int>::iterator it=nex[nei].begin(); it!=nex[nei].end(); it++) {
				nex[*it].erase(nei);
				if(nex[*it].size()==1) {
					l[End++]=*it;
				}
			}
		}
	}
	printf("Second\n");

	return 0;
}

Measured memory_bytes: 15360
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int p;
		int count = 0;

		for (int i = 1; i < n+1; i++) {
			p = sc.nextInt();
			if (p != i) {
				count++;
				if (count > 2) {
					System.out.println("NO");
					return;
				}
			}
		}
		System.out.println("YES");
	}
}


Measured memory_bytes: 23764
n=int(input())
l=list(map(int,input().split()))

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

#factorization(24) 

## [[2, 3], [3, 1]]
z=[0]*(10**6+1)
for i in l:
    if i>=2:
        re=factorization(i)
        for p in re:
            z[p[0]]=max(z[p[0]],p[1])
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m
w=1
mod=10**9+7
for i in range(10**6+1):
    w*=pow(i,z[i],mod)
    w%=mod
kai=0
for i in l:
    kai+=w*mod_inv(i,mod)
    kai%=mod
print(kai)
            

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

#define FOR(i, l, r) for(size_t i = (l); i < (r); i = i + 1)
#define REP(i, n) FOR(i, 0, n)
using ll = long long;

int calc_mean(vector<int> v) {
    int size = v.size();
    int sum = 0;
    REP(i, size) {
        sum += v[i];
    }
    return round((double)sum / (double)size);
}

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    REP(i, N) {
        cin >> X[i];
    }
    int mean = calc_mean(X);
    int sum = 0;
    int i;
    REP(i, N) {
        sum += (X[i] - mean) * (X[i] - mean);
    }

    cout << sum << endl;
    return 0;
}

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

namespace AtCoder.Contest.A
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

			int a = cin.NextInt();
			int b = cin.NextInt();
            Console.WriteLine(a * b);

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

int w,h,s[30][30],c[4],d[900][4],ans;

int encode(int y,int x){
    return w*y+x;
}

pii decode(int pos){
    return pii(pos/w,pos%w);
}

void dijkstra(){
    ans=inf;
    fill_n((int*)d,900*4,inf);
    d[0][0]=0;
    priority_queue<pair<int,pii>,vector<pair<int,pii>>,greater<pair<int,pii>>> que;
    que.push(make_pair(0,pii(0,0)));
    while(!que.empty()){
        pair<int,pii> p=que.top(); que.pop();
        int dist=p.first,pos=p.second.first;
        int y=decode(pos).first,x=decode(pos).second,dir=p.second.second;

        if(y==h-1 and x==w-1){
            ans=min(ans,dist);
            continue;
        }
        if(dist>d[encode(y,x)][dir]) continue;

        rep(i,0,4){
            int cost=c[i],ndir=(dir+i)%4;
            if(i==s[y][x]) cost=0;
            
            int ny=y+dy[ndir],nx=x+dx[ndir];
            int npos=encode(ny,nx);
            if(ny<0 or h<=ny or nx<0 or w<=nx) continue;
            if(dist+cost<d[npos][ndir]){
                d[npos][ndir]=dist+cost;
                que.push(make_pair(d[npos][ndir],pii(npos,ndir)));
            }
        }
    }
}

void solve(){
    while(true){
        cin >> w >> h;
        if(w==0 and h==0) break;

        rep(y,0,h) rep(x,0,w) cin >> s[y][x];
        rep(i,0,4) cin >> c[i];

        dijkstra();

        cout << ans << endl;
    }
}

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

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

int getSumOfDigits(int n){
    int sum = 0;
    while(n>0){
        int digit = n % 10;
        sum = sum + digit;
        n = n / 10;
    }
    return sum;
}

int main(void){
    int n,a,b,sum,total=0;
    cin >> n >> a >> b;
    for(int i=0;i<=n;i++){
        int sum = getSumOfDigits(i);
        if(a<=sum && sum<=b) total = total + i;
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect

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

A.sort()

rank = [0, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 3200, 3200, 3200, 3200, 3200]
n_rank = []
for i in range(1,len(rank)):
  var = bisect.bisect_left(A, rank[i]) - bisect.bisect_left(A, rank[i-1])
  n_rank.append(var)
else:
  n_rank.append(len(A) - bisect.bisect_left(A, rank[-1]))
  
n_color = sum(n_rank[i] != 0 for i in range(len(n_rank)-1))

min_color = max(n_color, 1)
max_color = n_color + n_rank[-1]

print(str(min_color) +' '+ str(max_color))
  



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  string s;
  cin >>s;
  
  cout << (s.substr(0,4)=="YAKI"?"Yes":"No") << endl;
  
}


Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <set>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int H, W;

	cin >> H >> W;

	string s[H];
	rep(i, H)
	{
		cin >> s[i];
	}

	bool ret = true;
	rep(i, H)
	{
		rep(j, W)
		{
			if (s[i][j] == '#')
			{
				if ((i>0) && (s[i-1][j] == '#'))
				{
					continue;
				}

				if ((j>0) && (s[i][j-1] == '#'))
				{
					continue;
				}

				if ((i < H-1) && (s[i+1][j] == '#'))
				{
					continue;
				}

				if ((j < W - 1) && (s[i][j+1] == '#'))
				{
					continue;
				}
				ret = false;
				break;
			}
		}
		if (!ret)
		{
			break;
		}
	}

	if (ret)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256