akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int r, g;
  cin >> r >> g;
  int ans = g*2 - r;
  cout << ans << endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n;
bool dp[11][11][11];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>n;
    string s;
    cin>>s;
    for(int i = 0; i < n; i++){
        int cur = s[i] - '0' + 1;
        for(int j = 1; j <= 10; j++){
            for(int k = 1; k <= 10; k++){
                dp[j][k][cur] |= dp[j][k][0];
            }
        }
        for(int k = 1; k <= 10; k++){
            dp[k][cur][0] |= dp[k][0][0];
        }
        dp[cur][0][0] |= 1;
    }
    int ct = 0;
    for(int i = 1; i <= 10; i++){
        for(int j = 1; j <= 10; j++){
            for(int k = 1; k <= 10; k++)
                ct += dp[i][j][k];
        }
    }
    cout<<ct<<endl;
    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using ull = unsigned long long;
using ll = long long;
using namespace std;

int main(void) {
    
    int n;
    cin >> n;
    vector<int> a(n);
    bool even = true;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];

        if (a[i] % 2 != 0){
            even = false;
        }
    }

    if (even == true) {
        cout << "second" << endl;
    } else {
        cout << "first" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3792
import math

a, b, C = map(int, input().split())
S = a * b * math.sin(C*math.pi/180) / 2
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(C*math.pi/180))
h = math.sin(C*math.pi/180) * b
print(f'{S:.5f}')
print(f'{a+b+c:.5f}')
print(f'{h:.5f}')



Measured memory_bytes: 5724
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int[] V = new int[N];
		int[] C = new int[N];
		for(int i = 0;i<N;i++) {
			V[i]=sc.nextInt();
		}
		for(int i = 0;i<N;i++) {
			C[i]=sc.nextInt();
		}
		sc.close();
		
		int sum=0;
		
		for(int i = 0;i<N;i++) {
			if(V[i]-C[i]>0) {
				sum+=V[i]-C[i];
			}
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
typedef long long  ll;
//typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set
// this for long double
#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define ld long double
#define kek cout<<endl; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
#define halt {cout<<-1; return 0;}
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const int N = 1010;
const int INF = 1e8;
const ll MOD1=1073741824;
const long double pi=3.1415926535;
using namespace std;
using namespace __gnu_pbds;
typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
string bin_rep(int n)
{
          string s="";
      for(int i=31;i>=0;i--)
   {
           if(n&(1<<i)) s+='1';
           else s+='0';
   }
   return s;
}
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 int n;
 cin>>n;
 vector<ll> v(n);
 map<ll,ll> m;
 ll sum=0;
 forn 
 {
           cin>>v[i];
           m[v[i]]++;
           sum+=v[i];
 }
 int q;
 cin>>q;
 ll a,b;
 while(q--)
 {
           cin>>a>>b;
           
           sum-=m[a]*a;
           ll cnt=m[b];
           m[b]+=m[a];
           cnt=m[b]-cnt;
           m[a]=0;
           sum+=cnt*b;
         //  cout<<m[b]<<" ";
           cout<<sum<<endl;
           
 }
 
         

    
 
 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

Measured memory_bytes: 10020
#include <stdio.h>
#include <string.h>
#include <math.h>

int main()
{
	int x,y,size;
	unsigned char arr[ 14 * 14 ];
	memset( arr, 0, 14 * 14 );
	while ( scanf("%d,%d,%d", &x, &y, &size ) != EOF ) {
		x+=2; y+=2;
		arr[ 14 * ( x - 1 ) + y ]++;
		arr[ 14 * x + y ]++;
		arr[ 14 * ( x + 1 ) + y ]++;
		arr[ 14 * x  + y - 1 ]++;
		arr[ 14 * x  + y + 1 ]++;
		if( size >= 2 ) {
			arr[ 14 * ( x - 1 ) + y - 1 ]++;
			arr[ 14 * ( x - 1 ) + y + 1 ]++;
			arr[ 14 * ( x + 1 ) + y - 1 ]++;
			arr[ 14 * ( x + 1 ) + y + 1 ]++;
		}
		if( size >= 3 ) {
			arr[ 14 * ( x - 2 ) + y  ]++;
			arr[ 14 * ( x + 2 ) + y  ]++;
			arr[ 14 * x + y - 2  ]++;
			arr[ 14 * x + y + 2  ]++;
		}
	}

	int cnt = 0;
	int maxv = 0;

	for( int i = 2; i < 12; i++ ) {
		for( int j = 2; j < 12; j++ ) {
			if( arr[ 14 * j + i ] == 0 ) {
				cnt++;
			}
			else if( maxv < arr[ 14 * j + i ] ) {
				maxv = arr[ 14 * j + i ] ;
			}
		}
	}

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

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

int main() {
 int a;
  int b;
  int c;
  int d;
  int e;
  int k;
  cin>>a>>b>>c>>d>>e>>k;
  if(e-a<=k){
    cout<<"Yay!"<<endl;
  }
  else {
    cout<<":("<<endl;
  }
}

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

using namespace std;

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

	int p_num = 0;
	for (int i = 0; i < S.size(); i++){
		if (S[i] == 'p'){
			p_num++;
		}
	}
	cout << floor(S.size() / 2) - p_num << endl;
	return 0;
}


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

namespace ConsoleApp110 {
    class Program {
        static void Main(string[] args) {
            long x = long.Parse(Console.ReadLine());

            long katamari_11 = 0;

            katamari_11 = (long)Math.Ceiling((double)x / 11);

            //11の塊を最後まで足した和
            long fullSum = 11 * katamari_11;

            if (fullSum - 5 < x) {
                Console.WriteLine(katamari_11 * 2);
            } else {
                Console.WriteLine(katamari_11 * 2 - 1);
            }

        }
    }
}


Measured memory_bytes: 11092
fun main(args: Array<String>) {
    val (k, s) = readLine()!!.split(" ").map(String::toInt)

    var ans = 0
    
    (0..k).forEach { x ->
        (0..k).forEach { y ->
            val z = s - x - y
            if (z in 0..k) {
                ans += 1
            }
        }
    }

    println(ans)
}

Measured memory_bytes: 40688
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i++)
#define pb push_back
#define vec vector
#define ref(a) &(a)

typedef long long ll;

using namespace std;

ll n;

ll solve() {
  ll res = 0;
  ll i = 2;
  if (n % 2 == 1) return 0;
  while (n >= i * 5) {
    i *= 5;
    res += n / i;
  }
  return res;
}

int main() {
  cin >> n;
  cout << solve() << endl;
  return 0;
}

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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;

lli n,k;

vll x,y;

map<lli,lli> zipx;
map<lli,lli> zipy;
vll unzipx;
vll unzipy;

mat field;
lli idx;
lli ans = LONG_MAX;

int main(){
  cin >> n >> k;
  x = vll(n);y = vll(n);
  for(lli i = 0;i < n;i++){
    cin >> x[i] >> y[i];
    zipx[x[i]] = 0;
    zipy[y[i]] = 0;
  }
  idx = 1;
  unzipx = vll(zipx.size()+1);
  unzipy = vll(zipy.size()+1);
  for(auto itr = zipx.begin();itr != zipx.end();itr++){
    itr->second = idx;
    unzipx[idx] = itr->first;
    idx++;
  }
  idx = 1;
  for(auto itr = zipy.begin();itr != zipy.end();itr++){
    itr->second = idx;
    unzipy[idx] = itr->first;
    idx++;
  }
  field = mat(zipx.size()+1,vll(zipy.size()+1,0));
  for(lli i = 0;i < n;i++){
    field[zipx[x[i]]][zipy[y[i]]] = 1;
  }
  for(lli i = 1;i <= zipx.size();i++){
    for(lli j = 1;j <= zipy.size();j++){
      field[i][j] += field[i-1][j];
    }
  }
  for(lli i = 1;i <= zipx.size();i++){
    for(lli j = 1;j <= zipy.size();j++){
      field[i][j] += field[i][j-1];
    }
  }
  for(lli xs = 1;xs <= zipx.size();xs++){
    for(lli xt = xs;xt <= zipx.size();xt++){
      for(lli ys = 1;ys <= zipy.size();ys++){
        for(lli yt = ys;yt <= zipy.size();yt++){
          if(field[xt][yt]-field[xs-1][yt]-field[xt][ys-1]+field[xs-1][ys-1] >= k){
            ans = min(ans,(unzipx[xt]-unzipx[xs])*(unzipy[yt]-unzipy[ys]));
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int N, sum_A = 0, sum_B = 0, ans;
  cin >> N;
  vector<int> cards(N);
  for(int i = 0; i < N; i++){
    cin >> cards.at(i);
  }
  sort(cards.begin(), cards.end());
  reverse(cards.begin(), cards.end());
  for(int j = 0; j < N; j += 2){
    sum_A += cards.at(j);
    if(j + 1 != N) sum_B += cards.at(j + 1);
  }
  ans = sum_A - sum_B;
  cout << ans << endl;
}

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

// --------------------------------------------------------------------------------
#define fast_IO	ios_base::sync_with_stio(false),cin.tie(NULL),cout.tie(NULL);
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------


void solve()
{
    int x,n;cin>>x>>n;
    set<int>st;
    int ans;
    frepi(1,n,1)
    {
    	int y;cin>>y;
    	st.insert(y);
    }
    for(int i=0;;++i)
    {
    	int x1 = x-i;
    	if(st.find(x1)==st.end())
    	{
    		ans=x1;
    		break;
    	}
    	int x2 = x+i;
    	if(st.find(x2)==st.end())
    	{
    		ans=x2;
    		break;
    	}
    }
    cout<<ans;
}

int main()
{
	// #ifndef ONLINE_JUDGE
 //    	freopen("/home/suryakant/input.txt","r",stdin);
 //        freopen("/home/suryakant/output.txt","w",stdout);
 //    #endif
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    
}

Measured memory_bytes: 3584
while 1:
    n=int(input())
    if n==0:break
    if n%1111==0:print("NA")
    else:
        count=0
        while 1:
            if n==6174:
                print(count)
                break
            else:
                n_min=[]
                for i in str(n).zfill(4):
                    n_min.append(i)
                n_min.sort()
                n_max=n_min[::-1]
                n=int("".join(n_max))-int("".join(n_min))
                count+=1


Measured memory_bytes: 5612
#include<cstdio>

char a;
int main()
{
  	a = getchar();
  	if(a == 'A') putchar('T');
  	if(a == 'T') putchar('A');
  	if(a == 'G') putchar('C');
  	if(a == 'C') putchar('G');
  	if(a == 'a') putchar('t');
  	if(a == 't') putchar('a');
  	if(a == 'g') putchar('c');
  	if(a == 'c') putchar('g');
  	return 0;
}

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

	int mod =1e9+7;


	int main() {

		#ifndef ONLINE_JUDGE
	        freopen("input.txt","r",stdin);
	        // freopen("output.txt","w",stdout);
	    #endif
	    ios::sync_with_stdio(false);
	    cin.tie(0);
	    cout.tie(0);  
	    int n;
	    cin>>n;

	    int arr[n];
	    ll sum[n+1];
	    sum[0]=0;
	    for(int i=0;i<n;i++){
	    	cin>>arr[i];
	    	sum[i+1]=sum[i]+arr[i];
	    	
	    }

	    ll ans=0;
	    for(int i=0;i<n;i++){
	    	int check=(sum[n]-sum[i+1])%mod;
	    	ans = ans+ 1LL* check *arr[i];
	    	ans%=mod;
	    }

	    cout<<ans<<endl;
	}


Measured memory_bytes: 5968
N=int(input())
alist=list(map(int,input().split()))

slist=[]
asum=0
for a in alist:
  asum+=a
  slist.append(asum)
#print(alist)
#print(slist)

dic_lp,dic_rp={},{}
lp,rp=0,2
for mp in range(1,N-2):
  #p1
  mindiff=slist[mp]
  while(lp<mp+1):
    sum1=slist[lp]
    sum2=slist[mp]-slist[lp]
    
    diff=abs(sum1-sum2)
    if mindiff>diff:
      lp+=1
      mindiff=diff
    else:
      lp-=1
      dic_lp[mp]=lp
      #print(mp,lp)
      break
    
  rp=max(rp,mp+1)
  mindiff=slist[-1]-slist[mp]
  while(rp<N):
    sum1=slist[-1]-slist[rp]
    sum2=slist[rp]-slist[mp]
    
    diff=abs(sum1-sum2)
    if mindiff>diff:
      rp+=1
      mindiff=diff
    else:
      rp-=1
      dic_rp[mp]=rp
      #print(mp,rp)
      break
    
min_diff=10**9
for mp in range(1,N-2):
  lp=dic_lp[mp]
  rp=dic_rp[mp]
  
  sum1=slist[lp]
  sum2=slist[mp]-slist[lp]
  sum3=slist[rp]-slist[mp]
  sum4=slist[-1]-slist[rp]
  #print(sum1,sum2,sum3,sum4)
  
  sum_list=[sum1,sum2,sum3,sum4]
  sum_list.sort()
  diff=sum_list[-1]-sum_list[0]
  #print(lp,mp,rp,diff)
  if diff<min_diff:
    min_diff=diff
    #print(min_diff)
  
print(min_diff)

Measured memory_bytes: 69736
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
#define FIRSTWIN do{cout << "Monocarp\n"; return 0;}while(0)
#define SECONDWIN do{cout << "Bicarp\n"; return 0;}while(0)
 
const int MAXN = 1e5+5;
const int MOD = 1e9+7;
const int INF = 1e9+1;

pair<LL,int> val[MAXN*4];
int dp[MAXN];
int trace[MAXN];

int N,M;
char S[MAXN];

void build(int node, int left, int right) {
    if (left == right) {
        if(left == N) val[node] = {0, left};
        else val[node] = {1e9,left};
        return;
    }

    int m = (left + right) / 2;
    build(node*2, left, m);
    build(node*2+1, m+1, right);

    val[node] = min(val[node*2], val[node*2+1]);
}

void update(int node, int left, int right, int i, int newval) {
    if(left == right) {
        assert(left == i);
        val[node].fi = newval;
        return;
    }

    int m = (left + right) / 2;
    if(i <= m) update(node*2, left, m, i, newval);
    else update(node*2+1, m+1, right, i, newval);

    val[node] = min(val[node*2],val[node*2+1]);
}

pair<LL,int> query(int node, int left, int right, int l, int r) {
    if (r < l) return {1e9, 1e9};
    if (r < left || right < l) return {1e9,1e9};

    if (l <= left && right <= r) return val[node];

    int m = (left + right) / 2;
    return min(query(node*2, left, m, l, min(m,r)), 
               query(node*2+1, m+1, right, max(m+1,l), r));
}


int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N >> M;
    cin >> S;

    build(1,0,N);
    for(int i = N-1; i >= 0; i--) {
        if(S[i] == '1') continue;
        auto p = query(1,0,N,i+1,min(N,i+M));
        if(p.fi == 1e9) RETURN(-1);
        dp[i] = dp[p.se]+1;
        update(1,0,N,i,dp[i]);
        trace[i] = p.se;
    }

    //fori(i,N+1) cout << trace[i] << endl;
    //return 0;

    int i = 0;
    while(i < N) {
        int j = trace[i];
        cout << j - i << ' ';
        i = j;
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 6528
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	cin >> s;
	int ans = 0;
	string tes = "CODEFESTIVAL2016";

	rep(i, tes.size()) {
		if (s[i] != tes[i]) {
			ans++;
		}
	}
	cout << ans << endl;



	return 0;
	
}





Measured memory_bytes: 256
#include<stdio.h>


int main(){

  int n, m, i, j, a[110][110], b[110], c;

  scanf("%d %d", &n, &m);

  for(i=1;i<=n;i++){
    for(j=1;j<=m;j++){
      scanf("%d", &a[i][j]);
    }
  }
  for(j=1;j<=m;j++){
    scanf("%d", &b[j]);
  }
  for(i=1;i<=n;i++){
    c=0;
    for(j=1;j<=m;j++){
      c += a[i][j]*b[j];
    }
    printf("%d\n", c);
  }
  
  return 0;
  
}

Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
int N,Y;
int main(){
	cin>>N>>Y;
	for(int i=0;i<=N;i++)
	for(int j=0;j<=N;j++){
	int k=N-i-j;

	if(k>=0 && i*10000+j*5000+k*1000==Y)
	{
	cout<<i<<" "<<j<<" "<<k;  return 0;
    }
    
}
	

	cout<<"-1"<<" "<<"-1"<<" "<<"-1";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O999")
//#define long long ll
const int INF=0x3f3f3f3f;
const int maxn=50000005;
using namespace std;

int main(){
	//freopen(".in", "r",stdin );
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(0);
	int n, k, ans=0;
	cin >> n >> k;
	string s;
	cin >> s;
	for(int i=1; i<s.size(); i++)
		ans+=s[i]==s[i-1];
	cout<<min(2*k+ans,n-1)<<endl;
	return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int N, M; cin >> N >> M;
    int sum = N*(N-1)/2 + M*(M-1)/2;
    cout << sum << endl;
}

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

int main(){
    int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2;

    int x=x2-x1,y=y2-y1;
    cout<<x2-y<<" "<<y2+x<<" "<<x1-y<<" "<<y1+x<<endl;
}

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

int main(void){
    int N,K; cin >> N >> K;
    int ans=0;
    vector<int> A;
    for(int i=0; i<N; i++){
        int a; cin >> a;
        A.push_back(a);
    }

    sort(A.begin(), A.end());
    for(int i=N-1; i>=N-K; i--){
        ans+=A[i];
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll A,B;
  cin>>A>>B;
  if(A==B) cout<<"Draw"<<endl;
  else if((A>B&&B!=1)||A==1) cout<<"Alice"<<endl;
  else cout<<"Bob"<<endl;
  return 0;
}
	

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
char p[501000];
int n, L[501000], R[501000];
long long res;
int main() {
	int i;
	scanf("%s", p);
	for (i = 0; p[i]; i++);
	n = i;
	for (i = 0; i <= n; i++) {
		if (i != 0 && p[i - 1] == '<')L[i] = L[i - 1] + 1;
	}
	for (i = n; i >= 0; i--) {
		if (i != n && p[i] == '>')R[i] = R[i + 1] + 1;
		res += max(L[i], R[i]);
	}
	printf("%lld\n", res);

}

Measured memory_bytes: 4608
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
typedef long long ll;
int main()
{
	ll ans,x,y;
	ans=0;
	cin>>x>>y;
	ll i=x;
	//cout<<n<<a<<b;
	while(i<=y){
		ans++;
		i=i*2;
	}
		
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import math

N = int(input())

def sosuu(num):
  if num == 2:
    return (True)
  else:
    numsq = int(math.sqrt(num))
    judge = True
    for i in range(numsq):
      if (num % (i + 2) == 0):
        judge = False
        break
    return (judge)

while True:
  if (sosuu(N) == False):
    N+=1
  else:
    break;

print(N)


Measured memory_bytes: 3060
fun main(args: Array<String>) {
    val a = readLine()!!.split(" ").map { it.toInt() }
    val h = readLine()!!.split(" ").map { it.toInt() }

    val spcl = a[1]
    val sort = h.sorted().reversed()

    val res = sort.drop(spcl).map { it.toLong() }
    println(res.sum())
}

Measured memory_bytes: 84860
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#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 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#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() {
    map<int, int> mp;
    cin >> N;
    REP(i, N) {
        cin >> A;
        mp[A]++;
    }
    for (auto x : mp) {
        if (x.second & 1)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8144
N, P = map(int, input().split())
S = input()

res = 0
if P == 2 or P == 5:
    for i in range(N):
        if int(S[i]) % P == 0:
            res += i + 1
else:
    mp = [0]*P
    mp[0] = 1
    cur = 0
    p10 = 1
    for c in S[::-1]:
        cur = (cur + int(c)*p10) % P
        res += mp[cur]
        mp[cur] += 1
        p10 *= 10
        p10 %= P

print(res)

Measured memory_bytes: 3500
#include<cstdio>
#include<algorithm>
#include<cstring>
#define rep(i, s, t) for(i = s; i <= t; ++i)

using namespace std;

int n, opt;
char s[200010];
int h[1<<26];

int main() {
	int now = 0, i, j;
	scanf("%s", s+1); n = strlen(s+1);
	memset(h, 0x3f, sizeof h); h[0] = 0;
	rep(i, 1, n) {
		now ^= 1 << s[i] - 'a';
		opt = h[now];
		for(j = 0; j < 26; ++j) opt = min(opt, h[now^(1<<j)]);
		++opt;
		//printf("%d %d\n", i, opt);
		h[now] = min(h[now], opt);
	}
	printf("%d\n", opt);
	return 0;
}

Measured memory_bytes: 262656
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
  long long n, i, j, k, a, b;
  cin >> n;
  vector<long long> v(n);
  long long ans=0;
  for(i=0; i<n; i++)
    cin >> v[i];
  sort(v.begin(), v.end());
  i=0;
  while(i<n-2)
  {
    a = v[i];
    j = i+1;
    while(j<n-1)
    {
    	if(v[j]==a)
    	{
    		j++;
    		continue;
    	}
    	else
    	{
    		b = v[j];
    		k = j+1;
		    while(k<n)
		    {
	    	  if(v[k]!=b && (a+b)>v[k])
	    	  {
	         	ans++;
	          }
	          k++;
	        }
        }
        j++;
    }
    i++;
  }
  cout << ans;
  return(0);
}

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


//TEMPLATE
#define pb                push_back
#define mp                make_pair
#define ll                long long
#define ld                long double
#define pii               pair <ll, ll>
#define piii              pair <ll, pii>
#define F                 first
#define S                 second

#define newline           printf("\n")
#define minusone          printf("-1\n")
#define zeroo             printf("0\n")
#define scl1(a)           scanf("%lld", &a)
#define scl2(a, b)        scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)     scanf("%lld %lld %lld", &a, &b, &c)
#define prl1(a)           printf("%lld\n", a)
#define prl2(a, b)        printf("%lld %lld\n", a, b)
#define ssl1(s)           scanf(" %[^\n]", s)
#define scd1(a)           scanf("%lf", &a)
#define scd2(a, b)        scanf("%lf %lf", &a, &b)
#define prd(a)            printf("%lf\n", a)
#define prld(a)           printf("%Lf\n", a)
#define prcase(cs)        printf("Case %lld: ", cs)
#define cin1(a)           cin >> a
#define cin2(a, b)        cin >> a >> b
#define cin3(a, b, c)     cin >> a >> b >> c
#define cin4(a, b, c, d)  cin >> a >> b >> c >> d
#define cot1(a)           cout << a << "\n"
#define cot2(a, b)        cout << a << " " << b << "\n"
#define cot3(a, b, c)     cout << a << " " << b << " " << c << "\n"
#define cot4(a, b, c, d)  cout << a << " " << b << " " << c << " " << d << "\n"
#define cotline           cout << "\n"
#define cotminus          cout << "-1\n"
#define cot0              cout << "0\n"
#define cotyes            cout << "YES\n"
#define cotno             cout << "NO\n"
#define cotcase(cs)       cout << "Case " << cs << ": "

#define reversed(s)       reverse(s.begin(), s.end())
#define asort(s)          sort(s.begin(), s.end())
#define dsort(s)          sort(s.rbegin(), s.rend())
#define all(s)            s.begin(), s.end()
#define uniq(s)           s.resize(distance(s.begin(),unique(s.begin(), s.end())))
#define found(s, x)       (s.find(x) != s.end())

#define for0(i, n)        for (i = 0; i < n; i++)
#define for1(i, n)        for (i = 1; i <= n; i++)
#define fora(i, a, b)     for (i = a; i <= b; i++)
#define forb(i, b, a)     for (i = b; i >= a; i--)
#define fori(it, s)       for(auto it = s.begin(); it != s.end(); it++)

#define FR                ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(a, x)          memset(a, x, sizeof a)
#define bitcount(n)       __builtin_popcountll(n)

//#define pi              3.1415926536
#define pi                acos(-1)

const ll INF = LLONG_MAX;
const ll SZ = 4e5+5;
const ll mod = 1e9+7;


//string s, s1, s2;
ll n, k, ans = 0;
ll a[SZ];
//ll b[SZ];



int main() {
    FR;
    ll cs = 0, tc = 1, x, y, z, i, j, g, p, q, sum = 0, c = 0, t = 0;
//    ll a, b, d;
//    string s, s1, s2;

    ll d, s;
    cin3(d, t, s);

    (s*t >= d) ? cout << "Yes\n" : cout << "No\n";

    return 0;
}



Measured memory_bytes: 3644
import numpy as np
import math
from collections import Counter
import sys

a, b,c,k = map(int, input().split()) 

total = 0

if a >= k:
    print(k)
    sys.exit()
else:
    if a+b >= k:
        print(a)
        sys.exit()
    else:
        if k-(a+b) <= c:
            total = a - (k- (a+b))
            print(total)
            sys.exit()
        else:
            total = a - c
            print(total)

Measured memory_bytes: 26968
import java.util.*;

public class Main {
    
    static int[] L;
    static int N;
    static int A;
    static int B;
    static int C;
    static int minMP = Integer.MAX_VALUE;
    
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();
        C = sc.nextInt();
        
        L = new int[N];
        for(int i = 0; i < N; i++){
            L[i] = sc.nextInt();
        }
        
        dfs(0, 0, 0, 0, 0);
        
        System.out.println(minMP);
        
    }
    
    static void dfs(int a, int b, int c, int i, int cost){
        
        if( i == N ){
            if( a == 0 || b == 0 || c == 0 ) return;
            cost -= 30;
            cost += Math.abs(A - a) + Math.abs(B - b) + Math.abs(C - c);
            minMP = Math.min(minMP, cost);
            return;
        }
        
        dfs(a, b, c, i+1, cost);
        dfs(a+L[i], b, c, i+1, cost+10);
        dfs(a, b+L[i], c, i+1, cost+10);
        dfs(a, b, c+L[i], i+1, cost+10);
        
    }
}


Measured memory_bytes: 24640
use strict;


my $a = <>;
my $b = <>;
my $ans = 0;


if (length($a) != length($b)) {
  die("string length does not match")
}


for (my $i=0; $i<length($a); $i++) {
  if (substr($a, $i, 1) ne substr($b, $i, 1)) {
    $ans += 1;
  }
}

print($ans);

Measured memory_bytes: 5288
H, W = map(int, input().split())
snuke = []
for i in range(H):
  snuke.append(list(input().split()))
for i in range(H):
  for j in range(W):
    if snuke[i][j] == "snuke":
      ans = [i, j]
      break

print(chr(65+ans[1])+str(ans[0]+1))


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

namespace AtCoder.Abc
{
    public class EijB
    {
        public static void Main(string[] args)
        {
            var c = new ConsoleInput(Console.In);
            int N = c.ReadInt;
            int count = 0;
            for (int i = 1; i <= N; i++)
            {
                int a = c.ReadInt;
                if (i % 2 == 0) continue;
                if (a % 2 == 0) continue;
                count++;
            }
            Console.WriteLine(count);

        }
        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: 27632
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int i,j,k,n,x,y,c=0;
    vector<pair<long long int,long long int>>v;
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
        cin>>x>>y;
        v.push_back({x,y});
    }
    sort(v.begin(),v.end());
    for(i=0;i<v.size();i++)
    {
        c+=v[i].second;
        if(c>=k)
        {
            cout<<v[i].first<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <ctime>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#include <cmath>
#include <functional>
#include <map>
#include <set>
using namespace std;
const long INF = 4000000000000000000;

typedef pair<long, long> P;
long n, a;
long x[50];
long y[50];

int main(){
	scanf("%ld%ld", &n, &a);
	for(long i = 0; i < n; i++){
		scanf("%ld%ld", &x[i], &y[i]);
	}
	//printf("%ld %ld\n", n, a);
	long xmin, xmax, ymin, ymax;
	long ans = INF;
	for(long i = 0; i < n-1; i++){
		for(long j = i; j < n; j++){
			xmin = min(x[i], x[j]);
			xmax = max(x[i], x[j]);
			for(long k = 0; k < n-1; k++){
				if(x[k] < xmin || x[k] > xmax/* || (y[k] >= ymin && y[k] <= ymax)*/){//順が関係するため不可
					continue;
				}
				for(long l = k; l < n; l++){
					if(x[l] < xmin || x[l] > xmax /*|| (y[l] >= ymin && y[l] <= ymax)*/){
						continue;
					}
					ymin = min(y[i], y[j]);
					ymin = min(y[k], ymin);
					ymin = min(y[l], ymin);
					ymax = max(y[i], y[j]);
					ymax = max(y[k], ymax);
					ymax = max(y[l], ymax);
					
					long count = 0;
					for(long m = 0; m < n; m++){
						if(x[m] >= xmin && x[m] <= xmax && y[m] >= ymin && y[m] <= ymax){
							count++;
						}
					}
					//printf("%ld\n", count);
					if(count >= a){
						ans = min(ans, (xmax-xmin)*(ymax-ymin));
						//printf("%ld %ld %ld %ld  %ld\n", i, j, k, l, (xmax-xmin)*(ymax-ymin));
					}
				}
			}
		}
	}
	printf("%ld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int N;
    scanf("%d", &N);
    int T[N];
    int sum = 0;
    for(int i = 0; i < N; i++){
        scanf("%d",&T[i]);
        sum += T[i];
    }
    int M;
    scanf("%d", &M);
    int P[M], X[M];
    for(int i = 0; i < M; i++){
        scanf("%d %d", &P[i], &X[i]);
    }
    
    for(int i = 0; i < M; i++){
        int time = sum;
        time -= T[P[i]-1];
        time += X[i];
        printf("%d\n",time);    
    }
    return 0;
}

Measured memory_bytes: 128
from collections import deque
H,W = map(int,input().split())
maze = []
dx = [1,0,-1,0]
dy = [0,1,0,-1]
ls = []
for i in range(H):
    tmp = list(input())
    maze.append(tmp)
    for j in range(W):
        if tmp[j] != "#":
            ls.append([i,j])
def bfs(sx,sy):
    INF = -1
    cost = [[INF]*W for _ in range(H)]
    P = deque()
    P.append([sx,sy])
    cost[sx][sy] = 0
    while len(P) != 0:
        p = P.popleft()
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] != "#" and cost[nx][ny] == INF:
                P.append([nx,ny])
                cost[nx][ny] = cost[p[0]][p[1]]+1
    return cost
def solve():
    ans = 0
    for i in ls:
        sx,sy = i[0],i[1]
        cs = bfs(sx,sy)
        for k in range(len(cs)):
            if max(cs[k]) > ans:
                ans = max(cs[k])
    return ans
print(solve())

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

char s[100];
int main() {
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	for (int i = 1; i < n; ++i) if (s[i] == 'A' && s[i + 1] == 'C') return printf("Yes\n"), 0;
	return printf("No\n"), 0;
}

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

int main(){
  string S;
  cin >> S;
  string T;
  cin >> T;
  vector<int> start(26,-1);
  vector<int> goal(26,-1);
  for(int i=0;i<S.size();i++){
    int a = S[i] - 'a';
    int b = T[i] - 'a';

    if(start[a] != -1 || goal[b] != -1){
      if(start[a] != b || goal[b] != a){
        cout << "No" << endl;
        return 0;
      }
    }
    else{
      start[a] = b;
      goal[b] = a;
    }
  }
  cout << "Yes" << endl;
}


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

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0;i < n;i++){
    cin >> a.at(i);
  }
  for(int i = 0;i < n-1;i++){
    a.at(i+1) = gcd(a.at(i),a.at(i+1));
  }
  cout << a.at(n-1) << endl;
}

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

int main()
{
	char s[5];
	cin >> s;

	int n1 = 0, n2 = 0;
	n1 = (s[0] - '0') * 10 + (s[1] - '0');
	n2 = (s[2] - '0') * 10 + (s[3] - '0');
	
	if ((n1 <= 12) && (n1 > 0) && (n2 <= 12) && (n2 > 0)) {
		cout << "AMBIGUOUS";
	}
	else if ((n1 <= 12) && (n1 > 0))
	{
		cout << "MMYY";
	}
	else if ((n2 <= 12) && (n2 > 0))
	{
		cout << "YYMM";
	}
	else
	{
		cout << "NA";
	}

	cout << endl;

	return 0;
	
}

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

void insertionSort(vector<int> a,int n){
  for(int i=0;i<n;++i){
    if(i!=n-1){
      cout << a[i] << " ";
    }else{
      cout << a[i] << endl;
    }
  }
  for(int i=1;i<=n-1;++i){
    int v=a[i];
    int j=i-1;
    while(j>=0 && a[j]>v){
      a[j+1]=a[j];
      j--;
    }
    a[j+1]=v;
    for(int i=0;i<n;++i){
      if(i!=n-1){
        cout << a[i] << " ";
      }else{
        cout << a[i] << endl;
      }
    }

  }
}

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

}



Measured memory_bytes: 3152
l = list(map(int,input().split()))
N = l[0]
K = l[1] 
S = input()
list_S = list(S)
if list_S[K-1] == 'A':
    list_S[K-1] = 'a'
elif list_S[K-1] == 'B':
    list_S[K-1] = 'b'
if list_S[K-1] == 'C':
    list_S[K-1] = 'c'
L = ''.join(list_S)
print(L)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector

int main(){
    int n,m;
    cin >> n >> m;
    ve<P> ab(n);
    rep(i,n){
        ll a,b;
        cin >> a >> b;
        ab[i] = P(a,b);
    }
    sort(ab.begin(), ab.end());
    int now = 0;
    ll ans = 0;
    int i = 0;
    while(now + ab[i].second < m){
        now += ab[i].second;
        ans += ab[i].first * ab[i].second;
        i++;
    }
    ans += ab[i].first * (ll)(m-now);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4748
w, h = (int(x) for x in input().split())
ab = []
for _ in range(h):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])
 
dp = [10000000000000 for i in range(w+1)]
 
for j in range(w+1):
    for i in range(h):
        if j <= ab[i][0]:
            dp[j] = min(dp[j], ab[i][1])
        else:
            dp[j] = min(dp[j], dp[j-ab[i][0]]+ab[i][1])
 
print(dp[w])

Measured memory_bytes: 44552
// i_m_arin

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef priority_queue<ll> pqll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef map<ll,ll> mpll;
typedef set<ll> stll;

#define f(i, a, n) 	for(ll i=a; i<(ll)n; i++)
#define f2(i, a, b) for(ll i=a; i<=(ll)b; i++)
#define pb 			push_back
#define ff 			first
#define ss 			second
#define pf			push_front
#define mp			make_pair
#define all(a)		(a).begin(),(a).end()
#define decimal(x)	fixed<<setprecision(x)
#define fsort(a)	sort(all(a))
#define rsort(a)	sort(all(a),greater<>())
#define fast_io		ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem0(a)		memset(a,0,sizeof(a))
#define mem1(a)		memset(a,-1,sizeof(a))
#define lcm(a,b)	(a*b)/__gcd(a,b)
#define ub(v,x)		upper_bound(all(v),x)-v.begin()
#define lb(v,x)		lower_bound(all(v),x)-v.begin()

const ld PI  = acos(-1);
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;
const ll SIZE= 100000;


void solve(){

ll n;
cin>>n;
ll a[n];
f(i,0,n) cin>>a[i];
ll suff[n+3];

f(i,0,n) suff[i]=0;

suff[n-1]=a[n-1];
for(ll i=n-2;i>=0;i--){
	suff[i]=(suff[i+1]+a[i])%MOD;
}

ll ans=0;

f(i,1,n){
	ans=(ans+(suff[i]*a[i-1]))%MOD;
}

cout<<ans<<endl;

}


int main(){
	fast_io;
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

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

#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define pb push_back
#define X first
#define Y second

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;

#ifdef umang99m
    #include "/home/umang/.templates/header.h"
#else
    #define dbg(args...)
    #define timer()
#endif

bool ispal(string s){
    ll n = s.length();
    dbg(s);
    for(int i=0; i<(n)/2; i++){
        if(s[i] != s[n-1-i]) return false;
    }
    return true;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    string s;
    cin>>s;
    ll n = s.length();
    bool ans = ispal(s) && ispal(s.substr(0,n/2)) && ispal(s.substr(n/2+1, n/2));
    if(ans) cout<<"Yes\n";
    else cout<<"No\n";

    timer();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if ((a*b) % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (size_t i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (size_t k = 1; k < v.size(); k++)
	{
		for (size_t j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int a;
	scanf("%d", &a);
	int L = a / 100;
	int R = a % 100;
	if (1 <= L && L <= 12)
	{
		if (1 <= R && R <= 12)
			printf("AMBIGUOUS\n");
		else
			printf("MMYY\n");
	}
	else
	{
		if (1 <= R && R <= 12)
			printf("YYMM\n");
		else
			printf("NA\n");
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,b) for(ll i=0;i<b;i++)
ll mod=1000000007;
#define vl vector<ll>
#define pl pair<ll,ll>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=b-1;i>=a;i--)
#define rsort(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(),(v).end()

ll w,h,x,y,ans=0;
int main() {
    cin>>w>>h>>x>>y;

    if((double)w/2.0==x&&(double)h/2.0==y)ans=1;
    cout<<(double)h*w/2.0<<" "<<ans<<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
ll c,k;
vector<ll> t;

void solve(){
    cin >> n >> c >> k;
    t.resize(n,0);
    rep(i,n){
        cin >> t[i];
    }
    sort(t.begin(),t.end());
    queue<ll> que;
    rep(i,n){
        que.push(t[i]);
    }
    int ans=0;

    while (!que.empty()){
        ll a=que.front();que.pop();
        ans+=1;
        if (que.empty()) break;
        rep(i,c-1){
            if (que.empty()) break;
            if (que.front()<=a+k) que.pop();
            else break;
        }
    }

    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 1920
//    >File Name: 2.cpp
//    > Author: Webwei

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

ll pw(int x){
	ll ans = 1;
	for(int i=1;i<=x;i++){
		ans*=2;
	}
	return ans;
}
int main()
{
	int n,m;
	cin >> n >> m;
	ll ans = 1900* m + 100*(n-m);
	ans  = ans *pw(m);
	cout << ans <<'\n';
	return 0;
}


Measured memory_bytes: 256