akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
	FastScanner in;
	PrintWriter out;

	int n, m;
	double[][] p;

	double f(double A) {
		double touristWin = 0;
		for (int i = 0; i < 6; i++) {
			touristWin += Math.max(p[0][i] * A, p[1][i] * (1 - A));
		}
		return touristWin;
	}

	void solve() {
		n = 2;
		m = 6;
		p = new double[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				p[i][j] = in.nextInt() / 100.0;
			}
		}
		double res = Double.MAX_VALUE;
		double eps = 1e-4;
		for (double A = 0.0; A < 1; A += eps) {
			double l = A, r = A + eps;
			for (int it = 0; it < 50; it++) {
				double m1 = l + (r - l) / 3;
				double m2 = r - (r - l) / 3;
				double f1 = f(m1), f2 = f(m2);
				if (f1 < f2) {
					r = m2;
				} else {
					l = m1;
				}
			}
			res = Math.min(res, f((l + r) / 2));
		}
		out.println(res);
	}

	void run() {
		try {
			in = new FastScanner(new File("object.in"));
			out = new PrintWriter(new File("object.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
				new Main().runIO();
			}
		}, "1", 1 << 26).start();
	}
}

Measured memory_bytes: 10468
N,M = map(int,input().split())
L = [list(map(int,input().split())) for _ in range(N)]


class UnionFind:
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0] * (n+1)
        self.root = [-1]*(n+1)
        self.cnt = 0

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    
    def groupsize(self):
        self.cnt = 0
        for i,x in enumerate(self.par):
            if x == i:
                self.cnt += 1
        return self.cnt

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.root[x] += self.root[y]
            self.root[y] = self.root[x]
        else:
            self.par[y] = x
            self.root[x] += self.root[y]
            self.root[y] = self.root[x]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
    def count(self, x):
        return -self.root[self.find(x)]
    
    
uf = UnionFind(M)
for lk in L:
    l = lk[1:]
    if len(l) > 0:
        base = l[0]-1
        for i in range(1,len(l)):
            uf.union(base,l[i]-1)
            
isUsed = [False] * M
for lk in L:
    for l in lk[1:]:
        isUsed[l-1] = True


looplist = [i for i in range(M) if isUsed[i]]
tmp1 = looplist[0]
for i in looplist[1:]:
    if not(uf.same_check(tmp1,i)):
        print('NO')
        break
else:
    print('YES')
        







        
        
        
    




Measured memory_bytes: 82136
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

#define REP(i,m,M) for(int i=m; i<M; i++)
#define REPR(i,M,m) for(int i=M; i>m; i—-)
#define REPLL(i,m,M) for(ll i=m; i<M; i++)
#define REPLLR(i,M,m) for(ll i=M; i>m; i—-)
#define ALL(v) v.begin(),v.end()

int N;
ll A[300000];

int main(int argc, const char * argv[]) {
    cin >> N;
    for (int n = 0; n < N; ++n) {
        cin >> A[n];
    }
    
    vll v;
    ll tmp = 0;
    v.push_back(0);
    for (int n = 0; n < N; ++n) {
        tmp += A[n];
        v.push_back(tmp);
    }
    
    sort(v.begin(), v.end());
    
    
    tmp = v[0];
    ll res = 0;
    vll v2;
    for(int i = 1; i <= N; ++i){
        if (v[i] == tmp){
            res++;
        }
        else {
            if(res != 0){
                v2.push_back(res);
                res = 0;
            }
            tmp = v[i];
        }
    }
    if (res != 0) v2.push_back(res);
    res = 0;
    for (int i = 0; i < v2.size(); ++i) {
        //cerr << v2[i] << " ";
        res += (v2[i]*(v2[i]+1))/2;
    }
    //cerr << endl;

    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 3956
#!/mnt/c/Users/moiki/bash/env/bin/python
# N,M = map(int, input().split())
N = int(input())
trains = [ [int(j) for j in input().split()] for _ in range(N-1)] 


for i in range(0,N):
    ans_i = 0
    for j in range(i, N-1):
        c,s,f = trains[j]
        ans_i = max(ans_i, s)
        if not ans_i % f == 0:
            ans_i += f - ans_i%f
        ans_i += c

        # ans_i += c + (f - ans_i%f)%f 
    print(ans_i)

exit(0)



Measured memory_bytes: 3188
package main

import (
        "fmt"
        "sort"
)

type Order []int

func (o Order) Len() int {
        return len(o)
}

func (o Order) Swap(i, j int) {
        o[i], o[j] = o[j], o[i]
}

func (o Order) Less(i, j int) bool {
        if o[i]%10 == 0 {
                return true
        }
        return o[i]%10 > o[j]%10
}

func solution(order Order) int {
        sort.Sort(order)
        out := 0
        for i := 0; i < 4; i++ {
                t := 0
                if order[i]%10 == 0 {
                        t = order[i]
                } else {
                        t = order[i] + 10 - order[i]%10
                }
                out += t
        }
        return out + order[4]
}

func main() {
        order := make(Order, 0, 5)
        for i := 0; i < 5; i++ {
                n := 0
                fmt.Scan(&n)
                order = append(order, n)
        }
        fmt.Println(solution(order))
}

Measured memory_bytes: 512
#include <cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;++i)

const int N=2005;
const int P=924844033;
int n,k,a[N],fac[N];
long long f[N][N][2][2];
bool vis[N];

int main() {
    scanf("%d%d",&n,&k);
    fac[0]=1;
    FOR(i,1,n) fac[i]=1LL*fac[i-1]*i%P;
    int tot=0;
    FOR(i,1,n) if(!vis[i]) for(int j=i;j<=n;j+=k) vis[j]=1,a[++tot]=j;
    f[0][0][0][0]=1;
    a[0]=-(1<<30);
    FOR(i,1,n) {
        f[i][0][0][0]=1;
        FOR(j,1,i) {
            f[i][j][0][0]=(f[i-1][j][1][0]+f[i-1][j][0][0]+(a[i]-a[i-1]==k)*f[i-1][j-1][0][0])%P;
            f[i][j][0][1]=(a[i+1]-a[i]==k)*(f[i-1][j-1][1][0]+f[i-1][j-1][0][0])%P;
            f[i][j][1][0]=(f[i-1][j][0][1]+f[i-1][j][1][1]+(a[i]-a[i-1]==k)*f[i-1][j-1][0][1])%P;
            f[i][j][1][1]=(a[i+1]-a[i]==k)*(f[i-1][j-1][0][1]+f[i-1][j-1][1][1])%P;
        }
    }
    int ans=0;
    FOR(i,0,n) {
        int sum=(f[n][i][0][0]+f[n][i][0][1]+f[n][i][1][0]+f[n][i][1][1])%P;
        if(i&1) (ans+=P-1LL*sum*fac[n-i]%P)%=P;
        else (ans+=1LL*sum*fac[n-i]%P)%=P;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 71920
def gcd(m, n):
	if m % n == 0:
		return n
	return gcd(n, m % n)

def resolve():
	n = int(input())
	ans = 0
	for i in range(1, n+1):
		for j in range(1, n + 1):
			for k in range(1, n + 1):
				ans += gcd(i, gcd(j, k))
	print(ans)

resolve()

Measured memory_bytes: 76852
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

# N =I()
a,b= LI()
#AB = [LI() for _ in range(N)]
#A,B = zip(*AB)
#Ap = np.array(A)
#C = np.zeros(N + 1)

def generateStr(s,n):
    result = ''
    temp = str(s)
    for _ in range(n):
        result += temp 
    return result

a_str = generateStr(a,b)
b_str = generateStr(b, a)

if a_str<b_str:
    print(a_str)
else:
    print(b_str)

Measured memory_bytes: 27148
#include <iostream>
#include <algorithm>
#define MAX 50000
using namespace std;
int a,b,d,cntA,cntB;

void cal(){
  for(int i=0;i<MAX;i++){
    int A=i,B=abs((a*i)/b-d/b);
    if((a*i)%b==d%b && cntA+cntB>A+B)cntA=A,cntB=B;
    
    A=abs((b*i)/a-d/a),B=i;
    if((b*i)%a==d%a && cntA+cntB>A+B)cntA=A,cntB=B;
  }
}

int main(){
  while(1){
    cin>>a>>b>>d;
    if(!a&&!b&&!d)break;
    cntA=cntB=MAX;
    cal();
    cout <<cntA<<" "<<cntB<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int a, b, c, k; cin >> a >> b >> c >> k;
    if (k <= a) {
        cout << k << endl;
    } else if (k <= a + b) {
        cout << a << endl;
    } else {
        cout << a - (k - a - b) << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;

#define PB push_back
#define MP make_pair

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long LL;
typedef pair<int,int> PII;

const int N =100303;
const LL inf = (LL) 1<<40;
#define mod 1000000007
//437001103351396 10int

int f[N];
struct node
{
    int id,val;
}a[N],b[N];

struct edge
{
    int x,y,val;
}c[N*2];

int find(int x)
{
    if (f[x]!=x) f[x]=find(f[x]);
    return f[x];
}

int cmp(node a,node b)
{
    return a.val<b.val;
}
int cmp2(edge a,edge b)
{
    return a.val<b.val;
}

int main()
{
    int n;
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        int x,y;
        cin>>x>>y;
        a[i].id=i;
        a[i].val=x;
        b[i].id=i;
        b[i].val=y;
    }


    sort(a+1,a+n+1,cmp);
    sort(b+1,b+n+1,cmp);
    for (int i=1;i<=n;i++) f[i]=i;

    long long ans = 0;

    int t=0;
    for (int i=2;i<=n;i++)
    {
        t++;
        c[t].x=a[i-1].id;
        c[t].y=a[i].id;
        c[t].val=abs(a[i].val-a[i-1].val);
    }

    for (int i=2;i<=n;i++)
    {
        t++;
        c[t].x=b[i-1].id;
        c[t].y=b[i].id;
        c[t].val=abs(b[i].val-b[i-1].val);
    }

    sort(c+1,c+t+1,cmp2);
    for (int i=1;i<=t;i++)
    {
        int x=find(c[i].x);
        int y=find(c[i].y);
        if (x!=y)
        {
            ans += c[i].val;
            f[x]=y;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
	int N;
	cin >> N;
	vector<int> arr(N);
	vector<int> vals(N);
	for(int i = 0; i < N; i++)
	{
		int temp;
		cin >> temp;
		arr[i] = temp;
		vals[i] = temp;
	}
	sort(arr.begin(), arr.end());
	int max_num = arr[N-1];
	int max_num2 = arr[N-2];
	for(int i = 0; i < N; i++)
	{
		int num = vals[i];
		if(num == max_num) cout << max_num2 << "\n";
		else cout << max_num << "\n";
	}
	return 0;
}

Measured memory_bytes: 3200
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std ; 

typedef long long ll ; 

int sel[11] ; 

bool ok(int num){
    while(num){
        if(!sel[num%10])
            return false ;
        num /= 10 ; 
    }
    return true ;
}

int main()
{
    int N, K ; 
    scanf("%d%d", &N, &K) ; 
    memset(sel, true, sizeof(sel)) ; 
    for(int i = 0 ; i != K ; i++){
        int now ; 
        scanf("%d", &now) ; 
        sel[now] = false ; 
    }
    for(int i = N ; ; i++){
        if(!ok(i))
            continue ; 
        printf("%d\n", i) ; 
        return 0 ; 
    }
    
    return 0 ; 
}


Measured memory_bytes: 128
// ------------------
// author: MatsuTaku
// date  : 19/02/2020
// ------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  ll N,D,A; cin>>N>>D>>A;
  vector<pair<ll, ll>> V(N);
  for (int i = 0; i < N; i++) {
    cin>>V[i].first>>V[i].second;
  }
  sort(V.begin(), V.end());

  ll ans = 0;
  ll c_damage = 0;
  vector<ll> ED(N);
  int r = 0;
  for (int i = 0; i < N; i++) {
    auto v = max(V[i].second - c_damage, 0ll);
    auto t = v/A+(v%A>0);
    auto damage = t*A;
    ans += t;
    c_damage += damage;
    while (r+1 < N and V[r+1].first <= V[i].first+2ll*D) {
      r++;
    }
    ED[r] += damage;
    c_damage -= ED[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double N;
  cin >> N;
  vector<double> X(N);
  for(int i=0;i<N;i++) cin >> X[i];
  double sum=0.0;
  
  for(int i=0;i<N;i++){
    sum += X[i];
  }
  
  double ans1 = sum/N;
  int ans2 = sum/N;
  
  double er = ans1 - ans2;
  if(er >0.50)ans2 += 1;
  
  int H=0;
  for(int i=0;i<N;i++){
    H += (X[i] - ans2)*(X[i] - ans2);
  }
  
  cout << H << endl;
}
  
  
    


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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
#include <complex>
typedef complex<double> Point;

int N, Q;
double R;
int sign(double x){
  if(x > EPS) return 1;
  if(x < -EPS) return -1;
  return 0;
}
bool equal(Point a, Point b){
  return sign(a.real() - b.real()) == 0 && sign(a.imag() - b.imag()) == 0;
}
double get_arg(Point c, Point p){
  double lb = 0, ub = M_PI;
  REP(iter, 64){
    double x = (lb + ub) * 0.5;
    Point q = (p - c) * polar((double)1.0, x) + c;
    //printf("x = %f p = (%f, %f) q = (%f, %f)\n", x, p.real(), p.imag(), q.real(), q.imag());
    if(sign(abs(q) - R) < 0){
      lb = x;
    }else{
      ub = x;
    }
  }
  return ub;
}

int main(){
  while(cin >> N >> R >> Q && N){
    vector<Point> P(N);
    REP(i, N) cin >> P[i].real() >> P[i].imag();
    int center = -1;
    REP(i, N) if(sign(abs(P[i]) - R) == 0) center = i;
    assert(center >= 0);
    REP(iter, Q){
      double th = M_PI;
      REP(i, N) if(center != i) th = min(th, get_arg(P[center], P[i]));
      REP(i, N){
        P[i] = (P[i] - P[center]) * polar((double)1.0, th) + P[center];
      }
      vector<pair<double, int> > cand;
      double ag0 = arg(P[center]);
      REP(i, N) if(sign(abs(P[i]) - R) == 0 && i != center) {
        double ag = arg(P[i]);
        while(ag < ag0) ag += 2.0 * M_PI;
        cand.push_back(make_pair(ag, i));
      }
      assert(cand.size() > 0);
      sort(cand.begin(), cand.end());
      int k = cand.back().second;
      printf("%.16f %.16f\n", P[k].real(), P[k].imag());
      center = k;
    }
  }
  return 0;
}

Measured memory_bytes: 1348
n = int(input())
a = list(map(int, input().split()))
a2 = [(a[i], i) for i in range(n)]
a2.sort(reverse=True)
# print(a2)

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

for i, (aj, j) in enumerate(a2):
    for k in range(i + 1):
        # left
        dp[i + 1][k + 1] = max(dp[i][k] + aj * abs(k - j), dp[i + 1][k + 1])

        # right
        dp[i + 1][k] = max(dp[i][k] + aj * abs((n - i + k - 1) - j),
                           dp[i + 1][k])

ans = max(dp[n])
print(ans)
# print(*dp, sep='\n')


Measured memory_bytes: 100184
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int cnt = 3;
	if (a == b && b == c)
		cnt = 1;
	else if (a == b || b == c || c == a)
		cnt = 2;
	else
		cnt = 3;
	cout << cnt << endl;
} 

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

int n;
long long a[101010], b[101010];

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
  }

  long long ans = 0;
  for (int i = n - 1; i >= 0; i--){
    a[i] += ans;
    if (a[i] % b[i] == 0) continue;
    ans += (a[i] / b[i] + 1) * b[i] - a[i];
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
from collections import deque
n, m = map(int, input().split())
L = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    L[a-1].append(b-1)
    L[b-1].append(a-1)

# 幅優先探索
d = deque([0])
D = [-1] * n
D[0] = 0
while len(d) > 0 :
    t = d.popleft()
    for i in L[t]:
        if D[i] == -1:
            D[i] = t
            d.append(i)
            # print(d, D)

print('Yes')
for i in range(1, n):
    print(D[i]+1)


Measured memory_bytes: 33932
//
//  main.cpp
//  Source
//
//  Created by Taguwa on 2020/01/23.
//  Copyright © 2020 Taguwa. All rights reserved.
//

#include <iostream>
#include <string>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < int(a) ; i ++)

int main(){
    string s;
    cin >> s;
    int cr = 0;
    rep( i , (s.size()/2)) if(s[i] != s[s.size()-i-1]) cr++;
    cout << cr << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	//int a, b, c; cin >> a >> b;
	string s,t; cin >> s>>t;
	if (s == "H") {
		if (t == "H")cout << "H";
		else cout << "D";
	}
	else {
		if (t == "H")cout << "D";
		else cout << "H";
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class BChristmasEveEve {
public:
	void solve(istream& in, ostream& out) {
        int n; in >> n;
        vector<int> p(n);
        rep(i,n) in >> p[i];
        sort(p.begin(),p.end());
        int ans = 0;
        rep(i,n-1) ans += p[i];
        ans += p[n-1] / 2;
        out << ans << endl;
	}
};

int main() {
	BChristmasEveEve solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

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

using namespace std;

#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9;
const int MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5;

int A[N], P[N];
bool MARK[N], PICK[N];
vector<int> G[N];

int DFS(int v) {
	MARK[v] = true;
	int res = v;
	for (int u : G[v]) if (!MARK[u]) {
		int w = DFS(u);
		if (A[w] < A[res]) res = w;
	}
	return res;
}
bool CMP(int i, int j) { return A[i] < A[j]; }

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n, m; cin >> n >> m;
	if (m == n - 1) die(0);
	if (n < 2 * (n - m - 1)) die("Impossible");
	for (int i = 0; i < n; i++) cin >> A[i], P[i] = i;
	for (int i = 0; i < m; i++) {
		int v, u; cin >> v >> u;
		G[v].push_back(u);
		G[u].push_back(v);
	}
	sort(P, P + n, CMP);
	ll ans = 0;
	for (int i = 0; i < n; i++) if (!MARK[i]) {
		int mn = DFS(i);
		PICK[mn] = true;
		ans += A[mn];
	}
	for (int i = 0, cnt = n - m; i < n && cnt < 2 * (n - m - 1); i++) {
		if (PICK[P[i]]) continue;
		ans += A[P[i]];
		cnt++;
	}
	cout << ans << endl;
	

	return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ll a, b, c;
    scanf("%lld%lld%lld", &a, &b, &c);
    ll right = c - a - b;
    if (right < 0) {
        printf("No\n");
        return 0;
    }
    right *= right;
    ll left = 4 * a * b;
    if (left < right) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
use proconio::*;

fn main() {
    input! {
        n: u32,
        a: u32,
        b: u32
    }
    let ans = (1..n+1).filter(|x| {
        let sum = x.to_string().chars().map(|c| (c as u8 - b'0') as u32).sum::<u32>();
        a <= sum && sum <= b
    }).sum::<u32>();
    println!("{}", ans);
}


Measured memory_bytes: 2112
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

A,B=get_i
ans=[]
ans.push(A+B)
ans.push(A-B)
ans.push(A*B)
puts ans.max

Measured memory_bytes: 1788
// Created by Bingoo on 7/8/2020.
#include"bits/stdc++.h"
using namespace std ;
#define ll  long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

template <class ...Args>
auto &see(const Args &...args) {return ((cerr << " " << args), ...) << '\n';}
#define bug(...)  cerr << "[ "#__VA_ARGS__" ] = "; see(__VA_ARGS__) << '\n';
//C++17
template<typename... Args>
void read(Args&... args){((cin >> args), ...);}
template<typename... Args>
void write(Args... args){((cout << args << " "), ...);}

ll mod = 1e6 +3 ;
ll power(ll a, ll b)	//a is base, b is exponent
{
    if (b == 0)
        return 1;
    if (b == 1)
        return a;
    if (b % 2 == 1)
        return (power(a, b - 1) * a) % mod;
    ll q = power(a, b / 2);
    return (q * q) % mod;
}

bool comp(pair<int,int>&a ,pair<int,int>&b)
{
    return a.second > b.second ;
}

string s;

int k ,n ;

int main(){
    cin >> n ;
    int m = n % 100;
    int y = n / 100 ;
    //bug(y,m)

   if(m>=1 && m <=12){
       if(y>=1 && y <=12)cout<<"AMBIGUOUS\n";
       else cout << "YYMM\n";
   }
   else if(y >=1 && y <=12){
       if(m>=1 && m <=12)cout<<"AMBIGUOUS\n";
       else cout << "MMYY\n";
   }
   else cout << "NA\n";



}

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

using namespace std;
#define int long long
int MOD = 1000000007;

signed main(){
    int N;
    cin >> N;
    
    int a[N];
    int mx = 0;
    for(int i=0;i<N;i++){
        cin >> a[i];
        mx += a[i]-1;
    }
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n ;
    cin >> n ;
    if ( n >= 30 ) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0; 
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    ll p = a[0];
    ll q = 0;
    ll r = a[1] + a[2];
    ll s = 0;
    for(int i = 3; i < n; i++)
    {
        s += a[i];
    }

    ll ans = 1e10;
    ll left = 0;
    ll right = 2;
    ll ma = 0, mi = 0;
    for(int pos = 1; pos < n-2; pos++)
    {
        q += a[pos];
        r -= a[pos];
        while(left < pos-1)
        {
            if(abs(p-q) > abs(p+a[left+1] - (q-a[left+1])))
            {
                p += a[left+1];
                q -= a[left+1];
                left++;
            }
            else
            {
                break;
            }
        }

        if(right == pos)
        {
            right++;
            r = a[right];
            s -= r;
        }
        while(right < n-2)
        {
            if(abs(r-s) > abs(r+a[right+1] - (s-a[right+1])))
            {
                r += a[right+1];
                s -= a[right+1];
                right++;
            }
            else
            {
                break;
            }
        }
        ma = max(max(p, q), max(r, s));
        mi = min(min(p, q), min(r, s));
        ans = min(ans, ma-mi);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val nums = inputs.head.split(" ").map(_.toInt)
  val a = nums(0)
  val b = nums(1)
  val c = nums(2)

  println(solve(a, b, c))

  private def solve(a: Int, b: Int, c: Int): String = {
    (1 to b).foreach { i =>
      if(a * i % b == c) {
        return "YES"
      }
    }
    "NO"
  }
}

Measured memory_bytes: 55044
a, b, K = map(int, input().split())

for i in range(K):
    if i % 2 == 0:
        if a % 2 != 0:
            a -= 1
        ageru = a / 2
        a -= ageru
        b += ageru
    else:
        if b % 2 != 0:
            b -= 1
        ageru = b / 2
        a += ageru
        b -= ageru

print(str(int(a)) + ' ' + str(int(b)))

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define rep2(i,a,n) for (int i = a; i < n; i++)
using namespace std;
#define PI 3.14159265359
int R;
int main() {
    cin >> R;
    double res = R * 2 * PI;
    cout << res << endl;
    return 0;
}


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

typedef long long ll;

#define vi vector<int>
#define vs vector<string>
#define vc vector<char>
#define MOD 1000000007
#define pb push_back
#define llnums vector<ll>
#define FOR(i,n) for(int i{0}; i < n; ++i)

using namespace std;

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0); // A.cpp
  int a;
  cin >> a;
  cout << a  + (a*a) + (a*a*a) << '\n';
  return 0;
}








Measured memory_bytes: 3624
def main05():
    num = int(input())
    data = input().split()
    zyun = []
    for i in data:
        zyun.append(int(i))
    result = 0
    for i in range(num-2):
        if zyun[i] < zyun[i+1]:
            if zyun[i+1] < zyun[i+2]:
                result = result + 1
        else:
            if zyun[i+1] > zyun[i+2]:
                result = result + 1
    print(result)

if __name__ == "__main__":
    main05()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		final int CAKE = 4; //ケーキ1個の値段
		final int DONUTS = 7; //ドーナツ1個の値段
		int N; //合計金額
		boolean frag = false;

		Scanner scan = new Scanner(System.in);
		N = scan.nextInt();

		for( int i = 0; i <= N / CAKE; i++ ) {
			if ( ( N - (CAKE * i) ) % DONUTS == 0 ) {
				frag = true;
				break;
			}else {
				frag = false;
			}
		}

		if( frag == true ) {
			System.out.print("Yes");
		}else {
			System.out.print("No");
		}

		scan.close();

	}
}

Measured memory_bytes: 23764
H,W=(int(i) for i in input().split())
s=[input() for i in range(H)]
for i in range(H):
    for j in range(W):
        if s[i][j]=='#':
            if i==0 or s[i-1][j]=='.':
                if i==H-1 or s[i+1][j]=='.':
                    if j==0 or s[i][j-1]=='.':
                        if j==W-1 or s[i][j+1]=='.':
                            print('No')
                            exit()
print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <queue>
#include <algorithm>
#include <numeric>
using namespace std;
const long long INF = 1LL<<40;


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> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }



int main() {
    long long N, K; cin >> N >> K;
    vector<vector<long long> > s(N); // s[i] := 種類 i の美味しさの集合
    for (int i = 0; i < N; ++i) {
        long long t, d; cin >> t >> d; --t;
        s[t].push_back(d);
    }

    // 各種類について、美味しい順に並べる
    for (auto &v : s) {
        sort(v.begin(), v.end(), greater<long long>());
        if (v.empty()) v.push_back(-INF); // 番兵
    }

    // 「美味しさの最大値」の大きいネタ順
    sort(s.begin(), s.end(), [&](vector<long long> a, vector<long long> b) {
            return a[0] > b[0];});
 
    // まず K 種類選ぶ場合
    long long cur = 0;
    priority_queue<long long> que;
    for (int i = 0; i < K; ++i) {
        cur += s[i][0];
        for (int j = 1; j < s[i].size(); ++j) que.push(s[i][j]);
    }
    for (int i = K; i < N; ++i) for (int j = 0; j < s[i].size(); ++j) que.push(s[i][j]);

    //COUT(s);

    // 走査
    long long res = cur + K*K;
    for (long long x = K-1; x >= 1; --x) {
        long long v = s[x][0];
        long long w = que.top();
        if (v < w) {
            que.pop(); cur += w;
            que.push(v); cur -= v;
        }
        res = max(res, cur + x*x);

        //cout << x << ": " << cur << ", " << v << "," << w << endl;
    }
    cout << res << endl;
}


Measured memory_bytes: 8696
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;

namespace ProjectContest
{
    class Test
    {
        static void Main()
        {
            var xa = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
            int x = xa[0], a = xa[1];
            Console.WriteLine(x < a ? 0 : 10);

        }
    }
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)

ll N,N2;
char S[202020];
ll mk[202020];
ll mk2[202020];
ll i, j,k, ans;
int main(){
    scanf("%lld%s", &N,S);
    if(S[0]=='W'){
        printf("0");
        return 0;
    }
    N2 = N * 2;
    j = 0;
    k = 1;
    ans = 1;
    fornum(i,1,N2){
        //printf("%lld:%lld\n", i, k);
        j = ((S[i - 1] == S[i]) + j) % 2;
        if(j){
            if(k==0){
                printf("0");
                return 0;
            }
            ans = ans * k % MOD;
            k--;
        }else{
            k++;
        }
        
    }
    if(k==0){
        fornum(i,0,N){
            ans = ans * (i + 1) % MOD;
        }
        printf("%lld", ans);
    }else{
        printf("0");
    }

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
const int MOD = 1e9+7;
const int MOOD = 998244353;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

int a[85][85];
int b[85][85];
bool bias[85][85][13000];

int main(){
	int h, w;
	cin >> h >> w;

	for (int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			cin >> a[i][j];
		}
	}

	for (int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			cin >> b[i][j];
		}
	}

	bias[1][1][abs(a[1][1] - b[1][1])] = true;

	for (int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			for (int k = 0; k <= 80*(i+j-1); k++){
				if (i == h && j == w){
					for (int l = 0; l < 13000; l++){
						if (bias[h][w][l]){
							cout << l << endl;
							break;
						}
					}
					return 0;
				}
				if (bias[i][j][k] == true){
					bias[i+1][j][k+abs(a[i+1][j]-b[i+1][j])] = true;
					bias[i][j+1][k+abs(a[i][j+1]-b[i][j+1])] = true;
					bias[i+1][j][abs(k-abs(a[i+1][j]-b[i+1][j]))] = true;
					bias[i][j+1][abs(k-abs(a[i][j+1]-b[i][j+1]))] = true;
				}
			}
		}
	}
}


Measured memory_bytes: 69540
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int a[301][301], sports[301], offset[301];
bool deleted[301];

int main()
{
    int N, M, min_max, locmax;
    bool flag = false;
    cin >> N >> M;
    for (int i = 1; i <= N; i++)
        for (int j = 1; j <= M; j++)
            scanf("%d", &a[i][j]);
    for (int i = 1; i <= N; i++)
        sports[a[i][1]]++;
    locmax = 1;
    for (int j = 1; j <= M; j++) {
        if (sports[j] > sports[locmax])
            locmax = j;
    }
    min_max = sports[locmax];
    for (int i = 1; i <= N; i++)
        offset[i] = 1;
    while (!flag) {
        deleted[locmax] = true;
        sports[locmax] = 0;
        for (int i = 1; i <= N; i++) {
            bool flag1 = false;
            while (deleted[a[i][offset[i]]]) {
                flag1 = true;
                offset[i]++;
                if (offset[i] > M){
                    flag = true;
                    break;
                }
            }
            if (flag)
                break;
            if (flag1) {
                sports[a[i][offset[i]]]++;
            }
        }
        if (flag)
            break;
        for (int j = 1; j <= M; j++) {
            if (sports[j] > sports[locmax])
                locmax = j;
        }
        if (min_max > sports[locmax])
            min_max = sports[locmax];
    }
    cout << min_max << endl;
    return 0;
}

Measured memory_bytes: 640
n,m=map(int,input().split())
tenbo=[1 for i in range(n+1)]
t=list(map(int,input().split()))
h=[0]+t
tenbo[0]=0
for i in range(m):
  a,b=map(int,input().split())
  if h[a]>=h[b]:
    tenbo[b]=0
  if h[a]<=h[b]:
    tenbo[a]=0
print(sum(tenbo))

Measured memory_bytes: 20896
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let w: usize = itr.next().unwrap().parse().unwrap();
    let h: usize = itr.next().unwrap().parse().unwrap();
    let n: usize = itr.next().unwrap().parse().unwrap();

    let mut minx = w;
    let mut maxx = 0;
    let mut miny = h;
    let mut maxy = 0;
    for _ in 0..n {
        // 最も右の1
        // 最も左の2
        // 最も上の3
        // 最も下の4
        let x: usize = itr.next().unwrap().parse().unwrap();
        let y: usize = itr.next().unwrap().parse().unwrap();
        let a: usize = itr.next().unwrap().parse().unwrap();
        match a {
            1 => maxx = max(maxx, x),
            2 => minx = min(minx, x),
            3 => maxy = max(maxy, y),
            _ => miny = min(miny, y),
        }
    }
    let rangex = minx.saturating_sub(maxx);
    let rangey = miny.saturating_sub(maxy);
    println!("{}", rangex * rangey);
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (b < a ? a - 1 : a) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdin);
    ll n;
    while(cin>>n){
        ll ans=0;
        if(n>=500){
            ans+=(n/500)*1000;
            n=n%500;
        }
        if(n>=5){
            ans+=(n/5)*5;
            n=n%5;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <map>
inline int read(){
  int ans=0,c=getchar_unlocked();
  while(c<'0'||c>'9')c=getchar_unlocked();
  while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar_unlocked();}
  return ans;
}
int main(){
  int n,m,a,b;n=read();m=read();
  std::map<int,bool> mp;
  while(m--){a=read();b=read();
    if(a==1){
      if(mp[b]==true)return puts("POSSIBLE"),0;
      mp[b]=true;
    }
    if(b==n){
      if(mp[a]==true)return puts("POSSIBLE"),0;
      mp[a]=true;
    }
  }
  puts("IMPOSSIBLE");
  return 0;
}

Measured memory_bytes: 9600
def tenki(s, t):

    ans = 0

    for i in range(len(s)):
        if s[i] == t[i]:
            ans += 1

    return ans

def main():
    s = list(str(input()))
    t = list(str(input()))
    print(tenki(s, t))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
N = int(input())
arr = []
for _ in range(N):
	arr.append(list(map(int, input().split(" "))))

dp = [[0 for _ in range(3)] for _ in range(N+1)]
 
for i in range(1, N+1):
	for j in range(3):
		dp[i][j] = max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]) + arr[i-1][j]

print(max(dp[-1]))

Measured memory_bytes: 47304
/*A - Beginner*/

#include <bits/stdc++.h>
using namespace std;

int main(){


	int contest;
	int score;
	int ans;

	cin >> contest >> score;

	if(contest >= 10)
		cout << score;
	else{
		ans = 100 * (10 - contest);
		ans += score;
		cout << ans;
	}

	return 0;
}

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

int main() {

    int N ;

    cin >> N ;

    int64_t sum = 0 ;

    for (int i = 0; i < N+1 ; i++ ){

        if (i % 3 == 0 && i % 15 != 0);
      
        else if (i % 5 == 0 && i % 15 != 0);

        else if (i % 15 == 0);

        else {

            sum += i ;

        }

    }
    
    cout << sum << endl;

}

Measured memory_bytes: 3580
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#define LL long long
using namespace std;
const LL Maxn = 100010;
const LL Maxpre = 3000;
bool v[Maxpre+10]; LL pr[Maxpre], prl;
void pre() {
	for(LL i = 2; i <= Maxpre; i++){
		if(!v[i]) pr[++prl] = i;
		for(LL j = 1; j <= prl && i*pr[j] <= Maxpre; j++){
			v[i*pr[j]] = true;
			if(i % pr[j] == 0) break; 
		}
	}
}
LL Norm[Maxn], Pair[Maxn], n, s[Maxpre];
LL b[Maxn<<1], bl, s1[Maxn<<1], s2[Maxn<<1];
LL _max(LL x, LL y) { return x > y ? x : y; }
int main() {
	LL i, j, k;
	pre();
	scanf("%lld", &n);
	for(i = 1; i <= n; i++){
		LL x;
		scanf("%lld", &x);
		Norm[i] = Pair[i] = 1;
		for(j = 1; j <= prl; j++){
			s[j] = 0;
			while(x % pr[j] == 0) s[j]++, x /= pr[j];
			s[j] %= 3;
			if(s[j] == 1) Norm[i] *= pr[j], Pair[i] *= pr[j]*pr[j];
			if(s[j] == 2) Norm[i] *= pr[j]*pr[j], Pair[i] *= pr[j];
		}
		if(x > 1){
			LL sqx = sqrt(x);
			if(sqx * sqx == x) Norm[i] *= x, Pair[i] *= sqx;
			else Norm[i] *= x, Pair[i] *= x*x;
		}
		b[++bl] = Norm[i]; b[++bl] = Pair[i];
	}
	sort(b+1, b+bl+1);
	bl = unique(b+1, b+bl+1) - (b+1);
	for(i = 1; i <= n; i++){
		s1[lower_bound(b+1, b+bl+1, Norm[i]) - b]++;
		s2[lower_bound(b+1, b+bl+1, Pair[i]) - b]++;
	}
	LL ans = 0, fl = 0;
	for(i = 1; i <= bl; i++){
		if(b[i] == 1) fl = 1;
		else ans += _max(s1[i], s2[i]);
	}
	ans >>= 1;
	printf("%lld\n", ans+fl);
	return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#define MAXN 210
#define INF 0x3f3f3f3f

using namespace std;

int main()
{
    int x, a, b, c, num;
    while(cin>>a>>b>>c>>x)
    {
        num = 0;
        for(int i = 0;i <= a; i++)
        {
            for(int j = 0; j <= b; j++)
            {
                int s = x - 500 * i - 100 * j;
                int nc = s / 50;
                if(s >= 0 && s % 50 == 0 && nc <= c)
                    num++;
            }
        }
        cout<<num<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000001
#define pi 3.141592653589793
#define pii pair<int , int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti set <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
int main()
{  
    FAST
    ll n;
    cin>>n;
    ll a[n][n];
    ll b[n];
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<n;j++)
        {
            a[i][j]=inf;
        }
    }
    for(ll i=0;i<n;i++)
    {
        a[i][i]=0;
    }
    for(ll i=0;i<n;i++)
    {
        cin>>b[i];
    }
    for(ll i=1;i<n;i++)
    {
        ll sum=b[i];
        for(ll j=i-1;j>=0;j--)
        {
            sum+=b[j];
            if(j==i-1)
                a[j][i]=sum;
            else
            {
                for(ll k=j;k<i;k++)
                {
                    if((a[j][k]+a[k+1][i]+sum)<a[j][i])
                        a[j][i]=(a[j][k]+a[k+1][i]+sum);
                }
            }
        }
    }
    cout<<a[0][n-1];
}

Measured memory_bytes: 1536
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//

int N, M;
int k[11], s[11][11], p[11];
bool on[11];

bool check() {
	for (int i=0; i<M; ++i) {
		int cnt = 0;
		for (int j=0; j<k[i]; ++j) if (on[s[i][j]]) ++cnt;
		if (cnt % 2 != p[i]) return false;
	}
	return true;
}

int solve(int i) {
	if (i == N) {
		if (check()) return 1;
		return 0;
	}
	int ret = 0;
	ret += solve(i+1);
	on[i] = true;
	ret += solve(i+1);
	on[i] = false;
	return ret;
}

int main() {
	cin >> N >> M;
	for (int i=0; i<M; ++i) {
		cin >> k[i];
		for (int j=0; j<k[i]; ++j) {
			cin >> s[i][j];
			--s[i][j];
		}
	}
	for (int i=0; i<M; ++i) cin >> p[i];
	memset(on, false, sizeof(on));
	cout << solve(0) << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

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

void swap(int& x,int &y){
        int tmp = x;
        x=y;
        y=tmp;
    }
int main(){
     int a,b,c;
    cin >>a>>b>>c;
    if(a>b) swap(a,b);
    if(b>c) swap(b,c);
    if(a>b) swap(a,b);
    
    cout <<a<<" "<<b<<" "<<c<<endl;
    
    
    }



Measured memory_bytes: 3100