akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {

  long long int n;
  cin >> n;

  vector< long long int > v;

  for ( long long int i = 0; i < n * 2; i++ ) {

    long long int in;
    cin >> in;
    v.push_back( in );

  }

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

  long long int ans = 0;

  for ( long long int i = 0; i < n; i++ ) {
    ans += v[i*2];
  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll divi[129];
ll vis[129];
map<long double,ll>mp1;
map<ll,ll>mp2;
vector<int>stp[29];
string str1;
string str2;
ll arra[100007];
deque<ll>save;
ll ans1[100005];
ll ans2[100005];
ll inp1[200009];
ll inp2[200009];
pair<ll,ll>sol;
//map<pair<ll, ll>, ll> mp3;
map<char,ll>mp3;
map<ll,ll>L;
map<ll,ll>R;
vector<ll>c_pg[1009];
ll x_p[1009];
ll y_p[1009];
ll x_last[1009];
ll y_last[1009];
int main()
{
  ll i,j,k,l,p=0,q=0,r=0,s=0,t,m,n,check=1,x=0,y=1,z=0,a=0,b=0,c=0,zero=0;
  cin>>x>>y;
  p=x/y;
  if(x%y!=0)
    p++;
    cout<<p;
 
     
  
   
  
    	
}

Measured memory_bytes: 256
#include<stdio.h>
typedef struct{
    int min;
    int max;
}Point;
int main(void){
    while(1){
        int N,M;
        scanf("%d%d",&N,&M);
        if(N+M==0) break;
        Point p[10001]={0};
        for(int i=0;i<M;i++){
            int score,k;
            scanf("%d%d",&score,&k);
            for(int j=0;j<k;j++){
                int hito;
                scanf("%d",&hito);
                if(k==1){
                    p[hito].min+=score;
                    p[hito].max+=score;
                }
                else{
                    p[hito].max+=score;
                }
            }
        }
        int diff=0;
        for(int i=1;i<=N;i++){
            for(int j=1;j<=N;j++){
                if(i==j) continue;
                if(diff<p[i].max-p[j].min)
                    diff=p[i].max-p[j].min;
            }
        }
        /*for(int i=1;i<=N;i++){
            printf("%d %d\n",p[i].min,p[i].max);
        }*/
        printf("%d\n",diff+1);
    }
}



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

using ll = long long;
#define REP(i, n) for(int (i)=0; (i)< (n); ++i)
#define REPR(i, n) for(int (i)=(n); (i)>=0; --i)
#define FOR(i, n, m) for(int (i)=(n); (i)<(m); ++i)


int main(){
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  REP(i, n){
    int id, k;
    cin >> id >> k;
    g[i].resize(k);
    REP(j, k){
      int v;
      cin >> v;
      v--;
      g[i].push_back(v);
    }
  }
  vector<int> dist(n, -1);
  dist[0] = 0;
  queue<pair<int, int>> que;
  que.push({0,0});
  while(!que.empty()){
    int v, d;
    tie(v, d) = que.front();que.pop();
    REP(i, g[v].size()){
      int nv = g[v][i];
      if(dist[nv] != -1) continue;
      dist[nv] = d + 1;
      que.push({nv, d+1});
    }
  }
  REP(i, n){
    cout << i+1 << " " << dist[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3168
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
#define int long long
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;

signed main(){
	int A,B,C,D,E,F;
	int ans=0,ans2=0;
	double Max=-INF;
	cin>>A>>B>>C>>D>>E>>F;
	for(int i=0;i<=F;i+=100*A){
		for(int j=0;i+j<=F;j+=100*B){
			for(int k=0;(i+j)/100*E>=k;k+=C){
				for(int l=0;(i+j)/100*E>=k+l&&i+j+k+l<=F;l+=D){
					if(Max<double(k+l)/double(i+j+k+l)){
						Max=double(k+l)/double(i+j+k+l);
						ans=k+l;
						ans2=i+j+k+l;
					}
				}
			}
		}
	}
	cout<<ans2<<" "<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split(" "))
a_list = []
for _ in range(n):
    a_list.append(list(map(int, input().split(" ")))[1:])

if len(a_list) == 1:
    print(len(a_list[0]))
    exit()
ans = set(a_list[0])
for a_lis in a_list:
    ans = ans & set(a_lis)

print(len(list(ans)))


Measured memory_bytes: 38384
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0){
                break;
            }
            else{
                for(int i = 0; i < H; i++){
                    for(int j = 0; j < W; j++){
                        System.out.printf("#");
                    }
                    System.out.println("");
                }
                System.out.println("");
            }
        }
    }
}


Measured memory_bytes: 57740
#include <iostream>
#include <vector>

using namespace std;

// n: 頂点数, m: 辺の数
int n, m;

int ans;
bool visited[8];
bool all_visited;

// max_n: 最大の頂点数
const int max_n = 8;
// 隣接リストによるグラフの表現
vector<int> G[max_n];

// cur: 現在 (current) いる頂点
void dfs(int cur) {
    visited[cur] = true;
    // cout << cur+1 << endl;
    all_visited = true;
    for (int i = 0; i < n; i++) {
        if (!visited[i]) {
            all_visited = false;
            break;
        }
    }
    if (all_visited) { ans++; }
    for (auto e: G[cur]) {
        if (!visited[e]) {
            dfs(e);
            visited[e] = false;
        }
    }
}

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

    for (int i = 0; i < m; i++) {
        int s, t;
        cin >> s >> t;
        // 0-based index にしたいのでデクリメント
        s--; t--;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    dfs(0);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

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

  int y, n;
  cin >> y >> n;
  int x;
  bool out[105] = {false};
  rep(i, n){
    cin >> x;
    out[x] = true;
  }
  int ans = 0;
  reps(i, 101){
    if(!out[i]){
      //cout << i << " ";
      if(abs(ans, y) > abs(i, y)){
	ans = i;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


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

using namespace std;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b != 0) gcd(b, a%b);
  return b;
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a/gcd(a , b)) * b;
}

int main(){
 
  int n; cin >> n;
  vector<vector<vector<vector<int> > > >dp(n + 10, vector<vector<vector<int> > >(4, vector<vector<int> >(4, vector<int >(4, 0))));
  
  dp[0][3][3][3] = 1;

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

          for(int a = 0; a < 4; a++)
          {
            if(a == 2 and j == 1 and k == 0)continue;
            if(a == 2 and j == 0 and k == 1)continue;
            if(a == 1 and j == 2 and k == 0)continue; 
            if(a == 2 and j == 1 and l == 0)continue;
            if(a == 2 and k == 1 and l == 0)continue;

            dp[i + 1][a][j][k] += dp[i][j][k][l];
            dp[i + 1][a][j][k] %= MOD;
          }
          
        }
        
      }
      
    }
    
  }
  
  ll ans = 0;

  for(int i = 0; i < 4; i++)
  {
    for(int j = 0; j < 4; j++)
    {
      for(int k = 0; k < 4; k++)
      {
        ans += dp[n][i][j][k];
        ans %= MOD;
      }
  
    }
    
  }
  
  pr(ans);

  return 0;
}

Measured memory_bytes: 384
type node = N of int * node list ;;
Scanf.scanf "%d" (fun n ->
    let xd = Array.init n (fun _ -> Scanf.scanf " %d %d" (fun x d -> x, d)) in
    Array.sort compare xd;

    let rec loop i acc =
        if i < 0 then acc else (
            let x, d = xd.(i) in
            let rec loop_i c = function
                | [] -> c, []
                | (N (a, b) as hd) :: tl ->
                        if a < x + d then loop_i (hd :: c) tl else c, (hd :: tl)
            in
            let c, next = loop_i [] acc in
            loop (i - 1) (N (x, c) :: next)
        )
    in
    let result = loop (n - 1) [] in
    let m = 998244353 in
    let ( +@) a b = (a + b) mod m in
    let ( *@) a b = ((a mod m) * (b mod m)) mod m in
    let rec calc l = List.fold_left (fun acc (N(_, l)) -> acc *@ (1 +@ calc l)) 1 l in
    calc result |> Printf.printf "%d\n"
)

Measured memory_bytes: 28544
#include<stdio.h>

int main (){
	
	int L, R, d;
	scanf("%d %d %d", &L, &R, &d);
	
	
int i;
	
		if (i%d ==0 && L%d == 0){
			printf ("%d\n", (R/d) - (L/d) + 1);
		
			}
		else if (i%d==0){
			printf ("%d\n", (R/d) - (L/d));
		
		}
	

	return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,k;
	cin>>n>>k;

	ll arr[n];
	for(ll i =0;i<n;i++)
		cin>>arr[i];

	ll s[n+1];
	s[0] = 0;

	for(ll i =1;i<=n;i++)
		s[i] = s[i-1] + arr[i-1];
	for(ll i = 1;i<=n;i++)
	    s[i] = ((s[i] - i)%k + k)%k;

	map<ll,ll> m;
	m[0] = 1;

	ll ans = 0;
	for(ll j = 1;j <= n;j++){
		//find i such that (s[j] - j) %k = (s[i] - i)%k
		// j - k < i < j
		//cout<<s[j]<<endl;
		if(j - k >= 0)
			m[s[j-k]]--;

		ans+=m[s[j]];

		m[s[j]]++;
	}
	cout<<ans;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i<b; i++)
#define lli long long
#define pb push_back
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
 
int main()
{
    fast
    int x,y;
    cin>>x>>y;
    if(y%2)
    cout<<"No";
    else{
        if(y>=2*x && y<=4*x)
        cout<<"Yes";
        else
        cout<<"No";
    }
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define fast_io ios::sync_with_stdio(false);cin.tie(NULL);
#define input freopen("Test.txt","r",stdin)
#define output freopen("Output.txt","w",stdout);
#define what_is(x) cout<<#x<<" is "<<x<<endl;
#define F(i,a,b) for(int i = a; i < b; i++)
#define MAX(a,b,c) max(a,max(b,c))
#define MIN(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define inf 1000000000
const double pi = 3.141592653589793238460;
#define debug false
#define MAXN 100010
#define mod 1000000007


void solve()
{
	int n;
	cin>>n;
	string s1,s2;
	cin>>s1>>s2;
	for(int i=0;i<n;i++)
	{
		cout<<s1[i]<<s2[i];
	}
	cout<<"\n";
}

int main()
{
     // input; // output; // if(debug){watch_is();}
    fast_io;
    solve();   
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

H,W = map(int, input().split())
a = [list(map(int, input().split())) for i in range(H)]
a_eo = [[a[i][j] % 2 for j in range(W)] for i in range(H)]

N = 0
move = ""
for i in range(H):
    for j in range(W):
        if a_eo[i][j] == 1:
            if j < W-1 and 1 in a_eo[i][j+1:]:
                a[i][j] -= 1
                a[i][j+1] += 1
                a_eo[i][j] = 0
                a_eo[i][j+1] = (a_eo[i][j+1] + 1) % 2
                N += 1
                move += "%d %d %d %d\n" % (i+1, j+1, i+1, j+1+1)
            elif i < H-1 and 1 not in a_eo[i][j+1:]:
                a[i][j] -= 1
                a[i+1][j] += 1
                a_eo[i][j] = 0
                a_eo[i+1][j] = (a_eo[i+1][j] + 1) % 2
                N += 1
                move += "%d %d %d %d\n" % (i+1, j+1, i+1+1, j+1)
            else:
                break

print("%d\n" % N + move)


Measured memory_bytes: 15136
// 2017/11/20 Tazoe

#include <iostream>
#include <queue>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

class FC{
public:
	string p;	// p[0]???????????????
	int n;		// ???????????°

	bool is_over()		// ????????????
	{
		return p[1]==p[2] && p[2]==p[3] && p[3]==p[4] && p[4]==p[5]	// p[1]???p[9]
		    && p[5]==p[6] && p[6]==p[7] && p[7]==p[8] && p[8]==p[9]
		    && p[10]==p[11] && p[11]==p[12]				// p[10]???p[12]
		    && p[13]==p[14] && p[14]==p[15]				// p[13]???p[15]
		    && p[16]==p[17] && p[17]==p[18]				// p[16]???p[18]
		    && p[19]==p[20] && p[20]==p[21];				// p[19]???p[21]
	}

	void rot1()		// ?????¢1
	{
		swap(p[ 7], p[22]);  swap(p[ 8], p[23]);  swap(p[ 9], p[24]);
		swap(p[13], p[18]);  swap(p[10], p[12]);
	}

	void rot2()		// ?????¢2
	{
		swap(p[ 1], p[28]);  swap(p[ 2], p[29]);  swap(p[ 3], p[30]);
		swap(p[15], p[16]);  swap(p[19], p[21]);
	}

	void rot3()		// ?????¢3
	{
		swap(p[ 1], p[24]);  swap(p[ 4], p[27]);  swap(p[ 7], p[30]);
		swap(p[10], p[21]);  swap(p[16], p[18]);
	}

	void rot4()		// ?????¢4
	{
		swap(p[ 3], p[22]);  swap(p[ 6], p[25]);  swap(p[ 9], p[28]);
		swap(p[12], p[19]);  swap(p[13], p[15]);
	}
};

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

	for(int i=0; i<N; i++){
		string p = "0";
		for(int j=1; j<=30; j++){
			string c;
			cin >> c;

			p += c;
		}

		queue<FC> que;			// ?????\???
		map<string, bool> memo;		// ?????¢

		FC now;
		now.p = p;
		now.n = 0;
		que.push(now);
		memo[now.p] = true;

		while(!que.empty()){		// ?????\???????????????????????§
			now = que.front();
			que.pop();

			if(now.is_over()){
				cout << now.n << endl;
				break;
			}

			FC nex1 = now;  nex1.rot1();  nex1.n++;
			if(memo.find(nex1.p)==memo.end()){
				que.push(nex1);
				memo[nex1.p] = true;
			}

			FC nex2 = now;  nex2.rot2();  nex2.n++;
			if(memo.find(nex2.p)==memo.end()){
				que.push(nex2);
				memo[nex2.p] = true;
			}

			FC nex3 = now;  nex3.rot3();  nex3.n++;
			if(memo.find(nex3.p)==memo.end()){
				que.push(nex3);
				memo[nex3.p] = true;
			}

			FC nex4 = now;  nex4.rot4();  nex4.n++;
			if(memo.find(nex4.p)==memo.end()){
				que.push(nex4);
				memo[nex4.p] = true;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3248
#Exhaustive Search
N=int(input())
A=list(map(int,input().split()))

bit_all=[]
for i in range(2**N):
    bit=[]
    for _ in range(N):
        bit.append(i%2)
        i//=2
    bit_all.append(bit)

m_list=[]
for bit in bit_all:
    m=0
    for a,b in zip (A,bit):
        m+=a*b
    m_list.append(m)

M=int(input())
q=list(map(int,input().split()))
for i in range(M):
    if q[i] in m_list:
        print("yes")
    else:
        print("no") 


Measured memory_bytes: 327580
#include <set>
#include <map>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

typedef long long ll;

using namespace std;

struct Edge{
  ll cap; // capacity
  int to;
  int rev; // reverse edge id

  Edge(){}
  Edge(ll c, int t, int r) :
    cap(c), to(t), rev(r){}
};

template<class E> // Edge type
class Graph{
public:
  typedef std::vector<std::vector<E> > G;

private:
  G g;

public:
  Graph(int n) : g(G(n)) {}

  void addEdge(int from, int to, ll cap){
    g[from].push_back(E(cap, to, g[to].size()));
    g[to].push_back(E(0, from, g[from].size() - 1));
  }

  G &getRowGraph(){
    return g;
  }
};

template<class E>
class Dinic{
  typedef typename Graph<E>::G G;
  G &g;
  std::size_t n; // size of graph

  std::vector<int> level;
  std::vector<int> iter;

  // other utilities

  // search length of shortest path from s
  void bfs(int s){
    std::queue<int> que;
    level = std::vector<int>(n, -1);

    level[s] = 0;
    que.push(s);

    while(!que.empty()){
      int v = que.front(); que.pop();
      for(int i = 0; i < (int)g[v].size(); i++){
        E &e = g[v][i];
        if(e.cap > 0 && level[e.to] < 0){
          level[e.to] = level[v] + 1;
          que.push(e.to);
        }
      }
    }
  }

  // search path
  ll dfs(int v, int t, ll f){
    if(v == t) return f;
    for(int &i = iter[v]; i < (int)g[v].size(); i++){
      E &e = g[v][i];
      if(e.cap > 0 && level[v] < level[e.to]){
        ll d = dfs(e.to, t, min(f, e.cap));
        if(d > 0){
          e.cap -= d;
          g[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

public:
  Dinic(Graph<E> &graph) : g(graph.getRowGraph()){
    n = g.size();
  }

  // Max flow of the flow from s to t.
  ll solve(int s, int t){
    ll flow = 0;
    while(true){
      ll f;
      bfs(s);
      if(level[t] < 0) return flow;
      iter  = std::vector<int>(n, 0);
      while((f = dfs(s, t, (1ll << 60))) > 0){
        flow += f;
      }
    }
  }
};

template<class E>
ll dinic(Graph<E> &g, int s, int d){
  return Dinic<E>(g).solve(s, d);
}

template<class T>
class IdMaker{
public:
  std::map<T,int> _m;
  int getId(const T &v){
    if(_m.find(v) == _m.end()){
      int next = _m.size();
      return _m[v] = next;
    }
    return _m[v];
  }
};

int main(){
  while(true){
    int n;
    ll w;
    ll all = 0;
    IdMaker<string> idm;

    cin >> n >> w;

    if(n + w == 0) break;

    Graph<Edge> g(n + 7 + 2);

    const int start = n + 7;
    const int end   = n + 7 + 1;

    REP(i, 7) g.addEdge(n + i, end, w);

    REP(i, n){
      long long t;
      int c;
      cin >> t >> c;
      all += t;
      g.addEdge(start, i, t);

      REP(j, c){
        string buff; cin >> buff;
        int m = idm.getId(buff);

        g.addEdge(i, n + m, w);
      }
    }

    all -= dinic(g, start, end);
    puts(all == 0 ? "Yes" : "No");
  }
  return 0;
}

Measured memory_bytes: 940
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n;
  cin >> n;
  ll a[n];
  ll s=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    s=s^a[i];
  }
  for(int i=0;i<n;i++){
    ll l=s^a[i];
    cout << l << endl;
  }

}

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

int n,k;
const int MAXN=100000+100;
const int mod=1000000007;
int a[MAXN];
long long dp[110][MAXN];
long long qzh[MAXN];

int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(register int i=1;i<=n;i++) cin>>a[i],dp[i][0]=1;
	dp[0][0]=1;
	for(register int i=1;i<=n;i++)
	{
		for(register int j=1;j<=k+1;j++)
		{
			qzh[j]=qzh[j-1]+dp[i-1][j-1];
			qzh[j]%=mod;
		}
		for(register int j=1;j<=k;j++)
		{
			if(j>=a[i]) dp[i][j]=qzh[j+1]-qzh[j-a[i]]+mod;
			else dp[i][j]=qzh[j+1]-qzh[0]+mod;
			dp[i][j]%=mod;
		}
	}
	
	/*
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=k;j++)
		{
			cout<<dp[i][j]<<' ';
		}
		cout<<endl;
		if(i==1) system("pause");
	}
	cout<<endl;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=k;j++)
		{
			cout<<qzh[i][j]<<' ';
		}
		cout<<endl;
		if(i==1) system("pause");
	}
	*/
	
	cout<<dp[n][k];
	return 0;
}

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

int main(){
    char p[100],s[100],t[100]={0};
    int i,k,result=0,ls,lp;
    scanf("%s", p);
    scanf("%s", s);
    lp=strlen(p);
    ls=strlen(s);
    for(i=0;i<lp;i++){
        for(k=0;k<ls;k++){
            t[k]=p[(i+k)%lp];
        }
        if(strcmp(s,t)==0){
            result=1;
            break;
        }
    }
    if(result)printf("Yes\n");
    else printf("No\n");
    
    return 0;
}

Measured memory_bytes: 1760
#include<iostream> 
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main()
{
	int x;
	rep(i, 5) {
		cin >> x;
		if (x == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	return 0;
}//どうして・・・(´･_･`)


Measured memory_bytes: 3600
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner scan = new Scanner(System.in)) {

			int n = scan.nextInt();
			int m = scan.nextInt();
			int L = scan.nextInt();

			int[][] distanceMap = new int[n][n];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					distanceMap[i][j] = i == j ? 0 : 1001001001;
				}
			}
			for (int i = 0; i < m; i++) {
				int from = scan.nextInt() - 1;
				int to = scan.nextInt() - 1;
				int len = scan.nextInt();
				distanceMap[from][to] = distanceMap[to][from] = len;
			}

			for (int k = 0; k < n; k++) {
				for (int i = 0; i < n; i++) {
					for (int j = 0; j < n; j++) {
						distanceMap[i][j] = Math.min(distanceMap[i][j], distanceMap[i][k] + distanceMap[k][j]);
					}
				}
			}

			int[][] supplyMap = new int[n][n];

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					supplyMap[i][j] = 1001001001;
					if(distanceMap[i][j] <= L)
					supplyMap[i][j] = 1;
				}
			}

			for (int k = 0; k < n; k++) {
				for (int i = 0; i < n; i++) {
					for (int j = 0; j < n; j++) {
						supplyMap[i][j] = Math.min(supplyMap[i][j], supplyMap[i][k] + supplyMap[k][j]);
					}
				}
			}

			int Q = scan.nextInt();

			int[] start = new int[Q];
			int[] end = new int[Q];

			for (int i = 0; i < Q; i++) {
				int s = scan.nextInt() - 1;
				int e = scan.nextInt() - 1;
				start[i] = s;
				end[i] = e;
			}

			for (int i = 0; i < Q; i++) {
				int ans = supplyMap[start[i]][end[i]] == 1001001001? -1: supplyMap[start[i]][end[i]]-1;
				System.out.println(ans);
			}

		}
	}
}

Measured memory_bytes: 90932
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n, m;
    cin >> n >> m;
    vint x(m);
    rep(i, m) cin >> x[i];
    sort(all(x));
    vint dist(m-1);
    rep(i, m-1) dist[i] = x[i+1] - x[i]; 
    sort(all(dist));
    int ans = 0;
    rep(i, m-n) ans += dist[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
#define inRange(x,a,b) (a <= x && x <= b)

int di[8] = {0,0,1,-1,1,1,-1,-1};
int dj[8] = {1,-1,0,0,1,-1,1,-1};

int main(){
    auto f = [](char c)->int{
        if(inRange(c, 'A', 'M'))    return 0;
        if(inRange(c, 'N', 'Z'))    return 1;
        if(inRange(c, 'a', 'm'))    return 2;
        if(inRange(c, 'n', 'z'))    return 3;
    };
    int n;
    cin >> n;
    string s;
    cin >> s;
    int i = 0, j = 0;
    for(char c : s){
        i += di[f(c)], j += dj[f(c)];
    }
    string ret = "";
    while(i > 0)    ret += "a", i--;
    while(i < 0)    ret += "n", i++;
    while(j > 0)    ret += "A", j--;
    while(j < 0)    ret += "N", j++;
    cout << ret.length() << endl;
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 3340
import java.util.Scanner;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        int E = sc.nextInt();
        int F = sc.nextInt();

        System.out.println(solve(A, B, C, D, E, F));

        sc.close();
    }

    static String solve(int A, int B, int C, int D, int E, int F) {
        int sugarWater = 100 * A;
        int sugar = 0;
        for (int o1 = 0; 100 * A * o1 <= F; ++o1) {
            for (int o2 = 0; 100 * A * o1 + 100 * B * o2 <= F; ++o2) {
                for (int o3 = 0; 100 * A * o1 + 100 * B * o2 + C * o3 <= F && C * o3 <= (A * o1 + B * o2) * E; ++o3) {
                    for (int o4 = 0; 100 * A * o1 + 100 * B * o2 + C * o3 + D * o4 <= F
                            && C * o3 + D * o4 <= (A * o1 + B * o2) * E; ++o4) {
                        int sw = 100 * A * o1 + 100 * B * o2 + C * o3 + D * o4;
                        int s = C * o3 + D * o4;

                        if (s * sugarWater > sugar * sw) {
                            sugarWater = sw;
                            sugar = s;
                        }
                    }
                }
            }
        }

        return String.format("%d %d", sugarWater, sugar);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    ll n,k;
    cin >> n >> k;
    ll a[n];
    rep(i,n)cin >> a[i];
    for(int i = k;i < n;i++){
        if(a[i] > a[i-k])cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 5196
h, w = (int(_) for _ in input().split())
l = [str(input()) for i in range(h)]

for si in l[:]:
    if si.count('.') == len(si):
        l.remove(si)
h = len(l)

rl = []
for i in range(w):
    tl = []
    for js in l:
        tl.append(js[i])
    rl.append(''.join(tl))

for si in rl[:]:
    if si.count('.') == len(si):
        rl.remove(si)
w = len(rl[0])

al = []
for i in range(w):
    tl = []
    for js in rl:
        tl.append(js[i])
    al.append(''.join(tl))

for si in al:
    print(si)

Measured memory_bytes: 3064
n = int(input())
S = input()

R = S.count('R')
G = S.count('G')
B = S.count('B')

ans = R * G * B

for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:
            break
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            ans -= 1

print(ans)

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,b,c;
  cin>>n;
  int a[n+1];
  long long ans=0;
  for(int i=0;i<n+1;i++)cin>>a[i];
  for(int i=0;i<n;i++){
    cin>>b;
    c=a[i+1]+a[i];
    ans+=min(c,b);
    a[i+1]=clamp(c-b,0,a[i+1]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3984
#include <iostream>
#include <string>
#include <vector>
typedef unsigned int UINT;
using namespace std;


//からいくつかの文字を消してCFという文字列にすることが出来るならYesを、そうでないならNoを出力せよ。

bool cheack(string &str)
{
    size_t pos = str.find('C');
    if (pos == string::npos)
        return false;
    pos = str.find('F', pos);
    if (pos == string::npos)
        return false;
    return true;
}

int main(void) {
    string S;
    cin >> S;

    if (cheack(S))
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;

int main() {
    char a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    Yes(c==d && e==f);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
#include <set>
using namespace std;

using ll = long long;

#define rep_init(i, init, n) for(int i = (init); i < (n); ++i)
#define rep(i, n) rep_init(i, 0, n)

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

	bool isEnable = false;
	int ansA, ansB, ansC;
	ansA = -1;
	ansB = -1;
	ansC = -1;
	rep(A, N+1)
	{
		rep(B, N-A+1)
		{
			if (9000 * A + 4000 * B >= Y - 1000 * N)
			{
				if (9000 * A + 4000 * B == Y - 1000 * N)
				{
					ansA = A;
					ansB = B;
					ansC = N - A - B;
					isEnable = true;
				}
				break;
			}
		}

		if (isEnable)
		{
			break;
		}
	}

	cout << ansA << " " << ansB << " " << ansC << endl;
	
	return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int N;
    int rate = 380000;
    double x[16], Y;
    string u[16];

    cin >> N;
    Y = 0;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> u[i];
        if (u[i] == "JPY") 
            Y += x[i];
        else
            Y += x[i] * rate;
    }

    cout << Y << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool is_proper(unsigned int in);
int main() {
  unsigned int a, b;
  cin >> a >> b;
  while(!is_proper(a) || !is_proper(b)){
    cin >> a >> b;
  }
  cout << (a+b+1)/2<< endl;
}

bool is_proper(unsigned int in){
  if (in>=1&&in<=100){
    return true;
  }
  return false;
}


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

using namespace std;

#define il inline
#define re register
#define Rep(i, s, e) for (re int i = s; i <= e; ++i)
#define Dep(i, s, e) for (re int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)

il int read() {
    int x = 0; bool f = true; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = false; c = getchar();}
    while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return f ? x : -x;
}

int n;
char s[10010];
il bool check(int l, int r) {
	Rep(i, 0, r - l) {
		if (s[l + i] != s[r - i]) return false;
	}
	return true;
}

int main() {
    gets(s + 1), n = strlen(s + 1);
    puts((check(1, n) && check(1, (n - 1) >> 1) && check((n + 3) >> 1, n)) ? "Yes" : "No");
    return 0;
}

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

int main(){
	int count=0;
	int a,b,c,i;
	std::scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0) count++;
	}
	std::cout << "" << count << std::endl;
	
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	int res = n;
	for(int i = 0; i<=n; i++){
		int count = 0;
		int t=i;
		while(t){
			count += t%6;
			t /= 6;
		}
		t=n-i;
		while(t){
			count += t%9;
			t /= 9;
		}
		if(count < res) res = count;
	}
	cout << res;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>
#include <math.h>

using namespace std;

int main(void)
{
    int A, B, C;
    cin >> A >> B >> C;
    bool ok = false;

    for (int i = 1; i < B + 1; i++)
    {
        if (A * i % B == C)
        {
            ok = true;
        }
    }

    cout << (ok ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
#define pb push_back
#define mp make_pair
using pii = pair<int,int>;
const int N = 100005;
const int Inf = 1e17+7;
const int mod = 1e9+7;
#ifndef M_PI
#define M_PI 3.1415926535
#endif
#define F first
#define S second

void io()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
//		cout << setprecision(10) << fixed;
}

int n;
int cnt[N];

int pw(int x, int p)
{
	if (p == 0)
		return 1;
	int t = 1;
	if (p & 1)
		t *= x;
	p >>= 1;
	int s = pw(x, p);
	return (s * s) % mod * t % mod;
}

signed main()
{
	io();
	int n, k, ans;
	cin >> n >> k;
	ans = k;
	cnt[k] = 1;
	for (int i = k - 1; i > 0; --i)
	{
		cnt[i] = pw(k / i, n);
		for (int j = i + i; j <= k; j += i)
		{
			cnt[i] -= cnt[j] - mod;
			cnt[i] %= mod;
		}
		ans += cnt[i] * i;
		ans %= mod;
	}
	cout << ans;
}

Measured memory_bytes: 4340
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

static int
enough(int *arr, int n, int k, int p) {
  int i, j, s;

  for (i = j = s = 0; i < n && j < k; ++i) {
    if ((s + arr[i]) <= p) {
      s += arr[i];
    } else {
      ++j;
      s = arr[i];
    }
  }

  return j < k;
}

int main(int argc, char **argv) {
  int n, k, p, i, ret, sum, avg, max;
  int *arr;

  ret = scanf("%d %d", &n, &k);
  if (errno != 0) perror("scanf: n, k");
  if (ret < 1) exit(1);

  arr = (int *) malloc(sizeof(int) * n);
  if (arr == NULL) exit(1);

  for (i = sum = max = 0; i < n; ++i) {
    ret = scanf("%d", &arr[i]);
    if (errno != 0) perror("scanf: arr[i]");
    if (ret < 1) break;
    sum += arr[i];
    if (arr[i] > max) max = arr[i];
  }

  avg = (sum / k) + ((sum % k) ? 1 : 0);
  for (p = max > avg ? max : avg; !enough(arr, n, k, p); ++p) {}
  printf("%d\n", p);

  free(arr);
  exit(0);
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(a,n) for (int a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<int,int> P;
typedef pair<P,int> PP;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;

//input
ll a,b,c,d;

int main(){
    cin >> a >> b >> c >> d;
    ll x = abs(c-a);
    ll y = abs(d-b);
    ll g = __gcd(x,y);
    x /= g;
    y /= g;
    cout << g*(x+y-1) << endl;

    return 0;
}


Measured memory_bytes: 3652
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


int main(){
    string S; cin >> S;
    REP(i, S.length())
        cout << "x";
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 1000

void isTriangle(int a,int b,int c){
	if(a*a == b*b + c*c){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
}

int main(void){
	int n;
	int i;
	int x,y,z;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		scanf("%d%d%d", &x, &y, &z);
		
		if(x > y && x > z){
			isTriangle(x,y,z);
		}else if(y > x && y > z){
			isTriangle(y,x,z);
		}else{
			isTriangle(z,y,x);	
		}
	}
	return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T & ref, const T  value) {
	if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
	if (ref < value) ref = value;
}

int main() {
	ll n;
	cin >> n;
	string s;
	cin >> s;
	int red = 0;
	rep(i, n) {
		if (s[i] == 'R') red++;
	}
	ll sum = 0;
	for (int i = 0; i < red; i++) {
		if (s[i] != 'R') {
			sum++;
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3744
def get_circle_equation(x, y)
  [x, y, 1, x ** 2 + y ** 2]
end

def get_invers_matrix m
  det = m[0][0] * m[1][1] * m[2][2] + m[0][1] * m[1][2] * m[2][0] + m[1][0] * m[2][1] * m[0][2]
  det -= m[0][2] * m[1][1] * m[2][0] + m[0][1] * m[1][0] * m[2][2] + m[1][2] * m[2][1] * m[0][0]

  v1 = [m[1][1] * m[2][2] - m[1][2] * m[2][1], m[0][2] * m[2][1] - m[0][1] * m[2][2], m[0][1] * m[1][2] - m[0][2] * m[1][1]]
  v2 = [m[1][2] * m[2][0] - m[1][0] * m[2][2], m[0][0] * m[2][2] - m[0][2] * m[2][0], m[0][2] * m[1][0] - m[0][0] * m[1][2]]
  v3 = [m[1][0] * m[2][1] - m[1][1] * m[2][0], m[0][1] * m[2][0] - m[0][0] * m[2][1], m[0][0] * m[1][1] - m[0][1] * m[1][0]]

  v1 = v1.map{|i| i / det}
  v2 = v2.map{|i| i / det}
  v3 = v3.map{|i| i / det}
  [v1, v2, v3]
end

def mluti(m1, m2)
  v1 = m1[0][0] * m2[0] + m1[0][1] * m2[1] + m1[0][2] * m2[2]
  v2 = m1[1][0] * m2[0] + m1[1][1] * m2[1] + m1[1][2] * m2[2]
  v3 = m1[2][0] * m2[0] + m1[2][1] * m2[1] + m1[2][2] * m2[2]
  [v1, v2, v3]
end
n = gets.to_i

n.times do
  x1, y1, x2, y2, x3, y3 = gets.split.map(&:to_f)
  e1 = get_circle_equation(x1, y1)
  e2 = get_circle_equation(x2, y2)
  e3 = get_circle_equation(x3, y3)

  matrix = [e1[0..2], e2[0..2], e3[0..2]]
  invers_matrix = get_invers_matrix(matrix)
  vec = mluti(invers_matrix, [e1[3], e2[3], e3[3]])
  center = [vec[0] / 2, vec[1] / 2]
  r = Math.sqrt((x1 - center[0]) ** 2 + (y1 - center[1]) ** 2)

  puts sprintf("%.3f %.3f %.3f", center[0].round(3), center[1].round(3), r.round(3))

end

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

using namespace std;

int DP[101][101][101]; // DP[i][j][k] : (???, ???)???????????¨?????????*??????????????¢??????

int main(){
	
	int n, ans;
	
	cin >> n;
	
	int dummy;
	
	for(int i = 0; i < 101; i++){
		for(int j = 0; j < 101; j++){
			for(int k = 0; k < 101; k++){
				DP[i][j][k] = -(1 << 30);
			}
		}
	}
	
	ans = -(1 << 30);
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cin >> dummy;
			DP[i][j][1] = dummy;
			if(DP[i][j][1] > ans){
				ans = DP[i][j][1];
			}
		}
	}
	
	for(int y = 2; y <= n; y++){
		for(int i = 0; i < n; i++){
			for(int j = 0; j <= n - y; j++){
				DP[i][j][y] = DP[i][j][y - 1] + DP[i][j + y - 1][1];
				if(DP[i][j][y] > ans){
					ans = DP[i][j][y];
				}
			}
		}
	}
	
	int sum;
	
	for(int x = 2; x <= n; x++){
		for(int y = 1; y <= n; y++){
			for(int j = 0; j <= n - y; j++){
				for(int i = 0; i <= n - x; i++){
					sum = 0;
					for(int k = 0; k < x; k++){
						sum += DP[i + k][j][y];
					}
					if(sum > ans){
						ans = sum;
					}
				}
			}
		}
	}
	
	printf("%d\n", ans);
	return 0;
}

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

int main() {
long n,k;
cin>>n>>k;
long a[n],f[n];
for(int i=0;i<n;i++) cin>>a[i];
for(int i=0;i<n;i++) cin>>f[i];
sort(a,a+n);
sort(f,f+n);
reverse(f,f+n);
long low =-1, high=8e18;
long mid;
while(high-low>1){
  mid = (low+high)/2;
  long train=0;
  for(int i=0;i<n;i++){
    if(a[i]*f[i]>mid){
        train += a[i]-mid/f[i];
    }
  }
  if(train>k) low=mid;
  else high=mid;
}
cout<<high<<endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define len length()
#define ld long double
int main()
{
    int n;
    cin>>n;
    int arr[n+1][3];
    forl(i,1,n+1) forl(j,0,3) cin>>arr[i][j];
    int dp[n+1][3];
    forl(i,0,n+1)forl(j,0,3) dp[i][j]=0;
    forl(i,1,n+1)
    {
        forl(j,0,3)
        {
            forl(k,0,3)
            {
                if(j!=k)dp[i][j]=max(dp[i][j],dp[i-1][k]+arr[i][j]);
            }
        }
    }
    cout<< max({dp[n][0],dp[n][1],dp[n][2]})<<endl;;
    
}

Measured memory_bytes: 2560
import sys
from itertools import groupby


def input():
    return sys.stdin.readline()[:-1]


def solve():
    S = input()
    N = len(S)
    ans = [0] * N

    cnt = 0
    for i, c in enumerate(S):
        if c == "R":
            cnt += 1
        else:
            even_num = cnt // 2
            odd_num = cnt - even_num
            ans[i] += even_num
            ans[i - 1] += odd_num
            cnt = 0
    cnt = 0
    for i in range(N - 1, -1, -1):
        if S[i] == "L":
            cnt += 1
        else:
            even_num = cnt // 2
            odd_num = cnt - even_num
            ans[i] += even_num
            ans[i + 1] += odd_num
            cnt = 0

    print(*ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 6400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace C
{
    public class Program

    {
        public static int targetA;
        public static int targetB;
        public static int targetC;
        public static int n;
        public static List<int> bamboos;
        public static bool[] used;
        public static int minCost;
        public static int candidate;

        public static void Main(string[] args)
        {
            int[] items = RIntAr();
            n = items[0];
            targetA = items[1];
            targetB = items[2];
            targetC = items[3];

            bamboos = new List<int>(8);
            for (int i = 0 ; i < n ; i++) bamboos.Add(RInt());

            Console.WriteLine(GetSteps(0, 0, 0, 0));
        }

        private static int GetSteps(int k, int a, int b, int c)
        {
            if (k == bamboos.Count())
            {
                if (a > 0 && b > 0 && c > 0)
                    return Math.Abs(targetA - a) + Math.Abs(targetB - b) + Math.Abs(targetC - c) - 10 * 3;
                else
                    return int.MaxValue - 10000;
            }

            int ret1 = GetSteps(k + 1, a, b, c);
            int ret2 = GetSteps(k + 1, a + bamboos[k], b, c) + 10;
            int ret3 = GetSteps(k + 1, a, b + bamboos[k], c) + 10;
            int ret4 = GetSteps(k + 1, a, b, c + bamboos[k]) + 10;

            return (new int[] { ret1, ret2, ret3, ret4 }).Min();

        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" a : "<<a<<"\n"
#define debug2(a,b) cout<<" a : "<<a<<" b : "<<b<<"\n"
#define debug3(a,b,c) cout<<" a : "<<a<<" b : "<<b<<" c : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" a : "<<a<<" b : "<<b<<" c : "<<c<<" d : "<<d<<"\n"
// #define M 421412341324321
#define MOD 998244353 

vector <vector <int>> adj;
map  <int, int> m;
int ans[(int)2e5+1];
void dfs(int node, int par) 
{
	ans[node]+=m[node];
	if (node!=par) m[node]+=m[par];
    for (auto it : adj[node]) 
    { 
        if (it != par) { 
            dfs(it, node);
            ans[it]+=m[node];
        } 
    } 
}

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n,M;
	cin>>n>>M;
	adj.resize(n+1);

	rep(i,n-1)
	{
		int x,y;
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	rep(i,M)
	{
		int x,y;
		cin>>x>>y;
		m[x]+=y;
	}
	memset(ans, 0, sizeof(ans));
	dfs(1,1);
	REP(i,1,n) cout<<ans[i]<<" ";


	return 0;
}



Measured memory_bytes: 46208
// B.

#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[])
{
	long long a = 2, b = 1, n;
	cin >> n;
	for (long long i = 1; i < n; ++i) {
		long long c = a + b;
		a = b, b = c;
	}
	cout << b << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, K;
  cin >> N >> K;
  pair<int,int> ab[N];
  for (int i = 0; i < N; i++) {
    cin >> ab[i].first >> ab[i].second;
  }
  sort(ab,ab+N);
  for (long long i = 0, sum = 0; i < N; sum += ab[i++].second) {
    if (sum <= K && K <= sum+ab[i].second) {
      cout << ab[i].first;
      return 0;
    }
  }
}

Measured memory_bytes: 4380