akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
#include <bitset>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

class UnionFind{
public:
  vector<ll> par; //各元の親を表す配列
  vector<ll> siz; //素集合のサイズを表す配列

  UnionFind(ll sz_): par(sz_), siz(sz_,1){
    for (int i=0; i<sz_; ++i) par[i] = i;
  }
  void init(ll sz_){
    par.resize(sz_);
    siz.assign(sz_,1);
    for (int i=0; i<sz_; ++i) par[i] = i;
  }

  // Find
  ll root(ll x){ //根の検索
    if (par[x] == x){
      return x;
    }else{
      return par[x] = root(par[x]);
    }
  }

  // Union(Unite, Merge)
  bool merge(ll x, ll y){
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (siz[x] < siz[y]) swap(x,y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }
  bool issame(ll x, ll y){
    return root(x) == root(y);
  }
  ll size(ll x){
    return siz[root(x)];
  }
};


int main(){
  int N, M; cin >> N >> M;
  vector<int> p(N);
  rep(i, N) {
    cin >> p[i];
    p[i]--;
  }

  UnionFind uf(N);
  rep(i, M){
    int x, y; cin >> x >> y;
    x--, y--;
    uf.merge(p[x], p[y]);
  }
  ll ans = 0;
  rep(i, N){
    if (uf.issame(i, p[i])) ans++;
  }
  cout << ans << endl;
}


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

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int x, a, b;
  cin >> x >> a >> b;
  int A = abs(x-a);
  int B = abs(x-b);
  if(A < B) cout << 'A' << endl;
  else cout << 'B' << endl;
}






Measured memory_bytes: 256
X = int(input())

def prime_factorize(x):
    i = 2
    ans = []
    while i * i <= x:
        if x % i == 0:
            return False
        else:
            i += 1
    return True

while True:
    if prime_factorize(X) is True:
        print(X)
        exit()
    else:
        X += 1

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

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

        int N,X,T;
        int i,k;
        int ans=0;
        int ctr=0;

        cin >> N >> X >> T;


        if(N%X==0)
                ans=(N/X)*T;
        else 
                ans=(N/X+1)*T;

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


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int n,m,x;
vector<vector<ll>>vec(12,vector<ll>(13));
ll ans=1e9;
void dfs(ll money,vector<ll>alg,int count)
{
if(count==n)//カウントがnのとき（すべてから選びきったとき）
 {bool ok=true;
  rep(i,m)
  {if(alg[i]<x)ok=false;}
  if(ok)ans=min(ans,money);
  return;
 }
 dfs(money,alg,count+1);//選ばないとき
 //ここから選ぶときの処理
 money+=vec[count][0];
 rep(i,m)
 {alg[i]+=vec[count][i+1];}//Cが最初にあるから+1
 dfs(money,alg,count+1);
}
int main() {
cin>>n>>m>>x;
rep(i,n)
{
  rep(j,m+1)
  {
    cin>>vec[i][j];
  }
}
dfs(0,vector<ll>(m),0);
if(ans==1e9)ans=-1;
cout<<ans<<endl;
}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

Measured memory_bytes: 3640
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// nがあり、nの数だけの整数の入力
			long n = sc.nextLong();
			List<Long> an = new ArrayList<>();
			for (long i = 0; i < n; i++) {
				an.add(sc.nextLong());
			}
			long max = 0;
			Map<Long, Long> map = new HashMap<>();
			for (long l : an) {
				Long c = map.get(l);
				if (c == null) {
					c = 0l;
				}
				map.put(l, c + 1);
				if (max < c + 1) {
					max = c + 1;
				}
			}
			Map<Long, Long> countMap = new HashMap<>();
			for (Long l : map.values()) {
				Long c = countMap.get(l);
				if (c == null) {
					c = 0l;
				}
				countMap.put(l, c + 1);
			}
			Map<Long, Long> resultMap = new HashMap<>();
			for (long l = 0; l <= max; l++) {
				resultMap.put(l, (l * (l - 1) / 2));
			}
			Long result = 0l;
			for (Entry<Long, Long> e : countMap.entrySet()) {
				result = result + (e.getKey() * (e.getKey() - 1) / 2) * e.getValue();
			}
			for (long l : an) {
				System.out.println(result - (resultMap.get(map.get(l))) + (resultMap.get(map.get(l) - 1)));
			}
		}
	}

	/**
	 * 最小公倍数
	 */
	static long lcm(long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return c / b;
	}

	/**
	 * 最大公約数
	 */
	static long gcd(long a, long b) {
		long temp;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return b;
	}
}

Measured memory_bytes: 137600
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <fstream>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;


int a[300010];

int main(){
	int N,Q;
	cin >> N >> Q;
	for(int i = 0 ; i < N ; i++){
		int t;scanf("%d",&t);
		a[t] = t;
	}
	for(int i = 1 ; i <= 300000 ; i++){
		a[i] = max(a[i],a[i-1]);
	}
	while(Q--){
		int ans = 0;
		int t;scanf("%d",&t);
		for(int i = t ; i <= 300000 ; i += t ){
			ans = max(a[i-1]%t,ans);
		}
		ans = max(a[300000]%t,ans);
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 2404
// abc167_d
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
  int n;
  ll k;
  cin>>n>>k;
  vector<int> a(n);
  rep(i,n) cin>>a.at(i);
  vector<int> ord(n,-1);
  vector<int> s;
  int c=0,l=0;

  int v=0;
  while(ord.at(v)==-1) {
    ord.at(v)=s.size();
    s.push_back(v+1);
    v=a.at(v)-1;
  }
  l=ord.at(v);
  c=s.size()-l;
  if (k<l) cout<<s.at(k)<<endl;
  else {
    k-=l;
    k%=c;
    cout<<s[l+k]<<endl;
  }
  return 0;
}


Measured memory_bytes: 5884
s = input()
p = input()


def search(s, p):
    index = [i for i, x in enumerate(s) if x == p[0]]
    while len(s) <= 100:
        s += s
    for index in index:
        for i in range(0, len(p)):
            if s[index + i] != p[i]:
                break
            if i == len(p) - 1:
                return 'Yes'
    return 'No'


print(search(s, p))



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

typedef long long ll;

const int MAX_N = 100005;
int N;

ll L;
ll A[MAX_N];

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

    cin >> N >> L;

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

    int x = -1;

    for (int i = 0; i < N-1; ++i) {
        if ((A[i] + A[i+1]) >= L) {
            x = i;
            break;
        }
    }

    if (x < 0) {
        cout << "Impossible" << endl;
        return 0;
    }

    cout << "Possible" << endl;

    for (int i = 0; i < x; ++i) {
        cout << (i+1) << endl;
    }
    for (int j = N-1; j >= x+1; --j) {
        cout << j << endl;
    }

    return 0;
}



Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
pair <int, int> a[100010];
int x[100010], y[100010], n, m, cnt, b[100010], c[100010];
inline void add(int x, int k) {
    for (; x <= cnt; x += x & -x) c[x] = (c[x] + k) % mod;
}
inline int get(int x) {
    int ans = 0;
    for (; x; x -= x & -x) ans = (ans + c[x]) % mod;
    return ans;
}
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) scanf("%d", x + i);
    for (int i = 1; i <= m; i++) scanf("%d", y + i);
    for (int i = 1; i <= n; i++) {
        int id = lower_bound(y + 1, y + 1 + m, x[i]) - y;
        if (id == 1 || id == m + 1 || y[id] == x[i] || y[id - 1] == x[i]) continue;
        a[++cnt] = make_pair(y[id] - x[i], x[i] - y[id - 1]);
        b[cnt] = x[i] - y[id - 1];
    }
    sort(a + 1, a + 1 + cnt, [] (pair <int, int> a, pair <int, int> b) {
        return a.first != b.first ? a.first < b.first : a.second > b.second;
    });
    sort(b + 1, b + 1 + cnt);
    int ttmp = unique(a + 1, a + 1 + cnt) - a - 1;
    for (int i = 1; i <= ttmp; i++) {
        int now = lower_bound(b + 1, b + 1 + cnt, a[i].second) - b;
        add(now, get(now - 1) + 1);
    }
    return cout << (get(cnt) + 1) % mod << endl, 0;
}

Measured memory_bytes: 2560
chars = gets.chomp.chars
test_odd = (chars.each_slice(2).map { |e| e[0] }.uniq - ['R', 'U', 'D']).size.zero?
test_even = (chars.each_slice(2).map { |e| e[1] }.compact.uniq - ['L', 'U', 'D']).size.zero?
puts (test_odd && test_even) ? 'Yes' : 'No'


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

int main()
{
    string str1, str2;
    string answer = "";
    cin >> str1 >> str2;
    if (str1.length() > str2.length()) {
        for (int i = 0; i < str2.length(); i++) {
            answer = answer + str1[i] + str2[i];
        }
        answer = answer + str1[str1.length() - 1];
    } else {
        for (int i = 0; i < str1.length(); i++) {
            answer = answer + str1[i] + str2[i];
        }
    }
    cout << answer << endl;
    return 0;
}


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

using namespace std;

typedef long long LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = N; i >= 0; i--)

template<typename Container>
bool include(const Container& c, const typename Container::value_type& v) {
  return ( c.end() != std::find(c.begin(),c.end(),v) );
}

template<class T>
vector<T> unique_vec(const vector<T> &v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  return v;
}

int main() {
  string S, T;
  cin >> S >> T;
  int cnt = 0;
  rep(i, S.size()) {
    if (S[i] != T[i]) {
      cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3916
import java.util.*;

class Main {
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		Integer[] num = new Integer[5];
		
		for(int i = 0; i < 5; i++) {
			num[i] = scan.nextInt();
		}
		
		Arrays.sort(num, Collections.reverseOrder());
		
		System.out.println(num[0] + " " + num[1] + " " + num[2] + " " + num[3] + " " + num[4]);
	}
}

Measured memory_bytes: 17348
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 ) *} } ;}
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 ) *} } ;}
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 main() {
   input! {
      sx: i32,
      sy: i32,
      tx: i32,
      ty: i32,
   }
   let mut x = sx;
   let mut y = sy;
   while x != tx {
      print!("R");
      x += 1;
   }
   while y != ty {
      print!("U");
      y += 1;
   }

   while x != sx {
      print!("L");
      x -= 1;
   }
   while y != sy {
      print!("D");
      y -= 1;
   }

   print!("D");
   y -= 1;
   while x != tx + 1 {
      print!("R");
      x += 1;
   }
   while y != ty {
      print!("U");
      y += 1;
   }
   print!("L");
   x -= 1;

   print!("U");
   y += 1;
   while x != sx - 1 {
      print!("L");
      x -= 1;
   }
   while y != sy {
      print!("D");
      y -= 1;
   }
   print!("R");
   // x += 1;
   println!("");
}


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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define list_input(x, n) x[n]; rep(i,n){ cin >> x[i];}
#define ll long long

int main(){
  int n[3], k;
  cin >> n[0] >> n[1] >> n[2] >> k;
  sort(n, n+3);
  rep(i, k){
    n[2] *= 2;
  }
  cout << n[0]+n[1]+n[2] << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
D a,b,c;
int main(void){
    cin>>a>>b>>c;
    printf("%.05lf\n",c/a*b);
}



Measured memory_bytes: 3196
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    static int N;
    static int[] A;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        A = sc.nextIntArray(N*3);

        System.out.println( solve() );
    }

    private static long solve() {
        long[] ls = new long[N+1];
        PriorityQueue<Integer> lq = new PriorityQueue<>();
        long curr = 0;
        for (int i = 0; i < N; i++) {
            lq.add(A[i]);
            curr += A[i];
        }
        ls[0] = curr;
        for (int i = 0; i < N; i++) {
            int a = A[N+i];
            lq.add(a);
            int b = lq.poll();
            curr += (a-b);
            ls[i+1] = curr;
        }

        long[] rs = new long[N+1];
        Comparator<Integer> c = Comparator.naturalOrder();
        PriorityQueue<Integer> rq = new PriorityQueue<>(c.reversed());
        curr = 0;
        for (int i = 3*N-1; i >= 2*N; i--) {
            int a = A[i];
            rq.add(a);
            curr += a;
        }
        rs[N] = curr;
        for (int i = 0; i < N; i++) {
            int a = A[2*N-1-i];
            rq.add(a);
            int b = rq.poll();
            curr += (a-b);
            rs[N-i-1] = curr;
        }

        long max = Long.MIN_VALUE;
        for (int i = 0; i < N+1; i++) {
            max = Math.max(ls[i] - rs[i], max);
        }
        return max;
    }

    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

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

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

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

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}



Measured memory_bytes: 62732
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int();
        var A = Reader.IntArray(N);
        int ans = 1;
        int sign = 0;

        for (int i = 1; i < N; i++)
        {
            int s = Math.Sign(A[i] - A[i - 1]);
            if (s != sign && s != 0 && sign != 0) { sign = 0; ans++; }
            else if (sign == 0) sign = s;
        }

        Console.WriteLine(ans);
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 22368
import math
def cc(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def ABC057D():

    N, A, B = map(int, input().split())
    v = list(map(int, input().split()))
    v = sorted(v)[::-1]

    anslist = []
    for i in range(A, B + 1):

        anslist.append([sum(v[0:i]) / i, i, v[i - 1]])
    anslist.sort()
    anslist = anslist[::-1]
    ans = anslist[0][0]
    key = anslist[0][2]
    long = anslist[0][1]
    print(ans)
    for i in range(1, len(anslist)):
        if anslist[i][0] == anslist[i - 1][0]:
            ans = anslist[i][0]
            key = anslist[i][2]
            long = anslist[i][1]
        else:
            break
    #print(anslist)
    #print(ans, key, long)
    cnt = 0
    for i in v:
        if i == key:
            cnt += 1

    c = 0
    for i in v[:long]:
        #print(i)
        if i == key:
            c += 1
    #print(c, long)
    ans = 0
    if c == long:
        for i in range(A,  min(B + 1, cnt + 1)):
            ans += cc(cnt, i)
    else:
        ans = cc(cnt, c)
    #print(anslist)
    #print(cnt, c, long)
    print(ans)
ABC057D()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string>
using namespace std;
typedef long long int ll;

int main(){
	int n,m; cin >> n >>m;
	int ans=0;
	for(int i=0;i<n;i++){
		int cnt=0;
		for(int j=0;j<m;j++){
			int a; cin >> a;
			if(a)cnt++;
		}
		ans=max(ans,cnt);
	}
	cout << ans << endl;
}



Measured memory_bytes: 3084
# D
import numpy as np
N = int(input())
A = np.array([list(map(int, input().split())) for _ in range(N)], dtype=int)

res = A.sum() // 2

A_ = A.copy()

# forbid self loop
for i in range(N):
    A_[i, i] = 1000000001


A3 = np.zeros((N, N, N), dtype=int)
for i in range(N):
    A3[i, :, :] += A_
for j in range(N):
    A3[:, :, j] += A_
    
A3_min = A3.min(axis=1)

for i in range(N-1):
    for j in range(i+1, N):
        if A3_min[i, j] < A[i, j]:
            res = -1
        elif A3_min[i, j] == A[i, j]:
            res -= A[i, j]
        
        
if res < 0:
    print(-1)
else:
    print(res)

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

int main(){
    string s;
    cin >> s;
    cout << ((s[0]=='9' || s[1]=='9') ? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    A1 = [int(x) for x in input().split()]
    A2 = [int(x) for x in input().split()]
    A3 = [int(x) for x in input().split()]
    N = int(input())
    A = set([int(input()) for _ in range(N)])
    f = False
    if A1[0] in A and A1[1] in A and A1[2] in A:
        print("Yes")
        return
    if A2[0] in A and A2[1] in A and A2[2] in A:
        print("Yes")
        return
    if A3[0] in A and A3[1] in A and A3[2] in A:
        print("Yes")
        return
    if A1[0] in A and A2[0] in A and A3[0] in A:
        print("Yes")
        return
    if A1[1] in A and A2[1] in A and A3[1] in A:
        print("Yes")
        return
    if A1[2] in A and A2[2] in A and A3[2] in A:
        print("Yes")
        return
    if A1[0] in A and A2[1] in A and A3[2] in A:
        print("Yes")
        return
    if A1[2] in A and A2[1] in A and A3[0] in A:
        print("Yes")
        return
    print("No")

    
    
    



if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long ll;
const ll INF = 1e18;
const int MOD = 1e9+7;
using namespace std;

int main(){
//freopen("output.txt", "w", stdout);
    int n; string s;
    cin >> n >> s;
    int cnt = 1;
    for(int i = 1; i < n; ++i){
        if(s[i] != s[i-1]){
            cnt++;
        }
    }
    cout << cnt << '\n';
}


Measured memory_bytes: 512
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static long N;
        static long M;
        static string[] A;
        static string[] B;
        static void Main(string[] args)
        {
            //N = long.Parse(Console.ReadLine());
            var NM = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            N = NM[0];
            M = NM[1];
            A = new string[N];
            B = new string[M];

            for (int i = 0; i < N; i++)
            {
                A[i] = Console.ReadLine();
            }

            for (int i = 0; i < M; i++)
            {
                B[i] = Console.ReadLine();
            }

            var ans = false;
            for (int i = 0;!ans && i < N - M+1; i++)
            {
                for (int j = 0;!ans && j < N - M+1; j++)
                {
                    ans = Match(i, j);
                }
            }

            
            Console.WriteLine(ans? "Yes":"No");
            //Console.WriteLine("Yes");
        }

        static bool Match(int i,int j)
        {
            var orii = i;
            var orij = j;

            //for (;i < orii+M; i++)
            //{

            //    for (j = orij; j < orij + M; j++)
            //    {
            //        if(A[i][j] != B[i - orii][j - orij])
            //        {
            //            return false;
            //        }
            //    }
            //}

            for (int k = 0; k < M; k++)
            {
                for (int l = 0; l < M; l++)
                {
                    if (A[orii+k][orij+l] != B[k][l])
                    {
                        return false;
                    }
                }
            }
            return true;
        }
       
    }


}


Measured memory_bytes: 27996
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e3+7, M = 1e4+7;
ll f[N][M];
struct node
{
	int w;
	int s;
	int v;
	int id;
}q[N];
bool cmp1(node a, node b)
{
	return a.s > b.s;
}
bool cmp2(node a, node b)
{
	return a.w < b.w;
}
bool cmp3(node a, node b)
{
	if(a.s*a.w==b.s*b.w)
	{
		return a.w > b.w;
	}
	return a.s*a.w < b.s*b.w;
}
bool cmp4(node a, node b)
{
	if(a.s==b.s)
	{
		return a.w < b.w;
	}
	return a.s > b.s;
}
bool cmp5(node a, node b)
{
	return a.w+a.s > b.w+b.s;
}
ll calc(int n, int m)
{
	ll ans = 0;
	memset(f[0], 0xcf, sizeof(f[0]));
    for(int i = 1; i <= n; i++)
    {
    	//printf("%d ", q[i].id);
    	for(int j = 0; j <= m; j++)
    	{
    		f[i][j] = f[i-1][j];
    	}
    	for(int j = q[i].w; j <= m; j++)
    	{
    		int p = min(j-q[i].w, q[i].s);
    		f[i][p] = max(f[i][p], f[i-1][j]+q[i].v);
    	}
    	f[i][q[i].s] = max(f[i][q[i].s], (ll)q[i].v);
    }
    //puts("");
    for(int i = 0; i <= m; i++)
    {
    	ans = max(ans, f[n][i]);
    }
    return ans;
}
int main()
{
    ll ans = 0;
    int n, m = 0;
    srand(time(0));
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
    {
    	q[i].id = i;
    	scanf("%d%d%d", &q[i].w, &q[i].s, &q[i].v);
    	m = max(m, q[i].s);
    }
    sort(q+1, q+1+n, cmp1);
    ans = max(ans, calc(n, m));
    sort(q+1, q+1+n, cmp2);
    ans = max(ans, calc(n, m));
    sort(q+1, q+1+n, cmp3);
    ans = max(ans, calc(n, m));
    sort(q+1, q+1+n, cmp4);
    ans = max(ans, calc(n, m));
    sort(q+1, q+1+n, cmp5);
    ans = max(ans, calc(n, m));
    for(int i = 1; i <= 5; i++)
    {
    	random_shuffle(q+1, q+1+n);
    	ans = max(ans, calc(n, m));
    }
    printf("%lld\n", ans);
    return 0;
}

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

const int M = 2019;
int64_t ans;

int main() {
    string S; cin >> S;
    map<int, int> mp;
    mp[0] = 1;
    int N = S.size(), ten = 1, total = 0;
    for (int i = 0; i < N; i++) {
        total = ((S[N-i-1] - '0') * ten + total) % M;
        ans += mp[total]++;
        ten = ten * 10 % M;
    }
    cout << ans << endl;
}

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

using namespace std;
bool ch[(int)1e5 + 10];
int pen[(int)1e5 + 10];
int main(){
    int n,m,x,ac=0,wa=0;
    scanf("%d%d",&n,&m);
    char c[10];
    for(int i = 0 ;i< m;i++){
        scanf("%d%s",&x,c);
        if(ch[x]) continue;
        if(c[0] == 'A') {
            ch[x] = true;
            ac++;
        }
        else pen[x]++;
    }
    for(int i =1;i<=n;i++) if(ch[i]) wa += pen[i];
    printf("%d %d",ac,wa);

}


Measured memory_bytes: 768
import sys

inf = float('inf')

n, *b = map(int, sys.stdin.read().split())

def main():
    a = [inf] * n
    for i in range(n-1):
        a[i] = min(a[i], b[i])
        a[i+1] = min(a[i+1], b[i])
    return sum(a)

if __name__ == '__main__':
    ans = main()
    print(ans)

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

int main() {
  int N;
  cin >>N;
  
  if(N%2 == 0)
    cout << 0.5 << endl;
  
  double n = N;
  
  if(N%2 == 1)
    cout << (N/2 + 1)/n << endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<functional>

using namespace std;



int main() {
	int n, k;
	vector<int> a(200001);
	
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		int temp;
		cin >> temp;
		a[temp]++;
	}

	sort(a.begin(),a.end(),greater<int>());

	int ans=0;

	for (int i = k; i < 2000001; i++)
	{
		if (a[i] == 0) break;
		ans += a[i];
	}

	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>
 
int main(){
    int dice[6],q,i;
    char c;
     
    for(i=0;i<6;i++){
        scanf("%d",&dice[i]);
    }
     
    scanf("%d",&q);
    for(i=0;i<q;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        if((x==dice[5] && y==dice[4])||(x==dice[4] && y==dice[0])||(x==dice[0] && y==dice[1])||(x==dice[1] && y==dice[5])){
            printf("%d\n",dice[2]);
        }else if((x==dice[0] && y==dice[2])||(x==dice[2] && y==dice[5])||(x==dice[5] && y==dice[3])||(x==dice[3] && y==dice[0])){
            printf("%d\n",dice[4]);
        }else if((x==dice[5] && y==dice[1])||(x==dice[1] && y==dice[0])||(x==dice[0] && y==dice[4])||(x==dice[4] && y==dice[5])){
            printf("%d\n",dice[3]);
        }else if((x==dice[0] && y==dice[3])||(x==dice[3] && y==dice[5])||(x==dice[5] && y==dice[2])||(x==dice[2] && y==dice[0])){
            printf("%d\n",dice[1]);
        }else if((x==dice[2] && y==dice[1])||(x==dice[1] && y==dice[3])||(x==dice[3] && y==dice[4])||(x==dice[4] && y==dice[2])){
            printf("%d\n",dice[5]);
        }else{
            printf("%d\n",dice[0]);
        }
    }
    return 0;
}


Measured memory_bytes: 2112
package main

import "fmt"

func main() {
	var a, b, c string
	fmt.Scan(&a, &b, &c)

	if a[len(a)-1] == b[0] && b[len(b)-1] == c[0] {
		fmt.Print("YES")
	} else {
		fmt.Print("NO")
	}
}


Measured memory_bytes: 512
X=int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
L=make_divisors(X)
Y=False
ans=[]
for x in L:
    a=0
    while True:
        tmp=a**5-(a-x)**5
        if tmp==X:
            Y=True
            ans=[a,a-x]
            break
        if tmp>X and a>int(X**0.2)+1:
            break
        a+=1
        
    if Y:
        break
print(ans[0],ans[1])

Measured memory_bytes: 9480
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
//ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
long long int intpow(long long int x,long long int n){
    long long int ans=1;
    for(int i=0;i<n;i++){
        ans*=x;
    }
    return ans;
}

int main(){
    int a,b,c,k;
    in(a,b,c,k);
    ll d=0;
    int ans=0;
    rep(i,k+1){
        rep(j,k+1){
            rep(z,k+1){
                if((i+j+z<=k)&&(a*intpow(2,i)<b*intpow(2,j))&&(b*intpow(2,j)<c*intpow(2,z))){
                    ans=1;
                    goto skip;
                }
            }
        }
    }
    skip:
    yn(ans);
}

Measured memory_bytes: 3764
#include <stdio.h>

int main(void)
{
    int r,g,b,sum,ans;
    
    scanf("%d %d %d",&r,&g,&b);
    
    sum=r*100+g*10+b;
    
    ans=sum%4;
    
    if(ans==0)printf("YES\n");
    else printf("NO\n");
    
    return 0;
}

Measured memory_bytes: 128
def main():
  N = int(input())
  A = list(map(int,input().split()))
  A = [[a,i] for a,i in zip(A,range(1,N+1))]
  A = sorted(A,reverse=True)
  INF = float('inf')
  dp = [[-INF] * (N+1) for _ in range(N+1)]
  dp[0][0] = 0
  ans = 0
  for x_y in range(1,N+1):
    a = A[x_y-1]
    for x in range(x_y+1):
      y = x_y-x
      if x==0:
        dp[x][y] = dp[x][y-1] + a[0]*(N-y+1-a[1])
      elif y==0:
        dp[x][y] = dp[x-1][y] + a[0]*(a[1]-x)
      else:
        dp[x][y] = max(dp[x-1][y]+a[0]*(a[1]-x),dp[x][y-1] + a[0]*(N-y+1-a[1]))

      ans = max(ans,dp[x][y])
  print(ans)
  
main()

Measured memory_bytes: 124568
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    private static int MIN = -100;
    private static int MAX = 100;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try {
            int[] a_b_c = Stream.of(sc.nextLine().split(" "))
                    .mapToInt(Integer::parseInt)
                    .toArray();
            if (a_b_c.length != 3) {
                System.out.println("Condition is invalid");
            }
            int a = a_b_c[0];
            int b = a_b_c[1];
            int c = a_b_c[2];
            if (a > MAX || a < MIN
            || b > MAX || b < MIN
            || c > MAX || c < MIN) {
                System.out.println("Condition is invalid");
            }
            if (a < b && b < c) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } catch (NoSuchElementException
                | NumberFormatException e) {
            System.out.println(e);
        }
    }
}



Measured memory_bytes: 31804
n = int(input())
arr = list(map(int, input().split()))
cnt = 0
for i in range(1, n - 1):
    if (arr[i - 1] < arr[i] < arr[i + 1]) or (arr[i - 1] > arr[i] > arr[i + 1]): 
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  ll h, w, K;
  cin >> h >> w >> K;
  vector<vi> v(h,vi(w));
  rep(i,h)rep(j,w) {
    char c;
    cin >> c;
    if(c=='.') v[i][j] = 0;
    else v[i][j] = 1;
  }
  ll ans = 0;
  rep(i,(1<<h))rep(j,(1<<w)) {
    vector<vi> vec = v;
    rep(k,h) {
      if(i>>k & 1) {
        rep(l,w) vec[k][l] = 2;
      }
    }
    rep(k,w) {
      if(j>>k & 1) {
        rep(l,h) vec[l][k] = 2;
      }
    }
    ll cnt = 0LL;
    rep(k,h)rep(l,w) if(vec[k][l]==1) cnt++;
    if(cnt==K) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#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>
using namespace std;
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'));
}

int main(){
	LL n,m,t;
	int i,j,k;
	LL a,b,c,d;
	vector<P> vp;
	vector<LL> v[2];
	cin>>n>>m>>t;
	m*=2,t*=2;
	vector<LL> v1(n),v2(n),vs(n);
	for(i=0;i<n;i++){
		cin>>a>>b;
		b--;
		a*=2;
		vp.push_back(make_pair(a,b));
		v[b].push_back(a);
	}
	int cnt=t/m*2;
	int pos=0;
	t%=m;
	if(t*2>=m){
		cnt++;
		t-=m/2;
		pos=m/2;
	}
	for(i=0;i<n;i++){
		a=i;
		if(vp[i].second==0){
			a+=(LL)v[1].size()*cnt;
			a%=n;
		}else{
			a-=(LL)v[0].size()*cnt;
			if(a<0)a+=((-a)/n+1)*n;
			a%=n;
		}
		v1[i]=a;
	}
	//array_show(v1);
	for(i=0;i<n;i++){
		if(vp[i].second==0){
			a=vp[i].first+t*2;
			a%=m;
			auto itr=lower_bound(v[1].begin(),v[1].end(),a);
			b=distance(v[1].begin(),itr);
			itr=lower_bound(v[1].begin(),v[1].end(),vp[i].first);
			c=distance(v[1].begin(),itr);
			if(a<vp[i].first)b+=v[1].size();
			d=i+b-c;
		}else{
			a=vp[i].first-t*2;
			if(a<0)a+=((-a)/m+1)*m;
			a%=m;
			auto itr=upper_bound(v[0].begin(),v[0].end(),a);
			b=distance(v[0].begin(),itr);
			itr=lower_bound(v[0].begin(),v[0].end(),vp[i].first);
			c=distance(v[0].begin(),itr);
			if(a>vp[i].first)c+=v[0].size();
			d=i+b-c;
			if(d<0)d+=n;
		}
		d%=n;
		v2[i]=v1[d];
		
		if(vp[i].second==0){
			a=pos+vp[i].first+t;
		}else{
			a=pos+vp[i].first-t;
			if(a<0)a+=m;
		}
		a%=m;
		vs[v1[d]]=a;
	}
	//array_show(v2);
	for(i=0;i<n;i++){
		cout<<vs[i]/2<<endl;
	}
}

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

int main() {
  string s;
  cin >> s;
  int ret = 0;
  for (int i = 0, j = s.size() - 1; i < j; ++i, --j) {
    if (s[i] != s[j])
      ++ret;
  }
  cout << ret << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long n;
  cin >> n;
  long a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  sort(a,a+n);
  reverse(a,a+n);
  long ans = a[0];
  for(int i=1;i<n/2;i++){
      ans += 2*a[i];
  }
  if(n%2) ans += a[n/2];
  cout << ans << endl;
}

Measured memory_bytes: 5160
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  string S, T; cin>>S>>T;
  cout << T << S << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define vl vector<ll>
#define pl pair<ll,ll>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,b) for(ll i=0;i<b;i++)
#define RFOR(i,a,b) for(ll i=b-1;i>=a;i--)
#define rsort(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(),(v).end()
using namespace std;

ll mod=1000000007;
signed main() {
    ll n;
    while(cin>>n,n){
        string s[n];
        rep(i,n)cin>>s[i];
        RFOR(i,1,n)
            rep(j,s[i].size()-1)
        if(s[i][j]=='.'&&s[i][j+1]<='z'&&s[i][j+1]>='a'){
            s[i][j]='+';
            ll k=i;
            while(s[k-1][j]=='.') if(s[k--][j]!='+')s[k+1][j]='|';
            s[k][j]='+';
        }
        RFOR(i,1,n)
            rep(j,s[i].size()-1)
        if(s[i][j]=='|'&&s[i][j+1]<='z'&&s[i][j+1]>='a') s[i][j]='+';
        RFOR(i,1,n)
            rep(j,s[i].size()-1)
        if(s[i][j]=='.') s[i][j]=' ';
        rep(i,n)cout<<s[i]<<endl;
    }
}


Measured memory_bytes: 3804
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    std::string as, bs;
    for (int i = 0; i < b; i++)
    {
        as.append(to_string(a));
    }
    for (int i = 0; i < a; i++)
    {
        bs.append(to_string(b));
    }
    if (as > bs)
    {
        cout << bs << endl;
    }
    else
    {
        cout << as << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        if(n%2==0) out.println(n);
        else out.println(2*n);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 21076
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int sum =0;
		int gcdWork=0;
		int gcd =0;
		
		for(int i=1;i<=k;i++) {
			for(int j=1;j<=k;j++) {
				for(int m=1;m<=k;m++) {
					Gcd g1 = new Gcd(i,j);
					gcdWork=g1.gcdCalc();
					Gcd g2 = new Gcd(gcdWork,m);
					gcd=g2.gcdCalc();
					sum+=gcd;
				}
			}
		}
		System.out.println(sum);
	}

}


class Gcd {
	int targetA;
	int targetB;
	static int[] targetArray;
	
	public Gcd(int targetNumberA ,int targetNumberB) {
		this.targetA=targetNumberA;
		this.targetB=targetNumberB;
		this.targetArray = new int[2];
		targetArray[0] =targetA;
		targetArray[1] =targetB;
	}
	
	////最大公約数ユークリッドの互除法(int[A,B] )(return int)
	public static int gcdCalc(){
         int x;
         int y;
        if (targetArray[0] > targetArray[1]) {
            x = targetArray[0];
            y = targetArray[1];
        } else {
            x = targetArray[1];
            y = targetArray[0];
        }
        // ここからがユークリッドの互除法を用いた最大公約数を
        // 求める為の式
        int tmp;
        while ((tmp = x % y) != 0) {
            x = y;
            y = tmp;
        }
        return(y);
    }
	
//////最小公倍数(int[A,B] int )(return int)
	////gcdをgcdCalcで求めて代入
	public static int lcmCalc(int gcd) {
        int x;
        int y;
       if (targetArray[0] > targetArray[1]) {
           x = targetArray[0];
           y = targetArray[1];
       } else {
           x = targetArray[1];
           y = targetArray[0];
       }
       int lcm = (x*y)/gcd;
       return(lcm);
	}
	

}




Measured memory_bytes: 53104