akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
 
int main()
{
	const int MAX = 100;
	int n[MAX], x[MAX];
	int q, max, i=0;
	
	do {
		cin >> n[i] >> x[i];
		i++;
	} while((n[i -1]!=0)||(x[i-1]!=0)||(i==MAX));
	
	max = i - 1;
	
	for (int i = 0; i < max ; i++) {
		q = 0;
		for (int j = 1; j <= n[i]; j++)
			for (int k = j + 1; k <= n[i]; k++)
				for (int m = k + 1; m <= n[i]; m++)
					if (j + k + m == x[i])
						q++;
		cout << q << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<int, ll> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
const ll MAXN = 100005;

int n;
int cnt[MAXN];
/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();

    cin >> n;
    REP (i, n) {
        int d;
        cin >> d;
        cnt[d]++;
    }

    int two = 0;
    REP (i, MAXN) {
        while (cnt[i] >= 3) {
            cnt[i] -= 2;
            n -= 2;
        }
        two += cnt[i] == 2;
    }

    cout << n - two - (two&1) << endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main()
{
	int i,N, T, c[100], t[100],min;

	scanf("%d%d", &N, &T);

	for (i = 0; i < N; i++)
		scanf("%d%d", &c[i], &t[i]);

	min = 1001;

	for (i = 0; i < N; i++)
	{
		if (t[i] <= T)
		{
			if (min>c[i])
				min = c[i];
		}
	}

	if (min != 1001)
		printf("%d\n", min);
	else
		printf("TLE\n");

	return 0;
}

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

int main(){
    int K;
    cin >> K;
    set<ll> st;
    for (ll i = 0; i < 1000; i++) {
        ll t = i;
        int dsum = 0;
        while (t > 0) {
            dsum += t%10;
            t /= 10;
        }
        t = i;
        while (dsum <= i) {
            if (t < 10) break;
            t = t*10+9;
            dsum += 9;
            if (t > 1e15) break;
        }
        while (t < 1e15) {
            st.insert(t);
            t = t*10+9;
            dsum += 9;
        }
    }
    auto it = st.begin();
    if ((*it) == 0) it++;
    for (int i = 0; i < K; i++) {
        cout << (*it) << endl;
        it++;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  ll n;cin>>n;
  lb x[n],y[n];rep(i,0,n)cin>>x[i]>>y[i];

  ll per[n];
  rep(i,0,n)per[i]=i;

  lb avg=0;
  ll count=0;
  do{
    count++;
    lb sum=0;
    rep(i,0,n-1){
      sum+=sqrt((x[per[i+1]]-x[per[i]])*(x[per[i+1]]-x[per[i]])+(y[per[i+1]]-y[per[i]])*(y[per[i+1]]-y[per[i]]));
    }
    avg+=sum;

  }while(next_permutation(per,per+n));

  out(fixed<<setprecision(10)<<avg/count);




  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
	public static void main(String[] args)throws IOException {
		FastReader sc = new FastReader();
		PrintWriter pw = new PrintWriter(System.out);
		int k = sc.nextInt();
		String s = sc.next();
		if (s.length() <= k)
			System.out.println(s);
		else {
			System.out.println(s.substring(0, k) + "...");
		}

	}
}





class FastReader {
	BufferedReader br;
	StringTokenizer st;

	public FastReader() {
		br = new BufferedReader(new
		                        InputStreamReader(System.in));
	}

	String next() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException  e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

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

	String nextLine() {
		String str = "";
		try {
			str = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return str;
	}
}

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

using namespace std;

int n, ans;

map<int, int> mp;

vector <int> a, v;

int main() {
    cin >> n;
    a.resize(n + 5);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        mp[a[i]]++;
        if (mp[a[i]] == 1) {
            v.push_back(a[i]);
        }
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < v.size(); ++i) {
        ans = max(ans, mp[v[i]] + mp[v[i] - 1] + mp[v[i] + 1]);
    }
    cout << ans;
}


Measured memory_bytes: 5372
N = int(input())
list = [int(x) for x in input().split()] 
print(*list)

for i in range(1, N):
    v = list[i]
    j = i - 1
    while j >= 0 and list[j] > v:
        list[j+1] = list[j]
        j = j - 1
    list[j+1] = v
    print(*list)



Measured memory_bytes: 5976
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N;
ll A[100010];
vector<int> pv;
vector<int> nv;

map<int, int> md;

/*==================================================*/
/*function*/

/*==================================================*/

int main(){
    cin>>N;
    ll sum = 0;
    REP(i,0,N){
        cin>>A[i];
        if(i == 0) sum += abs(A[i] - 0);
        if(i > 0 && i < N-1) sum += abs(A[i] - A[i-1]);
        if(i == N-1) sum += abs(A[i] - A[i-1]) + abs(A[i] - 0);
    }


    REP(i,0,N){
        ll ans;
        if(i == 0){
            ans = sum - abs(A[i] - 0) - abs(A[i] - A[i+1]) + abs(0 - A[i+1]);
        }
        if(i > 0 && i < N-1){
            ans = sum - abs(A[i] - A[i-1]) - abs(A[i] - A[i+1]) + abs(A[i-1] - A[i+1]);
        }
        if(i == N-1){
            ans = sum - abs(A[i] - A[i-1]) - abs(A[i] - 0) + abs(A[i-1] - 0);
        }

        cout<<ans<<endl;
    }
}



Measured memory_bytes: 2048
#include <iostream>

struct Vec2D{
				double x,y;
};

Vec2D vector(double x1,double y1,double x2,double y2){
				Vec2D vec;
				vec.x = x2 -x1;
				vec.y = y2 -y1;
				return vec;
}

double outerProduct(Vec2D a,Vec2D b){
				double crossProduct = a.x * b.y - a.y * b.x;
				return crossProduct;
}

int main(int argc, char *argv[])
{
	double x1,x2,x3,y1,y2,y3,x,y;

	while(std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x >> y){

		Vec2D BA = vector(x2,y2,x1,y1);
		Vec2D CB = vector(x3,y3,x2,y2);
		Vec2D AC = vector(x1,y1,x3,y3);


		Vec2D BP = vector(x2,y2,x,y);
		Vec2D CP = vector(x3,y3,x,y);
		Vec2D AP = vector(x1,y1,x,y);

		double a,b,c;

		a = outerProduct(BA,BP);
		b = outerProduct(CB,CP);
		c = outerProduct(AC,AP);



		if((a<0 && b<0 && c<0) || (a>0 && b>0 && c>0)){
					std::cout << "YES" << std::endl;
		}else{
					std::cout << "NO" << std::endl;
		}

	}
	return 0;
}

Measured memory_bytes: 1216
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            while (true)
            {
                string input = Console.ReadLine();
                if (input == "0")
                    break;
                char[] array = input.ToCharArray();
                int answer = 0;

                for (int i = 0; i < array.Length; i++)
                {
                    answer = answer + int.Parse(array[i].ToString());
                }

                Console.WriteLine(answer);
            }
          
        }
    }
}

Measured memory_bytes: 9188
import sys

input = sys.stdin.readline


def read_i():
    return list(map(int, input().split()))


class Graph:
    def __init__(self, n_nodes):
        self.n_nodes = n_nodes
        self.edges = [[float('inf')] * n_nodes for _ in range(n_nodes)]

    def add_edge(self, s, t, d):
        self.edges[s][t] = d
        self.edges[t][s] = d


class FloydWarshall:
    def __init__(self, graph):
        self.graph = graph
        self.distances = [[float('inf')] * graph.n_nodes
                          for _ in range(graph.n_nodes)]
        self._init()

    def _init(self):
        for x in range(self.graph.n_nodes):
            self.distances[x][x] = 0
        for source in range(self.graph.n_nodes):
            for destination, distance in enumerate(self.graph.edges[source]):
                self.distances[source][destination] = distance

    def compute_shortest_path_lengths(self):
        for k in range(self.graph.n_nodes):
            for i in range(self.graph.n_nodes):
                for j in range(self.graph.n_nodes):
                    s = self.distances[i][k] + self.distances[k][j]
                    if s < self.distances[i][j]:
                        self.distances[i][j] = s
        return self.distances


n, m, l = read_i()
graph = Graph(n)
for _ in range(m):
    a, b, c = read_i()
    if c > l:
        continue
    graph.add_edge(a - 1, b - 1, c)
fw = FloydWarshall(graph)
ds = fw.compute_shortest_path_lengths()

graph = Graph(n)
for s in range(n):
    for t in range(s + 1, n):
        if ds[s][t] > l:
            continue
        graph.add_edge(s, t, 1)
fw = FloydWarshall(graph)
ds = fw.compute_shortest_path_lengths()

q = int(input())
for _ in range(q):
    s, t = read_i()
    d = ds[s - 1][t - 1] - 1
    if d == float('inf'):
        print(-1)
    else:
        print(d)

Measured memory_bytes: 84444
X = int(input())

N = 10**9
ab=[]
a = 0
b = 0
while len(ab) < 2:
  a += 1
  b = 0
  for i in range(a):
    #print(a,b)
    if X % (a-b)==0:
      #print(a, b)
      c = a ** 5 - b ** 5
      if c == X :
        ab.append(a)
        ab.append(b)
      if X*(-1) == c:
        ab.append(a)
        ab.append(b)
    b = -b
    if X % (a-b)==0:
      c = a ** 5 - b ** 5
      if c == X :
        ab.append(a)
        ab.append(b)
      if X*(-1) == c:
        ab.append(a)
        ab.append(b)
    b = -b + 1


print(ab[0],ab[1])

Measured memory_bytes: 9244
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;
int p = 1e9 + 7;

int32_t main()
{	
	IOS;
	int n;
	cin >> n;
	int stb = 0, ena = 0, stb_ena = 0;
	int ans = 0;
	for(int i = 0; i < n; i++)
	{
		string s;
		cin>>s;
		int m = s.length();
		if(s[0] == 'B' && s[m-1] == 'A')
			stb_ena++;
		else if(s[0] == 'B')
			stb++;
		else if(s[m-1] == 'A')
			ena++;
		for(int j = 0; j < m-1; j++)
			if(s[j] == 'A' && s[j+1] == 'B')
				ans++;
	}
	if(!stb_ena)
		ans += min(stb, ena);
	else
	{
		if(!stb && !ena)
			ans += stb_ena - 1;
		else
			ans += stb_ena + min(stb, ena);
	}
	cout << ans;
	return 0;
} 


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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

int main() {

  int N, X, T;
  cin >> N >> X >> T;

  int time = N/X;
  if(N%X!=0)time++;

  cout << time * T << endl;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // System.out.println(147 105);
        // System.out.println(105 % 42);
        // System.out.println(42 % 21);

        Scanner sc = new Scanner(System.in);
        String[] a = sc.nextLine().split(" ");
        
        int x = Integer.parseInt(a[0]);
        int y = Integer.parseInt(a[1]);

        while (true) {
            if (x % y == 0) {
                System.out.println(y);
                break;
            }
            int tmp = x;
            x = y;
            y = tmp % y;
        }
    }
}


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

using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int n;
	cin>>n;
	long long int t=n;
	long long int sum=0;
	while(n){
		sum+=(n%10);
		n/=10;
	}
	if(t%sum==0){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int vacation(int a[], int b[], int c[], int n)
{
    if(n==1)
        return max(a[0],max(b[0],c[0]));
    int as[n-1],bs[n-1],cs[n-1];
    as[0]=a[1]+max(b[0],c[0]);
    bs[0]=b[1]+max(a[0],c[0]);
    cs[0]=c[1]+max(a[0],b[0]);
    for(int i=1;i<n-1;i++)
    {
        as[i]=a[i+1]+max(bs[i-1],cs[i-1]);
        bs[i]=b[i+1]+max(as[i-1],cs[i-1]);
        cs[i]=c[i+1]+max(as[i-1],bs[i-1]);
    }
    return max(as[n-2],max(bs[n-2],cs[n-2]));
}
int main()
{
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i]>>c[i];
    cout<<vacation(a,b,c,n);
}


Measured memory_bytes: 2560
#include"bits/stdc++.h"
#include"vector"
using namespace std;
int n,m;
int a[100005],b[100005],c[100005];
int dist[100005];
int color[100005];
vector<int> v[100005];
void dfs(int u,int dis,int co)
{
	if(dis<=dist[u]||dis<0)
	{
		return ;
	}
	dist[u]=dis;
	if(color[u]==0) color[u]=co;
	for(int i=0;i<v[u].size();i++)
	{
		dfs(v[u][i],dis-1,co);
	}
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int x,y;
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	int q;
	cin>>q;
	for(int i=1;i<=q;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	for(int i=q;i>=1;i--)
	{
		dfs(a[i],b[i]+1,c[i]);
	}
	for(int i=1;i<=n;i++)
	{
		cout<<color[i]<<endl;
	}
}

Measured memory_bytes: 9728
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

int n;
long long cnt;
int A[1000000];
int l;
vector<int> G;

void insertionSort(int A[], int n, int g){
  int v, j;
  for (int i=g; i<n; i++){
    v = A[i];
    j = i - g;
    while(j >= 0 && v < A[j]){
      A[j+g] = A[j];
      j = j - g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shellSort(int A[], int n){
  for (int h=1; ;){
    if (h > n) break;
    G.push_back(h);
    h = 3*h + 1;
  }

  for (int i=G.size()-1; i>=0; i--){
    insertionSort(A, n, G[i]);
  }
}

int main(){
  scanf("%d", &n);
  for (int i=0; i<n; i++){
    scanf("%d", &A[i]);
  }
  cnt = 0;

  shellSort(A, n);

  printf("%d\n", G.size());

  for (int i=G.size()-1; i>=0; i--){
    printf("%d", G[i]);
    if(i) printf(" ");
  }
  printf("\n");
  printf("%d\n", cnt);
  for (int i=0; i<n; i++){
    printf("%d\n", A[i]);
  }

  return 0;
}



Measured memory_bytes: 7164
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = stoi(s), m = 0;
    for (char c : s) m += c - '0';
    if (n % m == 0) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
import math
N = int(input())
ans = []
if N == 0:
  ans.append('0')
else:
  i = 0
  while abs(N) > 0:
    t = N % 2
    ans.append(str(t))
    N = N - t
    N = N // -2
    i += 1
  ans.reverse()
print("".join(ans))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		// input process
		Scanner scanner = new Scanner(System.in);
		int n = Integer.parseInt(scanner.nextLine());
		String s = scanner.nextLine();

		// initialization
		int redCount = 0;
		int blueCount = 0;

		// count process
		for(int i=0; i<s.length();i++) {
			char c = s.charAt(i);
			if(c == 'R') {
				redCount++;
			}else {
				blueCount++;
			}
		}

		// output process
		if(redCount>blueCount) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 21588
#include <iostream>
#include <cstdio>
#define int long long
using namespace std;
int F[1005][10005],i,j,k,n,sum[10005],A[10005];
signed main()
{
    //freopen("SLIMES.inp","r",stdin);
    cin >> n;
    for (i = 1; i <= n; i++)
    {
        cin >> A[i];
        sum[i]=A[i]+sum[i-1];
    }
    for (i = 1; i < n; i++)
    for (j = i+1; j <= n; j++)
    {
        F[i][j]=1e18;
    }
    for (int len=2; len <= n; len++)
    for (i = 1; i < n; i++)
    {
        j=i+len-1;
        if (j > n) break;
        for (k =i; k < j; k++)
        {
            F[i][j]=min(F[i][k] + F[k+1][j],F[i][j]);
        }
        F[i][j]+=sum[j]-sum[i-1];
    }
    cout << F[1][n];
    return 0;
}


Measured memory_bytes: 31104
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
import sys
import numpy as np
mod=10**9+7
def ncr_1(n,r,p):##　n>>r の場合のncr　O(r)
    x = 1
    y = 1
    for i in range(r):
        x*=(n-i)
        y*=(i+1)
        x%=p
        y%=p
    return x*modinv(y,p) %p
def modinv(a,p):
    b,u,v = p,1,0
    while b:
        t = a//b
        a -= t*b
        a,b = b,a
        u -=t*v
        u,v = v,u
    u %=p
    return u
n,m,k = ma()
ans=0
for i in range(1,n):
    ans+=i*(n-i)*m**2
    ans%=mod
for i in range(1,m):
    ans+=i*(m-i)*n**2
    ans%=mod
print((ans*ncr_1(n*m-2,k-2,mod))%mod)


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

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> P;

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

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n)  for(int i=0; i<(n); i++)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}
int main(){
   LL n, r, b, ans;
   cin >> n >> b >> r;
   LL cnt;
   cnt = n/(r+b);
   LL amr;
   amr=n%(r+b);
   if(b>=amr) ans=cnt*b+amr;
   else ans=cnt*b+b;
   cout << ans << endl;
}
    




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

typedef long long int llint;

int main()
{
  int n;
  int a[200001];

  cin>> n;
  for(int i = 0; i < n; i++) {
    cin>> a[i];
    a[i] -= i + 1;
  }

  sort(a, a + n);

  int b = (n % 2 ? a[n / 2] : (a[n / 2] + a[n / 2 - 1]) / 2);
  
  llint ans = 0;
  
  for(int i = 0; i < n; i++) {
    ans += abs(a[i] - b);
  }

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



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long double ll;
int main()
{
    ll n,d,x[200005],y[200005],count=0;
    cin>>n>>d;
    for(int i=0;i<n;i++)
    {
        cin>>x[i]>>y[i];
        if(sqrt(x[i]*x[i]+y[i]*y[i])<=d)
        {
            count++;
        }
    }
    cout<<count<<'\n';
    return 0;
}

Measured memory_bytes: 10056
/// Template by Zayed ///

///************************************************************///
/// #include <bits/stdc++.h>
#include <iostream>
#include <cstdio>

#include <string>
#include <cstring>
#include <sstream>

#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
//#include<unordered_map>
#include <set>
//#include<unordered_set>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
///************************************************************///
using namespace std;
int caseno = 1;
///************************************************************///
#define NL '\n'
#define SF scanf
#define PF printf
#define PC() printf("Case %d: ", caseno++)//NOTES:printf
//#define PC cout << "Case "//NOTES:cout
//#define CN cout << caseno++ << ": "//NOTES:cout
#define CLR(ar) memset(ar, 0, sizeof(ar))
#define SET(ar) memset(ar, -1, sizeof(ar))
#define READ() freopen("input.txt", "r", stdin)
#define WRITE() freopen("output.txt", "w", stdout)
#define BOOST std::ios_base::sync_with_stdio(0);
///************************************************************///
typedef long long LL;//NOTES:"%lld"
typedef unsigned long long ULL;//NOTES:"%llu"
///************************************************************///
#define INF (1 << 31) - 1
#define MOD 1000000007
#define PRIME 999998727899999 			// (largest prime below 10^16)
#define PB push_back
#define pii pair<int, int>
#define pic pair<int, char>
#define pci pair<char, int>
#define pLL pair<LL, LL>
#define pis pair<int, string>
#define psi pair<string, int>
#define pss pair<string, string>
#define PI 2 * acos(0.0)
#define EPS 1e-11
///************************************************************///
// Numeric Functions
template < class T > inline void SWAP(T &a, T &b) { T t = a; a = b; b = t; }
inline LL POW(LL base, LL power){
	LL res = base; if (power == 0) return 1;
	for (int I = 0; I < power - 1; I++) res *= base; return res;
}
// Translator Functions
int ToInt(string s) { int r = 0; istringstream sin(s); sin >> r; return r; }//NOTES:ToInt(
double ToDouble(string s) { double r = 0; istringstream sin(s); sin >> r; return r; }//NOTES:ToDouble(
string ToString(int n) { string s; stringstream convert; convert << n; s = convert.str(); return s; }//NOTES:ToString(
///************************************************************///

/*
*******4 Direction Array*******
int dx[] = {0, 0, - 1, 1}, dy[] = {-1, 1, 0, 0};
*******8 Direction Array*******
int dx[] = {0, 0, -1, +1, -1, -1, +1, +1}, dy[] = {-1, +1, 0, 0, -1, +1, -1, +1};
********Knight Moves********
int dx[] = {-2, -2, -1, -1, +1, +1, +2, +2}, dy[] = {-1, +1, -2, +2, -2, +2, -1, +1};
*/

const int SIZE = 1e6;



int main()
{
	BOOST
	///READ();
	///WRITE();
	int T, I, J, K, N, n, m, cnt = 0, len, x, a, b;

	cin >> x >> a >> b;

	if(abs(x - a) <= abs(x - b))
		cout << "A\n";
	else
		cout << "B\n";


	return 0;
}






Measured memory_bytes: 256
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]

inf = 10 ** 18


def dfs(i, a, b, c):
    if n == i:
        if 0 == a or 0 == b or 0 == c:
            return inf
        return abs(A - a) + abs(B - b) + abs(C - c)

    res = dfs(i + 1, a, b, c)
    res = min([res, dfs(i + 1, a + l[i], b, c) + (10 if a > 0 else 0)])
    res = min([res, dfs(i + 1, a, b + l[i], c) + (10 if b > 0 else 0)])
    res = min([res, dfs(i + 1, a, b, c + l[i]) + (10 if c > 0 else 0)])
    return res


print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
int n;
int dp[(1 << 21)];
int a[21][21];
int main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  cin >> n;
  for(int i = 0;i < n;i++)
    for(int j = 0;j < n;j++)
      cin >> a[i][j];
  dp[0] = 1;
  for(int i = 0;i < (1 << n);i++){
    for(int j = 0;j < n;j++){
      int in = __builtin_popcount(i);
      if(((1 << j) & i) || !a[in][j])continue;

      dp[i | (1 << j)] = (1LL * dp[i | (1 << j)] + dp[i]) % MOD;
    }
  }
  cout << dp[(1 << n) - 1];
  return 0;
}


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

using namespace std;

int main()
{
  int N, M, A, B, D[1000];

  cin >> N >> M >> A >> B;

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

  vector< int > latte;
  for(int i = 0; i < N; i++) {
    if(D[i] >= A) latte.push_back(D[i]);
    else break;
  }

  if(N - latte.size() < M) {
    for(int i = latte.size() - 1; i >= 0; i--) {
      if(latte[i] <= B) latte.pop_back();
      else break;
    }
  }

  cout << latte.size() << endl;
}

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

#define N 1000

int main(){
	
	int i;
	int count=0;
	int ans[N];
	int str_length;
	int cmp_length;
	char str[N];
	char cmp[N];
	
	scanf("%s %s",str,cmp);
	
	str_length = strlen(str);
	cmp_length = strlen(cmp);
	
	 for(i=0;i<str_length;i++){
	if( strncmp(str+i,cmp,cmp_length) ==0 ){
	ans[count] = i;
	count++;
	 }
	}
	
	for(i=0;i<count;i++){
	printf("%d\n",ans[i]);
	}
	
	return 0;
}

Measured memory_bytes: 564
import sys
h = int(input())
w = int(input())
n = int(input())

ans = 0
border = n

for i in range(1000):

    if h >= w:
        n -= h
        ans += 1
    else:
        n -= w
        ans += 1

    if n <= 0:
        print(ans)
        sys.exit()



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

int main(){

    string S;
    cin >> S;

    int ans = 0;
    for(int i = 0; i < S.length(); i++){
        if(S[i] == '+') ans++;
        else ans--;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Convert;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }


        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            for(int i = 1; i <= 9; i++)
            {
                for(int j = 1; j <= 9; j++)
                {
                    if(i * j == N)
                    {
                        WriteLine("Yes");
                        return;
                    }
                }
            }
            WriteLine("No");
        }


        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


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

struct edge{
    int from, to;
    bool operator < (const edge &e) const {
        if(from==e.from) return to < e.to;
        return from < e.from;
    }
};

const int MAX_N = (int)2e5 + 5;
int cnt = 1, par[MAX_N];
lint bit[MAX_N];
vector<int> G[MAX_N];
auto cmp = [](const edge &e1, const edge &e2){return e1.from<e2.from;};
map<edge, int> start, fin;

lint sum(int i){
    lint res = 0;
    while(i) {res += bit[i]; i -= i & -i;}
    return res;
}

void add(int i, lint x){
    while(i<MAX_N) {bit[i] += x; i += i & -i;}
}

void dfs(int s, int p){
    for(auto u : G[s]){
        if(u != p){
            par[u] = s;
            start[{s, u}] = cnt++;
            //cout<<s<<' '<<u<<' '<<start[{s, u}]<<endl;
            dfs(u, s);
            fin[{s, u}] = cnt++;
            //cout<<s<<' '<<u<<' '<<fin[{s, u}]<<endl;
        }
    }
}

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        int K;
        cin>>K;
        for(int j=0;j<K;j++){
            int c;
            cin>>c;
            G[i].push_back(c);
        }
    }
    dfs(0, -1);
    int Q;
    cin>>Q;
    for(int i=0;i<Q;i++){
        int t;
        cin>>t;
        if(t==0){
            int v, w;
            cin>>v>>w;
            edge e = {par[v], v};
            int id1 = start[e], id2 = fin[e];
            add(id1, w), add(id2, -w);
        } else {
            int u;
            cin>>u;
            edge e = {par[u], u};
            int id = start[e];
            printf("%lld\n", sum(id));
        }
    }
    return 0;
}


Measured memory_bytes: 36340
fn main() {
    proconio::input! {
        n: usize,
        mut a: [i128;n],
    }
    let mut v=1;
    a.sort();
    for a in a {
        v*=a;
        if v>1000000000000000000i128 {
            v=-1;
            break;
        }
    }
    println!("{}",v);
}

Measured memory_bytes: 6104
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    int n = nextInt();
    int k = nextInt();
    double[] p = new double[n];
    for(int i=0;i<n;i++){
      p[i] = nextDouble();
    }

    double[] eachK = new double[n-k+1];

    double Sum = 0;

    for(int i=0;i<k;i++){
      Sum += (1+p[i])/2;
    }

    double max = Sum;

    for(int i=1;i<n-k+1;i++){
      Sum -= (1+p[i-1])/2;
      Sum += (1+p[i+k-1])/2;
      max = Math.max(max,Sum);
    }


    System.out.println(max);

  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

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

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


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

void c_p_c()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main()
{
    c_p_c();
    int n;
    cin >> n;
    string str[n];
    int ac = 0, tle = 0, wa = 0, re = 0;
    for (int i = 0; i < n; i++)
        cin >> str[i];
    for (int i = 0; i < n; i++) {
        if (str[i] == "AC") ac++;
        else if (str[i] == "TLE") tle++;
        else if (str[i] == "WA") wa++;
        else if (str[i] == "RE") re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

    return 0;
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i<b; i++)
using namespace std;
typedef long long int ll;
int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int h,n,ans=0;
    cin>>h>>n;
    int arr[n];
    rep(i,0,n){
        cin>>arr[i];
        ans+=arr[i];
    }
    if((h-ans)<=0) cout<<"Yes\n";
    else cout<<"No\n";
return 0;
}

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

int main() {
  int N; cin >> N; map<string,int> S;
  for (int i =0; i<N; i++) {
    string s; cin >> s;
    if (!S.count(s)) {
      S[s] = 1;
    } else {
      S.at(s)++;
    }
  }  
  cout << S.size() << endl; 
}
  

Measured memory_bytes: 19152
def main():
    n = int(input())
    ab = []
    for i in range(n):
        a, b = map(int, input().split(' '))
        ab.append([a+b, a, b])
    ab.sort(reverse = True)
    result = 0
    for i in range(n):
        if i%2 == 0:
            result += ab[i][1]
        else:
            result -= ab[i][2]
    print(result)
if __name__ == '__main__':
    main()

Measured memory_bytes: 23260
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;

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

const int TOWN = 11;
const int ROAD = 50;
const int INF = 10000;

int d[TOWN][TOWN] ;

int n,a,b,c;
int main()
{
	while(cin >> n && n)
	{
		memset(d,INF,sizeof(d));
		int townnum = 0;
		REP(n)
		{
			cin>> a >> b >> c;
			d[a][b] = c;
			d[b][a] = c;
			d[i][i] = 0;
			townnum = max(townnum,a);
			townnum = max(townnum,b);
		}
		//cout << "town "<<townnum << endl;
		rep(k,townnum+1)rep(i,townnum+1)rep(j,townnum+1)//if(d[i][j] != INF)
		{
			d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
			d[j][i] = d[i][j];
		}
		int time = 1000000,town = 0;
		
		rep(i,townnum+1)//town i
		{
			int sum = 0;
			rep(j,townnum+1) sum += d[i][j];//i to j
			//cout << sum << endl;
			if(sum < time){ time = sum; town = i;}
		}
		cout << town << " " << time << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<vector>
#include<cstring>
#include<cmath>
using namespace std;
inline int read(){
	int x = 0; char ch = getchar(); bool positive = 1;
	for (; !isdigit(ch); ch = getchar())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = getchar())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
	if(a>=10)write(a/10);
	putchar('0'+a%10);
}
inline void writeln(int a){
	write(a); puts("");
}
const int N=200005;
int sum,n,a[N],dp[N][2],b[N],c[N];
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		int t=log(a[i])/log(2);
		if((1<<t)==a[i]){
			dp[i][0]=dp[i][1]=max(dp[i-1][0]+min(b[i-1],t),dp[i-1][1]+min(c[i-1],t));
			b[i]=c[i]=t; sum+=t;
		}else{b[i]=t+1; c[i]=t;
			dp[i][0]=max(dp[i-1][0]+min(b[i-1],t),dp[i-1][1]+min(c[i-1],t));
			dp[i][1]=max(dp[i-1][0]+min(b[i-1],t+1),dp[i-1][1]+min(c[i-1],t+1)); sum+=t+1;
		}
	}
	writeln(sum-max(dp[n][0],dp[n][1]));
}

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

int month[13] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
char dd[7][12] = {"Monday", "Tuesday", "Wednesday", "Thursday", 
                  "Friday", "Saturday", "Sunday"};

int main(){
    int m, d;
    while(true){
        scanf("%d %d", &m, &d);
        if(m == 0 && d == 0) break;
        int a = 3;
        for(int i = 1; i < m; i++){
            a = (a + month[i])%7;
        }
        a = (a + d - 1)%7;
        printf("%s\n", dd[a]);
    }
    return 0;
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

bool print(bool ans) {
	if(ans) {
		printf("Yes\n");
		return true;
	}
	return false;
}

int main() {
	auto a = make_v<int>(3, 3);
	for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) scanf("%d", &a[i][j]);

	int n; scanf("%d", &n);
	std::map<int, bool> mp;
	while(n--) {
		int b; scanf("%d", &b);
		
		mp[b] = true;
	}
	
	bool ans = true;
	for(int i = 0; i < 3; i++) ans &= mp[a[i][i]];
	if(print(ans)) return 0;
	
	ans = true;
	for(int i = 0; i < 3; i++) ans &= mp[a[i][2 - i]];
	if(print(ans)) return 0;
	
	for(int i = 0; i < 3; i++) {
		ans = true;
		for(int j = 0; j < 3; j++) ans &= mp[a[i][j]];
		if(print(ans)) return 0;
		
		ans = true;
		for(int j = 0; j < 3; j++) ans &= mp[a[j][i]];
		if(print(ans)) return 0;
	}
	printf("No\n");
	return 0;
}


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

#define pb push_back
#define fr first
#define sc second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main() {

  int n;
  cin>> n;
  for(int num=0; num<n; num++) {
    int s;
    cin>> s;
    int rand_num=s;
    printf("Case %d:\n", num+1); 
    for(int i=0; i<10; i++) {
      rand_num*=rand_num;
      rand_num%=1000000;
      rand_num/=100;
      printf("%d\n",rand_num);
    }
  }
}

Measured memory_bytes: 1140
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int n;
    long long sum=0;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    vector<long long> C(n+1);
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++) cin >> b[i];
    for(int i=0; i<n; i++) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    C[n] = 0;
    for(int i=n-1; i>=0; i--){
        C[i] = C[i+1] + c.end() - upper_bound(c.begin(), c.end(), b[i]);
    }
    for(int i=0; i<n; i++){
        int x = upper_bound(b.begin(), b.end(), a[i]) - b.begin();
        sum += C[x];
    }

    cout << sum << endl;
}
    

Measured memory_bytes: 2176
#include <stdio.h>
int main(){
	int a;

	scanf("%d",&a);
	
	for(int i=0;i<=25;i++){
		for(int j=0;j<=14;j++){
			if(i*4+j*7==a){
				printf("Yes");
				return 0;
			}
		}
	}
	printf("No");
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int ans,k,x;
   cin >> k >> x;

   ans = 500 * k;

   if(ans >= x) cout << "Yes" << endl;
   else cout << "No" << endl;




   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdlib.h>
using namespace std;
int main()
{
    long long int a,b,c,x,y,maxi,mini,p1,p2,p3,m,r;
    cin>>a>>b>>c>>x>>y;
    p1=(a*x+b*y);
    if(x>y){
        m=y;
        r=x-m;
        p2=(m*2*c)+(r*a);
        //cout<<p2<<endl;
    }
    else{
        m=x;
        r=y-m;
        p2=(m*2*c)+(r*b);
        //cout<<p2<<endl;
    }
    if(x>y){
        m=x;
        r=abs(y-m);
        p3=(m*2*c);
    }
    else{
        m=y;
        r=abs(x-m);
        p3=(m*2*c);
    }
//    cout<<p1<<endl;
//    cout<<p2<<endl;
//    cout<<p3<<endl;
    cout<<min(p1,min(p2,p3))<<endl;
}


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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N;
int leg[2];

int main(){
  while(scanf("%d",&N) && N){
    leg[0] = leg[1] = 0;
    int res = 0;
    string f[128];
    rep(i,N) cin >> f[i];
    rep(i,N-1){
      if(f[i][0]!=f[i+1][0] && f[i][1]==f[i+1][1]) res++;
    }
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define bg begin()
#define end end()
#define sz size()
#define vi vector<int>
#define vl vector<long long int>
int main(){
	fast;
	ll a,b,c,ans=0;
	cin>>a>>b>>c;
	cout<<b/c - (a-1)/c;
	return 0;
}



Measured memory_bytes: 3648
import sys

def sumi(i,j):
    s=0
    for k in range(i,j+1):
        s+=l[k]
    return s

n = int(input())
l = list(map(int, input().split()))
dp = []
for i in range(n):
    dp.append([sys.maxsize]*n)
for i in range(n-1,-1,-1):
    for j in range(i,n):
        if i==j:
            dp[i][j]=0
        else:
            s=sumi(i,j)
            for k in range(i,j):
                dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+s)
print(dp[0][n-1])

Measured memory_bytes: 43484