akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for(ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
 
 
ll power(ll b,ll e,ll m)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
}


void solve()
{
  string s;
  cin>>s;
  map<char,int> map;
  for(auto i:s) map[i]++;
    for(auto i:map) 
    {
      if(i.sc%2)
      {
        cout<<"No";
        return;
      }
    }
    cout<<"Yes";
}
 
int main()
{
  fastio
  int tt=1;
  // cin>>tt;
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
  return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    getline(cin,s);
    for(int i=0;i<s.size()-1;i++)
    {
    	if(s[i]=='C')
    	{
    		for(int j=i+1;j<s.size();j++)
    		{
    			if(s[j]=='F')
    			{
    				cout<<"Yes\n";
    				return 0;
				}
			}
		}
	}
	cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
def parent(i)
  i / 2
end

def left(i)
  2 * i
end

def right(i)
  2 * i + 1
end

def max_heapify(nodes, i)
  h = nodes.size - 1
  l = left(i)
  r = right(i)

  largest = i

  if l <= h && nodes[l] > nodes[i]
    largest = l
  end

  if r <= h && nodes[r] > nodes[largest]
    largest = r
  end

  if largest != i
    nodes[i], nodes[largest] = nodes[largest], nodes[i]
    max_heapify(nodes, largest)
  end
end

if $PROGRAM_NAME == __FILE__
  n = gets.to_i

  nodes = [nil] + gets.chomp.split.map(&:to_i)

  (n / 2).downto(1) do |i|
    max_heapify(nodes, i)
  end

  puts " #{nodes[1..-1].join(' ')}"
end

Measured memory_bytes: 71324
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,m = LI()
    a = LIR(n)
    ans = 0
    for i in range(2):
        for j in range(2):
            for k in range(2):
                a.sort(key = lambda x:(-1)**i*x[0]+(-1)**j*x[1]+(-1)**k*x[2])
                p = [0,0,0]
                for l in range(m):
                    p[0] += a[l][0]
                    p[1] += a[l][1]
                    p[2] += a[l][2]
                p = abs(p[0])+abs(p[1])+abs(p[2])
                if p > ans:
                    ans = p
    print(ans)
    return

#B
def B():

    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#G
def G():

    return

#H
def H():

    return

#I
def I_():

    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 40048
#include <iostream>
#include <string>
int main() {
    std::string x;
    for (std::cin >> x; x != "0"; std::cin >> x) {
        int s = 0;
        for (auto&& c: x) {
            s += c - '0';
        }
        std::cout << s << std::endl;
    }
}



Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pii pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define traceloop(x,a) {for(ll i=0;i<x;i++) cerr<<a[i]<<" "; cerr<<endl;}
ll ab(ll x) {return x>0LL?x:-x;}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll n;
	cin>>n;
	vector<ll> v(n);
	for(int i=0; i<n; i++)
		cin>>v[i];
	stack<int> s;
	vector<ll> a(n,-1);
	for(int i=0; i<n; i++)
	{	
		while(!s.empty() && s.top()>=v[i])
			s.pop();
		if(s.empty())
			a[i]=-1;
		else
			a[i]=s.top();
		s.push(v[i]);
	}
	ll ans=0;
	for(int i=0; i<n; i++)
		if(a[i]==-1)
			ans++;
	cout<<ans;
	return 0;
}
	

Measured memory_bytes: 4224
use std::io;

fn main() {
  let mut line = String::new();
  io::stdin().read_line(&mut line)
    .expect("failed to read line");
  let ss: Vec<i32> = line.trim().split_whitespace()
    .map(|e| e.parse().unwrap()).collect();

  println!("{} {}", ss[0] * ss[1], ss[0] * 2 + ss[1] * 2)
}



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

int N;
int h[111111];
int dp[111111];
int main(){
    cin >> N;
    for(int i=0; i<N; i++)
        cin >> h[i];

    fill_n(dp, 111111, 1<<30);
    dp[0] = 0;
    for(int i=0; i<N; i++){
        dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1]-h[i]));
        dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2]-h[i]));
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	ll k;
	cin>>k;

	ll len = k/50,res = k%50;
	if(k==0){
		cout << 2 << endl;
		cout << 0 << " " << 0 << endl;
	}else if(k==1){
		cout << 2 << endl;
		cout << 2 << " " << 0 << endl;
	}else if(len==0){
		cout << k << endl;
		for(int i = 1; i <= k; i++){
			cout << i << " ";
		}printf("\n");
	}else{
		// cout << "len = " << len << endl;
		vector<ll> ans(50);
		for(int i = 0; i < 50; i++){
			ans[i] = i+1;
		}
		for(int i = 0; i < 50; i++){
			ans[i] += len-1;
		}
		int pos=49;
		while(res>0){
			ans[pos]++;
			res--;
			pos--;
		}
		cout << 50 << endl;
		for(int i = 0; i < 50; i++){
			cout << ans[i] << " ";
		}printf("\n");
	}


	return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 256
from itertools import product


def solve(string):
    ans = 0
    for i in range(3, len(string) + 1):
        tmp = ("".join(x) for x in product("753", repeat=i) if "7" in x and "5" in x and "3" in x)
        ans += len([x for x in tmp if len(x) < len(string) or x <= string])
    return str(ans)


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 48092
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int[] a=new int[n];
        for (int i = 0; i < n; i++) {
			a[i]=sc.nextInt();
		}
        int k=0;
        for (int i = 0; i < n; i++) {
			if(i%2==0&&a[i]%2==1){
				k++;
			}
		}
        System.out.println(""+k);
}
}

Measured memory_bytes: 38640
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
using namespace std;

typedef long long ll;
#define rep(i, a, b) for (ll i=(a); i<(b); i++)
#define all(obj) (obj).begin(), (obj).end()
#define fi first
#define sc second
#define pb push_back
#define str to_string
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
void chmax(ll &a, ll b) { a = max(a, b); }
void chmin(ll &a, ll b) { a = min(a, b); }

typedef tuple<int,int,int> P;
vector<string> grid;
vector<vector<ll>> L,R,U,D;
unordered_map<char,vector<int>> prep;
queue<P> que;
vector<tuple<int,int>> directions;
ll memo[1010][1010];
bool visited[1010][1010];

int main() {
    int H,W;
    ll ans;
    string s;
    memset(memo, -1, sizeof(memo));
    cin>>H>>W;
    grid.resize(H+2);
    grid[0]=string(W+2,'*');
    grid[H+1]=string(W+2,'*');
    rep(i,1,H+1) {
        cin>>s;
        grid[i]="*"+s+"*";
    }
    rep(i,1,H+1) rep(j,1,W+1) {
        if (grid[i][j]=='#') {
            que.push(make_tuple(i, j, 0));
        }
    }
    // 4方向の設定
    directions.pb(make_tuple(0,-1));
    directions.pb(make_tuple(0,1));
    directions.pb(make_tuple(-1,0));
    directions.pb(make_tuple(1,0));

    while(!que.empty()) {
        P cur=que.front(); que.pop();
        ll cur_t=get<0>(cur);
        int cur_h=get<0>(cur);
        int cur_w=get<1>(cur);
        int cost=get<2>(cur);
        // 訪問済チェック
        if (visited[cur_h][cur_w]) continue;
        visited[cur_h][cur_w]=true;
        memo[cur_h][cur_w]=cost;
        // 4方向見る
        for(tuple<int,int> dir: directions) {
            int nxt_h=cur_h+get<0>(dir);
            int nxt_w=cur_w+get<1>(dir);
            // 壁、黒はスキップ
            if (grid[nxt_h][nxt_w]=='*' || grid[nxt_h][nxt_w]=='#') continue;
            // 白を埋める
            if (grid[nxt_h][nxt_w]=='.') {
                grid[nxt_h][nxt_w]='#';
                que.push(make_tuple(nxt_h, nxt_w, cost+1));
            }
        }
    }
    ans=0;
    rep(i,1,H+1) rep(j,1,W+1) {
        chmax(ans, memo[i][j]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 23312
#include <bits/stdc++.h>
#include <cmath>
#include <functional>
#include <iostream>
using namespace std;

void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}

void foreach_comb(int n, int k, std::function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

int main() {
  vector<int> L;
  int N, num = 0;
  
  cin >> N;
  if(N < 3){
    cout << 0 << endl;
    return 0;
  }
  
  L.resize(N);
  for(int i = 0; i < N; i++)cin >> L[i];
  
  for(int i = 0; i < N; i++){
    for(int j = i+1; j < N; j++){
      for(int k = j+1; k < N; k++){
        if((L[i] == L[j]) || (L[i] == L[k]) || (L[j] == L[k]))continue;
        if(L[i] < L[j] + L[k] &&
           L[j] < L[k] + L[i] && 
           L[k] < L[i] + L[j])num++;
        }
    }
  }
  
  cout << num << endl;
  
  return 0;
}

Measured memory_bytes: 3624
K = int(input())

A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(A[K-1])

Measured memory_bytes: 3316
#include<iostream>

#include <stdio.h>


using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    
    int S[n];
    for(int i=0; i<n; i++){
        scanf("%d", &S[i]);
    }
    
    int q;
    scanf("%d", &q);
    
    int count=0;
    int temp;
    
    for(int i=0; i<q; i++){
        scanf("%d", &temp);
        for(int j=0; j<n; j++){
            if(temp==S[j]){
                count++;
                break;
            }
        }
    }
    printf("%d\n", count);
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
int vis[30100];
char ch[30010];
int vis2[200];
int vis3[30010][10];
int main(){
	int n;
	scanf("%d",&n);
	scanf("%s",ch+1);
	for(int i=n-1;i>=1;i--){
		if(!vis2[ch[i+1]-'0']){
			vis[i]=vis[i+1]+1;;
			vis2[ch[i+1]-'0']=1;
		}
		else vis[i]=vis[i+1];
	}
	memset(vis2,0,sizeof(vis2));
	for(int i=1;i<=n;i++){
		if(!vis2[ch[i]-'0']){
			vis2[ch[i]-'0']=1;
			vis3[0][ch[i]-'0']=i;
		}
	}
	memset(vis2,0,sizeof(vis2));
	for(int i=n;i>=1;i--){
		for(int j=0;j<=9;j++){
			if(ch[i]-'0'==j){
				vis3[i][j]=i;
			}
			else vis3[i][j]=vis3[i+1][j];
		}
		//vis3[i][ch[i]-'0']
	}

	long long ans=0;
	for(int i=1;i<=n;i++){
		if(!vis2[ch[i]-'0']){
			vis2[ch[i]-'0']=1;
			for(int j=0;j<=9;j++){
				int now=vis3[i][j];
				if(j==ch[i]-'0')now=vis3[i+1][j];
				ans=ans+vis[now];
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>

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

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;
int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<pair<ll, ll>>> G(n);
    for (int i = 0; i < m; ++i) {
        ll u, v; ll s;
        cin >> u >> v >> s;
        G[u-1].emplace_back(v-1, s);
        G[v-1].emplace_back(u-1, s);
    }
    vector<pair<ll, ll>> v(n, make_pair(0, 0));
    v[0] = make_pair(1, 0);
    pair<ll, ll> s {0, 0};
    queue<ll> q;
    q.emplace(0);
    while(!q.empty()){
        ll f = q.front(); q.pop();
        for (auto &&i : G[f]) {
            ll to, cost; tie(to, cost) = i;
            if(v[to].first == 0) {
                q.emplace(to);
                v[to] = make_pair(-v[f].first, cost-v[f].second);
            }else if(v[to].first != v[f].first){
                if(v[to].second != cost-v[f].second){
                    puts("0");
                    return 0;
                }
            }else {
                ll x = (cost-v[to].second-v[f].second);
                if((x+INF<ll>+1)%2 || x/(2*v[f].first) <= 0){
                    puts("0");
                    return 0;
                }else {
                    s = make_pair(2, x/(2*v[f].first));
                    while(!q.empty()) q.pop();
                    break;
                }
            }
        }
    }
    if(s == make_pair(0LL, 0LL)){
        ll a = 0, b = INF<ll>;
        for (int i = 0; i < n; ++i) {
            if(v[i].first > 0) a = max(a, -v[i].second);
            else b = min(b, v[i].second);
        }
        cout << max(b-a-1, 0LL) << "\n";
    }else {
        vector<ll> va(n, 0);
        va[0] = s.second;
        q.emplace(0);
        bool valid = true;
        while(!q.empty()){
            ll f = q.front(); q.pop();
            for (auto &&i : G[f]) {
                ll to, cost; tie(to, cost) = i;
                if(va[to]){
                    if(va[to]+va[f] != cost) valid = false;
                }else {
                    if(cost-va[f] <= 0) {
                        valid = false;
                    }else {
                        va[to] = cost - va[f];
                        q.emplace(to);
                    }
                }
            }
        }
        puts(valid ? "1" : "0");
    }
    return 0;
}


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

typedef long long int ll;

int MAX(int a, int b){return a>b?a:b;}
int MIN(int a, int b){return a>b?b:a;}
int compare(const void* a, const void* b){return *(int*)a - *(int*)b;}
ll llMAX(ll a, ll b){return a>b?a:b;}
ll llMIN(ll a, ll b){return a>b?b:a;}
ll digits(ll a){ll tmp=a; ll cnt=0; while(tmp>0){tmp/=10; cnt+=1;} return cnt;}

int main(void){
    int sx, sy, tx, ty;
    scanf("%d%d%d%d", &sx, &sy, &tx, &ty);

    int dx = tx-sx;
    int dy = ty-sy;

    // 1往復目
    // 行き
    for(int i=0; i<dx; i++){putchar('R');}
    for(int i=0; i<dy; i++){putchar('U');}
    // 帰り
    for(int i=0; i<dx; i++){putchar('L');}
    for(int i=0; i<dy; i++){putchar('D');}

    // 2往復目
    // 行き
    putchar('D');
    for(int i=0; i<dx+1; i++){putchar('R');}
    for(int i=0; i<dy+1; i++){putchar('U');}
    putchar('L');
    // 帰り
    putchar('U');
    for(int i=0; i<dx+1; i++){putchar('L');}
    for(int i=0; i<dy+1; i++){putchar('D');}
    putchar('R');

    printf("\n");
    return 0;
}

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

int main(){

    priority_queue<int> pq;
    string s;
    while(cin>>s && s!="end"){
        int num;
        if(s=="insert"){
            cin>>num;
            pq.push(num);
        }
        else{
            cout<<pq.top()<<endl;
            pq.pop();
        }
    }
}


Measured memory_bytes: 7040
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

import math
from collections import defaultdict

def main():
	n=II()
	#A=[]
	#B=[]
	d=defaultdict(int)

	for _ in range(n):
		x=float(input())
		x*=10**9
		x=int(x+0.5)
		g=math.gcd(x,10**9)
		#print(g)
		a=math.gcd(x//g,10**9)
		b=10**9//g
		#A.append(math.gcd(x//g,10**9))
		#B.append(10**9//g)
		d[(a,b)]+=1
	#print(A,B,d)

	ans=0

	for k,v in d.items():
		for kk,vv in d.items():
			if k!=kk:
				if (k[0]*kk[0])%(k[1]*kk[1])==0:
					#print(k,v,kk,vv)
					ans+=v*vv


	ans//=2

	for k,v in d.items():
		if k[1]==1:
			ans+=v*(v-1)//2

	print(ans)





















if __name__ == "__main__":
	main()


Measured memory_bytes: 68876
import math


def sushu(n):
    arr = []
    for i in range(2, n + 1):
        arr.append(i)

    limit = int(math.sqrt(n)) + 1

    prev = []
    while True:
        start = arr[0]
        prev.append(start)
        if start > limit:
            break
        brr = []
        for i in arr:
            if i % start != 0:
                brr.append(i)
        arr = brr

    prev.extend(arr)
    return prev


n = 100000
shushu = sushu(100000)

marks = []
for i in range(n + 1):
    marks.append(False)

for j in shushu:
    marks[j] = True

marks2 = []
result = []
for i in range(n + 1):
    if i % 2 == 0:
        marks2.append(False)
        if i == 0:
            result.append(0)
        else:
            result.append(result[i - 1])
    else:
        if marks[(i + 1) // 2] and marks[i]:
            marks2.append(True)
            result.append(result[i - 1] + 1)
        else:
            marks2.append(False)
            result.append(result[i - 1])

Q = 4
ARR = [
    [13, 13],
    [7, 11],
    [7, 11],
    [2017, 2017]
]

Q = 6
ARR = [
    [1, 53],
    [13, 91],
    [37, 55],
    [19, 51],
    [73, 91],
    [13, 49]
]

Q = int(input())

ARR = []

for i in range(Q):
    ARR.append(list(map(int, input().split())))

for i in range(Q):
    start = ARR[i][0]
    end = ARR[i][1]
    print(result[end] - result[start - 1])


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

#define N 100
#define M 1000
#define INT(X) \
  ( *( (const int *)(X) ) )

int comparator (
  const void  * a,
  const void  * b
  )
{
  return ( INT( b ) - INT( a ) );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    struct tagD
    {
      int h;
      int p;
      int q;
    } d[ M ];
    int n, m, a;

    scanf ( "%d%d%d", &n, &m, &a );
    if ( !( n | m | a ) ) break ;

    for ( i = 0; i < m; ++i )
    {
      scanf ( "%d%d%d", &d[ i ].h, &d[ i ].p, &d[ i ].q );
    }
    qsort ( d, m, sizeof ( struct tagD ), comparator );

    for ( i = 0; i < m; ++i )
    {
      if ( d[ i ].p == a )
      {
        a = d[ i ].q;
      }
      else if ( d[ i ].q == a )
      {
        a = d[ i ].p;
      }
    }

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

  return ( 0 );
}

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

struct edge{int from, to;};
int G[50][50];
int n, m;

void dfs(int s, int a, int b, vector<int>& reached) {
    if(reached[s] > 0) return;
    reached[s]++;
    for(int i = 0; i < n; i++) {
        if(s == a && i == b) continue;
        if(s == b && i == a) continue;
        if(G[s][i] > 0) dfs(i, a, b, reached);
    }
}

int main() {
    cin >> n >> m;
    vector<edge> es(m);
    vector<int> reached(n, 0);
    for(auto& e : es) {
        cin >> e.from >> e.to;
        e.from--; e.to--;
        G[e.from][e.to]++;
        G[e.to][e.from]++;
    }

    int ans = 0;
    for(auto e : es) {
        int a = e.from, b = e.to;
        fill(reached.begin(), reached.end(), 0);
        dfs(0, a, b, reached);
        for(auto i : reached) {
            if(i == 0) {
                ans++;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main(){
  int n, a, b;
  cin >> n >> a >> b;

  cout << min(a*n, b) << endl;

  return 0;
}


Measured memory_bytes: 256
import numpy as np
D = int(input())
C = np.array(list(map(int, input().split())))
S = np.zeros((D,26),int)
for i in range(0,D):
    S[i] = list(map(int, input().split()))

N = (C/np.sum(C)*D)
MN = np.argmax(N)
# print(N)
N = np.floor(N)
N[MN] += D-np.sum(N)
# print(N)
# print(np.sum(N))

Plan = np.zeros(D,int)
num = np.arange(D).reshape(D,-1)
# print(num)
S = np.hstack((S,num)).T
# print(S)

test=list()
for i in range(26):
    for j in range(int(N[i])):
        test.append(int(i))

# print(test)
for i in test:
    l = np.argmax(S[i])
    # print(S[26,l])
    Plan[S[26,l]] = i
    S = np.delete(S,l,1)
# print(Plan)

[print(i+1) for i in Plan]

Measured memory_bytes: 27608
#pragma GCC optimize("Ofast")
#include <cstring>
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    ll N, M, bday, A;
    int i;

    cin >> N >> M;

    for(i=0; i<M; i++) {
        cin >> A;
        N -= A;
    }

    if(N<0) {
        cout << "-1";
    } else{
        cout << N;
    }

}

Measured memory_bytes: 3584
/**
 * Created by Sakib on 06/11/2018.
 */
#include <bits/stdc++.h>
using namespace std;

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(args...) { dbg,args; cerr<<"\n"; }
struct debugger{
template<typename T>debugger& operator,(const T& v){cerr<<v<<" ";return *this;}}dbg;

#define Fix( x ) setprecision( x ) << fixed
#define mem( a , x ) memset( a , x , sizeof( a ) )
#define bug( a , b ) cerr<< #a <<" = "<<a<<" , "<< #b <<" = "<<b<<"\n";
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define FOR( i , a , b ) for( int i = a; i <= b; i++ )
#define ROF( i , a , b ) for( int i = a; i >= b; i-- )
#define sz( V ) (int)V.size( )
#define all( V ) V.begin( ),V.end( )
#define Found( S , val ) S.find( val ) != S.end( )
#define Unique( V ) sort( all( V ) ), V.erase( unique( all( V ) ), V.end() )
typedef pair < int , int > ii;
typedef pair < int , ii > iii;
typedef long long int LL;
typedef unsigned long long uLL;
const int inf = (int)1e9;
const LL INF = (LL)1e18;
const int N = 100005;
const int mod = 1000000007;
const double eps = 1e-8;
const double pi = acos( -1.0 );


int main( int argc, char const *argv[] ) {
    fast_io;
    int a , b;
    cin >> a >> b;
    FOR( i , 1 , 999 ) {
        LL x = 1LL*i*(i+1)/2 , y = 1LL*(i+1)*(i+2)/2;
        if( x-a == y-b ) return cout << x-a << endl,0;
    }
    return 0;
}











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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

#define MAXN 500005

int ti = 0, num[MAXN], low[MAXN];
bool visited[MAXN];
vector<int> adj[MAXN];
vector<vector<int>> ret;
stack<int> st;

void dfs(int u) {
    num[u] = low[u] = ti++;
    st.push(u);
    visited[u] = true;
    for (int v : adj[u]) {
        if (num[v] == -1)
            dfs(v);
        if (visited[v])
            low[u] = min(low[u], low[v]);
    }

    if (low[u] == num[u]) {
        int v = -1;
        ret.emplace_back();
        while (u != v) {
            v = st.top();
            st.pop();
            visited[v] = false;
            ret.back().push_back(v);
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, m;
    cin >> n >> m;
    for (int i=0; i<m; i++) {
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
    }

    memset(num, -1, sizeof(num));
    for (int i=0; i<n; i++)
        if (num[i] == -1)
            dfs(i);

    cout << ret.size() << "\n";
    reverse(ret.begin(), ret.end());
    for (auto &v : ret) {
        cout << v.size();
        for (int u : v)
            cout << " " << u;
        cout << "\n";
    }

    return 0;
}


Measured memory_bytes: 58372
#include <stdio.h>

int main(void)
{
    int n ,j ,i ,o ,cnt=1;
    scanf("%d",&n);
    for(j=0;j<n;j++){
        scanf("%d %d" ,&i ,&o);
        printf("%d" ,i);
        if(i<o||(i>5&&i<10)){
            while(1){
                if(i>=9){
                    i=6;
                    cnt *= -1;
                }
                if(i==0&&cnt<0){
                    cnt *= -1;
                }
                i += cnt;
                printf(" %d" ,i);
                if(i==o){
                    cnt = 1;
                    break;
                }
            }
            puts("");
        }else if(i==o){
            puts("");
        }else{
            cnt *= -1;
            while(1){
                i += cnt;
                printf(" %d" ,i);
                if(i==o){
                    cnt = 1;
                    break;
                }
            }
            puts("");
        }
    }
    return 0;
}

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

int main(void)
{
	long long n, m, ans, sum, dis;
	pair<long long, long long> p[50], q[50];

	cin >> n >> m;
	rep(i, n) cin >> p[i].first >> p[i].second;
	rep(i, m) cin >> q[i].first >> q[i].second;
	rep(i, n)
	{
		sum = abs(p[i].first - q[0].first) + \
			  abs(p[i].second - q[0].second);
		ans = 1;
		rep(j, m)
		{
			dis = abs(p[i].first - q[j].first) + \
				  abs(p[i].second - q[j].second);
			if (sum > dis)			
			{
				sum = dis;
				ans = j + 1;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define pri 1000000000000007

using namespace std;

int main() {
	ll n;
	cin>>n;
	ll a[n],h[n];
	for(ll i=0;i<n;i++)cin>>h[i];
	for(ll j=0;j<n;j++)cin>>a[j];
set < pair<ll,ll> > go;
	go.insert(MP(0,0));
	go.insert(MP(pri,pri));
	//cout<<n<<endl;
	for(ll i=0;i<n;i++){
		auto j=go.lower_bound(MP(h[i],0));
	//	cout<<i<<endl;
		j--;
		ll v=(j->ss)+a[i];
		go.insert(MP(h[i],v));
		ll un=1;
		while(un){
			auto s=go.upper_bound(MP(h[i],v));
			pair<ll,ll> se=*s;
			
			if((se.ss)<v){go.erase(s);}
			
			else un=0;
			
		}
		//cout<<"b";
	}
//	cout<<"b";
	auto ze=go.lower_bound(MP(pri,pri));
	ze--;
	ll x=(*ze).ss;
	cout<<x;
	// your code goes here
	return 0;
}

Measured memory_bytes: 15872
import java.util.*;

public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();

        int a = sc.nextInt();
        int b = sc.nextInt();
        for(int i=a; i<=b; i++) {
            if(i%k == 0) {
                System.out.println("OK");
                return;
            }
        }
        System.out.println("NG");
    }
}

Measured memory_bytes: 35736
n = int(input())
a = list(map(int, input().split()))
ans = [0] * (10**5+3)

for i in range(n):
    mini, mid, maxi = a[i], a[i]+1, a[i]+2
    ans[mini] += 1;  ans[mid] += 1;  ans[maxi] += 1

print(max(ans))

Measured memory_bytes: 13964
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
using namespace std;

int a,b,c;

int main(){
	int cnt = 0;
	cin >> a >> b >> c;
	for(int i=a;i<b+1;i++){
		if(c%i==0) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 1160
x, y = map(int, input().split())
group = {
    1:1,
    3:1,
    5:1,
    7:1,
    8:1,
    10:1,
    12:1,
    4:2,
    6:2,
    9:2,
    11:2,
    2:3
}
if group[x] == group[y]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
n,m=map(int,input().split())
k=[0]*m
s=[set() for i in range(m)]
for i in range(m):
  k[i],*t=map(int,input().split())
  for j in range(k[i]):
    s[i].add(t[j]-1)
ans=0
p=list(map(int,input().split()))
for i in range(2**n):
  switch=[0]*n
  flag=True
  for j in range(n):
    if i>>j&1:
      switch[j]=1
  for j in range(m):
    on_cnt=0
    for k in range(n):
      if switch[k]==1 and k in s[j]:
        on_cnt+=1
    if on_cnt%2!=p[j]:
      flag=False
      break
  if flag:
    ans+=1
print(ans)

Measured memory_bytes: 3064
a,b,c = map(int,input().split())
k = int(input())

while k>=1:
    if a>=b:
        k-=1
        b*=2
    else:
        break
while k>=1:
    if b>=c:
        k-=1
        c*=2
    else:
        break

if a<b<c:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9172
#include<bits/stdc++.h>
#define rep(i,n,k) for(long long int i=k; i<n; ++i)
#define drep(i,n,k) for(long long int i=n-1; i>=k; --i)
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n-1);
  rep(i,n,0) cin >> a[i];
  rep(i,n,0) cin >> b[i];
  rep(i,n-1,0) cin >> c[i];
  
  long long int ans = 0;
  rep(i,n,0){
    ans += b[a[i]-1];
  }
  rep(i,n-1,0){
    if(a[i+1]-a[i] == 1){
      ans += c[a[i]-1];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
# intin = map( int, readline().rstrip().split() )

N = int(input())
S = input()

# 10^4 * 10^3 * 3 = 3* (10 ^7)

ans = 0
for x in range(0,1000):
    x = str(x)
    if len(x) == 1:
        x = "00" + x
    elif len(x) == 2 :
        x = "0" + x
    index = 0
    for s in S:
        if x[index] == s:
            index += 1
        if index == 3:
            ans += 1
            break

print(ans)


Measured memory_bytes: 41884
import java.util.*;

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

      int n = sc.nextInt();

      int ans = 0;

      int[] h = new int[n];

      for(int i=0;i<n;i++){
        h[i] = sc.nextInt();
      }

      int check=0;

      for(int i=0;i<n-1;i++){
        if(h[i]>=h[i+1]){
          check++;
        }
        if(h[i]<h[i+1]){
          ans = Math.max(ans,check);
          check = 0;
        }
      }
      /*
      if(h[n-2]>=h[n-1]){
        check++;
      }
      */

      ans = Math.max(ans,check);


      System.out.println(ans);

    }
}


Measured memory_bytes: 50532
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        int a,b,c,d = 0;
        
        Scanner scan = new Scanner(System.in);
        a = scan.nextInt();
        b = scan.nextInt();
        c = scan.nextInt();
        
       
           if(a > b){
               d = a;
               a = b;
               b = d;
           }
           
           if(b > c){
               d = b;
               b = c;
               c = d;
           }
           
           if(a > b){
               d = a;
               a = b;
               b = d;
           }
           
           
              System.out.println(a + " " + b + " " + c);
           
         }
}


Measured memory_bytes: 26204
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int n; cin>>n;
  vector<int> l(10005);
  for(int x = 1 ; x <= 105; x++)
    for(int y = 1 ; y <= 105;y++)
      for(int z = 1 ; z <= 101 ; z++)
        if(x*x + y*y + z*z + x*y + y*z + z*x < 10005)
          l[x*x + y*y + z*z + x*y + y*z + z*x]++;
  for(int i = 1 ; i <= n ; i++)
  {cout<<l[i]<<endl;}
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <utility>
#include <string>
typedef unsigned long ul;

using namespace std;

int main(){
	int len;
	string str;
	cin >> str;
	len = str.length();
	for(int i = len-1; i >= 0; i--){
		cout << str.at(i);
	}
	cout << endl;
}

Measured memory_bytes: 1172
import java.util.*;
public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n,a,b;
        n = sc.nextInt();
        a = sc.nextInt();
        b = sc.nextInt();
        int r = 0;
        for(int i = 1; i <= n; i++){
            int c = 0, t = i;
            for(int j = 0; j < 5; j++){
                c = c + (t % 10);
                t = t / 10;
            }
            if(a <= c && c<= b){
                r = r + i;
            }
        }
        System.out.println(r);    
            
    }
}

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

int main() {
  int H,W;
  cin>>H>>W;
  vector<vector<char>> S(H,vector<char>(W));
  rep(i,H){
    rep(j,W){
      cin>>S.at(i).at(j);
    }
  }
  
  vector<int> ans(0);
  
  rep(m,H){
    rep(n,W){
      if(S.at(m).at(n)=='.'){
        //S.at(m).at(n)=='s';
        vector<vector<int>> distance(H,vector<int>(W,-1));
        distance.at(m).at(n)=0;
        
        
        
  queue<pair<int,int>> que;
  que.push({m,n});
  while(!que.empty()){
    pair<int,int> v=que.front();
    que.pop();
    int i,j;
    i=v.first;
    j=v.second;
    
    if(0<=i+1 && i+1<H && 0<=j && j<W && distance.at(i+1).at(j)==-1 && S.at(i+1).at(j)=='.'){
      distance.at(i+1).at(j)=distance.at(i).at(j)+1;
      que.push({i+1,j});
    }
    if(0<=i-1 && i-1<H && 0<=j && j<W && distance.at(i-1).at(j)==-1 && S.at(i-1).at(j)=='.'){
      distance.at(i-1).at(j)=distance.at(i).at(j)+1;
      que.push({i-1,j});
    }
    if(0<=i && i<H && 0<=j+1 && j+1<W && distance.at(i).at(j+1)==-1 && S.at(i).at(j+1)=='.'){
      distance.at(i).at(j+1)=distance.at(i).at(j)+1;
      que.push({i,j+1});
    }
    if(0<=i && i<H && 0<=j-1 && j-1<W && distance.at(i).at(j-1)==-1 && S.at(i).at(j-1)=='.'){
      distance.at(i).at(j-1)=distance.at(i).at(j)+1;
      que.push({i,j-1});
    }
  }
  rep(k,H){
    rep(l,W){
      ans.push_back(distance.at(k).at(l));
      
      //test
      //cout<<distance.at(k).at(l)<<" ";
    }
  }
        
        
        
        //S.at(m).at(n)=='.';
      }
    }
  }
  
  /*test
  rep(i,ans.size()){
    cout<<ans.at(i)<<" ";
  }
  cout<<endl;*/
  
  sort(ans.begin(),ans.end());
  reverse(ans.begin(),ans.end());
  cout<<ans.at(0)<<endl;
  
  
}





Measured memory_bytes: 1404
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    vector<vector<int>> c(3,vector<int>(3,0));
    for(auto &x:c)for(auto &y:x)cin >> y;

    vector<int> a(3,0),b(3,0);
    bool ans=false;
    for(b[0]=0;b[0]<100;b[0]++){
        a[0]=c[0][0]-b[0];
        a[1]=c[0][1]-b[0];
        a[2]=c[0][2]-b[0];
        b[1]=c[1][0]-a[0];
        if(b[1]!=c[1][1]-a[1] || b[1]!=c[1][2]-a[2])continue;
        b[2]=c[2][0]-a[0];
        if(b[2]!=c[2][1]-a[1] || b[2]!=c[2][2]-a[2])continue;
        else{
            ans=true;
            break;
        }
    }

    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdtr1c++.h>

using namespace std;

#define INP "solve"
#define OUT "solve"

const int QQ = 3e5 + 10;
const int maxN = 2e5;
const int maxM = 3e5 + 10;
const int oo = 2e9;
const int module = 1e9 + 7;
const long double du = 1e-9;

void doc() {
    freopen(INP ".inp","r",stdin);
    freopen(OUT ".out","w",stdout);
}

void solve() {
    int n;
    cin >> n;
    int m = 1 << n;
    int a[m];
    for (int i = 0; i < m; i++) cin >> a[i];
    sort(a, a + m, greater<int>());
    //for (int i = 0; i < m; i++) cout << a[i] << '\n';
    multiset <int> S;
    for (int i = 1; i < m; i++) S.insert(a[i]);
    multiset <int> A;
    A.insert(a[0]);
    for (int i = 0; i < n; i++) {
        vector <int> B;
        for (int x : A) B.push_back(x);
        reverse(B.begin(), B.end());
        int SL = 1 << i;
        //cout << (int)B.size() << '\n';
        for (int x : B) {
            auto Pos = S.lower_bound(x);
            if (Pos == S.begin()) {
                cout << "No";
                return;
            }
            Pos--;
            //cout << x << " " << *Pos << '\n';
            A.insert(*Pos);
            S.erase(Pos);
        }
    }
    cout << "Yes";
}
int main(int argc,char *argv[]) {
    //srand(time(nullptr));
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //doc();
    solve();
}


Measured memory_bytes: 15996
#include<iostream>
#include<deque>
#include<queue>
#include<cstring>

#define INF 10000000

using namespace std;

char ban[1001][1001];
int d[1001][1001];			//en_ÜÅÌÅZ£


class mouse
{
	public:
	mouse(int xx, int yy, int p, int c){
		x = xx;
		y = yy;
		pow = p;
		cont = c;
	}
	int x, y;		//»ÝÀW
	int pow;		//ÌÍ
	int cont;		//è
	
};


int h, w, c;

int main()
{
	int st_y, st_x;
	int g_x, g_y;
	int vec[2] = {-1,1};
	
	cin >> h >> w >> c;
	
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> ban[i][j];
			if(ban[i][j] == 'S'){
				st_y = i;
				st_x = j;
			}
			if(ban[i][j]-48 == c){
				g_x = j;
				g_y = i;
			}
			d[i][j] = INF;
		}
	}
	
	queue<mouse> Q;
	
	Q.push(mouse(st_x, st_y, 1, 0));
	d[st_x][st_y] = 0;
	
	int cont = 1;
	int tesu = 0;
	
	while(1)
	{
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				d[i][j] = INF;
			}
		}
		
		while(1)
		{
			mouse temp = Q.front();
			Q.pop();
			
			if(ban[temp.y][temp.x]-48 == cont){
				tesu += d[temp.y][temp.x];
//				printf("±±ÜÅÌèF%d\n",d[temp.y][temp.x]);
						
				while(!Q.empty()){
					Q.pop();
				}
				Q.push(mouse(temp.x, temp.y, 0, 0));
				break;
			}
			
			//óÔ¶¬
			for(int i = 0; i < 2; i++){
				if(temp.x + vec[i] > -1 && temp.x + vec[i] < w && d[temp.y][temp.x+vec[i]] == INF && ban[temp.y][temp.x+vec[i]] != 'X'){
					Q.push(mouse(temp.x+vec[i],temp.y,temp.pow,temp.cont+1));
					d[temp.y][temp.x+vec[i]] = temp.cont+1;
					
//					printf("x:%d y:%d cont:%d\n",temp.x+vec[i],temp.y,temp.cont+1);
				}
				if(temp.y + vec[i] > -1 && temp.y + vec[i] < h && d[temp.y+vec[i]][temp.x] == INF && ban[temp.y+vec[i]][temp.x] != 'X'){
					Q.push(mouse(temp.x,temp.y+vec[i],temp.pow,temp.cont+1));
					d[temp.y+vec[i]][temp.x] = temp.cont+1;
					
//					printf("x:%d y:%d cont:%d\n",temp.x,temp.y+vec[i],temp.cont+1);
				}
			}
		}
		cont++;
		
		if(cont-1 == c){
			break;
		}

	}
	
	cout << tesu << endl;
}

Measured memory_bytes: 5764
import numpy as np

def bingo(A):
    for i in range(3):
        if (A[i,0] == 0) and (A[i,1] == 0) and (A[i,2] == 0):
            return True
        
        if (A[0,i] == 0) and (A[1,i] == 0) and (A[2,i] == 0):
            return True
    
    if A[1, 1] == 0:
        if (A[0, 0] == 0) and (A[2, 2] == 0):
            return True
        if (A[0, 0] == 0) and (A[2, 2] == 0):
            return True
        if (A[2, 0] == 0) and (A[0, 2] == 0):
            return True
        if (A[2, 0] == 0) and (A[2, 0] == 0):
            return True
    else:
        return False
    
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
A1 = np.array(A1)
A2 = np.array(A2)
A3 = np.array(A3)
A = np.array([A1,A2,A3])

n = int(input())


for i in range(n):
    b = int(input())
    A = np.where(A == b, 0, A)

if bingo(A) == True:
    print("Yes")

else:
    print("No")

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

#define int long long int
#define MOD 1000000007

int dp[3005][3005] ;

int32_t main()
{
    int t = 1 ;
    //cin >> t ;
    while(t--)
    {
        string s, t, ans = "" ;
        cin >> s >> t ;
        int sn = s.length() ;
        int tn = t.length() ;
        for(int i = 1 ; i <= sn ; i++)
        {
            for(int j = 1 ; j <= tn ; j++)
            {
                if(s[i-1] == t[j-1])
                {
                    dp[i][j] = 1 + dp[i-1][j-1] ;
                    //ans += s[i-1] ;
                }
                else
                {
                    dp[i][j] = max(dp[i-1][j], dp[i][j-1]) ;
                }
            }
        }
        while(sn and tn)
        {
            if(s[sn-1] == t[tn - 1])
            {
                ans += s[sn-1] ;
                sn-- ; tn-- ;
            }
            else if(dp[sn-1][tn] > dp[sn][tn-1])
            {
                sn-- ;
            }
            else
            {
                tn--;
            }
        }
        reverse(ans.begin(), ans.end()) ;
        //cout << dp[sn][tn] << " " << ans ;
        cout << ans ;                
    }
    return 0 ;
}

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

using namespace std;
int a[100005],b[100005],c[100005];
int dp[100005][5];
int main(){
	int n;
    cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	dp[1][1]=a[1],dp[1][2]=b[1],dp[1][3]=c[1];
	for(int i=2;i<=n;i++){
		dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a[i];
		dp[i][2]=max(dp[i-1][1],dp[i-1][3])+b[i];
		dp[i][3]=max(dp[i-1][1],dp[i-1][2])+c[i];
	}
	/*for(int i=1;i<=n;i++){
		for(int j=1;j<=3;j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;*/
	cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));
	return 0;
} 

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define PF first
#define PS second
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;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl;
#define OUTD(x) cout << fixed << x << endl;
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 1000000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};

ll dp[1001][1001];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  IN(ll,A);
  IN(ll,B);
  IN(ll,C);
  bool ans = false;
  if(A == B + C || A + B == C || A + C == B)
    ans = true;
  BOUT(ans);
}



Measured memory_bytes: 256
n, m = map(int, input().split())
info = [list(map(int, input().split())) for i in range(m)]

memo = {}
for i in range(m):
    if info[i][0] not in memo:
        memo[info[i][0]] = 1
    else:
        memo[info[i][0]] += 1
    if info[i][1] not in memo:
        memo[info[i][1]] = 1
    else:
        memo[info[i][1]] += 1
for i in memo:
    if memo[i] % 2 == 1:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 66136
#include <bits/stdc++.h>
using namespace std;
#define endl            "\n"
#define ll                long long
#define all(v)            ((v).begin()), ((v).end())
#define sz(v)            ((int)((v).size()))
#define clr(v, d)        memset(v, d, sizeof(v))
#define rep(i, v)        for(int i=0;i<sz(v);++i)
#define lp(i, n)        for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)    for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)    for(int i=(j);i>=(int)(n);--i)
#define vi                vector <int>
#define vl                vector <ll>
#define ii                pair <ll,ll>
#define vii                vector <ii>
const double PI = 2 * acos(0.0);
void run() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
}
int n, m;
string s, t;
int dp[3000 + 3][3000 + 3];
int optimal;
int sol(int i, int j) {
	if (i == n || j == m)
		return 0;
	int &ret = dp[i][j];
	if (~ret)
		return ret;
	if (s[i] == t[j])
		return ret = 1 + sol(i + 1, j + 1);
	else
		return ret = max(sol(i + 1, j), sol(i, j + 1));
}
void build(int i, int j) {
	if (i == n || j == m)
		return;
	optimal = sol(i, j);
	if (s[i] == t[j]) {
		cout << s[i];
		build(i + 1, j + 1);
	} else {

		int ch1 = sol(i + 1, j);
		if (optimal == ch1)
			build(i + 1, j);
		else
			build(i, j + 1);

	}
}
int main() {
	run();
	cin >> s >> t;
	clr(dp, -1);
	n = sz(s), m = sz(t);
	sol(0, 0);
	build(0, 0);
}


Measured memory_bytes: 35840