akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <math.h>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


int main() {
    string Sd,T;
    vector<string> candidates;

    cin >> Sd >> T;

    rep(i,Sd.size()-T.size()+1){
        bool match = true;
        rep(j,T.size()){
            if(Sd[i+j]!=T[j] && Sd[i+j] != '?'){
                match = false;
                break;
            }
        }
        if(match){
            string tmpS;
            rep(j,Sd.size()){
                if(i==j){
                    tmpS+=T;
                    j+=T.size()-1;
                }else{
                    if(Sd[j]=='?'){
                        tmpS+= 'a';
                    }else{
                        tmpS+= Sd[j];
                    }
                }
            }
            candidates.push_back(tmpS);
        }
    }

    if(candidates.empty()){
        cout << "UNRESTORABLE" << endl;
    }else{
        sort(candidates.begin(),candidates.end());
        cout << candidates[0] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  double a, b, C, S, L, h;
  cin >> a >> b >> C;
  S = 0.5 * a * b * sin(C * M_PI / 180);
  L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(C * M_PI / 180));
  h = 2 * S / a;
  cout << fixed << setprecision(6) << S << endl << L << endl << h << endl;
}



Measured memory_bytes: 3568
// Problem : A - Kyu in AtCoder
// Contest : AtCoder - M-SOLUTIONS Programming Contest 2020
// URL : https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
int main()
{
	ll i,j,k,m,n,t;
	cin>>n;
	if(n>=400 and n<=599)
	cout<<8;
	else if(n>=600 and n<=799)
	cout<<7;
	else if(n>=800 and n<=999)
	cout<<6;
	else if(n>=1000 and n<=1199)
	cout<<5;
	else if(n>=1200 and n<=1399)
	cout<<4;
	else if(n>=1400 and n<=1599)
	cout<<3;
	else if(n>=1600 and n<=1799)
	cout<<2;
	else cout<<1;
}

Measured memory_bytes: 3616
#include <stdio.h>
int main(void){
        int W,H,x,y,r;
        scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

        if(y-r>=0 && x-r>=0 && y+r<=H && x+r<=W)
                puts("Yes");
        else
                puts("No");

        return 0;
}


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

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

    int as = a.size();
    int bs = b.size();
    if (a == b) {
        puts("EQUAL");
    }
    if (as > bs) {
        puts("GREATER");
    } else if (as < bs) {
        puts("LESS");
    } else {
        for (int i = 0; i < as; i++) {
            if (a[i] > b[i]) {
                puts("GREATER");
                break;
            } else if (a[i] < b[i]) {
                puts("LESS");
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
  ll N,K;
  cin >> N >> K;
  vector<ll> A(N);
  int cntp=0;
  int cntm=0;
  int cntz=0;
  vector<ll> B;
  vector<ll> D;
  REP(i, N){
    cin >> A[i];
    if(A[i]>0){
      cntp++;
      B.push_back(A[i]);
    }else if(A[i]==0){
      B.push_back(A[i]);
      cntz++;
    }else{
      D.push_back(A[i]);
      cntm++;
    }
  }
  
  sort(ALL(A));
  reverse(ALL(A));
  sort(ALL(B));
  reverse(ALL(B));
  sort(ALL(D));
  
  
  if(K==N){
    mint ans = 1;
    REP(i,N){
      ans*=A[i];
    }
    cout << ans << endl;
  }else if(K%2==1&&cntz==0&&cntp==0){
    mint ans = 1;
    REP(i,K){
      ans*=A[i];
    }
    cout << ans << endl;
  }else{
    mint ans = 1;
    int x = 0;
    int y = 0;
    int now = 0;
    while(true){
      if(now+2>K){
        break;
      }
      if(x<=(int)B.size()-2&&y<=(int)D.size()-2){
        if(B[x]*B[x+1]>D[y]*D[y+1]){
          ans*=B[x];
          x+=1;
          now+=1;
        }else{
          ans*=D[y]*D[y+1];
          y+=2;
          now+=2;
        }
      }else if(x<=(int)B.size()-2){
        ans*=B[x];
        x+=1;
        now+=1;
      }else if(y<=(int)D.size()-2){
        ans*=D[y]*D[y+1];
        y+=2;
        now+=2;
      }
    }
    if(K-now==1){
      ans*=B[x];
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 6924
#include<stdio.h>
#include<stdlib.h>

typedef struct cell{
 int num;
 struct cell* next;
}cell;


/*-----------------push------------*/
cell* push(cell *root,int x){

cell *new;
new=(cell*)malloc(sizeof(cell));
new->next=NULL;
new->num=x;

if(root==NULL){root=new;}
else{new->next=root;root=new;}

return root;
}
/*----------------------------------*/



cell* pop(cell *root,int *x){

*x=root->num;
root=root->next;
return root;
}



int main(){
char temp[11];
cell *root=NULL;
int a,b;

while(scanf("%s",temp)!=EOF){
 if(temp[0]=='+'){root=pop(root,&a);root=pop(root,&b);root=push(root,a+b);}
 else if(temp[0]=='-'){root=pop(root,&a);root=pop(root,&b);root=push(root,b-a);}
 else if(temp[0]=='*'){root=pop(root,&a);root=pop(root,&b);root=push(root,a*b);}
 else{root=push(root,atoi(temp));}

}

 printf("%d\n",root->num);


return 0;
}


Measured memory_bytes: 2072
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

/// --- Union Find {{{ ///
#include <vector>
struct UF {
  int n;
  vector< int > par;
  UF(int n) : n(n), par(n, -1) {}
  int find(int x) { return par[x] < 0 ? x : par[x] = find(par[x]); }
  int size(int x) { return -par[find(x)]; }
  bool same(int a, int b) { return find(a) == find(b); }
  void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if(a == b) return;
    if(par[a] < par[b]) swap(a, b);
    par[b] += par[a];
    par[a] = b;
  }
};
/// }}}--- ///


const int N = 1e5;
vector<int> g[N];

int edges[N];
ll w[N];

int n, m;
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n >> m;
  using P = tuple<int, int, int>;
  vector<P> v;
  for(int i = 0; i < n; i++) cin >> w[i];
  for(int i = 0; i < m; i++) {
    int a, b, c; cin >> a >> b >> c;
    a--; b--;
    v.emplace_back(c, a, b);
  }
  sort(begin(v), end(v));
  UF uf(n);
  int ans = 0;
  for(int i = 0; i < m; i++) {
    int c, a, b;
    tie(c, a, b) = v[i];
    a = uf.find(a);
    b = uf.find(b);
    if(a != b) {
      ll newval = w[a] + w[b];
      ll newedge = edges[a] + edges[b];
      uf.unite(a, b);
      a = uf.find(a);
      w[a] = newval;
      edges[a] = newedge;
    }
    edges[a]++;
    if(w[a] >= c) ans += edges[a], edges[a] = 0;
  }
  cout << m - ans << endl;
  return 0;
}


Measured memory_bytes: 5364
s = input()
n = len(s)
t = [0]*(n+1)
tmp=0
for i in range(n):
  tmp+=1
  if s[i]=="<":
    t[i]=tmp-1
    t[i+1]=tmp
  else:
    tmp=0
    
tmp=0
for j in range(n)[::-1]:
  tmp+=1
  if s[j]==">":
    t[j+1]=max(tmp-1,t[j+1])
    t[j]=max(tmp,t[j])
  else:
    tmp=0
#print(t)
print(sum(t))


Measured memory_bytes: 29164
#include <iostream>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;

typedef long long ll;
int main(){
    int A=0,B=0,s=1,n=0;
    cin >> A >> B;
    while(true){
        if(B <= s)break;
        s--;
        n++;
        s+=A;
    }
    cout << n << endl;
 }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long
using namespace std;
ll gcd(ll,ll);
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a*b/g;
}

ll gcd(ll a,ll b){
    if(a<b){
        ll temp=a;
        a=b;
        b=temp;
    }
    ll r=a%b;
    while(r){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll r1=(a-1)/c;
    ll r2=b/c;
    ll r3=(a-1)/d;
    ll r4=b/d;
    ll l=lcm(c,d);
    ll r5=(a-1)/l;
    ll r6=b/l;
    cout<<b-a+1-(r2+r4-r1-r3-(r6-r5))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>



 int main()
 {
   int H;
   int W;
   int i,j;

while (1){
  scanf("%d %d",&H,&W);

  if(H==0 && W ==0) break;


  for(i=0;i < H ;i++){
      for(j = 0; j < W; j++){
        printf("#");
      }
     printf("\n");
    }
     printf("\n");
    }

return(0);
}

Measured memory_bytes: 572
n = gets.chomp.to_i
arr = gets.chomp.split.map{ |item| item.to_i}
ans = 0
cont = true
while(1)
  n.times do |i|
    cont = false  if (arr[i] % 2 != 0)
    arr[i] = arr[i]/2
  end
  if cont
    ans += 1
  else
    break
  end
end
print ans,"\n"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MN = 112;
const int MW = 100012;
ll n,c,w[MN],v[MN],dp[MW][MN];
int main (void) {
    cin >> n >> c;
    for (ll i = 0; i < n; i++)
        cin >> w[i] >> v[i];
    for (ll cc = 1; cc <= c; cc++) {
        for (ll i = 1; i <= n; i++) {
            ll cw = w[i-1], cv = v[i-1];
            if (cw > cc)
                dp[cc][i] = dp[cc][i-1];
            else dp[cc][i] = max(dp[cc][i-1], dp[cc-cw][i-1]+cv);
        }
    }
    cout << dp[c][n] << "\n";
}


Measured memory_bytes: 87808
#include<bits/stdc++.h>
using namespace std;
int main()
{
    std::ios_base::sync_with_stdio(false);
    //cin.tie(0);
    long long n,k,ans;
    cin>>n>>k;
    ans = n =n%k;
    if(k-n<n)
        ans = k-n;
    cout<<ans;



}


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

int N, Q;
vector<int> tree[200010];
vector<ll> weight(200010);

void dfs(int v, int pre = -1)
{
    for(int u : tree[v])
    {
        if(u == pre) continue;
        weight[u] += weight[v];
        dfs(u, v);
    }
}

int main(void)
{
    cin >> N >> Q;
    rep(i, N-1)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    rep(i, Q)
    {
        int p, x;
        cin >> p >> x;
        p--;
        weight[p] += x;
    }
    dfs(0);
    rep(i, N)
    {
        cout << weight[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 24832
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define in insert
#define er erase
#define fi first
#define se second
#define mp make_pair
#define all(x) x.begin(),x.end()
#define le(x) (int) x.length()
#define rsz resize

using namespace std;
typedef vector <int> vi;
typedef vector <vector <int> > vii;
typedef pair <int, int> pii;
typedef queue <int> qi;
typedef double db;
typedef long long ll;
typedef long double ld;
 
const long double PI=3.141592653589793238462643383279502884;
const long long PRIME1=1e9+787;
 
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll minll(ll a,ll b) {return a<=b?a:b;}
ll maxll(ll a,ll b) {return a>=b?a:b;}

int main () {
    fast;
    ll n;
    ll ans=0;
    cin>>n;
    int f=0;
    int l=-1;
    for (int i=0; i<n&&!f; i++) {
        ans=ans*10+7;
        ans%=n;
        if (ans==0) {
            f=1;
            l=i+1;
        }
    }
    cout<<l;
    return 0;
}
 
 


Measured memory_bytes: 3636
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s: String,
    }

    let s = s.as_bytes().to_vec();

    let ans = if s[2] == s[3] && s[4] == s[5] {
        "Yes"
    } else {
        "No"
    };

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


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    int a[3][3];
    rep(i, 3) rep(j, 3)
    {
        cin >> a[i][j];
    }
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i, n)
    {
        cin >> b[i];
        rep(x, 3) rep(y, 3)
        {
            if (a[x][y] == b[i])
                a[x][y] = -1;
        }
    }
    bool flg = false;
    rep(i, 3)
    {
        if (a[i][0] == -1 && a[i][1] == -1 && a[i][2] == -1)
        {
            flg = true;
        }
        if (flg)
            break;
    }
    if (!flg)
    {
        rep(i, 3)
        {
            if (a[0][i] == -1 && a[1][i] == -1 && a[2][i] == -1)
            {
                flg = true;
            }
        }
    }
    if (!flg)
    {
        if (a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1)
        {
            flg = true;
        }
        else if (a[0][2] == -1 && a[1][1] == -1 && a[2][0] == -1)
        {
            flg = true;
        }
    }
    if (flg)
    {
        c("Yes");
    }
    else
    {
        c("No");
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int dp[200001],n,a,cnt,m,L;
string s;
set<int> se[26];
void BITadd(int a,int b){
    a++;
    while(a<=200000){
        dp[a]+=b;
        a+=a&(-a);
    }
    return ;
}
int BITsum(int a){
    int tot=0;
    while(a>0){
        tot+=dp[a];
        a-=a&(-a);
    }
    return tot;
}
int main(void){
    cin>>s>>n;
    for(int i=0;i<s.size();i++){
        se[s[i]-'a'].insert(i);
    }
    for(int i=0;i<s.size();i++){
        for(int j=0;j<26;j++){
            if(se[j].size()==0)continue;
            L=*se[j].begin();
            m=L-BITsum(L);
            if(n<m)continue;
            cout<<char(j+'a');
            se[j].erase(L);
            n-=m;
            BITadd(L,1);
            break;
        }
    }
    cout<<endl;
}



Measured memory_bytes: 13308
#include<iostream>
#include<algorithm>
#include<vector>

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

using namespace std;

const int INF = 10000;

int main()
{
	int a, b;

	cin >> a >> b;

	int lap  = 2 * a + 2 * b;
	int area = a * b;

	cout << area << " " << lap << endl;
 
	return 0;

}



Measured memory_bytes: 3080
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		long ans = 1;
		for (int i = 1; i <= n; i++) {
			ans = (long) ((ans * i) % (Math.pow(10, 9) + 7));
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int memo[1<<10][1000];

int ans(int cnt, int f, int s){
  if(s < 0) return 0;
  if(memo[f][s] != -1) return memo[f][s];
  if((cnt == 1) && (s < 10) && ((f&(1<<s))!=0)) return memo[f][s] = 1;
  int ret = 0;
  for(int i=9; i>=0; i--)
    if((f & (1<<i)) != 0)
      ret += ans(cnt-1, f^(1<<i), s-i*cnt);
  return memo[f][s] = ret;
}

int main(){
  int n,s;
  while(cin>>n>>s){
    memset(memo, -1, sizeof(memo));
    if(s >= 1000 || n>10) 
      cout << 0 << endl;
    else
      cout << ans(n, (1<<10)-1, s) << endl;
  }
  return 0;
}

Measured memory_bytes: 4864
using System;
using System.Linq;

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(double.Parse).ToArray();
            var a = input[0];
            var b = input[1];
            var h = input[2];
            var m = input[3];

            var theta = Math.Abs(30 * h - 11 * m / 2);
            var length = Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(theta * Math.PI / 180));

            Console.WriteLine(length);
        }
    }
}


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

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;

#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        cout << A[i] << " ";
    }
    cout << endl;
}

inline void solve() {
    int n, l;
    cin >> n >> l;
    vector<string> v;

    string s;

    for (int i = 0; i < n; i++) {
        cin >> s;
        v.push_back(s);
    }

    sort(v.begin(), v.end());
    string res;
    for (auto& s : v) {
        res += s;
        // cout << s << endl;
    }
    cout << res << endl;

}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    int t = 1;
    // cin >> t;

    for (int _ = 0; _ < t; _++) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3620
<?php
$s=trim(fgets(STDIN));
$n=strlen($s);
$i=1;
$c=$s[0];
$ans=1;
while($i<$n){
  if($s[$i]==$c){
    ++$i;
    $c='ok';
  }else{
    $c=$s[$i];
  }
  ++$ans;
  ++$i;
}
if($i>$n){
  --$ans;
}
echo $ans;

Measured memory_bytes: 4732
#![allow(unused_imports)]
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_end().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}
impl<T: Iterator> IteratorExt for T {}


fn main() {
    let (x, y) = read!(usize, usize);

    if (2*x <= y && y <= 4*x) && (4*x - y)%2 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

      int X = sc.nextInt();
      int sum = 0;

      while(X >= 500){
         X -= 500;
         sum += 1000;
      }

      while(X >= 5){
         X -= 5;
         sum += 5;
      }

      System.out.println(sum);
   }
 }


Measured memory_bytes: 35632
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Main main = new Main();
		main.solveC();
	}

	private void solveA() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		System.out.println(N * A < B ? N * A : B);
	}

	private void solveB() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int tmp = N;
		int sum = 0;
		while (tmp > 0) {
			sum += tmp % 10;
			tmp /= 10;
		}
		if (N % sum == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] F = new int[N + 1][];
		for (int i = 1; i <= N; i++) {
			F[i] = new int[10];
			for (int j = 0; j < 10; j++) {
				F[i][j] = sc.nextInt();
			}
		}
		int[][] P = new int[N + 1][];
		for (int i = 1; i <= N; i++) {
			P[i] = new int[11];
			for (int j = 0; j <= 10; j++) {
				P[i][j] = sc.nextInt();
			}
		}
		long max = Long.MIN_VALUE;
		for (int pat = 1; pat < 1024; pat++) {
			long current = 0L;
			int[] M = new int[10];
			int tmp = pat;
			for (int i = 0; i < 10; i++) {
				M[i] = tmp % 2;
				tmp /= 2;
			}
			for (int i = 1; i <= N; i++) {
				int count = 0;
				for (int j = 0; j < 10; j++) {
					count += F[i][j] * M[j];
				}
				current += P[i][count];
			}
			if (max < current) {
				max = current;
			}
		}
		System.out.println(max);
	}

	private void solveD() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int C = sc.nextInt();
		int[][] M = new int[C + 1][];
		for (int j = 1; j <= C; j++) {
			M[j] = new int[100001];
		}
		for (int i = 1; i <= N; i++) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			int c = sc.nextInt();
			for (int j = s; j <= t; j++) {
				M[c][j] = 1;
			}
		}
		int max = 0;
		for (int i = 1; i <= 100000; i++) {
			int sum = 0;
			for (int j = 1; j <= C; j++) {
				if (M[j][i] == 1) {
					sum++;
				}
			}
			if (max < sum) {
				max = sum;
			}
		}
		System.out.println(max);
	}
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    int N;
    string S;

    cin >> N >> S;

    REP(i, S.length()) {
        int cur = S[i] - 'A';
        cur += N;
        cur %= 26;
        printf("%c", 'A' + cur);

    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,k;
	string s;
	cin >> n >> k; --k;
	cin >> s;
	s[k] -= 'A';
	s[k] += 'a';
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 764
def main(n):
    t = n[-1]
    if(int(t) in (0,1,6,8)):return "pon"
    elif(int(t) == 3):return "bon"
    else:return"hon"

def resolve():
    n = input()
    print(main(n))

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9164
#include<stdio.h>
int sort(int *a, int *b){
  return *b-*a;
}
int main(void){
int n;
  scanf("%d",&n);
  int l[n];
  for(int i=0;i<n;i++){
    scanf("%d",&l[i]);
  }
  long sum=0;
  qsort(l,n,sizeof(l[0]),sort);
  for(int i=0;i<n-2;i++){
	for(int j=i+1;j<n-1;j++){
		for(int k=j+1;k<n;k++){
			if(l[i]<l[j]+l[k])sum++;
        }
    }
  }
  printf("%ld",sum);
  return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  ull X;
  cin >> X;
  int a = X / 500;
  int d = X % 500;
  int c = d / 5;
  cout << a*1000+c*5 << '\n';
}


Measured memory_bytes: 888
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();
      
      if(N==M){
      System.out.println("Yes");
      }
      else if(N>M){
      System.out.println("No");
      }
    }
}

Measured memory_bytes: 21716
n = gets.to_i
a = (1..n).map { gets.to_i }
l = 1
k = 0
a.each_with_index do |x, i|
    next if i == 0
    next if x == a[i-1]
    if x > a[i-1]
        if k > 0
            k += 1
        else
            l = k.abs if l < k.abs
            k = 2
        end
    else
        if k < 0
            k -= 1
        else
            l = k.abs if l < k.abs
            k = -2
        end
    end
end
l = k.abs if l < k.abs
p l



Measured memory_bytes: 9812
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int H, W;
	cin >> H >> W;

	vector<string> grid(H);
	int black = 0;
	for (int i = 0; i < H; i++) {
		cin >> grid[i];
		for (int j = 0; j < W; j++) black += grid[i][j] == '#';
	}

	vector<vector<int>> used(H, vector<int>(W, INF));
	used[0][0] = 1;
	vector<int> dx{ 1,0,-1,0 }, dy{ 0,1,0,-1 };

	auto ok = [&](const int &x, const int &y) -> bool { return 0 <= x && x < H && 0 <= y && y < W && grid[x][y] == '.'; };

	auto dfs = [&](auto &&f,const int &x,const int &y) -> bool {
		
		bool flag = (x == H - 1 && y == W - 1);

		for (int i = 0; i < 4; i++) {
			int xto = x + dx[i], yto = y + dy[i];
			if (ok(xto, yto) && used[xto][yto] > used[x][y] + 1) {
				used[xto][yto] = used[x][y] + 1;
				flag |= f(f, x + dx[i], y + dy[i]);
			}
		}

		return flag;

	};

	if(dfs(dfs,0,0)) cout << H * W - black - used.back().back() << "\n";
	else cout << "-1\n";

	return 0;
}

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

using namespace std;

const int N = (int) 1e5 + 7;
int n, k, a[N], dep[N], ans;
vector<int> g[N];

void build(int a) {
  for (auto &b : g[a]) {
    dep[b] = 1 + dep[a];
    build(b);
  }
}

int dfs(int a) {
  int mx = dep[a];
  for (auto &b : g[a]) {
    int val = dfs(b);
    if (val - dep[a] >= k) {
      ans += (a != 1);
    } else {
      mx = max(mx, val);
    }
  }
  return mx;
}

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

  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  if (a[1] != 1) {
    ans++;
    a[1] = 1;
  }
  for (int i = 2; i <= n; i++) {
    g[a[i]].push_back(i);
  }
  build(1);
  dfs(1);
  cout << ans << "\n";
}


Measured memory_bytes: 11264
N=int(input())
sum=(1+N)*N/2
sum_Fizz=(3+(N//3)*3)*(N//3)/2
sum_Buzz=(5+(N//5)*5)*(N//5)/2
sum_FizzBuzz=(15+(N//15)*15)*(N//15)/2
print(int(sum-sum_Fizz-sum_Buzz+sum_FizzBuzz))

Measured memory_bytes: 9184
#include <cstdio>
#include <iostream>
#include <string>
#include <queue>
using namespace std;

const int N=100200;

int LT[N],UT[N],LA[N],UA[N],A[N],n;

int main()
{
  scanf("%d",&n);
  int last = -1;
  for (int i=0; i<n; ++i)
  {
    int h;
    scanf("%d",&h);
    if (h > last)
    {
      LT[i] = UT[i] = h;
    }
    else
    {
      LT[i] = 1;
      UT[i] = h;
    }
    last = h;
    //cout << LT[i] << "," <<  UT[i] << ' ';
  }
  //cout << endl;
  for (int i=0; i<n; ++i)
    scanf("%d", A+i);
  last = -1;
  for (int i=n-1; i>=0; --i)
  {
    if (A[i] > last)
    {
      LA[i] = UA[i] = A[i];
    }
    else
    {
      LA[i] = 1;
      UA[i] = A[i];
    }
    last = A[i];
  }
  //for (int i=0; i<n; ++i) cout << LA[i] << ',' << UA[i] << ' '; cout << endl;
  long long MOD = 1000000007;
  long long ans = 1;
  for (int i=0; i<n; ++i)
  {
    long long u = min(UT[i], UA[i]);
    long long l = max(LT[i], LA[i]);
    if (u < l)
    {
      ans = 0;
      break;
    }
    ans *= u-l+1;
    ans %= MOD;
  }
  printf("%d\n", (int)ans);
}


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

int main (){
    string S;
    cin >> S;
    char ACGT[4] = {'A', 'C', 'G', 'T'};

    int ans, temp;
    ans = temp = 0;
    for (int i = 0; i < S.length(); i++)
    {
        bool flg = false;
        for (char a: ACGT)
        {
            if (S[i] == a)
            {
                flg = true;
                temp++;
                break;
            }
            
        }
        if (!flg)
        {
            ans = max(ans, temp);
            temp = 0;
        } else if (flg && i == S.length() - 1)
        {
            ans = max(ans, temp);
        }    
    }
    cout << ans << endl;
    return 0;
    
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define fin(x) cout << x << endl;

using namespace std;
using ll = long long;

int main(void) {
  ll a, b, c;
  cin >> a >> b >> c;
  if (c - a - b > 0 && 4 * a * b < (c - a - b) * (c - a - b)) {
    fin("Yes");
  } else {
    fin("No");
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
	    *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
    fastIO;
    ll n,m;
    cin>>n>>m;
    ll x,y,val,val1,ans;
    if(n<=1)
    {
        x=0;
    }
    else
    {
        x=(n*(n-1))/2;
    }
    if(m<=1)
    {
        y=0;
    }
    else
    {
        y=(m*(m-1))/2;
    }
    ans=x+y;
    cout<<ans<<endl;
}  

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

const int INF = 1001001001;
//const ll INF = 1000000000000000000;

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

	int ac = 0, wa = 0, tle = 0, re = 0; 
	rep(i,n) {
		string s;
		cin >> s;
		if (s == "AC") ac++;
		else if (s == "WA") wa++;
		else if (s == "TLE") tle++;
		else if (s == "RE") re++;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
	return 0;
}


Measured memory_bytes: 3636
dice = [int(i) for i in input().split()]
directions = str(input())
for direction in directions:
    if direction == "N":
        dice = [dice[1], dice[5], dice[2], dice[3], dice[0], dice[4]]
    elif direction == "S":
        dice = [dice[4], dice[0], dice[2], dice[3], dice[5], dice[1]]           
    elif direction == "E":
        dice = [dice[3], dice[1], dice[0], dice[5], dice[4], dice[2]]
    else:
        dice = [dice[2], dice[1], dice[5], dice[0], dice[4], dice[3]]
print(dice[0])


Measured memory_bytes: 5604
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
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;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int main(){
  int h,w; cin >> h >> w;
  vector<string> s(h);
  vector<vector<int>> d(h,vector<int>(w,-1));
  rep(i,h) cin >> s[i];
  queue<pair<int,int>> q;

  rep(i,h)rep(j,w){
    if(s[i][j] == '#'){
      q.push({j,i});
      d[i][j] = 0;
    }
  }
  int ans = 0;
  while(!q.empty()){
    int x,y;
    tie(x,y) = q.front(); q.pop();
    rep(i,4){
      int nx = x + dx[i], ny = y + dy[i];
      if(nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
      if(d[ny][nx] != -1) continue;
      d[ny][nx] = d[y][x] + 1;
      chmax(ans,d[ny][nx]);
      q.push({nx,ny});
    }
  }  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 13456
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void ok() { cerr << "ok" << endl; }
using D = double;
using Point = complex<D>;
const D eps = 1e-40;
inline int sgn(const D &a) { return (a < -eps) ? -1 : (a > eps) ? 1 : 0; }
inline D cross(const Point &a, const Point &b) {
    return a.real() * b.imag() - a.imag() * b.real();
}
inline D dot(const Point &a, const Point &b) {
    return a.real() * b.real() + a.imag() * b.imag();
}
istream &operator>>(istream &is, Point &p) {
    D a, b;
    is >> a >> b;
    p = Point(a, b);
    return is;
}
inline int ccw(const Point &a, const Point &b, const Point &c) {
    D d = cross(b - a, c - a);
    if (sgn(d) > 0) {
        return +1; //counter-clockwise
    } else if (sgn(d) < 0) {
        return -1; //clockwise
    } else {
        if (sgn(dot(b - a, c - a)) < 0) {
            return -2; //c,a,b
        } else if (sgn(dot(a - b, c - b)) < 0) {
            return +2; //a,b,c
        }
    }
    return 0; //a,c,b
}
struct Line {
    Point a, b; //aを通り、方向ベクトルbの直線
    Line(const Point &p0, const Point &p1) : a(p0), b(p1) {}
};
inline Point projection(const Line &l, const Point &b) { //a to b
    return l.a + (dot(l.b, b - l.a) / norm(l.b)) * l.b;
}
inline Point reflection(const Line &l, const Point &b) {
    return b + (projection(l, b) - b) * static_cast<D>(2.0);
}
bool isparallel(const Line &l1, const Line &l2) {
    return sgn(cross(l1.b, l2.b)) == 0;
}
bool isvertical(const Line &l1, const Line &l2) {
    return sgn(dot(l1.b, l2.b)) == 0;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int q;
    cin >> q;
    while (q--) {
        Point p0, p1, p2, p3;
        cin >> p0 >> p1 >> p2 >> p3;
        Line l1(p0, p1 - p0), l2(p2, p3 - p2);
        if (isparallel(l1, l2)) {
            cout << 2 << '\n';
        } else if (isvertical(l1, l2)) {
            cout << 1 << '\n';
        } else {
            cout << 0 << '\n';
        }
    }
}



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

using namespace std;

int main(){
  string s, p;
  cin >> s >> p;
  string ss = s + s;
  bool flag = false;
  for (int i = 0; i < ss.length(); i++) {
    if (ss[i] == p[0]) {
      flag = true;
      for (int j = 1; j < p.length(); j++) {
        if (ss[i+j] != p[j]) {
          flag = false;
          break;
        }
      }
      if (flag) break;
    }
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 1188
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<vector<bool> > jewel(21, vector<bool>(21, false));
        for(int i=0; i<n; ++i){
            int x, y;
            cin >> x >> y;
            jewel[y][x] = true;
        }

        int m;
        cin >> m;
        int get = 0;
        int y = 10;
        int x = 10;
        for(int i=0; i<m; ++i){
            char c;
            int dist;
            cin >> c >> dist;

            int dy = 0;
            int dx = 0;
            if(c == 'N')
                dy = 1;
            else if(c == 'S')
                dy = -1;
            else if(c == 'E')
                dx = 1;
            else
                dx = -1;

            while(--dist >= 0){
                y += dy;
                x += dx;
                if(jewel[y][x]){
                    jewel[y][x] = false;
                    ++ get;
                }
            }
        }

        if(get == n)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main() {
    string S;
    int K;
    cin>>S>>K;
    K--;
    int fir=S.length();
    for(int i=0;i<S.length();i++){
        if(S[i]!='1'){
            fir=i;
            break;
        }
    }
    if(K<fir)cout<<1<<endl;
    else cout<<S[fir]<<endl;

}


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

using namespace std;

typedef long long ll;
#define INF 100000000
#define MOD 1000000007

int main()
{
	const int N = 100000;
	const int M = 100000;
	int n, m;
	//int a[M], b[M];
	int a, b;
	int v[N] = {0};
	
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		v[a - 1]++;
		v[b - 1]++;
	}
	for (int i = 0; i < n; i++) {
		if ((v[i] % 2) != 0) {
			cout << "NO" << endl;
			return (0);
		}
	}
	cout << "YES" << endl;

	return (0);
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
	int a,b,c,d,p,x,y,r;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&p);
	if(c>p){
		y=b;
	}else{
		y=b+(p-c)*d;
	}
	x=a*p;
	if(y<x){
		r=y;
	}else{
		r=x;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 2728
#include <stdio.h>

int bsort(int a[], int N){
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            if(a[i] > a[j]){
                int tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
        }
    }
}

int main(void)
{
    int n, k;
    scanf("%d", &n);
    scanf("%d", &k);

    int a[n];
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
    }
    bsort(a, n);

    int ans=0;
    for(int i=0; i<k; i++){
        ans += a[i];
    }

    printf("%d", ans);

}

Measured memory_bytes: 1732
def gcd(a,b):
    while b != 0:
        a,b = b, a%b
    return a
def gcd3(a,b,c):
    return gcd(a,gcd(b,c))

ans = 0
k = int(input())

for i in range(1,k+1):
    for j in range(1,k+1):
        for k in range(1,k+1):
            ans += gcd3(i,j,k)
print(ans)

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

A=[int(i) for i in input().split()]


c=[0,0,0]
ans=1
uncho=True

for i in range(N):
    s=sum([c[j]==A[i] for j in range(0,3)])
    if s==0:
        uncho=False
        print(0)
        break
    c[c.index(A[i])]+=1
    ans=(ans*s)%1000000007

if uncho:
    print(ans%1000000007)

Measured memory_bytes: 53132
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;
int n,m,k,a[300100];
string s;

int main()
{
    cin >> n >> k >> s;
    s[k - 1] = tolower(s[k - 1]);
    cout << s;
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc175/tasks/abc175_d
#include <bits/stdc++.h>
using namespace std;
// #define int int64_t
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int64_t N, K;
    cin >> N >> K;
    vector<int64_t> P(N);
    vector<int64_t> C(N);
    for (auto &&x : P) {
        cin >> x;
        x--;
    }
    for (auto &&x : C) {
        cin >> x;
    }

    int64_t ans = -1e12;
    // スタート位置
    REP(i, N) {
        // 循環する要素を求める（Pi != i なので自分自身へループしない）
        vector<int64_t> v;
        for (int j = i;; j = P[j]) {
            v.push_back(C[j]);
            // 開始時点に戻ったら終了
            if (P[j] == i)
                break;
        }
        // 循環する要素の長さ
        int64_t m = v.size();
        // 循環する要素の合計
        auto sum = accumulate(begin(v), end(v), 0LL);
        int64_t cur = 0;
        for (int r = 1; r <= m; ++r) {
            if (r > K)
                break;
            cur += v[r - 1];
            // 先頭からスコアを加算し、残りの長さに対して何回循環するか数える
            ans = max(ans, cur + (K - r) / m * max<int64_t>(sum, 0));
        }
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
double SUM(double N) {
    return N * (N + 1) / 2.0;
}
int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<double> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        v[i] = (SUM(v[i]) / v[i]);
    }
    double mx = 0;
    double cur = 0;
    int prevIndex = 0;
    for (int i = 0; i < k; i++) {
        cur += v[i];
    }
    mx = cur;
    for (int i = k; i < n; i++) {
        cur += v[i];
        cur -= v[prevIndex++];
        mx = max(mx, cur);
    }
    cout << fixed;
    cout << setprecision(6);
    cout << mx << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main(){
    lli n,x,a,sum=0;
    vector<lli> vec;
    lli i,j;
    cin>>n>>x;
    rep(i,0,n){
        cin>>a;
        vec.push_back(a);
    }
    rep(i,1,n){
        if(vec[i]+vec[i-1]>x){
            lli def=vec[i]+vec[i-1]-x;
            sum+=def;
            if(vec[i]>=def){
                vec[i]-=def;
            }
            else{
                def-=vec[i];
                vec[i]=0;
                vec[i-1]-=def;
            }
        }
    }
//    rep(i,0,n){
//        cout<<vec[i]<<" ";
//    }
//    cout<<endl;
    cout<<sum<<endl;
}


Measured memory_bytes: 1400