akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

class MainClass
{
    public static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[,] f = new int[N, 10];
        int[,] p = new int[N, 11];

        //for (int i = 0; i < N;i++)
        //{
        //    string[] s = Console.ReadLine().Split(' ');
        //    for (int j = 0; j < 5;j++)
        //    {
        //        f[i, j, 0] = int.Parse(s[j]);
        //        f[i, j, 1] = int.Parse(s[j + 1]);
        //    }
        //}
        for (int i = 0; i < N; i++)
        {
            var input_f = Console.ReadLine().Split(' ');
            for (int j = 0; j < 10; j++)
            {
                f[i, j] = int.Parse(input_f[j]);
            }
        }

        for (int i = 0; i < N; i++)
        {
            string[] s = Console.ReadLine().Split(' ');
            for (int j = 0; j < 11;j++)
            {
                p[i, j] = int.Parse(s[j]);
            }
        }

        long ans = long.MinValue;


        for (int i = 1; i < 1024;i++)
        {
            int pro = 0;

            for (int j = 0; j < N;j++)
            {
                int c = 0;
                for (int k = 0; k< 10; k++)
                {
                    if (((i >> k & 1)==1) && (f[j, k]==1))
                    {
                        c++;
                    }
                }

                pro += p[j, c];
            }

            if (ans < pro) ans = pro;

        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
END { load __FILE__ unless $stdin.eof? }

n = gets.to_i
ap = { U: [], D: [], L: [], R: [] }

n.times do
  x, y, u = gets.split
  x = x.to_i
  y = y.to_i
  ap[u.to_sym] << [x, y]
end

def xy2h(xy, &block)
  h = Hash.new { |h, k| h[k] = [] }
  xy.each { |x, y| k, v = block.call(x, y); h[k] << v }
  h
end

def time(ap1, ap2, &block)
  ap1 = xy2h(ap1, &block)
  ap2 = xy2h(ap2, &block)
  cross_lines = ap1.keys & ap2.keys

  t = []
  cross_lines.each do |cl|
    v1 = ap1[cl].sort!
    v2 = ap2[cl].sort!

    v1.reverse_each do |v|
      i = v2.bsearch_index { |w| w > v }
      next unless i
      t << v2[i] - v
      v2 = v2.take(i)
    end
  end

  t.min
end

time = []
time << time(ap[:U], ap[:D]) { |x, y| [x, y] }
time << time(ap[:R], ap[:L]) { |x, y| [y, x] }
time << time(ap[:U], ap[:L]) { |x, y| [x - y, x + y] }
time << time(ap[:R], ap[:U]) { |x, y| [x + y, x - y] }
time << time(ap[:D], ap[:L]) { |x, y| [x + y, x - y] }
time << time(ap[:R], ap[:D]) { |x, y| [x - y, x + y] }
puts time.compact.map { |t| t * 5 }.min || :SAFE


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

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

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


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

    int n, m;
    cin >> n >> m;
    vector<vector<int>> G(n);

    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;

        G[a].push_back(b);
        G[b].push_back(a);
    }

    rep(i, n){
        cout << G[i].size() << endl;
    }

    return 0;
}

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

int main(){
  int n;
  cin>>n;
  int vec[n][26]={};
  string q="abcdefghijklmnopqrstuvwxyz";
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    for(int j=0;j<s.size();j++){
      for(int k=0;k<26;k++){
        if(s[j]==q[k]){
          vec[i][k]++;
        }
      }
    }
  }
  for(int i=0;i<26;i++){
    int z=500;
    for(int j=0;j<n;j++){
      z=min(z,vec[j][i]);
    }
    for(int j=0;j<z;j++){
      cout<<q[i];
    }
  }
  cout<<endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
*A, = map(int, input().split())
A.sort()

mod = 10**9+7
fac = [1]*(N+1)
rev = [1]*(N+1)
 
for i in range(1,N+1):
  fac[i] = i*fac[i-1]%mod
  rev[i] = pow(fac[i], mod-2, mod)
 
comb = lambda a,b:(fac[a]*rev[a-b]*rev[b])%mod

maxX, minX = 0, 0

for i in range(N-K+1):
    minX += A[i]*comb(N-i-1, K-1)

for j in range(K-1, N):
    maxX += A[j]*comb(j, K-1)

print((maxX-minX)%mod)

Measured memory_bytes: 15248
#define basic using namespace std ;int main()
#include<bits/stdc++.h>
basic{
	string day[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
	string s;
	ios::sync_with_stdio(0);
	cin>>s;
	for(int i=0;i<7;i++){
		if(s==day[i]){
			cout<<7-i<<"\n";
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
long long ax[52],ay[52],bx[52],by[52];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    cin>>ax[i]>>ay[i];
    for(int i=0;i<m;i++)
    cin>>bx[i]>>by[i];
    for(int i=0;i<n;i++)
    {
    	 int minn=1e9;
    	 int ans=0;
    	for(int j=0;j<m;j++)
    	{
    		if(minn>abs(ax[i]-bx[j])+abs(ay[i]-by[j]))
    		{
    		ans=j;
    		minn=abs(ax[i]-bx[j])+abs(ay[i]-by[j]);
    	}
		}
		cout<<ans+1<<endl;
	}
   return 0;
}


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



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

    int n; cin >> n;
    vector<int> ans(n,0);
    int a;
    rep(i,n-1){
        cin >> a;
        a--;
        ans[a]++;
    }
    rep(i,n) cout << ans[i] << "\n";
}

Measured memory_bytes: 3972
// arock - 2019-02-16

#include <iostream>
#include <vector>

template <class T> std::vector<T> read(int n) {
    std::vector<T> res(n);
    for (auto& r : res) {
        std::cin >> r;
    }

    return res;
}

int main() {
    int N, M;
    std::cin >> N >> M;

    std::vector<bool> yes(M, true);
    for (int i = 0; i < N; i++) {
        int num;
        std::cin >> num;
        auto A = read<int>(num);
        std::vector<bool> y2(M);
        for (int a : A) y2[a - 1] = true;
        for (int j = 0; j < M; j++) yes[j] = yes[j] & y2[j];
    }

    int ans = 0;
    for (int i = 0; i < M; i++) ans += yes[i];

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


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

// #include <chrono>
// using namespace std::chrono;
// auto clockStart = high_resolution_clock::now();
// auto timer() {return duration_cast<milliseconds>(high_resolution_clock::now() - clockStart);}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
// typedef __int128 int128_t;
// typedef unsigned __int128 uint128_t;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<char, int> pci;
typedef tuple<int, int, int> ti3;
typedef tuple<ll, ll, ll> tl3;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#define ff          first
#define ss          second

#define pb(x)       push_back(x)
#define ppb()       pop_back()
#define pf(x)       push_front(x)
#define ppf()       pop_front()
#define mp(x,y)     make_pair(x, y)
// #define mk(args...) make_tuple(args...)
#define all(v)     begin(v),end(v)
#define gcd(x, y)   __gcd(x, y)

// pbds and ordered set
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <class T, class cmp = less<T> >
// using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;

// for fast I/O
#define endl '\n'
#define FASTIO() ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

const int N = 600;

int main() {
  FASTIO();
  
  ll a, b, v, w, t;
  cin >> a >> v >> b >> w >> t;

  ll ad = t * v, bd = t * w;

  if (ad - bd >= abs(a - b)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[1000000+10];

ll lcm(ll a, ll b) {
	return a*b/__gcd(a,b);
}

ll power(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n&1) {
			res = (res*a)%mod;
		}
		a = (a*a)%mod;
		n = n/2;
	}
	return res;
}

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=1000000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=1000000; i++) {
		if(prime[i] == 1) {
			for(ll j=2*i; j<=1000000; j+=i) {
				prime[j] = i;
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		int n;
		cin>>n;
		int arr[n];
		f(i,n) cin>>arr[i];
		int ans = 0;
		f(i,n) ans = __gcd(ans,arr[i]);
		if(ans > 1) {
			cout<<"not coprime\n";
		}
		else {
			int c = 0;
			f(i,n) if(arr[i] == 1) c++;
			if(n > 100000+c) {
				cout<<"setwise coprime\n";
			}
			else {
				int flag = 0;
				sort(arr,arr+n);
				int check[1000000+10] = {0};
				for(int i=0; i<n; i++) {
					int temp = arr[i];
					if(temp != 1) {
						for(int j=2; j<=sqrt(arr[i]); j++) {
							if(temp%j == 0) {
								if(check[j] or check[temp/j]) {
									flag = 1;
									break;
								}
								check[j] = 1;
								check[temp/j] = 1;
							}
						}
						if(flag) break;
						if(check[arr[i]]) {
							flag = 1;
							break;
						}
						check[arr[i]] = 1;
					}
				}
				if(flag) cout<<"setwise coprime\n";
				else cout<<"pairwise coprime\n";
			}
		}
 	}
 	return 0;
}


Measured memory_bytes: 11440
import heapq

class edge:
    def __init__(self, to, cap, cost, rev):
        self.to: int = to
        self.cap: int = cap
        self.cost: int = cost
        self.rev: int = rev


class min_cost_flow:
    def __init__(self, N):
        self.N: int = N
        self.INF: int = 1000000000000000000
        self.G = [[] for i in range(N)]
        
    def add_edge(self, fro, to, cap, cost):
        self.G[fro].append(edge(to, cap, int(cost), int(len(self.G[to]))))
        self.G[to].append(edge(fro, 0, -int(cost), int(len(self.G[fro]) - 1)))
        
    def solve(self, s, t, f):
        N = self.N
        prevv = [0 for i in range(N)]
        preve = [0 for i in range(N)]
        
        ret = 0
        while 0 < f:
            dist = [self.INF for i in range(N)]
            dist[s] = 0
            hq = [(0, s)]
            heapq.heapify(hq)
            while hq:
                d, v = heapq.heappop(hq)
                for i in range(len(self.G[v])):
                    e = self.G[v][i]
                    if 0 < e.cap and dist[v] + e.cost < dist[e.to]:
                        dist[e.to] = dist[v] + e.cost
                        prevv[e.to] = v
                        preve[e.to] = i
                        heapq.heappush(hq, (dist[e.to], e.to))

            # 流せない
            if dist[t] == self.INF:
                return self.INF

            d = f
            v = t
            while v != s:
                d = min(d, self.G[prevv[v]][preve[v]].cap)
                v = prevv[v]

            f -= d
            ret += d * dist[t]
            v = t
            while v != s:
                e = self.G[prevv[v]][preve[v]]
                e.cap -= d
                self.G[v][e.rev].cap += d
                v = prevv[v]
    
        return ret

# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_B
v, e, f = map(int, input().split())
mcf = min_cost_flow(v)
for i in range(e):
    ui, vi, ci, di = map(int, input().split())
    mcf.add_edge(ui, vi, ci, di)
    
ans = mcf.solve(0, v-1, f)
if ans == mcf.INF:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 6112
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll l,r;
cin>>l>>r;
ll a=2020;
if(r-l>2020){
cout<<0<<endl;}
else{
for(ll i=l; i<=r; i++){
for(ll k=i+1; k<=r; k++){
a=min((i%2019)*(k%2019)%2019,a);}}
cout<<a<<endl;}}


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

#define roop(i,p) for(int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

	string S;
	cin >> S;

	ll int L;
	L = (int)(S.length());

	roop(i,L){
		cout << "x";
	}












	return 0;

}



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

int main() {
  string s;
  int a = 0;
  cin >> s;
  for (int i= 1; i < s.size(); i++){
    if( s.at(i) != s.at(i-1) ) {
      a++;
    }
  }
  cout << a << endl;
  
}

Measured memory_bytes: 512
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int a,b;
	cin>>a>>b;
	int f=0;
	int p =10*b;
	rep(i,10){
		int check = 8*p/100;
		if(check == a){f = 1;break;}
		p++;
	}	
	if(f)cout<<p;
	else cout<<-1;
	return 0;
}

Measured memory_bytes: 256
n=int(input())

c=[]
s=[]
f=[]

for i in range(n-1):
    p,q,r=map(int,input().split())
    c.append(p)
    s.append(q)
    f.append(r)
    
for i in range(n-1):
    ans=s[i]+c[i]
    for j in range(i+1,n-1):
        if ans<=s[j]:
            ans=s[j]+c[j]
        else:
            ans+=(f[j]-ans%f[j])%f[j]+c[j]
    print(ans)
print(0)

Measured memory_bytes: 3064
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int cnt = sc.nextInt();
    int[] ary = new int[cnt];
    for(int i = 0; i < cnt; i++){
        ary[i] = sc.nextInt();
    }
    ary = Arrays.stream(ary).distinct().toArray();
    System.out.println(ary.length);
  }
}

Measured memory_bytes: 28364
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int M=1e9+7;
int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

signed main(){
	fast;
	string s;
	vector<int> v;
	map<int,int> mp;
	int n,m,c=0,t=1;
	//cin>>t;
	while(t--){
		cin>>n;
		c+=(1000*(n/500));
		c+=5*((n%500)/5);
		cout<<c;

	}
	return 0;
}



Measured memory_bytes: 256
from heapq import heappush, heappop, heappushpop, heapreplace, heapify

#隣接リスト作成
v = int(input())
edge_list = [[] for _ in range(v)]
for i in range(v):
    l = list(map(int, input().split()))
    for j in range(1,l[1]+1):
        edge_list[l[0]].append([l[2*j+1],l[2*j]])

def dijkstra(v, edges, start):
    d = [float("inf")] * v
    visited = [False] * v
    d[start] = 0
    visited[start] = 0
    hq = []
    for i in edges[start]:
        d[i[1]] = i[0]
        heappush(hq, i)

    while hq:
        x, y = heappop(hq)
        #もし更新する必要がないならこれ以降の処理を行わない
        if d[y] < x:
            continue
        d[y] = x
        visited[y] = True
        for n in edges[y]:
            if not visited[n[1]]:
                hq.append([x + n[0], n[1]])
        heapify(hq)
    return d

for index, d in enumerate(dijkstra(v, edge_list,0)):
    print(index,d)



Measured memory_bytes: 6460
#include <bits/stdc++.h>
     
    using namespace std;
     
    int mod=1e9+7;  ///A simpler way to write 1,000,000,007
     
    int main()
    {
        int n,k;
        cin >> n >> k;
        int a[n+1];
        for(int i=1;i<=n;i++)
        {
            cin >> a[i];
        }
        int dp[n+1][k+1];
        dp[0][0]=1;
        for(int i=1;i<=k;i++)  /// Set the initial values
        {
            dp[0][i]=0;
        }
        for(int i=1;i<=n;i++)
        {
            int sums[k+1];
            sums[0]=dp[i-1][0];
            for(int j=1;j<=k;j++)
            {
                sums[j]=(sums[j-1]+dp[i-1][j])%mod;  ///Calculate the prefix sums for i-1
            }
            for(int j=0;j<=k;j++)
            {
                int tr=sums[j];  ///Sum of dp[i-1][0...j]
                int unreachable=j-a[i]-1;  ///We need to subtract the sum of the first "unreachable" elements (dp[i-1][0...unreachable])
                if(unreachable>=0)
                {
                    tr=(tr-sums[unreachable]+mod)%mod;  ///Add mod to make sure that "tr-sums[unreachable]" is not negative.
                }
                dp[i][j]=tr;
            }
        }
      	cout << dp[n][k];
        return 0;
    }

Measured memory_bytes: 40064
#include<bits/stdc++.h>
#define eoi ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int main()
{
    eoi;
string s;
cin>>s;
vector<char>v;
for(int z=0;z<s.length();z++){
if(s[z]=='1' || s[z]=='0'){
    v.push_back(s[z]);
}
else{
    if(v.size()!=0){
        v.pop_back();
    }
}


}
for(int i=0;i<v.size();i++){
    cout<<v[i];
}



}







Measured memory_bytes: 256
package main


import (
    "fmt"
)

func main() {
    var C string
    fmt.Scan(&C)


    if C == "a" || C == "e" || C == "i" || C == "o" || C == "u" {
      fmt.Println("vowel")
    } else {
      fmt.Println("consonant")
    }


}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<pair<int,int>,null_type, less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
const int N=1e6+10, mod=1e9+7;


int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int n,i,ct=0;
	cin>>n;
	int temp=n;
	while(temp){
		temp/=10;
		ct++;
	}
	
	if(ct%2==0){
		cout<<(pow(100,ct/2)-1)/11;
	}else{
		cout<<n-pow(10,ct-1) +1 + (pow( 100,(ct-1)/2 )-1)/11 ;
	}
	
}
// check for any potential overflow before submitting



Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

vector<int> get_prime(int n){
    if(n <= 1) return vector<int>();
    vector<bool> iscomp(n+1);
    vector<int> prime;
    for (int i = 2; i <= n; ++i) {
        if(!iscomp[i]) prime.emplace_back(i);
        for (auto &&j : prime){
            if((ll)i*j > n) break;
            iscomp[i*j] = true;
            if(i % j == 0) break;
        }
    }
    return prime;
}
int main() {
    int n, p;
    auto x = get_prime(200000);
    while(cin >> n >> p, n != -1 && p != -1){
        vector<int> v;
        int cur = upper_bound(x.begin(), x.end(), n) - x.begin();
        for (int i = 0; i < p; ++i) {
            v.emplace_back(x[cur+i]);
        }
        vector<int> ans;
        for (int i = 0; i < p; ++i) {
            for (int j = i; j < p; ++j) {
                ans.emplace_back(v[i]+v[j]);
            }
        }
        sort(ans.begin(), ans.end());
        cout << ans[p-1] << "\n";
    }
    return 0;
}


Measured memory_bytes: 3248
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        char[][] data = new char[2][3];
        String s = scan.next();
        data[0] = s.toCharArray();
        s = scan.next();
        data[1] = s.toCharArray();
        boolean answer = false;
        if (data[0][0] == data[1][2] && data[0][1] == data[1][1] && data[0][2] == data[1][0]) {
            answer = true;
        }
        System.out.println(answer ? "YES" : "NO");
    }
}


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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end



int main(){
   ll a; string b; cin>>a>>b;
   b.erase(b.begin()+1);
   int c=stoi(b);
   a*=c; cout<<a/100<<endl;
   return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

ll BASE_NUM = 1000000007;

long long gcd(long long a, long long b){

    if (a== 0){
        return b;
    }else if (b == 0){
        return a;
    }

    if (a%b == 0){
        return b;
    }else{
        return gcd(b,a%b);
    }
}

int main()
{
    // 整数の入力
    ll N,M;
    vector<ll> A;
    cin >> N >> M;
    ll first_two_count = -1;
    ll a_gcd  = 0;
    for(int i = 0;i< N;i++){
        ll a;
        ll two_count = 0;
        cin >> a;
        while(a % 2 == 0){
            two_count++;
            a = a/2;
        }
        if (i == 0){
            first_two_count = two_count;
        }else if(first_two_count != two_count){
            cout << 0 << endl;
            return 0;
        }
        A.push_back(a);
        a_gcd = gcd(a_gcd,a);
    }
    ll a_lcm = 1;
    for(auto a: A){
        a_lcm = a * a_lcm /gcd(a_lcm,a);
        if (a_lcm<<(first_two_count-1) > M){
            cout << 0 << endl;
            return 0;
        }
    }
    a_lcm = (a_lcm<<(first_two_count-1));
    ll normal_count =  M / a_lcm;
    ll odd_count =  (normal_count + 1)/2;

    cout << odd_count << endl;

    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2);
  return x*POW(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}


int main()
{
  ll n,k,a[120000],p,q[50],ans;
  cin >> n >> k;
  ans=0;
  rep(i,50)q[i]=0;
  rep(i,n)cin >> a[i];
  p=keta(k,2);
  rep(i,n){
    rep(j,45){q[j]+=DEC(a[i],2,j);
            }
  }
  per(i,45){if(n>2*q[i]&&k-POW(2,i)>=0){ans+=(n-q[i])*POW(2,i);
                                       k-=POW(2,i);
                                      }                   
           else {ans+=(q[i])*POW(2,i);
                }
          }
  printf("%lld",ans);
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main
{
		public static void main(String[] args)
		{
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			sc.close();
			long ans = 0;
			for (int i=1; i <= n; i++) {
				if (i % 5 == 0 || i%3 ==0)  {
				} else {
					ans  += i;
				}
			}
			System.out.println(ans);
		}
}


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

typedef long long ll;
using namespace std;

int main(void){
  int w,b,i,j,x,y;
  static bool grid[100][100];

  cin>>w>>b;
  for(i=0;i<100;i++){
    for(j=0;j<50;j++){
      grid[j][i]=0;
    }
    for(j=50;j<100;j++){
      grid[j][i]=1;
    }
  }

  x=0,y=0;
  for(i=0;i<b-1;i++){
    grid[y][x]=1;
    x=x+2;
    if(x>=100){
      x=0;
      y=y+2;
    }
  }
  x=0,y=51;
  for(i=0;i<w-1;i++){
    grid[y][x]=0;
    x=x+2;
    if(x>=100){
      x=0;
      y=y+2;
    }
  }

  printf("100 100\n");
  for(i=0;i<100;i++){
    for(j=0;j<100;j++){
      if(grid[i][j]){
        printf("#");
      }
      else{
        printf(".");
      }
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
using namespace std;
const int N=1e6+5;
typedef long long ll;
int n,m;
bool vis[N];
vector<int>edge[N];
queue<int>q;
map<int,int>f[N];
int dist[N];
int fa[N];
int find_father(int x){
    if(x==fa[x]) return x;
    return fa[x]=find_father(fa[x]);
}
void merge(int x,int y){
    int f1=find_father(x),f2=find_father(y);
    fa[f1]=f2;
}
void bfs(){
    memset(dist,-1,sizeof dist);
    q.push(1);
    vis[1]=1;
    dist[1]=0;
    while(!q.empty()){
        int u=q.front();
        q.pop();
        for(int i=0,sz=edge[u].size();i<sz;i++){
            int v=edge[u][i];
            v=find_father(v);
            if(!vis[v]){
                dist[v]=dist[u]+1;
                q.push(v);
                vis[v]=1;
            }
        }
    }
}
int main()
{
    int cnt=0;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        f[i][0]=++cnt;
    }
    for(int i=1;i<N;i++)//!
        fa[i]=i;
    for(int i=1;i<=m;i++){
        int u,v,w;
        scanf("%d%d%d",&u,&v,&w);
        if(f[u][w]==0){
            f[u][w]=++cnt;
            edge[u].push_back(cnt);
            edge[cnt].push_back(u);
        }
        u=f[u][w];
        u=find_father(u);
        if(f[v][w]==0){
            f[v][w]=++cnt;
            edge[v].push_back(cnt);
            edge[cnt].push_back(v);
        }
        v=f[v][w];
        v=find_father(v);
        merge(u,v);
    }
    for(int i=1;i<=n;i++)
        for(map<int,int>::iterator it=f[i].begin();it!=f[i].end();it++){
            int j=it->second;
            j=find_father(j);
            edge[i].push_back(j);
            edge[j].push_back(i);
        }
    bfs();
    if(dist[n]==-1)
        puts("-1");
    else
        printf("%d\n",dist[n]/2);
}


Measured memory_bytes: 123904
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

const int MAXN = 1001024;

// a, b の最大公約数を返す O( log max(a, b) )
int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}

signed main(){
    int n, k; cin >> n >> k;
    vector<pair<int, int>> p(n);
    for(int i = 0; i < n; i++){
        int x, y; cin >> x >> y;
        p[i].first = x;
        p[i].second = y;
    }
    
    int ans = 1;
    for(int i = 0; i < n; i++){
        map<pair<int, int>, int> mp;
        for(int j = 0; j < n; j++){
            if(i == j) continue;

            int x = p[j].first - p[i].first;
            int y = p[j].second - p[i].second;
            int g = gcd((int)abs(x), (int)abs(y));
            x /= g;
            y /= g;
            mp[{x, y}] = mp[{x, y}] + 1;
        }

        int tmp = 1;
        for(auto x : mp){
            tmp = max(tmp, x.second + 1);
        }
        ans = max(ans, tmp);
    }

    cout << (ans >= k) << endl;
    
    return 0;
}



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

ll mod = 1e9 + 7;

int main(){
	int n;
	cin >> n;
	set <string> zz;
	for(int i = 0; i < n; ++i){
		string s;
		cin >> s;
		zz.insert(s);
	}
	cout << zz.size() << endl;
}

Measured memory_bytes: 19260
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 300010;
ll res;
struct trie {
	trie * nxt[26]{};
	int cnt[26]{};
	void insert(const string &w) {
		int wcnt[26]{};
#define V(i) ((i)-'a')
		for (char i : w) ++wcnt[V(i)];
		trie* now = this;
		for (char i : w) {
			for (int j = 0;j < 26;++j)
				if (wcnt[j])
					++now->cnt[j];
			--wcnt[V(i)];
			now = now->nxt[V(i)] = (!now->nxt[V(i)] ? new trie : now->nxt[V(i)]);
		}
	}
	void query(const string &w) {
		//cerr << "Q \n";
		trie* now = this;
//		for (int i = 0;i < 26;++i)
//			if (now->cnt[i])
//				cerr << (char)(i + 'a');
//		cerr << '\n';
		//if (w.size() == 
		int nd = V(w.back());
		for (int i = 0;i+1 < w.size();++i) {
			if (!now->nxt[V(w[i])]) return;
			now = now->nxt[V(w[i])];
		}
		res += now->cnt[nd];
	}
}tree;
void spe(vector<string> w) {
	return ;
	int allc[26]{};
	for (auto &i : w) {
		if (i.size() == 1)
			res += allc[ V(i[0]) ];
		bool have[26]{};
		for (auto c : i)
			have[V(c)] = true;
		for (int j = 0;j < 26;++j)
			if (have[j]) ++allc[j];
	}
}
		
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n;
	cin >> n;
	vector<string> w(n);
	for (auto &i : w)
		cin >> i;
	sort(w.begin(), w.end(), [&](auto a, auto b){
		return a.size() > b.size();
	});
	for (auto &i : w) {
		//if (i.size() == 1) continue;
		reverse(i.begin(), i.end());
		tree.query(i);
		tree.insert(i);
	}
	spe(w);
	cout << res << '\n';
		
}



Measured memory_bytes: 317680
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        1000000007
#define all(x)     x.begin(),x.end()    
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
void comp() {
    ll i,j,k,n,m,a,r;
    char c;
    cin>>n;
    string ans="";
    while(n>0) {
        ll temp=n%26;
        if(temp==0) temp=26;
        temp--;
        ans+='a'+temp;
        if(n%26==0) n--;
        n/=26;
    }
    reverse(all(ans));
    cout<<ans;
}

int main() {
    speedup;
    ll i=0,t;
    t=1;
    //cin>>t;
    while(t--) {
        comp();
    }
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
const long long md=1e9+7;
long long n,m,s[2020],t[2020],dp[2020][2020];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>s[i];
	}
	for(int i=1;i<=m;i++)
	{
		cin>>t[i];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			dp[i][j]=(dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1])%md;
			if(s[i]==t[j])
			{
				dp[i][j]+=dp[i-1][j-1]+1;
			}
		}
	}
	cout<<(dp[n][m]%md+1+md)%md<<endl;
	return 0;
}

Measured memory_bytes: 31872
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] Adj = new int[n][n];
        for (int i = 0; i < n; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            for (int j = 0; j < b; j++){
                int c = sc.nextInt();
                Adj[a - 1][c - 1] = 1;
            }
        }
        for (int i = 0; i < n; i++){
            for (int j = 0; j < n; j++){
                System.out.print(Adj[i][j]);
                if (j < n - 1){
                    System.out.print(" ");
                }
                else {
                    System.out.println();
                }
            }
        }
    }
}



Measured memory_bytes: 33924
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int[][] c = new int[10][10];
        for (int i = 0 ; i < 10 ; i++) {
            for (int j = 0 ; j < 10 ; j++) {
                c[i][j] = sc.nextInt();
            }
        }
        int[][] a = new int[h][w];
        for (int i = 0 ; i < h ; i++) {
            for (int j = 0 ; j < w ; j++) {
                a[i][j] = sc.nextInt();
            }
        }

        for (int k = 0 ; k < 10 ; k++) {
            for (int i = 0 ; i < 10 ; i++) {
                for (int j = 0 ; j < 10 ; j++) {
                    c[i][j] = Math.min(c[i][j], c[i][k] + c[k][j]);
                }
            }
        }

        int ans = 0;
        for (int i = 0 ; i < h ; i++) {
            for (int j = 0 ; j < w ; j++) {
                if (a[i][j] >= 0) ans += c[a[i][j]][1];
            }
        }
        System.out.println(ans);

    }

}

Measured memory_bytes: 47828
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
  string S;
  cin >> S;
  if(S=="SUN")cout << 7;
  if(S=="MON")cout << 6;
  if(S=="TUE")cout << 5;
  if(S=="WED")cout << 4;
  if(S=="THU")cout << 3;
  if(S=="FRI")cout << 2;
  if(S=="SAT")cout << 1;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8


def main():
    while True:
        a, op, b = [x for x in raw_input().split(" ")]
        a, b = int(a), int(b)

        if op == '?':
            break
        elif op == '+':
            print a + b
        elif op == '-':
            print a - b
        elif op == '*':
            print a * b
        elif op == '/':
            print a / b

if __name__ == '__main__':
    main()

Measured memory_bytes: 4224
use proconio::*;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
#[allow(non_snake_case)]
fn main() {
    input! {
        x: [i32; 5],
    }
    for i in 0..5 {
        if x[i] == 0 {
            println!("{}", i + 1);
        }
    }
}


Measured memory_bytes: 2148
n = int(input())
ans = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
for _ in range(n):
    s = input()
    if s in ans:
        ans[s] += 1
    else:
        ans[s] = 1

for k, v in ans.items():
    print(f'{k} x {v}')

Measured memory_bytes: 9196
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k, n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 100010
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans, cnt;

// a^n mod を計算する
ll modpow(ll a, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算する
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;
	return u;
}


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

	map<int, int> lcm{};
	rep(i, N) {
		int x = A[i];
		for (int j = 2; j*j <= x; j++) {
			if (x % j == 0) {
				int cnt = 0;
				while (x % j == 0) {
					cnt++;
					x /= j;
				}
				lcm[j] = max(lcm[j], cnt);
			}
		}
		if (x != 1) {
			lcm[x] = max(lcm[x], 1);
		}
	}

	ll temp = 1;

	for (auto pr : lcm) {
		temp *= modpow(pr.first, pr.second);
		temp %= MOD;
	}

	rep(i, N) {
		// cout << "temp:" << temp << endl;
		ans += temp * modinv(A[i]) % MOD ;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}


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

/*
code credits : ਜ਼ੈਲਦਾਰ
dashan jot singh
*/
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define inf LLONG_MAX
#define p pair<ll,ll>
ll n;
ll dp[100010];
ll arr[100010];

int main(){
	fast;
	cin>>n;
	for(ll i=0;i<n;i++){
		cin>>arr[i];
	}
	memset(dp,0,sizeof(dp));
	for(ll i=1;i<n;i++){
		if(i==1){
			dp[i]=dp[i-1]+abs(arr[i]-arr[i-1]);
		}
		else{
			dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),
					dp[i-2]+abs(arr[i]-arr[i-2]));
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        Set<Integer> s = new HashSet<>();
        int gold = 0;
        for (int i = 0; i < n; i++) {
            int rank = a[i];
            if (rank < 3200) {
                s.add(rank / 400);
            } else {
                gold++;
            }
        }

        // 全部が3200以上だったら1種類
        int min = s.size() == 0 ? 1 : s.size();

        // 9種類以上の色もあるっぽい？
        int max = s.size() + gold;

        System.out.printf("%s %s\n", min, max);
    }
}


Measured memory_bytes: 21332
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


class SegTree:
    X_unit = 0

    def __init__(self, n):
        self.n = n
        self.length = n
        self.data = [self.X_unit] * 2 * self.length

    def update(self, i, x):
        i += self.length
        self.data[i] = x
        while i > 1:
            i >>= 1
            self.data[i] = max(self.data[i << 1 | 0], self.data[i << 1 | 1])

    def get(self, l, r):
        x = self.X_unit
        l += self.length
        r += self.length
        while l < r:
            if l & 1:
                x = max(x, self.data[l])
                l += 1
            if r & 1:
                r -= 1
                x = max(x, self.data[r])
            l >>= 1
            r >>= 1
        return x


def main():
    N, K, *A = map(int, read().split())
    Amax = max(A)
    tree = SegTree(Amax + 1)

    for a in A:
        x = tree.get(max(a - K, 0), min(a + K, Amax) + 1)
        tree.update(a, x + 1)

    print(tree.get(0, Amax + 1))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 113092
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;

int main()
{
	int N, M;
	int K;

	cin >> N >> M;

	int ans[30];

	for (auto i = 0; i < M; ++i)
	{
		ans[i] = 0;
	}

	for (auto i = 0; i < N; ++i)
	{
		cin >> K;
		for (auto j = 0; j < K; ++j)
		{
			int A;
			cin >> A;
			++ans[A - 1];
		}
	}

	auto total = 0;
	for (auto i = 0; i < M; ++i)
	{
		if (ans[i] >= N)
		{
			++total;
		}
	}

	cout << total << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(ll i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

bool check(string a,string b)
{
	FOR(i,0,a.size())
	{
		if((a[i] == b[i])||(a[i]!=b[i]&&a[i] == '?'))continue;
		else return 0;
	}
	return 1;
}
int main()
{
	string s,t;
	cin>>s>>t;
	string ans = "";
	for(int i=0;i+t.size()-1<s.size();i++)
	{
		string tmp = s.substr(i,t.size());
		bool isok = check(tmp,t);
		if(!isok)continue;
		string ma = s;
		for(int j = i;j<=i+t.size()-1;j++)ma[j] = t[j-i];
		for(int j=0;j<ma.size();j++)
			if(!isalpha(ma[j]))ma[j] = 'a';
		if(ans == ""||ans>ma)ans = ma;
	 } 
	if(ans == "")cout<<"UNRESTORABLE"<<Endl;
	else cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vll vector< vector<ll> >
#define mod 1000000007
#define rep(i,a,b)	for(int i=a;i<b;i++)
ll K;
vll mul(vll a,vll b,ll m) {
vll c(K,vector<ll>(K));rep(ii,0,K)rep(jj,0,K)rep(kk,0,K)c[ii][jj]=(c[ii][jj]+a[ii][kk]*b[kk][jj])%m;return c;}
vll fme(vll a,ll n,ll m){
if(n==1)return a;if(n&1)return mul(a,fme(a,n-1,m),m);vll x=fme(a,n/2,m);return mul(x,x,m);}
int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	ll n,k;
	cin>>n>>k;
	K=n;
	vll a(n,vector<ll>(n));
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)
		cin>>a[i][j];
	}
	vll v=fme(a,k,mod);ll ans=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)
		ans=(ans+v[i][j])%mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2944
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import itertools as ite
import math
import random
import sys
import codecs
from collections import defaultdict

INF = 10 ** 18
MOD = 10 ** 9 + 7

sys.setrecursionlimit(1000000)

N = input()
A = map(int, raw_input().split())
B = map(int, raw_input().split())

ans = 0
for i in range(N):
    if B[i] <= A[i]:
        A[i] -= B[i]
        ans += B[i]
    else:
        ans += A[i]
        B[i] -= A[i]
        A[i] = 0
        if B[i] <= A[i + 1]:
            A[i + 1] -= B[i]
            ans += B[i]
        else:
            ans += A[i + 1]
            A[i + 1] = 0
print ans


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

class Section
{
private:
  int _begin, _end;
public:
  Section(int b, int e)
  {
    _begin = b;
    _end = e;
  }

  int begin()
  {
    return _begin;
  }

  int end()
  {
    return _end;
  }

  int length()
  {
    return end() - begin();
  }
};

vector<Section> sections;
bool card[100002];
int K, N;
int main()
{
loop:
  fill(card, card + 100002, false);
  sections.clear();

  cin >> N >> K;
  if(!N)
    return 0;
  for(int i = 0; i < K; i++)
  {
    int a;
    cin >> a;
    card[a] = true;
  }

  bool keep = false;
  int st, ans = 0;
  for(int i = 1; i <= N + 1; i++)
  {
    if(keep && !card[i])
    {
      sections.push_back(Section(st, i));
      keep = false;
    }
    if(!keep && card[i])
    {
      st = i;
      keep = true;
    }
  }
    
  for(auto it = sections.begin(); it != sections.end(); ++it)
  {
    if(card[0] && (it + 1) != sections.end() && it->end() + 1 == (it + 1)->begin())
      ans = max(ans, it->length() + (it + 1)->length() + 1);
    if(card[0])
      ans = max(ans, it->length() + 1);
    ans = max(ans, it->length());
  }
  cout << ans << endl;
  goto loop;
}

Measured memory_bytes: 1524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

    ll maxCnt = 0;
    ll cnt = 0;
    REP(i, S.length()) {
        for(ll j = 0; j <= T.length() && j + i <= S.length(); ++i) {
            string sbs = T.substr(j, min(T.length() - j, S.length() - j));
            ll tmpCnt = 0;

            if(i + sbs.length() <= S.length()) {
                REP(h, sbs.length()) {
                    if(S[i + h] == sbs[h]) {
                        ++tmpCnt;
                    }
                }
            }

            if(tmpCnt >= maxCnt) {
                maxCnt = tmpCnt;
            }
        }
    }

    cout << T.length() - maxCnt << endl;

    return 0;
}

Measured memory_bytes: 3600
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
count = 0
for i in range(n):
    if a[i] >= b[i]:
        count += b[i]
    elif a[i]+a[i+1] >= b[i]:
        count += b[i]
        a[i+1] -= b[i] - a[i]
    else:
        count += a[i] + a[i+1]
        a[i+1] = 0
print(count)

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

int main(){
    vector<int> haiku(3);
    int p=0, q=0;
    
    for (int i = 0; i < 3; i++){
        cin >> haiku.at(i);
    }
    for (int i = 0; i < 3; i++){
        if (haiku.at(i) == 5){
            p++;
        }
        else if (haiku.at(i) == 7){
            q++;
        }
    }

    if (p==2 || q==1){
        cout << "YES" <<endl;
    }
    else {
        cout << "NO" << endl;
    }

}

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

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

  vector<int> ans(n);
  for (int i = 1; i < n; i++) {
    int b = 0, t = i;
    while (t) {
      b += (t & 1);
      t >>= 1;
    }

    if (i % b == 0)
      ans[i] = 1;
    else
      ans[i] = ans[i % b] + 1;
  }

  vector<int> a(n);
  int s = 0;
  for (int i = 0; i < n; i++) {
    char c;
    scanf(" %c", &c);
    a[i] = c - '0';
    s += a[i];
  }

  vector<vector<int>> two(2, vector<int>(n));
  vector<int> x(2);
  for (int i = 0; i < 2; i++) {
    int m = i * 2 - 1;
    if (s + m > 0)
    {
      two[i][0] = 1 % (s + m);
      x[i] = a[0] % (s + m);
      for (int j = 1; j < n; j++) {
        two[i][j] = two[i][j - 1] * 2 % (s + m);
        x[i] = (x[i] * 2 + a[j]) % (s + m);
      }
    }
  }

  for (int i = 0; i < n; i++)
  {
    int u = s - 2 * a[i] + 1;
    if (u == 0)
      printf("0\n");
    else {
      int v = (x[1 - a[i]] + (-2 * a[i] + 1) * two[1 - a[i]][n - i - 1] + u) % u;
      printf("%d\n", ans[v] + 1);
    }
  }

  return 0;
}

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

using namespace std;

int main(){
  string a; cin>>a;
  if(a[1]==a[2] && a[0]==a[1]){
    cout<<"Yes";
  }else if(a[1]==a[2] &&a[2]==a[3]){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
  
  return 0;
}


Measured memory_bytes: 256