akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
int m, n;
char c;
char g[101][101];
int id[8] = {0, -1, 0, 1, -1, 0, 1, 0};
int main() {
    while ((~scanf("%d %d", &n, &m)) && m && n) {
        for (int i = 0; i < n; ++i) {
            getchar();
            for (int j = 0; j < m; ++j)
                while (scanf("%c", &g[i][j]) == 1 && g[i][j] == ' ');
        }//puts("123");
        int ans = 0;
        for (int x = 0; x < m * n; ++x) {
            if (g[x / m][x % m] != '.') {
                c = g[x / m][x % m];
                g[x / m][x % m] = '.';
                queue<int> q;
                q.push(x);
                while (!q.empty()) {
                    int i = q.front() / m, j = q.front() % m;
                    q.pop();
                    for (int k = 0; k < 8; k += 2) {
                        int ni = i + id[k], nj = j + id[k + 1];
                        if (ni >= 0 && ni < n && nj >= 0 && nj < m && g[ni][nj] == c) {
                            g[ni][nj] = '.';
                            q.push(ni * m + nj);
                        }
                    }
                }
                ++ans;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}



Measured memory_bytes: 2672
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
	public static void Main()
	{
		Console.ReadLine();
		var S = Console.ReadLine().Split().Select(i => int.Parse(i)).ToList();
		Console.ReadLine();
		var T = Console.ReadLine().Split().Select(i => int.Parse(i)).ToList();
		Console.WriteLine(S.Intersect(T).ToList().Count);
	}
}

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

typedef long long int ll;

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

    ll sum = 0;
    for(ll i = 0;i < n;i++){
        sum += l[i];
    }

    if(sum - m > m){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
/********************************************************************************************************************************/
/* main *************************************************************************************************************************/
/********************************************************************************************************************************/
int DEBUG = 0;										/* デバッグプリント 提出時は0 */
int main()
{
	int		a,b,ans = 0;
	
	scanf("%d %d", &a,&b);

	if (a<b) printf("a < b\n");
	if (a>b) printf("a > b\n");
	if (a==b) printf("a == b\n");
	return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

char field[21][21];

int main(){
  int t;
  int H, W;
  cin >> t;
  for(int cs = 0 ; cs < t ; cs++){
    cin >> H >> W;
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
	cin >> field[i][j];
      }
    }
    
    int tmp;
    string op;
    cin >> tmp;
    cin >> op;
    
    
    for(int cc = 0 ; cc < tmp ; cc++){
      if(op[cc] == 'U' || op[cc] == 'D' || op[cc] == 'L' || op[cc] == 'R'){
	bool flag = false;
	for(int i = 0 ; i < H ; i++){
	  for(int j = 0 ; j < W ; j++){
	    if(flag) break;
	    if(field[i][j] == '^' || field[i][j] == 'v' || field[i][j] == '<' || field[i][j] == '>'){
	      flag = true;
	      
	      if(op[cc] == 'U'){
		if(i-1 < 0 || field[i-1][j] == '*' || field[i-1][j] == '#' || field[i-1][j] == '-') field[i][j] = '^';
		else{
		  field[i-1][j] = '^';
		  field[i][j] = '.';
		}
	      }
	      
	      if(op[cc] == 'D'){
		if(H <= i+1 || field[i+1][j] == '*' || field[i+1][j] == '#' || field[i+1][j] == '-') field[i][j] = 'v';
		else{
		  field[i+1][j] = 'v';
		  field[i][j] = '.';
		}
	      }
	      
	      if(op[cc] == 'L'){
		if(j-1 < 0 || field[i][j-1] == '*' || field[i][j-1] == '#' || field[i][j-1] == '-') field[i][j] = '<';
		else{
		  field[i][j-1] = '<';
		  field[i][j] = '.';
		}
	      }
	      
	      if(op[cc] == 'R'){
		if(W <= j+1 || field[i][j+1] == '*' || field[i][j+1] == '#' || field[i][j+1] == '-') field[i][j] = '>';
		else{
		  field[i][j+1] = '>';
		  field[i][j] = '.';
		}
	      }	      
	    }
	  }
	}
      }
      else if(op[cc] == 'S'){
	bool flag = false;
	for(int i = 0 ; i < H ; i++){
	  for(int j = 0 ; j < W ; j++){
	    if(flag) break;
	    
	    if(field[i][j] == '^'){
	      flag = true;
	      for(int y = i-1 ; y >= 0 ; y--){
		if(field[y][j] == '#') break;
		else if(field[y][j] == '*'){
		  field[y][j] = '.';
		  break;
		}
	      }
	    }

	    if(field[i][j] == 'v'){
	      flag = true;
	      for(int y = i+1 ; y < H ; y++){
		if(field[y][j] == '#') break;
		else if(field[y][j] == '*'){
		  field[y][j] = '.';
		  break;
		}
	      }
	    }
	    
	    if(field[i][j] == '<'){
	      flag = true;
	      for(int x = j-1 ; x >= 0 ; x--){
		if(field[i][x] == '#') break;
		else if(field[i][x] == '*'){
		  field[i][x] = '.';
		  break;
		}
	      }
	    }

	    if(field[i][j] == '>'){
	      flag = true;
	      for(int x = j+1 ; x < W ; x++){
		if(field[i][x] == '#') break;
		else if(field[i][x] == '*'){
		  field[i][x] = '.';
		  break;
		}
	      }
	    }
	  }
	}
      }
      /*
      for(int a = 0 ; a < H ; a++){
	for(int b = 0 ; b < W ; b++){
	  cout << field[a][b];
	}
	cout << endl;
      }
      cout << endl;*/
    }
    
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
	cout << field[i][j];
      }
      cout << endl;
    }
    if(cs != t-1)cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
signed  main(){
  int a;
  cin>>a;
  if(a<1200){
    cout<<"ABC\n";
  }else if(a>=1200 && a<2800){
    cout<<"ARC\n";
  }else{
    cout<<"AGC\n";
  }
}


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

int main() {
  int N, X, m, i, minm = 100000;
  cin >> N >> X;
  for(i = 0; i < N; i++){
  	cin >> m;
  	X -= m;
  	minm = min(minm, m);
  }
  cout << N + X / minm << '\n';
  
  return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, M;
    cin >> N >> M;

    vector<ll> A(N);
    rep (i, N) {
        cin >> A[i];
    }

    vector<ll> B(M), C(M);
    rep (i, M) {
        cin >> B[i] >> C[i];
    }

    priority_queue<Pll> pq;
    rep (i, N) {
        pq.push(make_pair(A[i], 1));
    }

    rep (i, M) {
        pq.push(make_pair(C[i], B[i]));
    }

    ll ans = 0;
    rep (i, N) {
        Pll p = pq.top();
        pq.pop();
        ans += p.first; 
        if (p.second > 1) {
            p.second--;
            pq.push(p);
        }
    }

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


Measured memory_bytes: 8816
n,m=map(int,input().split())

a=[1,1]
for i in range(2,100001):
    a.append((a[i-1]+a[i-2])%1000000007)

bad=[]
for i in range(m):
    bad.append(int(input()))
num=[]
before=0
bad_flag=0

if m!=0:
    for i in range(len(bad)):
        nxt=bad[i]-before-1
        if nxt==-1:
            bad_flag=1
            break
        num.append(nxt)
        before=bad[i]+1
    num.append(n-bad[len(bad)-1]-1)
else:
    num.append(n)
if bad_flag:
    print(0)
else:
    ans=0
    last=1
    for i in num:
        ans=a[i]*last
        last=ans%1000000007
    print(last)

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

struct Participant{
    int h, p;
    bool operator<(const Participant& obj)const{
        if(p != obj.p)return h+p < obj.h+obj.p;
        else return p < obj.p;
    }
};

long long int dp[5003][5003] = {0};

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

    vector<Participant> v;
    v.push_back((Participant){0, 0});
    for(int i=0;i<n;++i){
        int h, p;
        cin >> h >> p;
        v.push_back((Participant){h, p});
    }

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

    for(int i=0;i<=n;++i){
        dp[i][0] = 0;
        for(int j=1;j<=n;++j){
            dp[i][j] = LLONG_MAX;
        }
    }

    for(int i=1;i<=n;++i){
        for(int j=1;j<=i;++j){
            dp[i][j-1] = min(dp[i][j-1], dp[i-1][j-1]);
            if(dp[i-1][j-1] <= v[i].h){
                dp[i][j] = min(dp[i][j], dp[i-1][j-1] + v[i].p);
            }
        }
    }

    int ans = 0;
    for(int i=1;i<=n;++i){
        if(dp[n][i] != LLONG_MAX)ans = i;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 195840
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>
 
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back
 
void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
void No(){cout<<"NO"<<endl;exit(0);}
void Yes(){cout<<"YES"<<endl;exit(0);}
 
typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main(void)
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    string board[112];
    bool x[112]={0}, y[112]={0};
    for (int i = 0; i < h;i++){
        cin >> board[i];
    }
    for (int i = 0; i < h;i++){
        for (int j = 0; j < w;j++){
            if(board[i][j]=='#')
                x[i] = true, y[j] = true;
        }
    }
    for (int i = 0; i < h;i++){
        if(x[i]){
            for (int j = 0; j < w;j++){
                if(y[j])
                    cout << board[i][j];
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define int ll
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<ll>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N >> M;
    vi a(N);
    cin >> a;
    sort(ALL(a));
    int mx = a[N - 1];
    vi hp(mx + 1);
    vi sum(mx + 1);
    int prev = 0;
    int pprev = 0;
    for (int i = N - 1; i >= 0; i--) {
        hp[a[i]] = ++prev;
        sum[a[i]] = (pprev += a[i]);
    }
    for (int i = mx; i >= 0; i--) {
        if (hp[i] == 0) {
            hp[i] = hp[i + 1];
            sum[i] = sum[i + 1];
        }
    }
    auto isOk = [&](int index, int key) {
        int now = 0;
        for (int i = 0; i < N; i++) {
            int tmp = index - a[i];
            if (tmp <= mx) {
                if (tmp < 0)
                    tmp = 0;
                now += hp[tmp];
            }
        }
        if (now < key)
            return true;
        else
            return false;
    };
    auto binary_search = [&](int key) {
        int ng = -1;         //「index = 0」が条件を満たすこともあるので、初期値は -1
        int ok = 2 * mx + 1; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
        /* ok と ng のどちらが大きいかわからないことを考慮 */
        while (abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            if (isOk(mid, key))
                ok = mid;
            else
                ng = mid;
        }
        return ok - 1;
    };
    int x = binary_search(M);
    if (x == -1) {
        x = 0;
    }
    //dump(hp);
    //dump(sum);
    dump(x);
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        int tmp = x - a[i];
        if (tmp <= mx) {
            if (tmp < 0)
                tmp = 0;
            ans += a[i] * hp[tmp] + sum[tmp];
            cnt += hp[tmp];
        }
    }
    cout << ans - x * (cnt - M) << endl;
}

Measured memory_bytes: 2688
N, X, M = $stdin.gets.split.map {|i| i.to_i }
case X
when 0
  puts "0"
  exit
when 1
  puts N
  exit
end
A = { 0 => X }
R = { X => 0 }
last = 0
sum0 = X
offset = nil
1.upto(N - 1) do |i|
  f = (A[i - 1] ** 2) % M
  if f == 0
    puts sum0
    exit
  elsif offset = R[f]
    break
  end
  A[i] = f
  R[f] = i
  last = i
  sum0 += f
end
offset ||= 0
length = last + 1 - offset
sum = 0
0.upto(offset - 1) do |i|
  sum += A[i]
end
0.upto(last - offset) do |i|
  a = A[offset + i]
  c = (N - offset - i + length - 1) / length
  sum += a * c
end
puts sum


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

using namespace std;

int hoge(vector<vector<pair<int, int>>> &vec, vector<int> mask, int idx = 0) {
  if (idx == static_cast<int>(vec.size()))
    return 0;

  int cnt1 = -100000, cnt2 = -100000;
  vector<int> mask1 = mask;

  if (mask1[idx] != 1) {
    mask1[idx] = 0;
    cnt1 = hoge(vec, mask1, idx + 1);
  }

  bool flag = true;
  for (auto &v : vec[idx]) {
    if (mask[v.first] == -1)
      mask[v.first] = v.second;
    else if (mask[v.first] != v.second) {
      flag = false;
      break;
    }
  }

  if (flag && mask[idx] != 0) {
    mask[idx] = 1;
    cnt2 = hoge(vec, mask, idx + 1) + 1;
  }

  return max(cnt1, cnt2);
}

int main() {
  int n;
  cin >> n;
  vector<vector<pair<int, int>>> vec(n);
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    for (int j = 0; j < a; ++j) {
      int x, y;
      cin >> x >> y;
      vec[i].push_back(make_pair(x - 1, y));
    }
  }

  vector<int> mask(n, -1);
  cout << hoge(vec, mask) << endl;
  ;
}

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

using namespace std;


 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

//5
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){

ios::sync_with_stdio(false);
cin.tie(0);
string s;

cin>>s;


if(s=="ABC")
cout<<"ARC"<<endl;
else
cout<<"ABC"<<endl;



}



//cout << fixed << setprecision(5) <<(n*2)*M_PI << endl;


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

int main(){
	ll a,b,c,d,e;
	cin >> a >> b >> c >> d >> e;
	if(a==0){
		cout << 1;
	}
	else if(b==0){
		cout << 2;
	}
	else if(c==0){
		cout << 3;
	}
	else if(d==0){
		cout << 4;
	}
	else if(e==0){
		cout << 5;
	}
	return 0;
}

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

int choco(int n,int d){
  int cnt = 0;
  int a = 1;
  while(a <= d) {
    cnt++;
    a += n;
  }
  return cnt;
}
    

int main() {
  int N,D,X;
  cin >> N >> D >> X;
  int sum = 0;
  for (int i = 0;i < N;i++) {
    int a;
    cin >> a;
    sum += choco(a,D);
  }
  cout << sum + X << endl;
    
  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
class Program
{
static string result;
  static decimal S;
  static int x2,x3,y2,y3;
    static void Main()
    {
      S=decimal.Parse(Console.ReadLine());
//三角形は平行移動しても面積が変わらないので１点（x1,y1）を原点に置いて考える。
//x2y3-x3y2=Sになる組み合わせを求めればいい。
//x2y3がSをちょっと越える組み合わせ。両者がルートＳを少し越えればいい。
if(S==1000000000000000000){x2=1000000000;}else{x2=(int)Math.Sqrt((double)S)+1;}
      y3=x2;
      //x3y2は１に『少し超えた分』をかければピタリＳに戻るはず。
      x3=1;
      y2=(int)((decimal)x2*y3-S);
      result= "0 0 " +  
        x2.ToString() + " " + y2.ToString() + " " + 
        x3.ToString() + " " + y3.ToString();
                    Console.WriteLine(result);

    }

}

Measured memory_bytes: 13140
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int upper = 55555;
		int a[] = new int[upper+1];
		for (int i = 2; i <= upper; i++) {
			a[i] = i;
		}
		for (int i = 2; i <= Math.sqrt(upper); i++) {
			for (int j = i + i; j <= upper; j += i) {
				a[j] = 0;
			}
		}
		int index = 0;
		for (int i = 0; i < n - 1; i++) {
			while (a[index] == 0 || a[index] % 10 != 1)
				index++;
			System.out.print(a[index] + " ");
			index++;
		}
		while (a[index] == 0 || a[index] % 10 != 1)
			index++;
		System.out.println(a[index]);
	}
}

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

ll n,d,a,j=1ll,sumv=0ll,total=0ll;
ll bomb[200005];

pair<ll,ll>m[200005];

int main()
{
	cin>>n>>d>>a;
	for (int i=1;i<=n;i++)
	{
		cin>>m[i].first>>m[i].second;
		m[i].second=(m[i].second+a-1)/a;
	}
	sort(m+1,m+n+1);
	for (int i=1;i<=n;i++)
	{
		while ((j<i)&&(m[i].first-m[j].first>d*2))
		{
			sumv-=bomb[j];
			j+=1ll;
		}
		bomb[i]=max(m[i].second-sumv,0ll);
		sumv+=bomb[i];
		total+=bomb[i];
	}
	cout<<total<<endl;
	return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int a,b,c,i,j;
        a=sc.nextInt();
        b=sc.nextInt();
        c=sc.nextInt();
        j=0;
        for(i=a;i<=b;i++){
            if(c%i==0){
                j++;
            }
        }
        System.out.println(j);
    }
}


Measured memory_bytes: 26264
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=5e5+5;
int n,m,k,mod,dp[N],all,ss[N];
pair<int,int>l[15];
 main(){
	mod=998244353;
	cin>>n>>m;
	for(k=1;k<=m;k++){
		cin>>l[k].first>>l[k].second;
	}
	sort(l+1,l+m+1);
	dp[1]=1;
	ss[1]=1;
	for(k=2;k<=n;k++){
	//	cout<<k<<"__"<<endl;
		for(int i=1;i<=m;i++){
			if(k-l[i].first<1) break;
			 dp[k]+=ss[k-l[i].first]; dp[k]%=mod; //<<ss[k-l[i]]-ss[max(0,k-r[i]-1)]<<endl;
			 dp[k]-=ss[max(0ll,k-l[i].second-1)]-mod;
			 dp[k]%=mod;

		}  
		ss[k]=ss[k-1]+dp[k];ss[k]%=mod;
	//	cout<<dp[k]<<"+"<<endl;
	}
	cout<<dp[n]%mod;
}

Measured memory_bytes: 6728
s = input()
c = 0
if s[0] == "R":
  c = c+1
  if s[1] == "R":
    c = c+1
    if s[2] == "R":
      c = c+1

if s[0] != "R":
  if s[1] == "R":
    c = c+1
    if s[2] == "R":
      c = c+1 
    
if s[0] != "R":
  if s[1] != "R":
    if s[2] == "R":
      c = c+1

print(c)


Measured memory_bytes: 9056
#include <stdio.h>
int main(void)
{
    int n,m;
    int sum=0;
    
    scanf("%d",&n);
    scanf("%d",&m);
    
    int a[m];
    for(int i=0;i<m; i++){
    scanf("%d",&a[i]);
    sum+=a[i];
    }
    if(n<sum)
        printf("%d",-1);
    else
        printf("%d",n-sum);
    
    return 0;
}


Measured memory_bytes: 1724
n , m , x = map(int, input().split())
a = list(list(map(int, input().split())) for _ in range(n))

c = []
for i in range(n):
    c.append(a[i][0])
    a[i].pop(0)

ans = 1000000000

for i in range(1 << n):
    score = [0] * m
    tmp = 0
    for j in range(n):
        if (i >> j) % 2 == 1:
            tmp += c[j]
            for k in range(m):
                score[k] += a[j][k]

    check = True
    for l in range (m):
        if score[l] < x:
            check = False

    if check:
        ans = min(ans , tmp)

if(ans == 1000000000):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9056
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second

ll arr[200001];

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

    ll ans = 0, M = 1000000007, sum = arr[0];

    for(int i=1; i<n; i++) {
        ans = (ans + (sum * arr[i])) % M;
        sum = (sum + arr[i]) % M;
    }

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

    return 0;
}

Measured memory_bytes: 5320
N,M = map(int, input().split())
a_n = list(map(int, input().split()))
g = a_n.copy()
 
while not any(x%2 for x in g): g = [x//2 for x in g]
if not all(x%2 for x in g): print(0); exit(0)
def gcd(a,b):
  while b: a,b = b,a%b
  return a
lcm = lambda a,b: a*b//gcd(a,b)
tot = 1
for x in a_n: tot = lcm(tot,x//2)
print((M//tot+1)//2)

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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/*int power(int a,int n)
{
    if(n == 1)return a%mod;
    if(n == 0)return 1;
    if(n&1)return ((a%mod)*(power((a*a)%mod,n/2))%mod)%mod;
    return power((a*a)%mod,n/2)%mod;
}*/
//const int md = 998244353;

/*int inverse(int x){

    return power(x,mod-2)%mod;//little fermat....
}*/
//const int inf = (int) 1e18+100;
//const int md = (int) 1e9+21;

int cnt[30],dp[maxn],sum[maxn];

signed main()
{
    showoff;
    int n;
    cin >> n;
    vector<int>col(n+5);
    FOR(i,1,n+1){
        cin >> col[i];
    }
    dp[n+1] = 1;
    RFOR(i,n,0){
        dp[i] = dp[i+1]%mod;
        if(col[i] != col[i+1]){
            dp[i] += sum[col[i]];
            dp[i] %= mod;
            sum[col[i]] += dp[i+1];
        }
        sum[col[i]] %= mod;
    }
    cout << dp[1] << "\n";
    return 0;

}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...


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

#define F first
#define S second

using namespace std;

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

int main(){
  int n;
  int l,s;
  int buff[4];
  int temp;
  int cnt;
  
  while(1){
    scanf("%d",&n);
    if(n==0) break;

    if(n%1111==0){
      printf("NA\n");
    }else{
      
      for(int i=3;i>=0;i--){
	buff[i]=n%10;
	n/=10;
      }
      
      cnt=0;
      while(!(buff[0]==6&&buff[1]==1&&buff[2]==7&&buff[3]==4)){
	s=l=0;
	sort(buff,buff+4);
	for(int i=0;i<4;i++){
	  s*=10;
	  s+=buff[i];
	}
	
	for(int i=3;i>=0;i--){
	  l*=10;
	  l+=buff[i];
	}
	
	temp=l-s;
	for(int i=3;i>=0;i--){
	  buff[i]=temp%10;
	  temp/=10;
	}
	cnt++;
      }
      
      printf("%d\n",cnt);
    }
  }

  return 0;
}



Measured memory_bytes: 3272
n, m = map(int, input().split())
a = list(map(int, input().split()))
s = 0
for i in a:
    s += i
pop = 0
d = s / (4 * m)
for i in range(n):
    if a[i] >= d:
        pop += 1
if pop >= m:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}



const int MAX_N = 100010;

int group1[7] = { 1,3,5,7,8,10,12 };
int group2[4] = { 4,6,9,11 };

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int x, y; cin >> x >> y;
	int a = 0, b = 0;
	if (x == 2)a = 3;
	if (y == 2)b = 3;
	rep(i, 7) {
		if (group1[i] == x)a = 1;
		if (group1[i] == y)b = 1;
	}
	if (a == 0)a = 2;
	if (b == 0)b = 2;
	Yes(a == b);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <tuple>
#include <string>
#include <cstdint>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <cassert>
using namespace std;
using i64 = int64_t;
const int OFS = 100000;
i64 n;
vector<int> g[200001];
bool vis[200001];
i64 r, c, p;
void dfs(int u) {
    if (vis[u]) return;
    vis[u] = true;
    if (u <= OFS) ++r;
    else ++c;
    for (int v : g[u]) {
        ++p;
        dfs(v);
    }
}
int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y + OFS);
        g[y + OFS].push_back(x);
    }
    i64 ans = 0;
    for (int u = 1; u <= 200000; ++u) {
        r = c = p = 0;
        dfs(u);
        ans += r * c - p / 2;
    }
    cout << ans << endl;
    return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		if(a >= b){
			System.out.println("delicious");
		}else if (a + x >= b) {
			System.out.println("safe");
		}else {
			System.out.println("dangerous");
		}
	}
}


Measured memory_bytes: 21972
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CSqrtInequality {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int a, b, c;
        cin >> a >> b >> c;
        int num = c - a - b;
        if (num <= 0) {
            cout << "No" << endl;
            return;
        }
        if (num * num > 4 * a * b) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CSqrtInequality solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int K, N; cin >> K >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    int ma = 0;
    for(int i=0; i<N; i++) chmax(ma, (A[(i+1)%N] - A[i] + K) % K);
    cout << K - ma << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

string s;
int K;
int dist(char c) {
    if (c == 'a') return 0;
    return 'z' - c + 1;
}
char advance(char c, int t) {
    rep(i, t) {
        if (c == 'z')
            c = 'a';
        else
            c++;
    }
    return c;
}
int main() {
    cin >> s >> K;
    rep(i, s.size()) {
        if (K == 0) break;
        int t = dist(s[i]);
        if (t <= K) {
            s[i] = advance(s[i], t);
            K -= t;
        } else {
        }
    }
    int n = s.size();
    s[n - 1] = advance(s[n - 1], K % 26);
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t;
    string s;
    set<char> se;
    cin>>s;
    for(i=0;i<s.size();i++) se.insert(s[i]);
    if(se.size()==2) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3604
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++){
		    arr[i] = scn.nextInt();
		}
      	int[] mem = new int[arr.length];
      	Arrays.fill(mem,-1);
		int ans = solution(0,arr,mem);
        System.out.println(ans);
	}
	
	public static int solution(int idx,int[] arr,int[] mem){
	    if(idx==arr.length-1)return mem[idx]=0;
      	if(mem[idx]!=-1)return mem[idx];
	    int o1 = idx+1<arr.length?solution(idx+1,arr,mem)+Math.abs(arr[idx+1]-arr[idx]):1000000;
	    int o2 = idx+2<arr.length?solution(idx+2,arr,mem)+Math.abs(arr[idx+2]-arr[idx]):1000000;
	    return mem[idx]=Math.min(o1,o2);
	}
}


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

typedef long long ll;
const int INF = 1e9;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin>>n;
	vector<int> ans(n,0);
	int temp;
	for (int i = 1; i < n; i++) {
		cin>>temp;
		ans[temp-1]++;
	}
	for (int i = 0; i < n; i++) {
		cout<<ans[i]<<'\n';
	}
	// cout<<'\n';
	return 0;
}

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

int main(){
    int mid, fin, retest;
    int student[50][3], studentNum=0;

    while(true){
        cin >> mid >> fin >> retest;
        if(mid==-1 && fin==-1 && retest==-1)break;

        student[studentNum][0]=mid;
        student[studentNum][1]=fin;
        student[studentNum][2]=retest;
        studentNum++;
    }

    for(int i=0; i<studentNum; i++){
        if(student[i][0]==-1 || student[i][1]==-1) {
            cout << "F";}
        else if(student[i][0]+student[i][1]>=80) {
            cout << "A";}
        else if(student[i][0]+student[i][1]>=65 && student[i][0]+student[i][1]<80) {
            cout << "B";}
        else if(student[i][0]+student[i][1]>=50 && student[i][0]+student[i][1]<65) {
            cout << "C";}
        else if(student[i][0]+student[i][1]>=30 && student[i][0]+student[i][1]<50) {
            if(student[i][2]>=50){cout << "C";}
            else {cout << "D";}}
        else if(student[i][0]+student[i][1]<30) {
            cout << "F";}
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long a,b,c,k,ans;
    cin>>a>>b>>c>>k;
    if(k%2==0){
        ans=a-b;
    }
    else{
        ans=b-a;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3640
package main

import (
	"fmt"
)

func main() {
	var h, w, k int
	fmt.Scan(&h, &w, &k)
	var y1, x1, y2, x2 int
	fmt.Scan(&y1, &x1, &y2, &x2)
	y1--
	x1--
	y2--
	x2--
	cs := make([][]byte, h)
	for i := range cs {
		fmt.Scan(&cs[i])
	}

	ans := make([][]int, h)
	for i := range ans {
		ans[i] = make([]int, w)
		for j := range ans[i] {
			ans[i][j] = -1
		}
	}

	qs := make([][]int, 0)
	qs = append(qs, []int{y1, x1, 0})
	ans[y1][x1] = 0
	dxs := []int{-1, 0, 1, 0}
	dys := []int{0, 1, 0, -1}
	for len(qs) > 0 {
		q := qs[0]
		qs = qs[1:]
		y, x, st := q[0], q[1], q[2]
		for i := range dxs {
			dx, dy := dxs[i], dys[i]
			for j := 1; j <= k; j++ {
				nx, ny := x+dx, y+dy
				if nx >= 0 && nx < w && ny >= 0 && ny < h && cs[ny][nx] == '.' {
					dx += dxs[i]
					dy += dys[i]
					if ans[ny][nx] != -1 {
						if ans[ny][nx] <= st {
							break
						} else {
							continue
						}
					}
					ans[ny][nx] = st + 1
					qs = append(qs, []int{ny, nx, st + 1})
				} else {
					break
				}
			}
		}
	}

	if ans[y2][x2] == -1 {
		fmt.Println(-1)
	} else {
		fmt.Println(ans[y2][x2])
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 36972
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {

    int a,b;
    cin >> a >> b;

    int h, m;
    cin >> h >> m;

    double Hangle;
    if (h<=12){
        Hangle = (8*atan(1)/12)*h + ((4*atan(1))/360)*m;
    } else {
        Hangle = (8*atan(1)/12)*(h-12);
    }

    double Mangle = ((8*atan(1))/60)*m;

    double angleR = abs(Hangle - Mangle);
    double cosA = cos(angleR);

    double resp;


    resp = a*a + b*b - 2*a*b*cosA;
    resp = sqrt(resp);

    printf("%.15lf", resp);

    return 0;
}


Measured memory_bytes: 4120
// abc138_f
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)
#define EPS (1e-9)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    struct Vec {
        int x, y;
        double angle;
        bool operator<(const Vec& v){ return angle < v.angle;}
        bool operator<(const double& angle_){ return angle < angle_;}
    };

    int N;
    cin >> N;
    vector<Vec> vecs(N);
    REP(i, N) {
        cin >> vecs[i].x >> vecs[i].y;
        vecs[i].angle = atan2(vecs[i].y, vecs[i].x);
    }
    sort(ALL(vecs));

    REP(i, N) {
        auto tmp = vecs[i];
        tmp.angle += 2 * M_PI;
        vecs.emplace_back(tmp);
    }

    double ans = 0;
    REP(i, N) {
//        double angle = vecs[i].angle;
//        int j = lower_bound(ALL(vecs), angle + M_PI - EPS) - vecs.begin();

        REPN(j, i, i+N){
            double x = 0, y = 0;
            REPN(k, i, j+1) {
                x += vecs[k].x;
                y += vecs[k].y;
            }
            ans = max(ans, sqrt(x * x + y * y));
        }

    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
import math

def is_prime(n):
    if n == 1: return True

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
    
a, b = map(int, input().split())

set1 = set(make_divisors(a))
# print(set1)

set2 = set(make_divisors(b))
# print(set2)

set3 = set1 & set2
# print(set3)

count = 0
for n in set3:
    # print(n)
    if is_prime(n):
        # print(n)
        count += 1

print(count)

Measured memory_bytes: 5120
#include<iostream>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)

int n,h[110],c=0;

int a(){
  int C=0;
  bool k=0;
  fr(i,n+1){
    if(k){
      if(h[i]>0) h[i]--;
      else{
        C++;
        k=0;
      }
    }
    else{
      if(h[i]>0){
        h[i]--;
        k=1;
      }
    }
  }
  return C;
}

int main(){
  cin>>n;
  fr(i,n) cin>>h[i];
  h[n]=0;
  fr(i,100){
    c+=a();
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a500,b100,c50,total,result = 0;
  scanf("%d",&a500);
  scanf("%d",&b100);
  scanf("%d",&c50);
  scanf("%d",&total);

  for(int i50 = 0;i50<=c50;i50++){
    for(int i100 = 0;i100<=b100;i100++){
      for(int i500 = 0;i500<=a500;i500++){
        if(i500*500 + i100*100 + i50*50 == total){
          result++;
        }

      }
    }
  }
  printf("%d\n",result);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
    int n,x;
    x=0;
    scanf("%d",&n);
    int t[n];
    for(int i=0;i<n;i++)
    scanf("%d",&t[i]);
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            x+=t[i]*t[j];
        }
    }
      printf("%d\n",x);
        return 0;
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const long double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> s;
  // vlli d(n);
  // rep(i, 0, n)
  // {
  //   cin >> d[i];
  // }
  if (s[s.size() - 1] == '3')
  {
    cout << "bon" << endl;
  }
  else if (s[s.size() - 1] == '0' || s[s.size() - 1] == '1' || s[s.size() - 1] == '6' || s[s.size() - 1] == '8')
  {
    cout << "pon" << endl;
  }
  else
  {
    cout << "hon" << endl;
  }
}

// cout << fixed << setprecision(12) <<ans<< endl;


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

int main()
{
	int H, W, K;
	scanf("%d%d%d", &H, &W, &K);
	std::vector<std::string> board(H);
	for (auto& e: board) std::cin >> e;
	
	int prev{}, count{};
	using vi = std::vector<int>;
	std::vector<vi> ans(H, vi(W, -1));
	for (int row{}; row < H; row++)
	{
		int first{(int)board[row].find_first_of('#')};
		if (first == std::string::npos) continue;
		for (int r{prev}; r <= row; r++)
			std::fill(ans[r].begin(), ans[r].end(), count);
		for (int col{first + 1}; col < W; col++)
		{
			if ([&]()
				{
					for (int r{prev}; r <= row; r++)
						if (board[r][col] == '#')
							return true;
					return false;
				}()
			)
			{
				count++;
			}
			for (int r{prev}; r <= row; r++)
				ans[r][col] = count;
		}
		count++;
		prev = row + 1;
	}
	for (int col{}; col < W; col++)
		for (int row{prev}; row < H; row++)
			ans[row][col] = ans[prev - 1][col];
	for (auto& e: ans)
		for (int i{}; i < W; i++)
			printf("%d%c", e[i] + 1, i + 1 == W? '\n': ' ');

	return 0;
}

Measured memory_bytes: 1280
def warshall_floyd():
    for middle in range(10):
        for start in range(10):
            for end in range(10):
                costs[start][end] = min(costs[start][end], costs[start][middle] + costs[middle][end])


H, W = map(int, input().split())
costs = []

for i in range(10):
    costs.append(list(map(int, input().split())))

warshall_floyd()

# print(*costs, sep='\n')
ans = 0
for i in range(H):
    wall = list(map(int, input().split()))
    for num in wall:
        if num != -1:
            ans += costs[num][1]
print(ans)

Measured memory_bytes: 9152
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include <cmath>
//#include <bits/stdc++.h>
using namespace std;

int main(){
    string S,T;
    cin>>S>>T;
    int n=S.length();
    int m=T.length();
    T.pop_back();
    if (S==T) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;import java.io.*;import java.math.*;

public class Main
{

    public static void process()throws IOException
    {
        String s=" "+nln()+"ababab";
        if(s.charAt(3)==s.charAt(4) && s.charAt(5)==s.charAt(6))
            pn("Yes");
        else
            pn("No");
    }


       static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new AnotherReader();
        boolean oj = true;

        //oj = System.getProperty("ONLINE_JUDGE") != null;
        if(!oj) sc=new AnotherReader(100);

        long s = System.currentTimeMillis();
        int t=1;
        while(t-->0)
            process();
        out.flush();
        if(!oj)
            System.out.println(System.currentTimeMillis()-s+"ms");
        System.out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);System.out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    static boolean multipleTC=false;



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

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
    
    
    

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define INF 1<<28
#define MAX 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

typedef long long ll;

int n, a[100005];
int dp[MAX];

int main()
{
    FASTIO
    cin>>n;
    for(int i = 1; i <= n; i++)
        cin>>a[i];
    dp[1] = 0;
    for(int i = 2; i <= n; i++){
        dp[i] = dp[i-1] + abs (a[i] - a[i-1]);
        if(i > 2){
            dp[i] = min(dp[i], dp[i-2] + abs(a[i] - a[i-2]));
        }
    }
    cout << dp[n]<<endl;
    return 0;
}  


Measured memory_bytes: 1024
from bisect import bisect_left
A = [ord(i) - 97 for i in input()]

A = A + list(range(26))
A = A[::-1]

dp = [0] * 26
key = [[] for _ in range(26)]
val = [[] for _ in range(26)]
for i, a in enumerate(A) :
  x = min(dp) + 1
  dp[a] = x
  key[a].append(i)
  val[a].append(x)

ret = ''
x = dp[dp.index(min(dp))] + 1
pos = 10 ** 6
while True :
  for i in range(26) :
    if key[i][0] < pos :
      j = bisect_left(key[i], pos) - 1
      if val[i][j] == x - 1 :
        ret += chr(i + 97)
        pos = key[i][j]
        x -= 1
        break
  else :
    break

print(ret)

Measured memory_bytes: 68220