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

bool isPalindrome(string S) {
  bool ret = true;
  for (int i = 0; i < (S.length() + 1) / 2; i++) {
    ret = ret && S[i] == S[S.length() - 1 - i];
  }
  return ret;
}

int main(void) {
  string S;
  cin >> S;
  cout << (isPalindrome(S) && isPalindrome(S.substr(0, (S.length() - 1) / 2))
               ? "Yes"
               : "No")
       << endl;
  return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.map!(to!int).array; }

void main() {
    auto nab = readints;
    int n = nab[0], a = nab[1], b = nab[2];

    writeln(min(n * a, b));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long int pow107 = (int)pow(10, 9) + 7;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}


int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<int,int> > vn,vm;

    for(int i = 0; i < n; ++i){
        int a,b;
        cin >> a >> b;
        vn.push_back(make_pair(a,b));
    }
    for(int i = 0; i < m; ++i){
        int a,b;
        cin >> a >> b;
        vm.push_back(make_pair(a,b));
    }
    
    for(int i = 0; i < n; ++i){
        int min = pow(10,9),x;
        for(int j = 0; j < m; ++j){
            if(min > abs(vn[i].first - vm[j].first) + abs(vn[i].second - vm[j].second)){
                min = abs(vn[i].first - vm[j].first) + abs(vn[i].second - vm[j].second);
                x = j + 1;
            }
        }
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
//#define rep(i,n) for(i=0; i < n; i++)
#define MAX 100000

vector<int> V(MAX);

int main(){
   int A, B , C ,D;
   cin >> A >> B >> C >> D;
   if(A+B>C+D) cout<< "Left" << endl;
   else if(A+B<C+D) cout<<"Right"<<endl;
   else cout << "Balanced" << endl;
    //昇順でソートして、INFまで絶対置分だけ加算する

}


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

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

  int min = s.length();

  for (char c = '0'; c <= '1'; c++) {
    int n = 0;
    for (int i = 0; i < s.length(); i+=2) {
      if (s[i] != c) {
        n++;
      }
    }
    for (int i = 1; i < s.length(); i+=2) {
      if (s[i] == c) {
        n++;
      }
    }
    if (min > n) {
      min = n;
    }
  }

  cout << min << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	string s ; 
	cin >> s ; 
	int a = 0 , b= 0 ;
	rep(i,0,sz(s)){
		if(s[i]=='A') a++;
		else b++;
	}
	if(a==0 or b==0) cout << "No\n";
	else cout << "Yes\n";

}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;
int64_t dp[2005];
int main() {
  int S;
  cin>>S;
  dp[0]=1;
  for(int i=0;i<=2000;i++){
    for(int next=3;next<=2001;next++){
      if(dp[i]==0){continue;}
      if(i+next<=2000){(dp[i+next]+=dp[i])%=mod;}
    }
  }
  cout<<dp[S]<<endl;
  return 0;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=1;
        int c=0;
        while(b<=a){
           if(b%2==1){
            c++;
           }
           b++;
        }
       System.out.println((double)c/a);
    }
}

Measured memory_bytes: 21968
a = int(input())
b = []
for i in range(a):
  c = input()
  if i == 0:
    b.append(c)
  elif 1 <= i < a-1:
    if c[0] != b[-1][-1] or c in b:
      b.append(c)
      print("No")
      break
    else:
      b.append(c)
  elif i == a-1:
    if c[0] != b[-1][-1] or c in b:
      print("No")
    else:
      print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<algorithm>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
#define pb push_back
#define mp make_pair
#define mh make_heap
#define F first
#define S second
//#define fin cin
//#define fout cout
#define file ifstream fin("input.txt");ofstream fout("output.txt");
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr(n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long int ll;
typedef pair<ll,ll> pairs;
typedef vector<ll> vi;
typedef vector<pairs> vpair;

void solve()
{
    ll n;cin>>n;
    n-=1;
    cout<<n*(n+1)/2;


    return ;

}
int main()
{
    ll t=1;
    //cin>>t;
    fr(t)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    ll n;
    while(cin>>n)
    {
        int i=1;
        for(i=1;i<=n;i++)
        {
            if((int)(i*1.08)==n)
            {
                cout<<i<<endl;
                break;
            }
        }
        if(i>n)cout<<":("<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        for(int i = 1; i < a+1; i++){
            int x = i;
            if (x % 3 == 0) {
                System.out.print(" "+i);
            } else {
                while(true){
                    if(x % 10 == 3){
                        System.out.print(" "+i);
                    break;
                    }
                    x /= 10;
                    if(x != 0){
                        continue;
                    }else{
                        break;
                    }
                }
            }
        }
        System.out.print("\n");
    }
}



Measured memory_bytes: 28528
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn = 100005;

int n;
vector<int>e[maxn];
bool f[maxn];
bool dfs(int x,int fa) {
  int cnt=0;
  for(int i=0; i<e[x].size(); i++) {
    int v=e[x][i];
    if(v==fa)continue;
    if(!dfs(v,x))return false;
    if(!f[v])cnt++;
  }
  if(cnt==1){
    f[x]=1;
    return true;
  } else {
    if(cnt>1)return false;
    return true;
  }
}

int main() {
 // freopen("in.cpp","r",stdin);
  cin>>n;
  for(int i=1; i<n; i++) {
    int x,y;
    cin>>x>>y;
    e[x].push_back(y);
    e[y].push_back(x);
  }
  if(dfs(1,0)&&f[1])cout<<"Second"<<endl;
  else cout<<"First"<<endl;
  return 0;
}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int m,f,r;
        cin>>m>>f>>r;
        if(m==-1 && f==-1 && r==-1)break;
        string ans;
        if(m==-1 || f==-1)ans="F";
        else if(m+f>=80) ans="A";
        else if(m+f>=65) ans="B";
        else if(m+f>=50) ans="C";
        else if(m+f>=30){
            if(r>=50) ans="C";
            else ans="D";
        }
        else ans="F";
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int m1, d1, m2, d2;
	cin >> m1 >> d1 >> m2 >> d2;

	bool ok = (d2 == 1);

	cout << (int) ok << endl;

	return 0;
}


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

int main(){
	int H, W;
	cin >> H >> W;
	vector<vector<char>> a(H,vector<char>(W));
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			cin >> a.at(i).at(j);
		}
	}
	
	vector<int> row(H);
	vector<int> col(W);
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			if( a.at(i).at(j) == '.' ){
				if( j == W-1 ){
					row.at(i) = 1;
				}
			}
			else{
				break;
			}
		}
	}
	for(int j=0; j<W; j++){
		for(int i=0; i<H; i++){
			if( a.at(i).at(j) == '.' ){
				if( i == H-1 ){
					col.at(j) = 1;
				}
			}
			else{
				break;
			}
		}
	}

	for(int i=0; i<H; i++){
		if(row.at(i)==1){
			continue;
		}
		for(int j=0; j<W; j++){
			if(col.at(j)==1){
			}
			else{
				cout << a.at(i).at(j);
			}
			if(j==W-1){
				cout << endl;
			}
		}
	}
}


Measured memory_bytes: 256
use proconio::*;
use std::collections::*;

#[fastout]
fn main() {
    input! {
        x: usize,
        y: usize,
    }

    for i in 0..=100 {
        for j in 0..=100 {
            if i + j == x && 2 * i + 4 * j == y {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}


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

string s, bezx;
int izm[100010], p, sol;

int main()
{
	cin >> s;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] != 'x')
		{
			bezx += s[i];
			p++;
		}
		else
			izm[p]++;
	}
	for (int i = 0; i < bezx.length(); i++)
	{
		if (bezx[i] != bezx[bezx.length() - i - 1])
		{
			cout << -1;
			return 0;
		}
	}
	for (int i = 0; 2 * i < p; i++) sol += max(izm[i] - izm[p - i], izm[p - i] - izm[i]);
	cout << sol;
	return 0;
}

Measured memory_bytes: 768
//The Number of Inversions
#include <iostream>
#include <vector>

using namespace std;

struct weight {
    int id;
    int weight;
    bool searched = false;
};

int partition(weight A[], int p, int r) {
    int x = A[r].weight;
    int i = p - 1;
    for(int j = p; j < r; j++) {
        if(x >= A[j].weight) {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}

void quickSort(weight A[], int p, int r) {
    if(p < r) {
        int x = partition(A, p, r);
        quickSort(A, p, x - 1);
        quickSort(A, x + 1, r);
    }
}


int main() {
    int n, s = 10000;
    cin >> n;
    weight W[n];
    for(int i = 0; i < n; i++) {cin >> W[i].weight; W[i].id = i; s = min(s, W[i].weight);}

    quickSort(W, 0, n - 1);

    int cost = 0;
    for(int i = 0; i < n; i++) {
        if(!W[i].searched) {
            int id = i, c = 0, size = 0;
            while(1) {
                W[id].searched = true;
                c += W[id].weight;
                size++;
                id = W[id].id;
                if(id == i) break;
            }
            if(size != 1) cost += (c + min((size - 2) * W[i].weight, W[i].weight + (size + 1) * s));
        }
    }
    cout << cost << endl;
}


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

typedef pair<int,int> pii;

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

    int n; cin >> n;
    std::vector<ll> a(n); rep(i,n) cin >> a[i];
    
    ll low = 0LL;
    ll high = a[0]*2LL;
    ll mid = (high+low)/2LL;
    if(mid%2==1) mid +=1;
    
    while(low < high){

        bool possible = true;

        ll x = mid;

        rep(i,n){
            x = (a[i]-x/2)*2;
            if(x<0) possible = false;
        }

        //cout << low << " " << mid << " " << high << " " << x << endl;

        if(x==mid && possible){break;}

        if(mid < x){
            low = mid+2;
        } else {
            high = mid-2;
        }

        mid = (high+low)/2;
        if(mid%2==1) mid +=1;
    }

    rep(i,n){
        cout << mid << " ";
        mid = (a[i]-mid/2)*2;
    }
    cout << '\n';


    return 0;
}

Measured memory_bytes: 2176
/*https://atcoder.jp/contests/code-festival-2016-qualb/tasks/codefestival_2016_qualB_b*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int n, a, b;
	string s;
	cin >> n >> a >> b;
	cin >> s;
	int pass = 0, orank = 0;
	for (int i = 0; i < n; i++)
	{
		if (pass < a + b)
		{
			if (s[i] == 'a')
				pass++, cout << "Yes" << endl;
			else if (s[i] == 'b')
			{
				orank++;
				if (orank <= b)
					pass++, cout << "Yes" << endl;
				else
					cout << "No" << endl;
			}
			else
				cout << "No" << endl;
		}
		else
			cout << "No" << endl;
	}
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,ans=0;
    cin >> n;
    vll a(n),b(n),c(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    sort(all(a));
    sort(all(b));
    sort(all(c));
    rep(i,n){
        ll res=lower_bound(all(a),b[i])-a.begin();
        ll lar=n-(upper_bound(all(c),b[i])-c.begin());
        ans+=res*lar;
    }
    cout << ans << endl;
    return 0;
}

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

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

	set<char> st(s.begin(), s.end());

	if (st.count('N') ^ st.count('S')) {
		puts("No");
		return 0;
	}
	if (st.count('E') ^ st.count('W')) {
		puts("No");
		return 0;
	}
	puts("Yes");
}

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

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

int main() {
    vector<bool> v(1300000, false);

    for (int i = 2; i < 1200; i++) {
        for (int j = 2; j * i <= 1300000; j++) {
            v[j * i] = true;
        }
    }

    int k;
    while (cin >> k, k) {
        int a = -1, b = -1;
        for (int i = 1; true; i++) {
            if (!v[k]) break;
            if (a != -1 && b != -1) break;

            if (k - i > 0 && !v[k - i] && a == -1) a = k - i;
            if (k + i < 1300000 && !v[k + i] && b == -1) b = k + i;
        }
        cout << b - a << endl;
    }

    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}


LL rec(int n, LL x) {
    if(n == 0) {
        return 1;

    }
    LL l, num;
    l = (1ll << (n + 1)) - 3;
    num = (1ll << n) - 1;

    if(x == 1) return 0;
    if(x <= l + 1) return rec(n - 1, x - 1);
    if(x == l + 2) return num + 1;
    if(x <= (l + 1) * 2) return num + 1 + rec(n - 1, x - l - 2);
    return num * 2 + 1;

}

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

    int n;
    LL x;
    cin >> n >> x;

    cout << rec(n, x) << endl;
    return 0;
}



Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let a = read::<usize>();
    let b = read::<usize>();
    println!("{}", (b - 1 + a - 2) / (a - 1));
}


Measured memory_bytes: 4352
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int num = in.nextInt();
            int number;
            int a = 0, b = 0, c = 0;
            for (int i = 0; i < num; i++) {
                number = in.nextInt();
                if (number % 4 == 0) {
                    a += 1;
                } else if (number % 2 == 0) {
                    b += 1;
                } else {
                    c += 1;
                }
            }
            if (b == 0) {
                if (a + 1 >= c) {
                    out.println("Yes");
                } else {
                    out.println("No");
                }
            } else {
                if (a >= c) {
                    out.println("Yes");
                } else {
                    out.println("No");
                }
            }
        }

    }
}



Measured memory_bytes: 48276
import java.util.Scanner;
public class Main{
	public static void main(String[] args){

        Scanner s = new Scanner(System.in);
		int i,j,n,m;				
        
        n = s.nextInt();
        m = s.nextInt();
        int[][] a = new int[n][m];
        
		for(i=0;i<n;i++)
            for(j=0;j<m;j++)
               a[i][j]  = s.nextInt();


        int[] b = new int[m];
        for(i=0;i<m;i++)
            b[i]  = s.nextInt();
				
        int[] c = new int[n];
        for(i=0;i<n;i++){
            for(j=0;j<m;j++){
           		c[i]+=(a[i][j])*(b[j]);
            }
        }
        
        for(i=0;i<n;i++){
            System.out.println(c[i]);
        
        }
		s.close();
	}
}


Measured memory_bytes: 40672
/*
 * “The difference between a master and a novice - is that the master has failed more times,
 *  than the novice has tried.”
 */
#include <bits/stdc++.h>
#define pvar(x) clog<<"["<<#x<<":"<<x<<"]\n"
using namespace std;
using ll = long long int;
void solve(){
	string n;
	cin>>n;
	int sum = 0;
  for(auto c : n){
  	int dig = c - 48;
  	sum  = (sum + dig)%9;
  }
  if(sum == 0)cout<<"Yes\n";
  else cout<<"No\n";
}
int main(){
	ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  while(t--){
		solve();
	}
}
 


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

typedef long long ll;

static const int MAX = 1e6;
static const int NIL = -1;
static const ll INF = 1<<21;
static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

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

    if((a==b&&b==c)||a!=b&&b!=c&&a!=c) { 
        cout << "No" << endl;
        return 0;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


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

    ll ans = 0;
    rep1(i, n)rep1(j, n)rep1(k, n){
        int ab = gcd(i, j);
        ans += gcd(ab, k);
    }
    cout << ans << endl;
}



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

using Graph = vector<vector<int>>;
using Pii = pair<int, int>;

void dfs(int v, int& i, const Graph& G, vector<Pii>& vp) {
  // cerr << "v = " << v << ", i = " << i << endl;
  vp[v].first = i++;
  for (auto u : G[v]) {
    dfs(u, i, G, vp);
  }
  vp[v].second = i;
}

template<class I>
class SegTree {
private:
  int n;
  std::vector<I> dat, lazy;

public:
  SegTree(int n_) {
    n = 1;
    while (n < n_) n *= 2;
    dat.resize(2 * n - 1, 0);
    lazy.resize(2 * n - 1, 0);
  }

  void eval(int k, int l, int r) {
    // cerr << "k = " << k << ", l = " << l << ", r = " << r << endl;
    if (lazy[k] == 0) return;
    dat[k] = (r - l) - dat[k];
    if (k < n - 1) {
      lazy[2 * k + 1] = (lazy[2 * k + 1] + lazy[k]) % 2;
      lazy[2 * k + 2] = (lazy[2 * k + 2] + lazy[k]) % 2;
    }
    lazy[k] = 0;
  }

  void update(int a, int b, I x, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    eval(k, l, r);
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      lazy[k] = (lazy[k] + x) % 2;
      eval(k, l, r);
    }
    else {
      update(a, b, x, 2 * k + 1, l, (l + r) / 2);
      update(a, b, x, 2 * k + 2, (l + r) / 2, r);
      dat[k] = dat[2 * k + 1] + dat[2 * k + 2];
    }
  }

  // return op[a..b)
  // k: node id, [l, r): node interval
  I query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    eval(k, l, r);
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return dat[k];
    I vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
    I vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return vl + vr;
  }

  void print() {
    int j = 2;
    for (int i = 0; i < 2 * n - 1; i++) {
      cerr << "(" << dat[i] << ", " << lazy[i] << ")";
      if (i == j - 2) {
        cerr << endl;
        j *= 2;
      }
      else {
        cerr << " ";
      }
    }
  }
};

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

  int n, q;
  cin >> n >> q;
  Graph G(n);
  rep2(i, 1, n) {
    int x;
    cin >> x;
    x--;
    G[x].push_back(i);
  }

  vector<Pii> vp(n);
  int cnt = 0;
  dfs(0, cnt, G, vp);

  SegTree<int> seg(n);
  // seg.print();
  rep(i, n) {
    char c;
    cin >> c;
    if (c == 'G') {
      seg.update(vp[i].first, vp[i].first + 1, 1);
    }
    // cerr << "i = " << i << endl;
    // seg.print();
  }

  // seg.print();

  rep(i, q) {
    int v;
    cin >> v;
    v--;
    seg.update(vp[v].first, vp[v].second, 1);
    int sm = seg.query(0, n);
    // cout << "i = " << i << ": ";
    cout << (2 * sm > n ? "broccoli" : "cauliflower") << endl;
    // seg.print();
  }


  return 0;
}



Measured memory_bytes: 17360
n=int(input())
d=dict({i:0 for i in range(1,n+1)})
for s in range(3,201):
    for x in range(1,s+1-2):
        for y in range(1,s+1-x-1):
            z=s-x-y
            v=x**2+y**2+z**2+x*y+y*z+z*x
            if not v in d:
                continue
            d[v]+=1
for k in d.keys():
    print(d[k])


Measured memory_bytes: 9564
#include <iostream>
using namespace std;
int main(){
        int a[4];
        int x,y,z;
        cin >>x;
        a[0]=(x/1000);
        x=x%1000;
        a[1]=(x/100);
        x=x%100;
        a[2]=(x/10);
        x=x%10;
        a[3]=x;
        if(a[0]==a[1] && a[1]==a[2]) {
                cout << "Yes" << endl;
        }
        else if (a[1]==a[2] && a[2]==a[3]) {
                cout << "Yes" << endl;
        }
        else{
                cout << "No" << endl;
        }
}


Measured memory_bytes: 256
/*
PROG: arc084b
LANG: C++
    _____
  .'     '.
 /  0   0  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
 */
#include <bits/stdc++.h>

using namespace std;

long long readi()
{
	long long input = 0;
	char c = ' ';
	while (c < '-')
	{
		c = getchar();
	}
	bool negative = false;
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	while (c >= '0')
	{
		input = 10 * input + (c - '0');
		c = getchar();
	}
	if (negative)
	{
		input = -input;
	}
	return input;
}
void printi(long long output)
{
	if (output == 0)
	{
		putchar('0');
		return;
	}
	if (output < 0)
	{
		putchar('-');
		output = -output;
	}
	int aout[20];
	int ilen = 0;
	while(output)
	{
		aout[ilen] = ((output % 10));
		output /= 10;
		ilen++;
	}
	for (int i = ilen - 1; i >= 0; i--)
	{
		putchar(aout[i] + '0');
	}
	return;
}
string reads()
{
	string input = "";
	char c = ' ';
	while (c <= ' ')
	{
		c = getchar();
	}
	while (c > ' ')
	{
		input += c;
		c = getchar();
	}
	return input;
}
void prints(string output)
{
	for (int i = 0; i < output.length(); i++)
	{
		putchar(output[i]);
	}
	return;
}

#define MP make_pair
#define PB push_back
#define PF push_front
#define MT make_tuple
#define LB lower_bound
#define UB upper_bound

#define SINF 10007
#define MOD 1000000007
#define INF 1000000861
#define LLINF 1000000000000000861ll
#define CO 1000861
#define EPS 0.000000000000001
#define PI 3.141592653589793
#define MAXN 100010

typedef int64_t ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll N;
int dist[MAXN];
deque<pii> dq;
int ans;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	srand(time(NULL));
	//	cout << fixed << setprecision(10);
	//	cerr << fixed << setprecision(10);
	//	if (fopen("arc084b.in", "r"))
	//	{
	//		freopen ("arc084b.in", "r", stdin);
	//		freopen ("arc084b.out", "w", stdout);
	//	}
	cin >> N;
	while(N % 2 == 0)
	{
		N /= 2;
	}
	while(N % 5 == 0)
	{
		N /= 5;
	}
	if (N == 1)
	{
		cout << "1\n";
		return 0;
	}
	for (int i = 0; i < N; i++)
	{
		dist[i] = INF;
	}
	dist[1] = 1;
	dq.PB(MP(1, 1));
	while(!dq.empty())
	{
		pii u = dq.front();
		dq.pop_front();
		if (dist[(u.second + 1) % N] > dist[u.second] + 1)
		{
			dist[(u.second + 1) % N] = dist[u.second] + 1;
			dq.PB(MP(dist[(u.second + 1) % N], (u.second + 1) % N));
		}
		if (dist[(u.second * 10) % N] > dist[u.second])
		{
			dist[(u.second * 10) % N] = dist[u.second];
			dq.PF(MP(dist[(u.second * 10) % N], (u.second * 10) % N));
		}
	}
	ans = dist[0];
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
	"math"
)

func main() {
	var N int
	fmt.Scan(&N)

	W := make([]int, N)
	sum := 0
	for i := 0; i < N; i++ {
		fmt.Scan(&W[i])
		sum += W[i]
	}
	ans := sum
	pre_sum := 0
	for i := 0; i < N; i++ {
		pre_sum += W[i]
		ans = int(math.Min(float64(ans), math.Abs(float64(pre_sum-(sum-pre_sum)))))
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long A,B,x,tmp;
  cin >> A >> B;
  x = A*B;
 
  /* 自然数 a > b を確認・入替 */
  if(A<B){
    tmp = A;
    A=B;
    B= tmp;
  }
 
  /* ユークリッドの互除法 */
  tmp = A % B;
  while(tmp!=0){
    A=B;
    B=tmp;
    tmp=A%B;
  }
  cout << x/B;

}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    h,w = readline() |> split |> parseMap
    s = String["" for i in 1:h]
    lc = 0
    for i in 1:h
        s[i] = readline() |> chomp
        for j in 1:w
            if s[i][j]=='#'
                lc += 1
            end
        end
    end
    stack = Tuple{Int,Int}[]
    push!(stack,(1,1))
    vst = -ones(Int,h,w)
    vst[1,1] = 0
    while !isempty(stack)
        now = shift!(stack)
        y = now[1]
        x = now[2]
        if now[1]>1
            if s[y-1][x]=='.'
                if vst[y-1,x]<0
                    vst[y-1,x] = vst[y,x]+1
                    push!(stack,(y-1,x))
                end
            end
        end
        if now[1]<h
            if s[y+1][x]=='.'
                if vst[y+1,x]<0
                    vst[y+1,x] = vst[y,x]+1
                    push!(stack,(y+1,x))
                end
            end
        end
        if now[2]>1
            if s[y][x-1]=='.'
                if vst[y,x-1]<0
                    vst[y,x-1] = vst[y,x]+1
                    push!(stack,(y,x-1))
                end
            end
        end
        if now[2]<w
            if s[y][x+1]=='.'
                if vst[y,x+1]<0
                    vst[y,x+1] = vst[y,x]+1
                    push!(stack,(y,x+1))
                end
            end
        end
   end
   println(vst[h,w]>0?h*w-lc-vst[h,w]-1:-1)
end

main()

Measured memory_bytes: 114732
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e5+10;
const int MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
int main() 
{ 
	//ios_base::sync_with_stdio(false);
  //  cin.tie(NULL);	
//	#ifndef ONLINE_JUDGE
//	freopen("inp.txt" ,"r", stdin );
//	freopen("out.txt", "w", stdout);
//	#endif
	ll n ,w ;
	cin>>n>>w;
	ll tot=0;
	ll cost[n+1] , wt[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>wt[i]>>cost[i];
		tot=tot+cost[i];
	}
	ll dp[n+1][tot+1];
	for(int i=0;i<=n;i++)
		for(int j=0;j<=tot;j++){
			dp[i][j]=INF;
		}
	for(int i=1;i<=n;i++){
		for(int j=0;j<=tot;j++){
			if(j==0)
				dp[i][j]=0;
			else if(i==1){
					if(j==cost[i])
						dp[i][j]=wt[i];
					else 
						dp[i][j]=INF;
			}
			else{
				if(j-cost[i]>=0)
					dp[i][j]=min(dp[i-1][j], dp[i-1][j-cost[i]]+wt[i]);
				else
					dp[i][j]=dp[i-1][j];
			}
		}
	}
	for(int i=tot;i>=0;i--)
	{
	//	cout<<dp[n][i]<<" ";
		if(dp[n][i]<=w){
			cout<<i;
			return 0;
		}
	}
}

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

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

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

template <class T>  inline void smax(T &x,T y){ x = max((x), (y)); }
template <class T>  inline void smin(T &x,T y){ x = min((x), (y)); }

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

int a[305][305] ;

bool possible(int n , int m ,int k)
{
    int curPointer[305] , cntPlayer[305] ; //cntPlayer[i]= i'th game kotojon kheltese,
//curPointer[i] = i'th row e kothay point kora ase , pointedTo[i][j] = i'th game j'th row teo point kora ase
    bool isCanceled[305] ;

    memset(isCanceled,0,sizeof(isCanceled)) ;
    memset(cntPlayer,0,sizeof(cntPlayer)) ;

    int i , j ;

    for(i=1 ; i<=n ; i++)
    {
        curPointer[i] = 1 ;
        cntPlayer[ a[i][1] ]++ ;
    }

    while(1)
    {
        int fl = 1 ;
        for(i=1 ; i<=m ; i++)
        {
            if( !isCanceled[i] && cntPlayer[i] > k ){
                isCanceled[i] = true ;
                fl = 0 ;
            }
        }

        if(fl==1) return 1 ;
      //  DBG ;
   //     printf("%d\n",k) ;
        for(i=1 ;i<=n ; i++)
        {
            j = curPointer[i] ;
            while(j<=m)
            {
                if( isCanceled[ a[i][j] ]==true ) j++ ;
                else break ;
            }
            if(j>m) return 0 ;
            if( j>curPointer[i] ) cntPlayer[a[i][j] ]++ ;
            curPointer[i] = j ;
        //    printf("%d: %d %d\n",i,curPointer[i],cntPlayer[ a[i][j] ]) ;
        }
    }
    return 1 ;
}

int main()
{
    int i , j , k , l , m , n ;

    scanf("%d %d",&n,&m) ;

    FOR(i,1,n) FOR(j,1,m) scanf("%d",&a[i][j]) ;

 //   cout<<possible(n,m,2)<<endl ;

 //   return 0 ;

    int lo = 1 , hi = n , mid ;

    while(lo<hi)
    {
        mid = (lo+hi)/2 ;
        if(possible(n,m,mid)) hi = mid ;
        else lo = mid+1 ;
    }

    printf("%d\n",lo) ;

    return 0 ;
}


Measured memory_bytes: 640
x,y = [int(i) for i in input().split()]


a = -1
b = -1

for j in range(x+1):
    if 2*j + 4*(x-j) == y:
        a = j
        b = (x-j)
        break


if a != -1:
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m;
    long long int a,b;
    cin>>n>>m;
    std::multimap<long long int, long long int> map;
    for (int i=0;i<n;i++) {
        cin>>a>>b;
        map.emplace(a,b);
    }
    long long int sum=0;
    for (auto itr=map.begin();itr!=map.end();itr++) {
        if (itr->second<m) {
            sum+=itr->first*itr->second;
            m-=itr->second;
        } else {
            sum+=itr->first*m;
            break;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 6528
#include <stdio.h>
#include <stdbool.h>

#define N_MAX 50
#define INF 1145141919
#define SMAP(a, b) ((a)!=(b))&&((a)^=((b)^=((a)^= (b))))

typedef unsigned long long ull;

int i, j;

int n, m;
int k;

bool max[N_MAX * N_MAX];
bool d[N_MAX][N_MAX];

void solve(){
	return;
}

int main (void) {
	ull x;
	ull a, b;
	scanf("%llu%llu%llu", &a, &b, &x);
	if (a) printf("%llu\n", (b / x) - ((a-1) / x));
	else printf("%llu\n", b / x + 1);
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+10,M=1e5,OO=1e9+100;
typedef long long ll;
#define scan(A,n) for(int i=0;i<n;++i) cin>>A[i];
#define pb push_back
#define bg begin
#define en end
#define f first
#define s second
#define set(A,x) memset(A,x,sizeof(A))
#define print(A,x) for(int i=0;i<x;++i) cout<<A[i]<<" ";
#define pii pair<int,int>
#define pll pair<ll,ll>
#define low lower_bound
#define high upper_bound
#define bs binary_search
#define sz size
#define l length
#define all(A) A.bg(),A.en()
int main(){
    string str; int b;
    cin>>b>>str;
    if(b>=3200) cout<<str;
    else cout<<"red";
}

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

typedef long long int int64;

int cmp(const void *a,const void *b){
  int64 p=*(int64 *)a;
  int64 q=*(int64 *)b;
  return p==q?0:p<q?-1:1;
}

int64 *za=NULL;
int len=0;
void zaatsu(int64 *b,int n){
  za=(int64 *)malloc(sizeof(int64)*n);
  int i;
  for(i=0;i<n;i++) za[i]=b[i];
  qsort(za,n,sizeof(int64),cmp);
  len=0;
  i=0;
  while(i<n){
    za[len++]=za[i++];
    while(i<n && za[len-1]==za[i]) i++;
  }
  return;
}

int toIndex(int64 v){
  int l=0;
  int r=len;
  while(r-l>1){
    int m=(l+r)/2;
    if(za[m]<=v){
      l=m;
    } else {
      r=m;
    }
  }
  return l;
}

void inc(int *bit,int n,int index){
  int i;
  for(i=index;i<=n;i+=i&-i) bit[i]++;
  return;
}

int sum(int *bit,int n,int index){
  int res=0;
  int i;
  for(i=index;i>0;i-=i&-i) res+=bit[i];
  return res;
}

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int *a=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++){
    scanf("%d",a+i);
    a[i]-=k;
  }
  int64 *b=(int64 *)malloc(sizeof(int64)*(n+1));
  b[0]=0;
  for(i=1;i<=n;i++) b[i]=b[i-1]+a[i-1];
  zaatsu(b,n+1);
  int *bit=(int *)calloc(len+1,sizeof(int));
  int64 ans=0;
  for(i=0;i<=n;i++){
    int index=toIndex(b[i])+1;
    ans+=sum(bit,len,index);
    inc(bit,len,index);
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 5628
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
ll gcd(ll a, ll b){
	if(b==0) return a;
	return gcd(b, a%b);
}
int main()
{
	ll a, b; cin>>a>>b;
	ll g=gcd(a, b);
	int ans=1;
	for(ll i=2; i*i<=g; i++){
		if(g%i==0){
			while(g%i==0) g/=i;
			ans++;
		}
	}
	if(g>1) ans++;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

vector < vector < int > > g;
vector < vector < int > > ginv;
vector < int > color; //0 - white, 1 - grey, 2 - black
vector < int > p;
vector < bool > inp;

vector < vector < int > > d;

void dfs(int v, int par = -1) {
    /*cout<<v + 1<<": ";
    for (auto i : p)
        cout<<i + 1<<" ";
    cout<<"\n";*/
    if (color[v] == 2)
        return;
    if (color[v] == 1) {
        //cout<<"v = "<<v + 1<<"\n";
        int ind = p.size() - 1;
        while (p[ind] != v)
            ind--;
        cout<<(p.size() - ind)<<"\n";
        for (int i = ind; i < p.size(); i++)
            cout<<p[i] + 1<<"\n";
        exit(0);
    }
    color[v] = 1;
    p.push_back(v);
    inp[v] = 1;
    for (auto u : g[v]) {
        if (u == par) continue;
        bool pos = true;
        int cnt = 0;
        for (auto i : ginv[u]) {
            if (inp[i]) cnt++;
        }
        //cout<<"cnt = "<<cnt<<"\n";
        if (cnt > 1) pos = false;
        cnt = 0;
        for (auto i : g[u]) {
            cnt += inp[i];
        }
        //cout<<"cnt2 = "<<cnt<<"\n";
        if (cnt >= 1) {
            int ind = p.size() - 1;
            while (!d[u][p[ind]])
                ind--;
            cout<<(p.size() - ind + 1)<<"\n";
            for (int i = ind; i < p.size(); i++)
                cout<<p[i] + 1<<"\n";
            cout<<u + 1<<"\n";
            exit(0);
        }
        if (pos) {
            dfs(u, v);
        }
    }
    inp[v] = 0;
    p.pop_back();
    color[v] = 2;
}

void solve() {
    int n, m;
    cin>>n>>m;
    g.resize(n);
    ginv.resize(n);
    d.resize(n, vector < int > (n, 0));
    for (int i = 0; i < m; i++) {
        int u, v;
        cin>>u>>v;
        u--;
        v--;
        g[u].push_back(v);
        ginv[v].push_back(u);
        d[u][v] = 1;
    }
    inp.resize(n, 0);
    color.resize(n, 0);
    for (int i = 0; i < n; i++)
        if (!color[i])
            dfs(i);
    cout<<"-1\n";
}

int main() {
    ios::sync_with_stdio(false);
    int t;
    t = 1;
    while (t--)
        solve();
}

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

int main(){
  vector<string> S(3);
  cin>>S.at(0)>>S.at(1)>>S.at(2);
  
  int turn=0;
  char winner;
  while(1){
    if(S.at(turn).size()==0){
      switch(turn){
        case 0:
          winner='A';
          break;
        case 1:
          winner='B';
          break;
       case 2:
          winner='C';
          break;
      }
      break;
    }
    char x=S.at(turn).at(0);
    S.at(turn).erase(S.at(turn).begin());
    switch(x){
      case 'a':
        turn=0;
        break;
      case 'b':
        turn=1;
        break;
      case 'c':
        turn=2;
        break;
    }
  }
  cout<<winner <<endl;
}
    
          

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
int n;
int a,b,ans=0,mark[207];
pair <int,int> now[207];
int main(){
	ios_base::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a>>b;
		now[a]=mp(b,1);
	}
	for(int i=1;i<=n;i++){
		cin>>a>>b;
		now[a]=mp(b,2);
	}
	for(int i=0;i<=n*2-1;i++){
		if(now[i].se==1) continue;
		else{
			int mx=-1,pos=-1;
			for(int j=0;j<i;j++){
				if(mark[j]) continue;
				if(now[j].fi>mx && now[j].fi<now[i].fi){
					mx=now[j].fi;
					pos=j;
				}
			}
			if(pos!=-1){
				ans++;
				mark[pos]=1;
			}
			mark[i]=1;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}cout<<endl;}
vector<ll> divv(ll n);

int main() {
    ll n,k;
    string s;
    cin>>n>>k;
    double sum = 0;
    fr(i,1,n+1){
        int d = 0;
        while( i * pow(2, d) < k) d++;
        sum += pow(0.5, d);
    }
    sum/=n;
    printf("%10.11f\n",sum);
    return 0;
}

// return sorted 約数s 1 <= x <= n
vector<ll> divv(ll n) {
  vector<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.push_back(i);
      if(i*i != n) v.push_back(n/i);
    }
  }
  sort(alll(v));
  return v;
}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(a, b);
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
 
  int A[N] = {0};

  for (int i = 0; i < N; i++) {
    int ai;
    cin >> ai;
    A[ai]++;
  }

  sort(A, A+N, greater<int>());

  int sum=0;
  for (int i = 0; i < K; i++) sum += A[i];
  cout << N - sum << endl;
}


Measured memory_bytes: 1024
W, H, N = map(int, input().split())

x = [0] * N
y = [0] * N
a = [0] * N

for i in range(N):
    x[i], y[i], a[i] = map(int, input().split())

X1 = 0
X2 = 0
Y1 = 0
Y2 = 0

x1, x2, y1, y2 = 0, 0, 0, 0

X = 0
Y = 0

entire = W * H

for i in range(N):
    if a[i]==1 and X1<x[i]:
        x1 = x[i] * H
        X1 = x[i]
    elif a[i]==2 and X2<(W-x[i]):
        x2 = (W-x[i]) * H
        X2 = W - x[i]
    elif a[i]==3 and Y1<y[i]:
        y1 = y[i] * W
        Y1 = y[i]
    elif a[i]==4 and Y2<(H-y[i]):
        y2 = (H-y[i]) * W
        Y2 = H - y[i]

if (X1 + X2) >= W or (Y1 + Y2) >= H:
    print('0')
else:
    entire = entire - (x1 + x2 + y1 + y2) + ((X1+X2) * (Y1+Y2))

#if entire<=0:
#    print('0')
#else:
    print(entire)


Measured memory_bytes: 3064
// c++include
#include <iostream>
// cinclude
#include <stdio.h>
#include<string.h>
#include<math.h>
//c++標準ライブラリ
#include<vector>
#include<string>
//std使用<-namespace
using namespace std;

// define, typedef
#define rpt(i, n) for(i = 0; i < (n); i++)
typedef long long ll;

// main関数
int main(void) {
	string s, t;
	cin >> s >> t;
	int count = 0;
	int i;
	rpt(i, 3) {
		if (s[i] == t[i])
			count++;
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a, b;
  scanf("%d %d", &a, &b);
  if (a == b) {
    printf("Draw\n");
  }
  else if (a == 1) {
    printf("Alice\n");
  }
  else if (b == 1) {
    printf("Bob\n");
  }
  else if (a > b) {
    printf("Alice\n");
  }
  else {
    printf("Bob\n");
  }
  return 0;
}


Measured memory_bytes: 128
n,m = map(int, raw_input().split())
picA = [raw_input() for _ in range(n)]
picB = [raw_input() for _ in range(m)]
find = True
for x in range(n-m+1):
    for y in range(n-m+1):
        find = True
        for p in range(m):
            if picA[y+p][x:x+m] != picB[p]:
                find = False
                break
        if find:
            break
    if find:
        break
if find:
    print 'Yes'
else:
    print 'No'


Measured memory_bytes: 2568
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
 
void trace(int A[],int N){
int i;
for(i=0;i<N;i++){
if(i>0)printf(" ");
printf("%d",A[i]);
}
printf("\n");
}
 
void insertionSort(int A[],int N){
int j,i,v;
for(i=1;i<N;i++){
v=A[i];
j=i-1;
while(j>=0&&A[j]>v){
A[j+1]=A[j];
j--;
}
A[j+1]=v;
trace(A,N);
}
}
 
int main(){
int N,i,j;
int A[100];
 
scanf("%d",&N);
for(i=0;i<N;i++)scanf("%d",&A[i]);
 
trace(A,N);
insertionSort(A,N);
 
return 0;
}

Measured memory_bytes: 2744
import numpy as np 

H,N = map(int,input().split())

A,B = np.array([list(map(int,input().split())) for i in range(N)]).T

dp = np.zeros(H+1,dtype=np.int32)

for i in range(1,H+1):
    dp[i] = np.amin(dp[np.maximum(i-A,0)]+B)
    
print(dp[H])

Measured memory_bytes: 21292