akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _data {
        int pre;
        int this;
        int trading_time;
} data_t;

int main()
{
        data_t d[1001];
        int i = 0, c, di;
        char * p, tmp1[5], tmp2[3], tmp[8];
        while ( i < 1001 ) {
                d[i].pre = 0;
                d[i].this = 0;
                d[i].trading_time = 0;
                i++;
        }

        while ( fgets( tmp, 8, stdin ) != NULL ) {
                if ( tmp[0] == '\n' ) { break; }

                i = 0;
                while ( tmp[i] != ',' ) {
                        tmp1[i] = tmp[i];
                        i++;
                }
                tmp1[i] = '\0';
                c = atoi( tmp1 );
                di = atoi( &tmp[i+1] );
                d[c].pre = di;
                d[c].trading_time++;
        }


        while ( scanf( "%d,%d", &c, &di ) == 2 ) {
                d[c].this = di;
                d[c].trading_time++;
        }

        for ( i = 0 ; i < 1001 ; i++ ) {
                if ( d[i].this > 0 && d[i].pre > 0 ) {
                        printf( "%d %d\n", i, d[i].trading_time );
                }
        }

        return 0;
}



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

#define ll long long int

using namespace std;


int solve(){
	
	int x,n;
	cin>>x>>n;
	

	
	int temp;
	set<int> s;
	for(int i=0; i<n; i++){
		cin>>temp, s.insert(temp);
		}
		
	if (s.find(x) == s.end()){
		return x;
		}
		
	for(int i=1; i<=1000; i++){
		if (s.find(x-i) == s.end())
			return x-i;
		if (s.find(x+i) == s.end())
			return x+i;
		}
	
	return 0;
	}


int main(){
	

	int k = solve();
	
	cout<<k<<endl;
	
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,from,to) for (int i=(from);i<=(to);i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define MOD 1000000007

ll a[100000];

int main () {
  int N;
  ll L;
  while (cin >> N >> L) {
    REP(i, N) scanf("%lld", a + i);

    bool ok = false;
    REP(i, N - 1) {
      if (a[i] + a[i + 1] >= L) {
        puts("Possible");
        for (int j = 0; j < i; j++) printf("%d\n", j + 1);
        for (int j = N - 1; j > i; j--) printf("%d\n", j);
        ok = true;
        break;
      }
    }
    if (!ok) puts("Impossible");
  }

  return 0;
}


Measured memory_bytes: 1536
#include<iostream>


int main(void){
	int W,H,x,y,r;
	bool flag = true;

	std::cin >> W >> H >> x >> y >> r;


	if(x+r > W ) flag = false;
	if(y+r > H ) flag = false;
	if(x-r < 0) flag = 0;
	if(y-r < 0) flag = 0;

	if(flag == true){
		std::cout << "Yes" << std::endl;
	}else {
		std::cout << "No" << std::endl;
	}


}

Measured memory_bytes: 3084
import math
import numpy as np
h_len,s_len,h_time,s_time = map(int,input().split())
#h_time = h_time%24
h_time = h_time%12
h_rad = ((h_time*60 + s_time)/720.0)*360
s_rad = (s_time/60.0)*360
sub_rad = abs(h_rad-s_rad)
if sub_rad%180!= 0 and sub_rad >= 180:
    sub_rad -= 360

#print([h_rad,s_rad,sub_rad])

#print([h_len,s_len,2*h_len*s_len*math.cos(math.radians(sub_rad))])

obj_len = h_len**2 + s_len**2 - 2*h_len*s_len*math.cos(math.radians(sub_rad))
print(np.sqrt(obj_len))

Measured memory_bytes: 27192
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		sc.close();
		long INF = 1000000007;

		String[][] count = new String[2][26];

		HashMap<String,Integer> map = new HashMap<String,Integer>();

		for(char c = 'a';c < ('a' + 26);c++) {
		    map.put(String.valueOf(c),1);
		}

		for(int i = 0 ; i < S.length(); i++){
				map.put(S.substring(i, i+1),1+map.get(S.substring(i, i+1)));
		}

		long ans = 1;
		for(String key : map.keySet()){
			ans *= map.get(key);
			ans %= INF;
		}
		ans--;
		System.out.println(ans);
	}
}

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

using namespace std;

int main()
{
//    freopen("in.txt","r",stdin);

    string s;
    string p;
    while(cin>>s)
    {
        cin>>p;
        int ok=0;
        int lens=s.length();
        int lenp=p.length();
        for(int i=0;i<lens;i++)
        {
            int j;
            for(j=0;j<lenp;j++)
            {
                if(s[(i+j)%lens]!=p[j])
                    break;
            }
            if(j==lenp)
            {
                ok=1;
                break;
            }
        }
        if(ok)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

struct Bipartite_Matching
{
  vector< vector< int > > graph;
  vector< int > match, alive, used;
  int timestamp;
 
  Bipartite_Matching(int n)
  {
    timestamp = 0;
    graph.resize(n);
    alive.assign(n, 1);
    used.assign(n, 0);
    match.assign(n, -1);
  }
 
  void add_edge(int u, int v)
  {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
 
  bool dfs(int v)
  {
    used[v] = timestamp;
    for(int i = 0; i < graph[v].size(); i++) {
      int u = graph[v][i], w = match[u];
      if(alive[u] == 0) continue;
      if(w == -1 || (used[w] != timestamp && dfs(w))) {
        match[v] = u;
        match[u] = v;
        return (true);
      }
    }
    return (false);
  }
 
  int bipartite_matching()
  {
    int ret = 0;
    for(int i = 0; i < graph.size(); i++) {
      if(alive[i] == 0) continue;
      if(match[i] == -1) {
        ++timestamp;
        ret += dfs(i);
      }
    }
    return (ret);
  } 
};

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

    int N;
    cin >> N;
    vector<P> v;
    REP(i, N){
        int x, y;
        cin >> x >> y;
        v.emplace_back(x, y);
    }    
    Bipartite_Matching BM(2*N);
    REP(i, N){
        int x, y;
        cin >> x >> y;
        REP(j, N){
            if(v[j].first < x && v[j].second < y){
                BM.add_edge(j, N+i);
            }
        }
    }

    cout << BM.bipartite_matching() << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int a[214514],sum[214514];
signed main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		a[i]--;
	}
	map<int,int> mope;
	int ans = 0;
	mope[0] = 1;
	for(int i=1;i<=n;i++){
		sum[i] = sum[i-1] + a[i];
		if( i >= k ) mope[ sum[i-k] % k ] --;
		ans += mope[ sum[i] % k ];
		//cout << mope[ sum[i] % k ] <<endl;
		mope[ sum[i] % k ] ++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15872
N, u, v = map(int, input().split())
u -= 1
v -= 1
tonari = [[] for _ in range(N)]
for _ in range(N-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  tonari[a].append(b)
  tonari[b].append(a)

d_from_u = [float('inf') for _ in range(N)]
d_from_v = [float('inf') for _ in range(N)]
d_from_u[u] = 0
d_from_v[v] = 0
#print(tonari)
now = [v] #追いかける方
d = 0
while now:
  d += 1
  nextvisit = []
  for n in now:
    for t in tonari[n]:
      if d_from_v[t] > d:
        d_from_v[t] = d
        nextvisit.append(t)
  now = nextvisit



now = [u] #逃げる方
d = 0
while now:
  d += 1
  nextvisit = []
  for n in now:
    for t in tonari[n]:
      if d_from_v[t] <= d: #追いかける方より遠い地点は排除
        continue
      elif d_from_u[t] > d:
        d_from_u[t] = d
        nextvisit.append(t)
  now = nextvisit


distance = []
ans = 0
for U, V in zip(d_from_u, d_from_v):
  if U < N+1: #infを排除
    ans = max(ans, V-1)
print(ans)

Measured memory_bytes: 97092
#include <iostream>

using namespace std;

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

    int cnt = 0;
    for (int i=1; i<=n; i++) {
        int p;
        cin >> p;
        if (i != p) cnt++;
    }

    cout << (cnt<3?"YES":"NO") << endl;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	string S[3];
	for (int i = 0; i < 3; i++) {
		cin >> S[i];
	}
	int res = 0;
	for (int i = 0; i < N; i++) {
		vector<char> X;
		for (int j = 0; j < 3; j++){
			X.push_back(S[j][i]);
		}
		sort(X.begin(), X.end());
		if (X[0] == X[1]) {
			if(X[1] == X[2]){
			}
			else {
				res++;
			}
		}
		else if (X[1] == X[2]) {
			res++;
		}
		else {
			res += 2;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
#define next ____next
#define prev ____prev
#define left ____left
#define hash ____hash
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class A, class B, class C> struct Triple { A first; B second; C third;
  bool operator<(const Triple& t) const { if (st != t.st) return st < t.st; if (nd != t.nd) return nd < t.nd; return rd < t.rd; } };
template<class T> void ResizeVec(T&, vector<int>) {}
template<class T> void ResizeVec(vector<T>& vec, vector<int> sz) {
  vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }
  for (T& v : vec) { ResizeVec(v, sz); }
}
typedef Triple<int, int, int> TIII;
template<class A, class B, class C>
ostream& operator<< (ostream &out, Triple<A, B, C> t) { return out << "(" << t.st << ", " << t.nd << ", " << t.rd << ")"; }
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }

    
int32_t main() {

  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);
  cin.tie(0);
  //double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;
  
  string s;
  cin>>s;
  if (SZ(s) >= 4 && s.substr(0, 4) == "YAKI") {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  return 0;
}


Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split())) #リストで複数行作るには？

count = 0

for i in range(2, N):
    for j in range(1, i):
        for k in range(0, j):
            if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
                continue
            elif L[k] < L[i] + L[j] and L[i] < L[j] + L[k] and L[j] < L[i] + L[k]:
                count += 1

print(count)

Measured memory_bytes: 9120
N = int(input())
A = [int(input()) for _ in range(N)]

a = [0]+A
visit = [False for _ in range(N+1)]
q = [1]
length = 0
while True:
    to = q.pop()
    if visit[to]:
        print('-1')
        break
    if to==2:
        print(length)
        break
    visit[to] = True
    q.append(a[to])
    length += 1

Measured memory_bytes: 8620
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<random>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 1145141919
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
typedef pair<int, P> PP;
struct edge { int u, v, cost; };
int a[114514];
int rwa[114514];
map<int, int>M;
vector<int>V;
signed main() {
	int n, m; cin >> n >> m;
	rep(i, n)cin >> a[i];
	rep(i, n)rwa[i + 1] = a[i];
	rep(i, n)rwa[i + 1] += rwa[i];
	rep(i, n+1) {
		M[rwa[i] % m]++;
	}
	int ans = 0;
	for (auto itr = M.begin(); itr != M.end(); itr++) {
		int C = itr->second*(itr->second - 1) / 2;
		ans += C;
	}
	cout << ans << endl;
}


Measured memory_bytes: 5760
def main():
	N, M = map(int, input().split())
	lst = [0] * N

	for _ in range(M):
		a, b = map(int, input().split())
		lst[a - 1] += 1
		lst[b - 1] += 1

	for i in range(N):
		print(lst[i])

  
if __name__ == "__main__":
  	main()

Measured memory_bytes: 9100
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int,input().split())
P = list(map(int,input().split()))
XY = [list(map(int,input().split())) for _ in range(M)]
pos = [0] * (N + 1)
for i in range(N):
  pos[P[i]] = i
#print(pos)
uf = UnionFind(N)
for i in range(M):
  uf.union(XY[i][0]-1,XY[i][1]-1)
#print(uf)
ans = 0
for i in range(N):
  if uf.same(i,pos[i+1]):
    ans += 1
print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int sum_Alice = 0;
  int sum_Bob = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      sum_Alice += a.at(i);
    }
    else {
      sum_Bob += a.at(i);
    }
  }
  cout << sum_Alice - sum_Bob << endl;
}


Measured memory_bytes: 3600
#include <stdio.h>
int main(){
  int n,q,i,j,count=0,flag=0;;
  scanf("%d",&n);
  int S[n];
  for(i =0 ; i<n ;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  int T[q];
  for(i =0 ; i<q ;i++){
    scanf("%d",&T[i]);
  }
  
  for(i =0 ;i<q;i++){
    for(j = 0 ;j<n;j++){
      if(flag==1) {
	j=0;
	flag = 0;
      }
      if(S[j] ==T[i]){
	count++;
	flag=1;
	if(i == q-1){
	  break;}
	i++;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}

  



Measured memory_bytes: 2124
#include <iostream>
#include <string>

using namespace std;

int main(){

    string S,T;
    cin >> S >> T;

    for(int i=0; i<S.size(); ++i){
        if(S[i]!=T[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int alice=0;
  int bob=0;
  for (int i=0;i<n;i++){
    if (i%2==0){
      alice=alice+a[i];
    }
    if (i%2!=0){
      bob=bob+a[i];
    }
  }
  cout << alice-bob<<endl;
}

Measured memory_bytes: 256
func readFourInts(separator: String.Element = " ") -> (a: Int, b: Int, c: Int, d: Int) {
    let ints = readLine()!.split(separator: separator).map { Int($0)! }
    return (a: ints[0], b: ints[1], c: ints[2], d: ints[3])
}

func mainB() {
    let (a, b, c, d) = readFourInts()
    let results = [a * c, a * d, b * c, b * d]

    print(results.max()!)
}
mainB()

Measured memory_bytes: 8264
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int N, M;
char A[50][55], B[50][55];

int main() {
    cin >> N >> M;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < M; ++i) {
        cin >> B[i];
    }

    bool ok = false;
    for (int sx = 0; sx < N-M+1; ++sx) {
        for (int sy = 0; sy < N-M+1; ++sy) {
            bool identical = true;
            for (int x = 0; x < M; ++x) {
                for (int y = 0; y < M; ++y) {
                    if (A[sx+x][sy+y] != B[x][y]) {
                        identical = false;
                    }
                }
            }
            if (identical) ok = true;
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#define int long long
using namespace std;
signed main() {
	string s; cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '9')cout << 1;
		else if (s[i] == '1')cout << 9;
		else cout << s[i];
	}cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

int main() {
    int N;
    cin >> N;
    map<int, int> hist;
    for (int i = 0; i < N; i++) {
        int ai;
        cin >> ai;
        hist[ai - 1]++;
        hist[ai]++;
        hist[ai + 1]++;
    }
    int max = 1;
    for (auto h : hist) {
        int x = h.second;
        if (max < x) {
            max = x;
        }
    }
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 4736
from operator import itemgetter

def main():
    N = int(input())
    point = set()
    for _ in range(N):
        x, y = map(int, input().split())
        point.add((x,y))
    #point = np.array(point)
    #oint = np.unique(point)
    if len(point) == 1:
        print(0)
        exit()
    
    t = []
    for x, y in point:
        l_00 = x + y
        l_0m = x + 10**9-y
        l_m0 = 10**9-x + y
        l_mm = 10**9-x + 10**9-y
        t.append(((x,y), l_00, l_0m, l_m0, l_mm))
    ans = 0
    for pos in range(1,5):
        t.sort(key=itemgetter(pos))
        l, r = t[0][0], t[-1][0]
        ans = max(ans,
            abs(l[0]-r[0])+abs(l[1]-r[1]))
    print(ans)

if __name__ == '__main__':
    main()

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

int main(){
  ll n, k;
  cin >> n >> k;
  ll l[k], r[k];
  rep(i,k) cin >> l[i] >> r[i];
  vector<ll> dp(n), sum(n);
  dp[0] = 1, sum[0] = 1;
  for(int i = 1; i < n; i++) {
    rep(j,k) {
      if(i-l[j] >= 0) (dp[i] += sum[i-l[j]]) %= mod;
      if(i-r[j]-1 >= 0) (dp[i] -= sum[i-r[j]-1]) %= mod;
    }
    sum[i] = (sum[i-1] + dp[i]) % mod;
  }
  if(dp[n-1] < 0) dp[n-1] += mod;
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 6424
#include <iostream>
using namespace std;
int main(void){
    int X;
    cin >> X;
    
    if(X%7 == 0) cout << "thu" << endl;
    else if(X%7 == 1) cout << "fri" << endl;
    else if(X%7 == 2) cout << "sat" << endl;
    else if(X%7 == 3) cout << "sun" << endl;
    else if(X%7 == 4) cout << "mon" << endl;
    else if(X%7 == 5) cout << "tue" << endl;
    else if(X%7 == 6) cout << "wed" << endl;
    
    return 0;
    
}



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

long long f(long long a) {
         long long res[] = {a,1,a+1,0};
         return res[a%4];
    }

long long getXor(long long a, long long b) {
  		 if (a>1) return f(b)^f(a-1);
  		 else {
           return f(b)^0;
         }
    }

int main() {
    long long a,b;
    cin >> a >> b;
    
   
    cout << getXor(a,b);
}

    


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

int main(){
	int a[4][4]={};
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			scanf("%d",&a[i][j]);
		}
	}
	if((a[0][2]+a[1][1]+a[2][0]==a[0][1]+a[1][0]+a[2][2]) && (a[0][2]+a[1][1]+a[2][0]==a[0][0]+a[1][2]+a[2][1]))printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <numeric>
#include <iomanip>
#define FI first
#define SE second
#define EB emplace_back
#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 1100000000
#define LLINF 1100000000000000000LL
#define Decimal fixed << setprecision(20)
#define ALL(c) c.begin(),c.end()
#define SHOWVEC(v, sz) for(int i = 0; i < sz; i++) cerr << v[i] << ' '; cerr << endl;
#define SHOWX(x) cerr << #x << ": " << x << endl;
#define SHOWP(p) cerr << "[" << p.first << ',' << p.second << "]";

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main()
{
  int N; cin >> N;
  string S; cin >> S;
  S.push_back('#');
  ll ans = 0;
  REP(i, S.size() - 1) {
    if (S[i] != S[i + 1]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int N=in();
	vector<int> P(N),Q(N);
	REP(i,N){
		P[i] = in();
		Q[i] = P[i];
	}
	sort(ALL(Q));
	int diff = 0;
	for(int i=0;i<N;i++){
		if(P[i]!=Q[i]) diff++;
	}
	cout << ((diff==2 || diff==0) ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.LinkedList;
import java.util.Scanner;

public class Main{
	public static double EPS = 1e-6;
	public static void main(String[] args) throws IOException{
		Scanner in = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			if(n == 0) break;
			Circle[] c = new Circle[n];
			LinkedList<Point> p = new LinkedList<Point>();
			for(int i=0; i<n; i++){
				c[i] = new Circle(in.nextDouble(), in.nextDouble(), 1);
				for(int j=i-1; j>=0; j--){
					Point[] pos = c[i].crossPoint(c[j]);
					if(pos == null) continue;
					p.add(pos[0]);
					p.add(pos[1]);
				}
			}
			int res = 1;
			for(Point pos: p){
				int count = 0;
				for(int i=0; i<n; i++){
					if(pos.dist2(c[i].p) <= 1+EPS) count++;
				}
				res = Math.max(res, count);
			}
			System.out.println(res);
		}
	}
}

class Circle{
	final static double EPS = 1e-6;
	
	Point p;
	double r;
	public Circle(double x, double y, double r){
		p = new Point(x, y);
		this.r = r;
	}
	
	public Point[] crossPoint(Circle c){
		if(!cross(c)) return null;
		double x1 = c.p.x - p.x;
		double y1 = c.p.y - p.y;
		double a = (x1*x1+y1*y1+r*r-c.r*c.r)/2.0;
		Point[] res = {
				new Point(culc(x1, y1, r, a, true)+p.x, culc(y1, x1, r, a, false)+p.y),
				new Point(culc(x1, y1, r, a, false)+p.x, culc(y1, x1, r, a, true)+p.y),
		};
		return res;
	}
	
	private static double culc(double x, double y, double r, double a, boolean sign){
		return (a*x + (sign?1:-1)*y*Math.sqrt((x*x+y*y)*r*r-a*a)+EPS)/(x*x+y*y);
	}
	
	public boolean cross(Circle c){
		return p.dist2(c.p) <= (r+c.r)*(r+c.r) + EPS;
	}
}

class Point{
	double x, y;
	public Point(double x, double y){
		this.x = x;
		this.y = y;
	}
	
	public double dist2(Point p){
		return (x-p.x)*(x-p.x) + (y-p.y)*(y-p.y);
	}
}

Measured memory_bytes: 58156
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back

using namespace std;
typedef long long ll;

string S;
bool dfs(string str, int sum, int d) {
  if (str.size() == 7) {
    if (sum == 7) {
      cout << str << "=7" << endl;
      return true;
    }
    return false;
  }
  if (dfs(str + "+" + S[d], sum + (S[d] - '0'), d + 1)) return true;
  if (dfs(str + "-" + S[d], sum - (S[d] - '0'), d + 1)) return true;
  return false;
}

int main()
{
  cin >> S;
  dfs(string(1, S[0]), S[0] - '0', 1);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#pragma warning(disable : 4996) //_CRT_SECURE_NO_WARNINGS

int calc(long n, long k,int cnt) {
	if (n < k)return cnt+1;
	return calc(n / k, k, cnt+=1);
}

int main(void) {
	long n, k;
	int cnt = 0;
	scanf("%ld%ld", &n, &k);
	printf("%d",calc(n,k,cnt));
	return 0;
}

Measured memory_bytes: 128
from bisect import bisect_left
try:
    from collections.abc import Sequence
except:
    from collections import Sequence


class LazySequence(Sequence):
    def __init__(self, f, n):
        self.f = f
        if isinstance(n, int):
            self.r = range(n)
        elif isinstance(n, range):
            self.r = n
        else:
            raise TypeError

    def __len__(self):
        return len(self.r)

    def __getitem__(self, i):
        r = self.r[i]
        if isinstance(r, int):
            return self.f(r)
        else:
            return self.__class__(self.f, r)


N, A, B = map(int, input().split())
D = A - B
H = [int(input()) for _ in range(N)]
H.sort()
l = (H[0] - 1) // A + 1
r = (H[-1] - 1) // B + 1


def isenough(n):
    b = B * n
    for h in H:
        n -= max(0, (h - b - 1) // D + 1)
        if n < 0:
            return False
    return True


a = LazySequence(isenough, r + 1)
ans = bisect_left(a, True, l, r)
print(ans)


Measured memory_bytes: 7736
N = int(input())
L = {}
for i in range(N):
  A = input()
  if not A in L:
    L[A] = 1
  else:
    L[A] += 1
S = []
maxv = 0
for i in L.keys():
  if L[i] == maxv:
    S.append(i)
  elif L[i] > maxv:
    S = [str(i)]
    maxv = L[i]
S.sort()
print("\n".join(S))

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

ll K;
ll ans_max = -1;
ll ans_min = INF;

int main(){
    cin >> K;
    vector<ll> A;

    rep(i,K) {
        ll a;
        cin >> a;
        A.push_back(a);
    }

    reverse(A.begin(),A.end());
    vector<ll> Bmin,Bmax;

    Bmin.push_back(2);
    Bmax.push_back(2);
    bool t = true;
    rep(i,K-1) {
        ll bmax = Bmax[i]+A[i]-1;
        ll bmin = Bmin[i];
        //cout << i << " " << bmin << " " << bmax << endl;
        if (bmax%A[i+1]!=0) {
            bmax -= bmax%A[i+1];
        }
        if (bmin%A[i+1]!=0) {
            bmin += A[i+1] - bmin%A[i+1];
        }
        //cout << i << " " << bmin << " " << bmax << endl;
        if ((bmin>Bmax[i]+A[i]-1) || (bmax<Bmin[i])) {
            t = false;
            break;
        }
        Bmax.push_back(bmax);
        Bmin.push_back(bmin);
    }

    if (t && A[0]==2) {

        cout << Bmin.back() << " " << Bmax.back()+A[K-1]-1 << endl;
    }
    else {
        cout << -1 << endl;
    }
}


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) <= (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int N;
vector<vector<int>> g;
vector<int> a;
vector<bool>homon;
constexpr int maxi = 2e5+3;
int length, L[maxi];
vector<int> ans;

void dfs(int v){
  int id=-1, b=0, lb = length;
  if(L[length-1] < a[v]){
    L[length++] = a[v];
  }
  else{
    int left = -1, right = length;
    while(abs(left-right)> 1){
      int mid = (left+right) / 2;
      if(L[mid] >= a[v]){
        right = mid;
      }
      else{
        left =mid;
      }
    }
    if(right != length){
      id = right;
      b = L[id];
      L[id] = a[v];
    }
  }
  ans[v] = length;
  for(auto nv : g[v]){
    if(homon[nv]) continue;
    homon[nv] = true;
    dfs(nv);
  }
  length = lb;
  if(id!=-1){
    L[id] = b;  
  }
}
int main(){
  cin >> N;
  a.resize(N), ans.resize(N), homon.resize(N, false);
  REP(i, N){
    cin >> a[i];
  }
  g.resize(N);
  REP(i, N-1){
    int u, v;
    cin >> u >> v;
    u--, v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  L[0] = a[0];
  length = 1;
  ans[0] = 1;
  homon[0] = true;
  for(auto nv: g[0]){
    homon[nv] = true;
    dfs(nv);
  }
  REP(i, N){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 30004
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <list>
#include <map>
#include <algorithm>

#define min_3(a, b, c) min(a, min(b, c))

typedef long long ll;
using namespace std;

int alph = 26;
int main()
{
    string w; cin >> w;
    int alph_count[alph] = {};
    for (int i = 0; i < w.size(); i++){
        alph_count[w[i] - 'a']++;
    }
    
    bool ok = true;
    for (int i = 0; i < alph; i++){
        if(alph_count[i] % 2 != 0){
            ok = false;
            break;
        }
    }
    if(ok == true) cout << "Yes" << endl;
    else cout << "No" << endl;
}  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


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





int main() {

	ll x;
	cin >> x;
	if (x < 1200) { cout << "ABC"; }
	else { cout << "ARC"; }


	system("PAUSE");
}


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

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

    vector<ll>a(n);
    rep(i,n)cin>>a[i];

    ll ans=0;

    rep2(i,1,n-1){
        if(a[i-1]>a[i]){
            ans+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }

    cout<<ans<<endl;
}


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

using namespace std;

inline int read(){
	char ch=getchar();int x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}

int main(){
	int n=read();
	if(n%2==0) cout<<n;
	else cout<<2*n;

	return 0;
}


Measured memory_bytes: 256
# D - Sum of Large Numbers
from itertools import accumulate


def main():
    N, K = map(int, input().split())
    MOD = 10 ** 9 + 7
    cumsum_left = tuple(accumulate(range(N + 1)))
    cumsum_right = tuple(accumulate(range(N + 1)[::-1]))
    total = sum(r - l + 1 for l, r in zip(cumsum_left[K - 1 :], cumsum_right[K - 1 :]))
    total %= MOD
    print(total)


if __name__ == "__main__":
    main()


Measured memory_bytes: 33268
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

#define fastio                              ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
#define read                                freopen("input.txt", "r", stdin);
#define write                               freopen("output.txt", "w", stdout);
#define nl                                  '\n'
#define mem(v,n)                            memset(v,n,sizeof(v))
#define debug(x)                            cerr << #x << " = " << x << nl
#define LCM(a,b)                            (a / __gcd(a,b) ) *b
#define GCD(a,b)                            __gcd(a,b)

#define ll                                  long long
#define ull                                 unsigned long long
#define vi                                  vector<int>
#define pb                                  push_back
#define vpii                                vector<pair<int, int>>
#define vpll                                vector<pair<ll, ll>>
#define mp                                  make_pair
#define ff                                  first
#define ss                                  second
#define all(v)                              v.begin(), v.end()
#define rsort(v)                            sort(v.rbegin(), v.rend())

using namespace std;

const double pi = 2*acos(0.0);



int main(){
    //fastio;
    //read;
    int n, x;
    cin >> n;
    int f[n+1];
    mem(f, 0);
    for(int i = 1; i < n; i++){
        cin >> x;
        f[x]++;
    }
    for(int i = 1; i <= n; i++) cout << f[i] << nl;
}















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

int N,M;
string S[100010];

int main(){
    cin >> N;
    map<string,vector<int>> m;
    int id = 0;
    string C; int D;
    for(int i=0;i<N;i++){
        cin >> C >> D;
        m[C].push_back(D);
    }
    for(auto x:m) sort(m[x.first].begin(),m[x.first].end());
    cin >> M;
    for(int i=0;i<M;i++) cin >> S[i];
    reverse(S,S+M);
    int now = 1e9;
    for(int i=0;i<M;i++){
        bool ok = false;
        while(true){
            if(m.count(S[i])==0) break;
            if(m[S[i]].size()==0){
                m.erase(S[i]);
                break;
            }
            if(m[S[i]].back()>=now) m[S[i]].pop_back();
            else{
                now = m[S[i]].back();
                m[S[i]].pop_back();
                ok = true;
                break;
            }
        }
        if(!ok){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main(){
  string s;cin>>s;
  string a,b;
  a =s.substr(0,s.size()/2);
  b =s.substr((s.size()+1)/2,s.size()/2);
  bool ok=true;

  rep(i,s.size()/2){
    if(s[i]!=s[s.size()-i-1]) ok=false;
    
  }
  rep(i,(s.size()/2)/2){
    if(a[i]!=a[s.size()/2-i-1]) ok=false;
    if(b[i]!=b[s.size()/2-i-1]) ok=false;
  }
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll n; string s; cin >> n >> s;
    ll ans = 200005;
    bool z = false;
    vector<ll> bl(n,0), wh(n,0);
    if(s[0] == '#') bl[0] = 1; else wh[0] = 1;
    for(ll i = 1; i < n; ++i){
        if(s[i] == '#') bl[i] = bl[i-1] + 1, wh[i] = wh[i-1];
        else wh[i] = wh[i-1] + 1, bl[i] = bl[i-1];
    }
    if(wh[n-1] == n || bl[n-1] == n){
        cout << 0 << endl;
        return 0;
    }
    //rep(i, n) cout << bl[i] << " ";
    //cout << endl;
    //rep(i, n) cout << wh[i] << " ";
    //cout << endl;
    rep(i,n){
        ll tmp = 0;
        if(s[i] == '#'){
            tmp += wh[n-1] - wh[i];
            if(i > 0) tmp += bl[i-1];
            ans = min(ans, tmp);
        }else{
            tmp += wh[n-1] - wh[i];
            tmp += bl[i];
            ans = min(ans, tmp);
        }
        //cout << tmp << " ";
    }
    //cout << endl;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6800
H, W = list(map(int, input().split()))

import heapq

f = []
count = 0
for _ in range(H):
    line = list(input())
    f.append(line)
    count += sum([1 if x == '.' else 0 for x in line])

v = [[2501 for i in range(W)] for j in range(H)]
v[0][0] = 0

dx = [0, -1, 0, 1]
dy = [-1, 0, 1, 0]

heap = [(0,0,0)]
while len(heap) > 0:
    w, x, y = heapq.heappop(heap)
    for i in range(4):
        nx = x+dx[i]
        ny = y+dy[i]
        if (nx >= 0 and nx < W and ny >= 0 and ny < H):
            if nx == W-1 and ny == H-1:
                print(count - w -2)
                exit()
            elif f[ny][nx] == '#':
                pass
            else:
                if v[ny][nx] > w+1:
                    v[ny][nx] = w+1
                    heapq.heappush(heap, (w+1, nx, ny))

print(-1)

Measured memory_bytes: 3188
a,b = gets.chomp.split(' ').map(&:to_i)
origin_a = a
origin_b = b
result = 0
if a == b
    result = a
else
    while true do
        if a < b
            a += origin_a
        elsif b < a
            b += origin_b
        else
            result = a
            break
        end
    end
end
puts result

Measured memory_bytes: 1788
h,w=map(int,input().split())
c=[list(input()) for _ in range(h)]
ans=[[0]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if c[i][j]=='.':
            if c[i][:j].count('c')==0:
                ans[i][j]=-1
            else:
                for k in range(1,j+1):
                    if c[i][j-k]=='c':
                        ans[i][j]=k
                        break
for i in ans:
    print(*i)


Measured memory_bytes: 6476
#include    <bits/stdc++.h>
#include    <ext/pb_ds/assoc_container.hpp>
#include    <ext/pb_ds/trie_policy.hpp>
#include    <ext/rope>

#pragma     03
#pragma     GCC             optimize("Ofast")
#pragma     GCC             optimization("unroll-loops, no-stack-protector")
#pragma     GCC             target("sse,sse2,sse3,ssse3,sse4.1,sse4.2")

#define     ll              long long
#define     ld              long double
#define     fi              first
#define     se              second
#define     sz(x)           x.size()
#define     mp              make_pair
#define     pb              push_back
#define     eb              emplace_back
#define     all(x)          begin(x), end(x)
#define     rall(x)         rbegin(x), rend(x)
#define     rep(i, x, n)    for (ll i = x; i < n; i++)
#define     fastio()        ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)

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

mt19937     rng(chrono::steady_clock::now().time_since_epoch().count());

typedef     vector<int>     vi;
typedef     vector<vi>      vvi;
typedef     pair<int, int>  ii;
typedef     vector<ii>      vii;
typedef     vector<ll>      vl;
typedef     vector<vl>      vvl;
typedef     pair<ll, ll>    pll;
typedef     vector<pll>     vll;

inline void EXECUTE_TIME() {cout << endl << setprecision(10) << fixed << "CPU Time: " << clock() / double(CLOCKS_PER_SEC) << " sec(s)\n";}

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}
template <class T> inline T gcd(T a, T b) {if (b) return gcd(b, a % b); else return a;}
template <class T> inline T lcm(T a, T b) {return a / gcd(a,b) * b;}
template<typename T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;

signed main() {
//    freopen("bubbletea.inp", "r", stdin);
//    freopen("bubbletea.out", "w", stdout);
    fastio();

    int n; cin >> n;

    string s, t; cin >> s;
    t = s;

    sort(all(s));
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] != t[i]) ans++;
    }
    cout << ans / 2;

//    EXECUTE_TIME();
}


Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int c[105];
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>c[i];
    }
    int a[105];
    for(int i=0;i<105;i++)
    {
        a[i]=9;
    }
    for(int j=0;j<105;j++)
    for(int i=0;i<n;i++)
    {
        if(c[i]==j) a[j]=1;
    }
    int ans=0;
    for(int i=0;i<105;i++)
    {
        if(a[i]==1) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int const N = 41 * 41;

string s;

void ok(int a, int b){
	cout << a << " " << b << endl;
	exit(0);
}

int main(){
	cin >> s;
	int n = s.size();
	for(int i=1;i<n;++i){
		if(s[i] == s[i-1]){
			ok(i, i+1);
		}
		if(i > 2 && s[i] == s[i-2]){
			ok(i-1, i+1);
		}
	}
	ok(-1, -1);

	return 0;
}

Measured memory_bytes: 512
def resolve():
    S = input()
    l, r = 0, len(S) - 1
    ans = 0
    while l < r:
        # 次に進める
        if S[l] == S[r]:
            l += 1
            r -= 1
        # r位置にxを追加
        elif S[l] == "x":
            ans += 1
            l += 1
        # l位置にxを追加
        elif S[r] == "x":
            ans += 1
            r -= 1
        else:
            print(-1)
            return

    print(ans)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9200
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(L[K-1])

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

using namespace std;
using ll  = long long;
using ii  = pair < int , int >;
using i3  = pair < int , ii >;
using vi  = vector < int >;
using vii = vector < ii >;
using vi3 = vector < i3 >;

const int N = 3030;
const ll INF = 1e12;
const double eps = 1e-9 , PI = acos(-1);

int n , mid = 3000;
double p[N];
double mem[N][2*N];

double dp(int i , int cnt){
    if(i == n){
        return cnt > mid;
    }

    double &ret = mem[i][cnt];
    if(ret > -0.5)return ret;

    return ret = p[i]*dp(i+1 , cnt+1) + (1.0-p[i])*dp(i+1 , cnt-1);
}

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

    memset(mem , -1 , sizeof mem);
    printf("%.9f\n" , dp(0 , mid));
}

main(){
    int t = 1;
    //scanf("%d" , &t);

    while( t -- ){
            solve();
    }

    return 0;
}






Measured memory_bytes: 144000
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		Integer red[] = new Integer[A];
		Integer green[] = new Integer[B];
		Integer clear[] = new Integer[C];
		
		for(int i = 0; i < A; i++){
			red[i] = sc.nextInt();
		}
		for(int i = 0; i < B; i++){
			green[i] = sc.nextInt();
		}
		for(int i = 0; i < C; i++){
			clear[i] = sc.nextInt();
		}
		
		Arrays.sort(red, Collections.reverseOrder());
		Arrays.sort(green, Collections.reverseOrder());

		Integer apple[] = new Integer[X + Y + C];
		for(int i = 0; i < X; i++)apple[i] = red[i];
		for(int i = 0; i < Y; i++)apple[i + X] = green[i];
		for(int i = 0; i < C; i++)apple[i + X + Y] = clear[i];
		Arrays.sort(apple, Collections.reverseOrder());
		
		long sum = 0;
		for(int i = 0; i < X + Y; i++){
			sum += apple[i];
		}
		System.out.println(sum);
	}
}


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

typedef long long ll;
const ll mod = 1e9 + 7;
const int maxn = 2005;
int N , K , A[maxn];

ll qpow(ll a , int n){
  if(n <= 0)return 1ll;
  ll ret = qpow(a , n / 2);
  if(n % 2)
    return (ret * ret % mod) * a % mod;
  return ret * ret % mod;
}

int main(){
  cin >> N >> K;
  for(int i = 1; i <= N; ++i)cin >> A[i];
  ll ret = 0;
  ll cnt = 0;
  for(int i = 1; i <= N; ++i){
    for(int j = i + 1; j <= N; ++j){
      if(A[i] > A[j]){
        ++cnt; //count # inversion in A
      }
    }
  }
  ret = cnt * K % mod;
  ll larger = 0;
  for(int i = 1; i <= N; ++i){
    for(int j = 1; j <= N; ++j){
      if(A[i] > A[j]){
        ++larger;
      }
    }
  }
  ll c = ((ll)K * (K - 1) % mod) * qpow(2ll , mod - 2) % mod;
  ret = (ret + larger * c % mod) % mod;
  cout << (ret + mod) % mod << endl;
  return 0;
}


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


int main(){
  int n=0,i=0,l=0,r=0,d=0,j=0,b=0,m=0;
  char s[7][7];
  
  scanf("%d %d %d",&l,&r,&d);

  for(i=l;i<=r;i++){
    if(i%d==0)
      n++;
  }

  printf("%d\n",n);
  
  return 0;
}


Measured memory_bytes: 1732
# 
import sys

from sys import stdin
input = lambda: stdin.readline().rstrip()

N = int(input())

l = [0] * N
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            v = x**2+y**2+z**2+x*y+y*z+z*x
            if v <= N:
                l[v-1] = l[v-1] + 1

for i in l:
    print(i)

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int c[3][3];
    rep(i, 0, 3) rep(j, 0, 3) cin >> c[i][j];
    rep(b0, 0, c[0][0] + 1) {
        int a0 = c[0][0] - b0;
        int a1 = c[1][0] - b0;
        int a2 = c[2][0] - b0;
        int b1 = c[0][1] - a0;
        int b2 = c[0][2] - a0;
        if (a1 + b1 == c[1][1] && a1 + b2 == c[1][2] && a2 + b1 == c[2][1] && a2 + b2 == c[2][2]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

ll sum(ll l, ll r) {
    return (l+r)*(r-l+1)/2;
}

int main() {

    long long mod = 1000000007;

    long long n, k; cin >> n >> k;

    long long ans;

    for (long long i=k; i<=n+1; i++){
        ll l = sum(0,i-1), r = sum(n-i+1,n);
        ans += r-l+1;
    }
    

    cout << ans%mod << "\n";

    return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>


int main(void)
{
	int W,H, x, y, r, c_x, c_y;
	
	scanf("%d %d %d %d %d", &W, & H, &x, &y, &r);
	
	c_x = x + r;
	c_y = y + r;
	
	if(c_x > W || c_y > H || (x - r) < 0 || (y - r) < 0){
		printf("No\n");
	} else {
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 1816