akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,P;
  cin>>N>>P;
  int ans=1,count=0,i=3;
  if(N==1)
    ans=P;
  else{
  if(P>1){
    while(1){
      if(P%2==0){
      count++;
      P/=2;
    }
    else{
      rep(j,0,count/N)
        ans*=2;
      count=0;
      break;
    }
    }
  while(1){
    if(i*i>P)
      break;
    if(P%i==0){
      count++;
      P/=i;
    }
    else{
      rep(j,0,count/N)
        ans*=i;
      count=0;
      i+=2;
    }
  }
    rep(j,0,(count+1)/N)
        ans*=i;
  }
  }
  cout<<ans;
  }




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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for(auto x : {1, 2, 4, 8, 16, 32, 64}) {
    if(x <= N) {
      ans = x;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
   int sum = 0;
   int i;
   char str[4];

   scanf("%s", str);
   for(i = 0; i < 4; i++) {
      if(str[i] == '+') {
         sum++;
      } else if(str[i] == '-') {
         sum--;
      } else {
         return -1;
      }
   }
   printf("%d\n", sum);
   return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string.h>
#include <math.h>
#include <vector>
using namespace std;

int main() {
    char S[6];
    cin >> S;
    
    if (S[2] == S[3] && S[4] == S[5]) {
        cout <<  "Yes";
    }
    else {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  string s;
  cin >> s;
  
  cout << s.substr(0, 4) << ' ' << s.substr(4) << endl;


  
  return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    m=I()
    ans=-1
    sm=0
    for i in range(m):
        d,c=MI()
        ans+=c
        sm+=d*c
    while sm>=10:
        ans+=sm//10
        sm=sm%10+sm//10
    
    print(ans)
    
        
                
                
    
        
        
        
        




if __name__=="__main__":
    main()


Measured memory_bytes: 74296
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define inf ((ll)1e18+5)
#define maxx ((ll)1e6+5)
#define pb push_back
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*
bool sv[maxx]={0};    // returns 0 if a num is prime
int sp[maxx]={0};     // gives smallest prime factor of the number
void Sieve() {for(int i= 2; i< maxx; i+= 2) sv[i]=1,sp[i] = 2;sv[2]=0;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll fact[1000007]={0}; // returns factorial of that number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
*/
using namespace std;
signed main(){
  fast;
 // usefile;
  //test
  {
    int n;
    cin>>n;
    bool flag=1;
    while(n--){
        int temp;
        cin>>temp;
        if(temp%2==0)
        {
            if(temp%3!=0&&temp%5!=0)
                flag=0;
        }
    }
    if(flag)
        cout<<"APPROVED";
    else
    {
        cout<<"DENIED";
    }
    
  }
  //time("");
  return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String str = br.readLine();
			if (str.equals("-")) break; 
			int m = Integer.parseInt(br.readLine());
			for (int i = 0; i < m; i++) {
				int h = Integer.parseInt(br.readLine());
				str = str.substring(h, str.length()) + str.substring(0, h);
			}
			System.out.println(str);
		}
	}
}

Measured memory_bytes: 24556
using System;

namespace Atcoder
{
    class Program
    //ABC127 B - Algae
    {
        private static void Main(string[] args)
        {
            var rdx = Console.ReadLine().Split(' ');
            var r = int.Parse(rdx[0]);
            var d = int.Parse(rdx[1]);
            long x = long.Parse(rdx[2]);

            long ans = 0;

            for (var i = 0; i < 10; i++)
            {
                ans = r * x - d;
                x = ans;
                Console.WriteLine(ans);
            }

        }
    }
}


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

int main() {
  int s1s2s3,s1,s2,s3;
  cin>>s1s2s3;
  s1=s1s2s3/100;
  s2=(s1s2s3-s1*100)/10;
  s3=(s1s2s3-s1*100-s2*10);
  cout<<s1+s2+s3<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MOD 1000000007
#define pb push_back
ll pwr(ll a, ll b){
    if(b == 0)
        return 1 ;
    ll c = pwr(a, b/2) ;
    c = c * c;
    if(b % 2)
        return c*a;
    return c ;
}
ll pwr(ll a, ll b, ll m){
    if(b == 0)
        return 1;
    ll c = pwr(a, b/2, m) % m ;
    c = (c * c) % m;    
    if(b % 2)
        return (c * a%m) % m;
    return c ;
}

int main(){
    #ifndef ONLINE_JUDGE    
    freopen("../../input", "r", stdin);
    freopen("../../output", "w", stdout);
    #else
    // online submission
    #endif

    boost
    int tt = 1;
    // cout << 0 << endl;
    // cin >> tt;
    while(tt--){
        ll d, t, s;
        cin >> d >> t >> s;
        // double x = d / t;
        if(s * t >= d) cout << "Yes";
        else cout << "No";
        // cout << "hi";
    }

}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<20;

int t[]={9,2,5,5,4,5,6,3,7,6};

string f(string s,string t){
    if(s.length()>t.length()) return s;
    else if(s.length()<t.length()) return t;
    else return (s>t?s:t);
}

int main(){
    int n,m;cin >> n >> m;
    vector<int> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }
    vector<string> dp(n+100,"");
    for (int i = 0; i < n; i++) {
        if(dp[i]==""&&i!=0) continue;
        for (int j = 0; j < m; j++) {
            dp[i+t[a[j]]]=f(dp[i+t[a[j]]],dp[i]+to_string(a[j]));
        }
    }
    cout << dp[n] << endl;
    return 0;
}



Measured memory_bytes: 33024
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#define INF 100000000

using namespace std;
typedef long long ll;

int main(){
    
    int m,n;
    char c;
    double X=0,Y=0;
    double now=90;
    while(cin>>m>>c>>n && (m!=0 || n!=0)){
//        cout<<now*(2*M_PI/360)<<endl;
        
        X+=m*cos(now*(2*M_PI/360));
        Y+=m*sin(now*(2*M_PI/360));
        now-=n;
    }
    printf("%d\n",(int)X);
    printf("%d\n",(int)Y);
    return 0;
}

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

int main(){
	int p,n,a=0,b=0,c=0;
	while (true){
		char s;
		cin>>p>>s>>n;
		if (cin.eof()) break;
		a += p*n;
		b += n;
		c++;
	}
	cout<<a<<endl;
	cout<<(int)(0.5+1.0*b/c)<<endl;
}

Measured memory_bytes: 1160
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,d=nii()

cnt=0
for i in range(n):
  x,y=nii()
  if x**2+y**2<=d**2:
    cnt+=1

print(cnt)

Measured memory_bytes: 9176
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        h: usize,
        w: usize,
        s: [chars; h],
    }
    let mut ans = 1;
    for i in 0..h {
        for j in 0..w {
            if s[i][j] == '#' {
                continue;
            }
            let mut s = s.clone();
            let mut q = std::collections::VecDeque::new();
            s[i][j] = '#';
            q.push_back((i, j, 0));
            while let Some((i, j, d)) = q.pop_front() {
                ans = std::cmp::max(d, ans);
                for &(x, y) in [(i + 1, j), (i - 1, j), (i, j + 1), (i, j - 1)].iter() {
                    if x < h && y < w && s[x][y] == '.' {
                        s[x][y] = '#';
                        q.push_back((x, y, d + 1));
                    }
                }
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    for i in range(1, 1000000):
        tax_A = int(i * 108 / 100 - i)
        tax_B = int(i * 110 / 100 - i)
        if tax_A == A and tax_B == B:
            print(i)
            return
        else:
            continue
    print(-1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	getchar();
	char str[a][b];
	char map[100][100];
	memset(map,'#',sizeof(map));
	for(int i=0;i<a;i++){
		for(int j=1;j<=b;j++){
			cin>>str[i][j];
		}
		getchar();
	}
	for(int i=0;i<b+2;i++)
		cout<<'#';
	cout<<endl;
	for(int i=0;i<a;i++){
		for(int j=0;j<b+2;j++){
			if(j==0||j==b+1){
				cout<<'#';
				if(j==b+1)
				cout<<endl;
			}
			else{
				cout<<str[i][j];
			}
		}
	} 
	for(int i=0;i<b+2;i++)
		cout<<'#';
}

Measured memory_bytes: 256
import sys

def doubleS(s):
    if len(s) % 2 == 1: return False
    L = len(s)
    for i in range(L // 2):
        if s[i] != s[L // 2 + i]:
            return False
    return True

def solve():
    input = sys.stdin.readline
    S = list(input().strip("\n"))
    N = len(S)
    S.pop()
    for i in range(N):
        if doubleS(S):
            print(N - i - 1)
            break
        S.pop()
    else: print(0)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lower_bound lowb
#define upper_bound upb
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	string s, t;
	cin >> s >> t;
	cout << t + s << endl;
	return 0;
}

Measured memory_bytes: 256
function main()
	H,W,K=map(x->parse(Int,x),split(readline()))
	s=String[]
	for _=1:H
		push!(s,readline())
	end
	ans=0
	for b=0:2^(H+W)-1
		x=0
		for i=0:H*W-1
			if (b>>(div(i,W)+W))%2==(b>>(i%W))%2==1&&s[div(i,W)+1][i%W+1]=='#'
				x+=1
			end
		end
		if x==K
			ans+=1
		end
	end
	println(ans)
end
main()


Measured memory_bytes: 167132
blue = [input() for _ in range(int(input()))]
red = [input() for _ in range(int(input()))]

from collections import Counter

bc = Counter(blue)
rc = Counter(red)
c = (bc - rc)
print(max([x[1] for x in filter(lambda x: x[1] > 0, c.items())] or [0]))

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> board(H);
    for (int i = 0; i < H; ++i) {
        cin >> board.at(i);
    }

    vector<bool> row(H, false);
    vector<bool> col(W, false);
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (board.at(i).at(j) == '#') {
                row.at(i) = true;
                col.at(j) = true;
            }
        }
    }

    for (int i = 0; i < H; ++i) {
        if (row.at(i) == true) {
            for (int j = 0; j < W; ++j) {
                if (col.at(j) == true) {
                    cout << board.at(i).at(j);
                }
            }
            cout << endl;
        }
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
	ll n,x,t,r;
	cin>>n>>x>>t;
	if(n%x!=0)
	{
		r=(n/x)+1;
	}
	else
	{
		r=n/x;
	}
	cout<<r*t<<endl;
	return;
	
}





		int main()
		{
#ifndef ONLINE_JUDGE
			// for getting input from input.txt
			freopen("input.txt", "r", stdin);
			// for writing output to output.txt
			freopen("output.txt", "w", stdout);
#endif

			int t=1;
			//cin >> t;

			while (t--)
			{
				solve();
			}
			return 0;
		}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;

int N;
int T[110000]={},Tmax=0;
int A[110000]={},Amax=0;
long long int P[110000]={}; // 高さ、確定か

int main()
{
	
	cin >> N;
	
	int ansF = 0;
	int flag=0;
	for(int i=0; i<N; i++) {
		cin >> T[i];
		P[i] = ((flag != T[i])? 1: T[i]);
		flag = T[i];
	}
	for(int i=0; i<N; i++) {
		cin >> A[i];
	}
	
	flag = 0;
	for(int i=N-1; i>=0; i--) {
		if(flag != A[i] && P[i] == 1 && A[i] != T[i]) {
			ansF = 1;
		}
		if(flag != A[i] && A[i] > T[i]) {
			ansF = 2;
		}
		
		P[i] = ((flag != A[i])? 1: min(P[i], (long long int)A[i]));
		flag = A[i];
	}
	
	if(ansF >= 1){
		cout << 0 << endl;
		return 0;
	}
	
	long long int waru = pow(10,9) + 7;
	long long int ans = 1;
	for(int i=0; i<N; i++) {
		ans *= P[i];
		ans %= waru;
	}
	cout << ans << endl;
	
	return 0;
}



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

int main() {
	string s,t;
	cin>>s>>t;
	string s1;
	for(int i=0;i<(int)t.length()-1;i++) {
		s1+=t[i];
	}
	if(s1==s) {
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;

int main(){
    string s;
    cin >> s;
    if(s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}


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

using namespace std;

int main ()
{
	int n;
	string s;
	cin >> n >> s;
	if (n % 2 == 1){
		cout << "No" << endl;
		return 0;
	}
	for (int i=0, j=n/2; i<n/2, j<n; i++, j++){
		if (s[i] == s[j]){
			continue;
		}
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
ll gcd(ll a, ll b) {
    if(a < b) swap(a, b);
    if(a % b == 0) return b;
    return gcd(a % b, b);
}

int main() {
    ll N;
    cin >> N;
    ll A[N];
    for(int i = 0; i < N; i++) cin >> A[i];
    ll ans = A[0];
    for(int i = 1; i < N; i++) ans = gcd(ans, A[i]);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if (a == 1 && b == 1 || c == 1) {
        printf("Open\n");
    }
    else if (a == 0 && b == 0 && c == 1) {
        printf("Open\n");
    }
    else {
        printf("Close\n");
    }
    return 0;

}
   

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


int main() {
	long long N;
	long long A, B, C, D, E;
	cin >> N;
	cin >> A >> B >> C >> D >> E;

	long long MinMove = min({ A,B,C,D,E });

	long long ans = ((N + MinMove - 1) / MinMove) + 4;

	cout << ans << endl;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace LogicSummoner
{
    class Program
    {
        static void Main(string[] args)
        {
            var nums = GetNumbersInt();
            var list = new List<int[]>();
            for (int i = 0; i < nums[0]; i++)
            {
                var line = GetNumbersInt(nums[1]);
                list.Add(line);
            }

            var b = Enumerable.Range(0, nums[1]).Select(x => GetNumber()).ToArray();
            foreach (var l in list)
            {
                var sum = 0;
                for (int i = 0; i < b.Length; i++)
                {
                    sum += l[i] * b[i];
                }
                System.Console.WriteLine(sum);
            }
        }

        //static StreamReader Console = new StreamReader("input.txt");

        static int GetNumber()
        {
            return int.Parse(Console.ReadLine().Trim());
        }

        static double GetDounble()
        {
            return double.Parse(Console.ReadLine().Trim());
        }

        static int[] GetNumbersInt(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static long[] GetNumbersLong(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToArray();
        }

        static double[] GetNumbersDouble(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => double.Parse(x)).ToArray();
        }

        static string[] GetStrings(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToArray();
        }
    }
}

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

ll dp[11000][110][2];

int main() {
  string s;
  getline(cin,s);
  int m;
  cin>>m;
  for(int i = 0; i < 11000; i++) for(int j = 0; j < 110; j++) {dp[i][j][0]=0LL;dp[i][j][1]=0LL;}
  dp[0][0][0]=1LL;
  int l = s.size();
  for(int i = 1; i <= l; i++) {
    int t = s[i-1]-'0';
    for(int j = 0; j < m; j++){
      for(int k = 0; k < 10; k++){
        if(k<t) dp[i][(j+k)%m][1]=(dp[i][(j+k)%m][1]+dp[i-1][j][0])%mod;
        if(k==t) dp[i][(j+k)%m][0]=(dp[i][(j+k)%m][0]+dp[i-1][j][0])%mod;
        dp[i][(j+k)%m][1]=(dp[i][(j+k)%m][1]+dp[i-1][j][1])%mod;
      }
    }
  }
  ll ans = (dp[l][0][0]+dp[l][0][1]-1)%mod;
  if(ans<0LL)ans+=mod;
  cout<<ans<<endl;
}
    

Measured memory_bytes: 19200
#https://atcoder.jp/contests/abc100/submissions/2677366
#絶対値の最大化→-1をかけて普通にソート!!!
N, M = map(int, input().split())
xyz = [list(map(int, input().split())) for i in range(N)]
sign = [-1,1]
ans = 0
for a in sign:   #x,y,zについて-1と1だから全8通り
    for b in sign:
        for c in sign:
            s = []    
            for x, y, z in xyz:   #そのときのxとyとzの和をlistに
                s.append(x*a + y*b + z*c)
            s.sort(reverse=True)  #ソート
            ans = max(ans,sum(s[:M])) #8通りの中での最大値を求める
print(ans)

Measured memory_bytes: 3316
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

import heapq
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
A = LIST()

for i in range(N):
    A[i] = -1 * A[i]
heapq.heapify(A)
for i in range(M):
    m = heapq.heappop(A) * (-1)
    m = m // 2
    heapq.heappush(A, -1 * m)
A = list(map(lambda x: x * (-1), A))
print(sum(A))
    


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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;

    // xy[0] = -, xy[1] = 0, xy[2] = +
    // xy[i][0] は最小値，xy[i][1] は最大値
    vector<vector<double>> x(3), y(3);
    for (int i = 0; i < n; ++i) {
        double xx, yy;
        char d;
        cin >> xx >> yy >> d;

        int idx_x = 1, idx_y = 1;
        if (d == 'R') idx_x = 2;
        else if (d == 'L') idx_x = 0;
        else if (d == 'U') idx_y = 2;
        else if (d == 'D') idx_y = 0;

        if (x[idx_x].size() == 0) { x[idx_x].push_back(xx); x[idx_x].push_back(xx); }
        else { x[idx_x][0] = min(x[idx_x][0], xx); x[idx_x][1] = max(x[idx_x][1], xx); }

        if (y[idx_y].size() == 0) { y[idx_y].push_back(yy); y[idx_y].push_back(yy); }
        else { y[idx_y][0] = min(y[idx_y][0], yy); y[idx_y][1] = max(y[idx_y][1], yy); }
    }

    vector<double> times = {0};
    for (auto x_i : x[0]) for (auto x_j : x[1]) if (x_j < x_i) times.push_back(x_i - x_j); // x_i - t = x_j
    for (auto x_i : x[0]) for (auto x_j : x[2]) if (x_j < x_i) times.push_back(0.5 * (x_i - x_j)); // x_i - t = x_j + t
    for (auto x_i : x[1]) for (auto x_j : x[2]) if (x_j < x_i) times.push_back(x_i - x_j); // x_i = x_j + t

    for (auto y_i : y[0]) for (auto y_j : y[1]) if (y_j < y_i) times.push_back(y_i - y_j);
    for (auto y_i : y[0]) for (auto y_j : y[2]) if (y_j < y_i) times.push_back(0.5 * (y_i - y_j));
    for (auto y_i : y[1]) for (auto y_j : y[2]) if (y_j < y_i) times.push_back(y_i - y_j);


    const double INF = numeric_limits<double>::max();
    const double NINF = numeric_limits<double>::lowest();

    auto f = [&](const double t) {
        pair<double, double> seg_x(INF, NINF), seg_y(INF, NINF);

        for (int i = 0; i < 3; ++i) {
            for (auto x_i : x[i]) {
                seg_x.first = min(seg_x.first, x_i + (i - 1) * t);
                seg_x.second = max(seg_x.second, x_i + (i - 1) * t);
            }
            for (auto y_i : y[i]) {
                seg_y.first = min(seg_y.first, y_i + (i - 1) * t);
                seg_y.second = max(seg_y.second, y_i + (i - 1) * t);
            }
        }
        return (seg_x.second - seg_x.first) * (seg_y.second - seg_y.first);
    };

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

    double min_v = f(0);
    for (size_t i = 0; i + 1 < times.size(); ++i) {
        double lb = times[i], ub = times[i + 1];

        for (int i = 0; i < 200; ++i) {
            const double t1 = (2.0 * lb + ub) / 3.0;
            const double t2 = (lb + 2.0 * ub) / 3.0;

            if (f(t1) > f(t2)) lb = t1;
            else ub = t2;
        }

        min_v = min(min_v, f(lb));
    }

    cout << min_v << endl;

    return 0;
}


Measured memory_bytes: 256
n, m, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
bs = gets.split.map(&:to_i)

temp_ans = 0
list = []
sum = 0
as.each do |a|
  if sum + a <= k
    temp_ans += 1
    sum += a
    list << a
  else
    break
  end
end

ans = temp_ans

bs.each do |b|
  while sum + b > k do
    if list.empty?
      puts ans
      exit
    end
    a = list.pop
    sum -= a
    temp_ans -= 1
    ans = [ans, temp_ans].max
  end
  if sum + b <= k
    temp_ans += 1
    ans = [ans, temp_ans].max
    sum += b
  else
    puts ans
    exit
  end
end
puts ans

Measured memory_bytes: 41512
#include <stdio.h>

int main()
{
	int m,f,b;

	scanf("%d%d%d",&m,&f,&b);

	if(m>b) printf("0\n");
	else if(m+f>=b) printf("%d\n",b-m);
	else  if(m+f<b)printf("NA\n");

	

	return 0;
}



Measured memory_bytes: 2140
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
typedef struct node *Node;
#define NIL NULL
Node root;
Node treeMinimum(Node a);
Node treeMaximum(Node a);
Node treeSuccessor(Node a);
void treeDelete(Node a);
void insert(int k);
void inorder(Node u);
void preorder(Node u);
int main(){
       int n,i,x;
       char com[20];
       scanf("%d",&n);
       
       for(i = 0 ; i<n; i++){
	 scanf("%s",com);
	 

        if(com[0] == 'i'){
	 scanf("%d",&x);
	 insert(x);
       }
       else {
	 inorder(root);
	 printf("\n");
	 preorder(root);
	 printf("\n");
	 
       }

     }
     return 0;
   }



Node treeMinimum(Node a){
  while(a->left!=NIL){
    a = a->left;
  }
  return a;
}

Node treeMaximum(Node a){
  while(a->right!=NIL){
    a = a->right;
  }
  return a;
}


Node treeSuccessor(Node a){
  if(a->right != NIL) return treeMinimum(a->right);
  Node y;
  y = a->p;
  while(y != NIL && a == y->right){
    a = y;
    y = y->p;
  }
  return y;
}

void treeDelete(Node a){
  Node y;
  Node x;
  if(a->left ==NIL || a->right==NIL)y=a;
  else{
    y = treeSuccessor(a);
  }
  if(y->left!=NIL)x = y->left;
  else {
    x = y->right;
  }

    if(x != NIL)x->p = y->p;
  if(y->p == NIL)root = x;
  else if(y==y->p->left) y->p->left = x;
  else{
    y->p->right = x;
  }
  if(y!=a)a->key = y->key;
}


 void insert(int k){
   Node y = NIL;
   Node x = root;
   Node z;

   z = malloc(sizeof(struct node));
   z ->key = k;
   z ->left = NIL;
   z ->right = NIL;

   while(x!= NIL){
     y= x;
     if(z->key < x->key) x= x->left;
   else{
     x = x->right;
 }
   }
     z->p = y;

     if(y == NIL) root =z;
     else if(z->key < y->key) y->left = z;
     else {
       y ->right =z;
     }
 }


 void inorder(Node u){
   if(u != NIL){
     inorder(u->left);
     printf(" %d", u->key);
     inorder(u->right);
   }
   else{
     return;
   }
 }

   void preorder(Node u){
     if(u!=NIL){
       printf(" %d",u->key);
       preorder(u->left);
       preorder(u->right);
     }
     else{
       return;
     }
   }



Measured memory_bytes: 25136
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    s=readline().strip()

    mod=10**9+7
    n=len(s)
    dp=[[0]*4 for _ in range(n+1)]
    dp[0][0]=1
    for i in range(1,n+1):
        #i文字目を選ばない
        for j in range(4):
            if s[i-1]!="?":
                dp[i][j]+=dp[i-1][j]
            else:
                dp[i][j]+=dp[i-1][j]*3

        #i文字目を選ぶ
        if s[i-1]=="A":
            dp[i][1]+=dp[i-1][0]
        elif s[i-1]=="B":
            dp[i][2]+=dp[i-1][1]
        elif s[i-1]=="C":
            dp[i][3]+=dp[i-1][2]
        elif s[i-1]=="?":
            dp[i][1]+=dp[i-1][0]
            dp[i][2]+=dp[i-1][1]
            dp[i][3]+=dp[i-1][2]

        for j in range(4):
            dp[i][j]%=mod
            
    print(dp[n][3])
if __name__=="__main__":
    main()

Measured memory_bytes: 54124
/*
 
 * This code is written by Sanskar Agarwal
 
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

#define ll long long
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define VPLL vector<PLL>
#define VPII vector<PII>
#define PQ priority_queue<PLL,VPLL, greater<PLL> > 
#define PQI priority_queue<PII,VPII,greater<PII> >
#define S second
#define F first
#define PB push_back

int dp[100000];

int solve(int x,vector<int> v[])
{
    if(v[x].size()==0)
        return dp[x]=1;
    if(dp[x]!=-1)
        return dp[x];

    int maxi=0;
    for(int i=0;i<v[x].size();i++)
    {
        maxi=max(maxi,1+solve(v[x][i],v));
    }
    return dp[x]=maxi;
}

int main()
{
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n,m;
    cin>>n>>m;
    vector<int> v[n];
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        x--;y--;
        v[x].PB(y);
    }
    memset(dp,-1,sizeof dp);
    int maxi=0;
    for(int i=0;i<n;i++)
    {
        int sz=solve(i,v);
        sz--;
        if(sz>maxi)
            maxi=sz;
    }
    cout << maxi;

    
   
    return 0;
}


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

#include <iostream>

class BEasyLinearProgramming {
public:
    void solve(std::istream& in, std::ostream& out) {
        long long a, b, c, k;
        in >> a >> b >> c >> k;
        if(k <= a){
            out << k << std::endl;
        }else if(a < k && k <= a+b){
            out << a << std::endl;
        }else{
            out << a-(k-(a+b)) << std::endl;
        }
    }
};


int main() {
    BEasyLinearProgramming solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3636
n, x, m = [int(x) for x in input().split()]
A = [x]
while len(A) < n:
    a = (A[-1] * A[-1]) % m
    if a not in A:
        A.append(a)
    else:
        i = A.index(a)
        loop_len = len(A) - i
        print(sum(A[:i]) + sum(A[i:]) * ((n - i) // loop_len) + sum(A[i:i + ((n - i) % loop_len)]))
        break
else:
    print(sum(A))


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

string s[3];
long long dp[2][51];

void solve(){
	int t = s[0].size();
	rep(i,2) rep(j,51) dp[i][j] = 0;
	for(int i = t-1; i >= 0; i--){
		rep(j,10){
			if(s[0][i] != '?') j = s[0][i]-'0';
			if(i == 0 && j == 0) continue;
			rep(k,10){
				if(s[1][i] != '?') k = s[1][i]-'0';
				if(i == 0 && k == 0) continue;
				rep(l,10){
					if(s[2][i] != '?') l = s[2][i]-'0';
					if(i == 0 && l == 0) continue;
					
					if(i == t-1){
						if(j+k == l) dp[0][i]++;
						if(j+k == l+10) dp[1][i]++;
					} else{
						if(j+k == l){
							dp[0][i] += dp[0][i+1];
							if(dp[0][i] > mod) dp[0][i] -= mod;
						}
						if(j+k == l-1){
							dp[0][i] += dp[1][i+1];
							if(dp[0][i] > mod) dp[0][i] -= mod;
						}
						if(j+k == l+10){
							dp[1][i] += dp[0][i+1];
							if(dp[1][i] > mod) dp[1][i] -= mod;
						}
						if(j+k == l+10-1){
							dp[1][i] += dp[1][i+1];
							if(dp[1][i] > mod) dp[1][i] -= mod;
						}
					}
					
					if(s[2][i] != '?') break;
				}
				if(s[1][i] != '?') break;
			}
			if(s[0][i] != '?') break;
		}
	}
	cout << dp[0][0] << endl;
}

int main(){
	while(cin >> s[0] >> s[1] >> s[2]){
		solve();
	}
}

Measured memory_bytes: 1184
N,M,X,Y = map(int,input().split(" "))
x = [int(i) for i in input().split(" ")]
y = [int(i) for i in input().split(" ")]
x.append(X)
y.append(Y)
x_max = max(x)
y_min = min(y)
if x_max<y_min:
  print("No War")
else:
  print("War")

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

typedef long long ll;

int main()
{

	ll n;
	cin>>n;

	ll a[n+5];
	ll b[n+1];

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

	for (ll i = 0; i < n; ++i)
	{
		cin>>b[i];
	}

	ll cnt=0;
	for(ll i=0;i<n;i++)	
	{	
		ll minval = min(a[i],b[i]);
		b[i]-=minval;
		a[i]-=minval;
		cnt+=minval;

		minval = min(a[i+1],b[i]);
		b[i]-=minval;
		a[i+1]-=minval;
		cnt+=minval;
	}

	cout<<cnt<<'\n';
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

const ll MOD = (ll)(1e9+7);
int nextInt() { int x; scanf("%d", &x); return x;}



const int SZ = 312345;
ll inv[SZ];
ll fact[SZ];
ll fact_inv[SZ];
ll choose(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  return fact[n] * fact_inv[n-r] % MOD * fact_inv[r] % MOD;
}

ll H(int n, int m) {
  if (n == 0) return 1;
  if (n < 0) return 0;
  return choose(n+m-1, m-1);
}

int main2() {
  int N = nextInt();
  int K = nextInt();

  int B = K;
  int R = N - K;

  for (int i = 1; i <= B; i++) {
    ll ans = 0;
    ans = H(R-(i-1), i+1) * choose(B-1, i-1) % MOD;
    ans %= MOD;
    cout << ans << endl;
  }
  return 0;
}

int main() {
  inv[1] = 1;
  for (int i = 2; i < SZ; i++) inv[i] = inv[(int) (MOD % i)] * (MOD - MOD / i) % MOD;
  fact[0] = 1;
  for (int i = 1; i < SZ; i++) fact[i] = fact[i-1] * i % MOD;
  fact_inv[0] = 1;
  for (int i = 1; i < SZ; i++) fact_inv[i] = fact_inv[i-1] * inv[i] % MOD;


#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 7552
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=list(input())

point={
    "s":r,
    "r":p,
    "p":s,
    "n":0
}

ans=0
result=[]

for i in range(k):
    ans+=point[t[i]]
    result.append(t[i])

for i in range(k,n):
    if t[i]==result[i-k]:
        result.append("n")
    else:
        ans+=point[t[i]]
        result.append(t[i])


print(ans)

Measured memory_bytes: 4792
N = input()
N = int(N)
a = N//10
a = a*10
b = N - a
if b == 2:
    print('hon')
if b ==4:
    print('hon')
if b == 5:
    print('hon')
if b == 7:
    print('hon')
if b == 9:
    print('hon')
if b == 3:
    print('bon')
if b == 0:
    print('pon')
if b == 1:
    print('pon')
if b == 6:
    print('pon')
if b == 8:
    print('pon')

Measured memory_bytes: 9160
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 x = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        
        long ans = Math.abs(x - a[0]);
        for(int i = 1; i < n; i++){
            ans = gcd(ans, Math.abs(x - a[i]));
        }
        
        System.out.println(ans);
    }
    
    private static long gcd(long a, long b){
        
        if(b == 0){
            return a;
        }else{
            return gcd(b, a % b);
        }
    }
}

Measured memory_bytes: 46928
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>

using namespace std;
#define MAX 1000000000

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

    vector<int> a;
    a.push_back(S);
    int cnt = 1;
    int temp = S;
    while (1){
        if (temp % 2 == 0){
            temp = temp / 2;
        }
        else{
            temp = temp * 3 + 1;
        }
        vector<int>:: iterator itr = find(a.begin(), a.end(), temp);
        cnt++;
        if (itr != a.end()){
            break;
        }
        a.push_back(temp);
    }

    cout << cnt <<  "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    int n; cin>>n;
    vector <pair<int,int>> A(n);
    rep(i,n) {int t,a; cin>>t>>a; A[i] = {t,a};}
    int now1 = 1, now2=1;
    rep(i,n){
        int x = (now1 + A[i].F -1)/ A[i].F;
        int y = (now2 + A[i].S -1)/ A[i].S;
        int z = max(x,y);
        //cout<<A[i].F<<' '<<z<<endl;
        now1 = A[i].F * z, now2 = A[i].S* z;
    }
    cout<<now2+now1<<endl;
}


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

vector<vector<int>> c(10, vector<int>(10));
void wf(){
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      for(int k = 0; k < 10; k++){
        c.at(j).at(k) = min(c.at(j).at(k), c.at(j).at(i) + c.at(i).at(k));
      }
    }
  }
}

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++) cin >> c.at(i).at(j);
  }
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++) cin >> a.at(i).at(j);
  }
  
  wf();
  
  int ans = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      int now = a.at(i).at(j);
      if(now < 0) continue;
      ans += c.at(now).at(1);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3776
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main(void) {
  //考察系
  //基本LR~RL,~はどうせかわらないのでなんでもいい、で基本幸福値は最適に選べば+2ずつ増える
  int N,K;
  string S;
  cin >> N >> K >> S;
  int value = 0;
  rrep(i,S.size()-1){
      if(S[i-1] == S[i]) value++;
  }
  int ans = min(value+K*2,N-1);
  fin(ans);
}

Measured memory_bytes: 512
#define R(x)(unsigned)x<5001
n;short p[3000][2];M(int*a){return*a-*1[&a];}F(x,y){int t=y<<16|x,i,l=0,h=n,m,r=0;for(;!r&&h>l;t<i?h=m:t>i?l=m+1:(r=1))i=*(int*)p[m=(l+h)/2];return r;}G(x,y,v,w){return R(x)&&R(y)&&R(v)&&R(w)&&F(x,y)&&F(v,w);}x,y,v,w,a,b,s,S;main(i){for(;scanf("%d",&n)*n;S=!printf("%d\n",S)){for(i=n;i--;*p[i]=x,p[i][1]=y)scanf("%d%d",&x,&y);for(qsort(p,n,4,M);n--;)for(i=n;i--;s>S&&(G(x-b,y+a,v-b,w+a)||G(x+b,y-a,v+b,w-a))?S=s:0)x=*p[n],y=p[n][1],v=*p[i],w=p[i][1],a=v-x,b=w-y,s=a*a+b*b;}}

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

#define f(i,x,n) for(i=x;i<n;i++)
#define pu(x) push_back(x)
#define eb(x) emplace_back(x)
#define pp pop_back()
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
const int MOD=1e9+7 , INF=INT_MAX;
const long long LINF=LLONG_MAX;

typedef long long ll;
typedef long double ld;
typedef vector<int> ivc;
typedef pair<int,int> ipr;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  
    string s;
    cin>>s;
    int n,i,j,x;
    n=s.length();
    int a[n]={0};
    ivc v(n);
    int p=0;
    f(i,0,n)
    {
        if(s[i]=='L')
            v[i]=p;
        else
            p=i;
    }
    p=n-1;
    for(i=n-1;i>=0;i--)
    {
        if(s[i]=='R')
            v[i]=p;
        else
            p=i;
    }

    f(i,0,n)
    {
        if(s[i]=='R')
        {
            x=v[i]-i;
            if(x&1)
                a[v[i]-1]++;
            else
                a[v[i]]++;
        }
        else
        {
            x=i-v[i];
            if(x&1)
                a[v[i]+1]++;
            else
                a[v[i]]++;
        }
     
    }
    f(i,0,n)
    {
        cout<<a[i]<<" ";
    }
  
return 0;
}

Measured memory_bytes: 1488
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

 
 
const ll N = 200005;
const ll mod = 1000000007;
const long long int inf = 1e10+5;
#define pp pair<ll,ll>
 
typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++) 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   




void fastIO(void);
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);




int main(){
    
     
    ll n;
    cin>>n;
    ll m = n;
    vector<ll> dig;
    while(m!=0){
        dig.push_back(m%10);
        m = m/10;
        

    }
    m = dig.size();
    if(m==1){
        cout<<n<<endl;
        return 0;
    }
   // cout<<"m = "<<m<<endl;
    ll ans[10][10];
    rep1(i,10){
        rep1(j,10){
            ans[i][j] = 0;
            if(dig[m-1]<i){
                ll k = m-3;
                while(k>=0){ ans[i][j] += pow(10,k); k--;}
               // if(m-3>=0)ans[i][j]++;

            }
            if(dig[m-1]>i){
                ll k = m-2;
                while(k>=0){ ans[i][j] += pow(10,k); k--;}
                //ans[i][j]++;
            }
            if(dig[m-1]==i){
                ll k = n;
               // cout<<"inti = "<<k<<endl;

                k = k/10;
                k = k - dig[m-1]*pow(10,m-2);
                //cout<<"f- = "<<k<<endl;
                ans[i][j] = k;
                if(n%10>=j) ans[i][j]++;
                k = m-3;
                 while(k>=0){ ans[i][j] += pow(10,k); k--;}
            }
        }
    }
    ll res = 0;
    rep1(i,10){
        rep1(j,10){
            if(i==j) ans[i][j]++;
            //cout<<ans[i][j]<<" ";

            if(i==j) continue;
            res += ans[i][j]*ans[j][i];
        }
       // cout<<endl;
    }
    rep1(i,10) res += ans[i][i]*ans[i][i];
    cout<<res<<endl;






   

}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}
 

Measured memory_bytes: 256