akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  ll N, cnt, min = 0;
  string S;
  cin >> N >> S;
  for(ll i  = 1; i < N; i++) {
    if(S.at(i) == 'E') min++;
  }
  cnt = min;
  for(ll i  = 1; i < N; i++) {
    if((S.at(i - 1) == 'E') && (S.at(i) == 'E')) {
      cnt--;
      if(cnt <= min) min = cnt;
    }
    else if((S.at(i - 1) == 'W') && (S.at(i) == 'W')) cnt++;
  }
  cout << min << endl;
}

Measured memory_bytes: 3932
N = int(input())
S = input()

K = set()
K.add(S[0:3])
K2 = set()
K2.add(S[0]+S[1])
K2.add(S[0]+S[2])
K2.add(S[1]+S[2])


for i in range(3,N):   
    c = S[i]
    tmp = set()
    tmp2 = set()
    for k in K2:
        tmp.add(k+c)
        tmp2.add(k[0]+c)
        tmp2.add(k[1]+c)
    K = K.union(tmp)
    K2 = K2.union(tmp2)

print(len(K))

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

int main() {
  char a;
  int N, c;
  bool P = false;
  bool W = false;
  bool G = false;
  bool Y = false;
  
  cin >> N;
  
  for (int i = 0; i < N; i++){
    
    cin >> a;
    
    if (a == 'P' && P == false){
      c ++;
      P = true;
    }
    else if (a == 'W' && W == false){
      c++;
      W = true;
    }
    else if (a == 'G' && G == false){
      c++;
      G = true;
    }
    else if (a == 'Y' && Y == false){
      c++;
      Y = true;
    }

  }
  
  cout << (c == 3 ? "Three": "Four") << endl; 

}


Measured memory_bytes: 256
import math
a, b = map(int, input().split())
for i in range(1251):
  tax8 = math.floor(i * 0.08)
  tax10 = math.floor(i * 0.1)
  if (tax8, tax10) == (a, b): 
    print(i)
    break
else:
  print(-1)

Measured memory_bytes: 9180
#include <iostream>
#include <string>

using namespace std;

int main(){
  string s;

  while(cin >> s){
    for(int i = 0 ; i < (int)s.size() ; i++){
      if(s[i] == '@'){
	cout << string(s[i+1]-'0',s[i+2]);
	i += 2;
      } else {
	cout << s[i];
      }
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1180
import java.lang.Math.abs

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val l2 = readLine()!!.split(" ")
    val t = l2[0].toInt()
    val a = l2[1].toDouble()
    val h = readLine()!!.split(" ").map { it.toInt() }.map { t - it * 0.006 }

    var result = 1
    var tmp = Double.MAX_VALUE
    for (i in (1..n)) {
        val diff = abs(h[i-1] - a)
        if (diff < tmp) {
            tmp = diff
            result = i
        }
    }

    print(result)
}

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

int main() {
  int n;
  cin>>n;
  vector<vector<int>> a(n,vector<int>(3));
  for(int i = 0;i<n;i++) {
    cin>>a[i][0]>>a[i][1]>>a[i][2];
  }
  //dp[i][0/1/2]
  // dp[i][0] is take a on ith day
  // dp[i][j] = a[i][j] + max(dp[i-1][k]) for k != j
  vector<vector<int>> dp(n,vector<int>(3));
  dp[0][0] = a[0][0]; 
  dp[0][1] = a[0][1]; 
  dp[0][2] = a[0][2];
  for(int i = 1;i<n;i++) {
    for(int j = 0; j<3;j++) {
      for(int k = 0; k< 3; k++) {
        if(j!=k) {
          dp[i][j] = max(dp[i][j],a[i][j] + dp[i-1][k]);
        }
      }
      //printf("dp[%d][%d] = %d\n",i,j,dp[i][j]);
    }
  } 
  cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vvchar vector<vector<char>>
#define vchar vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

int digits(int x){
    int ret=1;
    while(x/10){
        x/=10;
        ret++;
    }
    return ret;
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    int res=INF;
    for(int a=1; a*a<=n; a++){
        if(n%a!=0) continue;
        int b=n/a;
        chmin(res,digits(b));
    }   
    cout<<res<<endl;
}

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

typedef long long ll;

ll n;
ll A[105];

int main(){
    cin >> n;

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

    ll mx=INT_MIN;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            ll tmp=abs(A[j]-A[i]);
            mx=max(mx,tmp);
        }
    }

    cout << mx << endl;

    return 0;
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut l: Vec<usize> = (0..n)
        .map(|_| iterator.next().unwrap().parse().unwrap())
        .collect();

    l.sort();

    let mut count = 0;
    for i in 0..(n - 2) {
        for j in (i + 1)..(n - 1) {
            let a = l[i];
            let b = l[j];

            // if !can_triangle(a, b, l[j + 1]) {
            //     continue;
            // }
            //
            // if can_triangle(a, b, l[n - 1]) {
            //     count += n - 1 - j;
            //     continue;
            // }
            //
            // let mut left = j + 1;
            // let mut right = n - 1;

            let mut left = j;
            let mut right = n;
            while left + 1 < right {
                let mid = (right + left) / 2;
                if can_triangle(a, b, l[mid]) {
                    left = mid;
                } else {
                    right = mid;
                }
            }
            count += left - j;
        }
    }
    return count.to_string();
}

fn can_triangle(a: usize, b: usize, c: usize) -> bool {
    return a < b + c && b < c + a && c < a + b;
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  int X; 
  cin >> X;

  vector<int> L(N);
  rep(i,N){
    cin >> L[i];
  }

  int D = 0;
  int ans = 1;
  for(int i=2;i <= N+1;i++){
    D = D + L[i-2];
    ans++;
    if(D > X){
      ans--;
      break;
    }
  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int A[5001],B[5001];
int main(){
    int a,b;
    cin>>a>>b;
    for(int i=0; i<a; i++) cin>>A[i];
    for(int i=0; i<b; i++) cin>>B[i];
    int next=0,maxl=0;
    for(int i=0; i<b; i++){
        next=i;
        int cnt=0;
        for(int j=0; j<a; j++) if(A[j]==B[next]) {cnt++; next++;}
        maxl=max(maxl,cnt);
    }
    cout<<maxl<<endl;
}

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

int main()
{
	int ans;
    for(int i=1 ; i<10 ; i++){
		for(int j=1 ; j<10 ; j++){
			ans=i*j;
			cout << i << "x" << j << "=" << ans <<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1116
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,k,s;
  cin >> n >> k >> s;
  for(int i=0; i<k; i++) {
    cout << s << " ";
  }
  for(int i=0; i<n-k; i++) {
    cout << 473265238 << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1280
#include<iostream>
#include<map>

using namespace std;

typedef long long ll;

int M;

int main() {
	cin >> M;
	ll sum = 0;
	ll cnt = 0;
	for (int i = 0; i < M; i++) {
		ll c, d;
		cin >> d >> c;
		sum += c * d;
		cnt += c;
	}
	ll ans = 0;
	ans += (cnt - 1);
	ans += (sum / 9);
	if (sum % 9 == 0)ans--;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
sa=sum(a)
hantei=2*(10**9)+1
sx=0
for i in range(len(a)-1):
  sx+=a[i]
  if abs(sa-2*sx)<hantei:
    hantei=abs(sa-2*sx)
print(hantei)

Measured memory_bytes: 24820
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

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

	int n, t;
	cin >> n >> t;

	int mic = INF;

	rep(i, n) {
		int a, b;
		cin >> a >> b;
		if (b <= t && a < mic) {
			mic = a;
		}
	}

	if (mic != INF) out(mic);
	else out("TLE");

	return 0;
}

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

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

using namespace std;

int A[500][500];

void dfs(int l,int r,int id){
	int n=r-l;
	if(n<=1) return;
	// K_{n/2,(n+1)/2}
	for(int u=l;u<l+n/2;u++) for(int v=l+n/2;v<r;v++) A[u][v]=id;
	// K_{n/2} cup K_{(n+1)/2}
	dfs(l,l+n/2,id+1);
	dfs(l+n/2,r,id+1);
}

int main(){
	int n; scanf("%d",&n);
	dfs(0,n,1);
	rep(u,n-1) for(int v=u+1;v<n;v++) printf("%d%c",A[u][v],v<n-1?' ':'\n');
	return 0;
}


Measured memory_bytes: 1408
N = int(input())

dic = {}
for c in input():
    if c in dic.keys():
        dic[c] += 1
    else:
        dic[c] = 1

for i in range(N-1):
    tmp_dic = {}
    for c in input():
        if c in tmp_dic.keys():
            tmp_dic[c] += 1
        else:
            tmp_dic[c] = 1
    for k in dic.keys():
        if k in tmp_dic.keys():
            dic[k] = min(dic[k], tmp_dic[k])
        else:
            dic[k] = 0
    
print("".join(sorted([k * dic[k] for k in dic.keys()])))


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <list>
#include <math.h>
#include <iomanip>
#include <map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;


string b;
int main(){
  cin>>b;
  if(b == "A"){
    cout<<"T";
  }else if(b == "C"){
    cout<<"G";
  }else if(b == "G"){
    cout<<"C";
  }else if(b == "T"){
    cout<<"A";
  }
  cout << endl;
}

Measured memory_bytes: 256
import math
N,M=map(int,input().split())

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

x=0
y=0
if N>=2:
    x=combinations_count(N, 2)
if M>=2:
    y=combinations_count(M, 2)

print(x+y)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        int a = scn.nextInt();
        int b = scn.nextInt();
        int c = scn.nextInt();

        if ((a < b) && (b < c)) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        scn.close();
    }
}


Measured memory_bytes: 26224
#AGC031 A Colorful Subsequence
# Answer
N = int(input())
S = input()
alpha = [0]*26
mod = 10**9+7

for n in S:
    num = ord(n)-97
    alpha[num] += 1
    
ans = 1
for i in range(26):
    ans *= (alpha[i]+1)

# ans %= mod
print((ans-1)%mod)

Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 110

struct SS{
  bool visited1[SIZE], visited2[SIZE];
  int num[SIZE],num_size,dic_num[SIZE];
  int group[SIZE],group_size;
  
  SS(){
    for(int i=0;i<SIZE;i++){
      visited1[i] = visited2[i] = false;
    }
    num_size = 0;
    group_size = 0;
  }
  
  void dfs1(int now, vector<int> *way){

    if(visited1[now]) return;
    visited1[now] = true;
    
    for(int i=0;i<way[now].size();i++){
      dfs1(way[now][i],way);
    }

    dic_num[now] = num_size;
    num[num_size++] = now;
  }

  bool dfs2(int now, vector<int> *way_back){

    if(visited2[now]) return false;
    group[now] = group_size;
    visited2[now] = true;
    
    for(int i=0;i<way_back[now].size();i++){
      dfs2(way_back[now][i],way_back);
    }

    return true;
  }
  

};
void calc(int n){
  double p[SIZE];
  int m[SIZE],a[SIZE][SIZE];
  vector<int> way[SIZE];
  vector<int> way_back[SIZE];

  for(int i=0;i<n;i++){
    scanf("%lf%d",p+i,m+i);

    for(int j=0;j<m[i];j++){
      scanf("%d",a[i]+j);
      a[i][j]--;
      way[i].push_back(a[i][j]);
      way_back[a[i][j]].push_back(i);
    }
  }

  SS ss;

  for(int i=0;i<n;i++){
    ss.dfs1(i,way);
  }

  for(int j=0;j<n;j++){
    ss.group_size += ss.dfs2(ss.num[n-j-1],way_back);
  }

  bool group_in[SIZE] = {0};
  vector<int> group_list[SIZE];
  
  for(int i=0;i<n;i++){
    group_list[ss.group[i]].push_back(i);
    
    for(int j=0;j<m[i];j++){
      if(ss.group[i] != ss.group[a[i][j]])
        group_in[ss.group[a[i][j]]] = true;
    }
  }

  double ans = 1;
  
  for(int i=0;i<ss.group_size;i++){
    if(group_in[i]) continue;

    double calc_p = 1;

    for(int j=0;j<group_list[i].size();j++){
      calc_p *= p[group_list[i][j]];
    }

    ans *= 1 - calc_p;
  }

  printf("%.10lf\n",ans);
}

int main(){

  int n;

  while(1){
    scanf("%d",&n);
    if(n == 0) break;
    calc(n);
  }
  
  
  return 0;
}

Measured memory_bytes: 3440
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string,int>;
using T = tuple<string,int,int>;

int main(){
  int A,B,M; cin >> A >> B >> M;
  vector<int> a(A), b(B);
  for(int i = 0; i < A; i++) cin >> a[i];
  for(int i = 0; i < B; i++) cin >> b[i];
  int amn = *min_element(a.begin(), a.end());
  int bmn = *min_element(b.begin(), b.end());
  ll ans = amn + bmn;
  for(int i = 0; i < M; i++){
    int x,y,c; cin >> x >> y >> c;
    x--; y--;
    ll temp = a[x] + b[y] - c;
    ans = min(ans, temp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

ll popcnt(ll n) {
  ll res = 0;
  while (n) {
    n = n & (n - 1);
    res++;
  }
  return res;
}

ll f(ll n) {
  ll res = 0;
  while (n) {
    n = n % (popcnt(n));
    res++;
  }
  return res;
}

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

  ll n;
  cin >> n;

  ll val[3];
  memset(val, 0, sizeof(val));

  string s;
  cin >> s;

  ll cnt = 0;
  for (ll i = 0; i < n; i++) {
    if (s[i] == '1')
      cnt++;
  }

  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < 3; j++) {

      ll sign = j - 1;
      ll cnt1 = cnt + sign;
      if (cnt1 <= 0)
        continue;
      val[j] = (val[j] + (s[i] == '1') * power(2, n - i - 1, cnt1)) % cnt1;
    }
  }

  for (ll i = 0; i < n; i++) {
    if (s[i] == '0') {
      ll res = (val[2] + power(2, n - i - 1, cnt + 1)) % (cnt + 1);

      cout << 1 + f(res) << en;
    } else {

      if ((cnt - 1) <= 0) {
        cout << 0 << en;
        continue;
      }

      ll res = (val[0] - power(2, n - i - 1, cnt - 1) + (cnt - 1)) % (cnt - 1);
      cout << 1 + f(res) << en;
    }
  }

  return 0;
}


Measured memory_bytes: 3776
#include <iostream>
#include <stdio.h>
#include <cstdlib>
 
using namespace std;
 
int main(void) {
    int n, k;
    cin >> n >> k;
    unsigned long long a = n / k;
    unsigned long long ans = a * a * a;
    if(k % 2 == 0){
        int c = n + (k / 2);
        unsigned long long b = c / k;
        ans = ans + b*b*b;
    }
    printf("%llu", ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,q;
    cin>>n>>k>>q;
    int a[q];
  int b[n]={0};

  for(int i=0;i<q;i++)
  {
   cin>>a[i];
  }
  for(int i=0;i<q;i++)
  {
   b[a[i]-1]++;
   }
   for(int i=0;i<n;i++)
  {
   b[i]=b[i]+k;
   }
for(int i=0;i<n;i++)
  {
   b[i]=b[i]-q;
   }
   for(int i=0;i<n;i++)
  {
   if(b[i]<=0) cout<<"No"<<endl;
   else cout<<"Yes"<<endl;
   }
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int dfs(int i,vector<vector<int>>&g,vector<int>&dp)
{	if(dp[i]!=-1)
	{
		return dp[i];
	}
	
	int temp=0;
	for(auto adj:g[i])
	{
		temp=max(temp,dfs(adj,g,dp)+1);
	}
	dp[i]=temp;
	return temp;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	int m;
	cin>>n>>m;
	vector<vector<int>>g(n);
	vector<int>dp(n,-1);
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		x--;y--;
		g[x].push_back(y);
	}
	int res=INT_MIN;
	for(int i =0;i<n;i++)
	{
		res=max(res,dfs(i,g,dp));
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 8832
n = input()
s = raw_input()

result = 300000

before = 0
after = 0

for i in range(n):
    if s[i] == "E":
        before = before + 1
    if before > after:
        before = after
    if s[i] == "W":
        after = after + 1

print min(before, after)

Measured memory_bytes: 12416
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		int[][] A = new int[n][m];
		int[][] B = new int[m][l];
		long[][] C = new long[n][l];
		int i, j, k;
		long sum = 0;
		for (i = 0; i < n; i++) {
			for (j = 0; j < m; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		for (i = 0; i < m; i++) {
			for (j = 0; j < l; j++) {
				B[i][j] = sc.nextInt();
			}
		}
		for (i = 0; i < n; i++) {
			for (j = 0; j < l; j++) {
				for (k = 0; k < m; k++) {
					sum += A[i][k] * B[k][j];
				}
				C[i][j] = sum;
				sum = 0;
				if (j == l - 1) {
					System.out.print(C[i][j]);
				} else {
					System.out.print(C[i][j] + " ");
				}
			}
			System.out.println();
		}
		sc.close();
	}
}


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

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

    int ac, wa, tle, re;
    ac = wa = tle = re = 0;
    string T ("AC"); string WA ("WA"); string TLE ("TLE"); string RE ("RE");
    
    string t;
    while(N--) {
        cin >> t;
        if(t.compare(T) == 0) {
            ++ac;
        } else if(t.compare(WA) == 0) {
            ++wa;
        } else if(t.compare(TLE) == 0) {
            ++tle;
        } else {
            ++re;
        }
    }
    cout << "AC x " << ac << "\n" << "WA x " << wa << "\n" << "TLE x " << tle << "\n" << "RE x " << re << "\n";
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>

using namespace std;
using ll = long long;

ll vx[4] = { -1, 0, 0, 1};
ll vy[4] = { 0, 1, -1, 0 };

bool isIn(ll x, ll y, ll h, ll w) {
	if (x >= 0 && y >= 0 && x < w && y < h) return true;
	else return false;
}

int main() {
	ll H, W;
	cin >> H >> W;
	vector<vector<char>> field(H, vector<char>(W));
	for (ll i = 0; i < H; i++)
	{
		for (ll j = 0; j < W; j++)
		{
			cin >> field[i][j];
		}
	}
	ll count = 0;
	for (ll i = 0; i < H; i++)
	{
		for (ll j = 0; j < W; j++)
		{
			if (field[i][j] == '.') continue;
			bool flag = false;
			for (ll k = 0; k < 4; k++)
			{
				if (isIn(j + vx[k], i + vy[k], H, W) && field[i + vy[k]][j + vx[k]] == '#') flag = true;
			}
			if (!flag) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int A[200000] ={0};
int main()
{
    int N=0;
    int max = 0;
    int max_second = 0;
    (void)scanf("%d",&N);


    for(int i = 0; i < N; i++)
    {
      (void)scanf("%d", &A[i]);
      if(max <= A[i])
      {
         max_second = max;
         max = A[i];
      }
      else if(max_second <= A[i])
      {
         max_second = A[i];
      }
    }

    for(int j = 0; j < N; j++)
    {
       if(A[j] == max)
       {
           printf("%d\n",max_second);
       }
       else
       {
           printf("%d\n",max);
       }
    }

    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using ld = long double;

int main(){
    ll h,w,x,y;
    cin >> w >> h >> x >> y;
    cout << setprecision(10) << fixed;

    ld a1,a2;
    ld ans = (ld)(h*w)/2;
    cout << ans << " ";

    if(x*2 == w && y*2 ==h){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    
    return 0;
}

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

ll g(ll N, ll k){
    ll p = (ll)1 << k;
    return (N+1)/(2*p)*p + max((ll)0, (N+1)%(2*p) - p);
}

int main(){
    ll A, B;
    cin >> A >> B;
    
    ll ans = 0;
    ll p = 1;
    for(ll k=0; k<=50; k++){
        ll cnt = g(B,k) - g(A-1,k);
        if(cnt%2==1) ans+=p;
        p*=2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <map>
#include <cctype>
#include <cstring>
#include <sstream>
#define MOD 1000000007LL

using namespace std;

typedef long long ll;
typedef string::const_iterator State;
typedef pair<int,int> P;
int n[4];
int all;
int m;
string str[51];
map<string,int> ind;
vector<P> vec[51];
vector<int> rule;
ll dp[51][51][51][51];

void make_rule(int v){
	if(all<rule.size())return;
	for(int i=0;i<vec[v].size();i++){
		if(vec[v][i].first==0){
			rule.push_back(vec[v][i].second);
		}else{
			make_rule(vec[v][i].second);
		}
	}
}

void parse_2(State &begin,State &end,int par){
	if(*begin==' ')begin++;
	if(begin==end)return;
	if(*begin=='['){
		begin++;
		int bit=0;
		while(*begin!=']'){
			if(*begin=='A')bit|=(1<<0);
			if(*begin=='T')bit|=(1<<1);
			if(*begin=='G')bit|=(1<<2);
			if(*begin=='C')bit|=(1<<3);
			begin++;
		}
		begin++;
		vec[par].push_back(P(0,bit));
	}else{
		string st="";
		while(*begin!=' ' && begin!=end){
			st+=*begin;
			begin++;
		}
		if(ind.find(st)==ind.end()){
			int next=ind.size();
			ind[st]=next;
		}
		vec[par].push_back(P(1,ind[st]));
	}
	parse_2(begin,end,par);
	return;
}

void parse_1(State &begin,State &end){
	string st="";
	while(*begin!=':'){
		st+=*begin;
		begin++;
	}
	if(ind.find(st)==ind.end()){
		int next=ind.size();
		ind[st]=next;
	}
	int par=ind[st];
	begin++;
	begin++;
	parse_2(begin,end,par);
	return;
}

int main(void){
	for(int i=0;i<4;i++){
		scanf("%d",&n[i]);
		all+=n[i];
	}
	scanf("%d%*c",&m);

	for(int i=0;i<m;i++){
		getline(cin,str[i]);
		State begin=str[i].begin();
		State end=str[i].end();
		parse_1(begin,end);
	}
	make_rule(0);
	dp[0][0][0][0]=1;
	for(int i=0;i<rule.size();i++){
		int g[4];
		for(g[0]=0;g[0]<=n[0];g[0]++){
			if(g[0]>i)continue;
			for(g[1]=0;g[1]<=n[1];g[1]++){
				if(g[0]+g[1]>i)continue;
				for(g[2]=0;g[2]<=n[2];g[2]++){
					if(g[0]+g[1]+g[2]>i)continue;
					if(dp[g[0]][g[1]][g[2]][i-g[0]-g[1]-g[2]]>=1){
						if((rule[i]>>0 & 1) && g[0]+1<=n[0]){
							dp[g[0]+1][g[1]][g[2]][i-g[0]-g[1]-g[2]]+=dp[g[0]][g[1]][g[2]][i-g[0]-g[1]-g[2]];
							if(dp[g[0]+1][g[1]][g[2]][i-g[0]-g[1]-g[2]]>=MOD)dp[g[0]+1][g[1]][g[2]][i-g[0]-g[1]-g[2]]-=MOD;
						}
						if((rule[i]>>1 & 1) && g[1]+1<=n[1]){
							dp[g[0]][g[1]+1][g[2]][i-g[0]-g[1]-g[2]]+=dp[g[0]][g[1]][g[2]][i-g[0]-g[1]-g[2]];
							if(dp[g[0]][g[1]+1][g[2]][i-g[0]-g[1]-g[2]]>=MOD)dp[g[0]][g[1]+1][g[2]][i-g[0]-g[1]-g[2]]-=MOD;
						}
						if((rule[i]>>2 & 1) && g[2]+1<=n[2]){
							dp[g[0]][g[1]][g[2]+1][i-g[0]-g[1]-g[2]]+=dp[g[0]][g[1]][g[2]][i-g[0]-g[1]-g[2]];
							if(dp[g[0]][g[1]][g[2]+1][i-g[0]-g[1]-g[2]]>=MOD)dp[g[0]][g[1]][g[2]+1][i-g[0]-g[1]-g[2]]-=MOD;
						}
						if((rule[i]>>3 & 1) && i-g[0]-g[1]-g[2]+1<=n[3]){
							dp[g[0]][g[1]][g[2]][i-g[0]-g[1]-g[2]+1]+=dp[g[0]][g[1]][g[2]][i-g[0]-g[1]-g[2]];
							if(dp[g[0]][g[1]][g[2]][i-g[0]-g[1]-g[2]+1]>=MOD)dp[g[0]][g[1]][g[2]][i-g[0]-g[1]-g[2]+1]-=MOD;
						}
					}
				}
			}
		}
	}
	printf("%lld\n",all==rule.size()?dp[n[0]][n[1]][n[2]][n[3]]:0);
	return 0;
}

Measured memory_bytes: 54092
//Author- Vaibhav Singh


#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
*/
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double 
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define all(x) x.begin(),x.end()
#define re return 0;
// *#######################################################################################*

/*
bool isp(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return false;
        }
        
    }
}
  */
  
  ll powerm(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;    
  
    x = x % p; 
   
    if (x == 0) return 0;
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
   
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}
  long long lcm(long long a, long long b){//?????????
   return a * b / gcd(a, b);
}

/*
ll po(ll z,ll z1)
{
    ll rer=0;
    rer=     ((z*(z-1))/2+(z1*(z1-1))/2);
    return rer;

}
*/
/*
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
*/
/*
bool is_prime(ll n){
    for(ll i = 2;i*i<=n;i++){
        if(n%i == 0) return false;
    }
    return true;
}
*/
int inv(int a){
    return powerm(a,mod-2,mod);
}

ll const N=1e5;
ll fact[N], invfact[N];
 
void precompute(){
    fact[0] = 1;
    for(int i=1;i<N;i++) fact[i] = (fact[i-1]*i)%mod;
    invfact[N-1] = inv(fact[N-1])%mod;
    for(int i=N-2;i>=0;i--) invfact[i] = (invfact[i+1]*(i+1))%mod;
}
 
ll ncr(ll n, ll r){
    if(n<r) return 0;
    return (((fact[n]*invfact[r])%mod)*invfact[n-r])%mod;
}


//*88888*********5555555555555555******88888888$$$$$$$$$$******!!!!!!!!!!
    
       int main()
       {
           //????????
     fast
          ll n;
          cin>>n;
          if(n==1)
          {
              o("0")
              re
          }
         o("1")
         
         
         
         
         
         
         
         
         
         
        
        
        
           
//?????????
re}

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

int main(void){
    int n, m, r;
    cin >> n >> m >> r;
    vector<vector<int>> graph(n, vector<int>(n));
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i == j){
                graph[i][j] = 0;
            }else{
                graph[i][j] = (int)1e8;
            }
        }
    }
    vector<int> route(r);
    for(int i=0; i<r; i++){
        int a;
        cin >> a;
        route.at(i) = a - 1;
    }
    for(int i=0; i<m; i++){
        int a, b, c;
        cin >> a >> b >> c;
        graph[a-1][b-1] = c;
        graph[b-1][a-1] = c;
    }

    for(int k=0; k<n; k++){
        for(int i=0; i<n; i++){
            for(int j= 0; j<n; j++){
                if(graph[i][k] + graph[k][j] < graph[i][j]){
                    graph[i][j] = graph[i][k] + graph[k][j];
                }
            }
        }
    }

    sort(route.begin(), route.end());
    int ans = 1e8;
    do{
        int d = 0;
        for(int i=0; i+1<r; i++){
            d += graph[route.at(i)][route.at(i+1)];
        }
        if(d < ans){
            ans = d;
        }
    }while(next_permutation(route.begin(), route.end()));

    cout << ans << endl;    

    return 0;
}

Measured memory_bytes: 384
// Charan Sriramula
 
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;
 
const ll lg=22;
const ll N=1e6+5;
const ll M=16;
const ll INF=1e18;
const ll mod=1e9+7;
const double PI = 3.14159265358979323846;
 
#define is(n) scanf("%d",&n)
#define io(n) printf("%d\n",n)
#define ls(n) scanf("%lld",&n)
#define lo(n) printf("%lld\n",n)
 
#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
 
inline ll mul(ll a, ll b, ll p){ return (a * 1ll * b) % p; }
inline ll sub(ll a, ll b, ll p){ ll c = a - b; if(c < 0) c += p; return c; }
inline ll add(ll a, ll b, ll p){ ll c = a + b; if(c > p) c -= p; return c; }
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

vector<ll> pos[27];

int main()
{
    string s,t;
    cin>>s>>t;
    ll n=s.length(),m=t.length(),las=-1,cnt=0;
    for(ll i=0;i<n;i++)
    {
        pos[s[i]-'a'].pb(i);
    }
    for(ll i=0;i<m;i++)
    {
        ll cur=t[i]-'a';
        if(i==0)
        {
            ll lb=lower_bound(all(pos[cur]),las)-pos[cur].begin();
            if(lb==pos[cur].size()){cout<<-1<<endl;exit(0);}
            las=pos[cur][lb];
        }
        else
        {
            if(t[i]==t[i-1])
            {
                ll ub=upper_bound(all(pos[cur]),las)-pos[cur].begin();
                if(ub==pos[cur].size())
                {
                    cnt++;
                    las=-1;
                    ll lb=lower_bound(all(pos[cur]),las)-pos[cur].begin();
                    if(lb==pos[cur].size()){cout<<-1<<endl;exit(0);}
                    las=pos[cur][lb];
                }
                else{las=pos[cur][ub];}
            }
            else
            {
                ll lb=lower_bound(all(pos[cur]),las)-pos[cur].begin();
                if(lb==pos[cur].size())
                {
                    las=-1;
                    cnt++;
                    lb=lower_bound(all(pos[cur]),las)-pos[cur].begin();
                    if(lb==pos[cur].size()){cout<<-1<<endl;exit(0);}
                    las=pos[cur][lb];
                }
                else{las=pos[cur][lb];}
            }
        }
    }
    cout<<(cnt*n)+(las+1)<<endl;
}

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

#include <iostream>


#define MOD 1000000007

typedef unsigned long long ull;
typedef long long ll;

using namespace std;
auto f=[]()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
};

int main()
{
	f();
	string s;cin>>s;
	cout<<(s[0]==s[1]?((s[1]==s[2] || s[0]==s[2])?"No\n":"Yes\n"):"Yes\n");
	return 0;
}


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

#define infi            2e9
#define infl            5e18
#define MX              100005
#define pi              2*acos(0.0)
#define ll              long long int
#define rr              read()
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define ms(a,b)         memset(a, b, sizeof(a))
#define loop(i,n)       for(register int i=0;i<n;i++)
#define pool(i,n)       for(register int i=n-1;i>=0;i--)
#define loop1(i,n)      for(register int i=1;i<=n;i++)
#define pool1(i,n)      for(register int i=n;i>0;i--)

using namespace std;

inline ll read(){char c=getchar();ll num,sign=1;for(;c<'0'||c>'9';c=getchar())if(c=='-')sign=-1;for(num=0;c>='0'&&c<='9';){c-='0';num=num*10+c;c=getchar();}return num*sign;}
// inline ll pw(ll b, ll p){ll ans=1;while(p>0){if(p&1)ans*=b;p>>=1;b*=b;}return ans;}
// inline bool isPrime(ll n){if(n==1)return false;if(n==2)return true;if(!(n%2))return false;for(ll i=3;i<=sqrt(n);i+=2)if(!(n%i))return false;return true;}
// inline ll gcd(ll a, ll b){if(a==0)return b;return gcd(b%a,a);}

// //*************************************  Bitmask Opereations  **********************************//
// int Set(int N,int pos){return N=N | (1<<pos);}
// int reset(int N,int pos){return N= N & ~(1<<pos);}
// bool check(int N,int pos){return (bool)(N & (1<<pos));}
// //********************************************************************************************//


int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    //#ifdef rid.dle
    //freopen("in.txt", "r", stdin);
    //#endif
    
    int n=rr;
    int ar[MX],dp[MX];

    loop(i,n)dp[i]=infi,ar[i]=rr;

    dp[0]=0;
    loop(i,n){
        for(int j:{i-1,i-2}){
            if(j>-1){
                dp[i] = min(dp[i], dp[j]+abs(ar[i]-ar[j]));
            }
        }
    }

    cout << dp[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}




map<string, ll> card;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

    

  vector<string> dic;
  ll N ;cin >> N;
  rep(i,N){
    string inp; cin >> inp;
    card[inp]++;
    dic.pb(inp);
  }
  ll M ; cin >> M ;
  rep(i,M){
    string inp; cin >> inp;
    card[inp]--;
    dic.pb(inp);
  }

  rmsame(dic);

  ll ans = 0 ; 
  rep(i,dic.size())
    ans = max(ans, card[dic[i]]);
  
  cout << ans << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;

  return 0;
}


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

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_n = 15;
const int max_m = 1000+10;
vector<Int> key[max_m];
vector<Int> value;
Int dp[1<<max_n]; //set 

int main(void) {
    int N,M;
    cin>>N>>M;

    for(int i = 0;i < (1<<N);i++) {
        dp[i] = TEN(10);
    }
    
    for(int i = 0;i < M;i++) {
        Int a,b;
        cin>>a>>b;
        value.push_back(a);
        for(int j = 0;j < b;j++) {
            int c;
            cin>>c;
            key[i].push_back(c);
        }
    }

    dp[0] = 0;
    for(int i = 0;i < (1<<N);i++) {
        for(int j = 0;j < M;j++) {
            int bit = i;
            for(int k = 0;k < key[j].size();k++) {
                bit |= (1<<(key[j][k]-1));
            }
            dp[bit] = min(dp[bit],dp[i]+value[j]);
        }
    }

    if(dp[(1<<N)-1] == TEN(10))
        cout<<-1<<endl;
    else
        cout<<dp[(1<<N)-1]<<endl;


    return 0;
}



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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    int n, m; cin >> n >> m;
    bool f = true;
    vector<int> v(n, -1);
    REP(i, m) {
        int s, c;
        cin >> s >> c;
        s--;
        if(n != 1 && s == 0 && c == 0) {
            f = false;
        }
        if(v[s] != -1 && v[s] != c) {
            f = false;
        }
        v[s] = c;
    }
    if(!f) {
        cout << -1 << endl;
        return 0;
    }
    if(v[0] == -1) {
        if(n == 1)  cout << 0;
        else cout << 1;
    } else {
        cout << v[0];
    }
    FOR(i, 1, n) {
        if(v[i] == -1) {
            cout << 0;
        } else {
            cout << v[i];
        }
    }
    cout << endl;
    

    return 0;
}

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

int main(void){
    int n;
    cin >> n;
    int res=1;
    
    int h[n];
    for(int i=0;i<n;i++){
        cin >> h[i];
        if(i!=0){
            bool can = true;
            for(int j=0;j<i;j++){
                if(h[j]>h[i]){
                    can = false;
                    break;
                }
            }
            if(can){
                res++;
            }
        }
    }
    
    
    cout << res << endl;
    
}


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

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> pix(h + 2, vector<char>(w + 2, '#'));
    for (int i = 1; i < h + 1; i++) {
        for (int j = 1; j < w + 1; j++) {
            cin >> pix.at(i).at(j);
        }
    }

    for (int i = 0; i < h + 2; i++) {
        for (int j = 0; j < w + 2; j++) {
            cout << pix.at(i).at(j);
        }
        cout << endl;
    }
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()

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

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main() { 
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i += 2) {
        if (S[i] == 'h' && S[i + 1] == 'i') {
            
        } else {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0; 
}

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

int main(int argc,char *argv[]){
	int a,b;
	scanf("%d %d", &a, &b);
	if(a == b){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <unordered_map>
#define int long long int
#define double long double
#define endl "\n"
#define PI 3.141592653589793238462643383279502884
#define sp(x)   setprecision(x)
#define ceil(a,b)   (a+(b-1))/b
#define LCM(a,b)    (a*b)/__gcd(a,b)
#define all(v)  v.begin(),v.end()
#define alls(s,v)  s.begin(),s.end(),v
#define gena(arr,n,nxt)  generate(arr,arr+n, nxt)
#define genv(v,nxt)  generate(v.begin(),v.end(), nxt)
#define base ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define exit return 0;
#define is(x) cout << #x << " = " << x << endl;
using namespace std;
const int N=500000;
bool prime[N];
void sieve(){
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<100000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<100000; i += p)
                prime[i] = false;
        }
    }
}
int nxt(){int x;cin >> x;return x;}
vector<int>adj[N];
bool vis[N];
int32_t main(){
    base
    int n=nxt(),k=nxt(),x=nxt(),y=nxt();
    int sum=0;
    for(int i=0;i<n;i++){
        if(i<k)sum+=x;
        else sum+=y;
    }
    cout<<sum;
    exit
}


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

int main(){
    int h, w, i_ans, j_ans;
    cin >> h >> w;
    string s;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> s;
            if(s == "snuke"){
                i_ans = i;
                j_ans = j;
            }
        }
    }
    string s_ans = "A";
    s_ans[0] += j_ans;
    cout << s_ans[0] << i_ans+1 << endl;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks/dp_i
//I - Coins
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N; cin>>N;
    vector<double> pn(N+1);
    FOR(i,1,N+1){
        cin>>pn.at(i);
    }    
    vector<vector<double>> dp(N+1,vector<double>(N+1));
    dp[0][0]=1;
    auto dpij = [&](ll i,ll j)->double{
        if (i<0||i>N) return 0;
        if (j<0||j>N) return 0;
        return dp[i][j];
    };
    FOR(i,0,N+1){
        FOR(j,0,N+1){
            if(i==0&&j==0) continue;
            ll tm=i+j; //回目
            if(tm>=pn.size()) continue;
            dump(tm,i,j); //表、うら
            auto p=pn.at(tm);
            dp[i][j] = p*dpij(i-1,j) + (1.0f-p)*dpij(i,j-1);
        }
    }
    dump(dp);
    double ans=0;
    FOR(i,0,N+1){
        FOR(j,0,N+1){
            if(i+j==N&&i>j) ans+=dp[i][j];
        }
    }
    cout<<fixed<<std::setprecision(10)<<ans<<endl;
    return 0;
}

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

typedef long long ll;

int main(){
    
    string s;
    cin >> s;
    int num[26] = {0};
    for(int i = 0; i < (int)s.size(); i++)
    {
        int a = s[i]-'a';
        num[a]++;
    }
    string ans = "Yes";
    for(int i = 0; i < 26; i++)
    {
        if(num[i]%2!=0) ans = "No";
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

cnt = {}
A.each do |x|
  cnt[x] = 0 unless cnt.has_key? x
  cnt[x] += 1
end

cnt2 = []
cnt.each do |k,v|
  cnt2 << [k,v]
end

cnt2.sort_by!{ |x| x[1]}

if cnt2.size <= K
  puts 0
else
  ret = 0
  (cnt2.size - K).times do |i|
    ret += cnt2[i][1]
  end
  puts ret
end


Measured memory_bytes: 42504
#include<stdio.h>
#include<math.h>
int main(){
	long long int h;
	long long int i;
	long long int cnt=0;
	long long int result=0;
	scanf("%lld",&h);
	if(h==1) result=1;
	else{
		do{
			h=h/2;
			cnt++;
		}while(h!=1);
		
		for(i=0;i<=cnt;i++){
			result+=pow(2,i);
		}
	}
	printf("%lld",result);
	return 0;
}

Measured memory_bytes: 128