akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n;
	string now, prev;

	cin >> n >> now;

	set<string> s;
	s.insert(now);

	FOR(i, 1, n) {
		prev = now;
		cin >> now;
		if (now[0] != prev[prev.size() - 1] || s.find(now) != s.end()) {
			cout << "No" << endl;
			return 0;
		}
		s.insert(now);
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

#include <cmath>
#include <cstdlib>
#include <climits>

//#include <stdio.h>
//#include <stdlib.h>


using namespace std;

#define debug false

int main(int argc, char *argv[]){

  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int sum = 0;
  if ( A+B <= 2*C ){
    sum = A*X + B*Y;
  }else{
    int smaller = (X<Y? X:Y);
    X -= smaller;
    Y -= smaller;
    sum = 2*C*smaller;

    int tmp1 = A*X + B*Y;
    int tmp2 = 2*C*(X+Y);
    sum += (tmp1>tmp2?tmp2:tmp1);

  }
  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner scn=new Scanner(System.in);
        String base=scn.next();
        int cnt=0;
        int max=0;
        for(int i=0;i<base.length();i++){
            switch(base.charAt(i)){
                case 'A':
                case 'T':
                case 'C':
                case 'G':
                    cnt++;
                    if(i==base.length()-1&&cnt>max) max=cnt;
                    break;
                default:
                    if(cnt>max) max=cnt;
                    cnt=0;
                    break;
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 22612
use std::str::FromStr;
use std::io::*;
use std::collections::*;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = AtRead::from(i);
    let (h, w, n) = i.read3::<usize, usize, usize>();
    let mut m = HashMap::new();
    for _ in 0..n {
        let (a, b) = i.read2::<usize, usize>();
        for y in 0..3 {
            for x in 0..3 {
                *m.entry(((a + y), (b + x))).or_insert(0) += 1;
            }
        }
    }
    let mut r = [0 as usize; 10];
    for (p, c) in m {
        if p.0 <= 2 || p.1 <= 2 || h < p.0 || w < p.1 {
            continue;
        }
        r[c] += 1;
    }
    let sum: usize = r.iter().sum();
    r[0] = (w - 2) * (h - 2) - sum;
    for &r in &r {
        writeln!(o, "{}", r).unwrap();
    }
}

mod utils {
    use super::*;

    pub struct AtRead<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        {$f:ident($($v:ident: $t:ident),*)} => {
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                $(
                    let $v = next(i);
                )*
                ($($v),*)
            }
        };
    }

    impl<R: BufRead> AtRead<R> {
        pub fn from(r: R) -> Self {
            AtRead {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(v1: T1, v2: T2) }
        fn_read! { read3(v1: T1, v2: T2, v3: T3) }
    }

    fn next<'a, T: FromStr, I: std::iter::Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }
}


Measured memory_bytes: 53544
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class Main {
	static int gcd(int x , int y){
		if(x < y){
			return gcd(y , x);			
		}
		while(y > 0){
			int r = x % y;
			x = y;
			y = r;
		}
		return x;
	}
	static String solveNaive(int A[]){
		int g = gcd(A[0] , A[1]);
		for(int i = 2 ; i < A.length ; ++i){
			g = gcd(g , A[i]);			
		}
		if(g != 1){
			return "not coprime";
		}
		for(int i = 0 ; i < A.length ; ++i){
			for(int j = i + 1 ; j < A.length ; ++j){
				g = gcd(A[i] , A[j]);
				if(g != 1){
					return "setwise coprime";					
				}
			}
		}
		return "pairwise coprime";
	}
	static String solve(int A[]){
		int g = gcd(A[0] , A[1]);
		for(int i = 2 ; i < A.length ; ++i){
			g = gcd(g , A[i]);			
		}
		if(g != 1){
			return "not coprime";
		}
		int ps[] = new int[1000001];
		for(int a : A){
			if(a == 1){
				continue;
			}
			if(ps[a] == 1){
				return "setwise coprime";
			}
			ps[a] = 1;
		}
		for(int i = 2 ; i < ps.length ; ++i){
			int p = 0;
			for(int j = i ; j < ps.length ; j += i){
				p += ps[j];
			}
			if(p >= 2){
				return "setwise coprime";				
			}
		}
		return "pairwise coprime";
	}
	public static void main(String[] args) {
		/*
		Random rand = new Random();
		for(int rep = 0 ; rep < 1000 ; ++rep){
			int A[] = new int[4];
			for(int i = 0 ; i < A.length ; ++i){
				A[i] = rand.nextInt(1000000) + 1;
			}
			String x = solve(A);
			String y = solveNaive(A);
			if(!x.equals(y)){
				System.out.println(Arrays.toString(A));
				System.out.println(x+" "+y);
			}else{
//				System.out.println(Arrays.toString(A));
//				System.out.println(x+" "+y);				
			}
		}*/
		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();
		}
		String ret = solve(A);
		System.out.println(ret);
	}
}


Measured memory_bytes: 62988
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, num[110];

int main(){
	while (cin >> n&&n){
		REP(i, 110)num[i] = 0;
		int sum = 0;
		REP(i, n){
			cin >> num[i];
			sum += num[i];
		}
		sort(num, num + n);
		sum -= num[0] + num[n - 1];
		cout << sum / (n - 2) << endl;
	}
}

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

int main(){
	int n,k;
	cin>>n>>k;
	vector <int> a(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a.begin(),a.end());
	vector <int> dp(k+1);
	for(int i=0;i<a[0];i++)
		dp[i]=0;
	for(int i=a[0];i<=k;i++){
		dp[i]=0;
		for(int j=0;j<n;j++){
			if(a[j]>i)
				break;
			dp[i]|=!(dp[i-a[j]]);
		}
	}
	if(dp[k]==1)
		cout<<"First\n";
	else
		cout<<"Second\n";
}

Measured memory_bytes: 3788
#include<stdio.h>
int main()
{
    int a, b, c;
    int tmp;
 
    scanf("%d%d%d", &a, &b, &c);
    if (a > b) tmp = a, a = b, b = tmp;
    if (b > c) 
        tmp = b, b = c, c = tmp;
        if (a > b) tmp = a, a = b, b = tmp;
    printf("%d %d %d\n", a, b, c);
    return 0;
}


Measured memory_bytes: 2116
package main

import "fmt"

func main(){
	var s,t string
	fmt.Scan(&s)
	fmt.Scan(&t)
	n := len(s)
	if n + 1 == len(t) && s[0:n] == t[0:n] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1752
import sys
from collections import deque
sys.setrecursionlimit(20000000)
input = sys.stdin.readline


def main():
    a, b, c = map(int, input().split())

    rest = a - b
    if rest < 0:
        rest = 0

    if rest > c:
        print(0)
    else:
        print(c - rest)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=(a); i<(b); i++)
#define push_back pb;
using namespace std;

int main(){
	int a[3][3];
	For(i,0,3)
		For(j,0,3)
			cin>>a[i][j];
	int n,k;
	cin>>n;
	For(i,0,n){
		cin>>k;
		For(i,0,3)
			For(j,0,3){
				if (a[i][j]==k)
					a[i][j]=0;
			}
	}
	For(i,0,3){
		bool flag=1;
		For(j,0,3){
			if (a[i][j]!=0)
				flag=0;
			}
		if (flag)
			goto loop;
	}
	For(i,0,3){
		bool flag=1;
		For(j,0,3){
			if (a[j][i]!=0)
				flag=0;
			}
		if (flag)
			goto loop;
	}
	if (a[0][0]==0 && a[1][1]==0 && a[2][2]==0)
		goto loop;
	if (a[0][2]==0 && a[1][1]==0 && a[2][0]==0)
		goto loop;
	cout<<"No";
	return 0;
	loop:
		cout<<"Yes";
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,ans=0;cin>>n;
  string s;cin>>s;
  rep(i,n-2) if(s.substr(i,3)=="ABC") ans++;
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<" "<<x<<endl;

using namespace std;

void run(){
	ll n;cin>>n;
	ll a[n];
	ll mx=2;
	for(ll i=0;i<n;i++){cin>>a[i];mx=max(mx,a[i]);}
	ll x=a[0];
	mx++;
//	cout<<mx<<endl;
	ll prime[mx]={0};
	ll spf[mx]={0};
	for(ll i=2;i<mx;i++){
		if(prime[i]==0){
			spf[i]=i;
			for(ll j=i*i;j<mx;j+=i){
				if(spf[j]==0){spf[j]=i;prime[j]=1;}
			}
		}
	}
	ll count[mx]={0};
	for(ll i=0;i<n;i++){
		x=__gcd(x,a[i]);
		ll c=a[i];
		while(c>1){
			
			ll z=spf[c];
		//	cout<<i<<" "<<z<<endl;
			while(c%z==0){
			c/=z;}
			count[z]++;
		}
	}
	ll un=0;
	for(ll i=0;i<mx;i++){
		if(count[i]>1)un=1;
	}
	if(un==0){cout<<"pairwise coprime";}
	else if(x==1){ cout<<"setwise coprime";}
	else{cout<<"not coprime";}
}

int main() {
	int t=1;
	//cin>>t;
	for(ll i=0;i<t;i++){
	run();
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 34864
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		int n = 0;
		long []s = new long[100001];
		final long mod = 1000000007;
		s[1] = 1;
		for(int i = 2; i <= 100000; i++){
			s[i] = (s[i-1] % mod * i % mod) % mod;
		}
		Scanner cin = new Scanner(System.in);
		while(cin.hasNext()){
			n = cin.nextInt();
			System.out.println(s[n]);
		}
	}
}


Measured memory_bytes: 21332
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#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 mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



int main() {
  map<string, int> cards;
  int n, m;
  cin >> n;
  rep(i, n) {
    string s;
    cin >> s;
    if(cards.count(s) == 0) {
      cards[s] = 1;
    } else {
      cards[s]++;
    }
  }

  cin >> m;
  rep(i, m) {
    string s;
    cin >> s;
    if(cards.count(s) > 0) {
      cards[s]--;
    }
  }

  int ans = 0;
  for(auto c : cards) {
    ans = max(ans, c.second);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n
h1 .. hn

n 100
hi 100
 */
int n,h[100];

int findn0(){
  REP(i,n){
    if(h[i]!=0) return i;
  }
  return n;
}

int main(){
  cin>>n;
  REP(i,n){
    cin>>h[i];
  }

  int l;
  int ans=0;
  while((l = findn0())<n){
    int r;
    for(r=l; r<n && h[r]!=0; r++);
    FOR_IN(i,l,r){
      h[i]--;
    }
    ans++;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int i,j,n,t,sum=0;
    string s;
    cin >> n;
    cin >>s;
    for(i=0;i<s.size();i++)
    {
        if((s[i])+n>90)
        {
           printf("%c",s[i]+n-26);
        }
        else
        {
            printf("%c",s[i]+n);
        }

    }
    return 0;
}


Measured memory_bytes: 256
#pragma region pre
#include <iostream>
#include <vector>
#include <array>
#include <numeric>
#include <algorithm>
#include <set>
#include <deque>
#include <queue>
#include <stack>

using namespace std;
using ll = long long;
constexpr double INF{ 1e9 };
constexpr int MOD{ 1000000000 + 7 };
#define rep(i,n) for (int i = 0; i < n; ++i)
constexpr array<int, 4> dy{ -1, 1, 0, 0 };
constexpr array<int, 4> dx{ 0, 0, -1, 1 };

//constexpr int div_ru(int a, int b)
//{
//    return (a - b + 1) / b;
//}
//ll pow_mod(ll b, ll e, ll m)
//{ // https://atcoder.jp/contests/atc002/tasks/atc002_b
//    ll r = 1;
//    for (; e > 0; e >>= 1)
//    {
//        if (e & 1)
//            r = (r * b) % m;
//        b = (b * b) % m;
//    }
//    return r;
//}

#pragma endregion

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

    int x, a;
    cin >> x >> a;

    cout << (x >= a ? 10 : 0) << endl;

}
// vector<vector<int>> mm(h, vector<int>(w, -1));


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define per(i,x,y) for (int i=(x); i>=(y); i--)
#define ll long long
#define ull unsigned long long
#define ld long double
#define inf 1000000000
#define INF 1000000000000000000ll
#define pii pair<int,int>
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define sqr(x) ((x)*(x))
#define y1 y1_
#define cmin(x,y) (x)=(y)<(x)?(y):(x)
#define cmax(x,y) (x)=(y)>(x)?(y):(x)
#define mset(x,y) memset((x),(y),sizeof(x))
#define mcpy(x,y) memcpy((x),(y),sizeof(y))
using namespace std;
const ld pi=acos(-1);
const ld eps=1e-8;
//////////////////////// header files ////////////////////////
ll read(){
	char ch=getchar(); ll x=0; int op=1;
	for (; !isdigit(ch); ch=getchar()) if (ch=='-') op=-1;
	for (; isdigit(ch); ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
void write(ll a){
	if (a<0) putchar('-'),a=-a;
	if (a>=10) write(a/10); putchar(a%10+'0');
}
////////////////////////// fast i/o //////////////////////////
#ifdef mod
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x%mod) if (p&1) ret=ret*x%mod;
	return ret;
}
ll getinv(ll x){ return ksm(x,mod-2); }
#else
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x) if (p&1) ret=ret*x;
	return ret;
}
#endif
//////////////////////////// qpow ////////////////////////////
#define N 605
#define base 233
#define mod 20030731
int n,h1[N][N],h2[N][N],pw[N],ans; char a[N][N];
int gethash1(int x,int s,int t){ return (h1[x][t]+mod-(ll)h1[x][s-1]*pw[t-s+1]%mod)%mod; }
int gethash2(int x,int s,int t){ return (h2[x][t]+mod-(ll)h2[x][s-1]*pw[t-s+1]%mod)%mod; }
//#define local
int main(){
#ifdef local
	freopen("test.in","r",stdin); freopen("test.out","w",stdout);
#endif
	n=read();
	rep (i,1,n){
		scanf("%s",a[i]+1);
		rep (j,1,n) a[i+n][j]=a[i][j+n]=a[i+n][j+n]=a[i][j];
	}
	rep (i,1,2*n){
		h1[i][0]=0;
		rep (j,1,2*n) h1[i][j]=((ll)h1[i][j-1]*base+a[i][j])%mod;
	}
	rep (j,1,2*n){
		h2[j][0]=0;
		rep (i,1,2*n) h2[j][i]=((ll)h2[j][i-1]*base+a[i][j])%mod;
	}
	pw[0]=1; rep (i,1,2*n) pw[i]=(ll)pw[i-1]*base%mod;
	rep (i,1,n) rep (j,1,n){
		bool flag=1;
		rep (k,1,n) if (gethash1(i+k-1,j,j+n-1)!=gethash2(j+k-1,i,i+n-1)) flag=0;
		ans+=flag;
	}
	cout<<ans<<endl;
	return 0;
}
// sample data:
/*

*/

// rest:
/*

*/

Measured memory_bytes: 3584
n = int(input())
nlist = list(map(int, input().split()))
def len1(nlist):
    cnt = 0
    c = 0
    for i in nlist:
        if i == 1:
            c += 1
        else:
            c = 0
        cnt = max(cnt, c)
    return cnt+1
print(len1(nlist))
        


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;

    if (A1 + A2 + A3 >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}

Measured memory_bytes: 764
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    s, t = LS()
    print("".join(t+s))
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39024
n,w_lim = map(int,input().split())
dp = [[0 for i in range(w_lim+1)] for i in range(n+1)]

w,v = [],[]
for i in range(n):
    ww,vv = map(int,input().split())
    w.append(ww)
    v.append(vv)

#初期条件
for ww in range(w_lim+1): dp[0][ww] = v[0] if ww>=w[0] else 0

#漸化式
for i in range(n-1):
    for ww in range(w_lim+1):
        dp[i+1][ww] = dp[i][ww] if w[i+1]>ww else max(dp[i][ww], dp[i][ww-w[i+1]]+v[i+1])

ans = dp[n-1][w_lim]
print(ans)


Measured memory_bytes: 171272
a, v = list(map(int,input().strip().split()))
b, w = list(map(int,input().strip().split()))
t = int(input())
ansa = a + v * t
ansb = b + w * t
ansa2 = a - v * t
ansb2 = b - w * t
if a < b:
    if ansb <= ansa:
        print("YES")
    else:
        print("NO")
else:
    if ansa2 <= ansb2:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 9196
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int month[]={31,28,31,30,31,30,31,31,30,31,30,31};

int main() {
	int y1,m1,d1,y2,m2,d2;
	while(cin>>y1>>m1>>d1>>y2>>m2>>d2,y1>=0&&m1>=0&&d1>=0&&y2>=0&&m2>=0&&d2>=0){
		int day1,day2;
		int i;
		day1=(y1-1)*365+(y1-1)/4-(y1-1)/100+(y1-1)/400+d1;
		for(i=0;i<m1-1;i++){
			day1+=month[i];
			if(i==1&&y1%4==0&&(y1%100!=0||y1%400==0))day1+=1;
		}
		day2=(y2-1)*365+(y2-1)/4-(y2-1)/100+(y2-1)/400+d2;
		for(i=0;i<m2-1;i++){
			day2+=month[i];
			if(i==1&&y2%4==0&&(y2%100!=0||y2%400==0))day2+=1;
		}
		cout<<day2-day1<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<vector<ll>> A(2, vector<ll>(N));
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A[i][j];
    }
  }
  queue<pair<ll, pair<ll, ll>>> q;
  q.push({0, {0, 0}});
  ll ans = 0;
  while (!q.empty()) {
    ll x = q.front().second.first;
    ll y = q.front().second.second;
    ll score = q.front().first + A[x][y];
    // cout << x << "," << y << "," << score << endl;
    q.pop();
    if (x == 1 && y == N - 1) {
      ans = max(ans, score);
      continue;
    }
    if (x + 1 < 2) q.push({score, {x + 1, y}});
    if (y + 1 < N) q.push({score, {x, y + 1}});
  }
  cout << ans << endl;
  return 0;
}

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

int compare(const void *a,const void *b){
    if(*(int *)a>*(int *)b)return 1;
    return -1;
}
int main()
{   int a,b,x,y,n,m,k,c;
    scanf("%d%d",&x,&a);
    if(x<a)
    printf("0");
    else 
    printf("10");

    return 0;
}


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

using namespace std;

#define REP(i,m) for(ll i=0; i<m; i++)
#define FOR(i,n,m) for(ll i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define pb push_back
#define ll long long int
#define P pair<ll, ll>
 
int main(){
  int n, m;
  cin >> n >> m;
  vector<int> c[100010];
  int p[m], y[m];
  REP(i, m){
    cin >> p[i] >> y[i];
    c[p[i]].pb(y[i]);
  }
  REP(i, n+1) if(c[i].size() != 0) sort(ALL(c[i]));
  map<int, int> mp;
  REP(i, n+1) REP(j, c[i].size()) mp[c[i][j]] = j+1;
  REP(i, m){
    string s = to_string(p[i]);
    while(s.size()!=6) s = "0"+s;
    string t = to_string(mp[y[i]]);
    while(t.size()!=6) t = "0"+t;
    cout << s << t << endl;
  }
	return 0;
}



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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[]={1,2,4,8,16,32,64};

	cin>>n;

	f(i,0,6)
	{
	    if(ara[i]>n){
            cout<<ara[i-1]<<endl,exit(0);
	    }
	    else if(ara[i]==n){
            cout<<ara[i]<<endl,exit(0);
	    }
	}

    cout<<ara[6]<<endl;



}


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

int main() {
  string C;
  cin >> C;
  int N=0;
  N = C.size();
  long cs=0;
  long cw=0;
  for (int i=0; i<N; i++) {
    if (C.at(i) == 'W') {
      cs += i;
      cw += 1;
    }
  }
  //cerr << cs << ' ' << cw << endl;
  cout << cs - cw*(cw-1)/2 << endl;
}

Measured memory_bytes: 644
#include<iostream>
using namespace std;
string s;
int a[4];
bool q,w,e,r,ans;
main(){
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='N')a[0]++,q=1;
        if(s[i]=='W')a[1]++,w=1;
        if(s[i]=='S')a[2]++,e=1;
        if(s[i]=='E')a[3]++,r=1;
    }
    int cnt=0;
    for(int i=0;i<4;i++)if(a[i])cnt++;
    if(cnt==2){
        if(q and e)ans=1;
        if(w and r)ans=1;
    }
    cout<<(cnt==4 or ans ? "Yes":"No")<<endl;
}

Measured memory_bytes: 256
//abc137_d.cpp
//Sat Aug 10 20:49:51 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;

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

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

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

	vector<P> pair;
	for (int i=0;i<n;i++){
		ll a,b;
		cin >> a >> b;
		pair.push_back(make_pair(a,b));
	}

	sort(pair.begin(),pair.end(),compare_by_b);

	ll day[m+1];
	fill(day,day+m+1,0);
	ll smallestday = 1;
	ll biggestday = m;
	int flag = 0;
	for (int i=0;i<n;i++){
		if (pair[i].first>biggestday){
			continue;
		}
		for (int j=max(pair[i].first,smallestday);j<=biggestday;j++){
			if (day[j]==0){
				day[j] = pair[i].second;

				if (j==smallestday){
					int smallflag = 1;
					for (int k=smallestday+1;k<=m;k++){
						if (day[k]==0){
							smallestday = k;
							smallflag = 0;
							break;
						}
					}
					if (smallflag){
						flag = 1;
					}
				}

				if (j==biggestday){
					for (int k=biggestday-1;k>=1;k--){
						if (day[k]==0){
							biggestday=k;
							break;
						}
					}
				}
				break;
			}
		}
		if (flag){
			break;
		}
	}

	ll ans = 0;
	for (int i=1;i<=m;i++){
		ans += day[i];
//		cout << day[i] << " ";
	}

	cout << ans << endl;
}

Measured memory_bytes: 2672
n, k = gets.split.map(&:to_i)
s = gets.chomp

lens = s.split('L').map(&:size) + s.split('R').map(&:size)
lens.keep_if{|it| it != 0}

base = lens.map{|it| it - 1}.inject(:+)
puts [n - 1, base + k * 2].min


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

using namespace std;

int main() {
    int a, b;

    cin >> a >> b;

    if (!((a * b) % 2)) {
        // able to divede
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }

    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var n = inputs[0];
        var k = inputs[1];
        var c = inputs[2];
        var s = Console.ReadLine().Select(t => t == 'o').ToArray();
        var workDaysLeft = Enumerable.Repeat(-1, n).ToArray();
        var workDaysRight = Enumerable.Repeat(-2, n).ToArray();

        // 左から貪欲法
        var workCount = 1;
        for(int i = 0; i < n; i++)
        {
            if (s[i])
            {
                workDaysLeft[i] = workCount;
                workCount++;
                i += c;
                if (workCount == k + 1) break;
            }
        }

        // 右から貪欲法
        workCount = k;
        for(int i = n - 1; i >= 0; i--)
        {
            if (s[i])
            {
                workDaysRight[i] = workCount;
                workCount--;
                i -= c;
                if (workCount == 0) break;
            }
        }

        // 必ず働くのは左右の貪欲法で何日目に働くかが同じとき
        var mustWorkDays = Enumerable.Range(1, n).Where(i => workDaysLeft[i-1] == workDaysRight[i-1]).ToArray();

        foreach(var day in mustWorkDays)
        {
            Console.WriteLine(day);
        }
    }
}

Measured memory_bytes: 27996
k = int (input())

def make_divisors(n):
	divisors = []
	for i in range(1, int(n**0.5)+1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n//i)

	# divisors.sort()
	return divisors

a =  make_divisors(k)
a.sort()
mini = 10000000000000
for i in range (len(a)):
	ii = a[i]
	jj = k / a[i]
	wa = ii - 1 + jj - 1
	mini = min(wa, mini)
	if a[i] > k//2:
		break
print (int(mini))

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  int P[N]; rep(i,N) cin >> P[i];
  int Q[N]; rep(i,N) cin >> Q[i];
  vector<int> c; rep(i,N) c.push_back(i+1);
  int p_pos = 0, q_pos = 0;
  int num = 0;
  do {
    num++;
    bool okp = true, okq = true;
    rep(i,N) {
      if (c[i]!=P[i]) okp = false;
      if (c[i]!=Q[i]) okq = false;
    }
    if (okp) p_pos = num;
    if (okq) q_pos = num;
  } while (next_permutation(all(c)));

  cout << abs(p_pos-q_pos) << endl;
  return 0;
}

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

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

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

int main(void) {
    Int r,d,x;

    cin>>r>>d>>x;

    for(int i = 1;i <= 10;i++) {
        cout<<r*x-d<<endl;
        x = r*x-d;
    }

    return 0;
}


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

int main(){
  int N, K; cin >> N >> K;
  vector<long long> V(N);
  for (int i=0; i<N; i++) cin >> V[i];
  long long ans = 0;
  for (int k=K; k>0; k--){
    long long tmpans = 0;
    vector<long long> tmpvec;
    if (k>=N&&k<K) continue;
    else if (k>=N&&k==K){
      for (int i=0; i<N; i++){
        tmpans += V[i];
        tmpvec.push_back(V[i]);
      }
      sort(tmpvec.begin(), tmpvec.end());
      for (int t=0; t<K-N; t++){
        if (t==N) break;
        else if (tmpvec[t] >= 0) break;
        else tmpans -= tmpvec[t];
      }
      ans = max(ans, tmpans);
    } else {
      for (int j=0; j<=k; j++){
        tmpans = 0;
        tmpvec = {};
        for (int i=0; i<j; i++){
          tmpans += V[i];
          tmpvec.push_back(V[i]);
        }
        for (int i=0; i<k-j; i++){
          tmpans += V[N-1-i];
          tmpvec.push_back(V[N-1-i]);
        }
        sort(tmpvec.begin(), tmpvec.end());
        for (int t=0; t<K-k; t++){
          if (t==tmpvec.size()) break;
          else if (tmpvec.empty()) break;
          else if (tmpvec[t] >= 0) break;
          else tmpans -= tmpvec[t];
        }
        ans = max(ans, tmpans);
        // cout << tmpans << endl;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>
#include <numeric>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  long sum = 0;
  long ans = 0;

  for (int i=0; i<n; i++) cin>>s[i];
  sum = accumulate(s.begin(),s.end(), 0L);
  if (sum%10 != 0) ans = sum;

  for (int i=0; i<n; i++) {
    if ((sum-s[i])%10!=0) ans = max(ans,sum-s[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
let cnt = ref 0

let merge a l m r =
  let init_ary n p =
    Array.init (n + 1) (fun i -> if i = n then max_int else a.(p + i))
  in
  let ai = init_ary (m - l) l in
  let aj = init_ary (r - m) m in
  let rec doit i j k =
    if k < r then begin
      incr cnt;
      if ai.(i) <= aj.(j) then (a.(k) <- ai.(i); doit (i + 1) j (k + 1))
      else (a.(k) <- aj.(j); doit i (j + 1) (k + 1))
    end
  in
  doit 0 0 l

let rec merge_sort a l r =
  if (l + 1) < r then begin
    let m = (l + r) / 2 in
    merge_sort a l m;
    merge_sort a m r;
    merge a l m r
  end

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  merge_sort a 0 n;
  Array.iteri (fun i e -> if i <> 0 then print_string " "; print_int e) a;
  print_newline ();
  Printf.printf "%d\n" !cnt

Measured memory_bytes: 19416
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
long long gcd(long long a, long long b) {
    // O(log min(a,b))
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

    int N, X;
    cin >> N >> X;

    vector<int> x(N);
    REP(i, N) { cin >> x.at(i); }

    vector<int> dis(N);
    REP(i, N) { dis[i] = abs(X - x[i]); }

    int ans = dis[0];
    REP(i, N) { ans = gcd(ans, dis[i]); }
    cout << ans << endl;

    return 0;
}


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

#define ll long long

int h,w,x;
char ch[15][1001];
int c[15][1001];
int sum[15];

ll calculate(int mask){
	int cnt=__builtin_popcount(mask)+1;
	int ret=0;
	memset(c,0,sizeof(c));
	memset(sum,0,sizeof(sum));
	int cur=0;
	for (int j=0; j<h; j++){
		for (int k=0; k<w; k++)
			c[cur][k]+=(ch[j][k]-'0');
		if (mask & (1<<j)) cur++;
	}
	for (int i=0; i<cnt; i++)
		for (int j=0; j<w; j++)
			if (c[i][j]>x) return 2e18;
	for (int i=0; i<w; i++){
		bool cut=false;
		for (int j=0; j<cnt; j++){
			if (sum[j]+c[j][i]>x){
				cut=true;
				break;
			}
		}
		if (cut){
			memset(sum,0,sizeof(sum));
			ret++;
		}
		for (int j=0; j<cnt; j++)
			sum[j]+=c[j][i];
	}
	return cnt+ret-1;
}

int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
    
	cin>>h>>w>>x;
	for (int i=0; i<h; i++)
		for (int j=0; j<w; j++)
			cin>>ch[i][j];
	ll ans=2e18;
	for (int mask=0; mask<(1<<h); mask++){
		ans=min(ans,calculate(mask));
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 384
x = int(input())

ans = 1
k = 2
while 2 ** k <= x:
    # print("k =", k)
    i = 1
    while i ** k <= x:
        # print("i =", i)
        r = i ** k
        # print("r =", r)
        ans = max(ans, r)
        i += 1
    k += 1
print(ans)


Measured memory_bytes: 3316
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
using namespace std;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
signed main() {
	int a[3], b[3];
	int cnta = 0, cntb = 0, cntc = 0, cntd = 0;
	rep(i, 3)cin >> a[i] >> b[i];
	rep(i, 3) {
		if (a[i] == 1||b[i]==1)cnta++;
		if (a[i] == 2||b[i]==2)cntb++;
		if (b[i] == 3||a[i]==3)cntc++;
		if (b[i] == 4||a[i]==4)cntd++;
	}
	if (cnta>2||cntb>2||cntc>2||cntd>2)puts("NO");
	else puts("YES");
	getchar(); getchar(); return 0;
}


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

int main() {
    int n;
    int m;
    int l;
 
   cin >> n >> m >> l;
  
  int cat = l-n;
  
  if(n>l){
    
    cout << "NO" << endl;
  }else{
  
   if(cat<=m){
     
     cout << "YES" << endl;
     
   }else{
     cout << "NO" << endl;
   }
    
  }
    
   
  
  
  return 0;
}

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

using namespace std;

const int INF = INT_MAX;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto& v : a)
        cin >> v;
    long long ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            ans += a[i] * a[j];
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin>>N;
  vector<string> vn(N);
  for(int i=0;i<N;i++){
    cin>>vn.at(i);
  }
  cin>>M;
  vector<string> vm(M);
  for(int i=0;i<M;i++){
    cin>>vm.at(i);
  }
  int max=0;
  for(int i=0;i<N;i++){
    int c1=0,c2=0,s=0;
    string x=vn.at(i);
    for(int j=0;j<N;j++){
      if(x==vn.at(j)){
        c1++;
      }
    }
    for(int j=0;j<M;j++){
      if(x==vm.at(j)){
        c2++;
      }
    }
    s=c1-c2;
    if(max<=s){
      max=s;
    }
  }
  cout<<max<<endl;
}

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

int main(){
  int n;
  cin >> n;
  for (int k=0;k<n;k++){
    string x,y;
    cin >> x >> y;
    int p=x.size();
    int q =y.size();
    int l[1001][1001] = {};
    for(int i=1;i<p+1;i++){
      for(int j=1;j<q+1;j++){
	if(x[i-1] == y[j-1] ){
	  l[i][j] = 1+l[i-1][j-1];
	}else{
	  l[i][j]= max(l[i-1][j],l[i][j-1]);
	}
      }
    }
    cout << l[p][q] << endl;
  }
}

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

using namespace std;

int main()
{
    int n,temp,i;
    cin>>n;
    int a[n+1];
    for(i=0;i<n;i++)
    {
        cin>>temp;
        a[i] = temp;
    }
    int dp[n+1];
    dp[0] = 0;
    dp[1] = abs(a[0]-a[1]);
    for(i=2;i<n;i++)
    {
        dp[i] = min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

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

Measured memory_bytes: 1152
N,M=map(int,input().split())
S=[]
for i in range(0,M):
    K=list(map(int,input().split()))
    S.append(K[1:])
P=list(map(int,input().split()))
import itertools as it
ans=0
for i in it.product([0,1], repeat=N):
    ON=True
    for s in S:
        cnt=0
        for j in range(0, len(s)):
            if i[s[j]-1]==1:
                cnt+=1
        if cnt%2!=P[S.index(s)]:
            ON=False
    if ON:
        ans+=1
print(ans)

Measured memory_bytes: 3064
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define mp make_pair

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
    return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
    return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
    int sign = 1;
    T ret = 0;
    char c;

    do{
        c = getc();
    }while(c == ' ' || c == '\n');
    if(c == '-')sign = -1;
    else ret = c-'0';
    while(1){
        c = getc();
        if(c < '0' || c > '9')break;
        ret = 10*ret + c-'0';
    }
    return sign * ret;
}

inline void ini(int& x){
    x = getnum<int>();
}

inline void scani(int& x){
    scanf("%d",&x);
}

//end of macro

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);
    
    int n;
    cin>>n;
    map<int,int>mep;
    REP(i,1,n){
        int x;
        cin>>x;
        mep[x]++;
    }
    int ans = 0;
    for(auto i : mep){
        if(i.S&1)ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 100000000000000000
#define mod 1000000007
#define MAX 100005
#define pb push_back
#define vit vector<int>::iterator
typedef pair<lint,lint> pii;
map<lint,lint>M;
vector<lint> V[MAX];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,x,t;
    cin>>n>>x>>t;
    cout<<((n-1)/x+1)*t;
    return 0;
}


Measured memory_bytes: 5988
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng (chrono::steady_clock::now().time_since_epoch().count() );

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 1e6 + 12; //check the limits, dummy


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

    ll n, k;
    cin >> n >> k;

    vl pref (n + 1);
    FOR (i, 0, n) {
        ll val;
        cin >> val;
        pref[i + 1] = (pref[i] + val) % k;
    }

    map<ll, ll>mp;
    ll j = 0, ans = 0;
    FOR (i, 0, n + 1) {
        if (i - j >= k) {
            mp[ ( (pref[j] - j) % k + k) % k]--;
            j++;
        }
        ans += mp[ ( (pref[i] - i) % k + k) % k];
        mp[ ( (pref[i] - i) % k + k) % k]++;
    }

    cout << ans << '\n';

    return  0;
}


Measured memory_bytes: 14336
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse::<usize>().unwrap();
    let m: usize = iter.next().unwrap().parse::<usize>().unwrap();
    
    let mut utree = Utree::new(n);
    let mut yes = true;
    for _ in 0..m {
        let l: usize = iter.next().unwrap().parse::<usize>().unwrap()-1;
        let r: usize = iter.next().unwrap().parse::<usize>().unwrap()-1;
        let d: i64 = iter.next().unwrap().parse::<i64>().unwrap();
        if utree.is_same(l, r) {
            if utree.get_weight(r) - utree.get_weight(l) != d {
                yes = false;
                break;
            }
        } else {
            utree.unite(l, r, d);
        }
    }

    if yes {println!("Yes");} else {println!("No");}
}

#[allow(dead_code)]
pub struct Utree {
    n: usize,
    par: Vec<usize>,
    rank: Vec<usize>,
    size: Vec<usize>,
    diff_weight: Vec<i64>,
}
#[allow(dead_code)]
impl Utree {
    pub fn new(n: usize) -> Utree {
        Utree {
            n: n,
            par: (0..n).collect(),
            rank: vec![0; n],
            size: vec![1; n],
            diff_weight: vec![0; n],
        }
    }
    pub fn find(&mut self, x: usize) -> usize {
        if self.par[x] == x {
            x
        } else {
            let parent = { self.par[x] };
            let ret = self.find(parent);
            self.diff_weight[x] += self.diff_weight[parent];
            self.par[x] = ret;
            ret
        }
    }
    pub fn get_weight(&mut self, x: usize) -> i64 {
        self.find(x);
        self.diff_weight[x]
    }
    pub fn get_size(&mut self, mut x: usize) -> usize {
        x = self.find(x);
        self.size[x]
    }
    pub fn is_same(&mut self, mut x: usize, mut y: usize) -> bool {
        x = self.find(x);
        y = self.find(y);
        x == y
    }
    #[doc = " x:from, y:to"]
    pub fn unite(&mut self, mut x: usize, mut y: usize, mut w: i64) {
        w += self.get_weight(x);
        w -= self.get_weight(y);
        x = self.find(x);
        y = self.find(y);
        if x == y {
            return;
        };
        if self.rank[x] < self.rank[y] {
            std::mem::swap(&mut x, &mut y);
            w = -w;
        }
        if self.rank[x] == self.rank[y] {
            self.rank[x] += 1;
        }
        self.par[y] = x;
        self.diff_weight[y] = w;
        self.size[x] += self.size[y];
    }
}

Measured memory_bytes: 12280
import numpy as np


def main():
    a, b, h, m = map(int, input().split())
    short_needle = np.array([a*np.cos(np.radians(-h*30-30*((m*6)/360)+90)), a*np.sin(np.radians(-h*30-30*((m*6)/360)+90))])
    long_needle = np.array([b*np.cos(np.radians(-m*6+90)), b*np.sin(np.radians(-m*6+90))])
    ans = np.linalg.norm(short_needle - long_needle)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 27232