akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<ll>>;
#define MAX 1000000007

int main()
{
    ll n;ll x,m;
    cin >> n >> x >> m;
    ll ans=0;
    ll loop_st;
    int loop_before=0;
    int loop_num=0;
    int loop_after=0;
    ll loop_vol=0;
    vector<bool> visit(m+1,false);
    if(n<m){
        rep(i,n){
            ans+=x;
            x*=x;
            x%=m;
        }
        cout << ans;
        return 0;
    }
    rep(i,m){
        if(visit[x]==false){
            ans+=x;
            visit[x]=true;
            x*=x;
            x%=m;
            loop_before++;
        }else if(x==0){
            cout << ans << endl;
            return 0;
        }else{
            loop_st=x;
            break;
        }
    }
    while(loop_num==0||x!=loop_st){
        loop_vol+=x;
        x*=x;
        x%=m;
        loop_num++;
    }
    ans+=loop_vol*((n-loop_before)/loop_num);
    loop_after=(n-loop_before)%loop_num;
    rep(i,loop_after){
        ans+=x;
        x*=x;
        x%=m;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3668
import java.util.*;
import java.io.*;
public class Main{
public static void main(String[] args) throws FileNotFoundException, IOException{
       Scanner s=new Scanner(System.in);
       StringBuilder sb=new StringBuilder();
       BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
       int n=s.nextInt();
        int[][] cij=new int[10][10];
        for(int i=1;i<=n;i++){
        	sb.append(i);
        	cij[sb.charAt(0)-'0'][sb.charAt(sb.length()-1)-'0']++;
        	sb=new StringBuilder();
        }
        long res=0;
        for(int i=0;i<=9;i++){
        	for(int j=0;j<=9;j++){
        		res+=(long)cij[i][j]*cij[j][i];
        	}
        }
       out.write(res+"");
        out.flush();
  }
}


Measured memory_bytes: 37792
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w;cin>>h>>w;
    vector<string> s(h);
    rep(i,h){
        cin>>s[i];
    }
    vector<vector<bool>> chk(h,vector<bool>(w,false));
    function<ll(ll,ll)> check = [&](ll x, ll y){
        map<char,ll> mp;
        mp[s[x][y]]++;
        queue<pair<ll,ll>> que;
        que.push(make_pair(x,y));
        while(!que.empty()){
            ll xx = que.front().first,yy = que.front().second;
            que.pop();
            for(ll i=-1;i<=1;i+=2){
                if(xx+i>=0&&xx+i<h&&s[xx][yy]!=s[xx+i][yy]&&!chk[xx+i][yy]) {
                    que.push(make_pair(xx+i,yy));
                    chk[xx+i][yy]=true;
                    mp[s[xx+i][yy]]++;
                }
                if(yy+i>=0&&yy+i<w&&s[xx][yy]!=s[xx][yy+i]&&!chk[xx][yy+i]) {
                    que.push(make_pair(xx,yy+i));
                    chk[xx][yy+i]=true;
                    mp[s[xx][yy+i]]++;
                }
            }
        }
        return mp['.']*mp['#'];
    };
    ll res = 0;
    rep(i,h){
        rep(j,w){
            if(!chk[i][j]){
                chk[i][j]=true;
                res += check(i,j);
            }
        }
    }
    cout << res << endl;
    return 0;
}


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

int main(){
  map<int,int> mp;
  ll ans=0;
  int n;cin>>n;
  REP(i,n){
    int tmp;cin>>tmp;
    mp[tmp]++;
    ans+=(ll)tmp;
  }
  
  int q;cin>>q;
  REP(i,q){
  	int b,c;cin>>b>>c;
    if(mp[b]>0){
      ans+=(ll)((ll)(c-b)*(ll)(mp[b]));
      mp[c]+=mp[b];
      mp[b]=0;
    }
    cout<<ans<<endl;
  }
}

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

void trace(int a[],int n){
    for(int i=0; i<n; i++){
        if(i>0)cout << " ";
        cout << a[i];
    }
    cout << endl;
    return;
}

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++)cin >> a[i];
    bool flag = 1;
    int sw=0;
    for(int i=0; flag; i++){
        flag = 0;
        for(int j=n-1; j>i; j--){
            flag = 1;
            if(a[j] < a[j-1]){
                swap(a[j], a[j-1]);
                sw++;
            }
        }
    }
    trace(a, n);
    cout << sw << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
  int n, cons = 0, ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    int x;
    scanf("%d", &x);
    if (x == i)
      cons++;
    else
      ans += (cons + 1) / 2, cons = 0;
  }
  printf("%d\n", ans + (cons + 1) / 2);

  return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
//#define INF 1100000000000000000LL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=2050;
//ここまでテンプレ
int main() {
	int N;
	cin>>N;
	char S[10];
	sprintf(S,"%d",N);
	int sum=0;
	string T=S;
	for(int i=0;i<T.length();i++){
		sum+=T[i]-'0';
	}
	if(N%sum)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a, b, ans = 0;
    char op;
    while (1) {
        scanf("%d %c %d", &a, &op, &b);
        switch (op) {
            case '+':
                ans = a + b;
                break;
            case '-':
                ans = a - b;
                break;
            case '*':
                ans = a * b;
                break;
            case '/':
                ans = a / b;
                break;
            default:
                break;
        }
        if(op == '?') break;
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 600
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
const ll MOD=1000000007LL;
ll sichigo(int MAX,int n,int k,string s,bool seven,bool five,bool three){
  if(seven)seven=true;
  if(five)five=true;
  if(three)three=true;
  if(k==n){
    if(seven && five && three && stoll(s)<=MAX)return 1;
    else return 0;
  }
  ll res=sichigo(MAX,n,k+1,s+'3',seven,five,true)+sichigo(MAX,n,k+1,s+'5',seven,true,three)+sichigo(MAX,n,k+1,s+'7',true,five,three);
  if(seven && five && three && s!="" &&stoll(s)<=MAX)res++;
  return res;
}
int main(){
  ll MAX;
  cin>>MAX;
  string s=to_string(MAX);
  int n=s.size();
  cout<<sichigo(MAX,n,0,"",false,false,false)<<endl;
}
  
  

Measured memory_bytes: 256
import java.util.*; 
 
class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
		String k=sc.next();
        String l=sc.next();
  		String m=l.substring(0,l.length()-1);
    
 	if(k.equals(m)){
    		System.out.println("Yes");
    	}else{
     		System.out.println("No");
   	 }
 
    }
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  int N;
  cin>>N;
  vector<ll> v(N);
  for(int i = 0; i < N; i++) cin>>v[i];
  sort(v.begin(),v.end());
  ll ans = 1LL;
  bool over = false;
  for(int i = 0; i < N; i++){
    if(v[i]==0) {
      ans = 0LL;
      break;
    }
    if(ans>1000000000000000000LL/v[i]) {
      over = true;
      break;
    }
    ans*=v[i];
  }
  if(!over) cout<<ans<<endl;
  else cout<<-1<<endl;
}

Measured memory_bytes: 4052
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class Main {
	public static void main(String[] args) {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
				PrintWriter pw = new PrintWriter(System.out);) {
			String[] AB = br.readLine().split(" ");
			int A = Integer.parseInt(AB[0]);
			int B = Integer.parseInt(AB[1]);
			String[] S = br.readLine().split("-");
			if (S.length == AB.length && A - B == S[0].length() - S[1].length()) {
				pw.println("Yes");
			} else {
				pw.println("No");
			}
			pw.flush();
		} catch (Exception e) {
		}
	}
}

Measured memory_bytes: 22868
// #pragma GCC optimize("O3")
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace ::std;
// clang-format off
template<typename T> T nxt() {T res; cin >> res; return res;}
#define tests() for (int _ = nxt<int>(); _ >= 0; _--)
#define nxt1(t,n) t (n); cin >> n
#define nxt2(t,n,m) t (n),(m); cin >> n >> m
#define nxt3(t,n,m,k) t (n),(m),(k); cin >> n >> m >> k
#define rep(i, A) for (int i = 0 ; i < A ; i++)
#define ll long long
typedef pair<int,int> pii;typedef pair<ll, ll> pll;typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<ll> vl;typedef vector<vl> vvl;
#define dbg(vari) cerr<<#vari<<" = "<<(vari)<<endl;
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
template<typename T> ostream& operator<<(ostream &s,vector<T> t){for(T ti : t)s<<ti<<" ";return s; }
#define all(x) (x).begin(), (x).end()
#define last(vec) vec[vec.size()-1]
#define has(c,x) ((c).find(x) != (c).end())
// clang-format on

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

    nxt2(int, N, K);
    vi h(N);
    generate(all(h), nxt<int>);

    vi dp(N);
    for (int i = 1; i < N; i++) {
        dp[i] = INT_MAX;
        for (int j = max(0, i - K); j < i; j++) {
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }

    cout << dp[N - 1] << endl;

    return 0;
}


Measured memory_bytes: 3976
import java.util.*;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] p = new int[N + 1];
        int[] x = new int[M];
        int[] y = new int[M];

        for(int i=1; i<=N; i++){
            p[i] = sc.nextInt();
        }

        for(int i=0; i<M; i++){
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }
        sc.close();
        UnionFind uf = new UnionFind(N + 1);
        for(int i=0; i<M; i++){
            uf.union(x[i], y[i]);
        }
        int ans = 0;
        for(int i=1; i<=N; i++){
            if(uf.same(i, p[i])){
                ans += 1;
            }
        }
        System.out.println(ans);
    }
}

class UnionFind{
    int[] par;
    int[] rank;

    public UnionFind(int N){
        par = new int[N];
        rank = new int[N];
        for(int i=1; i<N; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }

    public void union(int x, int y){
        int xroot = find(x);
        int yroot = find(y);
        if(rank[xroot]>rank[yroot]){
            par[yroot] = xroot;
        }
        else if(rank[xroot]<rank[yroot]){
            par[xroot] = yroot;
        }
        else if(xroot!=yroot){
            par[yroot] = xroot;
        }
    }

    public int find(int x){
        if(x==par[x]){
            return x;
        }
        return par[x] = find(par[x]);
    }
    public boolean same(int x, int y){
        return find(x)==find(y);
    }
}

Measured memory_bytes: 91824
#include<bits/stdc++.h>
using namespace std;
#define MAX_V 25
#define INF 1<<21

int d[MAX_V][MAX_V];	//d[u][v]テ」ツ?ッティツセツコe=(u,v)テ」ツ?ョテ」ツつウテ」ツつケテ」ツδ?テ・ツュツ佚・ツ慊ィテ」ツ?療」ツ?ェテ」ツ??・ツ?エテ・ツ青暗」ツ?ッINFテ」ツ??」ツ?淌」ツ??」ツ?妖[i][i]=0テ」ツ?ィテ」ツ?凖」ツつ?
int n, m;	//テゥツ?づァツつケテヲツ閉ー

void warshall_floyd(){
	for(int k = 0; k < n; k++){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}




int main(){
	for(int i = 0; i < MAX_V; i++){
		for(int j = 0; j < MAX_V; j++){
			d[i][j] = INF;
		}
	}


	cin >> n >> m;
	char c;
	for(int i = 0; i < m; i++){
		int a1, b1, c1, d1;
		cin >> a1 >> c >> b1 >> c >> c1 >> c >> d1;
		d[a1-1][b1-1] = c1;
		d[b1-1][a1-1]	= d1;	
	}
	int x1, x2, y1, y2;
	cin >> x1 >> c >> x2 >> c >> y1 >> c >> y2;
	
	warshall_floyd();
	cout << y1 - y2 - d[x1-1][x2-1] - d[x2-1][x1-1] << endl;
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i <= k; i++)
#define SZ 110000
#define PB push_back
#define MEM(n, val) memset((n), val, sizeof(n))
#define INF 1000000000
#define F first
#define S second
#define MP make_pair
#define LL long long

int a, b, c, k;
LL ara_a[1010], ara_b[1010], ara_c[1010];

class Data  {
public:
    int apos, bpos;
    LL val;
    Data()  {}
    Data(int tapos, int tbpos, LL tval)  {
        apos = tapos;
        bpos = tbpos;
        val = tval;
    }
};

class Cmp   {
public:
    bool operator()(Data x, Data y)   {
        return x.val < y.val;
    }
};

int main()  {
//    freopen("in.txt", "r", stdin);
    cin >> a >> b >> c >> k;
    FOR(i, 0, a - 1)   {
        cin >> ara_a[i];
    }
    FOR(i, 0, b - 1)   {
        cin >> ara_b[i];
    }
    FOR(i, 0, c - 1)   {
        cin >> ara_c[i];
    }

    vector<LL> vv;

    FOR(i, 0, a - 1)   {
        FOR(j, 0, b - 1)   {
            vv.PB(ara_b[i] + ara_c[j]);
        }
    }
    sort(vv.begin(), vv.end(), greater<LL>());
    sort(ara_a, ara_a + a, greater<LL>());

//    FOR(i, 0, a - 1)   {
//        cout << ara_a[i] << " ";
//    }
//    cout << "\n";
//
//    FOR(i, 0, (int)vv.size() - 1)   {
//        cout << vv[i] << " ";
//    }
//    cout << "\n";

    priority_queue<Data, vector<Data>, Cmp> pq;
    pq.push(Data(0, 0, ara_a[0] + vv[0]));

    while(k) {
        k--;
        Data top = pq.top();
        cout << top.val << "\n";
        pq.pop();
        if(top.apos == top.bpos)    {
            if((top.apos + 1 < a) && (top.bpos + 1 < vv.size()))    {
                pq.push(Data(top.apos + 1, top.bpos + 1, ara_a[top.apos + 1] + vv[top.bpos + 1]));
            }
            if((top.apos + 1 < a) && (top.bpos < vv.size()))    {
                pq.push(Data(top.apos + 1, top.bpos, ara_a[top.apos + 1] + vv[top.bpos]));
            }
            if((top.apos < a) && (top.bpos + 1 < vv.size()))    {
                pq.push(Data(top.apos, top.bpos + 1, ara_a[top.apos] + vv[top.bpos + 1]));
            }
        }
        else if(top.apos < top.bpos)    {
            if((top.apos < a) && (top.bpos + 1 < vv.size()))    {
                pq.push(Data(top.apos, top.bpos + 1, ara_a[top.apos] + vv[top.bpos + 1]));
            }
        }
        else    {
            if((top.apos + 1 < a) && (top.bpos < vv.size()))    {
                pq.push(Data(top.apos + 1, top.bpos, ara_a[top.apos + 1] + vv[top.bpos]));
            }
        }
    }

    return 0;
}
/**
*/


Measured memory_bytes: 10604
#include<bits/stdc++.h>
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
#define mem(x,y) memset(x,y,sizeof(x))  
#define lli long long int
#define ll long long 
#define ld long double
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define LB lower_bound
#define UB upper_bound
#define BS binary_search
#define pii pair<lli,lli>
const long long int mod=1000000009;
//const long long int mod=998244353;
const long double PI=3.141592653589793;
const long long int inf=1e18;
const long long int inf2=LLONG_MAX;
#define setBitCount(x) __builtin_popcountll(x)
#define all(a) (a).begin(), (a).end()
#define all_r(a) (a).rbegin(), (a).rend()
lli gcd(lli a,lli b)
{
    if(b==0)
    return a;
    else
    return gcd(b,a%b);
}
// calculating (x^y)%p
lli power(lli x,lli y,lli p)
{
    lli res = 1;      
    x = x % p;  
    while (y > 0)
    {
        if (y & 1) //y is odd  
        res = (res*x) % p;
        y = y>>1; 
        x = ( (x%p)*(x%p) )% p;  
    }
    return res%p;
}
// calculating modular inverse using fermat little theorem
lli modInverse(lli n,lli p) 
{
    return power(n, p-2, p)%p;
}

// policy based data structures !!
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
// s.order_of_key (k) : Number of items strictly smaller than k
// *(s.find_by_order(k)) : K-th element in a set (counting from zero)

void solve()
{
   lli n;
   cin>>n;
   lli limit;
   cin>>limit;
   
   lli w[n+5],p[n+5];
   for(lli i=1;i<=n;i++)
   cin>>w[i]>>p[i];
   
   lli dp[n+5][limit+5];
   mem(dp,0);
   for(lli i=1;i<=n;i++)
   {
      for(lli j=1;j<=limit;j++)
      {
         dp[i][j]=dp[i-1][j];
         if(j>=w[i])
         dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+p[i]);
      }
   }
   cout<<dp[n][limit];
}
int main()
{
   
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    lli T;
    //cin>>T;
    T=1;
    while(T--)
    {
        solve();
    }




    return 0;
}

Measured memory_bytes: 82304
#include <iostream>
using namespace std;
long long x, y;

int main(){
    cin >> x >> y;
    if(x % y == 0){
        cout << "-1\n";
        return 0;
    }
    else{
        for(int i = 2; i <= 100; i++){
            if(x*i % y != 0){
                cout << x*i << '\n';
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
while True:
    n = int(input())
    if not n:
        break

    poles = [tuple(map(int, input().split())) for _ in range(n)]
    poles_set = set(poles)

    max_square = 0
    for i in range(n):
        x1, y1 = poles[i]
        for j in range(i, n):
            x2, y2 = poles[j]
            dx, dy = x2 - x1, y2 - y1
            if ((x2 + dy, y2 - dx) in poles_set and (x1 + dy, y1 - dx) in poles_set) \
                    or ((x2 - dy, y2 + dx) in poles_set and (x1 - dy, y1 + dx) in poles_set):
                edge = dx ** 2 + dy ** 2
                if max_square < edge:
                    max_square = edge
    print(max_square)

Measured memory_bytes: 8812
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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            String S = in.next();

            if (S.charAt(a) != '-') {
                out.println("No");
                return;
            }

            for (int i = 0; i <= a - 1; i++) {
                if ('0' > S.charAt(i) || S.charAt(i) > '9') {
                    out.println("No");
                    return;
                }
            }

            for (int i = a + 1; i <= a + b; i++) {
                if ('0' > S.charAt(i) || S.charAt(i) > '9') {
                    out.println("No");
                    return;
                }
            }
            out.println("Yes");
        }

    }
}



Measured memory_bytes: 23124
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;

#define NIL -1
#define N_MAX 100000
#define M_MAX 100000

struct Node{
    int value;
    int parent;
};

struct Node node[N_MAX];

void init(int n){
    for(int i = 0; i <= n; i++){
        node[i].value = i;
        node[i].parent = NIL;
    }
}

int find(int x){
    struct Node target_node = node[x];
    vector<int> v;
    while(target_node.parent != NIL){
        v.push_back(target_node.value);
        target_node = node[target_node.parent];
    }

    for(int i = 0; i < v.size(); i++){
        node[v[i]].parent = target_node.value;
    }

    return target_node.value;
}

void unite(int x, int y){
    if(find(x) != find(y)){
        node[find(x)].parent = y;
    }
}

bool same(int x, int y){
    if(find(x) == find(y)){
        return true;
    }else{
        return false;
    }
}


int main(void){
    int N, M;
    int p[N_MAX];

    scanf("%d", &N);
    scanf("%d", &M);

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

    init(N);

    for(int i = 0; i < M; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        unite(x, y);
    }

    int count = 0;
    for(int i = 0; i < N; i++){
        if(same(i + 1, p[i])){
            count += 1;
        }
    }

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

}


Measured memory_bytes: 1408
N=int(input())
a=0
b=0
c=0
a_list=[]
b_list=[]
c_list=[]
for i in range(N):
    a,b,c=map(int,input().split())
    a_list.append(a)
    b_list.append(b)
    c_list.append(c)
for i in range(1,N):
    a_list[i]=a_list[i]+max(b_list[i-1],c_list[i-1])
    b_list[i]=b_list[i]+max(a_list[i-1],c_list[i-1])
    c_list[i]=c_list[i]+max(a_list[i-1],b_list[i-1])
print(max(a_list[-1],b_list[-1],c_list[-1]))

Measured memory_bytes: 90960
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum = 0



for i in range(N):
    x = A[i]-B[i]
    if x>=0:
        sum = sum + B[i]
    else:
        sum = sum + A[i]
        B[i] = B[i]-A[i]
        x = A[i+1]-B[i]
        if x>=0:
            sum = sum + B[i]
            A[i+1]=A[i+1]-B[i]
        else:
            sum = sum + A[i+1]
            A[i+1]=0

print(sum)

Measured memory_bytes: 18624
N,K=map(int,input().split())
B=[]
for n in range(N):
    B.append(n+1)
for i in range(K):
    d=int(input())
    A=list(map(int,input().split()))
    for n in A:
        if n in B:
            B.remove(n)  
print(len(B))

Measured memory_bytes: 9120
n,m=map(int,input().split())
*x,=map(int,input().split())
*y,=map(int,input().split())
mod=10**9+7

w,h=0,0
for i in range(n):
    w+=(2*i+1-n)*x[i]
for i in range(m):
    h+=(2*i+1-m)*y[i]
print(w*h%mod)

Measured memory_bytes: 86944
S = list(map(int, input()))
pre =  S[0] * 10 + S[1]
suf =  S[2] * 10 + S[3]
S2 = [pre, suf]
ans = ''

def YorM (x):
    if x == 0:
        return 'YY'
    elif x >= 1 and x <= 12:
        return 'AMB'
    else:
        return 'YY'

S3 = [YorM(i) for i in S2]

if S3[0] == 'YY':
    if S3[1] == 'AMB':
        ans = 'YYMM'
    else:
        ans = 'NA'
if S3[0] == 'AMB':
    if S3[1] == 'YY':
        ans = 'MMYY'
    else:
        ans = 'AMBIGUOUS'

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
long long mod = 1e9+7;
long long f(int n, vector<int> x){
    long long res = 0;
    for(int i=0;i<n;i++){
        res += (mod + i*2-n+1) % mod * (mod + x[i]) % mod;
        res %= mod;
    }
    return res;
}
int main(void){
    int n, m;
    cin >> n >> m;
    vector<int> x(n, 0), y(m, 0);
    for(int i=0;i<n;i++) cin >> x[i];
    for(int i=0;i<m;i++) cin >> y[i];
    cout << f(n, x) * f(m, y) % mod << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdio>
#include <list>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}

int main(){
    int n=in(),ans=0;
    vec a(n),b(n);
    rep(i,n)a[i]=in();
    rep(i,n)b[i]=in();
    rep(i,n)ans+=max(0,a[i]-b[i]);
    cout<<ans<<endl;
}

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

public class Program
{
    private int N, K;
    private int R, S, P;
    private char[] T;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        K = sc.NextInt();
        R = sc.NextInt();
        S = sc.NextInt();
        P = sc.NextInt();
        T = sc.Next().ToCharArray();

        // t[i] = t[i-k]なら 

        long ans = 0;
        
        bool[] f = new bool[N];

        for (int i = 0; i < N; i++)
        {
            char c = T[i];
            if (i - K >= 0 && c == T[i - K] && !f[i - K])
            {
                f[i] = true;
                continue;
            }

            switch (c)
            {
                case 'r':
                    ans += P;
                    break;
                case 's':
                    ans += R;
                    break;
                case 'p':
                    ans += S;
                    break;
            }
        }
        
        Console.WriteLine(ans);
    }


    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 14048
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long int a,b;
	cin>>a>>b;
	int x=a,y=b;
	
	while(x!=y)
	if(x>y)
	x=x-y;
	else y=y-x;
	
	cout<<a*b/x<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int g[201][201];
int main(){
	ios::sync_with_stdio(0);
	int k;
	cin>>k;
	rep(i,k)
	rep(j,k){
		g[i][j]=__gcd(i+1,j+1);
	}
	ll ans=0;
	rep(i,k)
	rep(j,k)
	rep(k1,k){
		ans+=g[g[i][j]-1][k1];
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 3808
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
#include <random>
#include <future>
#include <thread>
#include <utility>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
#define int long long


//booooooooooooost
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)



LL inv_mod(LL a, LL m)
{
	LL b, x, u, q, tmp;

	b = m; x = 1; u = 0;
	while (b > 0) {
		q = a / b;
		tmp = u; u = x - q * u; x = tmp;
		tmp = b; b = a - q * b; a = tmp;
	}

	return (x < 0) ? m + x : x;
}


signed main() {

	int N;
	vector<int> s;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		int tmp;
		cin >> tmp;
		s.push_back(tmp);
	}

	bool ans[10001];
	for (int i = 0; i < 10001; ++i) {
		ans[i] = false;
	}
	ans[0] = true;

	for (int i = 0; i < N; ++i) {
		for (int j = 10000; 0 <= j; --j) {
			if (ans[j] && j + s[i] < 10001) {
				ans[j + s[i]] = true;
			}
		}
	}

	int r = 0;
	for (int i = 0; i < 10001; ++i) {
		if (ans[i] && i % 10 != 0) {
			r = i;
		}
	}

	cout << r << endl;



	return 0;
}

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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

int N, K;
string S;

inline void Main() {
  // code
  cin >> N >> K >> S;
  int x = 0;
  rep(i, N-1) {
    if(S.at(i) == S.at(i+1)) x++;
  }
  cout << min(N-1, x+2*K) << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   long N = sc.nextLong();
   long ans = 1;
   for(int i=1;i<=N;i++) 
   {
     ans *= i;
     ans = ans%1000000007;
   }
   System.out.println(ans);
 }
}

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

a = list(map(int, input().split()))

s = [0] * (n + 1)

for i in range(n):
    s[i + 1] = s[i] + a[i]

table = {}

for i in range(n + 1):
    if s[i] in table:
        table[s[i]] += 1
    else:
        table[s[i]] = 1

ans = 0
for key, val in table.items():
    if val >= 2:
        ans += val * (val - 1) // 2

print(ans)


Measured memory_bytes: 41400
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T>using vv = vector<vector<T>>; template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    ll N, X;
    cin >> N >> X;

    ll sum = N;

    ll Y = N - X;
    while (1) {
        if (Y % X == 0) {
            sum += 2 * Y - X;
            break;
        }
        else {
            sum += Y / X * X * 2;
            ll nextY = X;
            X = Y % X;
            Y = nextY;
        }
    }

    cout << sum << endl;
}

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

int main(void){
    vector<int> v;
    int n;
    while(cin>>n){
        if(n==0){
            cout<<v.back()<<endl;
            v.pop_back();
        }
        else{
            v.push_back(n);
        }
    }
    return 0;
}



Measured memory_bytes: 2996
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>
#include <deque>

using namespace std;


int main(void)
{
	int n;
	int i;
	int size;
	int cnth, cntm;
	int cnt = 0;
	char s[120];
	deque <char> d;

	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> s[i];
		d.push_back(s[i]);
	}

	for (i = 0; i < n; i++) {
		if (s[i] == '(') {
			cnt++;
		}
		else {
			cnt--;
			if (cnt < 0) {
				cnt = 0;
				d.push_front('(');
			}
		}
	}

	for (i = 0; i < cnt; i++) {
		d.push_back(')');
	}
	size = d.size();

	for (i = 0; i < size; i++) {
		cout << d.front();
		d.pop_front();

	}
	cout << endl;

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main ()
{
	int arr[3],a,b;
	scanf("%d %d",&a,&b);
	arr[0]=a+b;
	arr[1]=a-b;
	arr[2]=a*b;
	sort(arr,arr+3);
	cout<<arr[2];
	return 0;
}

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

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

    string s;
    cin >> s;

    if(s=="ABC") puts("ARC");
    else puts("ABC");

    return 0;
}

Measured memory_bytes: 3612
import itertools,sys
def f(a):
 if len(a)<2:yield[a[0]]*2
 for i in range(1,len(a)):
  for p,s in f(a[:i]):
   for q,t in f(a[i:]):
    yield(p+q,f'({s} + {t})')
    yield(p-q,f'({s} - {t})')
    yield(p*q,f'({s} * {t})')
def s(a):
 for p in itertools.permutations(a):
  for n,s in f(p):
   if n==10:print(s);return 1
for e in iter(input,'0 0 0 0'):
 a=list(map(int,e.split()))
 if not s(a):print(0)


Measured memory_bytes: 5652
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int H=gi();
	    int W=gi();
	    int[][] A=new int[H][W];
	    List<Integer> y=new ArrayList<Integer>();
	    List<Integer> x=new ArrayList<Integer>();
	    List<Integer> yd=new ArrayList<Integer>();
	    List<Integer> xd=new ArrayList<Integer>();
	    
	    for (int i=0;i<H;i++) {
	    	for (int j=0;j<W;j++) {
		    	A[i][j]=gi();
		    }
	    }
	    
	    for (int i=0;i<H;i++) {
	    	for (int j=0;j<W;j++) {
		    	int m=A[i][j];
		    	if(m%2!=0) {
		    		if(i<H-1) {
		    			A[i+1][j]++;
		    			y.add(i+1);
		    			x.add(j+1);
		    			yd.add(i+2);
		    			xd.add(j+1);
		    		} else if(j<W-1) {
		    			A[i][j+1]++;
		    			y.add(i+1);
		    			x.add(j+1);
		    			yd.add(i+1);
		    			xd.add(j+2);
		    		}
		    	}
		    }
	    }

	    StringBuilder sb=new StringBuilder();
	    sb.append(y.size());
	    sb.append(System.lineSeparator());
	    for(int i=0; i<y.size();i++) {
	    	sb.append(y.get(i) + " " + x.get(i) + " " + yd.get(i) + " " + xd.get(i) + System.lineSeparator());
	    }
	    System.out.print(sb);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

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

	int N,tmp;
	scanf("%d",&N);
	// printf("N = %d \n",N);

	vector<vector<int>> A(2,vector<int>(N));

	for(int i = 0;i < 2;i++){
		for(int j = 0;j < N;j++){
			scanf("%d",&A[i][j]);
			// printf("%d ", A[i][j]);
		}
		// printf("\n");
	}

	int num = accumulate(A[0].begin(),A[0].end(),0);
	num += A[1][N-1];
	int num_max = num;
	// cout << num;
	for(int i = N-1; i > 0; --i){
		num = num - A[0][i] + A[1][i-1];
		// printf("%d %d \n",i,num);
		num_max = max(num,num_max);
	}		
	printf("%d",num_max);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  int N,K; cin >> N >> K;
  string S; cin >> S;
  
  int count = 1;
  int cur;
  vector<pair<int, int>> A(0);
  rep(i,N) {
    if (i == 0) {
      if (S[0] == '0') cur = 0;
      else cur = 1;
    } else if (S[i] != S[i-1]) {
      A.push_back(make_pair(count,cur));
      cur = 1 - cur;
      count = 1;
    } else count++;
  }
  A.push_back(make_pair(count,cur));

  int M = A.size();
  int num = 0;
  int right = 0;
  int KK = 0;
  int ans = 0;
  rep(left,M) {
    while (right < M && (A[right].second != 0 || KK < K)) {
      num += A[right].first;
      if (A[right].second == 0) KK++;
      right++;
    }

    ans = max(ans,num);

    if (left == right) right++;
    else {
      num -= A[left].first;
      if (A[left].second == 0) KK--;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1528
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

constexpr intmax_t MOD = 1e9+7;

template <class Tp>
Tp gcd(Tp a, Tp b, Tp& x, Tp& y) {
  x = Tp(0);
  y = Tp(1);
  for (Tp u=y, v=x; a;) {
    Tp q = b/a;
    std::swap(x-=q*u, u);
    std::swap(y-=q*v, v);
    std::swap(b-=q*a, a);
  }
  return b;
}

template <class Tp>
Tp modinv(Tp a, Tp mod) {
  Tp x, y;
  gcd(a, mod, x, y);
  x %= mod;
  if (x < 0) x += mod;
  return x;
}

class modchoose {
  std::vector<intmax_t> fact, fact_inv;
  intmax_t mod;

public:
  modchoose(intmax_t N, intmax_t mod): mod(mod) {
    fact.resize(N+1);
    fact_inv.resize(N+1);
    fact[0] = 1;
    for (intmax_t i = 1; i <= N; ++i)
      fact[i] = fact[i-1] * i % MOD;

    fact_inv[N] = modinv(fact[N], mod);
    for (intmax_t i = N; i--;)
      fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
  }

  intmax_t operator ()(intmax_t n, intmax_t r) const {
    intmax_t res = fact[n] * fact_inv[r] % mod;
    (res *= fact_inv[n-r]) %= mod;
    return res;
  }
};

int main() {
  intmax_t H, W, A, B;
  scanf("%jd %jd %jd %jd", &H, &W, &A, &B);

  modchoose ncr(H+W, MOD);
  intmax_t res = 0;
  for (intmax_t i = 0; i < W-B; ++i)
    (res += ncr(H-A-1+B+i, B+i) * ncr(A+W-B-2-i, A-1)) %= MOD;

  printf("%jd\n", res);
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, M;
  map<string, ll> cnt;
  string s;

  cin >> N;
  rep(i, N){
    cin >> s;

    cnt[s]++;
  }
  
  cin >> M;
  rep(i, M){
    cin >> s;

    cnt[s]--;
  }

  vl amount;

  for(auto it = cnt.begin(); it != cnt.end(); it++) amount.push_back(it->second);

  stable_sort(amount.begin(), amount.end(), greater<ll>());

  cout << std::max((ll)0, amount[0]) << endl;
  
  return 0;
}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


s = input()
t = input()

def sub(s,t):
    """共通部分文字列長
    """
    ls = len(s)
    lt = len(t)
    dp = [[0]*(lt+1) for _ in range(ls+1)]
    ###
    prev = [[None]*(lt+1) for _ in range(ls+1)]
    ###
    for i in range(1,ls+1):
        for j in range(1,lt+1):
            if dp[i][j-1]>dp[i-1][j]:
                v = dp[i][j-1]
                pp = (i,j-1)
            else:
                v = dp[i-1][j]
                pp = (i-1,j)
            if s[i-1]==t[j-1] and dp[i-1][j-1] + 1 > v:
                v = dp[i-1][j-1] + 1
                pp = (i-1,j-1)
            dp[i][j] = v
            ###
            prev[i][j] = pp
            ###
    return dp, prev

dp, prev = sub(s,t)
ans = []
i,j = len(s), len(t)
while prev[i][j] is not None:
    if prev[i][j]==(i-1, j-1):
        ans.append(s[i-1])
    i,j = prev[i][j]
print("".join(ans[::-1]))

Measured memory_bytes: 425912
package main

// ABC160C - Travelling Salesman around Lake (解説回答)
// https://atcoder.jp/contests/abc160/tasks/abc160_c

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	K := nextInt(sc)
	N := nextInt(sc)
	A := make([]int, N)
	for i := range A {
		A[i] = nextInt(sc)
	}
	A = append(A, K+A[0])
	L := 0
	for i := 0; i < N; i++ {
		L = max(L, A[i+1]-A[i])
	}
	fmt.Println(K - L)
}
func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 5888
#!/usr/bin/env python3
import sys


def solve(N: int, p: "List[int]"):
    counts = 0
    idx = 0
    while idx < len(p):
        if p[idx] == idx + 1:
            counts += 1
            idx += 1
        idx += 1
    #print(counts)
    ret = counts
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14452
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;
ll ans, x, y, z, p;

int main()
{
	scanf("%lld%lld%lld%lld%lld%lld%lld", &x, &ans, &p, &y, &z, &p, &p);

	ans += max(x - (x & 1) + y - (y & 1) + z - (z & 1), (x > 0 && y > 0 && z > 0 ? x - ((x & 1) ^ 1) + y - ((y & 1) ^ 1) + z - ((z & 1) ^ 1) : 0));
	printf("%lld\n", ans);
	//cin >> x;
	return 0;
}

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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
   int N, P;
   std::string S;
   std::cin >> N >> P >> S;

   if(10 % P == 0) {
     ll ans = 0;
     for(int r = N - 1; r >= 0; --r) {
       if((S[r] - '0') % P == 0) {
         ans += r + 1;
       }
     }
     std::cout << ans << '\n';
     return 0;
   }

   std::map<int, int> cnt;
   int a = 1;
   int sum = 0;
   for(int r = N - 1; r >= 0; --r) {
     int x = (a * (S[r] - '0') % P);
     sum = (sum + x) % P;
     ++cnt[sum];
     a = 10 * a % P;
   }

   ll ans = (ll)cnt[0];
   rep(i, P) {
     ans += (ll)cnt[i] * (cnt[i] - 1) / 2;
   }
   std::cout << ans << '\n';
}


Measured memory_bytes: 900
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stdlib.h>
#include <cmath>
#include <math.h>
#include <fstream>
#include <bitset>
#include <time.h>
#include <queue>
#include <cassert>
#include <cstdio>
#include <complex>
#define int long long
using namespace std;
int n, ai;
vector<int> data;
signed main()
{
    int answer = 1e18;
    cin >> n;
    int summ = 0;
    for (int i=0;i<n;i++){
        cin >> ai;
        summ += ai;
        data.push_back(ai);
    }
    int now = 0;
    for (int i=0; i < n-1; i++){
        now += data[i];
        answer = min(answer, abs(now - (summ - now)));
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int N;
int a[100010];
vector<vector<int> > Tree(100010);
int len[100010];
int cnt[100010];
int par[100010];
int top;
int tlen[100010];
int tL;

/*void dfs(int u)
{
	int i;
	for(i=0; i<Tree[u].size(); i++){
		int v = Tree[u][i];
		len[v] = len[u] + 1;
		dfs(v);
	}
}

void solve()
{
	int i;
	for(i=1; i<N; i++){
		Tree[a[i]].push_back(i);
	}
	len[0] = 0;
	dfs(0);
	int res = 0;
	for(i=0; i<N; i++){
		if(res < len[i])
			res = len[i];
	}
	printf("%d\n", res);
}*/

/*void solve()
{
	int i;
	for(i=0; i<N; i++){
		cnt[a[i]] ++;
	}
	top = -1;
	for(i=0; i<N; i++){
		if(cnt[i] == 0){
			cnt[i] = top;
			top = i;
		}
	}
	while(top != -1){
		int u = top;
		top = cnt[top];
	}
}*/

void dfs(int u)
{
	int i;
	len[u] = 0;
	//tL = 0;
	vector<int> tt;
	for(i=0; i<Tree[u].size(); i++){
		int v = Tree[u][i];
		dfs(v);
		//tlen[tL] = len[v];
		//tL ++;
		tt.push_back(len[v]);
	}
	//sort(tlen, tlen+tL, greater<int>() );
	/*for(i=0; i<tL; i++){
		tlen[i] += i+1;
	}
	for(i=0; i<tL; i++){
		if(len[u] < tlen[i])
			len[u] = tlen[i];
	}*/
	sort(tt.begin(), tt.end(), greater<int>() );
	for(i=0; i<tt.size(); i++){
		tt[i] += i+1;
	}
	for(i=0; i<tt.size(); i++){
		if(len[u] < tt[i])
			len[u] = tt[i];
	}
}

void solve()
{
	int i;
	for(i=1; i<N; i++){
		Tree[a[i]].push_back(i);
	}
	dfs(0);
	printf("%d\n", len[0]);
}

int main()
{
	int i;
	scanf("%d", &N);
	for(i=1; i<N; i++){
		scanf("%d", &a[i]);
		a[i] --;
	}
	solve();
	return 0;
}

Measured memory_bytes: 14336