akhauriyash/Code-Regression huggingface dataset:
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    P = [int(x) for x in input().split()]


    ans = 1
    mi = P[0]
    for i in range(1, N):
        if mi >= P[i]:
            ans += 1
        mi = min(mi, P[i])


    print(ans)



    
    

if __name__ == '__main__':
    main()



Measured memory_bytes: 25748
ans = -101

N = int(input())
N_list = []
for _ in range(N):
    N_list.append(input())

M = int(input())
M_list = []
for _ in range(M):
    M_list.append(input())

MN_list = N_list[:]
MN_list.extend(M_list)
MN_list = set(MN_list)

for word in MN_list:
    word_point = 0
    for item in N_list:
        if word == item:
            word_point += 1
    for item in M_list:
        if word == item:
            word_point -= 1
    ans = max(ans, word_point)

if ans < 0:
    print(0)
else:
    print(ans)


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
#define fors(i,a,b) for(int i=(a);i<=(b);++i)
int main(){
    ios::sync_with_stdio(0);
    register int a,wh[9],b,e;
    cin>>a>>b>>e;
    fors(c,-100,200){
        wh[1]=a+b+c;
        if(wh[1]<a+e) continue;
        fors(i,-100,200){
            wh[7]=a+e+i;
            if(wh[7]!=wh[1]) continue;
            fors(f,-100,200)
            {
                wh[6]=c+f+i;
                if(wh[6]!=wh[7]) continue;
                fors(d,-100,200){
                    wh[2]=d+e+f;
                    if(wh[2]!=wh[6]) continue;
                    fors(g,-100,200)
                    {
                        wh[4]=g+d+a;
                        wh[8]=c+e+g;
                        if((wh[8]!=wh[4])) continue;
                        fors(h,-100,200){
                            wh[3]=g+h+i;
                            wh[5]=b+e+h;
                            if((wh[3]!=wh[5]) || (wh[3]!=wh[4]) || (wh[3]!=wh[8])) continue;
                                cout<<a<<" "<<b<<" "<<c<<endl;
                                cout<<d<<" "<<e<<" "<<f<<endl;
                                cout<<g<<" "<<h<<" "<<i<<endl;
                                return 0;
                        }
                    }       
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
N,W = map(int,input().split())
w = []
v = []
for i in range(N):
    x,y = map(int,input().split())
    w.append(x)
    v.append(y)

dp = [[0]*(W+1) for j in range(N+1)]

for i in range(N):# 2 1 0
    for j in range(W+1):# 0 1 2 3 4 5 6 7 8
        """
        for k in dp:
            print(k)
        print(i,j)
        print("-------------------")
        """
        if j < w[i]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i])
"""
for k in dp:
    print(k)
print("-------------------")
"""
print(dp[N][W])

Measured memory_bytes: 120172
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  vector<int> V(N);
  for (int i=0;i<N;i++){
    cin >> V[i];
  }
  vector<int> l(N+1),r(N+1);
  l[0]=0;
  r[0]=0;
  for (int i=1;i<N+1;i++){
    l[i]=l[i-1]+V[i-1];
    r[i]=r[i-1]+V[N-i];
  }
  int ans=0;
  for (int i=0;i<=min(K,N);i++){
    for (int j=0;j<=min(K-i,N-i);j++){
      int sum=l[i]+r[j];
      priority_queue<int,vector<int>,greater<int>> pq;
      for (int k=0;k<i;k++){
        pq.push(V[k]);
      }
      for (int k=0;k<j;k++){
        pq.push(V[N-1-k]);
      }
      for (int k=0;k<K-i-j;k++){
        if (!pq.empty()){
          if (pq.top()<0){
            sum-=pq.top();
            pq.pop();
          }
          else {
            break;
          }
        }
        else {
          break;
        }
      }
      ans=max(ans,sum);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    static FastScanner sc = new FastScanner();
    public static void main(String[] args) {
        int n=sc.nextInt();
        char a[]=sc.next().toCharArray();
        ArrayList<Integer> ws= new ArrayList<>(),
                rs= new ArrayList<>();
        for (int i=0;i<n;i++){
            if (a[i]=='W')
                ws.add(i);
            else
                rs.add(i);
        }
        int wind=0,rInd=rs.size()-1;
        int count=0;
        while (wind<ws.size()&&rInd>=0&&ws.get(wind)<rs.get(rInd)){
            count++;
            rInd--;
            wind++;
        }
        System.out.println(count);




    }

        static void sortint(int[] a) {
        ArrayList<Integer> l=new ArrayList<>();
        for (int i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }
    static void sort(long[] a) {
        ArrayList<Integer> l = new ArrayList<>();
        for (long i : a) l.add((int) i);
        Collections.sort(l);
        for (int i = 0; i < a.length; i++) a[i] = l.get(i);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

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

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

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

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





Measured memory_bytes: 43072
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  ll D, T, S;
  cin >> D >> T >> S;
  if(D <= T * S) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n)-1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a)-1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using Vec = vector<T>;
template<class T> using VVec = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i-1)*10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}

struct IoSetup {
	IoSetup() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} iosetup;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//


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

	ll ans = 0;
	ans += X / 500 * 1000;
	X -= X / 500 * 500;
	ans += X / 5 * 5;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n, x, t;
    cin >> n >> x >> t;
    if(n%x==0) cout << n/x * t << endl;
    else cout << (n/x+1) * t << endl;
}

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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

int main() {
	int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
	int dist1=x2-x1, dist2=y2-y1;

	cout << x2-dist2 << " "
	     << y2+dist1 << " "
		 << x1-dist2 << " "
		 << y1+dist1 << endl;
}

Measured memory_bytes: 256
from collections import deque
H,W,K = map(int,input().split())
x1,y1,x2,y2 = map(int,input().split())

maze = []
maze.append(["@"]*(W+2))
for _ in range(H):
  row = list(input())
  maze.append(["@"]+row+["@"])
maze.append(["@"]*(W+2))

q = deque([(x1,y1)])
depth = 0
while q:
  for i,j in q:
    maze[i][j] = "@"

  new_q = set()
  l = len(q)
  for _ in range(l):
    x,y = q.pop()
    if (x,y) == (x2,y2):
      print(depth)
      exit()

    # Up
    for i in range(1, K+1):
      if maze[x-i][y] == "@": break
      new_q.add((x-i, y))

    # Down
    for i in range(1, K+1):
      if maze[x+i][y] == "@": break
      new_q.add((x+i, y))

    # Left
    for i in range(1, K+1):
      if maze[x][y-i] == "@": break
      new_q.add((x, y-i))

    # Right
    for i in range(1, K+1):
      if maze[x][y+i] == "@": break
      new_q.add((x, y+i))

  q = deque(list(new_q))
  depth += 1

print(-1)

Measured memory_bytes: 157928
#include<bits/stdc++.h>
using namespace std;
const int N = 200005;
vector<int> a[N];
int n, q;
long long ans[N];
void dfs(int v, int p){
	for(auto to: a[v]){
		if(to == p){
			continue;
		}
		ans[to] += ans[v];
		dfs(to, v);
	}
}
int32_t main(){
	cin>>n>>q;
	for(int i = 1; i < n; i++){
		int u, v; cin>>u>>v;
		a[v].push_back(u);
		a[u].push_back(v);
	}
	while(q--){
		int v, x; cin>>v>>x;
		ans[v] += x;
	}
	dfs(1, 1);
	for(int i = 1; i <= n; i++){
		cout<<ans[i]<<" ";
	}
}


Measured memory_bytes: 24320
#include <stdio.h>
#include <math.h>

int main()
{
  int a;
  int b;
  char merge[10] = { 0 };
  int question;
  int seq;

  scanf("%d %d", &a, &b);
  snprintf(merge, 10, "%d%d", a, b);

  question = atoi(merge);

  seq = floor(sqrt(question));
  if ((seq * seq) == question) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

lint gcd(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

lint lcm(lint a, lint b) {
	//aとbの最小公倍数を返す
	return a / gcd(a, b) * b;
}

lint sgm(lint n) {
	//0からの総和を返す
	return n * (n + 1) / 2;
}

lint fact(lint n) {
	//n!を返す
	if (n == 0) return 1;
	else return n * fact(n - 1);
}

lint power(lint x, lint n, lint m) {
	//(x^n)%mを返す
	lint res = 1;
	x %= m;
	while (n > 0) {
		if (n % 2 == 1) {
			res = res * x % m;
		}
		x = x * x % m;
		n /= 2;
	}
	return res;
}

/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	lint A, B, K;
	cin >> A >> B >> K;
	rep(i, K) {
		if (i % 2 == 0) {
			if (A % 2 != 0) {
				A--;
			}
			A -= (A / 2);
			B += A;
		}
		else if (i % 2 != 0) {
			if (B % 2 != 0) {
				B--;
			}
			B -= (B / 2);
			A += B;
		}
		//cout << A << ' ' << B << endl;
	}
	cout << A << ' ' << B << endl;
}


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

using namespace std;

int main(void){
    string s;
    cin >> s;
    int len = (int)s.size();

    if(s[0] == 'A'){
        s[0] = 'a';
        int a;
        for(a = 2; a < len - 1; a++){
            if(s[a] == 'C'){
                s[a] = 'c';
                break;
            }
        }
        if(a == len - 1){
            cout << "WA";
        }else{
            string ss = s;
            for(int b = 0; b < len; b++) ss[b] = tolower(ss[b]);
            if(ss != s)cout << "WA";
            else cout << "AC";
        }
    }else cout << "WA";

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
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())
#1回１回UnionFind繋ぎ直す
N, M = map(int, input().split())
ab = []
for i in range(M):
    ab.append(list(map(int,input().split())))

out=0
for k in range(M):
    Network = UnionFind(N)
    for i in range(M):
        if i!=k:
            a,b = ab[i][0], ab[i][1]
            Network.union(a-1,b-1)
    if Network.group_count() != 1:
        out+=1

print(out)


Measured memory_bytes: 68444
Option Strict On

Module Module1
    Const n As Int32 = 3
    Dim i As Int32
    Dim c(n - 1), ans As String

    Sub Main()
        For i = 0 To n - 1
            c(i) = Console.ReadLine()
        Next

        For i = 0 To n - 1
            ans &= c(i)(i)
        Next

        Console.WriteLine(ans)
    End Sub

End Module

Measured memory_bytes: 11092
#include <stdio.h>
int main(void){
	int fre,mic,dis,i;
	scanf("%d%d%d",&fre,&mic,&dis);
	int a[fre+1],b[mic+1],x[dis+1],y[dis+1],c[dis+1],coupon[dis+1],couponed=200000,normal,amin=200000,bmin=200000;
	for(i=0;i<fre;i++){
		scanf("%d",&a[i]);
		amin=((a[i]<amin)?a[i]:amin);
	}
	for(i=0;i<mic;i++){
		scanf("%d",&b[i]);
		bmin=((b[i]<bmin)?b[i]:bmin);
	}
	normal=amin+bmin;
	for(i=0;i<dis;i++){
		scanf("%d%d%d",&x[i],&y[i],&c[i]);
		coupon[i]=(a[x[i]-1]+b[y[i]-1]-c[i]);
		couponed=((coupon[i]<couponed)?coupon[i]:couponed);
	}
	printf("%d",(normal<couponed)?normal:couponed);
	return 0;
}

Measured memory_bytes: 2560
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    n, y = (int(i) for i in sys.stdin.readline().split())
    y //= 1000
    if y > 10 * n or y < n: print('-1 -1 -1'); exit()

    for i in range(n+1):
        for j in range(n+1-i):
            k = n - i - j
            t = 10 * i + 5 * j + k
            if t == y: 
                print(i, j, k)
                exit()
    print(-1, -1, -1)


if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  char C;
  cin >> C;
  char ans = C + 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    int n; cin >> n;
    map<ll, int, greater<ll>> mp;
    rep(i, n){
        ll a; cin >> a;
        mp[a]++;
    }

    ll a = 0, b = 0;
    auto begin = mp.begin(), end = mp.end();
    for (auto iter = begin; iter != end; iter++) {
        ll key = iter->first; int val = iter->second;
        if(val >= 2){
            if(a==0) a = key;
            else if(b==0) b = key;
            val -= 2;
        }
        if(val >= 2){
            if(b==0) b = key;
        }
    }
    cout << a * b << ln;
}

Measured memory_bytes: 6528
N,K = (int(i) for i in input().split())  
h = [int(input()) for i in range(N)]
 
h.sort()
 
ans=[]
 
for i in range(N):
	if i+K==N+1:
		break
	else:
		ans.append(h[i+K-1] - h[i])
print(min(ans))

Measured memory_bytes: 11244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const float pi = 3.1415926535;
unsigned GetDigit(unsigned num){
    return to_string(num).length();
}

int main() {
  int n,k,r,s,p;
  string t;
  
  cin >> n >> k >> r >> s >> p >> t;
  vector<int>ans(n);
  for (int i = 0; i < n; i++) {
    if (t.at(i) == 's') ans.at(i) = r;
    else if (t.at(i) == 'p') ans.at(i) = s;
    else ans.at(i) = p;
  }

  for (int i = k; i < n; i++) {
    if (t.at(i-k) == t.at(i)) {
      ans.at(i) = 0;
      t.at(i) = 'a';
    }
  }
  int kotae = 0;
  for (int i = 0; i < n; i++) {
    kotae += ans.at(i);
  }
  cout << kotae << endl;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF (ll)(1e17+5)
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
       ll a,b,c;
       cin>>a>>b>>c;
       cout<<c<<" "<<a<<" "<<b<<"\n";
   }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n, k;
    cin >> n >> k;
    set<int> treat;
    for (int i = 0; i < k; i++){
        int d;
        cin >> d;
        vector<int> a(d);
        for (int j = 0; j < d; j++){
            cin >> a.at(j);
            treat.insert(a.at(j));
        }
    }
    
    cout << n - treat.size()  << endl;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int result[100][100];
int win[100];
int sum[100];
int ans=0;
int n;
void dfs(int);
void comb(int w,int s,int d,int num,int bbit,int wnum,int lnum){
  if(num==n-s-1){
    int cnt=0;
    vector<pair<int,int> >po;
    for(int i=d+1;i<n;i++){
      if(result[d][i]==0){
	if(bbit&(1<<cnt)){
	  result[d][i]=1;
	  result[i][d]=2;
	  sum[i]++;
	  win[d]++;
	  po.pb(mp(i,0));
	}else{
	  result[d][i]=2;
	  result[i][d]=1;
	  sum[i]++;
	  win[i]++;
	  po.pb(mp(i,1));
	}
	cnt++;
      }
    }
    dfs(d+1);
    for(int i=0;i<po.size();i++){
      if(po[i].S){
	win[po[i].F]--;
      }else
	win[d]--;
      sum[po[i].F]--;
      result[d][po[i].F]=0;
      result[po[i].F][d]=0;
    }
    return;
  }
  if(wnum+w<(n-1)/2)
    comb(w,s,d,num+1,bbit+(1<<num),wnum+1,lnum);
  if(lnum+(s-w)<(n-1)/2)
    comb(w,s,d,num+1,bbit,wnum,lnum+1);
}
void dfs(int depth){
  if(depth==n-1){
    for(int i=0;i<n;i++){
      if(win[i]!=n/2)return;
    }
    ans++;
    return;
  }
  comb(win[depth],sum[depth],depth,0,0,0,0);
}
int main(){
  while(cin>>n,n){
    ans=0;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++)
	result[i][j]=0;
      win[i]=0;
      sum[i]=0;
    }
    int m;cin>>m;
    for(int i=0;i<m;i++){
      int x,y;cin>>x>>y;
      result[--x][--y]=1;
      result[y][x]=2;
      win[x]++;
      sum[x]++;
      sum[y]++;
    }
    dfs(0);
    cout<<ans<<endl;
  }
  return 0;
}



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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

struct UnionFind {
  vector<ll> p;
  vector<ll> rank;

  UnionFind(ll n) {
    p.resize(n);
    rank.resize(n, 0);
    for (long long i = 0; i < n; i++) {
      p.at(i) = i;
    }
  }

  ll root(ll x) {
    if (p.at(x) == x) {
      return p.at(x);
    }
    return p.at(x) = root(p.at(x));
  }

  void unite(ll x, ll y) {
    x = root(x);
    y = root(y);
    if (x == y) return;

    if (rank.at(x) > rank.at(y)) {
      swap(x, y);
    }
    if (rank.at(x) == rank.at(y)) {
      rank.at(y)++;
    }
    p.at(x) = p.at(y);
    return;
  }

  bool same(ll x, ll y) { return root(x) == root(y); }
};

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

  UnionFind uf(n);

  for (long long i = 0; i < m; i++) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    uf.unite(a, b);
  }

  vector<ll> r(n, 0);
  for (long long i = 0; i < n; i++) {
    r.at(uf.root(i))++;
  }
  sort(r.begin(), r.end());
  reverse(r.begin(), r.end());
  cout << r.front() << endl;
}


Measured memory_bytes: 7960
#include <stdio.h>
#include <string.h>

int main(){
  char s[4]={0};
  scanf("%s", s);
  
  if	 ( strcmp(s, "ooo")==0 ){ printf("1000"); }
  else if( strcmp(s, "xoo")==0 || strcmp(s, "oxo")==0 || strcmp(s, "oox")==0 ){ printf("900"); }
  else if( strcmp(s, "xxo")==0 || strcmp(s, "oxx")==0 || strcmp(s, "xox")==0 ){ printf("800"); }
  else if( strcmp(s, "xxx")==0 ){ printf("700"); }
 
  return 0;
}

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

using ll = long long;
#define int long long

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a) rreps(i, a, 0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(15)
#define YES(f) cout << ((f) ? YES_STR : NO_STR) << endl;

using namespace std;

int solve(int m) {
	int mi, ma; cin >> mi >> ma;
	vector<int> p(m);
	rep(i, m) cin >> p[i];
	int g = 1;
	int res = -1;
	reps(n, mi, ma+1) {
		if (g <= p[n-1] - p[n]) {
			g = p[n-1] - p[n];
			res = n;
		}
	}
	return res;
}

signed main() {
	int m;
	while (cin >> m, m) cout << solve(m) << endl;
}




Measured memory_bytes: 3084
#https://atcoder.jp/contests/dp/submissions/10194253
import numpy as np
n, w = map(int, input().split())
dp = np.zeros(w+1)
for i in range(n):
    w, v = map(int, input().split())
    dp[w:] = np.maximum(dp[:-w]+v, dp[w:])
print(int(dp[-1]))

Measured memory_bytes: 15460
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long int LL;
typedef pair<LL,LL> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
vector<P> v1,v2;

LL check(LL a,LL b,int cnt){
	int i,j;
	LL c,d;
	if(cnt<v1.size()){
		c=1;
		for(i=0;i<v1[cnt].second;i++){
			c*=v1[cnt].first;
		}
		return min(check(a*c,b,cnt+1),check(a,b*c,cnt+1));
	}
	P pa=crt(vector<LL>({0,b-1}),vector<LL>({a,b}));
	if(pa.second==0)return 1LL<<60;
	if(pa.first==0)return pa.second;
	return pa.first;
}

int main(){
	LL n,m;
	int i,j,k;
	LL a,b,c;
	cin>>n;
	n*=2;
	for(i=2;i<4e7;i++){
		if(n==1)break;
		j=0;
		while(n%i==0){
			n/=i,j++;
		}
		if(j)v1.push_back(make_pair(i,j));
	}
	if(n!=1)v1.push_back(make_pair(n,1));
	cout<<check(1,1,0)<<endl;
}

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

int main(){
	int n; cin >> n;
	int F[50];
	F[0] = F[1] = 1;
	for (int i=2; i<=n; i++){
		F[i] = F[i-1] + F[i-2];
	}

	cout << F[n] << endl;

	return 0;
}

Measured memory_bytes: 1160
K,N = map(int, input().split())
A_list = [int(e) for e in input().split()]

#間が一番大きいところを避けたい
between_house = list()
between_house = [A_list[i+1]-A_list[i] for i in range(N-1)]
between_house.append((K - A_list[-1])+A_list[0])

print(K-max(between_house))

Measured memory_bytes: 24908
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
int w[50000];
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\Users\Joeon\Desktop\IN.txt", "r", stdin);
//		freopen("C:\Users\Joeon\Desktop\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k, cnt = 0;
	cin>>n>>k;
	while(k--)
	{
		int p = next<int>();
		while(p--) w[next<int>()] = 1;
	}
	R(w, 100);
	hrp(i, 1, n) if (!w[i]) cnt++;
	cout<<cnt<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}

Measured memory_bytes: 3640
main :: IO()
main = do
    str <- getLine
    putStrLn $ getsolve (isMonth (take 2 str)) (isMonth (drop 2 str))

getsolve :: Bool -> Bool -> String
getsolve True True 	= "AMBIGUOUS"
getsolve True False	= "MMYY"
getsolve False True	= "YYMM"
getsolve False False= "NA"

isMonth :: String -> Bool
isMonth str
    | str == "01"		= True
    | str == "02"		= True
    | str == "03"		= True
    | str == "04"		= True
    | str == "05"		= True
    | str == "06"		= True
    | str == "07"		= True
    | str == "08"		= True
    | str == "09"		= True
    | str == "10"		= True
    | str == "11"		= True
    | str == "12"		= True
    | otherwise			= False

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

int main(){
    int64_t a,b,k;
    cin >> a >> b >> k;
    if(a >= k) a -= k;
    else if(a < k){
        int64_t s = k - a;
      	a = 0;
        if(b >= s) b -= s;
        else if(b < s)b = 0;
    }
    cout << a  << " " << b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define forin(x,y) for(ll i=x;i<y;i++)
#define vii vector<ll>
#define pii  pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e17
#define M (ll)(1e9+7)
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll n;
struct MAT
{
    vector<vii> a;
    MAT()
    {
        a.resize(n,vii(n,0));
    }
    MAT operator * (const MAT & b)  const
    {
        MAT ans = MAT();
        for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<n;j++)
            {
                for(ll k=0;k<n;k++)
                {
                   ans.a[i][j] += ((this->a[i][k])%M)*((b.a[k][j])%M);
                   ans.a[i][j] %=M;
                }
            }
        }
        return ans;
    }
};

MAT power(MAT a,ll k)
{
    if(k==2)    return a*a;
    if(k==1)    return a;
    MAT B = power(a,k/2);
    if(k%2 == 0)
    {
        return B*B;
    }
    else
    {
        return B*B*a;
    }
    

}

int main()
{
    ios::sync_with_stdio(false);    cin.tie(0);     cout.tie(0);
    ll k,temp=0;    cin>>n>>k;
    MAT data = MAT();
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<n;j++)
        {
            cin>>data.a[i][j];
        }
    }
    MAT b = power(data,k);
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<n;j++)
        {
            ans += (b.a[i][j])%M;
            ans %= M;
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 1664
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b,n=0,h,w,j,i,c=0;
    char x[100],y[100];
    scanf("%s%s",x,y);
    y[strlen(x)]='\0';
    if(strcmp(x,y)==0){printf("Yes\n");}
    else{printf("No\n");}



    return 0;
}


Measured memory_bytes: 1608
#include <stdio.h>
int main(void){
	int a,b,c,i,tmp,cnt;
	char str[100];

	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		sscanf(str,"%d %d %d",&a,&b,&c);
		tmp=a+b; cnt=0;
		for(i=1;i<11;i++){
			if(i==a || i==b || i==c)
				continue;
			if(i+tmp<=20)
				cnt++;
		}
		printf(cnt>3 ? "YES\n" : "NO\n");
	}
	return 0;
}

Measured memory_bytes: 588
import sys
from collections import defaultdict

def load(vtype=int):
    return vtype(input().strip())

def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]

def exit():
    import sys
    sys.exit(0)

def kumiawase(li, used):
    if len(li) == len(used):
        return [[]]
    k = []
    for i in range(0, len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = kumiawase(li, used)
        for sub in sub_list:
            sub.append(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
        
n = load()
p = "".join(load_list(vtype=str))
q = "".join(load_list(vtype=str))

ks = kumiawase([i for i in range(n, 0, -1)], set())
ks = sorted(["".join([str(e) for e in k]) for k in ks])

a = ks.index(p) + 1
b = ks.index(q) + 1
print(abs(a-b))



Measured memory_bytes: 13028
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100005

int main()
{
	
	io
	
	ll a,b,n;
	cin>>a>>b>>n;
	ll zz=min(50000000LL,n);
	ll res=0;
	rep(i,0,zz+1)
	{
		ll v1=i*a;
		ll res1=(v1/b);
		ll res2=(i/b);
		res1=(res1-res2*a);
		res=max(res,res1);
	}
	ll z1=max(1LL,n-50000000);
	rep(i,z1,n+1)
	{
		ll v1=i*a;
		ll res1=(v1/b);
		ll res2=(i/b);
		res1=(res1-res2*a);
		res=max(res,res1);
	}	
	if(b-1<=n)
	{
		ll v1=(b-1)*a;
	ll res1=(v1/b);
	ll res2=((b-1)/b);
	res1=(res1-res2*a);
	res=max(res,res1);	
}
	cout<<res;

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const long long INF=INT_MAX/4;
const long long MOD=1'000'000'007;
const double EPS=1e-14;
const bool DEBUG=true;

const string YES = "YES";
const string NO = "NO";
const string Yes = "Yes";
const string No = "No";

template<class T>
void debug(T head){
    if(DEBUG){
        cout<<head<<endl;
    }
}

template <class Head, class... Body>
void debug(Head head, Body... body){
    if(DEBUG){
        cout<<head<<" ";
        debug(body...);
    }
}

/////


void answer(){
    int a;
    cin>>a;
    if(a==0){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }

    return;
}

/////

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.precision(16);

    answer();

    return 0;
}


Measured memory_bytes: 3616
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int n, a[105], ans;
void Init() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) 
		scanf("%d", &a[i]);
}

void solve() {
	ans = 0;
	for(int i = 1; i < n; i++) {
		if(a[i] == a[i - 1]) {
			a[i] = -1;
			ans++;
		}
	}
	printf("%d\n", ans);
}

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

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

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int T = sc.nextInt();
    int minCost = 0;

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

      int c1 = sc.nextInt();
      int t1 = sc.nextInt();

      if (t1 <= T) {
        if (minCost == 0 || c1 < minCost) {
          minCost = c1;
        }
      }
    }
    
    System.out.println(minCost == 0 ? "TLE" : minCost);
  }
}

Measured memory_bytes: 23508
#include<stdio.h>
int main()
{
	int s=0;
	char n;
	n=getchar(); 
	while(n!='\n')
	{
		s+=n-48;
		n=getchar(); 
	}
	if(s%9==0)
	printf("Yes");
	else
	printf("No");
}


Measured memory_bytes: 1592
#include<bits/stdc++.h>
#define maxn 100050
#define LL long long
#define mm(a,b) memset(a,b,sizeof(a))
using namespace std;
int a[maxn];
int main(){
//	freopen("input.txt","r",stdin);
	int n; scanf("%d",&n);
	mm(a,0);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n,greater<int>());
	LL ans=1;
	int num=1;
	int flag=0;
	n++,a[n]=a[n-1]-1;
	for(int i=1;i<n;i++){
		if(a[i]==a[i+1]) num++;
		else{
			if(num>=4){
				if(ans==1) ans=(LL)a[i]*a[i];
				else ans=max(ans*a[i],(LL)a[i]*a[i]);
				break;
			}
			else if(num>=2){
				ans*=(LL)a[i];
				flag++;
			}
			num=1;
		}
		if(flag==2) break;
	}
	if(ans==1) ans=0;
	cout<<ans<<endl;
	return 0;
}

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

const int maxn=510;

int n;
int a[maxn],b[maxn];
int ans;
int k,sum;

bool pd(int x){
	for(register int i=1;i<=n;i++)
		b[i]=a[i]%x;
	sort(b+1,b+n+1);
	int l=1,r=n,sum=0;
	while(l<r){
		int mi=min(b[l],x-b[r]);
		sum+=mi;
		if(sum>k)
			return 0;
		b[l]-=mi;
		b[r]+=mi;
		b[r]%=x;
		if(!b[l])
			l++;
		if(!b[r])
			r--;
	}
	if(l==r && b[l])
		return 0;
	else
		return 1;
}
int main(){
	scanf("%d%d",&n,&k);
	for(register int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	for(register int i=1;i*i<=sum;i++){
		if(sum%i)
			continue;
		if(pd(sum/i))
			ans=max(ans,sum/i);
		if(pd(i))
			ans=max(ans,i);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
def solve(l):
    n = 0
    while 2**n <= l:
        n += 1
    E = []
    for i in range(n-1, -1, -1):
        x = 2**i
        if i != n-1:
            E.append((i, i+1, 0))
            E.append((i, i+1, x))
        if l - x >= 2**(n-1):
            E.append((i, n-1, l-x))
            l -= x
    print(n, len(E))
    for u, v, x in E:
        print(u+1, v+1, x)

l = int(input())
solve(l)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
signed main(){
  ll n,cun=0;
  cin>>n;
  for(ll i=1;i<=n;i++){
	if( (i%5) != 0 && (i%3) != 0){
	cun+=i;
    }
  }
  cout<<cun<<"\n";
}


Measured memory_bytes: 3608
import fractions
n = int(input())
a = [0] + list(map(int, input().split())) + [0]

# 前処理。left, rightでそれぞれ累積gcdを作っておく
left = [0] * (n + 2)
right = [0] * (n + 2)

for i in range(n):
    left[i] = fractions.gcd(left[i - 1], a[i])

for i in range(n, 0, -1):
    right[i] = fractions.gcd(right[i + 1], a[i])

for i in range(1, n):
    right[-i - 1] = fractions.gcd(right[-i], a[-i - 1])

ans = 1
for i in range(1, n + 1):
    ans = max(ans, fractions.gcd(left[i - 1], right[i + 1]))
print(ans)

Measured memory_bytes: 16572
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<set>
#include<algorithm>
using namespace std;
int a[202020],t[202020];
bool cmp(const int &x,const int &y)
{
	return a[x]<a[y];
}
set <int> s;
int main()
{
	int n,la,ne;
	long long ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		t[i]=i;
	}
	s.clear();
	s.insert(0);
	s.insert(n+1);
	sort(t+1,t+1+n,cmp);
	for(int i=1;i<=n;i++)
	{
		la=*(--s.lower_bound(t[i]));
		ne=*s.upper_bound(t[i]);
		ans+=(long long)a[t[i]]*(t[i]-la)*(ne-t[i]);
		s.insert(t[i]);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 11136
#include<stdio.h>
int main(){
	int x,y,z;
	scanf("%d %d %d\n",&x,&y,&z);
	if(x<=y&&y<=z) printf("%d %d %d\n",x,y,z);
	else if(y<=x&&x<=z) printf("%d %d %d\n",y,x,z);
	else if(z<=y&&y<=x) printf("%d %d %d\n",z,y,x);
	else if(z<=x&&x<=y) printf("%d %d %d\n",z,x,y);
	else if(x<=z&&z<=y) printf("%d %d %d\n",x,z,y);
	else  printf("%d %d %d\n",y,z,x);
	
	return 0;
}

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

#define MOD 1000000007
using namespace std ;

int n ;

const int MAXN = 100010 ;

int x[MAXN] ; 

int v[MAXN << 1] ; 

int main() {
#ifdef YJQ_LOCAL
		freopen(".in", "r", stdin) ;
#endif
		scanf("%d", &n) ; 
		for (int i = 1; i <= n; i ++) {
				scanf("%d", &x[i]) ; 
				if (x[i] <= 2 * n) v[x[i]] ++ ; 
		}
		for (int i = 1; i <= 2 * n + 2; i ++) v[i] += v[i - 1] ; 
		int now = 0 , ans = 1;  
		for (int i = 1; i <= n; i ++) {
				while (now <= 2 * n && v[now] - (i - 1) <= (now / 2)) now += 2 ; 
			    if (v[now] - (i - 1) > (now / 2)) {
						int cnt = v[now] ; 
						ans = 1LL * ans * (cnt - (i - 1)) % MOD ; 
				}	
				else ans = 1LL * ans * (n - (i - 1)) % MOD ; 
		}
		printf("%d\n", ans) ; 
}




Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

int A[510], S[1510] = { 0 };
vector<int> X;
vector<int> R[1510];
int main()
{
	int N;
	ll K;
	cin >> N >> K;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	for (int i = 1; i * i <= sum; i++) {
		if (sum % i == 0) {
			X.push_back(i);
			if (i * i != sum) {
				X.push_back(sum / i);
			}
		}
	}
	sort(X.begin(), X.end());
	for (int i = 0; i < X.size(); i++) {
		for (int j = 0; j < N; j++) {
			R[i].push_back(A[j] % X[i]);
			S[i] += A[j] % X[i];
		}
	}
	for (int i = 0; i < X.size(); i++) {
		sort(R[i].begin(), R[i].end(),greater<int>());
	}
	int ans = 1, m = 0;
	for (int i = 0; i < X.size(); i++) {
		m = 0;
		for (int j = 0; j < R[i].size(); j++) {
			S[i] -= R[i][j];
			m += (X[i] - R[i][j]);
			if (S[i] == m) {
				if (S[i] <= K) {
					ans = X[i];
					break;
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2688
from heapq import heapify,heappush,heappop
N = int(input())
A = list(map(int,input().split()))

Q = []
R = []
sumQ = [0 for _ in range(N+1)]
sumR = [0 for _ in range(N+1)]
for i in range(N):
  heappush(Q, A[i])
  heappush(R, -A[3*N-1-i])

#sQ = sum(Q)
#sR = sum(R)
sumQ[0] = sum(Q)
sumR[N] = sum(R)

for i in range(N):
  heappush(Q, A[N+i])
  B = heappop(Q)
  #sQ += A[N+i] - B
  sumQ[i+1] = sumQ[i] + A[N+i] - B
  
  heappush(R, -A[2*N-1-i])
  B = heappop(R)
  #sR += -A[2*N-i] - B
  sumR[N-i-1] = sumR[N-i] -A[2*N-1-i] - B
  
  

ans = sumQ[0] + sumR[0]
#print(sumQ,sumR)
for i in range(1, N+1):
  ans = max(ans, sumQ[i] + sumR[i])
  
print(ans)

Measured memory_bytes: 126908
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn paritition(array: &mut Vec<u32>, p: usize, r: usize) -> usize {
    let x = array[r];
    let mut i: i32 = (p as i32) - 1;

    for j in p..r {
        if array[j] <= x {
            i += 1;
            array.swap(i as usize, j);
        }
    }
    array.swap((i + 1) as usize, r);

    (i + 1) as usize
}

fn main() {
    let n: usize = read();

    let mut array: Vec<u32> = (0..n).map(|_| read::<u32>()).collect();

    let p = paritition(&mut array, 0, n - 1);

    for i in 0..n {
        if i == 0 {
            print!("");
        }
        if i == p {
            print!("[");
        }
        print!("{}", array[i]);
        if i == p {
            print!("]");
        }
        if i != n - 1 {
            print!(" ");
        }
    }
    println!("");
}



Measured memory_bytes: 5048
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <numeric>
#include <iostream>

using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)	   for(int i = 0; i < (n); ++i)
#define all(c)		   begin(c), end(c)
#define rall(c)		   rbegin(c), rend(c)
#define SZ(a)		   ((ll) a.size())

typedef long long		   ll;
typedef unsigned long long ull;


int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> a2(n);
  rep(i,n){
    scanf("%lld",&a[i]);
  }

  copy(all(a),a2.begin());
  sort(all(a2));
  ll ma = a2[n-1];
  ll ma2 = a2[n-2];

  ll c=-1;
  rep(i,n){
    if((a[i] == ma) && (ma!=ma2)) continue;
    else if(abs(a[i]-ma/2)<abs(c-ma/2)) c=a[i];
  }
  cout << ma << " " << c << endl;

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b &&  b!=c){
    cout<<"Yes"<<'\n';
  }
  else if(b==c && a!=c){
    cout<<"Yes"<<'\n';
  }
  else if(a==c && a!=b){
    cout<<"Yes"<<'\n';
  }
  else{
    cout<<"No"<<'\n';
  }
  return(0);
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
#include<cmath>
using namespace std;
const int N = 10010;
const int INF = 0x3f3f3f3f;
typedef pair<int,int>P;
struct Edge{
    int to,dis,cost;
    Edge(int a,int b,int c):to(a),dis(b),cost(c){}
};
int n,m,u,v,c,ds;
vector<Edge>G[N];
int d[N];

void Dijkstra(int s){
    priority_queue<P,vector<P>,greater<P> >que;
    for(int i=1;i<=n;i++)d[i]=INF;
    d[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p=que.top();que.pop();
        int v=p.second;
        if(d[v]<p.first)continue;
        for(int i=0;i<G[v].size();i++){
            Edge e=G[v][i];
            if(d[e.to]>d[v]+e.dis){
                d[e.to]=d[v]+e.dis;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

int main()
{
    //freopen("F:\\11.txt","r",stdin);
    while(cin>>n>>m&&(n||m)){
        for(int i=1;i<=n;i++)G[i].clear();
        for(int i=0;i<m;i++){
            scanf("%d%d%d%d",&u,&v,&ds,&c);
            G[u].push_back(Edge(v,ds,c));
            G[v].push_back(Edge(u,ds,c));
        }
        Dijkstra(1);
        int ans=0;
        for(int i=2;i<=n;i++){
            int Min=INF;
            for(int j=0;j<G[i].size();j++){
                Edge e=G[i][j];
                if(d[e.to]+e.dis==d[i]&&Min>e.cost){
                    Min=e.cost;
                }
            }
            ans+=Min;
        }
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 3304