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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

#define INF INT_MAX

// graph by adjacency list
template <typename T>
struct Edge {
  int dst; T weight;
  Edge(int dst, T weight) : dst(dst), weight(weight) { }
  bool operator < (const Edge<T> &e) const {
    return weight > e.weight;
  }
};

template <typename T>
struct Graph {
  int V;
  vector<vector<Edge<T>>> E;

  Graph(int V) : V(V) { E.resize(V); }

  void add_edge(int src, int dst, T weight) {
    E[src].push_back(Edge<T>(dst, weight));
  }
};

template <typename T>
struct Node {
  int v; T dist;
  Node(int v, T dist) : v(v), dist(dist) { };
  bool operator < (const Node<T> &n) const {
    return dist > n.dist; // reverse
  }
};

template <typename T>
struct ShortestPath {
  const Graph<T> g;
  vector<T> dist;
  vector<int> prev;

  ShortestPath(const Graph<T> g) : g(g) { dist.resize(g.V), prev.resize(g.V); }

  void dijkstra(int start) {
    priority_queue<Node<T>> que;
    dist.assign(g.V, INF);
    dist[start] = 0;
    que.push(Node<T>(start, 0));
    prev[0] = -1;

    while (!que.empty()) {
      Node<T> n = que.top(); que.pop();
      int v = n.v; T cost = n.dist;
      if (dist[v] < cost) continue;
      for (Edge<T> e : g.E[v]) {
	if (dist[v] < dist[e.dst] - e.weight) {
	  dist[e.dst] = dist[v] + e.weight;
	  prev[e.dst] = v;
	  que.push(Node<T>(e.dst, dist[e.dst]));
	}
      }
    }
  }

  vector<int> build_path(int goal) {
    vector<int> path;
    for (int v = goal; v != -1; v = prev[v]) {
      path.push_back(v);
    }
    reverse(path.begin(), path.end());
    return path;
  }
};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int V, E, r; cin >> V >> E >> r;
  Graph<int> g(V);
  REP(i, E) {
    int s, t, d; cin >> s >> t >> d;
    g.add_edge(s, t, d);
  }
  ShortestPath<int> sp(g);
  sp.dijkstra(r);
  REP(i, g.V) {
    if (sp.dist[i] == INF) {
      cout << "INF" << endl;
    } else {
      cout << sp.dist[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 26724
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int N,M,p[11];

int dfs(int n,int f,int pra)
{
	int t,r=-1;
	if(pra>M)return -1;
	if(n==N)
		return 0;
	for(int i=f;i<10;i++)
	{
		t=dfs(n+1,f,pra+p[i]);
		if(t!=-1)return t+i*(pow(10.0,N-n));
	}
	return -1;
}

int main()
{
	scanf("%d%d",&N,&M);
	for(int i=0;i<10;i++)
		scanf("%d",&p[i]);
	int r=dfs(0,0,0);
	if(r==-1)puts("NA");
	else
	{
		char x[]="%0xd\n";
		x[2]=N+'0';

		printf(x,r/10);
	}
}


Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
#define mod 1000000007
#define pi 3.14159265358979323846
double Angle(double h, double m)
{
	double hour_angle = h * 30 + m * 0.5;
	double minute_angle = 6 * m;
	double angle = abs(hour_angle - minute_angle);
	angle = min(360 - angle, angle);
	return angle;
}
int main()
{
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double ans, deg;
	deg = Angle(h, m);
	if (deg == 90)
		cout << fixed << setprecision(20) << sqrt(a * a + b * b) << '\n';
	else if (deg == 180)
		cout << fixed << setprecision(20) << a + b << '\n';
	else
	{
		double trig = cos(deg * pi / 180);
		ans = sqrt(a * a + b * b - 2 * a * b * trig);
		cout << fixed << setprecision(20) << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 4136
while True:
  m,n1,n2=map(int,input().split())
  if m==0 and n1==0 and n2==0:
    break
  P=[]
  A=[]
  B=[]
  for i in range(m):
    P.append(int(input()))
  
  for i in range(n1,n2+1):
    A.append(P[i-1]-P[i])
    B.append(i)
  S=[]   
  for i in range(len(A)):
    if A[i]==max(A):
      S.append(B[i])
  print(max(S))


Measured memory_bytes: 5616
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		// 計算
		int result = -1;
		for(int i = 0; i <= 11000; i++){
		    if(a == floor(0.08*i) && b == floor(0.1*i)){
		        result = i;
		        break;
		    }
		}
		
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 17;
const int L = 32800;
const int mo = 1e9+7;

LL f[N][L];
int t[L];
int co[N],cu[N];
int n,m;
LL c0[N],c1[N];
LL mi[300];
int cnt[L];
int s1[14350000],s2[14350000];
int it[N],sit[L];

inline LL add(LL x,LL y){
	return x+y>=mo?x+y-mo:x+y;
}

inline int trs(int x,int y){
	int ct=0;
	fo(i,0,n-1){
		ct=ct*3;
		if ((x&(1<<i))>0)ct=ct+1;
		if ((y&(1<<i))>0)ct=ct+2;
	}
	return ct;
}

int main(){
	n=get();m=get();
	fo(i,1,m){
		int x=get(),y=get();
		co[y]|=(1<<(x-1));
		cu[x]|=(1<<(y-1));
		it[y]++;
	}
	mi[0]=1;
	fo(i,1,m)mi[i]=mi[i-1]*2%mo;
	fo(i,1,(1<<n)-1)cnt[i]=cnt[i-(i&-i)]+1;
	fo(i,0,(1<<n)-1){
		for(int x=i;x<(1<<n);x=((x+1)|i)){
			int x_=x^i;
			int now=trs(i,x_);
			//s1
			fo(t,1,n)
			if (((1<<(t-1))&i)>0)s1[now]=s1[now]+cnt[cu[t]&x_];
			s1[now]=mi[s1[now]];
			//s2
			s2[now]=1;
			fo(t,1,n)
			if (((1<<(t-1))&x_)>0)s2[now]=1ll*s2[now]*(mi[cnt[cu[t]&i]]+mo-1)%mo;
		}
		fo(x,1,n)
		if ((i&(1<<(x-1)))>0)sit[i]+=it[x];
	}
	
	LL ans=0;
	fo(i,1,(1<<n)-1){
		f[0][i]=s2[trs(i,((1<<n)-1)^i)];
		if ((i&3)==3)ans=add(ans,f[0][i]*mi[m-sit[i]]%mo);	
	}
	fo(i,0,(1<<n)-1)
	for(int x=(i+1)|i;x<(1<<n);x=((x+1)|i)){
		int x_=i^x;
		int t1=trs(i,x_),t2=trs(x_,((1<<n)-1)^x);
		fo(lev,0,n-1)
		if (f[lev][i]){
			LL tmp=f[lev][i]*s1[t1]%mo*s2[t2]%mo;
			f[lev+1][x]=add(f[lev+1][x],tmp);
			if ((i&3)==0&&(x&3)==3)ans=add(ans,tmp*mi[m-sit[x]]%mo);
		}
	}
	ans=(mi[m]+mo-ans)%mo;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 116992
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,i,j,ans=1;
    cin>>n;
    ll arr[n];
    for(i=0; i<n; i++)
        cin>>arr[i];
    for(i=1; i<n; i++)
    {
        bool flag=1;
        for(j=0; j<i; j++)
        {
            if(arr[i]>=arr[j]);
            else
            {
                flag=0;
                break;
            }
        }
        if(flag)
            ans++;
    }

    cout<<ans<<endl;



    return 0;
}




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


#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;
main(){
    int n=in();
    vector<queue<int>> v;
    v.resize(n+1);
    rep(i,n){
        rep(j,n-1){
            v[i+1].push(in());
        }
    }
    int m=0;
    vec w;w.resize(n+1);
    rep2(i,1,n){
        w[i]=v[i].front();
        v[i].pop();
    }
    vector<int> used(n+1);
    while(1){
        m++;
        int t=0,s=0;
        
        rep2(i,1,n){
            if(w[i]==-1){t++;continue;}
            if(w[w[i]]==i&&!used[i]&&!used[w[i]]){
                s++;
                used[i]=used[w[i]]=1;
                if(!v[w[i]].empty()){
                    w[w[i]]=v[w[i]].front();
                    v[w[i]].pop();
                }
                else{
                    w[w[i]]=-1;
                }
                if(!v[i].empty()){
                    w[i]=v[i].front();
                    v[i].pop();
                }
                else w[i]=-1;
            }
        }
        //rep2(i,1,n)cout<<w[i]<<" ";
        //cout<<endl;
        used=vector<int>(n+1);
        if(t==n){cout<<m-1<<endl;return 0;}
        if(s==0){cout<<-1<<endl;return 0;}
    }
}

Measured memory_bytes: 4736
import Control.Applicative( (<$>))
import Control.Monad( replicateM)
import Data.List( foldl')

main = do
    n_ <- readLn::IO Int
    let
	readPair = do
	    [l,r] <- map read . words <$> getLine
	    return (l,r)

    pairs_ <- replicateM n_ readPair 
    print $ foldl' (\v (l,r)->v + r-l+1) 0 pairs_

Measured memory_bytes: 1404
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

int maxc;

void dfs(VI &a, VI &b, vector<map<int,int>> &m, VVI &es, int n, int c, int p) {
    if (p > -1) m[p][n] = c;
    int cnt = 0;
    for (auto &dst: es[n]) {
        if (dst == p) continue;
        if (cnt == c) ++cnt;
        dfs(a,b,m,es,dst,cnt++,n);
    }
    maxc = max({maxc, cnt, c + 1});
}

void solve() {
    int n;
    cin >> n;
    VI a(n-1), b(n-1);
    REP(i,0,n-1) cin >> a[i] >> b[i];
    REP(i,0,n-1) --a[i];
    REP(i,0,n-1) --b[i];
    VVI es(n);
    REP(i,0,n-1) {
        es[a[i]].push_back(b[i]);
        es[b[i]].push_back(a[i]);
    }
    vector<map<int,int>> m(n);
    maxc = 0;
    REP(i,0,es[0].size()) dfs(a,b,m,es,es[0][i],i,0);
    cout << maxc << endl;
    REP(i,0,n-1) {
        cout << m[a[i]][b[i]] + 1 << endl;
    }
}

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

Measured memory_bytes: 17664
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    rep (i, N) { cin >> h[i]; }

    sort(ALL(h));
    vector<int> li;
    rep (i, N - K + 1)
    {
        int min = h[i];
        int max = h[i + K - 1];
        li.pb(max - min);
    }

    sort(ALL(li));

    cout << li[0] << "\n";

    return 0;
}


Measured memory_bytes: 1276
#include <iostream>

using namespace std;

class Cards {
public:
  char m;
  int n;
};

int main(void) {
  int n, min, f=0;
  Cards b[36], s[36];
  cin >> n;
  for (int i=0; i<n; i++) {
    cin >> b[i].m >> b[i].n;
    s[i] = b[i];
  }
  for (int i=0; i<n-1; i++) {
    for (int j=n-1; j>i; j--) {
      if (b[j-1].n > b[j].n) {
        swap(b[j-1],b[j]);
      }
    }
  }
  for (int i=0; i<n; i++) {
    min = i;
    for (int j=i; j<n; j++) {
      if (s[j].n < s[min].n) {
        min = j;
      }
    }
    swap(s[i],s[min]);
  }
  for (int i=0; i<n; i++) {
    cout << (i==0?"":" ") << b[i].m << b[i].n << flush;
  }
  cout << endl;
  cout << "Stable" << endl;
  for (int i=0; i<n; i++) {
    if (b[i].m != s[i].m) {
      f=1;
    }
    cout << (i==0?"":" ") << s[i].m << s[i].n << flush;
  }
  cout << endl;
  if (f) {
    cout << "Not stable" << endl;
  } else {
    cout << "Stable" << endl;
  }
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int s; cin>>s;
  vector<long long> dp(s+1,0); dp[0]=1;
  for(int i=3; i<=s; ++i) dp[i]=(dp[i-1]+dp[i-3])%1000000007;
  cout<<dp[s];
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#define ull long long
using namespace std;

const int nmax = 100100;
int N;
ull a[nmax];

void read(){
    cin >> N;
    for(int i=0;i < N; ++i){
        cin >> a[i];
    }
}
inline ull abs_(ull x, ull y)
{
    if(x < y) swap(x,y);
    return x - y;
}
void solve(){
    sort(a, a  + N);
    ull x = a[N-1], y = a[N-1], yi = 0;
    for(int i = 0; i  < N-1;++i)
    {
        if(abs_(a[i], x/2) < y) yi = i, y = abs_(a[i], x/2);
    }
    if(x&1)
    {
         for(int i = 0; i  < N-1;++i)
        {
            if(abs_(a[i], (x+1)/2) < y) yi = i, y = abs_(a[i], (x+1)/2);
        }
   
    }
        cout << a[N-1] << ' ' << a[yi] << endl;
}

int main(){
    read();
    solve();
}

Measured memory_bytes: 1024
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

typedef pair<int,int> pii;
typedef pair<pii,int> P;
struct edge{int to,cost;};

const int INF = 1000000000;

int main(){
  int n,m,k;
  scanf("%d%d%d",&n,&m,&k);
  vector<P> E;
  vector<edge> G[3000];
  for(int i=0;i<m;i++){
    int a,b,l;
    scanf("%d%d%d",&a,&b,&l);
    E.push_back(P(pii(a-1,b-1),l));
    edge e; e.cost = l;
    e.to = a-1; G[b-1].push_back(e);
    e.to = b-1; G[a-1].push_back(e);
  }
  int D[n];
  fill(D,D+n,INF);
  for(int i=0;i<k;i++){
    int x;
    scanf("%d",&x);
    int d[n];
    priority_queue<pii,vector<pii>,greater<pii> > q;
    fill(d,d+n,INF);
    d[--x] = 0;
    D[x] = 0;
    q.push(pii(0,x));
    while(!q.empty()){
      pii p = q.top();
      int v = p.second; q.pop();
      if(d[v]<p.first) continue;
      for(int j=0;j<G[v].size();j++){
        int nv = G[v][j].to;
        if(d[nv]>d[v]+G[v][j].cost){
          d[nv] = d[v] + G[v][j].cost;
          D[nv] = min(D[nv],d[nv]);
          q.push(pii(d[nv],nv));
        }
      }
    }
  }
  int ans = 0;
  for(int i=0;i<E.size();i++){
    ans = max((double)ans,max((double)max(D[E[i].first.first],D[E[i].first.second]),(double)(D[E[i].first.first]+D[E[i].first.second]+E[i].second)/2.0+0.5));
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 6536
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    veci res(5);
    REP(i,5) cin >> res[i];
    int k;
    cin >> k;
    bool ok = true;
    for(int i = 0; i < 4; i++) {
        for(int j = i + 1; j < 5; j++) {
            if(res[j]-res[i] > k) ok = false;
        }
    }
    cout << (ok ? "Yay!":":(") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stack>
#include<cstdio>

using namespace std;

int main(){
  char match[256];
  string str;

  match['('] = ')';
  match['['] = ']';

  while(getline(cin, str), str != "."){
    stack<char> br;
    bool ans = true;

    for(int i = 0; ans && i < str.size(); i++){
      switch( str[i] ){
      case '(':
      case '[':
        br.push(str[i]);
        break;
      case ')':
      case ']':
        if(br.empty()){
          ans = false;
        }else{
          char c = br.top(); br.pop();
          if(match[c] == str[i]){
          }else{
            ans = false;
          }
        }
        break;
      default:
        break;
      }
    }

    ans = ans && br.empty();

    puts(ans ? "yes" : "no");
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    N %= 10;
    if(N==2||N==4||N==5||N==7||N==9){
        cout << "hon";
    } else if(N == 3){
        cout << "bon";
    } else {
        cout << "pon";
    }
}

Measured memory_bytes: 3632
n,m,x=map(int,input().split())
ca=[list(map(int,input().split())) for _ in range(n)]
c=[0]*n
ans=10**7
for i in range(n):
  c[i]=ca[i][0]
for i in range(2**n):
  l=[0]*m
  prime=0
  for j in range(n):
    if ((i >> j) & 1):
      prime+=c[j]
      for k in range(m):
        l[k]+=ca[j][k+1]
  if all([j>=x for j in l]):
    ans=min(ans,prime)
print(-1 if ans==10**7 else ans)

Measured memory_bytes: 9228
// https://atcoder.jp/contests/abc175/tasks/abc175_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X, K, D;
    cin >> X >> K >> D;
    // if (abs(X) >= K * D) {
    if (K <= abs(X) / D) {
        cout << abs(X) - K * D << endl;
    } else {
        // // 正の絶対値が最小
        // int b = abs(X) - abs(X) / D * D;
        // // 負の絶対値が最小
        // // int c = abs(abs(X) - ((1 + a / D) * D));
        // int c = abs(abs(X) - (abs(X) / D) * D - D);
        // // 移動回数の偶奇によって分岐
        // int bMove = abs(X) / D;
        // if ((K - bMove) % 2 == 0) {
        //     cout << b << endl;
        // } else {
        //     cout << c << endl;
        // }
        if ((K - abs(X) / D) % 2 == 0)
            cout << abs(X) - (abs(X) / D) * D;
        else
            cout << abs(abs(X) - (abs(X) / D) * D - D);
    }

    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, x, y;

int main() {
	cin >> n;
	x = n*800, y = (n/15)*200;
	cout << x-y << ln;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public Main(){
		Scanner sc = new Scanner(System.in);
		int f = 0;
		
		while(sc.hasNext()){
			if(f == 1){
				System.out.println();
			}
			String str = sc.next();
			int n = str.length();
			String s0="", s1="", s2="", s3="", s4="", s5="", s6="";
			
			for(int i = 0; i < n; i++){
				int t = Integer.parseInt(str.substring(i, i+1));
				if(t < 5){
					s0 += "*";
					s1 += " ";
				} else {
					s0 += " ";
					s1 += "*";
				}
				if(t == 0 || t == 5){
					s2 += " ";
				} else {
					s2 += "*";
				}
				if(t == 1 || t == 6){
					s3 += " ";
				} else {
					s3 += "*";
				}
				if(t == 2 || t == 7){
					s4 += " ";
				} else {
					s4 += "*";
				}
				if(t == 3 || t == 8){
					s5 += " ";
				} else {
					s5 += "*";
				}
				if(t == 4 || t == 9){
					s6 += " ";
				} else {
					s6 += "*";
				}
			}
			
			for(int i = 5-n; i > 0; i--){
				s0 = "*" + s0;
				s1 = " " + s1;
				s2 = " " + s2;
				s3 = "*" + s3;
				s4 = "*" + s4;
				s5 = "*" + s5;
				s6 = "*" + s6;
			}
			
			System.out.println(s0);
			System.out.println(s1);
			System.out.println("=====");
			System.out.println(s2);
			System.out.println(s3);
			System.out.println(s4);
			System.out.println(s5);
			System.out.println(s6);
			f = 1;
		}
	}
	
	public static void main(String[] args){
		new Main();
	}
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb push_back
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int N;
vector <int> E[100010];
int D[100010], ans;

void dfs(int x, int fa) {
	vector <int> v;
	int c[20] = {};
	for(int e : E[x]) if(e != fa) {
		dfs(e, x);
		rep(i, 20) if(1<<i & D[e]) ++c[i];
	}
	int f = -1;
	for(int i=19;i>=0;i--) {
		if(c[i] >= 2) break;
		if(c[i] == 0) f = i;
	}
	ans = max(ans, f);
	for(int i=19;i>=f;i--) if(c[i]) D[x] |= 1<<i;
	D[x] |= 1<<f;
}

int main() {
	scanf("%d", &N);
	rep(i, N-1) {
		int x, y; scanf("%d%d", &x, &y);
		E[x].pb(y);
		E[y].pb(x);
	}
	dfs(1, -1);
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 17536
def calc(sa, sb, sc, player):
    if player == 'a':
        if len(sa) == 0:
            return 'A'
        else:
            return calc(sa[1:], sb, sc, sa[0])

    elif player == 'b':
        if len(sb) == 0:
            return 'B'
        else:
            return calc(sa, sb[1:], sc, sb[0])

    elif player == 'c':
        if len(sc) == 0:
            return 'C'
        else:
            return calc(sa, sb, sc[1:], sc[0])

def solve():
    sa = input()
    sb = input()
    sc = input()

    print(calc(sa, sb, sc, 'a'))

solve()

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main(){
  string str;
  int alp[26]={};
  while(getline(cin,str)){
    for(int i=0,l=str.size();i<l;i++){
      if(str[i]>='a'&&str[i]<='z') alp[str[i]-'a']++;
      else  if(str[i]>='A'&&str[i]<='Z') alp[str[i]-'A']++;
    }
  }
  for(int i=0;i<26;i++){
    printf("%c : %d\n",i+'a',alp[i]);
  }
}


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

#define MAX


struct node{
  int key;
  struct node *right;
  struct node *left;
  struct node *parent;
};
  typedef struct node Node;
Node *root,*NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z=(Node *)malloc(sizeof(Node));
  z->key =k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    //leafのところまで探索
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;
  //右に入るか左に入るかを考える
  if( y == NIL)root = z;
  else{
    if(z->key < y->key ){
      y->left=z;
    }
    else{
      y->right = z;
    }
  }       
}
void inorder(Node *u){ 
  if(u == NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void print(Node *u){
  if(u == NIL)return;
  printf(" %d",u->key);
  print(u->left);
  print(u->right);
}



int main(){
  int i,j,n,k;
  char s[10];

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%s",s);
    if(s[0]=='i'){
      scanf("%d",&k);
      insert(k);
    }
    else if(s[0]=='p'){
      //print
      inorder(root);
      printf("\n");
      print(root);
      printf("\n");
    }
  }
  return 0;
}



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

int main() {
	string s;
	cin >> s;
	int count = 0, max = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')
			count++;
		else {
			if (max < count)
				max = count;
			count = 0;
		}
	}
	if (max == 0 || max < count)
		max = count;
		cout << max << endl;
		return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s = input()
if s[2] == s[3] and s[5] == s[4]:
  print("Yes")
else:
  print("No")

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;

    vec le(26, INF), ri(26, -INF);
    rep (i, n) {
        int num = s[i] - 'a';
        chmin(le[num], i);
        chmax(ri[num], i);
    }

    int ans = -100;
    For(i, 0, n - 2) {
        int cnt = 0;
        rep (c, 26)
            if (le[c] <= i and ri[c] > i) cnt++;
        chmax(ans, cnt);
    }
    print(ans);

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,h;
    cin>>n>>h;
    vi a(n);
    vi b(n);

    int ans = 0;
    int mxa = -1;

    REP(i,n){
        cin>>a[i]>>b[i];
        if(mxa < a[i]) mxa = a[i];
    }

    sort(ALL(b));

    FORR(i,0,n){
        if(mxa<b[i]){
            h -= b[i];
            ans++;
            if(h<=0) break;
        }
    }

    if(h>0) ans += ceil((double)h / mxa);

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long N,K;
    long long H[200010];
    long long ans=0;
    cin >> N >> K;
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    sort(H,H+N);
    for(int i=0;i<N-K;i++){
        ans+=H[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
# import numpy as np
# import scipy as sp
# import sys
# input = sys.stdin.readline
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=list(map(int, input().split()))  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# a=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# a=[int(input()) for _ in range (n)]  #リスト入力  改行でa1 ... anのとき
# s=[list(map(str,list(input()))) for i in range(h)]  # 文字列の二次元配列入力
# s = [list(map(int, input().split())) for i in range(n)] # 数値の二次元配列入力
# a = b[:], a = [x[:] for x in b] # deepcopy
# chr(ord('a') + 1) # chrのインクリメント
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）

n, w = list(map(int, input().split()))
wl = [0] * n
vl = [0] * n
for i in range(n):
    wl[i], vl[i] = map(int, input().split())


dp = [[0]*(w+1)for _ in range(n+1)]  # h:item w:weight v:value
for i in range(n):
    for j in range(w+1):
        if j+wl[i] <= w:
            dp[i+1][j+wl[i]] = max(dp[i+1][j+wl[i]], dp[i][j]+vl[i])
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(dp[-1][-1])


Measured memory_bytes: 120172
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Online Judge: Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include<utility>
using namespace std;
typedef long long LL;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define ULL unsigned long long
#define MP make_pair
#define ff first
#define ss second
#define endl '\n'
#define INF LL(1e18);
#define _INF INT32_MIN
#define pq priority_queue
#define MM multimap
#define PB push_back
#define EMPP emplace_back
#define vii vector<int>
#define vll vector<LL>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sf1(v) scanf("%I64d",&v);
#define sf2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sf3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL GCD(LL a,LL b) {
	return !b ? a : GCD(b, a % b);
}
LL LCM(LL a, LL b) {
	return (a*b) / GCD(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		//printf("%d ", 2);
//		aa.insert(2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			//printf("%d ", i);
			//aa.insert(i);
			n /= i;
		}
	}
	if (n > 2){
		//printf("%d ", n);
	//	aa.insert(n);
	};
}
bool Is_Square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
LL Power(LL x, LL y)
{
	LL temp;
	if (y == 0)return 1;
	temp = Power(x, y / 2);
	if (y % 2 == 0)
		return temp*temp;
	else return x*temp*temp;
}
bool Is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
bool valid(int i, int j,int r,int h)
{
	if (i < r&&i + 1 < r&&i - 1 >= 0 && j < j&&j + 1 < h&&j - 1 >= 0)return 1;
	else return 0;
}
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	int r, h;
	cin >> r >> h;
	vector<vector<char>>s(60, vector<char>(60,'#'));
	for (int i = 1; i <= r; i++)
		for (int j = 1; j <= h; j++)
			cin >> s[i][j];
	for (int i = 1; i <= r; i++)
	{
		for (int j = 1; j <= h; j++)
		{
			if (s[i][j] == '#'&&s[i][j-1]=='.')
			{
				if (s[i - 1][j] == '.'&&s[i + 1][j] == '.'&&s[i][j + 1] == '.')
					return cout << "No\n", 0;
			}
		}
	}
	cout<<"Yes\n";
	return 0;
}

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


int main()
{	

	string st;
	cin>>st;
	if(st.size()%2==0){
	int flag=1;
	for(int i=0;i<st.size();i++)
	{
		if(i%2==0&&st[i]!='h')
			flag=0;
		if(i%2!=0&&st[i]!='i')
			flag=0;
	}
	if(flag==1)
		cout<<"Yes";
	else cout<<"No";}
	else
		cout<<"No";
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int c[10001];
bool map[10001];
int n;
void DFS(int key){
	if(key<0||key>=n)return;
	int bef,aft;
	bef=key-1;
	while(true){
		if(bef<0)break;
		if(map[bef]&&c[bef]!=c[key])break;
		bef--;
	}
	bef++;
	aft=key+1;
	while(true){
		if(aft==n)break;
		if(map[aft]&&c[aft]!=c[key])break;
		aft++;
	}
	aft--;
	int cnt=0;
	for(int i=bef;i<=aft;i++)cnt+=map[i];
	if(cnt>3){
		for(int i=bef;i<=aft;i++)map[i]=false;
		DFS(bef-1);
	}
}
int main(){
	while(true){
	cin>>n;
	if(n==0)break;
	int ans=n;
	for(int i=0;i<n;i++)cin>>c[i];
	for(int ch=0;ch<n;ch++){
		int keep=c[ch];
		for(int aft=1;aft<=3;aft++){
			if(aft!=keep){
				c[ch]=aft;
				for(int i=0;i<n;i++)map[i]=true;
				DFS(ch);
				int cnt=0;
				for(int i=0;i<n;i++)cnt+=map[i];
				ans=min(ans,cnt);
			}
		}
		c[ch]=keep;
	}
	cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

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

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
vector<int> s;
vector<int> t;
const ll MOD = 1e9 + 7;
ll f() 
{ 
    ll n1 = sz(s); 
    ll n2 = sz(t); 
    vector<vector<ll>> dp (n1 + 1, vector<ll>(n2 + 1));
    for (ll i = 0; i <= n1; i++) { 
        for (int j = 0; j <= n2; j++) { 
            dp[i][j] = 0; 
        } 
    } 
    for (int i = 1; i <= n1; i++) 
    { 
        for (int j = 1; j <= n2; j++) 
        { 
            if (s[i - 1] == t[j - 1])  
            {
                dp[i][j] = (1 + dp[i][j - 1] + dp[i - 1][j] + MOD) % MOD;             
            }
            else 
            {
                dp[i][j] = (dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - 1] + MOD) % MOD;             
            }
        } 
    } 
    return (dp[n1][n2] % MOD); 
} 
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    s.assign(n, 0);
    t.assign(m, 0);
    F0R(i, n) cin >> s[i];
    F0R(i, m) cin >> t[i];
    cout << (f() + 1) % MOD;
    return 0;
}

Measured memory_bytes: 31616
#include <stdio.h>

int main(){
  int a, b, c;

  scanf("%d %d %d\n", &a, &b, &c);
  
  if(a < b && a < c)
    if(b < c)
      printf("Yes\n");
    else
      printf("No\n");
  else
    printf("No\n");
    
  return 0;
}

Measured memory_bytes: 584
import sys
readline = sys.stdin.readline

inf = 10**9+7
def dfs(s, Edge):
    dist = [inf]*N
    dist[s] = 0
    stack = [s]
    used = set([s])
    while stack:
        vn = stack.pop()
        for vf in Edge[vn]:
            if vf not in used:
                used.add(vf)
                dist[vf] = 1+dist[vn]
                stack.append(vf)
    return dist                

def calc(v1, v2, Dim):
    d1 = dfs(v1, Edge)
    d2 = dfs(v2, Edge)
    di1 = [0]*N
    di2 = [0]*N
    for i in range(N):
        if d1[i] < d2[i]:
            di1[d1[i]] = max(di1[d1[i]], Dim[i] - 1)
        else:
            di2[d2[i]] = max(di2[d2[i]], Dim[i] - 1)
    K = [max(f1, f2) for f1, f2 in zip(di1, di2)]
    res = 1
    for k in K:
        if not k:
            continue
        res = res*k
    return 2*res

N = int(readline())

Edge = [[] for _ in range(N)]
Dim = [0]*N
for _ in range(N-1):
    a, b = map(int, readline().split())
    a -= 1
    b -= 1
    Edge[a].append(b)
    Edge[b].append(a)
    Dim[a] += 1
    Dim[b] += 1

dist0 = dfs(0, Edge)
vfst = dist0.index(max(dist0))
dist1 = dfs(vfst, Edge)
D = max(dist1)
dist0 = dfs(dist1.index(D), Edge)
ans = inf
if D&1:
    C1 = [i for i in range(N) if dist1[i] == D//2 and dist0[i] == D//2+1]
    C2 = [i for i in range(N) if dist1[i] == D//2+1 and dist0[i] == D//2]
    for c1 in C1:
        for c2 in C2:
            ans = min(ans, calc(c1, c2, Dim))
else:
    c = [i for i in range(N) if dist1[i] == D//2 and dist0[i] == D//2]
    c = c[0]
    dic = [0]*N
    dic[0] = Dim[c]
    dc = dfs(c, Edge)
    for i in range(N):
        dic[dc[i]] = max(dic[dc[i]],Dim[i]-1)
    ans = 1
    for i in range(N):
        if dic[i]:
            ans = ans*dic[i]
    for vc in Edge[c]:
        ans = min(ans, calc(vc, c, Dim))
print(-(-(D+1)//2), ans)

Measured memory_bytes: 41712
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9
int N, K;
int arr[100010];
int L, R;
void input() {
	scanf("%d %d", &N, &K);
	for (int i = 0; i < N; i++) {
		scanf("%d", &arr[i]);
		if (arr[i] < 0) {
			L++;
		}
		else if (arr[i] == 0) {
			K--;
			N--;
			i--;
		}
	}
}
int main() {
	input();
	int sol = INF;
	if (K == 0) {
		puts("0");
		return 0;
	}
	for (int i = 0; i < N; i++) {
		int val = INF;
		if (i < L) {
			int left = i, right = (i + K-1);
			if (right < N) {
				val = abs(arr[i]);
				if (right >= L) {
					val+=abs(arr[right] - arr[left]);
				}
			}
		}
		else {
			int left = (i-K+1), right = i;
			if (left >= 0) {
				val = abs(arr[i]);
				if (left < L) {
					val += abs(arr[right] - arr[left]);
				}
			}
		}
		sol = min(sol, val);
	}
	printf("%d\n", sol);
}

Measured memory_bytes: 640
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    println(48-parseInt(readline()))
end
main()

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

bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){ //合成数ならば, sqrt(n)以下の約数を持つ. もしそうでないならば, nは素数である
        if(n % i == 0) return false;
    }
    return n != 1;
}

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

    for(int i = x; i <=100003; i++){
        if(is_prime(i)){
            cout << i << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 256
from itertools import count, takewhile, dropwhile
 
def dfs(n, max9, max6, d={0:0}):
    if n in d: return d[n]
  
    max9 = next(dropwhile(lambda x: x>n, (max9 / 9**i for i in count())))
    max6 = next(dropwhile(lambda x: x>n, (max6 / 6**i for i in count())))
    d[n] = min(dfs(n-max9, max9, max6), dfs(n-max6, max9, max6)) + 1
    return d[n]
 
n = int(input())
 
max9 = max(takewhile(lambda x: x<=n, (9**i for i in count())))
max6 = max(takewhile(lambda x: x<=n, (6**i for i in count())))
 
print(dfs(n, max9, max6))

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

int main(){
    int A,B,K;
    cin >> K;
    cin >> A >> B ;
    int l = B-A+1;
    if(l>=K || A%K==0 || B%K==0){cout << "OK" << endl;}
    else{
        if((A%K) > (B%K)){cout << "OK" << endl;}
        else{cout << "NG" << endl;}


    }

    return 0;
}

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

int main(){
    char b;
    cin >> b;
    if(b=='A'){
        cout << 'T' << endl;
    }else if(b=='T'){
        cout << 'A' << endl;
    }else if(b=='G'){
        cout << 'C' << endl;
    }else if(b=='C'){
        cout << 'G' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
s = list(input())[: -1]
i = 0
j = len(s) - 1
res = 0
while i < j:
  if s[i] != s[j]:
    res += 1
    if s[i] == "x":
      i += 1
    elif s[j] == "x":
      j -= 1
    else:
      print(-1)
      exit(0)
  else:
    i += 1
    j -= 1
print(res)

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

using namespace std;

string s, t;

string RRotate(string x)
{
    char c = x[x.size()-1];
    for (int i=s.size()-1; i>=0; i--)
        x[i+1]=x[i];
    x[0]=c;
    return x;
}

int main()
{
    cin>>s>>t;
    for (int i=0; i<s.size(); i++)
    {
        if (s==t)
        {
            cout<<"Yes";
            return 0;
        }
        s = RRotate(s);
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

ll a, b, c, d;

ll lcm(ll a, ll b)
{
    return abs(a * b) / __gcd(a, b);
}

ll f(ll n)
{
    ll dc = n / c;
    ll dd = n / d;
    ll dcd = n / lcm(c, d);
    return n - dc - dd + dcd;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> a >> b >> c >> d;
    cout << f(b) - f(a - 1);
}


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int d, t, s;
  cin >> d >> t >> s;
  double tt = (double)d / s;
  if (tt < (double)t || fabs(tt - t) < 1e-6) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;

typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}

ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll ans;
    string s;
    cin >> s;
    if (s=="SAT")ans=1;
    if (s=="FRI")ans=2;
    if (s=="THU")ans=3;
    if (s=="WED")ans=4;
    if (s=="TUE")ans=5;
    if (s=="MON")ans=6;
    if (s=="SUN")ans=7;
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int n;
	string s[51],x;
	int t[51];
	cin>>n;
	rep(i,n)cin>>s[i]>>t[i];
	cin>>x;
	int f=0,t2=0;
	rep(i,n){
		if(x==s[i])f=1;
		else if(f==1)t2+=t[i];
	}
	cout<<t2<<endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
d = {}
for a in A:
    if a not in d:
        d[a] = 0
    d[a] += 1

n = 0

d2 = {}

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

for i in range(N):
    x = d[A[i]]-1
    print(n - d2[A[i]] + x*(x-1)//2)

Measured memory_bytes: 32672