akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef int status;
typedef long long ll;
typedef unsigned long long ull;
const ull base = 343;
const int INF = int(1e9);
const ll INF1 = ll(1e15);
const int MAX = 200002;

int N;
ll a[MAX],b[MAX];

ll fa(ll x){
    return x<0?-x:x;
}

int main()
{
    cin>>N;
    for(int i = 1;i <= N;i++)
        cin>>a[i];
    sort(a+1,a+1+N);
    if(N==2){
        cout<<a[2]<<" "<<a[1]<<endl;
        return 0;
    }
    cout<<a[N]<<" ";
    ll t = a[N]/2;
    ll min1 = INF1;
    ll minid = -1;
    for(int i = 1;i <= N;i++){
        if(fa(a[i]-t)<=min1){
            min1 = fabs(a[i]-t);
            minid = i;
        }
    }

    cout<<a[minid]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll x; cin>>x;

    for (ll i = -2000; i <= 2000; ++i) {
        for (ll j = -2000; j <= 2000; ++j) {
            ll a = 1; ll b = 1;
            rep(k,5) {
                a *= i;
                b *= j;
            }
            if (a-b==x) {
                cout << i << ' ' << j << '\n';
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3604
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

_, e = I()
hs = Is()

obs = sorted([(i, h) for i, h in enumerate(hs, 1)], key=lambda x:x[1], reverse=True)
seen = D(bool)

roads = D(set)
for _ in range(e):
  a, b = I()
  roads[a].add(b)
  roads[b].add(a)
  
ans = 0
for ob in obs:
  if not seen[ob[0]]:
    if all(ob[1] > hs[r-1] for r in roads[ob[0]]):
      ans += 1
    seen[ob[0]] = True
    for r in roads[ob[0]]:
      seen[r] = True
      
print(ans)

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

long long h,m;
char s;
int main()
{
    scanf("%lld %c %lld",&h,&s,&m);
    if(s=='+')
    {
        printf("%lld\n",h+m);
    }
    else
    {
         printf("%lld\n",h-m);
    }
    return 0;
}


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

int main() {
  string n;
  cin >> n;
  bool flg = false;
  for(int i = 0; i < 3; i++){
    if(n[i] == '7') flg = true;
  }
  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3624
# include <iostream>
# include <cstdio>
# include <cstring>
# include <algorithm>
using namespace std;
char s[100006], t[100006];
int main()
{
    scanf("%s",s);
    int len = strlen(s), cnt=0,ans=0;
    for(int i=0; i<len; ++i)
        if(s[i]!='x') t[cnt++] = s[i];
    for(int i=0, j=cnt-1; i<j; ++i,--j)
        if(t[i]!=t[j]) return 0*puts("-1");
    for(int i=0, j=len-1; i<j;)
    {
        int i1=i,j1=j;
        for(; s[i1]=='x'; ++i1);
        for(; s[j1]=='x'; --j1);
        if(i1>j1) break;
        ans += abs((i1-i)-(j-j1));
        i = i1+1;
        j = j1-1;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(){
    int x, y;
    while(1){
        scanf("%d %d", &x, &y);
        if(x==0 && y==0)break;
        if(x<y){
            printf("%d %d\n", x, y);
        }else{
            printf("%d %d\n", y, x);
        }
    }
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 1000005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 998244353;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    multiset<ll>st;
    f (n) {
        int x;
        cin >> x;
        st.insert(x);
    }
    int ans = 0;
    while (st.size()) {
        int x = *(--st.end());
        st.erase(st.lower_bound(x));
        for (int i = (1<<30) ; i ; i>>=1){
            if (i <= x) {
                break;
            }
            if (st.find(i-x) != st.end()) {
                ans++;
                st.erase(st.lower_bound(i-x));
                break;
            }
        }
    }
    cout << ans << '\n';
}
    



Measured memory_bytes: 9600
import math

a, b, x = map(int,input().split())

if x <= (a * a * b / 2):
    angle = math.atan(a * b * b / (2 * x)) * 180 / math.pi
    print(angle)
else:
    angle = math.atan(2 * (a * a * b - x) / (a * a * a)) * 180 / math.pi
    print(angle)

Measured memory_bytes: 3060
x,k,d = map(int,input().split())
if x < 0:
  x = -x
if x - k * d >= 0:
  print(x-k*d)
  exit()
if k % 2 == 1:
  k -= 1
  x -= d
k //= 2
d *= 2
m = x // d
#print(k,d,x,m)
#print(abs(x-m*d),abs(x-(m-1)*d))
print(min(abs(x-m*d),abs(x-(m+1)*d)))

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

#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n; cin>>n;
  string s; cin>>s;
  vector<int> c(26, 0);
  for (int i=0; i<(int)(s.length()); i++) {
    c[s[i]-'a']++;
  }
  ll ans = 1;
  for (int i=0; i<26; i++) {
    ans = ans * (1+c[i]) % mod;
  }
  ans = (ans + mod - 1) % mod;
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


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

 int main(){

   int a;
   int b;
   string s;
   bool check = true;

   cin >> a >> b >> s;

   for(int i = 0; i < s.size(); i++){

     if(i == a){
      if(s[i] != '-'){
         check = false;
       }
     }else if(s[i] < '0' || s[i] > '9'){
         check = false;
       }
     }

     if(check == true){
       cout << "Yes" << endl;
     }else{
       cout << "No" << endl;
     }
     
     return 0;
}




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

		}
		System.out.printf("\n");
	}
}

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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;++i){
        string s;
        cin >> s;
        deque<char> deq;
        set<char> st;
        bool back = false;
        for(int j=0;j<s.size();++j){
            if(s[j] == '<'){
                back = false;
                j++;
            }else if(s[j] == '-'){
                back = true;
                j++;
            }else{
                if(st.count(s[j]))continue;
                if(back)deq.push_back(s[j]);
                else deq.push_front(s[j]);
                st.insert(s[j]);
            }
        }
        for(auto c: deq){
            cout << c;
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3060
#include <stdio.h>

int eyejudge(double eyesight);

int main(void) {
    int right[4] = {0};
    int left[4] = {0};
    double rsig, lsig;
    int i, j;
    
    while(scanf("%lf %lf", &lsig, &rsig) != EOF) {
        if(eyejudge(lsig) == 0 || eyejudge(rsig) == 0)
            return(0);
        left[eyejudge(lsig) - 1]++;
        right[eyejudge(rsig) - 1]++;
    }
    
    
    for(i = 0; i < 4; i++) {
        for(j = 0; j < 1; j++) {
            printf("%d %d", left[i], right[i]);
        }
        putchar('\n');
    }
    
    return(0);
}

int eyejudge(double eyesight) {
    if(eyesight >= 1.1)
        return(1);
    else if(eyesight >= 0.6 && eyesight < 1.1)
        return(2);
    else if(eyesight >= 0.2 && eyesight < 0.6)
        return(3);
    else if(eyesight < 0.2)
        return(4);
    else
        return(0);
}

Measured memory_bytes: 632
#include<cstdio>
#include<cctype>
int main()
{
    char ch;
    while(1)
    {
        scanf("%c", &ch);
        if( isalpha(ch) )
        {
            if( islower(ch) ) printf("%c", toupper(ch));
            else printf("%c", tolower(ch));
        }
        else printf("%c", ch);
    if ( ch == '\n' )break;
    }
    return 0;
}

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


long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){
    int N,M;
    cin>>N>>M;
    multimap<long long,int>A;
    long long ans=0;
    long long a=0;
    for(int i=0;i<N;i++){
        cin>>a;
        A.insert(make_pair(-a,i));
    }

    
    for(int i=0;i<M;i++){
        auto iter=A.begin();
        a=iter->first/2;
        A.erase(iter);
        A.insert(make_pair(a,i));
    }
auto it=A.begin();

while(it!=A.end()){
    ans-=it->first;
      it++;
}
    

    cout<<ans<<endl;
}

Measured memory_bytes: 6528
/*
                        Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
        {   if(n % 2 ==1)
            result=(result * x) % M;
            x=(x*x)% M;
            n=n/2;
        }
    return result % M;
}      
bool isPrime(int n)
    {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
    }
int inv(int a,int m)
{   return power(a,m-2);
}
int lcm(int a,int b)
{   return a*b/(gcd(a,b));
}
signed main()
{   jaldi
    int n;
    cin>>n;
    string str;
    cin>>str;
    for(int i=0;i<n-1;i++)
    {   if(str[i]==str[i+1])
        str[i]=' ';
    }
    int count=0;
    for(int i=0;i<n;i++)
    {   if(str[i]!=' ')
        count++;
    }
    cout<<count;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
int main(){
    string sun = "Sunny" , cloud = "Cloudy" , rain = "Rainy" , s;
    cin >> s;
    if (s == sun) cout << cloud;
    else if(s == cloud) cout << rain;
    else cout << sun;
    return 0;
}

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

int main()
{
    int n,a,b;
    a=b=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        if(x%4==0)a++;
        else if(x%2==0) b++;
    }
    if(b>0)
    n-=b-1;
    if((n)/2<=a)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define piii pair<pii,int>
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;



int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	ll n;
	cin>>n;
	if(n&1)cout<<n*2<<endl;
	else cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    int N;
    cin >> N;
    vector<Pint> AB(N);
    for (int i = 0; i < N; i++){
        cin >> AB.at(i).first >> AB.at(i).second;
    }
    sort(rALL(AB));
    cout << AB.at(0).first + AB.at(0).second << endl;

}




Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(i%2==0)
			if(s[i]!='R'&&s[i]!='U'&&s[i]!='D')
			{
				printf("No\n");
				return 0;
			}
		if(i%2==1)
			if(s[i]!='L'&&s[i]!='U'&&s[i]!='D')
			{
				printf("No\n");
				return 0;
			}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main(){
        int N,M;
        cin >> N >> M;
        vector<int>groups(N,-1);
        vector<vector<int> >friends(N);
        for(int i=0 ; i<M ; i++ ){
                int s,t;
                cin >> s >> t;
                friends[s].push_back(t);
                friends[t].push_back(s);
        }
        int group=0;
        for(int i=0 ; i<N ; i++ ){
                if(groups[i]!=-1)
                        continue;
                queue <int> cycle;
                cycle.push(i);
                while(cycle.size()!=0){
                        int now=cycle.front();cycle.pop();
                        vector <int>::iterator itr;
                        for(itr=friends[now].begin() ; itr!=friends[now].end() ; ++itr ){
                                if(groups[*itr]==-1)
                                        cycle.push(*itr);
                        }
                        groups[now]=group;
                }
                group++;
        }
        cin >> N;
        for(int i=0 ; i<N ; i++ ){
                int s,t;
                cin >> s>> t;
                if(groups[s]==groups[t])
                        cout<<"yes"<<endl;
                else
                        cout<<"no"<<endl;
        }
        return 0;
}



Measured memory_bytes: 8580
#include <iostream>
#include <algorithm>

using namespace std;

int a[4];

int func(int n, int sum) {
    if (n == 3) {
        if (sum+a[n] == 7) return 1<<2;
        else if (sum-a[n] == 7) return 0;
        else return -1000;
    }

    return max(func(n+1, sum+a[n])+(1<<n-1), func(n+1, sum-a[n]));
}

int main() {
    int n;
    cin >> n;
    for (int i=0; i<4; i++) {
        a[3-i] = n%10;
        n /= 10;
    }

    int ans = func(1, a[0]);

    cout << a[0];
    for (int i=1; i<4; i++) {
        if (ans & 1<<i-1) cout << "+";
        else cout << "-";
        
        cout << a[i];
    }
    cout << "=7" << endl;

    return 0;
}

Measured memory_bytes: 256
import qualified Data.Set as DS
main = do
  getLine 
  s <- getLine 
  print $ solve s 0

solve :: String -> Int -> Int
solve str n = 
  if n == length str then 0 
  else
    max (DS.size (DS.intersection s1 s2)) (solve str (n+1))
      where (l,r) = splitAt n str
            s1 = DS.fromList l
            s2 = DS.fromList r


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll a, b, c; cin >> a >> b >> c;
  if (a+b >= c) cout << b+c << endl;
  else cout << b + a+b + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using P = pair<int, int>;
int H, W, K;
vector<vector<char>> maze;  // 迷路の内容を保存する配列
vector<vector<int>> dist;   // 距離を記録しておく配列
P s, g;

// 幅優先探索
int bfs(P s) {
    const int INF = 1e8;
    dist.assign(H, vector<int>(W, INF));  // 初期化
    int ans = INF;
    queue<pair<int, int>> que;
    que.emplace(s);
    dist[s.first][s.second] = 0;
    while (que.size() != 0) {
        pair<int, int> now = que.front();
        que.pop();
        int dis = min(now.first, min(now.second, min(H - now.first - 1, W - now.second - 1)));
        chmin(ans, 1 + (dis + K - 1) / K);
        if (dist[now.first][now.second] >= K) continue;
        int dy[4] = {0, 0, 1, -1};  // dx,dy は次の探索場所への距離を表す（４方向分）
        int dx[4] = {1, -1, 0, 0};
        for (int i = 0; i < 4; i++) {
            int ny = now.first + dy[i];
            int nx = now.second + dx[i];
            if (ny < 0 || H <= ny || nx < 0 || W <= nx) continue;
            if (maze[ny][nx] == '#') continue;  // 障害物があればスルー
            if (dist[ny][nx] != INF) continue;
            que.push(make_pair(ny, nx));
            dist[ny][nx] = dist[now.first][now.second] + 1;
        }
    }
    return ans;
}

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

    cin >> H >> W >> K;

    maze.assign(H, vector<char>(W, '.'));  // 初期化
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> maze[i][j];
            if (maze[i][j] == 'S') s = make_pair(i, j);
        }
    }

    cout << bfs(s) << endl;

    return 0;
}


Measured memory_bytes: 3456
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"
import copy
#input = sys.stdin.readline

########################################




r , c , k = map(int , input().split())
arr = [list(input()) for i in range(r)]
ans = 0
row = [i for i in range(r)]
col = [i for i in range(c)]
ans = 0
for ii in range(r+1):
	for i in combinations(row,ii):
		for jj in range(c+1):
			for j in combinations(col,jj):
				t = 0
				for r1 in range(r):
					for c1 in range(c):
						if r1 in i or c1 in j:continue
						if arr[r1][c1] == "#":t+=1
				if t == k: ans+=1
print(ans)







Measured memory_bytes: 69956
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

const int INF = 1000000007;

vector<P> g[100000];
int n;
int dist[100000];

void bfs(int s) {
  REP(i, n) dist[i] = INF;
  queue<int> que;
  que.push(s);
  dist[s] = 0;
  while (que.size()) {
    int u = que.front();
    que.pop();
    REP(i, g[u].size()) {
      int v = g[u][i].first;
      int cost = g[u][i].second;
      if (dist[v] == INF) {
        que.push(v);
        dist[v] = dist[u] + cost;
      }
    }
  }
}

int main() {
  cin >> n;
  REP(i, n - 1) {
    int s, t, w;
    cin >> s >> t >> w;
    g[s].push_back(P(t, w));
    g[t].push_back(P(s, w));
  }
  bfs(0);
  int ans = 0;
  int x = 0;
  REP(i, n) {
    if (dist[i] == INF) continue;
    if (ans < dist[i]) {
      ans = dist[i];
      x = i;
    }
  }
  bfs(x);
  ans = 0;
  REP(i, n) {
    if (dist[i] == INF) continue;
    ans = max(ans, dist[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9804
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
    getline(cin,a),getline(cin,b),sort(a.begin(),a.end()),sort(b.begin(),b.end(),greater<char>());
    printf("%s\n",(a<b?"Yes":"No"));
	//cout<<(a<b?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int n = sc.nextInt();
    static int[][] vac = new int[n][3];
    static int[][] dp = new int[n + 1][3];
    public static void main(String[] args) {
        //dp初期化
        for (int i = 0; i < n; i++){
            for (int j = 0; j < 3; j++)
            dp[i][j] = 0;
        }
        //標準入力を取得
        for (int i = 0; i < n; i++){
            for (int j = 0; j < 3; j++){
                vac[i][j] = sc.nextInt();
            }
        }
         for (int i = 0; i < n; i++){
             for (int j = 0; j < 3; j++){
                 for (int k = 0; k < 3; k++){
                     if (j == k)
                         continue;
                     dp[i + 1][k] = chmax(dp[i + 1][k], dp[i][j] + vac[i][k]);
                 }
             }
         }

        System.out.println(Math.max(Math.max(dp[n][0], dp[n][1]), dp[n][2]));
    }

    static int chmax(int a, int b){
        if (a < b) {
            return b;
        } else {
            return a;
        }
    }
}


Measured memory_bytes: 101340
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long 
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
signed main() {
	int n, m, ans;
	cin >> n >> m;
	if (n == 1)cout << m << endl;
	else {
		for (int i = 1; i <= m / n; i++) {
			if (m%i == 0)ans = i;
		}
		cout << ans << endl;
	}
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}

inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};

struct UnionFind {
  private:
	std::vector<int> rank, par, col;
	int n_;

  public:
	UnionFind(int n) : n_(n) {
		rank.resize(n, 1);
		par.resize(n);
		for (int i = 0; i < n; ++i) {
			par[i] = i;
		}
		col.resize(n, 1);
	}
	int root(int i) {
		while (par[i] != i) {
			i = par[i];
		}
		return i;
	}
	bool isSame(int x, int y) { return root(x) == root(y); }
	void unite(int x, int y) {
		if (isSame(x, y)) return;
		x = root(x), y = root(y);
		if (rank[x] < rank[y]) {
			par[x] = y;
			col[y] += col[x];
		} else {
			if (rank[x] == rank[y]) rank[x]++;
			par[y] = x;
			col[x] += col[y];
		}
	}
	int cnt(int x) {
		x = root(x);
		return col[x];
	}
};

signed main() {
	IOS();
	ll n, m;
	cin >> n >> m;
	vector<ll> a(n);
	vector<P> p(n);
	vector<ll> g[114514];

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		p[i] = P(a[i], i);
	}
	if (n < 2 * (n - m - 1)) {
		dump("Impossible");
		return 0;
	}
	if (m == n - 1) {
		dump(0);
		return 0;
	}

	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	sort(p.begin(), p.end());
	vector<bool> used(n, false), used2(n, false);
	ll ans = 0;
	ll cnt = 0;
	for (int i = 0; i < n; i++) {
		if (used[i]) continue;
		stack<ll> st;
		st.push(i);
		ll tmp  = a[i];
		ll unko = i;
		while (!st.empty()) {
			ll j = st.top();
			st.pop();
			used[j] = true;
			if (tmp > a[j]) {
				unko = j;
				tmp  = a[j];
			}
			for (int k = 0; k < g[j].size(); k++) {
				if (!used[g[j][k]]) st.push(g[j][k]);
			}
		}
		used2[unko] = true;
		ans += tmp;
		cnt++;
	}
	for (int i = 0; i < n; i++) {
		if (cnt == 2 * (n - m - 1)) break;
		if (!used2[p[i].second]) {
			cnt++;
			ans += p[i].first;
			used2[p[i].second];
		}
	}
	dump(ans);
	return 0;
}

Measured memory_bytes: 8960
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	while(1){
		string in;
		getline(cin,in);
		if(in[0]=='.') break;
		stack<int> a;
		bool flg = false;
		REP(i,in.size()){
			if(in[i]=='(') a.push(1);
			if(in[i]=='[') a.push(2);
			if(in[i]==')'){
				if(!a.empty()){
					if(a.top()!=1) flg = true;
					a.pop(); 
				}else{
					flg = true;
				}
			}
			if(in[i]==']'){
				if(!a.empty()){
					if(a.top()!=2) flg = true;
					a.pop(); 
				}else{
					flg = true;
				}
			}
		}

		if(flg==false){
			if(!a.empty()) flg = true;
		}
		if(flg) cout << "no" << endl;
		else cout << "yes" << endl;
	}
}

Measured memory_bytes: 1176
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

constexpr char endl('\n');

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define INF 100000000000ULL

int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    size_t k, sum;
    cin >> k;
    sum = 0;

    FOR(a, 1, k+1) {
        sum += a;
    }
    FOR(a, 1, k + 1) {
        FOR(b, a+1, k + 1) {
            sum += gcd(a, b) * 6;
        }
    }
    FOR(a, 1, k + 1) {
        FOR(b, a+1, k + 1) {
            FOR(c, b+1, k + 1) {
                sum += gcd(a, gcd(b, c)) * 6;
            }
        }
    }
    cout << sum << ::endl;

    return 0;
}


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

using namespace std;
using ll = long long;


int main()
{
    string s;
    cin >> s;
    for(auto &i: s){
        if(i == '9')i = '1';
        else if(i == '1')i = '9';
    }
    cout << s << endl;
}

Measured memory_bytes: 256
def print_building(b_dict,b_floor):
    for i in range(len(b_dict[b_floor])):
        for j in b_dict[b_floor][i]:
            print(' {}'.format(j),end='')
        print('\r')

def print_fence():
    print('####################')

building = {
    1:[[0]*10 for i in range(3)],
    2:[[0]*10 for i in range(3)],
    3:[[0]*10 for i in range(3)],
    4:[[0]*10 for i in range(3)]
}

n = int(input())
for _ in range(n):
    b,f,r,v = map(int,input().split())
    building[b][f-1][r-1] += v

for i in range(1,4):
    print_building(building,i)
    print_fence()
print_building(building,4)


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n, W;
    cin >> n >> W;
    vector<int> w(n);
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> w[i] >> v[i];
    vector<vector<ll>> dp(n+1, vector<ll>(W+1, 0));
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j <= W; j++)
        {
            if(j < w[i])
            {
                dp[i+1][j] = dp[i][j];
            }
            else
            {
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
            }
        }
    }
    cout << dp[n][W] << endl;
}


Measured memory_bytes: 80256
import java.awt.*;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    static String s, t;
    static int dp[][];
    static StringBuilder sb = new StringBuilder();

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        s = sc.next();
        t = sc.next();
        int n = s.length(), m = t.length();
        dp = new int[n+1][m+1];
        for (int a[] : dp) Arrays.fill(a, -1);
        check(n - 1, m - 1);
        System.out.println(lcs(n , m ));
    }

    static int check(int n, int m) {
        if (n < 0 || m < 0) return 0;
        if (dp[n+1][m+1] != -1) return dp[n+1][m+1];
        if (s.charAt(n) == t.charAt(m)) return dp[n+1][m+1] = check(n - 1, m - 1) + 1;
        return dp[n+1][m+1] = Math.max(check(n - 1, m), check(n, m - 1));
    }

    static String lcs(int n, int m) {
        if (n==0 || m==0)return "";
        if (s.charAt(n-1) == t.charAt(m-1)) return lcs(n - 1, m - 1) + s.charAt(n-1);
        if (dp[n][m - 1] > dp[n - 1][m]) return lcs(n, m - 1);
        return lcs(n - 1, m);


    }
}

Measured memory_bytes: 99152
#include <bits/stdc++.h>
using namespace std;
int main(){
int X,N;
cin>>X>>N;
int p[110]={};
for(int i=0; i<N; i++){
    int q;
    cin>>q;
    p[i]=q;
}
bool k=false;
for(int i=0; i<200; i++){
    int t=2;
    while(t>0){
        i=(-1)*i;
        bool s=true;
        for(int j=0; j<N; j++){
            if(p[j]==X+i){ s=false;break; }
        }
        if(s) {cout<<X+i<<endl; k=true; break;}
        t--;
    }
    if(k) break;
}

}


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

using namespace std;
#define ll long long
#define pb push_back

int main()
{
	int n;
	cin>>n;
	ll cnt = 0;
	for(int i=n-1; i>=1; i--) {
		int x = n-i;
		for(int j=1; j*j<=x; j++) {
			if(x%j==0) cnt+=2;
			
			if(j==sqrt(x)) cnt--;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3676
#include <iostream>

using namespace std;

int main(){

    int r = 0;
    int D = 0;
    int x_2000 = 0;

    cin >> r >> D >> x_2000;

    int x_pre=x_2000;

    for(int i=0;i<10;i++){
        int ret = r*x_pre - D;

        cout << ret << endl;

        x_pre = ret;
    }

    return 0;
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  ll n, k;
  cin >> n >> k;
  vec<int> d(k);
  vec<char> dc(k);
  scan(d);
  rep(i, 0, k) dc[i] = '0' + d[i];

  rep(i, n, 100000) {
    string s = to_string(i);
    bool invalid = false;
    for (char c : dc) {
      if (!count(all(s), c)) continue;
      invalid = true;
      break;
    }

    if (invalid) continue;
    put(s);
    return 0;
  }
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) {
  T c = min(a, b), d = max(a, b);
  return c * (d / gcd(c, d));
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<complex>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define pb push_back


const int N = 1000;

class Edge{
public:
  int to;
  double cost;
};

vector<Edge> edge[N];

double dist(double x,double y){
  return sqrt(x*x+y*y);
}

double getx(double xa,double xb,double ya,double yb,double y){
  double A = (ya-yb)/(xa-xb);
  return (y-ya+A*xa)/A;
}

void makeedge(int n,double *x,double *y,double vd,double vwalk){
  rep(i,n-1){
    edge[i].pb((Edge){i+1,dist(x[i]-x[i+1],y[i]-y[i+1])/vwalk});
  }
  
  rep(i,n){
    REP(j,i+1,n-1){
      if (i+1 == j && y[j] <= y[i])break;
      if (y[j+1] <= y[i] && y[i] < y[j]){
	double tx = getx(x[j],x[j+1],y[j],y[j+1],y[i]);
	edge[i].push_back((Edge){j+1,(tx-x[i])/vd+dist(tx-x[j+1],y[i]-y[j+1])/vwalk});
	break;
      }
    }
    
    for(int j=i-1;j>=1;j--){
      if (i-1 == j && y[j] <= y[i])break;
      if (y[j-1] <= y[i] && y[i] < y[j]){
	double tx = getx(x[j],x[j-1],y[j],y[j-1],y[i]);
	edge[j-1].push_back(
			    (Edge){i,(x[i]-tx)/vd+dist(tx-x[j-1],y[i]-y[j-1])/vwalk});
	break;
      }
    }
  }
}


double cost[N];
double solve(int n,double *x,double *y,double vw,double vd){
  rep(i,n)edge[i].clear();
  makeedge(n,x,y,vd,vw);
  rep(i,n)cost[i] = 1e100;

  cost[0] = 0;
  rep(i,n){
    rep(j,edge[i].size()){
      int next = edge[i][j].to;
      cost[next]=min(cost[next],cost[i]+edge[i][j].cost);
    }
  }

  /*
  rep(i,n){
    cout << "now " << x[i] << " " << y[i]<<endl;
    puts("edge begin");
    rep(j,edge[i].size()){
      int nex = edge[i][j].to;
      cout << x[nex] << " "<< y[nex] << " "<< edge[i][j].cost << endl;
    }
    puts("Edge end");
  }
  */

  return cost[n-1];
}


main(){
  int n;
  while(cin>>n && n){
    double vwalk,vd;
    cin>>vwalk>>vd;
    double x[n],y[n];
    rep(i,n)cin>>x[i]>>y[i];
    printf("%6lf\n",solve(n,x,y,vwalk,vd));
  }
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;


class TTBrothers
{
    static void Main(string[] args)
    {
        String[] input = Console.ReadLine().Split(' ');
        var N = int.Parse(input[0]);
        var A = int.Parse(input[1]);
        var B = int.Parse(input[2]);
        Console.WriteLine(Math.Min((N * A),B));
    }
}


Measured memory_bytes: 11092
N = gets.to_i
s = []
count = {}
N.times do |i|
  s[i] = gets.chomp
  if count[s[i]].nil?
    count[s[i]] = 1
  else
    count[s[i]] += 1
  end
end
# countハッシュのvalの最大を求める
max = count.max{|x,y| x[1]<=>y[1]}[1]
# keyの辞書順でソート
count = count.sort

count.each do |val|
  # puts "#{val}"
  if val[1]==max
    puts val[0]
  end
end

Measured memory_bytes: 52456
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
//#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


const ll MOD=998244353;
const int N=500000;

ll gcd(ll x,ll y){
    if(x) return gcd(y%x,x);
    else return y;
}

main(){
    ll n,x,d;
    cin>>n>>x>>d;
    ll g=gcd(x,d);
    if(d==0){
        if(g==0)cout<<1<<endl;
        else cout<<n+1<<endl;
        return 0;
    }
    x/=g;d/=g;
    if(d<0){
        d*=-1;
        x*=-1;
    }
    ll ans=0;
    rep(a,min(d,n+1)){
        priority_queue<pll,vector<pll>,greater<pll>> pq;
        rep(i,n/d+2){
            ll now=a+i*d;
            if(now>n)continue;
            pq.emplace(now*(now-1)/2+x*i,1ll);
            pq.emplace(now*(2*n-1-now)/2+x*i+1,-1ll);
        }
        if(pq.empty())continue;
        ll pre=pq.top().first;
        ll res=1; pq.pop();
        while(!pq.empty()){
            pll p=pq.top();pq.pop();
            if(res) ans+=p.first-pre;
            pre=p.first;
            res+=p.second;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 10604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pb push_back
const ll mod = 1000000007;
void solve(){
    ll n,m;
    cin>>n>>m;
    vector<ll>x(n),y(m);
    for(int i=0;i<n;i++) cin>>x[i];
    for(int i=0;i<m;i++) cin>>y[i];
    ll sumx=0,sumy=0;
    for(int k=1;k<=n;k++){
        sumx=((sumx%mod)+(((x[k-1]%mod)*((2*k-n-1)%mod))%mod))%mod;
    }
    for(int k=1;k<=m;k++)
    {
        sumy=((sumy%mod)+(((y[k-1]%mod)*((2*k-m-1)%mod))%mod))%mod;
    }
    ll ans = ((sumx%mod)*(sumy%mod))%mod;
    cout<<ans;
}
int  main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
    //cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 1792
while 1:
	sentence = raw_input()
	if sentence == ".":
		break
	bracket = []
	length = 0
	for s in sentence:
		if s == "(":
			bracket.append(s)
			length += 1
		elif s == ")":
			if len(bracket) == 0 or bracket.pop() != "(":
				length = -1
				break
			length -= 1
		elif s == "[":
			bracket.append(s)
			length += 1
		elif s == "]":
			if len(bracket) == 0 or bracket.pop() != "[":
				length = -1
				break
			length -= 1
	print "yes" if length == 0 else "no" 

Measured memory_bytes: 4240
#DP-C

n,w=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]

dp=[[0]*(w+1) for i in range(n+1)]

for i in range(1,n+1):
    for sum_w in range(w+1):
        if sum_w-l[i-1][0]>=0:
            dp[i][sum_w]=max(dp[i-1][sum_w],dp[i-1][sum_w-l[i-1][0]]+l[i-1][1])
        else:
            dp[i][sum_w]=dp[i-1][sum_w]

print(max(dp[-1]))

Measured memory_bytes: 120172
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin>>N;
	
	vector<int> vea(N);
	vector<int> veb(N);
	vector<int> vec(N);
	vector<int> ved(N*3);
	
	for(int i=0; i<N; i++){
		cin>>veb.at(i);
		vea.at(i)=(veb.at(i))-1;
		vec.at(i)=(veb.at(i))+1;
	}
	for(int i=0; i<N; i++){
		ved.at(i)=vea.at(i);
		ved.at(i+N)=veb.at(i);
		ved.at(i+N*2)=vec.at(i);
	}
	sort(ved.begin(), ved.end());
	
	int A=0,B=0,C=0;
	for(int i=0; i<N*3-1; i++){
		if(ved.at(i)==ved.at(i+1)){
			A++;
		}
		else{
			if(A>B){
				B=A;
			}
			A=0;
		}
	}
	cout<<B+1<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >>k;
	ll ans = 0;
	if (k <= a) ans += k;
	else if (k <= a + b) ans += a;
	else if (k <= a + b + c) ans += a - (k - a - b);
	cout << ans << endl;
	return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  bool tturn = true;
  while (a > 0 && c > 0) {
    if (tturn)
      c -= b;
    else
      a -= d;
    tturn = !tturn;
  }
  cout << (c <= 0 ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const int N = 1e5;
const int INF = 1e9;
const int MOD = 1e9 + 7;
 
long long dp[1000][1000];
 
int main() {
    int h, w;
    cin >> h >> w;
    char a[h][w];
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            cin >> a[i][j];
    dp[0][0] = 1;
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            if (a[i][j] == '.') {
                if (i > 0 && a[i - 1][j] == '.')
                    dp[i][j] += dp[i - 1][j];
                dp[i][j] %= MOD;
                if (j > 0 && a[i][j - 1] == '.')
                    dp[i][j] += dp[i][j - 1];
                dp[i][j] %= MOD;
            }
    cout << dp[h - 1][w - 1];
} 

Measured memory_bytes: 9088
#include <stdio.h>

int main(void)
{
	int N, tmp, max, i, ans;
	int nums[1000001] = {0};

	scanf("%d\n", &N);
	max = 0;
	for (i = 0; i < N; i++)
	{
		scanf("%d", &tmp);
		nums[tmp]++;
		if (max < tmp)
			max = tmp;
	}

	ans = 0;
	i = 1;
	while (i <= max)
	{
		if (nums[i] == 0)
		{
			i++;
			continue;
		}
		if (nums[i] == 1)
			ans++;
		int j = i * 2;
		while (j <= max)
		{
			nums[j] = 0;
			j += i;
		}
		i++;
	}
	printf("%d\n", ans);
	return (0);
}

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

using namespace std;
using namespace __gnu_pbds;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
    int n,w;
    cin>>n>>w;
    vector<pair<int , int> > v;
 v.push_back(make_pair(-1,-1));
    for(int i=0;i<n;i++)
    {
        long long x,y;
        cin>>x>>y;
        v.push_back(make_pair(x,y));
        
    }
    vector<vector <long long  >> dp(n+1,vector<long long>(w+1));
    for(int i=1;i <=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
dp[i][j]=dp[i-1][j];
          if(j>=v[i].first) dp[i][j]=max(dp[i][j],dp[i-1][j-v[i].first]+v[i].second); 
        }
    }
   long long ans=0;
     for(int j=0;j<=w;j++){ans=max(ans,dp[n][j]);}
     cout<<ans;
    
return 0;
}


Measured memory_bytes: 80256
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <stdarg.h>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

double tot = 0;
int cnt = 0;
double dist[8][8] = {0};
bool have[8] = {false};

double
getDist(vector<double> & x, vector<double> & y, int i, int j) {
  return sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
}

void
find(vector<int> & now, int n, double current) {
  if (now.size() == n) {
    tot += current;
    cnt++;
  }
  else {
    for (int i=0; i<n; i++) {
      if (have[i]) continue;

      have[i] = true;
      double temp = current;
      if (now.size() > 0)
        temp += dist[now[now.size()-1]][i];
      now.push_back(i);
      find(now, n, temp);
      now.erase(now.begin() + now.size() - 1);
      have[i] = false;
    }
  }
}

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

  vector<double> x(n, 0), y(n, 0);
  for (int i=0; i<n; i++)
    cin>>x[i]>>y[i];

  for (int i=0; i<n; i++)
    for (int j=0; j<n; j++) 
      dist[i][j] = getDist(x, y, i, j);

  vector<int> now;
  double current = 0;
  find(now, n, current);

  printf("%.10lf\n", tot/cnt);
  return 0;
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  string s; cin >> s;
  int t = 0;
  V<> a;
  V<bool> b;
  for (int i = 0; i < n; ++i) {
    ++t;
    if (i == n - 1 or s[i] != s[i + 1]) {
      a.push_back(t);
      t = 0;
      b.push_back(s[i] == '1');
    }
  }
  if ((int) a.size() == 1) return cout << n << '\n', 0;
  n = a.size();
  V<> c(n + 1);
  for (int i = 0; i < n; ++i) c[i + 1] = c[i] + a[i];
  k = 2 * k + 1;
  int res = 0;
  for (int i = 0; i < n; ++i) if (b[i]) {
    res = max(res, c[min(i + k, n)] - c[i]);
    res = max(res, c[i + 1] - c[max(i + 1 - k, 0)]);
  }
  cout << res << '\n';
}

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

using namespace std;

long long inf=1000000007;

int main(){
	int x,n;
	cin>>x>>n;
	set<int> hoge;

	for(int i=-1000;i<=1000;i++){
		hoge.insert(i);
	}

	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		hoge.erase(a);
	}

	int ans=inf;

	for(auto at=hoge.begin();at!=hoge.end();at++){
		if(abs(ans-x)>abs(x-*at)){
			ans=*at;
		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3720
///
// File:  grl_1_c.cpp
// Author: ymiyamoto
//
// Created on Thu Oct 19 23:14:36 2017
//

#include <cstdint>
#include <iostream>

using namespace std;

#define SIZE 100
#define INF INT32_MAX

static int64_t graph[SIZE][SIZE];

int32_t main()
{
  uint32_t V, E;
  cin >> V >> E;

  for (uint32_t i = 0; i < V; i++) {
    for (uint32_t j = 0; j < V; j++) {
      if (i == j)
        graph[i][j] = 0;
      else
        graph[i][j] = INF;
    }
  }

  for (uint32_t i = 0; i < E; i++) {
    int64_t s, t, d;
    cin >> s >> t >> d;
    graph[s][t] = d;
  }

  for (uint32_t k = 0; k < V; k++) {
    for (uint32_t i = 0; i < V; i++) {
      for (uint32_t j = 0; j < V; j++) {
        if (graph[i][k] == INF || graph[k][j] == INF) continue;
        if (graph[i][k] + graph[k][j] < graph[i][j]) {
          graph[i][j] = graph[i][k] + graph[k][j];
        }
      }
    }
  }

  for (uint32_t i = 0; i < V; i++) {
    if (graph[i][i] < 0) {
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
  }

  for (uint32_t i = 0; i < V; i++) {
    for (uint32_t j = 0; j < V; j++) {
      if (j != 0) cout << " ";
      if (graph[i][j] == INT32_MAX) {
        cout << "INF";
      } else {
        cout << graph[i][j];
      }
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3180
#from collections import deque,defaultdict
from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 998244353

def ddprint(x):
  if DBG:
    print(x)

a,b,c,d = inm()
dp = [[0]*(d+1) for i in range(c+1)]
dp[a][b] = 1
for i in range(a+1,c+1):
    dp[i][b] = (dp[i-1][b]*b)%R
for j in range(b+1,d+1):
    dp[a][j] = (dp[a][j-1]*a)%R
for i in range(a+1,c+1):
    for j in range(b+1,d+1):
        dp[i][j] = (dp[i-1][j]*j+dp[i][j-1]*i-dp[i-1][j-1]*(i-1)*(j-1))%R
print(dp[c][d])


Measured memory_bytes: 133620