akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = int64_t; using ull = uint64_t; const ll INF = 9e18;
void print() { cout << endl; }
template<typename Head,typename... Tail> void print(Head head,Tail... tail){cout<<head;if(sizeof...(Tail)>0)cout<<" ";print(tail...);}
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<head;print0(tail...);}
// clang-format on

ll dpval(vector<vector<ll>> &dp, ll i, ll j) {
    if (j >= 0) {
        return dp[i][j];
    }
    return -INF;
}
int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    if (N % 2 == 0) {
        vector<vector<ll>> dp(2, vector<ll>(N, -INF));
        dp[0][0] = A[0];
        dp[1][1] = A[1];
        for (ll i = 2; i < N; i++) {
            dp[0][i] = A[i] + dpval(dp, 0, i - 2);
            dp[1][i] = A[i] + max(dpval(dp, 1, i - 2), dpval(dp, 0, i - 3));
        }
        ll result = max(dpval(dp, 0, N - 2), dpval(dp, 1, N - 1));
        print(result);
    } else {
        vector<vector<ll>> dp(3, vector<ll>(N, -INF));
        dp[0][0] = A[0];
        dp[1][1] = A[1];
        dp[2][2] = A[2];
        dp[0][2] = A[0] + A[2];
        for (ll i = 3; i < N; i++) {
            dp[0][i] = A[i] + dpval(dp, 0, i - 2);
            dp[1][i] = A[i] + max(dpval(dp, 1, i - 2), dpval(dp, 0, i - 3));
            dp[2][i] = A[i] + max(max(dpval(dp, 2, i - 2), dpval(dp, 1, i - 3)), dpval(dp, 0, i - 4));
        }
        ll result = max(max(dpval(dp, 0, N - 3), dpval(dp, 1, N - 2)), dpval(dp, 2, N - 1));
        print(result);
    }
}


Measured memory_bytes: 11180
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if (N == 1) {
			System.out.println("Hello World");
		} else {
			int A = sc.nextInt();
			int B = sc.nextInt();
			System.out.println(A+B);
		}
	}
}


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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std; 

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";} 
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n;
    cin >> n;
    string s, t;
    cin >> s;
    t = s;

    int r = 0;
    irep(i, n) {
        if(s[i]=='R'){ r++; }
    }
    
    sort(t.begin(), t.end());
        
    int ans =  0;
    irep(i,r) {
        if(s[i] != t[i]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

/*atcoder*/



Measured memory_bytes: 3896
#include<iostream>
#include<utility>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  long int n,k,num;
  cin>>n>>k;
  const int N=n;
  vector <pair<long int,long int> > a;
  for(int i=1;i<=N;i++){
    cin>>n>>num;
    a.push_back(make_pair(n,num));
  }
  sort(a.begin(),a.end());
  for(int i=0;i<N;i++){
    k-=a[i].second;
    if(k<=0){
      cout<<a[i].first<<endl;
      break;
    }
  }
  return 0;
}



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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

ll f(ll h, ll w) {
   ll Min = 1e18;
   for (ll i = 1; i < w; i++) {
      ll j = w - i;

      ll left = i * h;
      // 縦3分割
      ll a = j/2, b = j - a;
      ll mid = a * h, right = b * h;
      ll v[] = {left, mid, right};
      sort(v, v+3);
      Min = min(Min, v[2] - v[0]);

      // 縦2、横2
      a = h/2, b = h - a;
      ll up = a * j, un = b * j;
      ll t[] = {left, up, un};
      sort(t, t+3);
      Min = min(Min, t[2] - t[0]);
   }
   return Min;
}

int main() {
   ll H, W;
   cin >> H >> W;

   cout << min(f(H, W), f(W, H)) << endl;

   return 0;
}

Measured memory_bytes: 256
use io::*;
use std::cmp::{max, min};

fn main() {
    let con = read_string();
    let mut sc = Scanner::new(&con);

    let n: i32 = sc.next();

    let mut ans = 99999;

    fn sum(mut x: i32) -> i32 {
        let mut ret = 0;
        while x > 0 {
            ret += x % 10;
            x /= 10;
        }
        ret
    }

    for i in 1..n {
        let j = n - i;

        // println!("{}: {} + {}", i, sum(i), sum(j));

        ans = min(ans, sum(i) + sum(j));
    }

    println!("{}", ans);
}

//-----

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


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

#define M_PI       3.14159265358979323846

using namespace std;

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

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

//container util

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

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

int a[100005], b[100005];

int main() {
	int n;
	scanf("%d", &n);
	vector<PII> x(2 * n); 
	int t;
	REP(i, n) {
		scanf("%d", &t);
		x[i] = MP(t, 0);
	}
	REP(i, n) {
		scanf("%d", &t);
		x[i+n] = MP(t, 1);
	}
	SORT(x);
	int c[2] = { 0, };
	LL ret = 1;
	REP(i, 2*n) {
		if (c[1 - x[i].second] > 0) {
			ret = (ret * c[1 - x[i].second]) % MOD;
			c[1 - x[i].second]--;
		}
		else {
			c[x[i].second]++;
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x,y;
    cin>>x>>y;
    int b=0;
    int flag=0;
    for(int i=0; i<=x; i++){
        b = x - i;
        if(2*i + 4*b == y){
            flag=1;
        }
    }

    if(flag)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3532
# solution
import io
from queue import Queue

nim,mike=map(int,input().split())
s=[list(input()) for _ in range(nim)]

white=sum([1 if s[y][x]=='.' else 0 for x in range(mike) for y in range(nim)])
used=[[False for x in range(mike)] for y in range(nim)]
q=Queue()
q.put((0,0,1))
while True:
    if q.empty():
        print(-1)
        break
    x,y,l=q.get()
    if used[y][x]:
        continue
    if x==mike-1 and y==nim-1:
        print(white-l)
        break
    used[y][x]=True
    for d in [(1,0),(0,1),(-1,0),(0,-1)]:
        nx=x+d[0]
        ny=y+d[1]
        if ny>=0 and ny<nim and nx>=0 and nx<mike:
            if s[ny][nx]=='.':
                q.put((nx,ny,l+1))

Measured memory_bytes: 3952
#include<bits/stdc++.h>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    long long int n,a[10000000],sum=0;
    cin>>n;
    for(long long i=0;i<n;i++)
    {
    	cin>>a[i];
    }
    for(long long i=0;i<n-1;i++)
    {
    	if(a[i]>a[i+1])
        {
            sum=sum+(a[i]-a[i+1]);
            a[i+1]=a[i];
        }
    }
    cout<<sum<<"\n";


}


Measured memory_bytes: 5152
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] a = new int[N];

		for (int i = 0; i < N; i++)
			a[i] = sc.nextInt();

		long s = 0;
		long min =Long.MAX_VALUE;

		for (int i = 0; i < N; i++)
			s += a[i];

		long x = 0, y = 0;

		for (int i = 0; i < N - 1; i++) {
			x += a[i];
			y = s - x;
			min = Math.min(min, Math.abs(x - y));
		}

		System.out.println(min);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 23612
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

int main()
{
        string s;
        cin >> s;
        int a, z;
        rep(i, s.size())
        {
                if (s[i] == 'A')
                {
                        a = i;
                        break;
                }
        }
        reverse(all(s));
        rep(i, s.size())
        {
                if (s[i] == 'Z')
                {
                        z = i;
                        break;
                }
        }

        cout << s.size() - z - a << endl;

        return 0;
}


Measured memory_bytes: 640
def main():
    n = int(input())
    s = input()

    ans = 0
    for i in range(n):
        x = set()
        for j in range(i):
            x.add(s[j])
        y = set()
        for j in range(i, n):
            if s[j] in x:
                y.add(s[j])
        ans = max(ans, len(y))

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import math
import copy
import bisect








def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:

            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l

n=nCast(input().split())

def func():

    if n[2]-n[1]<2:
        return 1+n[0]
    if n[1]-1>=n[0]:
        return 1+n[0]

    result=n[1]
    ret=n[0]+1-n[1]
 
    if ret%2==0:

        
        return result+int(ret/2)*(n[2]-n[1])
    return 1+result+int((ret-1)/2)*(n[2]-n[1])

print(int(func())) 



Measured memory_bytes: 3540
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pbi pair<bool,int>
#define pob pop_back
#define all(a) a.begin(),a.end()
#define fio ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define i64 long long int
#define mem(x,y) memset(x,y,sizeof(x))
#define fill(arr,b) fill(arr, arr+sizeof(arr)/sizeof(arr[0]), b)
#define maxarr(n,arr,m) m =-1e9;for(int i=0;i<n;i++)if(arr[i]>m) m=arr[i];
#define read freopen("input.txt","r",stdin);

const double pi = acos(-1.0);
const int maxn = (i64)1e9+7;
vector<int>v[100005];
int arr[100005];
int main()
{
    //read;
    int n,m,a,b;
    cin >> n >> m;
    for(int i=1;i<=n;i++) cin>>arr[i];
    for(int i=0;i<m;i++)
    {
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        bool fg=true;
        for(int j=0;j<v[i].size();j++)
        {
            if(arr[i]<=arr[v[i][j]]){fg=false;break;}
        }
        if(fg)cnt++;
    }
    cout<<cnt;

    return 0;
}


Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
priority_queue<int>que;
int main()
{
	int n,m,x;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",&x),que.push(x);
	while(m--)
	{
		int x=que.top()/2;
		que.pop();
		que.push(x);
	}
	long long ans=0;
	while(!que.empty())
	{
		ans+=que.top();
		que.pop();
	}
	printf("%lld",ans);
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
#define ll long long int
using namespace std;

int main() {
	int K, X; cin >> K >> X;
	if (500 * K >= X) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<vector<int>> D(2, vector<int>(N));
	for (int i = 0; i < N; i++) {
		cin >> D[0][i];
		cin >> D[1][i];
	}
	int j = 0;
	for (int i = 0; i < N; i++)
	{
		//cout << j << endl;
		if (D[0][i] == D[1][i]) {
			j++;
		}
		else {
			j = 0;
		}
		if (j == 3) {
			cout << "Yes" << endl;
			return 0;
		}
		if (i == N - 1 && j < 3) {
			cout << "No" << endl;
			return 0;

		}
	}
}

Measured memory_bytes: 3620
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
struct edge{int to,cost;};
vector<int> G[100005];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
std::vector<P> tree[100010];
ll i,j;

ll n;
ll color[8]={399,799,1199,1599,1999,2399,2799,3199};
ll dp[9]={0,0,0,0,0,0,0,0,0};
ll a;
ll low,high;

int main(){
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a;
		for(j=0;j<=10;j++){
			if(j==8){
				dp[8]++;
				break;
			}
			if(a<=color[j]){
				dp[j]++;
				break;
			}
		}
	}
	ll ans=0;
	for(i=0;i<=7;i++){
		if(dp[i]!=0)ans++;
	}
	a = 8;
	if(ans==0)low=1;
	else low=ans;
	high=ans+dp[8];
	cout<<low<<" "<<high<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <complex>
#include <cmath>
using namespace std;
typedef complex<double> point;

point ins[310];
int main(){
    for(;;){
        int N;
        scanf("%d",&N);
        if(N==0) break;
        double x,y;
        for(int i=0;i<N;i++){
            scanf("%lf%lf",&x,&y);
            ins[i]=point(x,y);
        }
        int ma=1;
        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                double no=norm(ins[i]-ins[j]);
                if(no<4){
                    double di=sqrt(1-no/4);
                    point hen=(ins[i]-ins[j])*point(cos(M_PI/2),sin(M_PI/2))*(di/sqrt(norm(ins[i]-ins[j])));
                    point cen[2];
                    cen[0]=(ins[i]+ins[j])/2.0+hen;
                    cen[1]=(ins[i]+ins[j])/2.0-hen;
                    for(int k=0;k<2;k++){
                        int cnt=2;
                        for(int l=0;l<N;l++){
                            if(l==i || l==j) continue;
                            if(norm(cen[k]-ins[l])<1) cnt++;
                        }
                        ma=max(ma,cnt);
                    }
                }
            }
        }
        printf("%d\n",ma);
    }
}

Measured memory_bytes: 1072
#include<stdio.h>
#include<stdlib.h>
int Bubblesort(int *p, int N){
    int flag,j,tmp,count=0,i=1;
    flag=1;//逆の隣接要素が存在する
    while(flag==1){
        flag=0;
    for(j=N-1;j>=i;j--){
        if(*(p+j)<*(p+j-1)){
            tmp=*(p+j);
            *(p+j)=*(p+j-1);
            *(p+j-1)=tmp;
            count++;
            flag=1;
        }
    }
    i++;
    }
    return count;
}
int main(void){
    int N,*p,n,i=0,count;
    scanf("%d",&N);
    p=malloc(sizeof(int)*N);
    while(scanf("%d",(p+i))==1){
        i++;
        if(i==N) break;
    }
    count=Bubblesort(p,N);
    for(i=0;i<N-1;i++){
        printf("%d ",*(p+i));
    }
    printf("%d\n",*(p+i));
    printf("%d\n",count);
    free(p);
    return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first 
#define ss second
#define mod 1000000007
#define lim 100005
#define mx 20005
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

struct box{
	int w,s,v;
	bool operator<(const box & b)
	{
		return (s+w<b.s+b.w);
	}
};

int main()
{
	ll ans = 0;
	int i,j,n,w,s,v,maxmw = 0;
	cin>>n;
	vector<box> all;
	for(i=0; i<n; i++){
		cin>>w>>s>>v;
		all.pb({w,s,v});
	}
	sort(all.begin(), all.end());
	ll dp[mx] = {};ll dp2[mx] = {};
	dp[0] = 0;
	for(i=0; i<n; i++){
		for(j=1; ((all[i].s + all[i].w) >= j); j++){
			dp2[j] = max({dp2[j-1], ((all[i].w<=j)?(dp[j-all[i].w] + all[i].v):0), dp[j]});
		}
		swap(dp,dp2);
	}
	cout<<dp[all[n-1].s+all[n-1].w];
}

Measured memory_bytes: 640
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int r,c,i,j;
    static int g[101][101];
    scanf("%d%d",&r,&c);
    for(i = 0 ; i <= r ; i++){
        for(j = 0 ; j < c ; j++){
            scanf("%d",&g[i][j]);
            printf("%d ",g[i][j]);
            g[i][c] += g[i][j];
            g[r][j] += g[i][j];
        }
        printf("%d\n",g[i][c]);
    }
    
    return 0;
}



Measured memory_bytes: 2104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Convert;
using static System.Console;
using static System.Math;
class MainClass
{
	static void Main(string[] args)
	{
		Answer();
	}
	public static void Answer()
	{
      string S = Console.ReadLine();
      int fee = 700;
      if (S[0] == 'o')
        fee += 100;
      if (S[1] == 'o')
        fee += 100;
      if (S[2] == 'o')
        fee += 100;
      Console.WriteLine(fee);
	}
}

Measured memory_bytes: 11092
import java.util.*;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        String s = sc.nextLine();
        String t = sc.nextLine();
        
        int count = 0, i;
        for(i = 0; i < s.length(); i++){
            if(s.charAt(i) != t.charAt(i)) count++;
        }
        System.out.println(count);

    }
}

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

using namespace std;
using ll = long long;


int main()
{
    string s, t = "CODEFESTIVAL2016"; cin >> s;
    int cnt = 0;
    for(int i = 0; i < 16; i++) if(s[i] != t[i])cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    p=LI()
    ans=0
    for i in range(N):
        if p[i]==i+1:
            if i!=N-1:
                p[i],p[i+1]=p[i+1],p[i]
                ans+=1
            else:
                p[i],p[i-1]=p[i-1],p[i]
                ans+=1
            
    print(ans)

main()


Measured memory_bytes: 52316
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <bitset>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

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

//static const ll MOD = 1000000007;
//static const ll INF = 100000000;

int main() {
    // input
    ll A, B;
    cin >> A >> B;

    // process
    ll ans = 0;

    ll x = A * B;
    if (A < B) {
        ll tmp = A;
        A = B;
        B = tmp;
    }
    ll r = A % B;
    while (r != 0) {
        A = B;
        B = r;
        r = A % B;
    }
    ans = x / B;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;



int main(){	
	long long N, D;
	cin >> N >> D;
	cout << (N+2*D)/(2*D+1) << endl;
	return 0;
}



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

s.sort()
t.sort(reverse=True)

def solve() :
    flg = True
    for i in range(min(len(s), len(t))) :
        if ord(s[i]) < ord(t[i]) :
            return 'Yes'
        elif ord(s[i]) > ord(t[i]) :
            flg = False
    
    if flg and len(t) > len(s) :
        return 'Yes'
    else :
        return 'No'
    
print(solve())

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void scoring(int &score , int choose, int day, vector<int> &c,vector<vector<int>> &s,vector<int> &last){
    --choose;
    score += s[day][choose];
    int hiku = 0;
    ++day;
    last[choose] = day;
    rep(i,26){
        hiku += c[i]*(day - last[i]);
    }
    score -= hiku;
    return;
}

//ミョ(-ω- ?)
int main() {
    int d;
    cin >> d;
    const int n = 26;
    vector<int> c(n,0);
    rep(i,n)cin >> c[i];
    vector<vector<int>> s(365,vector<int>(n,0));
    rep(i,d)rep(j,n)cin >> s[i][j];

    vector<int> t(d);
    vector<int> last(n,0);
    int score = 0;
    cerr << endl;
    rep(i,d){
        cin >> t[i];
        scoring(score,t[i],i,c,s,last);
        cout << score << endl;
    }

    return 0;
}

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

int main(){
    int n,k;
	cin >> n >> k;
	vector<int> d(k);
	for(int i = 0; i < k; i++){
		cin >> d[i];
	}

	for(int x = n; x < 100000; x++){
		int tmp = x;
		set<int> s;
		while(tmp!=0){
			s.insert(tmp%10);
			tmp /= 10;
		}
		bool flag = true;
		
		for(int i = 0; i < k; i++){
			if(s.count(d[i])) flag = false;
		}
		if(flag){
			cout << x << endl;
			break;
		}
	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    int h, w, k = 0;
    cin >> h >> w >> k;
    vector<string> c;
    for (int i = 0; i < h; i++) {
        string s ;
        cin >> s;
        c.push_back(s);
    }
    int ans = 0;
    for (int maskR = 0; maskR < (1 << h); maskR++) {
        for (int maskC = 0; maskC < (1 << w); maskC++) {
            int black = 0;
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if (((maskR >> i) & 1) == 0
                            && ((maskC >> j) & 1) == 0) {
                        if (c[i][j] == '#') {
                            black++;
                        }
                    }
                }
            }
            ans = (black == k) ? ans + 1 : ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void solve(long long A, long long B, long long C, long long D, long long E,
           long long F) {
  set<ll> waterCand;
  set<ll> sugarCand;
  for (ll a = 0; a <= 30; a++) {
    for (ll b = 0; b <= 30; b++) {
      ll water = 100 * (a * A + b * B);
      if (water <= F) {
        waterCand.insert(water);
      }
    }
  }
  for (ll c = 0; c <= 3000; c++) {
    for (ll d = 0; d <= 3000; d++) {
      ll sugar = c * C + d * D;
      if (sugar <= F) {
        sugarCand.insert(sugar);
      }
    }
  }

  ll maxSugarWater = 0;
  ll maxSugar = 0;
  for (auto w : waterCand) {
    for (auto s : sugarCand) {
      if (w + s <= F && w + s > 0 && s * (100 + E) <= E * (w + s) &&
          ((maxSugarWater == 0 && w > 0) ||
           ((double)maxSugar * (w + s) < (double)s * maxSugarWater))) {
        maxSugarWater = w + s;
        maxSugar = s;
      }
    }
  }

  print(maxSugarWater << " " << maxSugar);
}

int main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  long long D;
  scanf("%lld", &D);
  long long E;
  scanf("%lld", &E);
  long long F;
  scanf("%lld", &F);
  solve(A, B, C, D, E, F);
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,x,y,t,a,b,c;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>c>>a>>b;
        if(abs(x-a)+abs(y-b)>c-t)
        {
            cout<<"No";
            return 0;
        }
        if((abs(x-a)+abs(y-b))%2==0 &&(c-t)%2==1)
        {
            cout<<"No";
            return 0;
        }
        if((abs(x-a)+abs(y-b))%2==1 &&(c-t)%2==0)
        {
            cout<<"No";
            return 0;
        }
        x=a;y=b;t=c;
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
cnt = 0
s_dict = {}
for i in range(n):
    s = ''.join(sorted(input()))
    if s not in s_dict:
        s_dict[s] = 0
    else:
        s_dict[s] += 1
        cnt += s_dict[s]
print(cnt)

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

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var s = ReadLine();

            var array = new string[] { "a", "i", "u", "e", "o" };

            Console.WriteLine((Array.IndexOf(array, s) > -1) ? "vowel" : "consonant");
            ReadLine();
        }

        /// <summary>
        /// コンビネーション
        /// </summary>
        /// <param name="n"></param>
        /// <param name="m"></param>
        /// <returns></returns>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }

        static string[] GetAplhaLowerArray() => new string[]{ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
        static string[] GetAplhaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    }
}

Measured memory_bytes: 13024
def main(W: int, H: int, x: int, y: int):
    area = W * H
    count = 0

    if x * 2 == W and y * 2 == H:
        count = 1

    print("{:.6f}".format(area / 2), count)


if __name__ == "__main__":
    W, H, x, y = map(int, input().split())

    main(W, H, x, y)


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var abc = br.readLine().split(" ");
      var a = Integer.parseInt(abc[0]);
      var b = Integer.parseInt(abc[1]);
      var c = Integer.parseInt(abc[2]);
      final var k = Integer.parseInt(br.readLine());

      var minCount = 0;
      while (a >= b) {
        b *= 2;
        minCount++;
      }
      while (b >= c) {
        c *= 2;
        minCount++;
      }

      System.out.println(minCount <= k ? "Yes" : "No");
    }
  }
}


Measured memory_bytes: 32744
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <limits>
#include <string>
#include <vector>

using namespace std;

const long long INF = 1LL << 60;

//各桁の和を出力
long long Sum(long long n) {
  long long m = 0;
  while (n) {
    m += n % 10;
    n /= 10;
  }
  return m;
}

const int MAX = 510000;
const int MOD = 1000000007;

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

void Comuse() {
  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 % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

#define comuse Comuse()
// nCk(comuseを使え)
long long combi(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// pCk(comuseを使え)
long long perm(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] % MOD) % MOD;
}

//最小公倍数(aとbの)
long long lcm(long long a, long long b) {
  long long n;
  n = a / __gcd(a, b) * b;
  return n;
}

// auto A = div(n)
vector<long long> div(long long n) {
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

//(aのn乗をmodで割ったあまり)
long long modpow(long long a, long long n, long long mod) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) {
      ans = ans * a % mod;
    }

    a = a * a % mod;

    n >>= 1;
  }

  return ans;
}

void solve();

const int MAX_N = 131072;
// segment tree
int NN;
int seg[MAX_N * 2 - 1];
void seguse() {
  for (int i = 0; i < 2 * NN - 1; i++) {
    seg[i] = INT_MAX;
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;
  solve();
}

///////////////////////////////////////////////////////////

int N, M;

void solve() {
  cin >> N >> M;
  cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int n;
  cin>>n;
  if(n%2==0) cout<<0.5<<endl;
  else cout<<(ld)(n/2+1)/(ld)n<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int a[5][2];
int main()
{
    int n,m,c,d,flag=1,f=0,mn=9;
    cin >> n >> m;
    if(n==1 && m==0)
    {
        cout << 0 << endl;
    }
    else
    {
        for(int i=1; i<=m; i++)
        {
            cin >> c >> d;
            if(c==1 && d==0 && n!=1)
            {
                flag=0;
                break;
            }
            else if(c==1 && d==0 && n==1)
            {
                f=1;
            }
            if(a[c][1]==0)
            {
                a[c][1]=1;
                a[c][0]=d;
                mn=c;
            }
            else if(a[c][0]!=d)
            {
                flag=0;
                break;
            }
        }
        if(flag)
        {
            for(int i=1; i<=n; i++)
            {
                if(i==1 && a[i][0]==0 && !f)
                {
                    cout << 1;
                }
                else
                {
                    cout << a[i][0];
                }
            }
        }
        else
        {
            cout << "-1" << endl;
        }
    }

    return 0;
}


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

int N, n, d;
int dy[] = {0, 1, 0, -1};
int dx[] = {-1, 0, 1, 0};

int main() {
	while (cin >> N, N) {
		int xmin, xmax, ymin, ymax;
		vector<pair<int, int>> v;
		v.emplace_back(0, 0);
		xmin = xmax = ymin = ymax = 0;
		for (int i = 0; i < N - 1; i++) {
			cin >> n >> d;
			int ny = v[n].first + dy[d];
			int nx = v[n].second + dx[d];
			xmin = min(xmin, nx);
			xmax = max(xmax, nx);
			ymin = min(ymin, ny);
			ymax = max(ymax, ny);
			v.emplace_back(ny, nx);
		}
		cout << xmax - xmin + 1 << ' ' << ymax - ymin + 1 << '\n';
	}
	return 0;
}

Measured memory_bytes: 1200
n, x, y = map(int, input().split())

dist = [0]*n

for i in range(1, n):
    for j in range(i+1, n+1):
        a = min(j-i, abs(i-x)+abs(y-j)+1)
        dist[a] += 1

for i in range(1, n):
    print(dist[i])

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    int alice = 0;
    int bob = 0;

    rep(i,n) cin >> a[i];

    sort(all(a));
    reverse(all(a));

    rep(i,n){
        if(i %2 == 0) alice += a[i];
        else bob += a[i];
    }

    cout << alice - bob << endl;
}

Measured memory_bytes: 256
'use strict'
function Main(lines) {
	let s = lines[0].split('')
	let out = []
	while(1) {
		if(s.length <= 0) break
		let char = s.shift()
		if(char === 'B') {
			out.pop()
		} else {
			out.push(char)
		}
	}
	console.log(out.join(''))
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().replace('\n', '').split("\n"));

Measured memory_bytes: 7372
#include <cstdio>
#include <algorithm>
using namespace std;
int N,d[50],ans;
int main() {
    scanf("%d",&N); for (int i = 0;i < N;i++) scanf("%d",&d[i]);
    for (int i = 0;i < N;i++) for (int j = i+1;j < N;j++) ans += d[i]*d[j];
    printf("%d\n",ans);
}

Measured memory_bytes: 128
sx, sy, tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
ans = 'R'* x + 'U' * y + 'L' * x + 'D' * y
ans += 'D' + 'R' * (x+1) + 'U' * (y+1) + 'L'
ans += 'U' + 'L' * (x+1) + 'D' * (y+1) + 'R'
print(ans)

Measured memory_bytes: 3060
#A
import math
N = int(input())
n2 = math.ceil(math.sqrt(N))
M = math.ceil(math.sqrt(10**9))
prime = []
for i in range(M):
    I = i+1
    m = math.ceil(math.sqrt(I))
    flag = 0
    for j in range(m):
        J = j+1
        if J == 1 or J == I:
            pass
        else:
            if I%J == 0:
                flag = 1
                break
    if flag == 0 and I != 1:
        prime.append(I)
prime.append(999993031)
fact = []
for p in prime:
    if p > N:
        break
    else:
        if N%p == 0:
            count = 0
            n3 = N
            while True:
                if n3%p == 0:
                    n3 = n3//p
                    count+=1
                else:
                    break
            fact.append([p,count])
print(str(N)+":",end="")
for f in fact:
    p,c = f
    while c > 0:
        c-=1
        print("",p,end="")
print()



Measured memory_bytes: 5696
using System;
class exor{
    public static void Main(){
        while(true){
            String[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            if(a+b==0){
                break;
            }
            else{
                for(int i=0; i<a; i++){
                    for(int j=0; j<b; j++){
                        if((i+j)%2==0){
                            Console.Write("#");
                        }
                        else{
                            Console.Write(".");
                        }
                    }
                    Console.WriteLine("");
                }
            }
            Console.WriteLine("");
        }
    }
}


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


int main() {
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  for(int i=0; i<m; ++i) cin >> x[i];

  sort(x.begin(), x.end());

  vector<int> diff(m-1);
  for(int i=0; i<m-1; ++i) diff[i] = x[i+1] - x[i];
  sort(diff.begin(), diff.end());

  int ans = 0;
  for(int i=0; i<m-n; ++i) ans += diff[i];

  if(n < m) cout << ans << endl;
  else cout << 0 << endl;


}


Measured memory_bytes: 1024
a, b, k = gets.chomp.split(" ").map(&:to_i)
k.times do |i|
  if (i + 1).odd?
    if a.odd?
      a -= 1
    end
    b += a / 2
    a /= 2
  else
    if b.odd?
      b -= 1
    end
    a += b / 2
    b /= 2
  end
end
puts "#{a} #{b}"

Measured memory_bytes: 1788
def main():
    x,n=map(int, input().split())
    p=set(map(int,input().split()))
    for i in range(200):
        if (x - i) not in p:
            print(x-i)
            return
        elif (x + i) not in p:
            print(x+i)
            return

if __name__ == '__main__':
    main()

Measured memory_bytes: 9164
# C - Attack Survival
N, K, Q = map(int, input().split())
A = [0] * N
for _ in range(Q):
    tmp = int(input())
    A[tmp - 1] += 1

for i in range(N):
    tmp = K - Q + A[i]
    if tmp > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 4680
#include<cstdio>
#include<algorithm>
#define N_ 601000
using namespace std;
int n, S[N_];
long long w[N_], Mod;
void Add(int b, int e) {
	if (b >= e)return;
	b %= (n * 2), e %= (n * 2);
	S[b]++; S[e]--;
	if (b >= e) S[0]++;
}
bool Pos(int K) {
	int i, b, e;
	for (i = 0; i <= 2 * n; i++)S[i] = 0;
	for (i = 0; i < n*2; i++) {
		int t = (Mod - w[i]) % Mod;
		if (w[i] > t) t += Mod;
		int pv = lower_bound(w, w + 4 * n, t) - w;
		int pv2 = lower_bound(w, w + 6 * n, t + K + 1) - w;
		Add(i + pv, i + pv2);
	}
	int s = 0;
	for (i = 0; i < 2 * n; i++) {
		s += S[i];
		if (s >= 2 * n && i%2==1) {
			return true;
		}
	}
	return false;
}
int main() {
	int i;
	scanf("%d%lld", &n,&Mod);
	for (i = 0; i < 2 * n; i++) {
		scanf("%lld", &w[i]);
	}
	sort(w, w + 2 * n);
	for (i = 0; i < 2 * n; i++) {
		w[i + 2 * n] = w[i] + Mod;
		w[i + 4 * n] = w[i] + 2 * Mod;
	}
	int b = 0, e = Mod - 1, r = -1, mid;
	while (b <= e) {
		mid = (b + e) >> 1;
		if (Pos(mid)) {
			r = mid;
			e = mid - 1;
		}
		else b = mid + 1;
	}
	printf("%d\n", r);
}

Measured memory_bytes: 6272
n = int(input())
s = int(input())

sqrt = 0
for i in range(n+1):
    if i*i >= n:
        sqrt = i
        break

def dsum(n, b):
    ret = 0
    while n :
        ret += n % b
        n //= b
    return ret


if s > n:
    print(-1)
    exit()
if s == n:
    print(n+1)
    exit()

# b = 2 ~ sqrt
# 少し先を見てもいい
for b in range(2, sqrt+1):
    use_n = n
    ans_tmp = dsum(n, b)
    if ans_tmp == s:
        print(b)
        exit()

# n = p*b + q
# s = p + q
# n = 2, s = 1 なら、 b=2, p=1, q=0
for p in range(1, sqrt)[::-1]:
    b = (n-s)//p + 1
    if b > 1 and dsum(n, b) == s:
        print(b)
        exit()
print(-1)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define INF 1e9

int main(void){
    int N,C;
    cin>>N>>C;
    int d[31][31] = {};
    int c[3][31] = {};
    rep1(x,C)rep1(y,C) cin>>d[x][y];
    rep1(i,N)rep1(j,N){
        int color;
        cin>>color;
        c[(i+j)%3][color]++;
    }
    int cost[3][31] = {};
    rep(i,3)rep1(x,C)rep1(y,C){
        cost[i][y] += c[i][x]*d[x][y];
    }
    int res = INF;
    rep1(i,C)rep1(j,C)rep1(k,C){
        if(i==j || j==k || k==i) continue;
        res = min(res, cost[0][i]+cost[1][j]+cost[2][k]);
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
import fractions
def gcdlist(a):
    ans = a[0]
    for i in range(1, len(a)):
        ans = fractions.gcd(ans, a[i])
    return ans

n,y=map(int,input().split())
x=list(map(int,input().split()))
x.append(y)
if y==1:
    print(abs(x[0]-1))
    exit()

l=[]
for i in range(n):
    l.append(abs(x[i+1]-x[i]))
print(gcdlist(l)) 




Measured memory_bytes: 21504
import sys
import math
import bisect
import heapq


def input():
    return sys.stdin.readline().rstrip()


def main():
    H, W = map(int, input().split())
    A = [[0] * W for _ in range(H)]
    for i in range(H):
        a = list(map(int, input().split()))
        A[i] = a

    for i in range(H):
        b = list(map(int, input().split()))
        for j in range(W):
            A[i][j] -= b[j]

    dp = [[set() for i in range(W)] for i in range(H)]
    # dp[i][j][k]
    dp[0][0].add(A[0][0])

    for i in range(H):
        for j in range(W):
            if i != 0:
                for k in dp[i-1][j]:
                    dp[i][j].add(abs(k - A[i][j]))
                    dp[i][j].add(abs(k + A[i][j]))
            if j != 0:
                for k in dp[i][j-1]:
                    dp[i][j].add(abs(k - A[i][j]))
                    dp[i][j].add(abs(k + A[i][j]))

    print(min(dp[H-1][W-1]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 545176