akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
const double PI  =3.141592653589793238463;
using namespace std;
using ll = long long;
const ll INF = +10010010000;
typedef pair<int,int> P;
const int mod = 1e9+7;

struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a){
        (x+=a.x)%=mod;
        return *this;
    }
    mint& operator-=(const mint a){
        (x-=mod-a.x)%=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x)%= mod;
        return *this;
    }
    mint operator+(const mint a)const{
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a)const{
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a)const{
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
      if(!t)return 1;
      mint a = pow(t>>1);
      a*=a;
      if(t%1)a*=*this;
      return a;
    }

    // for prime mod
    mint inv() const {
      return pow(mod-2);
    }
    mint& operator/=(const mint a){
      return (*this) *= a.inv();
    }
    mint operator/(const mint a)const{
      mint res(*this);
      return res/=a;
    }
};

struct combination{
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i<n;++i)fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i>=1;--i) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k){
    if(k<0 || k>n)return 0;
    return fact[n] * ifact[k] + ifact[n-k]; 
  }
};

int main(){
    char a;
    cin >> a;
    if(a-'0'>48)cout << "a"<<endl;
    else cout << "A"<<endl;
    return 0;
}

Measured memory_bytes: 3616
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int len_s,len_t,flag = 0;
    string s,t;
    cin>>s>>t;
    len_s = s.length();
    len_t = t.length();

    for(int i=0; i<len_t; i++){
        if(len_s == 0){
            break;
        }
        if(s[i] == t[i]){
            flag = 1;
            len_s--;
        }
        else if(s[i] != t[i]){
            cout<<"No\n";
            flag = 0;
            break;
        }
    }
    if(flag == 1){
        cout<<"Yes\n";
    }
    return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const ll INF = 1LL << 60;

#define MAX 2001
ll com[MAX][MAX];
void COM(){
  memset(com,0,sizeof(com));
  com[0][0] = 1;
  for (int i = 1; i < MAX; i++) {
    com[i][0] = 1;
    for (int j = 1; j < MAX; j++) {
      com[i][j] = (com[i-1][j] + com[i-1][j-1])%MOD;
    }
  }
}

int main(){
  int n,k; cin >> n >> k;
  COM();
  for (int i = 1; i <= k; i++) {
    std::cout << (com[n-k+1][i]*com[k-1][i-1])%MOD << '\n';
  }
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using vs = vector<string>;
using pint = pair<int, int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
    int n, m;
    cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int i, n;
    for(; scanf("%d", &n), n; printf("%d\n", i)) {
        for(i = 0; n - 1; i++) {
            n % 2 ? n = n * 3 + 1 : (n /= 2);
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define TTF template<typename T, typename F>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline void Out(T&x){cout<<x;}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline int ubnd(T&v,ET(T)&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T)&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF inline void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF inline void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
#undef TT
#undef TTF
#undef ET

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}

const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000;

int main()
{
  int cnt = 0;
  int n = in();
  string ans;
  cin >> ans;
  for (int k = 0; k < n; k++){
    string s;
    cin >> s;
    for (int step = 1; step < (int)s.size(); step++){
      for (int p = 0; p < (int)s.size(); p++){
        bool ok = true;
        for (int i = 0; i < (int)ans.size(); i++){
          if (p + step * i >= (int)s.size()){
            ok = false;
            break;
          }
          if (ans[i] != s[p + step * i]){
            ok = false;
            break;
          }
        }
        if (ok){
          cnt++;
          goto end;
        }
      }
    }
end:;
  }
  cout << cnt << endl;
  return (0);
}

// priority_queue queue deque front stringstream max_element min_element insert count make_tuple

Measured memory_bytes: 1228
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra() {
    int minv;
    int d[MAX], color[MAX];

    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[0] = 0;
    color[0] = GRAY;
    while (1) {
        minv = INFTY;
        int u = -1;
        for (int i = 0; i < n; i++) {
            if (minv > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1) break;
        color[u] = BLACK;
        for (int v = 0; v < n; v++) {
            if (color[v] != BLACK && M[u][v] != INFTY) {
                if (d[v] > d[u] + M[u][v]) {
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }

    for (int i = 0; i < n; i++) {
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            M[i][j] = INFTY;
        }
    }

    int k, c, u, v;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v >> c;
            M[u][v] = c;
        }
    }

    dijkstra();

    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

int main()
{
  string s;
  cin >> s;

  string oz = "", zo = "";
  for (int i = 0; i < s.size(); i++) {
    if (i % 2 == 0) {
      oz += '0';
      zo += '1';
    } else {
      oz += '1';
      zo += '0';
    }
  }
  
  ll ozc = 0, zoc = 0;
  for (ll i = 0; i < s.size(); i++) {
    if (oz[i] != s[i]) {
      ozc++;
    }
    if (zo[i] != s[i]) {
      zoc++;
    }
  }
  cout << min(ozc, zoc) << endl;
  return 0;
}


Measured memory_bytes: 768
n=int(input())
l=list(map(int,input().split()))
l.sort()
cnt=0

for i in range(n):
    for j in range(i,n):
        for k in range(j,n):
            if l[i]+l[j]>l[k] and l[i]!=l[j] and l[i]!=l[k] and l[k]!=l[j]:
                cnt+=1
print(cnt)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const ll INF = (ll)1 << 60;

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if (abs(a-c) <= d) cout << "Yes" << endl;
    else if (abs(a-b) <= d && abs(b-c) <= d) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
use std::io::{BufRead, Write, stdin, stdout};

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let mut split = s.split_whitespace();
    let a: u8 = match split.next().unwrap().parse().unwrap() {
        1 => 14,
        n => n,
    };
    let b: u8 = match split.next().unwrap().parse().unwrap() {
        1 => 14,
        n => n,
    };
    writeln!(output,
             "{}",
             match (a, b) {
                 _ if a < b => "Bob",
                 _ if a == b => "Draw",
                 _ if a > b => "Alice",
                 _ => unreachable!(),
             })
        .unwrap();
}

fn main() {
    let stdin = stdin();
    solve(stdin.lock(), stdout());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v = Vec::<u8>::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }
    #[test]
    fn case1() {
        test("8 6\n", "Alice\n");
    }
    #[test]
    fn case2() {
        test("1 1\n", "Draw\n");
    }
    #[test]
    fn case3() {
        test("13 1\n", "Bob\n");
    }
}

Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {

	/** 元金 */
	static final BigDecimal capital = BigDecimal.valueOf(100000);

	/** 利子 */
	static final BigDecimal interest = BigDecimal.valueOf(0.05);

	/** 率 */
	static final BigDecimal rate = BigDecimal.valueOf(1).add(interest);

	/**
	 * プログラミングコンテスト
	 * 初級編：Debt Hell(借金地獄)
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);
		String input = br.readLine();

		// ユーザに入力：何週間後の借金を出力するのか
		int weeks = Integer.valueOf(input);

		// 計算結果の初期値に元金を格納
		BigDecimal result = capital;
		for (int i = 0; i < weeks; i++) {
			// 利子を考慮した率をかけ、1000円未満を切り上げる
			result = roundUpLowerThousand(rate.multiply(result).setScale(0, BigDecimal.ROUND_UP));
		}

		System.out.println(result);
	}

	/**
	 * 対称の数値の1000未満を切り上げをして返却
	 *
	 * @param target 対称数値
	 * @return 切り上げした結果
	 */
	private static BigDecimal roundUpLowerThousand(BigDecimal target) {
		// 計算に使用する基準数（1000）
		BigDecimal basisNumber = BigDecimal.valueOf(1000);
		BigDecimal result = target.divide(basisNumber).setScale(0, BigDecimal.ROUND_UP);

		return result.multiply(basisNumber);
	}
}

Measured memory_bytes: 18276
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 105
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;

int main() {
	go;
    cin >> N;
    fi(i, 0, N, 1) {
    	cin >> arr[i];
    }
    sort(arr, arr + N);
    ll finalAns = 1e15;
    fei(i, 0, 2005, 1) {
    	ll minVal = min(abs(i - arr[0]), abs(i - arr[N - 1]));
    	ll maxVal = max(abs(i - arr[0]), abs(i - arr[N - 1]));
    	ll ans = 2 * minVal + maxVal;
    	finalAns = min(ans, finalAns);
    }
    cout << finalAns << "\n";
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define for(i,n) for(i=0;i<n;i++)
#define ll long long
///vector<int>vec;
///sort(s.begin(),s.endl());
///sort(ara,ara+n);
int main()
{
     int i,n,t,p,j=0;
     string s,m;
     cin>>n;
     int ara[n];
     for(i,n){
        cin>>ara[i];
     }
     for(i,n){
        if(ara[i]%2==0){
            if(ara[i]%3!=0 && ara[i]%5!=0){
                   // cout<<ara[i];
                cout<<"DENIED"<<endl;return 0;
            }
        }
     }
     cout<<"APPROVED"<<endl;

     return EXIT_SUCCESS;

}



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

namespace AOJ_ICPC1 {

	class Program {
		static void Main(string[] args) {
			while (true) {
				int num = int.Parse(Console.ReadLine());
				if (num == 0) break;
				Console.WriteLine(result(num));
			}
		}
		static int result(int n) {
			int count = 0;
			int max_a = n/2+1;
			for (int a = 2; a <= max_a; a++) {
				for (int b = 1; b < a; b++) {
					int tmp = a * a + a - b * b + b;
					if (tmp == 2 * n) count++;
					else if (tmp < 2 * n) break;
				}
			}
			return count;
		}
	}
}

Measured memory_bytes: 5604
#include<string>
#include<iostream>
using namespace std;
int main(){
  string tmp[]={"","',.!?","abcABC","defDEF","ghiGHI","jklJKL","mnoMNO","pqrsPQRS","tuvTUV","wxyzWXYZ"};

  string str;

  while(cin >> str){
    char hg=str[0];
    int cnt = -1;

    for(int i=0,l=str.size();i<l;i++){
      if(str[i-1]=='0'&&str[i]=='0') cout << " ";
      else if(str[i] == '0'){
        cout << tmp[hg - '0'][cnt % tmp[hg - '0'].size()];
        cnt = -1,hg = '0';
      }else if(hg == '0') cnt=0,hg = str[i];
      else if(str[i] == hg) cnt++;
      else{
        cout << tmp[hg - '0'][cnt % tmp[hg - '0'].size()];
        hg = str[i],cnt = 0;
      }
    }
    if(str[str.size()-1]!='0')cout << tmp[hg - '0'][cnt % tmp[hg - '0'].size()];
    cout << endl;
  }
}

Measured memory_bytes: 1192
#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, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9
const int mod = 1e9+7;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  COMinit();
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  REP(i, N){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  ll ans = 0;
  REP(i, N){
    int add;
    if(N-i>= K){
      add = (A[i] *COM(N-i-1, K-1)) % mod;
      if(add < 0){
        add += mod;
      }
      ans -= add;
      ans %= mod;
      if(ans < 0){
        ans += mod;
      }
    }
    if(K-1 <= i){
      add = (A[i] * COM(i, K-1)) % mod;
      if(add < 0){
        add += mod;
      }
      ans += add;
      ans %= mod;
      if(ans < 0){
        ans += mod;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12544
m,d = map(int,input().split())
ans = 0
if d <= 21:
    print(0)
    exit()
for i in range(1,m+1):
    for j in range(22,d+1):
        x = str(j)
        d1 = int(x[0])
        d2 = int(x[1])
        if d1 >= 2 and d2 >= 2 and d1*d2 == i:
            ans += 1
            #print(i,d1,d2)

print(ans)

Measured memory_bytes: 3060
'use strict';
process.stdin.on('data', function(chunk) {
 
  var inputs = chunk.toString().trim().split('\n');
  var cols = inputs.filter(function(v) {
    return v !== '0 0';
  })
  .map(function(v) {
    return v.split(' ')
          .map(Number)
          .sort(function(a ,b) {
            return a - b;
          })
          .join(' ');
  })
  .join('\n');
 
  console.log(cols);
 
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 18452
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1, 0, 1,0};
const int dy[] = {0, -1, 0,1};
const int INF = 1001001001;
const ll INFll = 1E+18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    mf_graph<ll> g(n*m+2);
    int start = n*m;
    int goal = n*m+1;

    rep(i, n) rep(j, m) {
        if (s[i][j]=='#') continue;
        int id1 = m*i+j;
        if ((i+j)%2==0) {
            g.add_edge(start, id1, 1);
        }
        else {
            g.add_edge(id1, goal, 1);
            continue;
        }
        rep(k, 4) {
            int ii = i + dx[k];
            int jj = j + dy[k];
            if (ii<0 || jj<0 || ii>=n || jj>=m) continue;
            if (s[ii][jj]=='#') continue;
            int id2 = m*ii+jj;
            g.add_edge(id1, id2, 1);
        }
    }
    ll f = g.flow(start, goal);
    
    pr(f);

    auto edges = g.edges();
    for (auto e: edges) {
        if (e.from==start || e.to==goal || e.flow==0) continue;
        int i = e.from/m;
        int j = e.from%m;
        int ii = e.to/m;
        int jj = e.to%m;
        //printf("%d %d %d %d\n", i, j, ii, jj);
        if (i==ii) {
            if (j>jj) swap(j, jj);
            s[i][j] = '>';
            s[ii][jj] = '<';
        }
        if (j==jj) {
            if (i>ii) swap(i, ii);
            s[i][j] = 'v';
            s[ii][jj] = '^';
        }
    }

    rep(i, n) pr(s[i]);
    return 0;
}


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

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

    for(int i = 1; i <= n; i++)    
        cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
x = [int(i) for i in input().split()]
y = x.copy()
y.sort()
y_e = y[n//2]
y_o = y[n//2 - 1]
for xx in x:
    if xx >= y_e:
        print(y_o)
    else:
        print(y_e)

Measured memory_bytes: 26772
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
  int n;

  scanf("%d" ,&n);
  while(n--){
    double h,m;
    scanf("%lf:%lf" ,&h ,&m);
    
    double l = 30*h + m/2;
    double s = m * 6.0;

    double key = fabs(l-s);
    key = min(key,360-key);
  
    if(0 <= key && key < 30){
      puts("alert");
    }else if(90 <= key && key <= 180){
      puts("safe");
    }else{
      puts("warning");
    } 
  }

  return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char a;
    cin>>a;
    if(isupper(a))
    cout<<"A\n";
    else
    cout<<"a\n";
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

int main() {
    cin>>S;
    N = S.size();
    char c = S[0];
    ll ans = 0;
    reps(i,1,N) {
        ans += c != S[i];
        c = S[i];
    }
    cout<<ans<<endl;
}

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

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

	int N, K;
	cin >> N >> K;

	vector<int> X1(N);
	vector<int> Y1(N);
	vector<int> D1(N);
	vector<int> X2(N);
	vector<int> Y2(N);
	vector<int> D2(N);

	for (int i = 0; i < N; i++){
		cin >> X1[i] >> Y1[i] >> D1[i] >> X2[i] >> Y2[i] >> D2[i];
	}
	
	//ソート用vector
	vector<int> X(2*N);
	vector<int> Y(2*N);
	vector<int> D(2*N);

	copy(X1.begin(), X1.end(), X.begin());
	copy(X2.begin(), X2.end(), X.begin()+N);
	copy(Y1.begin(), Y1.end(), Y.begin());
	copy(Y2.begin(), Y2.end(), Y.begin()+N);
	copy(D1.begin(), D1.end(), D.begin());
	copy(D2.begin(), D2.end(), D.begin()+N);

	sort(X.begin(), X.end());
	sort(Y.begin(), Y.end());
	sort(D.begin(), D.end());
	
	long long int ans = 0;
	int kasanari;
	for (int i = 0; i < 2*N-1; i++){ //X
		for (int j = 0; j < 2*N-1; j++){ //Y
			for (int k = 0; k < 2*N-1; k++){ //D
				kasanari = 0;
				for (int l = 0; l < N; l++){ //実際の直方体
					if ((X1[l]<=X[i] && X[i+1] <= X2[l]) &&
						(Y1[l]<=Y[j] && Y[j+1] <= Y2[l]) &&
						(D1[l]<=D[k] && D[k+1] <= D2[l]))
						kasanari++;
				}
				if (kasanari >= K){
					ans += (long long int)(X[i + 1] - X[i]) * (Y[j + 1] - Y[j]) * (D[k + 1] - D[k]);
				}
			}
		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int n;
	cin>>n;
	cout<<n/500*1000+(n-n/500*500)/5*5;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# スペース区切りの整数の入力
n, k = map(int, input().split())

# n個の要素の入力
l = list(map(int, input().split()))
l.sort()
l.reverse()

# 出力
if n <= k:
    print("0")
else:
    print("{}".format(sum(l[k:])))


Measured memory_bytes: 25768
n,m = map(int, input().split())
aa = [input() for _ in range(n)]
bb = [input() for _ in range(m)]

match = False
for y in range(n-m+1):
    for x in range(n-m+1):
        target = ([''.join(aa[i][x:x+m]) for i in range(y,y+m)])
        if match or target == bb:
            match = True

print('Yes' if match else 'No')


Measured memory_bytes: 3060
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn f(x: i64) -> usize {
    if x == -1 {
        return 0;
    }

    let mut ans = (x+1) / 2 % 2;
    if x % 2 == 0 {
        ans ^= x;
    }

    return ans as usize;
}

fn solve() {
    input!(
        a: i64,
        b: i64,
    );

    println!("{}", f(b) ^ f(a  - 1));
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
import math

def n_check(N,P):
  N_list = list(range(1,N+1))
  n = 0
  for i in P:
    n += (N_list.index(i))*(math.factorial(len(N_list)-1))
    N_list.remove(i)
  return n

N = int(input())
P = map(int,input().split())
Q = map(int,input().split())

p_n = n_check(N,P) + 1
q_n = n_check(N,Q) + 1

print(abs(p_n - q_n))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
int ret;
vector<int>vx,vy;
void dfs(int d,int x,int y,int n){
	if(ret<n)ret=n;
	if(0<d&&x<vx.size())dfs(d-1,x+1,y,n+vx[x]);
	if(1<d&&y<vy.size())dfs(d-2,x,y+1,n+vy[y]);
}
int main(){
	int d,x,y,n;
	string s;

	cin>>d;
	for(cin>>x;x--;){
		cin>>s>>n;
		if(s=="D")vx.push_back(n);
	}
	for(cin>>y;y--;){
		cin>>s>>n;
		if(s=="DD")vy.push_back(n);
	}
	sort(vx.begin(),vx.end(),greater<int>());
	sort(vy.begin(),vy.end(),greater<int>());
/*
	//greedy
	for(x=y=n=0;;){
		if(d>0 && x<vx.size()){
			if(d>1 && y<vy.size() && vx[x]<vy[y]){
				d-=2;
				if(x<vx.size()-1 && vx[x]+vx[x+1]>=vy[y]){
					n+=vx[x]+vx[x+1];
					x+=2;
				}else{
					n+=vy[y];
					y++;
				}
			}else{
				d-=1;
				n+=vx[x];
				x++;
			}
		}else if(d>1 && y<vy.size()){
			d-=2;
			n+=vy[y];
			y++;
		}else{
			break;
		}
	}
	cout<<n<<endl;
*/
	dfs(d,0,0,0);
	cout<<ret<<endl;
}

Measured memory_bytes: 1236
#include<iostream>
#include<string>
using namespace std;
int l[1000];
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int N,K,a;
    int result=0;
	cin >> N >> K;
    for(int i=0;i<N;i++){
        cin >> l[i];
    }

    for(int i=0;i<N-1;i++){
        for(int j=N-1;j>i;j--){
            if(l[i]<l[j]){
                int a=l[i];
                l[i]=l[j];
                l[j]=a;
            }
        }
    }
    for(int i=0;i<K;i++){
        result=result+l[i];
    }
	cout << result << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#include <stdbool.h>
#define MAX 200

int top = 0;
char stk[1];
int stack[MAX];

bool isEmpty(){
	if (top == 0)
		return true;
	return false;	
}

bool isFull(){
	if(top >= MAX-1)
		return true;
	return false;
}

void push(int s[], int x){
	if (isFull())
		printf("overflow");
	else{
		top++;
		s[top] = x;
	}
	
}

int pop(int s[]){
	if (isEmpty())
		printf("underflow");
	else{
		top--;
		return s[top+1];
	}
}

int main(void) {
	int x, y, result;

	while(scanf("%s", stk) != EOF){
		if (stk[0] == '+'){
			x = pop(stack);
			y = pop(stack);
			
			result = x + y;
			push(stack, result);
			
			
		}else if(stk[0] == '-'){
			x = pop(stack);
			y = pop(stack);
			
			result = y - x;
			push(stack,result);
			
		}else if(stk[0] == '*'){
			x = pop(stack);
			y = pop(stack);

			result = x * y;
			push(stack,result);
		}else{
			x = atoi(stk);
			push(stack,x);
		}
	}
	printf("%d\n", result);

	return 0;
}



Measured memory_bytes: 2052
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int K, T; cin >> K >> T;
    vector<int> as(T); for (auto &ai : as) cin >> ai;
    int tmpIndex = -1, tmpNum = -1;
    int ans = 0;
    for (int i = 0; i < K; ++i)
    {
        // 現時点で最も残っているケーキから順に食べる
        auto itr = max_element(as.begin(), as.end());
        *itr -= 1;
        // なるべく連続して食べないように，今日食べたケーキの残数を０に置き換えておく
        if (tmpIndex >= 0)
        {
            as[tmpIndex] = tmpNum;
        }
        tmpIndex = distance(as.begin(), itr);
        tmpNum = *itr;
        as[tmpIndex] = 0;
        // 残りのケーキの種類が１通りになってしまったら，後は連続で食べるしかない
        if (count(as.begin(), as.end(), 0) == T)
        {
            ans = K - 1 - i;
            break;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a, b;
    cin >> a >> b;

    int c = a * b;

    
    if(c & 1)
        cout << "Odd\n";
    else
        cout << "Even\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
int iinf=1<<30;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll poc(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
deque<ll> dq;
ll dp[200010];
ll h[200010];
ll c,n;
ll aa(ll j){
    return -2*h[j];
}
ll bb(ll j){
    return dp[j]+h[j]*h[j];
}
ll f(ll j,ll x){
    return aa(j)*x+bb(j);
}
bool check(ll ss,ll tt,ll uu){
    return (bb(uu)-bb(ss))*(aa(ss)-aa(tt))<=
    (bb(tt)-bb(ss))*(aa(ss)-aa(uu));
}
void solve(){
    dp[1]=0;
    dq.push_back(1);
    rep(i,2,n+1){
        while(dq.size()>=2){
            if(f(dq[0],h[i])>=f(dq[1],h[i]))dq.pop_front();
            else break;
        }
        dp[i]=dp[dq[0]]+(h[i]-h[dq[0]])*(h[i]-h[dq[0]])+c;
        while(dq.size()>=2){
            int t=dq.size();
            if(check(dq[t-2],dq[t-1],i)==false)break;
            dq.pop_back();
        }
        dq.push_back(i);
    }
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n;
    cin>>c;
    rep(i,1,n+1)cin>>h[i];
    solve();
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<vi> cnt(n + 1, vi(3));
  for(int i = n - 1; i >= 0; i--){
    for(int j = 0; j < 3; j++){
      cnt[i][j] += cnt[i + 1][j];
    }
    if(s[i] == 'R') cnt[i][0]++;
    if(s[i] == 'G') cnt[i][1]++;
    if(s[i] == 'B') cnt[i][2]++;
  }
  ll res = 0;
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){
      if(s[i] != s[j]){
        if(s[i] == 'R' && s[j] == 'G'){
          res += cnt[j][2];
          if(j + j - i < n && s[j + j - i] == 'B') res--;
        }
        if(s[i] == 'G' && s[j] == 'R'){
          res += cnt[j][2];
          if(j + j - i < n && s[j + j - i] == 'B') res--;
        }
        if(s[i] == 'R' && s[j] == 'B'){
          res += cnt[j][1];
          if(j + j - i < n && s[j + j - i] == 'G') res--;
        }
        if(s[i] == 'B' && s[j] == 'R'){
          res += cnt[j][1];
          if(j + j - i < n && s[j + j - i] == 'G') res--;
        }
        if(s[i] == 'G' && s[j] == 'B'){
          res += cnt[j][0];
          if(j + j - i < n && s[j + j - i] == 'R') res--;
        }
        if(s[i] == 'B' && s[j] == 'G'){
          res += cnt[j][0];
          if(j + j - i < n && s[j + j - i] == 'R') res--;
        }
      }
    }
  }
  cout << res;
}

Measured memory_bytes: 3848
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
#define pb push_back
#define skip continue
#define ll long long
long long a,b,c,d=0,e=0,i,f=0,g=0,j,k=0,l=0,r,m,h,p[200001]={0},df[200001]={0};
string t,x,q,s;
double w;
vector<ll>dv[200001],v,z;
vector<string>u;
map<string,ll>n;
set<ll>y;
void dfs(ll x){
    for(ll i=0;i<dv[x].size();i++){
        if(df[dv[x][i]]==0){
            p[df[x]]++;
            df[dv[x][i]]=df[x];
            dfs(dv[x][i]);
        }
    }
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin>>a>>b;
    for(i=1;i<=b;i++){
        cin>>c>>d;
        dv[c].pb(d);
        dv[d].pb(c);
    }
    d=0;
    for(i=1;i<=a;i++){
        if(df[i]==0){
            d++;
            df[i]=d;
            p[d]++;
            dfs(i);
        }
    }
    sort(p+1,p+200001);
    cout<<p[200000];
}

Measured memory_bytes: 27024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}

int M,N;
bool num[7368792];

int f(){
	if(M==2&&N==500000)return 7368791;
	memset(num,1,sizeof(num));
	for(int i = M;i<7368792;i++){
		if(num[i]){
			if(N--==0)return i;
			for(int j = 2;i*j<7368792;j++){
				num[i*j] = false;
			}
		}
	}
}

signed main(){
	vector<int>ans;
	while(cin>>M>>N,M||N)ans.push_back(f());
	for(auto e:ans)cout<<e<<endl;
}


Measured memory_bytes: 10284
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num), lower_bound(A, A+N, num)
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>		// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>			// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>		// push(x), front(), pop()
#include <deque>
#include <stack>		// push(x), top(), pop()
#include <map>			// M[key],  insert(key, val), erase(key), find(key), 
#include <set>			// insert(key), erase(key), find(key)

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

#define PI 3.141592653589793)
#define MOD 1000000007
#define REP(i, n) for(int i = 0; i < n; i++)

void solve() {
	int a, b, ans;
	cin >> a >> b;
	if (b%a == 0) ans = a + b;
	else ans = b - a;
	cout << ans << endl;
}

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

Measured memory_bytes: 256
// AOJ 0590: Available Areas
// 2017.10.1 bal4u@uu
// 2017.11.14

#include <stdio.h>

int check(int s)
{
	int x, u, v;

	for (u = 3, v = 4, x = 1; v <= s; x++, u += 2, v += (x << 2)) {
		if ((s - x) % u == 0) return 0;
	}
	return 1;
}

char buf[15], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, ans;

	fgets(p=buf, 15, stdin), n = getint();
	ans = 0; 
	while (n -- > 0) {
		fgets(p=buf, 15, stdin);
		if (check(getint())) ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1740
import java.util.Scanner;

public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int a[] = new int[n];
		for(int i = 0 ; i < n; i++){
			a[i] = s.nextInt();
		}
		for(int i = n - 1; 0 <= i; i--){
			System.out.print(a[i]);
			if(i != 0) System.out.print(" ");
		}
		System.out.println();
	}
	public static void main(String[] args) {
		/* 
		 * Main x;
		 * x = new Main();
		 * x.run();
		 * ??¨????????????
		 */
		new Main().run();
		
	}
}

Measured memory_bytes: 26448
N = int(input())
A = list(map(int,input().split()))
maxA = max(A)
B = [0]*(maxA)

for i in A:
    B[i-1] += 1

ans = 0
for i in sorted(A):
    if B[i-1] == 0:
        continue
    if B[i-1] == 1:
        ans += 1
    for j in range(i,maxA+1,i):
        B[j-1] = 0

print(ans)

Measured memory_bytes: 123472
#include <bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define cases long long int t;cin>>t;while(t--)
#define fio ios::sync_with_stdio(false); cin.tie(0)
#define ALL(v) (v).begin(), (v).end() 
#define twod(n,m) vector<vector<int> > arr( n , vector<int> (m, 0))
#define prs(s,n) for(ll i=0;i<n;i++)cout<<s[i];
#define pra(arr,n) for(ll i=0;i<n;i++)cout<<arr[i]<<" ";
#define err1(a) cout<<#a<<" "<<a<<endl;
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl;
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl;
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl;
using namespace std;
int main() 
{
	fio;
    ll n,sum=0;
    cin>>n;
    vector<ll> arr(100010,0);
    for(ll i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        ++arr[x];
        sum += x;
    }
    ll q;
    cin>>q;
    while (q--)
    {
        ll b,c;
        cin>>b>>c;
        ll cnt = arr[b];
        sum -= cnt*b;
        sum += cnt*c;
        arr[b] = 0;
        arr[c] += cnt;
        cout<<sum<<endl;
        // pra(arr,5);
        // cout<<endl;
    }
    /*
      1 2 3 4
    0 1 1 1 1 0
    0 0 2
      
    */
}


Measured memory_bytes: 3988
from sys import stdin
N = int(stdin.readline().rstrip())
data = [0]
for _ in range(N):
    data.append(int(input()))
ans = 0
s = sum(data)
for i in data:
    if (s - i) % 10 != 0:
        ans = max(ans,s-i)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n, long long modvalue) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2, modvalue);
        return t * t % modvalue;
    } else {
        return modpow(m, n - 1, modvalue) * m % modvalue;
    }
}

long long moddiv(long long a, long long b, ll modvalue) { return (a * modpow(b, mod - 2, modvalue)) % modvalue; }

const ll INF = 1LL << 60;

string change_binary(long long a) {
    string ret;
    for (int i = 31; i >= 0; i--) {
        ret += (a >> i & 1) + '0';
    }
    return ret;
}

ll nCkmod(ll n, ll k, ll modvalue) {
    ll numera = 1;
    for (int i = n; i > n - k; i--) {
        numera *= i;
        numera %= modvalue;
    }
    ll denomi = 1;
    REP(i, k) {
        denomi *= (i + 1);
        denomi %= modvalue;
    }
    return moddiv(numera, denomi, modvalue);
}

map<ll, ll> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
vector<ll> dijkstra(vector<vector<P>> graph, ll s) {
    vector<ll> ans(graph.size(), -1);
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push({0, s});
    while (pq.size() > 0) {
        ll cur1 = 0;
        ll cur2 = 0;
        if (ans[pq.top().second] != -1) {
            pq.pop();
        } else {
            cur1 = pq.top().first;
            cur2 = pq.top().second;
            pq.pop();
            ans[cur2] = cur1;
            for (ll i = 0; i < graph[cur2].size(); i++) {
                pq.push({cur1 + graph[cur2][i].first, graph[cur2][i].second});
            }
        }
    }
    return ans;
}
vector<string> maze;
ll h, w;
bool check(ll y, ll x) {
    if (x < 0 || x >= w || y < 0 || y >= h || maze[y][x] == '#') {
        return false;
    }
    return true;
}
double p;
long double f(long double x) { return x + p / (pow(2, x / 1.5)); }
ll gcd(ll a, ll b) {
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}
int main() {
    ll s;
    cin >> s;
    ll sum = 0;
    rep(i, 1, s / 3 + 1) {
        sum += nCkmod(s - 2 * i - 1, i - 1, mod);
        sum %= mod;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3684
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		boolean[][] dp = new boolean[101][10010];
		dp[0][0] = true;
		for(int i = 0 ; i < n ; i++) {
			for(int j = 0 ; j <= 10000 ; j++) {
				if(dp[i][j] == true) {
					dp[i + 1][j] = true;
					dp[i + 1][j + a[i]] = true;
				}
			}
		}
		for(int i = 10000 ; i >= 0 ; i--) {
			if(i % 10 != 0 && dp[n][i] == true) {
				System.out.println(i);
				return;
			}
		}
		System.out.println(0);
	}
}


Measured memory_bytes: 25300
def main():
    n, m = map(int, input().split())
    lamps = [list(map(lambda x:int(x)-1, input().split()))[1:] for _ in range(m)]
    p = list(map(int, input().split()))
    res = 0
    for i in range(2**n):
        # a = [0] * n
        # ランプごとにスイッチとつながっているか l：ランプindex
        for l in range(m):
            s_on = 0
            for j in range(n): # j;スイッチリスト
                # スイッチ入ってる かつ ランプがつながっているかlampsはつながっているスイッチリスト
                if(i >> j) & 1 and j in lamps[l]:
                    s_on += 1
            if s_on % 2 != p[l]:
                break
        # ランプ全てにおいて、ifの条件以外だったら
        else:
            res += 1
    print(res)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
line = input()
a, b, c = [int(n) for n in line.split()]
k = int(input())

while k>0:
    if a>=b and a>=c:
        a = a*2
        soma = a+b+c
    elif b>=a and b>=c:
        b = b*2
        soma = a+b+c
    else:
        c = c*2
        soma = a+b+c
    k = k-1

print(soma)

Measured memory_bytes: 3064
import bisect
n = int(input())
a = list(map(int, input().split()))
ans = 0
l_dp = []
r_dp = []
for i in range(n):
    l_dp.append(a[i]+i)
    r_dp.append(n-i-1-a[n-i-1])
r_dp.sort()
for i in l_dp:
    if i < 0 or i >= n: continue
    l_index = bisect.bisect_left(r_dp, i)
    r_index = bisect.bisect_right(r_dp, i)
    ans += r_index - l_index
print(ans)

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

struct Node{
    int key;
    Node *lch,*rch;  
    Node(int key):key(key),lch(nullptr),rch(nullptr){}
};

class BinarySearchTree
{
 private:
    Node* root;
 public:
    BinarySearchTree():root(nullptr){}
    void insert(int key){
        Node* node=new Node(key);
        if(root==nullptr){
            root=node; return;
        }
        Node *cur=root,*pre=nullptr;
        while(cur!=nullptr){
            pre=cur;
            cur=(node->key<cur->key? cur->lch:cur->rch);
        }
        assert(pre!=nullptr);
        (node->key<pre->key? pre->lch:pre->rch)=node;

    }
    Node* find(int key){
        Node* cur=root;
        while(cur!=nullptr and key!=cur->key){
            cur=(key<cur->key? cur->lch:cur->rch);
        }
        return cur;
    }
    void print(){
        assert(root!=nullptr);
        inorder(root); puts("");
        preorder(root); puts("");
    }
    void inorder(Node* node){
        if(node->lch!=nullptr) inorder(node->lch);
        printf(" %d",node->key);
        if(node->rch!=nullptr) inorder(node->rch);
    }
    void preorder(Node* node){
        printf(" %d",node->key);
        if(node->lch!=nullptr) preorder(node->lch);
        if(node->rch!=nullptr) preorder(node->rch);
    }
};

int main()
{
    BinarySearchTree tree;
    int Q; cin>>Q;
    while(Q--){
        string s; cin>>s;
        if(s=="insert"){
            int x; cin>>x;
            tree.insert(x);
        }else if(s=="find"){
            int x; cin>>x;
            cout<<(tree.find(x)!=nullptr? "yes":"no")<<endl;
        }else{
            tree.print();
        }
    }
    return 0;
}


Measured memory_bytes: 18812
#include<bits/stdc++.h>
using namespace std;
signed main(){
  string s;
  cin>>s;
  string x(7,'.');
  for(int i=0;i<4;i++) x[i*2]=s[i];
  int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
  if(a+b+c+d==7){
    x[1]='+';x[3]='+';x[5]='+';
  }
  if(a+b+c-d==7){
    x[1]='+';x[3]='+';x[5]='-';
  }
  if(a+b-c+d==7){
    x[1]='+';x[3]='-';x[5]='+';
  }
  if(a+b-c-d==7){
    x[1]='+';x[3]='-';x[5]='-';
  }
  if(a-b+c+d==7){
    x[1]='-';x[3]='+';x[5]='+';
  }
  if(a-b+c-d==7){
    x[1]='-';x[3]='+';x[5]='-';
  }
  if(a-b-c+d==7){
    x[1]='-';x[3]='-';x[5]='+';
  }
  if(a-b-c-d==7){
    x[1]='-';x[3]='-';x[5]='-';
  }
  cout<<x<<"=7"<<endl;
  return 0;
}

Measured memory_bytes: 256