akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    char c[H][W];
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++) {
            cin >> c[i][j];
        }
    }

    int count, pattern=0;
    for(int i=0; i<pow(2, H); i++){
        for(int j=0; j<pow(2, W); j++){
            count = 0;
            for(int h=0; h<H; h++){
                if ( ((i/(int)pow(2, h)) % 2) == 1) continue;
                for(int w=0; w<W; w++) {
                    if ( ((j/(int)pow(2, w)) % 2) == 1) continue;
                    if(c[h][w] == '#') count++;
                }
            }
            if(count==K) pattern++;
        }
    }
    cout << pattern << endl;
}

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

Measured memory_bytes: 2464
l = 10**6
primes = [False] * 2 + [True] * (l - 2)   
for i in range(2, l):
  if primes[i]:
    for j in range(i ** 2, l, i):
      primes[j] = False
x=int(input())
for i in range(x,l):
    if primes[i]:
        print(i)
        break


Measured memory_bytes: 18676
mod = 10**9+7
N,M = map(int,input().split())
S = list(map(int,input().split()))
T = list(map(int,input().split()))
dp = [[0]*(len(T)+1) for _ in range(len(S)+1)]
for s in range(len(S)+1):
    for t in range(len(T)+1):
        if s == 0 or t == 0:
            dp[s][t] = 1

for s in range(len(S)):
    for t in range(len(T)):
        if S[s]==T[t]:
            dp[s+1][t+1] = (dp[s+1][t]+dp[s][t+1])%mod
        else:
            dp[s+1][t+1] = (dp[s+1][t]+dp[s][t+1]-dp[s][t])%mod
print(dp[len(S)][len(T)])

Measured memory_bytes: 73180
#include<bits/stdc++.h>
using namespace std;
    
int main()
{
    string s;
    cin>>s;
    int ans=0;
    int sum=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='R')
        sum++;
        else
        sum=0;
        ans=max(ans,sum);
    }
    cout<<ans;
}

Measured memory_bytes: 3508
#include <bits/stdc++.h>
#define pi acos(-1)
#define MOD 998244353
#define MAX 100000
#define inf 1e9+10
#define print(a) cout<< #a <<" --> "<<(a)<<endl
#define Endl endl
#define endk endl
#define Endk endl
#define fileinput freopen("altsub - Copy.txt","r",stdin)
#define fileoutput freopen("max-med.txt","w",stdout)
typedef std::vector<int> vi;
typedef std::vector<vi > vvi;
typedef std::pair<int,int> pii;
typedef long long ll;

 using namespace std;

ll a[MAX+4],b[MAX+4];

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

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

    ll x=(a[n-1]/b[n-1])+1; //print(x);
    x=b[n-1]*x-a[n-1]; //print(x);
    if(a[n-1]%b[n-1]==0) x=0;

    for(int i=n-2;i>=0;i--)
    {
        ll A=a[i]; ll B=b[i]; //if(A==B) continue;
        ll d=(x+A)/B;
        if(B*d-A>=x) x=B*d-A;
        else x=B*(d+1)-A;
    }
    cout<<x<<endl;;

}

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

using namespace std;
typedef long long ll;

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    if(a.back() == b.front() && b.back() == c.front()){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from collections import Counter as c
import sys
input = sys.stdin.readline

S = [input() for _ in range(int(input()))]
T = [input() for _ in range(int(input()))]

S = c(S)
T = c(T)
ans = 0
for s in S:
    ans = max(ans,S[s]-T[s])
print(ans)

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

void solve(int TestCase) {
    int n;
    cin >> n;
    auto A = vector<int>(n);
    for(auto& x : A)
        cin >> x;
    map<long long, long long> cnt;
    for(auto i = 0; i < n; ++i)
    {
        cnt[A[i]]++;
    }

    long long all = 0;
    for(auto& x : cnt)
    {
        if(x.second > 1)
            all += x.second * (x.second - 1) / 2;
    }

    for(auto i = 0; i < n; ++i)
    {
        long long x = A[i];
        long long ret = all - cnt[x] * (cnt[x] - 1) / 2;
        if(cnt[x] > 2)
            ret += (cnt[x] - 1) * (cnt[x] - 2) / 2;
        cout << ret << endl;
    }
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int t = 1;
    //cin >> t;
    for(auto i = 1; i <= t; ++i) {
        //cout << "Case #"<< i << ": ";
        solve(i);
    }
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	string s;cin>>s;
	vector<pair<char,int> > v;
	v.push_back(make_pair(s[0],1));
	for(int i=1;i<3;i++){
		if(s[i]==v[v.size()-1].first){
			v[v.size()-1].second++;
		}
		else{
			v.push_back(make_pair(s[i],1));
		}
	}
	int ans=0;
	for(int i=0;i<v.size();i++){
		if(v[i].first=='R'){
			ans = max(ans,v[i].second);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3612
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

//https://doc.rust-jp.rs/book/second-edition/ch08-03-hash-maps.html
fn main() {
    let w: String = read();
    let mut map = HashMap::new();

    for s in w.chars() {
        let count = map.entry(s).or_insert(0);
        *count += 1;
    }

    println!(
        "{}",
        if map.values().all(|x| x % 2 == 0) {
            "Yes"
        } else {
            "No"
        }
    );
}


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    string A; cin >> A;
    ll lenA = A.length();
    ll alp[26] = {0};
    rep(i, lenA){
        alp[A[i] - 'a']++;
    }
    ll ans = lenA * (lenA-1) / 2 + 1; //何もしない + nC2
    rep(i, 26){
        ans -= alp[i]*(alp[i]-1)/2;
    }
    cout << ans << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 640
//https://atcoder.jp/contests/abc117/tasks/abc117_b

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
#include<numeric>


using namespace std;
int main(){
	int n,sum,max;
	cin>>n;
	
	vector<int> c(n);
	for(int i=0; i<n; i++) cin>>c.at(i);
	
	sum=std::accumulate(c.begin(),c.end(),0);
	max=*std::max_element(c.begin(),c.end());

	if(max*2<sum) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}





Measured memory_bytes: 256
print(["1","1","2","6","24","120","720","5040","40320","362880","3628800","39916800","479001600","6227020800","87178291200","1307674368000","20922789888000","355687428096000","6402373705728000","121645100408832000","2432902008176640000","51090942171709440000"][int(input())])

Measured memory_bytes: 6724
def II(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
N=II()
A=LI()
ans=1000
for i in range(N-1):
  if A[i]<A[i+1]:
    ans+=(ans//A[i])*(A[i+1]-A[i])
print(ans)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}



int main(){FIN

    ll n,k;cin>>n>>k;
    vll a(n); REP(i,n) cin>>a[i];
    VSORT(a);
    ll ans=0;
    REP(i,k){
        ans += a[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
    	int X, A;
    	
        void solve(InputReader in, PrintWriter out) {
        	X = in.nextInt();
        	A = in.nextInt();
        	out.println(X < A ? 0 : 10);
        }
        
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}


Measured memory_bytes: 21460
mod=10**9+7
n=int(input())
rec,cer=tuple(map(int,input().split())),tuple(map(int,input().split()))
table=[-1]*n#確定した山ならば、その高さ。-1は未確定
table[0]=rec[0]
table[-1]=cer[-1]
if rec[-1]!=cer[0]:print(0);exit()#同じ山々を踏破してるので全体の最大値が違うのは矛盾
for i in range(1,n):
    if rec[i]>rec[i-1]:
        if table[i]!=-1 and table[i]!=rec[i]:print(0);exit()
        table[i]=rec[i]
        if cer[i]<table[i]:print(0);exit()
    if cer[n-i-1]>cer[n-i]:
        if table[n-i-1]!=-1 and table[n-i-1]!=cer[n-i-1]:print(0);exit()
        table[n-i-1]=cer[n-i-1]
        if rec[n-i-1]<table[n-i-1]:print(0);exit()
#各人について、「記録が真に増加したなら、その山の高さは確定する」は真。もう一人の情報と矛盾しないかも見る。
start,f=0,0
now=0
won=0
for i in range(n):
    now=max(now,table[i])
    won=max(won,table[-i-1])
    if now!=rec[i] or won!=cer[-i-1]:print(0);exit()
if now!=won:print(0);exit()
#念のため二人の情報と矛盾しないかシミュレーションしておく
ans=1
for i,v in enumerate(table):
    if v==-1 and f==0:
        start=i
        f=1    #[start,?)に連続して高さ未定義の山が続く
    if v!=-1 and f:
        kosuu=i-start #[start,v)であることがわかったので個数は左
        f=0
        ans=ans*pow(min(v,table[start-1]),kosuu,mod)%mod
        #高さ未定義の山が続く群に対して、そいつらは両隣に高さを抑えられるので、場合の数はこうなる
        #table[0]とtable[n-1]については高さが必ず確定するので、両隣に確定済みの山は必ず存在する

print(ans)


Measured memory_bytes: 25612
#include<stdio.h>
#include<string.h>
typedef struct{
  int page;
  char name[50];
}STR;
main(){
  STR temp,str[10000];
  int i=0,j,k;
  int count=0;
  while(scanf("%s %d",str[i].name,&str[i].page)!=EOF){
    i++;
  }
  for(j=0;j<i;j++){
    for(k=i-1;0<k;k--){
      if(strcmp(str[k].name,str[k-1].name)<0){
	temp=str[k];
	str[k]=str[k-1];
	str[k-1]=temp;
      }
      else if(strcmp(str[k].name,str[k-1].name)==0){
	if(str[k].page<str[k-1].page){
	  temp=str[k];
	  str[k]=str[k-1];
	  str[k-1]=temp;
	}
      }
    }
  }
  for(j=0;j<i;j++){
    if(j!=0){
      if(strcmp(str[j].name,str[j-1].name)==0){
	printf(" %d",str[j].page);
      }
      else{
	printf("\n%s\n%d",str[j].name,str[j].page);
      }
    }
    else{
      printf("%s\n%d",str[j].name,str[j].page);
    }
  }
  printf("\n");
  return 0;
}

			

Measured memory_bytes: 624
class Integer
  def is_prime?
    return true if self == 2

    return false if self < 2 || (self % 2 == 0)

    sqrt = Math.sqrt(self)
    3.step(sqrt, 2) do |i|
      return false if self % i == 0
    end

    true
  end
end

answer = 0
count = gets.chomp.to_i
count.times do
  n = gets.chomp.to_i
  answer += 1 if n.is_prime?
end

puts answer

Measured memory_bytes: 8772
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int i;
  cin >> i;
  int one = i / 1000;
  int two = (i - one * 1000) / 100;
  int three = (i - one * 1000 - two * 100) / 10;
  int four = (i - one * 1000 - two * 100 - three * 10) / 1;
  if ((one == two && two == three) || (two == three && three == four)) {
    cout << "Yes";
  } else {
    cout << "No"; 
  }
}


Measured memory_bytes: 3600
inputs = STDIN.readlines.map{|line|line.strip.split()}
input = inputs.shift
n = input[0].to_i
m = input[1].to_i
c = input[2].to_i
b_list = inputs.shift

counts = 0
n.times do |ni|
    a_list = inputs.shift
    sum = 0
    m.times do |mi|
        sum += b_list[mi].to_i * a_list[mi].to_i
    end
    if sum + c > 0 then
        counts += 1
    end
end

puts(counts)

Measured memory_bytes: 3836
n = int(input())
b = [int(i) for i in input().split()]
count = 0
ju = True
while(ju):
    for i in range(n):
        if b[i]%2 !=0:
            ju = False
            break
        b[i] = b[i]/2 
    if ju:
        count +=1
print(count)


Measured memory_bytes: 2940
package main
import "fmt"

func imin(a ...int) (int){
	min := a[0]
    for _, v := range a {
        if v < min {
            min = v
        }
    }
    return min
}

func imax(a ...int) (int){
	max := a[0]
    for _, v := range a {
        if v > max {
            max = v
        }
    }
    return max
}

func main() {
	var a,b,c int
	fmt.Scan(&a, &b, &c)
	fmt.Println(imax(a,b,c)-imin(a,b,c))
}

Measured memory_bytes: 512
#include <stdio.h>
#define LL long long
#define maxn 200010
int color[maxn],head[maxn],tot,n,size[maxn],sum[maxn];
LL ans[maxn];
struct node{
	int to,next;
}e[maxn<<1];
void add_edge(int u,int v){
	tot++,e[tot].to=v,e[tot].next=head[u],head[u]=tot;
}
LL get_num(LL x){
	return x*(x+1)/2;
}
void dfs(int u,int fa){
	int v,b,c,t,dt;
	LL pre;
	size[u]=1,c=color[u],pre=sum[c];//非u子树已算出的c颜色为根的节点数量
	for(b=head[u];b;b=e[b].next){
		v=e[b].to;
		if(v==fa)continue;
		t=sum[c];
		dfs(v,u);
		dt=sum[c]-t;//遍历了v之后，c颜色对应的变化量
		size[u]+=size[v];
		ans[c]-=get_num(size[v]-dt);//两个c颜色之间的，其他颜色节点数量
	}
	sum[c]=pre+size[u];//总的c颜色为根的节点数量
}
int main(){
	int i,u,v;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&color[i]);
	for(i=1;i<n;i++){
		scanf("%d%d",&u,&v);
		add_edge(u,v),add_edge(v,u);
	}
	for(i=1;i<=n;i++)ans[i]=get_num(n);
	dfs(1,0);
	for(i=1;i<=n;i++)ans[i]-=get_num(n-sum[i]);//n-sum[i]指离树根最近的i颜色之外的其他颜色(整棵树扣除所有以i颜色为根的子树)数量
	for(i=1;i<=n;i++)printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 25232
import math

h,n = map(int,input().split())
a = [] ; b = []
for i in range(n) :
  a1,b1 = map(int,input().split())
  a.append(a1) ; b.append(b1)

#dp[i] = 体力iの敵を倒すのに必要な魔力の最低値
dp = [0,min(b)]

for i in range(2,a[b.index(min(b))]+1) :
  dp.append(min(b))

for i in range(a[b.index(min(b))]+1,h+1) :
  dp.append(10**10)
  for j in range (n) :
    if i-a[j] < 0 :
      dp[i] = min(dp[i],b[j])
      continue
    dp[i] = min(dp[i],dp[i-a[j]]+b[j])

print(dp[h])

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>

int main(){
    ll N,P; cin>>N>>P;
    vector<ll> v;
    map<ll,int> mp;
    while(P>1){
        bool prime = true;
        for(ll i=2;i<=sqrt(P); ++i){
            if(P%i==0){ 
                ++mp[i];
                if(mp[i]==1){ v.push_back(i); }
                P /= i;
                prime = false;
                break;
            }
        }
        if(prime){
            ++mp[P];
            if(mp[P]==1){ v.push_back(P); }
            break;
        }
    }
    ll ans = 1;
    for(ll x:v){
        ll g = mp[x]/N;
        if(g>0){
            ans *= pow(x,g);
        }
    }
    cout << ans << "\n";
}

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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

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

    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    string s;
    cin >> s;

    for (int i = a; i < c; i++) {
        if (s[i] == '#' && s[i + 1] == '#') {
            cout << "No";
            return 0;
        }
    }
    for (int i = b; i < d; i++) {
        if (s[i] == '#' && s[i + 1] == '#') {
            cout << "No";
            return 0;
        }
    }
    if (c > d) {
        bool ok = false;
        for (int i = b; i <= d; i++) {
            if (s[i] == '.' && s[i - 1] == '.' && s[i + 1] == '.') {
                ok = true;
            }
        }
        if (!ok) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <limits.h>

using namespace std;

int main(int argc, char const* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<array<long long, 3>> xyz(N);
    for (int i=0; i<N; ++i) {
        cin >> xyz[i][0] >> xyz[i][1] >> xyz[i][2];
    }
    vector<long long> tmp(N);
    long long max = 0;
    for (int x: {1, -1}) {
        for (int y: {1, -1}) {
            for (int z: {1, -1}) {
                for (int i=0; i<N; ++i) {
                    tmp[i] = xyz[i][0] * x + xyz[i][1] * y + xyz[i][2] * z;
                }
                sort(tmp.begin(), tmp.end(), greater<long long>());
                long long sum = 0;
                for (int j=0; j<M; ++j) {
                    sum += tmp[j];
                }
                if (sum > max) {
                    max = sum;
                }
            }
        }
    }
    cout << max << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define pb(x) push_back(x)
#define HAYAKU_HAYAKU ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const long long SIZE = 1000001;
int main()
{
    HAYAKU_HAYAKU; 
    ll t,k,ans = 0,d;
    cin>>t>>k;
    d = k*k;
    for(int I = 0 ; I < t; I++)
    {
        ll n,m,r;
        cin>>n>>m;
        r = (n*n) + (m*m);
        if(r <= d)
            ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 3624
#define lp(i,n) for(int i=0;i<n;i++)
#define pau system("pause")
#include<bits/stdc++.h>

using namespace std;
int main() {
    int n,a,b;
    cin>>n>>a>>b;
    if(n*a>b)
        cout<<b<<endl;
    else
        cout<<n*a<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 50

int main(void)
{
  int i, j;
  int N;
  int d[MAX];
  int kaihuku=0;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&d[i]);
  }

  for(i=0;i<N;i++){
    for(j=N-1;j>i;j--){
      kaihuku += d[i]*d[j];
    }
  }
  printf("%d\n",kaihuku);

  return 0;
}





Measured memory_bytes: 128
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

dp = [[0] * (W + 1) for _ in range(N + 1)]
# dp[i][j](j=0,1,...,W)の値が求まっている状態で、dp[i+1][j]を更新することを考える

for i in range(N):
    for j in range(W+1):#重さ0からWまでチェック
        if j-w[i]>=0:#入れてもOKな場合,容量と価値を足す
            dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i])
        else:#何も入れずに先に進む
            dp[i+1][j]=dp[i][j]
print(max(dp[N]))


Measured memory_bytes: 120300
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  rep(i,h){
    cin>>s[i];
  }
  rep(i,h){
    rep(j,w){
      int count=0;
      if(s[i][j]=='#'){
        cout<<'#';
      }
      else{
        rep(k,8){
          if(i+dx[k]>=0 && j+dy[k]>=0 && i+dx[k]<h && j+dy[k]<w){
            if(s[i+dx[k]][j+dy[k]]=='#'){
              count++;
            }
          }
        }
        cout<<count;
      }
    }
    cout<<'\n';
  }
  return(0);
}


Measured memory_bytes: 256
#include <stdio.h>

void display_residents(int info[4][3][10])
{
	int i, j, k;

	while(i < 4)
	{
		j = 0;
		while(j < 3)
		{
			k = 0;
			while(k < 10)
			{
				printf(" %d", info[i][j][k]);
				if(k == 9)
					printf("\n");
				k++;
			}
			j++;
			if(j == 3 && i < 3)
				printf("####################\n");
		}
		i++;
	}
}

int main(void)
{
	int info[4][3][10] = {};		//[Ridge][Floor][Room].
	int procedure;					//Number of move-in procedures.
	int ridge, floor, room, resident = 0;
	int i;

	scanf("%d", &procedure);

	i = 0;
	while(i < procedure)
	{
		scanf("%d %d %d %d", &ridge, &floor, &room, &resident);
		info[ridge - 1][floor - 1][room - 1] += resident;
		i++;
	}
	
	display_residents(info);

	return (0);
}



Measured memory_bytes: 2148
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define all(a) (a).begin(), (a).end()

int main() {
	int ans = 0, a, b, c;
	cin >> a >> b >> c;
	for (int i = a; i <= b; ++i)
		if (c % i == 0)
			ans++;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3104
def a(q)
puts"? "+q.join(" ")
STDOUT.flush
gets
end
N=gets.to_i
s="! "
I=(0..2*N).to_a
f=a I[1..N]
l,r=1,N+1
9.times{
m=(l+r)/2
q=I[m,N]
f==a(q)?l=m:r=m
}
x=I[r,N-1]
y=I-[0]-I[l,N+1]
1.upto(2*N){|i|
s+=a([i]+(x.index(i)?y:x))[0]
}
puts s

Measured memory_bytes: 4300
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
const lint mod=1e9+7;


int N;
// 隣接リスト
vector<vector<int>> connected_nodes;
// 再帰関数の結果
vector<vector<int>> memo;

int search(int x, unsigned int came){
  int cnt = 0;
  // 頂点xを探索済みに
  came |= (1<<x);
  vector<int> stack;
  // 隣接ノードのうち探索済みでないものをスタックに積む
  for(int i : connected_nodes[x]){
    if(!(came & (1<<i))){
      stack.push_back(i);
    }
  }
  while(stack.size() != 0){
    if(memo[*(stack.end()-1)][came] != -1){
      // 探索済みであれば結果を返す
      cnt += memo[*(stack.end()-1)][came];
    }else{
      // スタックのパスを探索
      cnt += search(*(stack.end()-1), came);
    }
    stack.pop_back();
  }
  // すべての頂点を訪れているのなら1を返す
  int tmp = 0;
  REP(i, N) if(came & (1<<i)) tmp++;
  if(tmp == N) return 1;
  return cnt;

}

int main()
{
  int m;
  cin >> N >> m;
  connected_nodes = vector<vector<int>>(N);
  memo = vector<vector<int>>(N, vector<int>(1<<N, -1));
  REP(i,m){
    int a, b;
    cin >> a >> b;
    connected_nodes[a-1].push_back(b-1);
    connected_nodes[b-1].push_back(a-1);
  }

  unsigned int came = 0;

  cout << search(0, came) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i++)
using namespace::std;

int main(){
	int n,ans;
	char s[200],t[200];
	cin>>n>>s>>t;
	REP(i,n){
		int j=0,f=0;
		
		if(s[i]==t[j])REP(k,n-i){
			if(s[i+k]!=t[k]){
				f=0;
				break;
			}
			f=1;
		}
		if(f==1){
		printf("%d\n",n+i);
		return 0;
		}
		
	}
	printf("%d\n",n*2);
	return 0;
}

Measured memory_bytes: 256
#pragma warning disable IDE0011
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Convert;
using static System.Math;
using static Extentions;

class IO
{
    int idx;
    string[] line;

    public void R(params char[] sep) { line = Console.ReadLine().Split(sep); idx = 0; }
    public string S => line[idx++];
    public string[] Ss => line.Skip(idx++).ToArray();
    public char C => char.Parse(line[idx++]);
    public char[] Cs => line.Skip(idx++).Select(char.Parse).ToArray();
    public int I => int.Parse(line[idx++]);
    public int[] Is => line.Skip(idx++).Select(int.Parse).ToArray();
    public long L => long.Parse(line[idx++]);
    public long[] Ls => line.Skip(idx++).Select(long.Parse).ToArray();
    public double F => double.Parse(line[idx++]);
    public double[] Fs => line.Skip(idx++).Select(double.Parse).ToArray();
    public decimal D => decimal.Parse(line[idx++]);
    public decimal[] Ds => line.Skip(idx++).Select(decimal.Parse).ToArray();
    public BigInteger B => BigInteger.Parse(line[idx++]);
    public BigInteger[] Bs => line.Skip(idx++).Select(BigInteger.Parse).ToArray();

    public void Write(params object[] xs)
    {
        Console.Write(xs.First());
        foreach (var x in xs.Skip(1)) Console.Write(" " + x);
        Console.WriteLine();
    }
}

static class Extentions
{
}

static class Program
{
    static void Main()
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        Solve(new IO());
        Console.Out.Flush();
    }

    static void Solve(IO io)
    {
        io.R();
        var n = io.I;
        io.R();
        var a = io.Is;

        var b = new int[a.Length];
        int i, j = 0;
        for (i = a.Length - 1; i >= 0; i -= 2) b[j++] = a[i];
        if (a.Length % 2 == 0) i = 0; else i = 1;
        for (; j < b.Length; i += 2) b[j++] = a[i];

        Console.Write(b[0]);
        for (i = 1; i < b.Length; i++) Console.Write(" " + b[i]);
    }
}

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

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> A(Q), point(N, K);
  for (int i = 0; i < Q; i++) {
    cin >> A[i];
    point[A[i]-1]++;
  }
  for (int i = 0; i < N; i++) {
    if (point[i] > Q) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


Measured memory_bytes: 1408
/*
ID: y1197771
PROG: test
LANG: C++
*/
#include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e3 + 10;
string s = "aeiou";

string a[4] = {"maerd", "remaerd", "esare", "resare"};
void solve() {
    while(cin >> s) {
        int n = s.size();
        int i = 0;
        reverse(s.begin(), s.end());
        bool f = 1;
        while(i < n) {
            bool tag = 0;
            for (int j = 0; j < 4; j++) {
                string t = s.substr(i, a[j].size());
                if(t == a[j]) {
                    i += a[j].size();
                    tag = 1;
                    break;
                }
           }
           if(!tag) {
                f = 0; break;
           }
        }
        if(f) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}
int main() {
   // freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
lint N;
lint ans = 0;

void dfs(lint c3, lint c5, lint c7, lint num){
  if(num > N) return;
  if(c3 && c5 && c7) ans++;
  dfs(1, c5, c7, 10 * num + 3);
  dfs(c3, 1, c7, 10 * num + 5);
  dfs(c3, c5, 1, 10 * num + 7);
}

signed main(){
  cin >> N;
  dfs(0, 0, 0, 0);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,X;
  cin>>N>>X;
  vector<int> A(N);
  for(int i=0;i<N;i++){
      cin >> A[i];
  }
  int H=0;
  sort(A.begin(), A.end());
  for(int i=0;i<N;i++) {
    if(X-A[i]<0){ 
        break;
    }
    if(i==N-1&&X-A[i]!=0) {
        break;
    }
      X-=A[i];
      H++;
}
  cout << H;
  return 0;
}


Measured memory_bytes: 3592
N = int(input())
A = [0] * N
for i in range(N):
    A[i] = int(input())

possible = 1
if A[0] != 0:
    possible = 0
ans = 0
for i in range(1, N):
    d = A[i] - A[i-1]
    if d > 1:
        if A[i] != 0:
            possible = 0
            break
    elif d == 1:
        ans += 1
    else:
        ans += A[i]
if possible:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 47080
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
 
#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)
 
ll gcd(ll x, ll y)
{
  if (x % y == 0)
  {
    return y;
  }
  return gcd(y, x % y);
}
 
int main()
{
  ll X, A, B;
  cin >> X >> A >> B;
  if (B - A <= 0){
    cout << "delicious" << endl;
  }else if (B - A <= X){
    cout << "safe" << endl;
  }else{
    cout << "dangerous" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i=1; i*i<=n ; i++){
    while(n%i==0){
      ++res[i];
      n /= i;
    }
  }
  if(n!=1) res[n]=1;
  return res;
}
map<int, int> prime_factor(int n){
  map<int, int> ma;
  for(int i=2 ; i*i<=n ; i++){
    while(n%i == 0){
      ma[i]++;
      n /= i;
    }
  }
  if(n != 1) ma[n]++;
  return ma;
}
int main(){
  int N;  cin>>N; 
  vector<int> v(N);
  rep(i,0,N){
    cin >> v[i];
  }
  int setwise = 0;
  int g = 0;
  rep(i,0,N){
    g = gcd(g, v[i]);
  }
  map<int, int> ma = prime_factor(v[0]);
  rep(i,1,N){
    map<int, int> now = prime_factor(v[i]);
    for(auto j : now){
      if(ma[j.fi]>0){
        if(g==1){
          cout << "setwise coprime" << endl;
        }else{
          cout << "not coprime" << endl;  
        }
        return 0;
      }
    }
    for(auto j : now){
      ma[j.fi]++;
    }
  }
  cout << "pairwise coprime" << endl;
  return 0;
}

Measured memory_bytes: 7292
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n],b[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
        if(i){
            b[i]=a[i]+b[i-1];
        }
        else{
            b[i]=a[i];
        }
    }
    ll ans=1e18;
    ll index1=0,index3=2;
    for(ll i=1;i<n-2;i++){
        ll ma,mi;
        ll x,y,z;
        while(abs(b[index1+1]*2-b[i])<abs(b[index1]*2-b[i])){
            index1++;
        }
        while(abs(b[n-1]-2*b[index3+1]+b[i])<abs(b[n-1]-2*b[index3]+b[i])){
            index3++;
        }
        x=b[i]-b[index1];
        y=b[index3]-b[i];
        z=b[n-1]-b[index3];
        ma=max(x,max(y,max(z,b[index1])));
        mi=min(x,min(y,min(z,b[index1])));
        ans=min(ans,ma-mi);
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main () {
	int n;
	string s;
	cin>>n>>s;
	int ans=0;
	for(int i=0;i<n-1;i++){
		if(s[i]!=s[i+1])ans++;
	}
	ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>

using namespace std;
#define SAY_YES cout<<"YES"<<endl;
#define SAY_Yes cout<<"Yes"<<endl;
#define SAY_NO cout<<"NO"<<endl;
#define SAY_No cout<<"No"<<endl;
#define IFYES(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;} 
#define IFYes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;} 
#define IFyes(TRUE_OR_FALSE) if(TRUE_OR_FALSE){cout<<"yes"<<endl;}else{cout<<"no"<<endl;} 
#define DEBUG_OUTPUT_ARRAY(XXX,ONE) for(int i=0;i<(ONE);i++){cout<<"DEBUG: i = "<<i<<" -> "<<XXX[i]<<endl;}
#define DEBUG_OUTPUT_ARRAY2(XXX,ONE,TWO) for(int i=0;i<(ONE);i++){cout<<"<<< i = "<<i<<" >>>"<<endl;for(int j=0;j<(TWO);j++){cout<<"DEBUG: j = "<<j<<" -> "<<XXX[i][j]<<endl; } }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX,ONE,TWO) for(int i=0;i<(ONE);i++){cout<<i<<"  ";for(int j=0;j<(TWO);j++){cout<<XXX[i][j]<<" "; } cout<<endl;}

typedef pair<long long int,long long int> pll;


const long long int mod=1000000007;
const long long int INF=99999999999999999;


long long int N,M,L,X,a[10005],res=0,tmp=0;
string str,resstr;
int main() {
	cout << fixed << setprecision(18);
    
    cin>>str;
    for(int i=0;i<str.length();i++){
        
        for(int j=i+1;j<=str.length();j++){
            tmp=0;
            for(int k=i;k<j;k++){
                if(str[k]=='A'||str[k]=='T'||str[k]=='G'||str[k]=='C'){tmp++;}
                else{tmp-=10000;}
            }
            if(res<tmp){resstr=str.substr(i,j-i);}
            res=max(res,tmp);
        }
    }
    cout<<res<<endl;
} 


Measured memory_bytes: 256
/** BiSmIlLaHiR rAhMaNiR rAhIm **\

*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*
*$*                                             *$*
*$*    ||||||||  ||||||||  ||||||||  ||||||||   *$*
*$*    ||    ||  ||           ||     ||         *$*
*$*    ||||||||  ||||||||     ||     ||||||     *$*
*$*    ||    ||        ||     ||     ||         *$*
*$*    ||    ||  ||||||||  ||||||||  ||         *$*
*$*                                             *$*
*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*$*

            \**  DIIT(17th batch) **/

#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define pf printf
#define sf scanf
#define endl "\n"
#define pb push_back
#define eb emplace_back
#define makep make_pair
#define MOD 1000000007
#define PI 2*acos(0.0)
#define PII pair<ll, ll>
#define pii pair<int, int>
#define what_is(x) cerr<<#x<<" is "<<x<<endl;
#define fio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;

ll func(ll n)
{
    ll count=0;
    while(n%2==0)
    {
        count++;
        n/=2;
    }
    return count;
}

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    fio();*/
    ll n,i,count,ans=0;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
        count=0;
        if(a[i]%2==0)
        {
            while(a[i]%2==0)
            {
                a[i]/=2;
                count++;
            }
            ans+=count;
        }
    }
    cout<<ans<<endl;
}


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

int n,m;

struct edge {int id; int to; int cost;};
vector<edge> g[100005];
ll val[200005];
bool vis[400005];

ll inf =(1ll<<50);

void dfs(int p) {
  for(int i=0;i<g[p].size();i++){
    auto e = g[p][i];
    if(vis[e.id])continue;
    vis[e.id] = true;
    if(val[e.to] == inf) {
      val[e.to] = val[p] + e.cost;
      dfs(e.to);
    } else {
      if(val[p] + e.cost != val[e.to]) {
        puts("No");
        exit(0);
      }
    }
  }
}

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

  cin>>n>>m;
  int line_id=0;
  for(int i=0;i<m;i++){
    int l,r,d;
    cin>>l>>r>>d;
    l--,r--;
    g[l].push_back({line_id++, r, d});
    g[r].push_back({line_id++, l, -d});
  }

  for(int i=0;i<n;i++){
    val[i] = inf;
  }
  for(int i=0;i<n;i++){
    if(val[i]==inf){
      val[i]=0;
      dfs(i);
    }
  }
  puts("Yes");

  return 0;
}


Measured memory_bytes: 14592
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int a[27]={0};
	for (int i = 0; i < s.length(); ++i)
	{
		a[s[i]-'a']++;
	}
	int flag=0;
	for (int i = 0; i < 27; ++i)
	{
		if(a[i]&1)
			flag=1;
	}
	if(flag)cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
	return 0;
}

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



int main() {
 int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++)
    cin >> a.at(i);
  int i = 1;
  int count=0;
  while(i!=2&&count<N-1){
  	i = a.at(i-1);
    count++;
  }
  if(i==2)
    cout << count << endl;
  else
    cout << -1 << endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second


void solve()
{
    int n,m;cin>>n>>m;
    string a[n],b[m];
    REP(i,n)cin>>a[i];
    REP(i,m)cin>>b[i];
    int as=a[0].size(),bs=b[0].size();
    bool flag=0;
    REP(i,n-m+1){
        REP(j,as-bs+1){
            flag=0;
            REP(k,m){
                REP(l,bs){
                    if(b[k][l]!=a[k+i][l+j])flag=1;
                    if(flag)break;
                }
                if(flag)break;
            }
            if(!flag){cout<<"Yes"<<endl;return;}
        }
    }
    cout<<"No"<<endl;
}

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

Measured memory_bytes: 256
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main argv =
    match read id with
    | "A" -> "T"
    | "T" -> "A"
    | "C" -> "G"
    | "G" -> "C"
    |> printfn "%s"
    0

Measured memory_bytes: 13916
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int a, b;
    cin >> a >> b;
    if (a + b >= 10)
        cout << "error\n";
    else
        cout << (a + b) << endl;
}



Measured memory_bytes: 3608
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll MAX_N = 16;
vector<vector<ll>> a(MAX_N,vector<ll>(MAX_N));
vector<ll> dp(1ll<<MAX_N,-1);
ll n;
ll solve(ll s){
  if(dp[s]!=-1) return dp[s];
  ll res = 0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if((s&(1ll<<i))&&(s&(1ll<<j))){
        res += a[i][j];
      }
    }
  }
  for(ll t=(s-1)&s;t>0;t=(t-1)&s){
    res = max(res,solve(t)+solve(s^t));
  }
  return dp[s] = res;
}
signed main(){
  init_io();
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin >> a[i][j];
    }
  }
  cout << solve((1ll<<n)-1)<<endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define maxN 102
using namespace std;

//FILE *fin = freopen("a.in", "r", stdin);

/* ------------------ */
int n;
char a[maxN];
int ans;
int main()
{
    scanf("%s", a + 1);
    n = strlen(a + 1);
    ans = n + 1;
    for (int c = 0; c < 26; ++ c)
    {
        int nrop = 0;

        for (int i = 1; i < n; ++ i)
            if (a[i] != 'a' + c)
            {
                bool ok = 0;
                for (int j = i + 1; j <= n; ++ j)
                    if (a[j] == 'a' + c)
                    {
                        nrop = max(nrop, j - i);
                        ok = 1;
                        break;
                    }
                if (!ok)
                    nrop = max(nrop, n - i + 1);
            }

        ans = min(ans, nrop);
    }
    printf("%d\n", ans);
    return 0;
}


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

int main(){
	int N;
	scanf("%d",&N);
	int l[N];
	int r[N];
	int sum = 0;
	for(int i=0; i<N; i++){
		scanf("%d %d",&l[i],&r[i]);
	}
	for(int i=0; i<N; i++){
		sum += (r[i] - l[i] + 1);
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>


int main(void){

    int K;
    char S[100];

    scanf("%d", &K);
    scanf("%s", S);

    if(strlen(S)<=K){
        printf("%s", S);
    }
    else{
        for(int i=0;i<K;i++){
            printf("%c", S[i]);
        }
        printf("...");
    }

    return 0;
}

Measured memory_bytes: 1708
import sys
from fractions import gcd
import bisect
 
stdin = sys.stdin
 
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

s = stdin.readline().split(",")
print(*s, sep=" ")

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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int h = int.Parse(input[0]);
            int w = int.Parse(input[1]);
            int[,] map = new int[h, w];
            int[,] lights = new int[h, w];
            int ans = 0;

            for (int y = 0; y < h; y++)
            {
                string line = Console.ReadLine();
                int x = 0;
                foreach (char c in line)
                {
                    map[y, x] = (c == '#' ? 1 : 0);
                    lights[y, x] = 0;
                    x++;
                }
            }

            // x方向スコア計算
            for (int y = 0; y < h; y++)
            {
                int st = 0;
                int ct = 0;
                for (int x = 0; x <= w; x++)
                {
                    if (x == w || map[y, x] == 1)
                    {
                        for (int i = st; i < x; i++)
                        {
                            lights[y, i] = ct;
                        }
                        ct = 0;
                        st = x + 1;
                    }
                    else
                    {
                        ct++;
                    }
                }
            }

            // y方向スコア計算しながら最大値を探索
            for (int x = 0; x < w; x++)
            {
                int st = 0;
                int ct = 0;
                for (int y = 0; y <= h; y++)
                {
                    if (y == h || map[y, x] == 1)
                    {
                        for (int i = st; i < y; i++)
                        {
                            lights[i, x] += ct;
                            ans = Math.Max(lights[i, x], ans);
                        }
                        ct = 0;
                        st = y + 1;
                    }
                    else
                    {
                        ct++;
                    }
                }
            }

            Console.WriteLine(ans - 1);
        }
    }
}

Measured memory_bytes: 46284
#include<bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define INF 1e9
#define All(x) (x).begin(),(x).end()
#define Cout(x) cout << (x) << endl
typedef long long ll;
using namespace std;

int main(){
    int N,M;
    cin>>N>>M;
    int ansa=0,answ=0;
    vector<int> c(N,0),P(N,0);
    REP(i,M){
        int p;string s;
        cin>>p>>s;
        p--;
        if(s=="AC"&&c[p]==0){
            c[p]=1;
        }else if(s=="WA"&&c[p]==0){
            P[p]++;
        }
    }
    REP(i,N){
        if(c[i]==1){
            ansa++;
            answ+=P[i];
        }
    }
    cout<<ansa<<endl;
    cout<<answ<<endl;

}


Measured memory_bytes: 1024