akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int h,w,n;
  cin>>h>>w>>n;
  string Map[h];
  queue<pair<pair<int,int>,int> >que;
  for(int i=0;i<h;i++){
    cin>>Map[i];
    for(int j=0;j<w;j++){
      if(Map[i][j]=='S')
	que.push(mp(mp(i,j),0));
    }
  }
  ll ans=0;
  int hp=1;
  int vx[4]={1,0,-1,0};
  int vy[4]={0,1,0,-1};
  bool used[h+10][w+10]={};
  while(!que.empty()){
    pair<int,int>now=que.front().F;
    int score=que.front().S;
    que.pop();
    //cout<<now.F<<" "<<now.S<<" "<<score<<endl;
    for(int i=0;i<4;i++){
      int x=now.F+vx[i],y=now.S+vy[i];
      if(x>=0&&x<h&&y>=0&&y<w&&!used[x][y]&&Map[x][y]!='X'){
	if('0'<=Map[x][y]&&Map[x][y]<=hp+'0'){
	  memset(used,0,sizeof(used));
	  while(!que.empty())que.pop();
	  que.push(mp(mp(x,y),0));
	  ans+=score+1;
	  hp++;
	  Map[x][y]='.';
	  used[x][y]=true;
	  break;
	}else if(Map[x][y]!='X'){
	  used[x][y]=true;
	  que.push(mp(mp(x,y),score+1));
	}
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    vector<int> d(n - 1);
    d[0] = gcd(a[0], a[1]);
    for (int i = 1; i < n - 1; i++) {
        d[i] = gcd(d[i - 1], a[i + 1]);
    }

    cout << d[n-2] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

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

typedef pair<int, int> Ps;
set<pair<Ps, int > > memo;
char f[17][17];

class State
{
public:
	vector<Ps> b;
	Ps p;
	int c;
	State(Ps p, int c, vector<Ps>& b)
	:p(p),c(c),b(b)
	{}
};

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

int main()
{
	int W,H;
	while(cin >> W >> H, (W||H))
	{
		memo.clear();
		
		Ps init;
		vector<Ps> bk;
		REP(i,H) REP(j,W) 
		{
			cin >> f[j][i];
			if(f[j][i]=='@') init=make_pair(j,i);
			if(f[j][i]=='*') bk.push_back(make_pair(j,i));
		}
		
		queue<State> q;
		q.push(State(init, 0, bk));
		
		while(!q.empty())
		{
			State s=q.front(); q.pop();
			bool ed=true;
			REP(i,s.b.size())
			{
				Ps p=s.b[i];
				if(f[p.first][p.second]!='_') ed=false;
			}
			
			if(ed)
			{
				cout << s.c << endl;
				break;
			}
			
			REP(i,4)
			{
				Ps p=s.p;
				int tx=p.first+dx[i], ty=p.second+dy[i];
				if(tx<0||ty<0||tx>=W||ty>=H) continue;
				if(f[tx][ty]=='#') continue;
				
				bool g=true;
				vector<Ps> tmp(3);
				REP(j,s.b.size())
				{
					Ps bp=s.b[j];
					if(bp.first==tx&&bp.second==ty)
					{
						int ttx=bp.first+dx[i], tty=bp.second+dy[i];
						if(ttx<0||tty<0||ttx>=W||tty>=H)
						{
							g=false;
							break;
						}
						if(f[ttx][tty]=='#')
						{
							g=false;
							break;
						}
						REP(k,s.b.size())
						{
							if(k==j) continue;
							if(s.b[k]==make_pair(ttx,tty))
							{
								g=false;
								break;
							}
						}
						
						if(g) tmp[j]=make_pair(ttx,tty);
						else break;
					}
					else tmp[j]=bp;
				}
				
				if(!g) continue;
				
				sort(tmp.begin(), tmp.end());
				int th=0;
				REP(k,tmp.size())
				{
					th<<=4;
					th|=(tmp[k].first-1);
					th<<=4;
					th|=(tmp[k].second-1);
				}
				Ps np=make_pair(tx,ty);
				if(memo.count(make_pair(np,th))) continue;
				
				memo.insert(make_pair(np,th));
				
				q.push(State(np, s.c+1, tmp));
			}
		}
	}
}

Measured memory_bytes: 13000
//while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
const int nax=100*1007;

int n;
int tab[nax];

int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++)
		scanf("%d", &tab[i]);
	sort(tab+1, tab+1+n);
	reverse(tab+1, tab+1+n);
	int v=0;
	while(v+1<tab[v+2])
		v++;
	int czy=0;
	if (!((tab[v+1]^v)&1))
		czy=1;
	for (int i=1; 1; i++)
	{
		if (tab[i]<=v)
		{
			if ((i-v)&1)
				czy=1;
			break;
		}
	}
	if (czy)
		printf("First\n");
	else
		printf("Second\n");
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint INF = 1e18;

signed main(){
  lint A, B, Q; cin >> A >> B >> Q;
  vector<lint> s(A), t(B);
  for(int i = 0; i < A; i++) cin >> s[i];
  for(int i = 0; i < B; i++) cin >> t[i];
  s.push_back(INF); s.push_back(-INF);
  t.push_back(INF); t.push_back(-INF);
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  for(int i = 0; i < Q; i++){
    lint x; cin >> x;
    vector<lint> ds(2), dt(2);
    lint ids = lower_bound(s.begin(), s.end(), x) - s.begin();
    lint idt = lower_bound(t.begin(), t.end(), x) - t.begin();
    ds = {x - s[ids - 1], s[ids] - x};
    dt = {x - t[idt - 1], t[idt] - x};
    lint x1 = max(ds[1], dt[1]), y = max(dt[0], ds[0]);
    lint z = min(ds[0] + 2 * dt[1], 2 * ds[0] + dt[1]);
    lint w = min(ds[1] * 2 + dt[0], ds[1] + dt[0] * 2);
    cout << min({x1, y, z, w}) << endl;
  }
}

Measured memory_bytes: 4576
import scala.io.StdIn._

object Main extends App {

  val Array(n,m) = readLine().split(" ").map(_.toInt)
  val X = readLine().split(" ").map(_.toLong)

  def solve() = {
    val sorted = X.sorted
    (0 until m-1).map { i =>
      sorted(i+1) - sorted(i)
    }.sorted(Ordering[Long].reverse).drop(n-1).sum
  }

  println(solve())

}



Measured memory_bytes: 65464
N = int(input())
BTC = 0
JPN = 0
for _ in range(N):
    x,u = (i for i in input().split())  
    x = float(x)
    if u == 'JPY':
        JPN += x
    else:
        BTC += x
print(JPN + 380000.0 * BTC)

Measured memory_bytes: 2940
package main

import "fmt"

func main() {
	var s string
	fmt.Scanf("%s", &s)

	i := 0
	j := len(s) - 1
	n := 0
	for i < j {
		if s[i] != s[j] {
			n++
		}
		i++
		j--
	}
	fmt.Print(n)
}


Measured memory_bytes: 512
import numpy as np

N, M, X = map(int, input().split())
books = [list(map(int, input().split())) for _ in range(N)]
res = float('inf')

def dfs(A):
    global res
    if len(A) == N:
        tmp = np.array([0]*M)
        tmp_c = 0
        for i, a in enumerate(A):
            if a == 1:
                tmp += np.array(books[i][1:])
                tmp_c += books[i][0]

        if np.all(tmp >= X):
            if tmp_c < res:
                res = tmp_c

        return

    dfs(A + [0])
    dfs(A + [1])


dfs([])
if res == float('inf'):
    res = -1
print(res)

Measured memory_bytes: 27340
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <string>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n, d, count = 0;
  cin >> n >> d;
  for(int i=0; i<n; i++){
    long long x, y;
    cin >> x >> y;
    if(x*x+y*y<=d*d){
      count++;
    }
  }
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 3652
def main():
    N, M = map(int, input().split())

    odd = []
    even = []
    for d in range(1, M + 1):
        if d % 2 == 1:
            if not odd:
                odd.append((1, 2))
            else:
                x = odd[-1][0] - 1
                y = x + d
                odd.append((x, y))
        else:
            if not even:
                even.append((1, 3))
            else:
                x = even[-1][0] - 1
                y = x + d
                even.append((x, y))

    if odd:
        start = 1
        d = start - odd[-1][0]
        for x, y in odd:
            print(x + d, y + d)
    if even:
        start = odd[-1][1] + d + 1
        d = start - even[-1][0]
        for x, y in even:
            print(x+d, y+d)


if __name__ == "__main__":
    main()

Measured memory_bytes: 21152
/*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)

inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void scd(int &a){scanf("%d",&a);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int i=0 ; i<b ; i++)scanf("%d",&a[i])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	int a,b,c;
	scd(a);
	scdd(b,c);
	if(a<b && b<c)
	{
		printf("Yes\n");
	}
	else
	printf("No\n");
	return 0;
}

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

using namespace std;

int main(){
       string s;
       int count=0;
       cin>>s;
if(s.find("S")!=string::npos&&s.find("N")!=string::npos&&s.find("W")!=string::npos&&s.find("E")!=string::npos){
cout<<"Yes"<<endl;
}

else if(s.find("S")==string::npos&&s.find("N")==string::npos&&s.find("W")!=string::npos&&s.find("E")!=string::npos){
    cout<<"Yes"<<endl;
}

 else if(s.find("S")!=string::npos&&s.find("N")!=string::npos&&s.find("W")==string::npos&&s.find("E")==string::npos){
    cout<<"Yes"<<endl;
}

else{cout<<"No"<<endl;}

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

ll f(ll n)
{
    ll ans = 1LL<<60;
    for(ll i = 1; i * i <= n; i++)
    {
        if(n % i == 0)
        {
            ll tmp = i + n / i - 2;
            ans = min(ans, tmp);
            if(i * i != n)
            {
                ans = min(ans, tmp);
            }
        }
    }
    return ans;
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    cout << f(n) << endl;
    return 0;
}



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

int a, b, c, x, y;
int main() {
    int ans = 0;
    cin >> a >> b >> c >> x >> y;
    if(a + b <= c*2) {
       ans = x * a + b * y;
    }
    else {
        if(x > y) {
            ans = 2*c*y;
            if(2*c <= a) ans += 2*c*(x-y);
            else ans += (x-y)*a;
        }
        else {
            ans = 2*c*x;
            if(2*c <= b) ans += 2*c*(y-x);
            else ans += (y-x)*b;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};
/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_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;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/
int main(){
    vector<int> ans(0);
    while(true){
        int N; cin >> N;
        if (N == 0){
            break;
        }
        int res = 0;
        int sum = 0, mn = 1;
        for (int st = 1; st < N; st++){
            sum = st;
            int num = st+1;
            while(sum < N){
                sum += num;
                num++;
                if (sum == N){
                    res++;
                }
            }
        }
        ans.push_back(res);
    }
    for (int i = 0; i < ans.size(); i++){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3144
n, x = map(int, input().split())
y = [x] + list(map(int, input().split()))
y.sort()

def g(a, b):
    while b != 0:
        a, b = b, a%b
    return a

for i in range(n):
    y[i] = y[i+1] - y[i]
y.pop()
for i in range(n-1):
    y[i+1] = g(y[i+1], y[i])

print(y[-1])

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

int main() {
  int n, a, b, c, d;
  cin >> n;
  
  a = n / 1000;
  b = (n - 1000 * a) / 100;
  c = (n - 1000 * a - 100 * b) / 10;
  d = (n - 1000 * a - 100 * b - 10 * c);
  
  if (a == b && b == c){
    cout << "Yes" << endl;
  }
  else if (b == c && c == d){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] suit={"S","H","C","D"};
        Set<String> list = new HashSet<String>(1000);
        for (int i = 0; i < n; i++) {
            list.add(br.readLine());
        }
        for (int i=0;i<4;i++) {
            for(int j=1;j<=13;j++){
                if(!list.contains(suit[i]+" "+j)){
                    System.out.println(suit[i]+" "+j);
                }
            }
        }
    }
}

Measured memory_bytes: 24224
/* vim:set foldmethod=marker: */
#include <bits/stdc++.h>
using namespace std;

//{{{
#define all(x) (x).begin(),(x).end()
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define RREP(i,a,b) for(int i=(int)(a); i>=b; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;

#define dump(x) (cerr << #x << "=" << x << endl)
template<class T> ostream& osContainer(ostream& os,T c) { os<<'[';for(decltype(c.begin()) it=c.begin();it!=c.end();it++)os<<*it<<',';os<<']';return os; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { return osContainer(os,v); }
template<class T> ostream& operator<<(ostream& os,const set<T>& s) { return osContainer(os,s); }
template<class T> ostream& operator<<(ostream& os,const multiset<T>& s) { return osContainer(os,s); }
template<class T,class S> ostream& operator<<(ostream& os,const map<T,S>& m) { return osContainer(os,m); }
template<class T,class S> ostream& operator<<(ostream& os,const multimap<T,S>& m) { return osContainer(os,m); }
template<class T1,class T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){ os << '(' << p.first << ',' << p.second << ')'; return os; }

const int dx[] = {0,1,0,-1};
const int dy[] = {1,0,-1,0};
//}}}
//
struct edge{int from, to, cost;};

edge es[2001];

ll d[1001];
const ll INF = 1e15;
int V, E;

bool shortest_path(int s) {
    rep(i, V+1) d[i] = INF;
    d[s] = 0;

    int c = 0;
    ll postdv = d[V];
    while(true) {
        bool update = false;
        c++;
        rep(i, E) {
            edge e = es[i];
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        bool change_dv = d[V] != postdv;
        if (!update) return true;
        if (!change_dv && c > V-1) return true;
        if (c > V-1) return false;
        postdv = d[V];
    }
}

void solve()
{
    cin >> V >> E;

    rep(i, E) {
        int a, b, c;
        cin >> a >> b >>c;
        es[i] = {a,b,-c};
    }

    if (shortest_path(1)) {
        cout << -d[V] << endl;
    } else {
        cout << "inf" << endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(12);
    solve();
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
double last_x;
double last_y;

void draw_polar_line(double r, double theta) {
    double radians;

    radians = theta / 180 * M_PI;
    last_x = last_x + r*cos(radians);
    last_y = last_y + r*sin(radians);
    printf("%.8lf %.8lf\n", fabs(last_x), fabs(last_y));
    if(fabs(last_x-100) < 0.00001) {
    	exit(0);
    }
}

void draw_fractal_line(double len, double theta, int order) {
    if (order == 0) {
        draw_polar_line(len, theta);
    } else {
        draw_fractal_line(len/3, theta, order - 1);
        draw_fractal_line(len/3, theta + 60, order - 1);
        draw_fractal_line(len/3, theta - 60, order - 1);
        draw_fractal_line(len/3, theta, order - 1);
    }
}

void koch_fractal(double size, int order) {
    draw_fractal_line(size, 0, order);
    draw_fractal_line(size, 120, order);
    draw_fractal_line(size, 240, order);
}

int main(void) {
    int n;
    scanf("%d\n", &n);
    last_x = 0.0;
    last_y = 0.0;
 
    printf("%.8lf %.8lf\n", 0.0, 0.0);
    koch_fractal(100.0, n);
    return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;



int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<bool>> mp(n, vector<bool>(m));
    vector<vector<int>> id(n, vector<int>(m));
    for(int i = 0, cnt = 0; i < n; i++) {
        string s; cin >> s;
        for(int j = 0; j < m; j++) {
            mp[i][j] = (s[j] == '#');
            id[i][j] = cnt++;
        }
    }
    vector<vector<int>> dp(n, vector<int>(m));

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            dp[i][j] = (i + j == 0) ? mp[i][j] : 1e9;
            if(i) {
                dp[i][j] = min(dp[i][j], dp[i - 1][j] + (int)(mp[i - 1][j] == 0 && mp[i][j] == 1));
            }
            if(j) {

                dp[i][j] = min(dp[i][j], dp[i][j - 1] + (int)(mp[i][j - 1] == 0 && mp[i][j] == 1));
            }
        }
    }
    cout << dp[n - 1][m - 1];
    return 0;
}


Measured memory_bytes: 384
now=1000
n=int(input())
l=list(map(int,input().split()))+[0]
m=l[0]
i=1
while i<n:
    if l[i]<m:m=l[i]
    else:
        while i<n and l[i]<l[i+1]:
            i+=1
        k=now//m
        now=now%m + k*l[i]
        m=l[i]
    i+=1
print(now)

Measured memory_bytes: 9196
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  char lc;
  cin >> lc;
  for (int i = 1; i < n; i++) {
    char c;
    cin >> c;
    if (c == lc) {
      ans++;
    } else {
      lc = c;
    }
  }
  
  cout << min(ans + 2 * k, n - 1) << endl;
  
  return 0;
}

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

int main() {
    int n, x;
    while (cin >> n >> x) {
        if (!n && !x) break;
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                for (int k = j + 1; k <= n; k++) {
                    if (i + j + k == x) ans++;
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n, m;
    cin >> n >> m;
    vector<ll> x(n), y(m);
    for(int i = 0; i < n; i++) cin >> x[i];
    for(int i = 0; i < m; i++) cin >> y[i];
    ll sumx, sumy;
    sumx = sumy = 0;
    for(int i = 0; i < n; i++) {
        sumx += i * x[i] - (n-1-i) * x[i];
        sumx %= MOD;
    }
    for(int i = 0; i < m; i++) {
        sumy += i * y[i] - (m-1-i) * y[i];
        sumy %= MOD;
    }
    ll ans = sumx * sumy % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
    long long int x,y=100,i=0;

    scanf("%lld",&x);

    while(true){
        y=y+y*0.01;
        i++;
        if(y>=x){
            break;
        }
    }

    printf("%lld\n",i);

    return 0;
}

Measured memory_bytes: 3220
# 初期値
N = int(input())
A = list(map(int, input().split()))

count = 0
##############################
def counter(A, count):
    global new_A
    global new_count
    new_A = []
    new_count = count
    for a in A:
        if a == 0:
            break
        elif a % 2 == 0:
            new_A.append(int(a / 2))
        else:
            break
    if len(new_A) == N:
        new_count += 1
    return new_A, new_count
#################################

# 計算
counter(A, count)

for i in range(100):
    counter(new_A, new_count)

print(counter(new_A, new_count)[1])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int n;
ll a[400];
ll dp[410][410];
ll csum[410];

ll f(int l, int r)
{
  assert(l < r);
  if (r - l == 1)
    return 0;
  if (dp[l][r] != -1)
    return dp[l][r];

  ll Min = LINF;
  REP(i, l + 1, r)
  {
    Min = min(Min, f(l, i) + f(i, r) + csum[r] - csum[l]);
  }
  return dp[l][r] = Min;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  cin >> n;
  rep(i, n) cin >> a[i];
  rep(i, 410) rep(j, 410) dp[i][j] = -1;
  csum[0] = 0;
  rep(i, n) csum[i + 1] = csum[i] + a[i];
  cout << f(0, n) << endl;
  return 0;
}


Measured memory_bytes: 1664
// Problem : B - Minor Change
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define vi vector<int>
#define pii pair<int, int>
#define si set<int>
#define y1 yy
#define debug if(printDebug)
using namespace std;
bool printDebug=false;
int main(){
    //printDebug=true;
    /*freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);//*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);//*/
    string s1, s2;
    cin >> s1 >> s2;
    int ans=0;
    for(int i=0; i<s1.size(); i++){
    	ans+=s1[i]!=s2[i];
    }
    cout << ans << "\n";
    return 0;
}


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

int main(){
  int A,B;
  cin >> A >> B;
  
  int cnt=0;
  for(int i=A;i<=B;i++){
    int a=i%10;
    int b=(i/10)%10;
    int d=(i/1000)%10;
    int e=i	/10000;
    if(a==e && b==d){
    cnt++;
    }
  }
  cout << cnt <<endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    if(s.front() == s.back()) cout << s.back() << endl;
    else cout << 'o' << endl;
    return 0;
}




Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

set<int> ans;
int p[20];
int n;

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

int lcm(int a,int b){
  return a*b/gcd(a,b);
}


void solve(int a,int b){
  //cout<<a<<endl;
  ans.insert(a);
  repi(i,b+1,n){
    solve(lcm(a,p[i]),i);
  }
}
  


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  
  cin>>n;
  int nex=1;
  rep(i,n) cin>>p[i];
  rep(i,n){
    solve(p[i],i);
  }
  cout<<ans.size()<<endl;
  
    

  return 0;
}



Measured memory_bytes: 4092
#include<iostream>
#define endl "\n"
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a=0,b=0,c=0,d=0;
	while(n--)
	{
		string str;
		cin>>str;
		if(str=="AC")
		a++;
		else if(str=="WA")
		b++;
		else if(str=="TLE")
		c++;
		else
		d++;
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<b<<endl;
	cout<<"TLE x "<<c<<endl;
	cout<<"RE x "<<d<<endl;
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main(){
int a,b,c,d;
cin>>a>>b>>c;
if(a>=b){
  d=a;
  a=b;
  b=d;
}if(b>=c){
  d=b;
  b=c;
  c=d;
  if(a>=b){
    d=a;
    a=b;
    b=d;
  }
}
cout<<c-a<<endl;
return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
using namespace std;
#define fi first
#define se second
#define ll long long
int n, time = 0, in[50], out[50], par[50], pind[50];
vector<pair<int, int> > adj[50];
void dfs(int c, int p, int aaa){
	par[c] = p;
	pind[c] = aaa;
	in[c] = time;
	time++;
	for (auto e : adj[c]){
		if (e.fi != p){
			dfs(e.fi, c, e.se);
		}
	}
	out[c] = time;
	time++;
}
int main(){
	scanf("%d", &n);
	for (int i = 0; i < n - 1; i++){
		int x, y;
		scanf("%d %d", &x, &y);
		adj[x - 1].push_back({y - 1, i});
		adj[y - 1].push_back({x - 1, i});
	}
	dfs(0, -1, -1);
//	for (int i = 0; i < n; i++){
//		printf("%d %d %d\n", i, par[i], pind[i]);
//	}
	int m;
	scanf("%d", &m);
	bool e[m][n - 1];
	for (int i = 0; i < m; i++){
		for (int j = 0; j < n - 1; j++) e[i][j] = false;
		int x, y;
		scanf("%d %d", &x, &y);
		x--;
		y--;
		int cur = x;
		while (cur != -1){
			if (in[cur] <= in[y] && out[y] <= out[cur]) break;
			e[i][pind[cur]] = true;
			cur = par[cur];
		}
		cur = y;
		while (cur != -1){
			if (in[cur] <= in[x] && out[x] <= out[cur]) break;
			e[i][pind[cur]] = true;
			cur = par[cur];
		}
//		printf("  ");
//		for (int j = 0; j < n - 1; j++){
//			if (e[i][j]) printf("%d ", j);
//		}
//		printf("\n");
	}
	ll ans = 0;
	for (int i = 0; i < (1 << m); i++){
		bool f[n - 1];
		for (int j = 0; j < n - 1; j++) f[j] = false;
		int what = 0, count = -1;
		for (int j = 1; j < (1 << m); j *= 2){
			count++;
			if ((i & j) == 0) continue;
//			printf("%d ", j);
			what++;
			for (int k = 0; k < n - 1; k++){
				if (e[count][k]) f[k] = true;
			}
		}
//		printf("\n%d: ", i);
//		for (int j = 0; j < n - 1; j++){
//			if (f[j]) printf("%d ", j);
//		}
//		printf("\n");
		int mask = 0;
		for (int j = 0; j < n - 1; j++){
			if (!f[j]) mask++;
		}
		if (what % 2 == 0){
			ans += (1ll << mask);
		}else{
			ans -= (1ll << mask);
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
delta=[]
for i in range(n):
  delta.append(abs(a-(t-h[i]*0.006)))
minimum=min(delta)
for i in range(n):
  if delta[i]==minimum:
    print(i+1)


Measured memory_bytes: 3444
def LI(): return list(map(int,input().split()))
A,B,C,D = LI()
count = 0
while 1:
    count += 1
    C -= B
    if C<=0:
        break
    count += 1
    A -=D
    if A<=0:
        break
print('Yes' if count%2==1 else 'No')


Measured memory_bytes: 9044
n = int(input())
data = [int(x) for x in input().split(" ")]
data[0] -= 1

for i in range(n-1):
    if data[i] < data[i+1]:
        data[i+1] -= 1
    elif data[i] == data[i+1]:
        pass
    else:
        print("No")
        exit()

print("Yes")
    

Measured memory_bytes: 14224
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;

void main() {
	long x = readln.chomp.to!long;
	long atom = x / 11;
	long remain = x - atom * 11;
	long ans = atom * 2;
	if (remain > 6) {
		ans += 2;
	} else if (remain > 0) {
		++ans;
	}
	ans.writeln;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;




int main() {
	int n;
	int ans, t;
	vi v(110, 0);
	while (cin >> n) {
		if (n == 0)break;
		ans = 0;
		rep(i, n) {
			cin >> v[i];
		}
		rep(i, n) {
			for (int j = 0; j < n - i - 1; j++) {
				if (v[j] > v[j + 1]) {
					t = v[j];
					v[j] = v[j + 1];
					v[j + 1] = t;
					ans++;
				}
			}
		}
		/*rep(i, n) {
			cout << v[i] << " ";
		}
		cout << endl;*/
		cout << ans << endl;
	}
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
vector<long long> res1; 
vector<long long> res2;
long long mod=1e9+7;
long long fact[200010];
long long poww(long long x,long long n)
{
	if(n==0)
	return 1*1LL;
	else if(n%2==0)
	{
		return poww(x,n/2)*poww(x,n/2)%mod;
	}
	else if(n%2!=0)
	{
		return poww(x,n/2)*poww(x,n/2)%mod*x%mod;
	}
}
long long C(long long k,long long n)
{
	if(k==0||n==0) return 1*1LL;
	if(k>n) return 0*1LL;
	return poww(fact[k],mod-2)%mod * poww(fact[n-k],mod-2)%mod * fact[n]%mod;
}
int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(0);
	//cout.tie(0);
	fact[0]=1*1LL;
	for(long long i=1;i<=200000;i++)
	{
		fact[i]=(fact[i-1]*i)%mod;
	}
	long long h,w,a,b;
	long long ans=0;
	cin >> h>>w>>a>>b;
	for(int i=1;i<=w-b;i++){
		ans+=C(h-a-1,h-a+b+i-2)*C(a-1,a+w-b-i-1)%mod;
		ans=ans%mod;
	}
	cout<<ans%mod;
	//cout  << C(99,1000);
}
//yyyyyyy

Measured memory_bytes: 1792
while True:
    n = int(input())
    if n == 0:
        break
    mat = []
    for i in range(n):
        mat.append(list(map(int, input().split())))
        mat[i].append(sum(mat[i]))
    mat.append([0]*(n+1))
    for i in range(n+1):
        for j in range(n):
            mat[n][i]+=mat[j][i]
    for i in mat:
        for j in range(n+1):
            print("%5d" % (i[j]), end="")
        print()
        


Measured memory_bytes: 5616
n = int(input())
r = int(input())
rr = int(input())

ans = rr- r
ma, mi = max(r, rr), min(r, rr)

for _ in range(n - 2):
    R = int(input())
    ans = max(R - mi, ans)
    
    ma = max(ma, R)
    mi = min(mi, R)
    
    
print(ans)
    
    


Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T x=0,f=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=(1<<18)+9,mod=998244353,inv2=(mod+1)/2;
	inline int add(int x,int y){return x+y>=mod?x-mod+y:x+y;}
	inline int sub(int x,int y){return x>=y?x-y:x+mod-y;}
	inline int qpow(int x,int y){
		int ret=1;
		while(y){
			if(y&1) ret=1LL*ret*x%mod;
			x=1LL*x*x%mod;y>>=1;
		}
		return ret;
	}
	int limit,bit;
	inline void fwt(int *a,int inv){
		for(int mid=1;mid<limit;mid<<=1)
			for(int i=0,R=mid<<1;i<limit;i+=R)
				for(int j=0;j<mid;j++){
					int x=1LL*a[i+j]*(~inv?1:inv2)%mod,y=1LL*a[i+j+mid]*(~inv?1:inv2)%mod;
					a[i+j]=add(x,y),a[i+j+mid]=sub(x,y);
				}
	}

	int n,a[N],f[N];
	int main(){
		n=read<int>(),bit=n,limit=1<<n;

		int sum=0;
		for(int i=0;i<limit;i++) sum=(a[i]=read<int>())+sum;
		sum=qpow(sum,mod-2);
		for(int i=0;i<limit;i++) a[i]=1LL*a[i]*sum%mod;

		fwt(a,1);
		for(int i=1;i<limit;i++)
			f[i]=1LL*qpow(sub(1,a[i]),mod-2)*(i?(mod-limit):0)%mod;
		fwt(f,-1);

		int x=sub(0,f[0]);
		for(int i=0;i<limit;i++) printf("%d\n",add(f[i],x));
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

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

  vector<int> L(N);
  rep(i,0,N-1) cin >> L[i];

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

  long long ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      for (int k = j + 1; k < N; ++k) {
        if (L.at(i) + L.at(j) <= L.at(k)) break;
        ans++;
      }
    }
  }

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


Measured memory_bytes: 3644
// #pragma GCC optimize(2)
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
#define sc(z) scanf("%d", &(z))
#define _ff(i, a, b) for (signed i = (a); i <= (b); ++i)
#define _rr(i, a, b) for (signed i = (a); i >= (b); --i)
#define _f(i, a, b) for (signed i = (a); i < (b); ++i)
#define _r(i, a, b) for (signed i = (a); i > (b); --i)
#define lowbit(x) x &(-x)
const signed inf = 0x3f3f3f3f;
const signed maxn = 8e4 + 5;
int h[maxn];
stack<int> s;
int main() {
    int x; cin >> x;
    if (!x) cout << 1<< endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3616
import cmath
EPS = 1e-4

#外積
def OuterProduct(one, two):
	tmp = one.conjugate() * two
	return tmp.imag

#内積
def InnerProduct(one, two):
	tmp = one.conjugate() * two
	return tmp.real

#点が線分上にあるか
def IsOnSegment(point, begin, end):
	if abs(OuterProduct(begin-point, end-point)) <= EPS and InnerProduct(begin-point, end-point) <= EPS:
		return True
	else:
		return False

def InsidePolygon(point, dots):
	res = 0
	for i in range(len(dots)-1):
		res += cmath.phase((dots[i+1]-point) / (dots[i]-point))
	res += cmath.phase((dots[0]-point) / (dots[-1]-point))
	if abs(res) <= EPS:
		return False
	else:
		return True

n = int(input())
dots = []
for _ in range(n):
	x, y = map(int, input().split())
	dots.append(complex(x, y))
ans = []

def solve(p, dots):
	for i in range(n-1):
		if IsOnSegment(p, dots[i], dots[i+1]):
			return 1
	if IsOnSegment(p, dots[n-1], dots[0]):
		return 1
	if InsidePolygon(p, dots):
		return 2
	else:
		return 0

q = int(input())
for _ in range(q):
	x, y = map(int, input().split())
	p = complex(x, y)
	ans.append(solve(p, dots))

print(*ans, sep="\n")


Measured memory_bytes: 5960
#include <bits/stdc++.h>
using namespace std;
static const int MAX=500;
int N;
int F[100][11],P[100][11];

int main(){ 
    cin>>N;
    for(int i=0;i<N;i++){
        for(int j=0;j<10;j++)
            cin>>F[i][j];
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<=10;j++)
            cin>>P[i][j];
    }
    int res=-(1<<30);
    for(int b=1;b<(1<<10);b++){
        int cc=0;
        for(int i=0;i<N;i++){
            int c=0;
            for(int j=0;j<10;j++){
                if((b>>j&1)&&F[i][j])c++;
            }
            cc+=P[i][c];
        }
        if(res<cc)res=cc;
    }
    cout<<res<<"\n";
    return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


int main()
{
    ll r, D, x;
    cin >> r >> D >> x;
    REP(i,0,10) {
        x = r * x - D;
        _PR(x);
    }

    return 0;
}

/*



*/

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

int main(){

int N;
cin >> N;
int ans = 1;
int m_cnt = 0;
for(int i = 1; i <= N; i++){ 
    int now = i;
    int cnt = 0; 
    while(now % 2 == 0){
        now = now / 2;
        cnt++;
    }

    if(cnt > m_cnt) {
        m_cnt = cnt;
        ans = i;
    }
}
cout << ans << endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using P = pair<int,int>;
const int INF = 1e9;

int main(){
    int x;
    cin >> x;
    if (x) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<functional>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef unsigned long long ll;
typedef pair<ll,ll>P;
using namespace std;
const ll mod=1e9+7;
const int NMAX=1e5+6;
const int NSMALLMAX=1e5+6;
bool IsPrime(int n)
{
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)return false;
    }
        return n!=1;

}

int main()
{
    int q;
    cin>>q;
    vector<P> lr(q);
    ll mv=0;
    rep(i,q)
    {
        ll l,r;
        cin>>l>>r;
        lr[i].first=l;
        lr[i].second=r;
        mv=max(mv,r);

    }
    vector<ll> dp(mv+1,0);
    vector<bool> isprime(mv+1,false);
    isprime[2]=true;
    dp[0]=0;
    dp[1]=0;
    dp[2]=0;
    for(int i=3;i<=mv;i+=2)
    {
        if(IsPrime(i))
        {
            if(isprime[(i+1)/2])
            {
                dp[i]+=1;
            }
            isprime[i]=true;
        }
       
        dp[i]+=dp[i-2];
        
    }
    rep(i,q)
    {
        ll ans=dp[lr[i].second]-dp[lr[i].first];
        if(isprime[lr[i].first] && isprime[(lr[i].first+1)/2])ans++;
        cout<<ans<<endl;
    }

    
    
}

Measured memory_bytes: 3452
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [(String, i64); n],
    }
    let mut a = a;
    let mut b = Vec::new();
    for (k, v) in a.into_iter().enumerate() {
        b.push((v.0, v.1, k + 1));
    }
    b.sort();
    let mut k = String::from("");
    let mut v: Vec<(i64, usize)> = Vec::new();
    for i in b.into_iter() {
        if k != i.0 {
            k = i.0;
            v.sort();
            for m in v.iter().rev() {
                println!("{}", m.1);
            }
            v.clear();
            v.push((i.1, i.2));
        } else {
            v.push((i.1, i.2));
        }
    }
    for m in v.iter().rev() {
        println!("{}", m.1);
    }
}

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

#define MAXN 200010

int n,a[MAXN],cnt[1000010],f[1000010];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",a+i);
		++cnt[a[i]];
	}
	for(int i=1;i<=1000000;++i)
	{
		if(!cnt[i])continue;
		for(int j=i;j<=1000000;j+=i)
			f[j]+=cnt[i];
	}
	int ans=0;
	for(int i=1;i<=n;++i)
	{
		if(f[a[i]]==1)++ans;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 12404
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		int[] x = new int[n], y = new int[n];
		for (int i = 0; i < n; ++i) {
			x[i] = sc.nextInt();
		}
		sc.nextLine();
		for (int i = 0; i < n; ++i) {
			y[i] = sc.nextInt();
		}
		double p1 = 0;
		for (int i = 0; i < n; ++i) {
			p1 += Math.abs(x[i] - y[i]);
		}
		double p2 = 0;
		for (int i = 0; i < n; ++i) {
			p2 += (x[i] - y[i]) * (x[i] - y[i]);
		}
		p2 = Math.sqrt(p2);
		double p3 = 0;
		for (int i = 0; i < n; ++i) {
			p3 += Math.abs((x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]));
		}
		p3 = Math.cbrt(p3);
		double p4 = -0;
		for (int i = 0; i < n; ++i) {
			p4 = Math.max(p4, Math.abs(x[i] - y[i]));
		}
		System.out.println(p1);
		System.out.println(p2);
		System.out.println(p3);
		System.out.println(p4);
		sc.close();
	}
}


Measured memory_bytes: 26608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    int tmp;
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        A[tmp]++;
    }
    bool check = false;
    int k;
    for (int i = 0; i < N; i++) {
        if(A[i] != 0){
            if(check == true){
                No();
                return 0;
            }
            if(i < N-1 && A[i+1] != 0){
                check = true;
                k = i+1;
                i++;
            }
            else{
                check = true;
                k = i;
            }
        }
    }

    int s = A[k-1];
    int t = A[k];
    if( s != 0 && s + 1 <= k && 2*(k-s) <= t){
        Yes();
    }
    else if( s == 0 && k == N-1){
        Yes();
    }
    else if(s == 0 && 2 * k <= N){
        Yes();
    }
    else{
        No();
    }
    

}

Measured memory_bytes: 3796
s = input()[::-1]
t = input()[::-1]
for i in range(len(s)):
    for j in range(len(t)):
        if i + j >= len(s):
            break
        if s[i+j] != '?' and s[i+j] != t[j]:
            break
    else:
        tmp = list(s)
        for j in range(len(t)):
            tmp[i+j] = t[j]
        ans = str.replace(''.join(tmp), '?', 'a')[::-1]
        print(ans)
        break
else:
    print('UNRESTORABLE')

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

using namespace std;

int main() {

	int a, b;
    cin>>a>>b;
    if ( a+b == 3) {
    
		printf("3\n");
    }
    else if(a+b == 4) {
			printf("2\n");
    
    }
    else if(a+b == 5) {
    printf("1\n");
    }

    return 0;
}


Measured memory_bytes: 256