akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdexcept>
#include<cmath>
#include<memory>
#include<algorithm>
#include<cstring>
#include<ctime>
#include<deque>
#include<sstream>
#include<iomanip>
#include<sstream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#include<list>
#include<cassert>
#include<deque>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<27
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define F first
#define S second
#define pb push_back
#define pf push_front
#define LIM 100000
#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
typedef long long ll;
typedef unsigned long long ull;
map<char,string> cs;
map<string,char> sc;

void init(){
  cs[' '] = "101";
cs['\''] = "000000";
cs[','] = "000011";
cs['-'] = "10010001";
cs['.'] = "010001";
cs['?'] = "000001";
cs['A'] = "100101";
cs['B'] = "10011010";
cs['C'] = "0101";
cs['D'] = "0001";
cs['E'] = "110";
cs['F'] = "01001";
cs['G'] = "10011011";
cs['H'] = "010000";
cs['I'] = "0111";
cs['J'] = "10011000";
cs['K'] = "0110";
cs['L'] = "00100";
cs['M'] = "10011001";
cs['N'] = "10011110";
cs['O'] = "00101";
cs['P'] = "111";
cs['Q'] = "10011111";
cs['R'] = "1000";
cs['S'] = "00110";
cs['T'] = "00111";
cs['U'] = "10011100";
cs['V'] = "10011101";
cs['W'] = "000010";
cs['X'] = "10010010";
cs['Y'] = "10010011";
cs['Z'] = "10010000";

sc["00000"] = 'A';
sc["00001"] = 'B';
sc["00010"] = 'C';
sc["00011"] = 'D';
sc["00100"] = 'E';
sc["00101"] = 'F';
sc["00110"] = 'G';
sc["00111"] = 'H';
sc["01000"] = 'I';
sc["01001"] = 'J';
sc["01010"] = 'K';
sc["01011"] = 'L';
sc["01100"] = 'M';
sc["01101"] = 'N';
sc["01110"] = 'O';
sc["01111"] = 'P';
sc["10000"] = 'Q';
sc["10001"] = 'R';
sc["10010"] = 'S';
sc["10011"] = 'T';
sc["10100"] = 'U';
sc["10101"] = 'V';
sc["10110"] = 'W';
sc["10111"] = 'X';
sc["11000"] = 'Y';
sc["11001"] = 'Z';
sc["11010"] = ' ';
sc["11011"] = '.';
sc["11100"] = ',';
sc["11101"] = '-';
sc["11110"] = '\'';
sc["11111"] = '?';


} 


string bina(string s){
  string ret;
  for(int i=0;i<s.length();i++){
    ret += cs[s[i]];
  }

    while(ret.size()%5 != 0){
      ret += "0";
    }
  
  return ret;
}



int main(){
  string s;
  init();

  while(getline(cin,s)){
  string nes;
  nes = bina(s);
  for(int i=0;i<nes.length();i+=5){
    cout << sc[nes.substr(i,5)];
  }
  cout << endl;
  }
return 0;
}

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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;



int main() {
  ll n;
  	ci(n);
  ll ans=0;
  ll countA=0;
  ll countB=0;
  ll countC=0;
  vst A(n);
  vpll B(n);
  
  FOR(i,0,n){
    ci(A[i])
    ll S=A[i].sz;
    
      FOR(j,1,S){
      if(A[i].at(j-1)=='A'&&A[i].at(j)=='B'){
        B[i].fi++;
      }
      }
    
      if(A[i].at(S-1)=='A'){
		B[i].se+=1;//最後の文字がAなら1
        //co(1)
      }
      if(A[i].at(0)=='B'){
        B[i].se+=2;//最初の文字がBなら2
        //co(2)
      }
        //両方を満たすなら3になる     
	ans+=B[i].fi;
    //co(B[i].se)ここまではしっかりできてる
}
    
    FOR(i,0,n){
      if(B[i].se==1){
        countA++;
      }
      else if(B[i].se==2){
        countB++;
      }
      else if(B[i].se==3){
        countC++;
      }
    }
    
   /* ans+=min(countA,countB);
    countA-=min(countA,countB);
    countB-=min(countA,countB);
    */
  
    /*FOR(i,0,countC){
      if(countA<countB){
		countA++;
      }
      else{
		countB++;
      }
    }
    ans+=min(countA,countB);
    */
  if(countC>=2){
    ans+=(countC-1);//BA型だけでつくってしまう
  }
  
  if(countC>=1){
    if(countA>=1&&countB>=1){
    ans+=2;
    countA--;
    countB--;
  }
    else if(countA>=1){
      ans++;
      countA--;
    }
    else if(countB>=1){
      ans++;
      countB--;
    }
  }
  
    ans+=min(countA,countB);
    co(ans);
  }
      

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int fl=0;
  string s;
  cin>>s;

  for(int i=0; i<=(s.size()-1)/2-1; i++){
    if(s[i]!=s[(s.size()-1)/2-i-1])fl=1;
  }

  for(int i=(s.size()+3)/2; i<=s.size()-1; i++){
    if(s[i]!=s[s.size()-i-1])fl=1;
  }

  for(int i=0; i<=s.size()-1; i++){
    if(s[i]!=s[s.size()-i-1])fl=1;
  }

  if(fl==0){
    cout<<"Yes"<<'\n';
  }else{
    cout<<"No"<<'\n';
  }

  return 0;
}

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

const ll mod = 1e9 + 7;
const int maxn = 3010;
ll dp[maxn][maxn];

int main() {
	ios_base::sync_with_stdio(false);

	int n;
	string s;
	cin >> n >> s;
	dp[1][1] = 1;
	for (int i = 2; i <= n; i++) {
		ll pref[i];
		pref[0] = 0;
		for (int j = 1; j < i; j++) {
			pref[j] = (pref[j - 1] + dp[i - 1][j]) % mod;
		}
		for (int j = 1; j <= i; j++) {
			int l, r;
			if (s[i - 2] == '<') {
				l = 1, r = j - 1;
			} else {
				l = j; r = i - 1;
			}
			if (l <= r) {
				dp[i][j] = (pref[r] - pref[l - 1] + mod) % mod;
			}
		}
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = (ans + dp[n][i]) % mod;
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 49812
#include <stdio.h>
int main()
{
  int t[24][60]={0};
  int h,m,count=1;
  int a,b;
  for(int k=0;k<=1;k++){
  scanf("%d",&a);
  for(int i=0;i<=a-1;i++){
    scanf("%d %d",&h,&m);
    t[h][m]=1;
  }
}
  for(h=0;h<=23;h++){
    for(m=0;m<=59;m++){
       if(t[h][m]!=0) {
         if(count!=1) printf(" ");
          else count=0;
         printf("%d:%02d",h,m);
       }
    }
  }
   printf("\n");
  return 0;
}

Measured memory_bytes: 1048
#include<stdio.h>
int gcd(long long  a, long long b)
{
	if (a > b)
	{
		while (b != 0)
		{
			long long temp = a % b;
			a = b;
			b = temp;
		}
		return a;
	}
	else
	{
		while (a != 0)
		{
			long long temp = b % a;
			b = a;
			a = temp;
		}
		return b;
	}
}
int main(void)
{
	long long a, b;
	scanf("%lld %lld", &a, &b);
	long long c = gcd(a, b);
	printf("%lld", c * (a / c) * (b / c));

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <sstream>
#include <string>
#include <climits>
#include <set>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <numeric>
using namespace std;

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

	vector<double> niz(n);

	for (int i = 0; i < n; i++)
		cin >> niz[i];

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

	double ans;
	for (int i = 0; i < n - 1; i++)
	{
		niz[i + 1] = (niz[i] + niz[i + 1]) / 2;
		ans = niz[i + 1];
	}

	cout << ans;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int n;
int l[220]={};
int main()
{
	cin>>n;
	for(int i=1;i<=2*n;i++)
	 {
	 	cin>>l[i];
	 }
	 sort(l+1,l+2*n+1);
	 int anss=0;
	 for(int i=1;i<=2*n;i++)
	 if(i%2!=0)
	 {
	  anss+=l[i];
     }
	cout<<anss<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

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

    int c0 = count(S.begin(), S.end(), '0');
    int c1 = count(S.begin(), S.end(), '1');
    cout << min(c0, c1) * 2 << endl;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   

int32_t main() 
{
    fastio
    int n;
    cin>>n;
    map<string, int> mp;
    for(int i = 0; i<n; ++i) {
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
} 

Measured memory_bytes: 3620
# -*- coding: utf-8 -*-
class DisjointSets:
    '''
    Implementing disjoint sets using disjoint sets forests structure.

    --- methods ---
    __init__(size): size should be the number of elements in this disjoint sets
    unite(x, y): unite sets that contain x and y into a new set
    same(x, y): check if x and y are in the same set
    '''

    def __init__(self, size):
        self.size = size
        self.ranks = [0] * self.size
        self.roots = [0] * self.size
        for x in range(self.size):
            self._make_set(x)

    def _make_set(self, x):
        self.roots[x] = x
        self.ranks[x] = 0

    def _link(self, x, y):
        if self.ranks[x] > self.ranks[y]:
            self.roots[y] = x
        else:
            self.roots[x] = y
            if self.ranks[x] == self.ranks[y]:
                self.ranks[y] += 1

    def _find_set(self, x):
        # compression of the path
        if x != self.roots[x]:
            self.roots[x] = self._find_set(self.roots[x])

        return self.roots[x]

    def unite(self, x, y):
        self._link(self._find_set(x), self._find_set(y))

    def same(self, x, y):
        return self._find_set(x) == self._find_set(y)


if __name__ == '__main__':
    import sys
    n, q = map(int, input().split())
    ds = DisjointSets(n)

    for line in sys.stdin.readlines():
        query, x, y = map(int, line.strip().split())
        if query == 0:
            ds.unite(x, y)
        elif query == 1:
            if ds.same(x, y):
                print(1)
            else:
                print(0)



Measured memory_bytes: 13964
#-*-coding:utf-8-*-
import sys
import math
input=sys.stdin.readline

def main():
    a,b = input().split()
    number=0

    number=int(a+b)
    for i in range(100101):
        if i * i ==number:
            print("Yes")
            exit()
        else:
            continue
    print("No")


if __name__=="__main__":
    main()

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    string s;
    cin >> s;
    string t = s;
    reverse(all(t));
    if (s == t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    long long a, b, c, d;
    cin >> a >> b >> c >> d;

    long long ans = a*c;

    if(a<=0 && c <= 0) ans = max(ans, a*c);
    if(b>=0 && d >=0) ans = max(ans, b*d);
    ans = max(ans, b*c), ans = max(ans, a*d);
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;


int main()
{
  

   ll n;
   cin>>n;
   ll arr[n];
   for(ll i=0;i<n;i++)
    cin>>arr[i];
    ll total = 0;
    for(ll i=0;i<n;i++)
        total = total ^ arr[i];
    ll res[n];
    for(ll i=0;i<n;i++)
        res[i] = total^arr[i];
    for(ll i=0;i<n;i++)
        cout<<res[i]<<' ';
}

Measured memory_bytes: 6564
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
using ll = long long int;

int main(){
    int N;
    cin>>N;
    vector<vector<int>> txy(N);
    for(int i=0;i<N;i++){
        txy[i].resize(3);
        cin>>txy[i][0]>>txy[i][1]>>txy[i][2];
    }
    
    for(int i=0;i<N;i++){
        int time,x,y;
        if(i==0){
            time=txy[i][0];
            x=txy[i][1];
            y=txy[i][2];
        }
        else{
            time=txy[i][0]-txy[i-1][0];
            x=abs(txy[i][1]-txy[i-1][1]);
            y=abs(txy[i][2]-txy[i-1][2]);
        }
        
        if(x+y>time || (time-x-y)%2!=0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    
    cout<<"Yes"<<endl;
    
    return 0;
}




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

int main(){
    int n;
    cin>>n;
    double long arr[n];
    double long mult = 1;

    for(int i=0;i<n;i++){
        cin>>arr[i];
        mult = mult*arr[i];
    }

    double long result = mult;
    double long base = 0;
    for(int i=0; i<n; i++){
        double long temp = mult/arr[i];
        base += temp;
    }
    cout<<fixed<<setprecision(9);

    cout<<mult/base<<endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

enum{NONE,STRIKE,SPARE};

bool compare(pii a,pii b)
{
	return a.second==b.second?a.first<b.first:a.second>b.second;
}

int main()
{
	for(int m;cin>>m,m;){
		vector<pii> res;
		rep(i,m){
			int n; cin>>n;
			int score=0;
			int flg[2]={};
			rep(j,10){
				int p[3];
				if(j==9){
					rep(k,3){
						cin>>p[k];
						score+=p[k];
						if(flg[0]==STRIKE) score+=p[k];
						if(flg[1]) score+=p[k];
						flg[0]=flg[1];
						flg[1]=NONE;
						if(k==1 && p[0]+p[1]<10)
							break;
					}
				}
				else{
					int p[2];
					rep(k,2){
						cin>>p[k];
						score+=p[k];
						if(flg[0]==STRIKE) score+=p[k];
						if(flg[1]) score+=p[k];
						flg[0]=flg[1];
						if(k==0 && p[k]==10){
							flg[1]=STRIKE;
							break;
						}
						else if(k==1 && p[0]+p[1]==10)
							flg[1]=SPARE;
						else
							flg[1]=NONE;
					}
				}
			}
			res.push_back(mp(n,score));
		}
		sort(allof(res),compare);
		rep(i,res.size())
			cout<<res[i].first<<" "<<res[i].second<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,k,n) for(int i=k;i<n;i++)
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a=0,a2=0,a4=0;
  rep(i,n){
    int t;
    cin >> t;
    if(t%4==0){
      a4++;
    }else if(t%2==0){
      a2++;
    }
  }
  a = n - a2 - a4;
  bool flag = false;
  if(a + (a2>0) <= a4 + 1){
    flag = true;
  }



  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int S, W;
    cin >> S >> W;
    if (W >= S) {
        cout << "unsafe" << endl;
    }
    else {
        cout << "safe" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3648
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
ans = [0]*(10**4+100)

x = 1
while x*x<=10**4:
    y = 1
    
    while x*x+y*y+x*y<=10**4:
        z = 1
        
        while x*x+y*y+z*z+x*y+y*z+z*x<=N:
            ans[x*x+y*y+z*z+x*y+y*z+z*x] += 1
            z += 1
        
        y += 1
    
    x += 1
    
for i in range(1, N+1):
    print(ans[i])

Measured memory_bytes: 74860
#include <bits/stdc++.h>
using namespace std;
int main() {
	int i;
	string j;
	cin >> i >> j;
	if (i % 2 == 0 and j.substr(0, i / 2) == j.substr(i / 2 , i-1)) cout << "Yes"; else cout << "No";
}

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

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using pli=pair<ll,int>;

#define fi first
#define se second
#define pb push_back
#define sz(a) int((a).size())
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define testcase int _;cin>>_;while(_--)

/*D-Road To MIllionaire*/
void Solve(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	ll cost=1000,buy=0;
	for(int i=0;i<n-1;i++){
      	while(i<n && a[i+1]<=a[i])
          	i++;
      	if(i==n)
          	break;
		buy=cost/a[i];
		cost-=(buy*a[i]);
		while(i<n && a[i+1]>=a[i])
			i++;
		if(i==n)
			break;
		cost+=(buy*a[i]);
      	buy=0;
	}
  	if(buy!=0)
      	cost+=(buy*a[n-1]);
	cout<<cost<<"\n";
}

int main(){
	fast
	Solve();
	return 0;
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int K, T; cin >> K >> T;
  VI xs(T);
  REP(i,T) cin >> xs[i];
  SORT(xs);

  if(xs.back()+1 <= K-xs.back()) cout << 0 << endl;
  else cout << (xs.back() - (K - xs.back()) - 1) << endl;
  

  return 0;
}


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

int main(){
  string w;
  cin >>w;
  int num[26] = {0};
  rep(i,w.size()){
    int x = w[i]-'a';
    num[x]++;
  }
  bool can = true;
  rep(i,26){
    if(num[i]%2 != 0){
      can = false;
      break;
    }
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque

N = int(input())
tree = [[] for i in range(N)]
for i in range(N-1):
  a, b = map(int, input().split())
  a -= 1; b -= 1
  tree[a].append(b); tree[b].append(a)

C = list(map(int, input().split()))
C.sort()
ans = sum(C[:-1])
dep = [-1] * N
dep[0] = C.pop()
d = deque([[0, -1]])
while d:
  node, par = d.popleft()
  children = tree[node]
  for child in children:
    if child == par:
      continue
    dep[child] = C.pop()
    d.append([child, node])

print(ans)
print(*dep)

Measured memory_bytes: 6424
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
  int a,b;
  cin>>a>>b;

  if(a==b || !((a+b)%2)) cout<<(a+b)/2;
  else cout<<"IMPOSSIBLE";
  cout<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;

const ll dx[9] = {-2, -2, -2, -1, -1, -1, 0, 0, 0}, dy[9] = {-2, -1, 0, -2, -1, 0, -2, -1, 0};

ll h, w;
map<ll, ll> cnt;

inline void Add(ll x, ll y) {
  ll a, b, temp;
  for (int i = 0; i < 9; ++i) {
    a = x + dx[i];
    b = y + dy[i];
    if (a <= 0 || b <= 0 || a > h - 2 || b > w - 2) {
      continue;
    }
    temp = (h - 2) * (b - 1) + a;
    ++cnt[temp];
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> h >> w >> n;
  for (int i = 1; i <= n; ++i) {
    int x, y;
    cin >> x >> y;
    Add(x, y);
  }
  ll ans[10] = {0};
  ans[0] = (h - 3) * (w - 2) + w - 2;
  for (auto it : cnt) {
    ans[it.second]++;
    ans[0]--;
  }
  for (int i = 0; i <= 9; ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 56576
N, S=list(map(int,input().split()))
A=list(map(int,input().split()))
A=[0]+A
dp=[[0 for j in range(S+1)] for i in range(N+1)]
dp[0][0]=1
for i in range(1,N+1):
    for j in range(S+1):
        dp[i][j]=(dp[i][j]+2*dp[i-1][j]) %998244353 # x[i]を入れないが、大きい方に入れるか入れないかが二通り
    for j in range(S-A[i]+1):
        dp[i][j+A[i]]=(dp[i][j+A[i]]+dp[i-1][j]) %998244353 # x[i]を入れる
print(dp[N][S])

Measured memory_bytes: 147220
s = input()
ans1 = 0
ans2 = 0
for i in range(len(s)):
  if i % 2 == 0 and s[i] == "1":
    ans1 += 1
  elif i % 2 == 1 and s[i] == "0":
    ans1 += 1
for i in range(len(s)):
  if i % 2 == 0 and s[i] == "0":
    ans2 += 1
  elif i % 2 == 1 and s[i] == "1":
    ans2 += 1
print(min(ans1, ans2))

Measured memory_bytes: 3316
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitsf(n) __builtin_popcount(n)
ll power(ll x, ll y); 

const ll MOD = 1000000007;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    int n;
    cin >> n;
    ll arr[n + 1];
    repp(i, 1, n) cin >> arr[i];
    unordered_map<ll, ll> m, f;
    repp(i, 1, n) f[i - arr[i]]++;

    ll res = 0;
    repp(i, 1, n){
        ll x = i + arr[i];
        m[i - arr[i]]++;
        res += max(0ll, f[x] - m[x]);
    }

    cout << res;
}
 
ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}


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

#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;

class BCommonRaccoonVsMonster {
 public:
  void solveOne(std::istream &in, std::ostream &out) {
    int n, k, s = 0, t;
    in >> n >> k;
    forn(i, k) {
      in >> t;
      s += t;
    }
    out << ((s >= n) ? "Yes" : "No") << endl;

  }
  void solve(std::istream &in, std::ostream &out) {
    int nt = 1;
    for (int i = 0; i < nt; ++i)
      solveOne(in, out);
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  BCommonRaccoonVsMonster solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

int main(){
    int n, m;
    std::cin >> n >> m;

    int ans = 1900 * 2;
    if(1 != n || 1 != m){
        ans = ((n - m) * 100 + 1900 * m) * std::pow(2, m);
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

//Graph in adjcency list
class Graph{
public:
    int N;
    vector<vector<int>> adjlist;
    vector<int> tsort;

    Graph(int n) : N(n), adjlist(n+1){}

    void setEdge(int a, int b){
        adjlist[a].push_back(b);
    }

    void topologicalSort(){
        vector<int> deg(N);
        for(auto i : adjlist){
            for(auto j : i){
                deg[j]++;
            }
        }

        deque<int> deq;
        REP(i, N){
            if(deg[i] == 0){
                deq.push_back(i);
            }
        }

        while(!deq.empty()){
            int v = deq.front();
            deq.pop_front();
            tsort.push_back(v);
            for(auto i : adjlist[v]){
                deg[i]--;
                if(deg[i] == 0){
                    deq.push_back(i);
                }
            }
        }
    }

    void solve(){
        topologicalSort();
        vector<int> f(N);
        REP(i, N){
            f[tsort[i]] = i;
        }
        vector<vector<int>> in(N);
        REP(i, N){
            for(auto j : adjlist[i]){
                in[j].push_back(i);
            }
        }
        for(auto i : in){
            int m = -1;
            for(auto j : i){
                if(f[j] > m){
                    m = f[j];
                }
            }
            cout << (m == -1 ? 0 : tsort[m] + 1) << endl;
        }
    }
};

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

    Graph G(n);
    REP(i, n-1+m){
        int a, b;
        cin >> a >> b;
        G.setEdge(a-1, b-1);
    }

    G.solve();

    return 0;
}

Measured memory_bytes: 12528
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	
	public static class UnionFind {
		int[] par;
		
		public UnionFind(int n){
			par = new int[n];
			Arrays.fill(par, -1);
		}
		
		public int find(final int x){
			if(par[x] < 0){
				return x;
			}else{
				return par[x] = find(par[x]);
			}
		}
		
		public boolean union(int x, int y){
			x = find(x);
			y = find(y);
			
			if(x == y){ return false; }
			
			if(par[y] < par[x]){
				int tmp = x; 
				x = y;
				y = tmp;
			}
			par[x] += par[y];
			par[y] = x;
			return true;
		}
		
		public boolean same(int x, int y){
			return find(x) == find(y);
		}
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		HashMap<String, Integer> id = new HashMap<String, Integer>();
		int[] costs = new int[N];
		
		for(int i = 0; i < N; i++){
			final String name = sc.next();
			id.put(name, i);
			
			final int cost = sc.nextInt();
			costs[i] = cost;
		}
		//System.out.println(Arrays.toString(costs));
		
		final int M = sc.nextInt();
		UnionFind uf = new UnionFind(N);
		for(int i = 0; i < M; i++){
			final String s = sc.next();
			final String t = sc.next();
			
			final int s_id = id.get(s);
			final int t_id = id.get(t);
			
			if(!uf.same(s_id, t_id)){
				uf.union(s_id, t_id);
			}
		}
		
		for(int i = 0; i < N; i++){
			costs[uf.find(i)] = Math.min(costs[uf.find(i)], costs[i]);
		}
		
		long sum = 0;
		for(int i = 0; i < N; i++){
			sum += costs[uf.find(i)];
		}
		
		System.out.println(sum);
		
	}
	
} 

Measured memory_bytes: 29808
//
// Created by yushi hosokawa on 2020/05/28.
//
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define MAX 100000

//グローバル変数でn,k wを定義。すると関数で参照で渡して値を使える
int n ,k;
vector <ll> w(MAX);


int check(ll P){
    int i = 0;
    for(int j = 0; j <k;j++){
        ll s = 0;
        while(s+w[i]<= P){
            s += w[i];
            i++;
            if(i == n)return n; //全ての荷物をつめたら n=荷物の値 を返す
        }
    }
    return i; //すべての荷物を返せなかったら載せられた数だけ返す
}

int solve(){
    ll left = 0;
    ll right = 10000*100000;
    ll mid ;
    while(right - left > 1){
        mid = (left +right)/2;
        int v = check(mid);
        if(v>=n)right = mid;
        else left = mid;
    }
    return right;
}


int main() {

    cin >>n>>k;
    rep(i,n){
        cin>>w.at(i);
    }
    ll ans = solve();
    cout <<ans<<endl;


}



Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define BIGINF (int) 4e18 + 7
#define MOD7 1000000007
#define MOD9 1e9 + 9
#define INF  (int)2e9 + 7
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
typedef long long ll;
typedef long double ld;
typedef string str;
typedef double d;
typedef unsigned u;
typedef unsigned long long ull;

int main () {
    //freopen("inputf.txt", "r", stdin);
    //freopen("outputf.txt", "w", stdout);
    int n, x;
    SCD(n);
    vector<int> v;
    for (int i = 0; i < n; i++) {
    	SCD(x);
    	v.push_back(x);
    }
    int dp[100005];
    memset(dp, INF, sizeof(dp));
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
    	if (i <= 1) {
    		dp[i] = dp[i - 1] + abs(v[i] - v[i - 1]);
    	}
    	else {
    		dp[i] = min(dp[i - 1] + abs(v[i] - v[i - 1]),
    					dp[i - 2] + abs(v[i] - v[i - 2]));
    	}
    }
    printf("%d", dp[n - 1]);


    return 0;
}



Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int n, k;
  string s;
  cin >> n >> k >> s;
  int cnt = 0;
  rep(i,n-1){
    if (s[i] == s[i + 1]) cnt++;
  }
  cout << min(n-1,cnt+2*k) << endl;
  return 0;
}

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

int main(void){

    int n;
    long ans = 0;
    cin >> n;
    int A[n+1];
    int B[n];
    
    for(int i = 0; i <= n; i++){
        cin >> A[i];
    }
    
    for(int i = 0; i < n; i++){
        cin >> B[i];
    }


    for(int i = 0; i < n; i++){
        if(B[i] == 0) continue;
        
        if(A[i] <= B[i]){
            ans += A[i];
            
            if(A[i + 1] <= B[i] - A[i]){
                ans += A[i + 1];
                A[i + 1] = 0;
            }
            else{
                ans += B[i] - A[i];
                A[i+1] -= max(B[i] - A[i], 0);
            }

        }
        else{
            ans += B[i];
        }
    }

    cout << ans << endl;
    

}


Measured memory_bytes: 1024
def xor_operate(a_list):
    result = 0
    for a in a_list:
        result ^= int(a)
    return result



if __name__ == "__main__":
    N = input()
    a_list = input()

    a_list = a_list.split(" ")

    bit_value = xor_operate(a_list)

    i_list = []
    for a in a_list:
        i_list.append(str(bit_value ^ int(a)))
    print(" ".join(i_list))
    


        



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

int main() {
    long long E=998244353;
   int N,K;
   cin >> N >> K;
   int L[K],R[K];
   for (int i=0; i<K; i++) {
       cin >> L[i] >> R[i];
   }
   long long dp[N];
   long long M[K];
   for (int i=0; i<N; i++) dp[i]=0;
   for (int i=0; i<K; i++) M[i]=0;
   dp[0]=1;
   for (int i=0; i<N; i++) {
       for (int j=0; j<K; j++) {
           if (i-L[j]>=0) {
               M[j]+=dp[i-L[j]];
               M[j]%=E;
               if (i-R[j]>0) {
                   M[j]-=dp[i-R[j]-1];
                   M[j]%=E;
               }
           }
           dp[i]+=M[j];
           dp[i]%=E;
           if (dp[i]<0) dp[i]+=E;
       }
       //cout << dp[i] << endl;
   }
   cout << dp[N-1] << endl;
}

Measured memory_bytes: 5176
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007
#define pi atan(1) * 4

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

int main()
{
	string s;
	cin >> s;
	string tmps = "";
	for(int i = 0; i < s.length(); i++){
		if(s[i] != 'x') tmps += s[i];
	}
	if(tmps.length() == 0){
		cout << 0 << endl;
		return 0;
	}
	int ans = -1;
	if(iskaibun(tmps)){
		ans = 0;
		if(tmps.length() % 2 == 0){
			// xをのぞいたsが長さ偶数の回文の時
			int centerl = 0, centerr = 0;
			int cnt = 0;
			while(cnt < tmps.length() / 2){
				if(s[centerl] != 'x') cnt++;
				centerl++;
			}
			centerl--;
			centerr = centerl + 1;
			while(s[centerr] != s[centerl]) centerr++;
			int l = centerl - 1, r = centerr + 1;
			// cout << l << r << endl;
			while(l >= 0 && r < s.length()){
				if(s[l] == s[r]){
					l--;
					r++;
				} else if(s[l] == 'x'){
					l--;
					ans++;
				} else if(s[r] == 'x'){
					r++;
					ans++;
				}
			}
			ans += l + 1 + s.length() - r;
		} else {
			int center = 0;
			int cnt = 0;
			while(cnt < tmps.length() / 2 + 1){
				if(s[center] != 'x') cnt++;
				center++;
			}
			center--;
			// cout << center << endl;
			int l = center - 1, r = center + 1;
			while(l >= 0 && r < s.length()){
				if(s[l] == s[r]){
					l--;
					r++;
				} else if(s[l] == 'x'){
					l--;
					ans++;
				} else if(s[r] == 'x'){
					r++;
					ans++;
				}
			}
			// cout << l << r << endl;
			ans += l + 1 + s.length() - r;
			// cout << center << s[center] << endl;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <cmath>
#include <iostream>
#include <limits>
#include <vector>


int main() {
    int n, k;
    std::cin >> n >> k;
    std::vector<long long> answers;
    answers.reserve(n);
    std::vector<int> heights(n);
    for(auto& e : heights) std::cin >> e;
    answers.push_back(0);
    for(int i = 1; i < n; i++) {
        long long ans = std::numeric_limits<long long>::max();
        const int lookBack = std::min(k, i);
        for (int j = 1; j <= lookBack ; j++) {
            const long long option = answers[i - j] + std::abs(heights[i - j] - heights[i]);
            ans = std::min(ans, option);
        }
        answers.push_back(ans);
    }
    std::cout << answers.back() << "\n";
}


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

int main() {
  string a,b,c; cin>>a>>b>>c;
  queue<int> A,B,C;
  int tmp = 0;
  while (tmp<a.size()) {
    A.push(a[tmp]);
    tmp++;
  }
  tmp = 0;
  while (tmp<b.size()) {
    B.push(b[tmp]);
    tmp++;
  }
  tmp = 0;
  while (tmp<c.size()) {
    C.push(c[tmp]);
    tmp++;
  }
  char cnt='a';
  while (1) {
    if (cnt=='a') {
      if (A.empty()) {
        cout<<"A"<<endl;
        break;
      }
      cnt = A.front();
      A.pop();
    }
    else if (cnt=='b') {
      if (B.empty()) {
        cout<<"B"<<endl;
        break;
      }
      cnt = B.front();
      B.pop();
    }
    else {
      if (C.empty()) {
        cout<<"C"<<endl;
        break;
      }
      cnt = C.front();
      C.pop();
    }
  }
}


Measured memory_bytes: 256
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
from itertools import accumulate as acc
def gcd(a,b):
    while b: a, b = b, a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)
def main():
    n = II()
    aa = MII()
    ll = list(acc(aa, lcm))
    lv = ll[-1]-1
    sumv = 0
    for a in aa:
        sumv += lv%a
    print(sumv)

if __name__ == '__main__':
    main()


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

ll a[200000];
int par[200000];
vector<ll>v[200000];

int find(int x){
	if(par[x]==x)return x;
	return par[x]=find(par[x]);
}
int main(){
	int n,m;scanf("%d%d",&n,&m);
	rep(i,n)scanf("%lld",&a[i]);
	rep(i,n)par[i]=i;
	rep(i,m){
		int x,y;scanf("%d%d",&x,&y);
		par[find(x)]=find(y);
	}
	rep(i,n){
		v[find(i)].push_back(a[i]);
	}
	ll ans=0,cnt=0;
	vector<ll>V;
	rep(i,n){
		if(v[i].empty())continue;
		cnt++;
		sort(v[i].begin(),v[i].end());
		ans+=v[i][0];
		for(int j=1;j<v[i].size();j++){
			V.push_back(v[i][j]);
		}
	}
	if(cnt==1){
		puts("0");return 0;
	}
	sort(V.begin(),V.end());
	rep(i,2*(n-m-1)-cnt){
		if(V.size()<=i){
			puts("Impossible");return 0;
		}
		ans+=V[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 9600
#include <stdio.h>

int main(){
    int i, j, mtrx[100][100], vctr[100];
    int n, m;

    scanf("%d %d", &n, &m);
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            getchar();
            scanf("%d", &mtrx[i][j]);
        }
    }
    
    for(i = 0; i < m; i++){
        getchar();
        scanf("%d", &vctr[i]);
    }

    for(i = 0; i < n; i++){
        int sum = 0;
        for(j = 0; j < m; j++){
            sum += mtrx[i][j] * vctr[j];
        }
        printf("%d\n", sum);
    }
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5+5;
int n, ans;
int a[MAXN], f[MAXN];
int main()
{
    scanf("%d", &n); for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for(int i = n; i >= 1; i--)
    {
        int sum = 0;
        for(int j = 2 * i; j <= n; j += i) sum = (sum + f[j]) % 2;
        f[i] = a[i] ^ sum;
//        printf("sum : %d a: %d f: %d\n", sum, a[i], f[i]);
        if(f[i]) ans++;
    }
    printf("%d\n", ans);
    for(int i = 1; i <= n; i++) if(f[i]) printf("%d ", i);
    if(ans) printf("\n");
//    system("pause");
}

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

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int Q,H,S,D;
  long long N;
  cin>>Q>>H>>S>>D>>N;

  int M1,M2;
  M1=min(min(4*Q,2*H),S);
  M2=min(M1*2,D);

  long long ans=0;
  if(N%2==0){
    ans = N/2*M2;
  }else{
    ans = N/2*M2+M1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type pair struct {
	a int
	b int
}

var sc = bufio.NewScanner(os.Stdin)
var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func nextInt() int {
	i, _ := strconv.ParseInt(nextLine(), 10, 32)
	return int(i)
}

func nextLong() int64 {
	i, _ := strconv.ParseInt(nextLine(), 10, 64)
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	graph := make([][]int, N+1)
	for i := 1; i < N+1; i++ {
		graph[i] = make([]int, 0, N-1)
		for j := 0; j < N-1; j++ {
			graph[i] = append(graph[i], nextInt())
		}
	}
	queue := make([]pair, 0)
	for i := 1; i < N; i++ {
		if graph[graph[i][0]][0] == i && i < graph[i][0] {
			queue = append(queue, pair{i, graph[i][0]})
		}
	}
	ans := 0
	for cnt := 0; cnt < N*(N-1)/2; ans++ {
		if len(queue) == 0 {
			fmt.Println("-1")
			return
		}
		for b := len(queue); b > 0; b-- {
			n := queue[0].a
			graph[n] = graph[n][1:]
			if len(graph[n]) != 0 && graph[graph[n][0]][0] == n {
				queue = append(queue, pair{n, graph[n][0]})
			}
			n = queue[0].b
			graph[n] = graph[n][1:]
			if len(graph[n]) != 0 && graph[graph[n][0]][0] == n {
				queue = append(queue, pair{n, graph[n][0]})
			}
			queue = queue[1:]
			cnt++
		}
	}
	fmt.Printf("%d\n", ans)
}


Measured memory_bytes: 20096
N, M, C = map(int, input().split())

import numpy as np
A = np.zeros((N,M))
B = list(map(int, input().split()))

for i in range(N):
  A[i] = list(map(int, input().split()))
D = np.dot(A, B) + C
cnt = 0
for i in range(N):
  if D[i] > 0: cnt+= 1
print (cnt)

Measured memory_bytes: 14448
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    map<ll, ll> mp;
    vector<ll> v;
    for(int i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        mp[b] += a;
        v.PB(b);
    }
    sort(ALL(v));
    uni(v);
    ll st = 0;
    bool ok = true;
    if(v[0] >= mp[v[0]]){
        st = mp[v[0]];
    }else{
        ok = false;
    }
    for(int i = 1; i < SZ(v); i++){
        if(v[i] - st >= mp[v[i]]){
            st += mp[v[i]];
        }else{
            ok = false;
        }
    }
    if(ok){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 14320
#include<bits/stdc++.h>
using namespace std;
long long x,k,d;
int main(){
	cin>>x>>k>>d;
	if(x<0)x=-x;
	k-=x/d;
	x%=d;
	if(k<=0){
		cout<<x+(-k*d);
		return 0;
	}
	if(k%2==1) cout<<d-x;
	else cout<<x;
	return 0;
}  

Measured memory_bytes: 3628
# input
N = int(input())
lst_red = [list(map(int, input().split())) for i in range(N)]
lst_blue = [list(map(int, input().split())) for i in range(N)]

lst_red.sort(key=lambda x: x[1], reverse=True) # yの大きい順
lst_blue.sort(key=lambda y: y[0]) # xの小さい順

ans = 0

# 貪欲法
# 各青点に対してペアになれる赤点のうち、yが最大の赤点を選んでいく
for b in lst_blue:
    for r in lst_red:
        if r[0] < b[0] and r[1] < b[1]:
            lst_red.remove(r)
            ans += 1
            break

print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define N 200010
#define SW 0
typedef long long ll;
using namespace std;
stack<ll> S;
ll l[N],r[N],ans,n,a[N];
void input()
{
    scanf("%lld",&n);
    ll i;
    for(i=1;i<=n;i++)
        scanf("%lld",&a[i]);
}
void process()
{
    ll i;
    for(i=1;i<=n+1;i++){
        while(!S.empty()){
            if(a[S.top()]>a[i]){
                r[S.top()]=i;
                S.pop();
            }
            else
                break;

        }
        S.push(i);
    }
    while(!S.empty())
        S.pop();
    for(i=n;i>=0;i--){
        while(!S.empty()){
            if(a[S.top()]>a[i]){
                l[S.top()]=i;
                S.pop();
            }
            else
                break;
        }
        S.push(i);
    }
}
void output()
{
    ll i;
    for(i=1;i<=n;i++){
      //  printf("%lld %lld\n",l[i],r[i]);
        ans+=(r[i]-i)*(i-l[i])*a[i];
    }
    printf("%lld",ans);
}
int main()
{
#if SW==1
freopen("input.txt","r",stdin);
#endif // SW
    input();
    process();
    output();
    return 0;
}



Measured memory_bytes: 5944
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	string s, t;
	cin >> s;
	for(int i=0; i<s.size(); i+=2) t+=s[i];
	cout << t << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main() {
    int M,N,i,n=0;
    double SA=0;
    cin >> N >> M;
    double A[N];
    for (int k=0;k<N;k++){
        cin >> A[k];
        SA = SA + A[k];
    }
    double a = SA/4/M;
    for (int k=0;k<N;k++){
        if(a <= A[k])n=n+1;
    }
        if(n>=M){cout <<"Yes";}
        if(n<M){cout << "No";}
}

Measured memory_bytes: 256