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


int main(void){
    int i,N,sum=0,min=101;
    int score[100];
    
    scanf("%d",&N);
    
    for( i = 0; i < N; i++ ){
        scanf("%d",&score[i]);
        sum += score[i];
        if( score[i] < min && score[i] % 10 != 0){
            min = score[i];
        }
    }
    
    if( sum % 10 != 0 ){
        printf("%d",sum);
    }
    if( min == 101 ){
        printf("0");
    }
    else if( sum % 10 == 0 ){
        printf("%d\n",sum-min);
    }
    
    
    
    
    
    
     return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;





// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) 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;
    }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        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];
    }
};


vector<int> x(101010);
combination comb = combination(101010);
vector<mint> fact(101010);
mint solve(int j,int goal){
    mint d = goal - x[j];
    if (j == 0){
        rn d;
    }
    mint ans;
    mint s = solve(j-1,x[j]);
    rep(i,j+1){
        ans += ( fact[j]*d*(i+1))*comb(j,i);
    }
    rn ans+s*(j+1);
}
int main(){
    
    char c;
    cin >> c;
    cout << (char) ((int) (c - 'a') + 1 + (int) 'a') ;
}


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

using namespace std;

int n, mx;
map<string, int> m;
string s;

int main(){
    cin >> n;
    n++;
    for(int i = 0; i < n; i++){
        getline(cin, s);
        m[s]++;
    }
    for(map<string, int>::iterator i = m.begin(); i != m.end(); i++)if(mx < (*i).second)mx = (*i).second;
    for(map<string, int>::iterator i = m.begin(); i != m.end(); i++)if(mx == (*i).second)cout << (*i).first << '\n';
    return 0;
}


Measured memory_bytes: 25216
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll ans = 1;
    REP(i, N){
        ans *= i;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
ans=0
X,N=map(int,input().split())
p=list(map(int,input().split()))
for i in range(102):
    if i in p:
        p.remove(i)
    else:
        p.append(i)
for i in range(102-N):
    if abs(X-p[i])<abs(X-ans):
        ans=p[i]
print(ans)

Measured memory_bytes: 61940
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int A,B,C,D,E,F;
    cin>>A>>B>>C>>D>>E>>F;

    A*=100; B*=100;

    double Max=-1;
    int ans1,ans2;
    for(int a=0;A*a<=F;a++){
        for(int b=0;A*a+B*b<=F;b++){
            for(int c=0;A*a+B*b+C*c<=F;c++){
                for(int d=0;A*a+B*b+C*c+D*d<=F;d++){
                    int water=A*a+B*b;
                    int salt=C*c+D*d;
                    if(water==0) continue;
                    if(salt>water/100*E) continue;

                    double p=(double)salt/(water+salt)*100;
                    if(p>Max){
                        Max=p;
                        ans1=water+salt;
                        ans2=salt;
                    }
                }
            }
        }
    }
    cout<<ans1<<' '<<ans2<<endl;
}


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

int main() {
    int n;
    while(cin >> n, n) {
        int w, h;
        cin >> w >> h;
        vector<vector<int>> field(w+1, vector<int>(h+1)); // field[w][h];
        for(int i=0; i<n; ++i) {
            int x, y;
            cin >> x >> y;
            field[x][y] = 1;
        }
        int s, t;
        cin >> s >> t;
        int ret = 0;
        for(int x=0; x<w+1; ++x) {
            for(int y=0; y<h+1; ++y) {
                int tmp = 0;
                if(x+s-1 > w || y+t-1 > h) continue;

                for(int i=0; i<s; ++i) {
                    for(int j=0; j<t; ++j) {
                        if(field[x+i][y+j] == 1) {
                            tmp++;
                        }
                    }
                }
                ret = max(ret, tmp);
            }
        }
        cout << ret << endl;
    }
}


Measured memory_bytes: 3064
L,R = [int(zz) for zz in input().split()]

Lm = L%2019
Rm = R%2019

if Lm*Rm == 0 or R-L > 2017 or Rm <= Lm:
    print(0)
    exit()

ans = 2019
for i in range(Lm,Rm+1):
    for j in range(i+1,Rm+1):
        ans = min(ans,i*j%2019)
print(ans)


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

using namespace std;

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

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


int main() {
    int n,m;

    map<string,int>cnt;

    cin>>n;

    rep(i,n){
        string s;
        cin>>s;

        cnt[s]++;
    }

    cin>>m;

    rep(i,m){
        string t;
        cin>>t;

        cnt[t]--;
    }

    int ans=0;

    for(auto x:cnt){
        ans=max(ans,x.second);
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int h, w;
    cin >> h >> w;
    vector<string> a(h), b(h);
    REP(i,h) cin >> a[i];
    REP(i,h) cin >> b[i];

    int ans = 0;
    REP(i,h) REP(j,w) if (a[i][j] != b[i][j]) ans++;
    cout << ans << endl;

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	string s;
	cin >> s;
	vector<ll>arr(s.size() + 1);
	rep(i, s.size() + 1) {
		if (i == 0)arr[i] = (s[i] == '<') ? 0LL : 1LL;
		else if (i == s.size())arr[i] = (s[i-1] == '>') ? 0 : arr[i - 1] +1LL;
		else {
			if (s[i - 1] == '>' && s[i] == '<')arr[i] = 0;
			else if (s[i - 1] == '<')arr[i] = arr[i - 1] + 1LL;
			else arr[i] = 0LL;
		}
	}

	for (ll i = s.size()-1; i >=0;i--) {
		if (s[i] == '>')arr[i] = max(arr[i + 1] + 1LL,arr[i]);
	}
	if (s[0] == '>')arr[0] = arr[1] + 1LL;

	ll sum = accumulate(all(arr),0LL);
	cout << sum << endl;
}


Measured memory_bytes: 7716
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
using namespace std;

using ll = long long;
constexpr auto PrimeBigNum10_9_7 = 1000000007;

// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

	for (int i = 2; i * i <= value; ++i) {
		if ((value % i) == 0) {
			return true;
		}
	}
	return false;
}

// 桁数判定
template <typename T>
T GetFigureLength(T value) {
	T figure = 1;
	while (value >= 10) {
		value /= 10;
		++figure;
	}
	return figure;
}

// 素因数分解結果
template <typename T>
map<T, T> GetPrimeFactorize(T value) {

	map<T, T> res;

	for (T i = 2; i * i <= value; ++i) {
		if ((value%i) != 0)	continue;

		T count = 0;
		while ((value % i) == 0) {
			value /= i;
			++count;
		}

		res[i] = count;
	}

	if (value != 1) {
		res[value] = 1;
	}
	return res;
}
int main(void) {


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

	t.pop_back();


	auto output = (s == t)?"Yes":"No";
	cout << output;

	return 0;
}


Measured memory_bytes: 3624
//By Tushar Gautam
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln "\n"
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long int  ll;
typedef long double  ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 1e5+5, MOD = 1e9+7;
int t,n,m,k,x,y;
ld dp[3001][6005]={0}; // 3000+x, 3000-x
int main(){
	fastio;
	cin>>n;
	ld p;
	dp[0][3000]=1;
	forn(i,n){
		cin>>p;
		forsn(j,1,5999){
			dp[i+1][j+1]+=dp[i][j]*p;
			dp[i+1][j-1]+=dp[i][j]*(1-p);
 		}
	}
	ld ans=0;
	forsn(i,3001,6000){
		ans+=dp[n][i];
	}
	cout<<setprecision(10)<<fixed;
	cout<<ans<<ln;
	return 0;
}

Measured memory_bytes: 281728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
#define all(v) v.begin(), v.end()
#define rep(i, from, to) for (ll i = from; i < ll(to); ++i)

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

    ll n, k;
    cin >> n >> k;

    ll f = 2*k;
    vi vertcount(2*k);
    vi horcount(2*k);
    ll basecount = 0;
    vi cv(2*k);
    vi ch(2*k);
    vector<vii> cch(2*k);
    vector<pair<ii, ll>> xyc;
    rep(i,0,n) {
        ll x, y;
        char c;
        cin >> x >> y >> c;
        ll cd = 0;
        if (c == 'W') cd = 1;
        xyc.push_back(make_pair(make_pair(x,y),cd));
        vertcount[x%f]++;
        horcount[y%f]++;
        cch[y%f].push_back(make_pair(x%f,cd));
        ll sx = x / k;
        ll sy = y / k;
        if ((sx + sy) % 2 == cd) {
            basecount++;
            cv[x%f]++;
            ch[y%f]++;
        }
            
    }


    ll best = basecount;

    rep(i,0,f) {
        ll curcount = basecount;
        rep(j,0,f) {
            best = max(best, curcount);
            ll md = (k+j)%f;
            curcount -= cv[md];
            cv[md] = vertcount[md] - cv[md];
            curcount += cv[md];
            md = j;
            curcount -= cv[md];
            cv[md] = vertcount[md] - cv[md];
            curcount += cv[md];
        }
        if (i == 1) {
            //cout << "bfc: " << curcount << endl;
        }
        ll md = (k+i)%f;
        curcount -= ch[md];
        ch[md] = horcount[md] - ch[md];
        curcount += ch[md];
        for (auto gg : cch[md]) {
            //cout << "hi" << endl;
            ll sx = gg.first / k;
            if (sx % 2 == gg.second) {
                cv[gg.first] += 1;
            } else {
                cv[gg.first] -= 1;
            }
        }
        md = i;
        curcount -= ch[md];
        ch[md] = horcount[md] - ch[md];
        curcount += ch[md];
        for (auto gg : cch[md]) {
            //cout << "hix" << endl;
            ll sx = gg.first / k;
            if (sx % 2 == gg.second) {
                cv[gg.first] -= 1;
            } else {
                cv[gg.first] += 1;
            }
        }
        if (i <= 1) {
            //cout << "curcount:" << curcount << endl;
            //cout << "hor: " << cv[0] << endl;
            //cout << "v: " << vertcount[0] << endl;
        }
        basecount = curcount;
        /*basecount = 0;
        rep(j,0,f) {
            cv[j] = 0;
            ch[j] = 0;
        }
        rep(j,0,n) {
            ll sx = xyc[j].first.first / k;
            ll sy = (xyc[j].first.second + i) / k;
            if ((sx+sy)%2 == xyc[j].second) {
                basecount++;
                cv[xyc[j].first.first%f]++;
            }
        }*/
    }

    cout << best << endl;




    return 0;
}


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

using namespace std;

int main(void) {
    string S;
    cin >> S;
    for(int i=0; i<100; i++) {
        if(i%2 == 0 && S[i] == 'L') {
            cout << "No" << endl;
            return 0;
        }
        if(i%2 == 1 && S[i] == 'R') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

class Node:
    def __init__(self, next_node, prev_node, val):
        self.next = next_node
        self.prev = prev_node
        self.val = val

    def __repr__(self):
        return f'{self.val}'


class DoubleLinkedList:
    def __init__(self):
        self.head = Node(None, None, None)
        self.tail = self.head

    def append(self, val):
        node = Node(None, self.tail, val)
        self.tail.next = node
        self.tail = node

    def dump(self):
        cur = self.head.next
        out = ''
        while cur is not None:
            out += f'{cur.val} '
            cur = cur.next
        print(out[:-1])

    def splice(self, other):
        self.tail.next = other.head.next
        self.tail = other.tail

    def clear(self):
        self.__init__()


n, q = map(int, input().split())

lists = {str(i): DoubleLinkedList() for i in range(n)}

lines = sys.stdin.readlines()
for i in range(q):
    query, *arg = lines[i].split()
    #print(i, query, arg)
    if query == '0':    # insert t x
        lists[arg[0]].append(arg[1])

    elif query == '1':  # dump t
        lists[arg[0]].dump()

    elif query == '2':  # splice s t
        lists[arg[1]].splice(lists[arg[0]])
        lists[arg[0]].clear()

    else:
        raise AssertionError



Measured memory_bytes: 162844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;



int main(void) {
  int x,y,z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
}






Measured memory_bytes: 256
function Main(input) {

	input = input.split("\n");
        let payPrice = parseInt(input[0], 10); //数値に変換
       while (payPrice > 1000){ 
             payPrice = payPrice - 1000;
       }

       let change = 1000 - payPrice;

	//結果出力
	console.log(change);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29560
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    double a,b,c,d=0,e=0;
    string s,t,u;
    cin>>s>>t>>a>>b>>u;
    if(s==u){a--;}
    if(t==u){b--;}
    cout<<a<<' '<<b;
    return 0;
    }


Measured memory_bytes: 3820
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();

        String[] texts = new String[n];
        for (int i = 0; i < n; i++) {
            texts[i] = std.next();
        }

        String[] sortedTexts = new String[n];

        for (int i = 0; i < n; i++) {
            String text = texts[i];
            List<String> textList = Arrays.asList(text.split(""));
            Collections.sort(textList);
            String sorted = String.join("",textList);
            sortedTexts[i] = sorted;
        }

        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            String s = sortedTexts[i];
            map.put(s, map.getOrDefault(s, 0) + 1);
        }

        Iterator<Map.Entry<String, Integer>> it = map.entrySet().iterator();
        long ans = 0;
        while (it.hasNext()) {
            long count = it.next().getValue();
            ans += count * (count - 1) / 2;
        }

        System.out.println(ans);
    }
}


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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
const ll zero=0;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  for(i=0;i<n;i++)cin>>a[i];
  res=1;
  buf=0;
  for(i=1;i<n;i++){
    if(buf==1&&a[i-1]>a[i]){
      buf=0;
      res++;
    }
    else if(buf==-1&&a[i-1]<a[i]){
      buf=0;
      res++;
    }
    else if(buf==0){
      if(a[i-1]<a[i])buf=1;
      else if(a[i-1]>a[i])buf=-1;
    }
  }
  cout<<res<<endl;
  return 0;
}

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

int main(){
	double x, y;
  	cin>>x>>y;
  	
  	double a, b;
  	a=(4*x-y)/2; b=(y-2*x)/2;
  
  	if((a-(int)a)==0 && (b-(int)b)==0 && (a!=0 || b!=0) && (a>=0 && b>=0)){
    	cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

int main() {
  int n,m; cin >> n >> m;
  vector<ll> x(n),y(n),z(n);
  rep(i,n) cin >> x[i] >> y[i] >> z[i];

  ll ans = -(1LL << 60);
  rep(x_plus, 2) rep(y_plus, 2) rep(z_plus, 2) {
    vector<ll> val(n);
    rep(i,n) {
      val[i] += x_plus ? x[i] : -x[i];
      val[i] += y_plus ? y[i] : -y[i];
      val[i] += z_plus ? z[i] : -z[i];
    }
    sort(ALL(val), greater<ll>());
    ll sum = 0;
    rep(i,m) sum+= val[i];
    umax(ans, sum);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include<stdio.h>

int n;
int s[100000];

int Binary(int a){

int L=0;
int C=0;
int R=n;

while(R > L){

C=(L+R)/2;
if(a==s[C]){
return 1;
}
else if(a<s[C])
R=C;
else if(a>s[C])
L=C+1;

}

return 0;

}

int main(void){

int a, q, i, j, ans=0;

scanf("%d", &n);

for(i=0;i<n; i++){
scanf("%d",&s[i]);
}

scanf("%d",&q);

for(i=0;i<q;i++){

scanf("%d",&a);

if(Binary(a)==1)
ans++;

}

printf("%d\n",ans);

return 0;

}

Measured memory_bytes: 2104
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;





int main() {
	const long long int mod = 1000000007,INF=100000000000000;
	map<long long int, long long int>mp;
	cout << fixed << setprecision(10);
    typedef pair<long long int,long long int> P;
    priority_queue<P,vector<P>,greater<P>> que;
    P tmp;
    long long int left=0,right,res=0;
    string str;
    cin>>str;
    right=str.length()-1;
    while(right-left>0){
        if(str[left]==str[right]){
            right--;
            left++;
        }else if(str[left]=='x'){
            res++;
            left++;
        }else if(str[right]=='x'){
            res++;
            right--;
        }else{
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<res<<endl;
} 


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

int main(){
	char buf[30];
	char *p;
	int n, m;
	int sum_a = 0;

	p = buf;
	scanf("%d %d\n", &n, &m);
	while (0<m){
		int day = 0;
		char c = getchar();
		while((c!=' ') && (c!=10)){
			day *= 10;
			day += c - '0';
			c = getchar();
		}
		sum_a += day;
		m--;
		if (n<sum_a){
			printf("%d", -1);
			return (0);
		}
	}
	printf("%d", n - sum_a);
	return (0);
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c,d;cin >> a >> b >> c >> d;
	cout << min(a,b)+min(c,d) << endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val A = sc.next().toInt()
        val B = sc.next().toInt()
        pw.println((A + B) % 24)
    }
}


Measured memory_bytes: 31392
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){
 int a,b;
cin >> a >> b;
if(a==1) a+=13;
if(b==1) b+=13;
if(a>b)cout<<"Alice"<< endl;
else if(a<b)cout<<"Bob"<< endl;
else cout<<"Draw"<< endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define nmMAX 100000
int N[nmMAX][100],M[nmMAX],g[nmMAX],id = 1;

/* inputデータ同士につながりがあるか検索 */
void dfs (int s) {
    g[s]=id;
    
    for (int i = 0; i < M[s]; i++) {
        if (g[N[s][i]] == 0)
        dfs(N[s][i]);
    }
}
  
int main() {
    int i, j, d1, d2, n, m, q;
    scanf("%d%d", &n, &m);
    
    /* データ読み取り */
    for (i = 0; i < m; i++)
    {
        scanf("%d%d", &d1, &d2);
        N[d1][M[d1]++] = d2;
        N[d2][M[d2]++] = d1;
    }
    for (i = 0; i < n; i++) {
        if (g[i] == 0) {
            dfs(i);
            id++;
        }
    }
    scanf("%d",&q);
    
    /* 再起関数にてデータの検索 */
    for (i = 0; i < q; i++) {
        scanf("%d%d", &d1, &d2);
        if (g[d1] == g[d2])
        printf("yes\n");
        else printf("no\n");
    }
    
    return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N;
int main(){
    
    scanf("%lld",&N);
    ll ans=0;
    for (ll i = 1; i < N;i++)
    {
        ans += i;
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
count = 0
for i in range(n):
    a = list(map(int, input().split()))
    ans = c
    for i in range(m):
        ans += a[i]*b[i]
    if ans > 0:
        count += 1
print(count)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int p = sc.nextInt();
		int q = sc.nextInt();
		int r = sc.nextInt();

		int a = p + q;
		int b = q + r;
		int c = r + p;

		System.out.println(Math.min(a, Math.min(b, c)));
	}
}

Measured memory_bytes: 21332
#include <cstdio>
#include <vector>
#include <cstring>
using namespace std;

typedef long long ll;

const int maxn = 1e5+1;
vector<int> g[maxn];
int n;
int sg[maxn];
void dfs(int cur, int p)
{
    sg[cur] = 0;
    for (int i = 0; i < g[cur].size(); ++i)
    {
        int nxt = g[cur][i];
        if (nxt != p)
        {
            dfs(nxt, cur);
            sg[cur] ^= (1+sg[nxt]);
        }
    }
}
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n-1; ++i)
    {
        int x, y;
        scanf("%d %d", &x, &y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(1, 0);
    puts(sg[1]?"Alice":"Bob");
}

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

using namespace std;

int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  while(a>=b)k--,b*=2;
  while(b>=c)k--,c*=2;
  cout<<(k<0 ? "No" : "Yes")<<endl;
}


Measured memory_bytes: 3632
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpl vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
/*long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

lld fac[100001]; 

void solve2()
{
   lld p=1000000007;
    fac[0] = 1; 
    for (lld i=1 ; i<=100000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrmodp(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


long long int gcd(lld b,lld a)
{
    if(a<b) return gcd(a,b);
    if(a%b==0) return b;
    return gcd(a%b , b);
}

//vector< vector <lld > > v(100001);
/*
void bfs(lld x , vector<lld>& d)
{
    d[x]=0;
    q.pu(x);
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        l=v[x].size();
        for(i=0;i<l;i++)
        {
            y=v[x][i];
            if(d[y]==INF) 
            {
                d[y] = d[x]+1;
                q.pu(y);
            }       
        }
    }

}
/*

lld DFS(lld a ,lld x)
{
    visited[a] =true;
    sub_size[a]=1;
 //   if(a==x) 
   //     cont[a] =true;
    lld l= v[a].size();
    for(lld i=0;i<l;i++)
    {
        if(visited[v[a][i]] == false)
        {
            sub_size[a]+= DFS(v[a][i],b);
//            if(cont[v[a][i]] ==true ) cont[a]=true;
        }
    }
    return sub_size[a];

}




*/lld p1=1000000007,p2=998244353;
lld l,r,mid,ans;
lld n,m,i,j,k;
lld x,y,n1,a,b,n2,h,z,c;
queue<lld> q;
lld d,p=1000000000;


void solve()
{
    string s,t;
    cin>>s>>t;
    n=s.size();
    for(i=0;i<n;i++)
    {
        if(s[i]!=t[i])
        {
            cout<<"No";
            return;
        }
    }
    cout<<"Yes";
    return;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
       //cin>>t;
       //cout<<t;
 //   solve2();
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
        solve();
        cout<<"\n";
    }

    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#define min(a, b) ((a)>(b) ? (b) : (a))
int main(){
  int n, m, x;  scanf("%d %d %d", &n, &m, &x);
  int c[15];
  int a[15][15];
  for(int i=0; i<n; i++){
    scanf("%d", &c[i]);
    for(int j=0; j<m; j++)
      scanf("%d", &a[i][j]);
  }
  int i, j, bit, flag = 1;
  int ans = 1200005;
  for(bit=1; bit<(1<<n); bit++){
    int cost = 0;
    int algo[15] = {0};
    for(i=0; i<n; i++){
      if(bit & (1<<i)){
	cost += c[i];
	for(j=0; j<m; j++)
	  algo[j] += a[i][j];
      }
    }
    for(j=0; j<m; j++)
      if(algo[j] < x)
	break;
    if(j == m){
      ans = min(ans, cost);
      flag = 0;
    }
  }
  if(flag)  ans = -1;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1732
import java.util.Scanner;

public class Main {

	void run() {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int a, b, c;

		for (int i = 0; i < N; i++) {
			a = sc.nextInt();
			b = sc.nextInt();
			c = sc.nextInt();

			a = a * a;
			b = b * b;
			c = c * c;

			if (a + b == c) {
				System.out.println("YES");
			} else if (b + c == a) {
				System.out.println("YES");
			} else if (a + c == b) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}

	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

using namespace std;
using ll=long long;

void solve() {
    ll x; cin >> x;
    ll k = 63- __builtin_clzll(x);
    ll res = (1ll<<k)-1 + (1ll<<k);
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    n = int(input())
    p = list(map(int, input().split()))
    count = 0
    for i in range(0, n):
        if i + 1 != p[i]:
            count += 1
            if count > 2:
                print("NO")
                exit()
    print("YES")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 1000001;
const int MOD = 1000000007;
   
        signed main() {
         int n,k;
         cin>>n>>k;
         int p[n];
         for(int i=0;i<n;i++)cin>>p[i];
         int ans=0,mans;
         for(int i=0;i<k;i++)ans+=(p[i]+1);
         mans=ans;
         for(int i=k;i<n;i++){
             ans-=(p[i-k]+1);
             ans+=p[i]+1;
            mans=max(mans,ans);
         }
         long double aa=mans;
         cout <<  setprecision(7)<<(aa)/2.0;

        }


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

int N;

int main(){
  cin >> N;
  if(N % 2){
    cout << N * (N - 1) / 2 - N / 2 << endl;
    for(int i = 1; i < N; i++){
      for(int j = i + 1; j <= N; j++){
	if(i + j != N){
	  cout << i << ' ' << j << endl;
	}
      }
    }
  }else{
    cout << N * (N - 1) / 2 - N / 2 << endl;
    for(int i = 1; i < N; i++){
      for(int j = i + 1; j <= N; j++){
	if(i + j != N + 1){
	  cout << i << ' ' << j << endl;
	}
      }
    }
  }
}


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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
    if(a<=b&&b<=c){cout<<a<<" "<<b<<" "<<c<<endl;}
    else if(a<=c&&c<=b){cout<<a<<" "<<c<<" "<<b<<endl;}
    else if(b<=a&&a<=c){cout<<b<<" "<<a<<" "<<c<<endl;}
    else if(b<=c&&c<=a){cout<<b<<" "<<c<<" "<<a<<endl;}
    else if(c<=a&&a<=b){cout<<c<<" "<<a<<" "<<b<<endl;}
    else{cout<<c<<" "<<b<<" "<<a<<endl;}
    
    return 0;
	}


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    int ans=0;
    for(int i=0;i<N-1;i++){
        if(s[i]!=s[i+1]) ans++;
    }
    cout << ans+1 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int N;
vector<P> red;
vector<P> blue;

bool cmp(const P &p1, const P &p2){
    return p1.second > p2.second;
}

int main(void){
    
    scanf("%d", &N);
    for(int i = 0; i < N; ++i){
        int x, y; scanf("%d %d", &x, &y);
        red.push_back(make_pair(x, y));
    }
    for(int i = 0; i < N; ++i){
        int x, y; scanf("%d %d", &x, &y);
        blue.push_back(make_pair(x, y));
    }
    
    sort(red.begin(), red.end(), cmp);
    sort(blue.begin(), blue.end());
    
    bitset<101> used;
    int ans = 0;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
            if(used[j]) continue;
            if(red[i].first < blue[j].first && red[i].second < blue[j].second){
                ++ans;
                used[j] = true;
                break;
            }
        }
    }
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 256
#DP C
n=int(input())
data=[list(map(int,input().split())) for _ in range(n)]
fa=[data[0][0]]
fb=[data[0][1]]
fc=[data[0][2]]
for i in range(1,n):
    fa.append(max(fb[i-1],fc[i-1])+data[i][0])
    fb.append(max(fa[i-1],fc[i-1])+data[i][1])
    fc.append(max(fb[i-1],fa[i-1])+data[i][2])
print(max(fa[-1],fb[-1],fc[-1]))

Measured memory_bytes: 83032
INF = 1000000000000000000 # N^12 より大きい数にする

inputs = Array.new
while line = $stdin.gets
  inputs << line.chomp
end
N = inputs[0].to_i

max = Math.sqrt(N).ceil
a = 1;

min_num = INF;

while a <= max
  if N % a == 0
    tmp = a + N/a - 2;
    min_num = tmp if min_num > tmp
  end
  a = a + 1;
end

puts min_num


Measured memory_bytes: 1788
#include <stdio.h>

int main( void ) {
	int i, j, data[ 5 ], tmp;

	for ( i = 5; i--; scanf( "%d", data + i ) ) ;

	for ( i = 1; i < 5; i++ ) {
		tmp = data[ i ];

		for ( j = i; j && data[ j - 1 ] > tmp; j-- )
			data[ j ] = data[ j - 1 ];

		data[ j ] = tmp;
	}

	for ( i = 5; i--; printf( "%d%c", data[ i ], i ? ' ' : '\n' ) ) ;

	return 0;
}

Measured memory_bytes: 596
// Aizu 1156: Twirling Robot
// 2017.9.18 bal4u@uu

#include <stdio.h>
#include <string.h>

#define MAX 10000
typedef struct { int t, a, b, c; } QUE;
QUE que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
  int l, r;
  int min;

  l = LEFT(i), r = RIGHT(i);
  if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
  if (r < qsize && que[r].t < que[min].t) min = r;
  if (min != i) {
    QUE t = que[i]; que[i] = que[min]; que[min] = t;
    min_heapify(min);
  }
}

int deq(int *a, int *b, int *c)
{
  if (qsize == 0) return 0;
  *a = que[0].a, *b = que[0].b, *c = que[0].c;
  que[0] = que[--qsize];
  min_heapify(0);
  return 1;
}

void enq(int t, int a, int b, int c)
{
  int i, ii;

  i = qsize++;
  que[i].t = t, que[i].a = a, que[i].b = b, que[i].c = c;
  while (i > 0 && que[ii = PARENT(i)].t > que[i].t) {
    QUE tt = que[i]; que[i] = que[ii]; que[ii] = tt;
    i = ii;
  }
}

char map[32][32]; int h, w;
int node[32][32][4];
int cost[4];
int mv[4][2] = {{-1,0,},{0,1},{1,0},{0,-1}};

int search()
{
	int i, r, c, d, r2, c2, d2;
	int t;

	qsize = 0;
	memset(node, -1, sizeof(node)); node[0][0][1] = 0;
	enq(0, 0, 0, 1);
	while(deq(&r, &c, &d)) {
		if (r == h-1 && c == w-1) break;
		for (i = 0; i < 4; i++) {
			d2 = (d+i) % 4, r2 = r + mv[d2][0], c2 = c + mv[d2][1];
			if (r2 < 0 || r2 >= h || c2 < 0 || c2 >= w) continue;
			t = node[r][c][d] + ((map[r][c] == i) ? 0 : cost[i]);
			if (node[r2][c2][d2] < 0 || t < node[r2][c2][d2])
				node[r2][c2][d2] = t, enq(t, r2, c2, d2);
		}
	}
	return node[h-1][w-1][d]; 
}

int main()
{
	int i, r, c, a;

	while (scanf("%d%d", &w, &h) && w) {
		for (r = 0; r < h; r++) for (c = 0; c < w; c++) scanf("%d", &a), map[r][c] = a;
		for (i = 0; i < 4; i++) scanf("%d", cost+i);
		printf("%d\n", search());
	}
	return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>

int main(void){
    int a,n,i,min=1000000,max=-1000000;
    long int sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        sum+=a;
        if(min>a)
            min=a;
        if(max<a)
            max=a;
    }
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
const int maxn=510;
int ans,n,k,sum,a[maxn],b[maxn];
inline bool pd(int x)
{
	for(register int i=1;i<=n;i++)
		b[i]=a[i]%x;
	sort(b+1,b+n+1);
	int l=1,r=n,sum=0;
	while(l<r)
	{
		int _min=min(b[l],x-b[r]);
		sum+=_min;
		if(sum>k)
			return 0;
		b[l]-=_min;
		b[r]+=_min;
		b[r]%=x;
		if(!b[l])
			l++;
		if(!b[r])
			r--;
	}
	if(l==r && b[l])
		return 0;
	return 1;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(register int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	for(register int i=1;i*i<=sum;i++)
	{
		if(sum%i)
			continue;
		if(pd(sum/i))
			ans=max(ans,sum/i);
		if(pd(i))
			ans=max(ans,i);
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int TEST,CASE=1;
#define sf scanf
#define pf printf
#define pb push_back
#define nl cout<<endl
#define all(x) x.begin(),x.end()
#define clr(a,b) memset(a,b,sizeof(a))
typedef long long int ll;
typedef long double ld;
ll n,m,a,b,c,k,x,y,z,ans=0,total=0;
string s;
int main(void){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<fixed<<setprecision(10);
#ifdef FILE_INPUT
  freopen("input.txt","r",stdin);
#endif /// FILE_INPUT
  cin>>n;
  if(n%2==0){
    cout<<n<<endl;
  }else cout<<n*2<<endl;
#ifdef FILE_INPUT
#endif /// FILE_INPUT
    return 0;
}


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

int main(){
	int H, W;
	cin >> H >> W;
	char S[H][W];
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			cin >> S[i][j];
		}
	}

	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			int c=0;

			if(S[i][j]=='#'){
				cout << '#';
			} else if(S[i][j]=='.'){
				if(0<i&&0<j&&S[i-1][j-1]=='#') c++;
				if(0<i&&S[i-1][ j ]=='#') c++;
				if(0<i&&j<W-1&&S[i-1][j+1]=='#') c++;
				if(0<j&&S[ i ][j-1]=='#') c++;
				if(j<W-1&&S[ i ][j+1]=='#') c++;
				if(i<H-1&&0<j&&S[i+1][j-1]=='#') c++;
				if(i<H-1&&S[i+1][ j ]=='#') c++;
				if(i<H-1&&j<W-1&&S[i+1][j+1]=='#') c++;
				cout << c;
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
#define l(i,a,b) for(auto i=a;i<b;i++)
#define lr(i,a,b) for(auto i=a;i>=b;i--)
#define ll long long
#define lli long long int
#define ld long double
#define vec vector<int>
#define mii map<ll,ll>
#define vl vector<long long>
#define se set <long long int>
#define pi pair<long long,long long>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define all(v) v.begin(), v.end()
#define in(x) cin>>x
#define o(x) cout<<x
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.14159265359
using namespace std;
 
ll modulo(ll a, ll b, ll n){
    long long x=1, y=a; 
    while (b > 0) {
        if (b%2 == 1) {
            x = (x*y) % n; 
        }
        y = (y*y) % n;
        b /= 2;
    }
    return x % n;
}
 
int main()
{
    SYNC
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n; in(n);
    ll dp[n+1][3];
    dp[0][0]=0;
    dp[0][1]=0;
    dp[0][2]=0;
    l(i,1,n+1)
    {
        ll a,b,c; in(a)>>b>>c;
        dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b+max(dp[i-1][2],dp[i-1][0]);
        dp[i][2]=c+max(dp[i-1][1],dp[i-1][0]);
    }
    o(max(dp[n][0],max(dp[n][1],dp[n][2])))<<endl;
 
    
 
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int h, w; std::cin >> h >> w;
  vector<string> grid(h); rep(i, h) std::cin >> grid[i];
  int hh = (h+1)/2, ww = (w+1)/2;
  map<int, int> need;
  rep(i, hh) rep(j, ww) {
    int cnt = 1;
    if (h-i > i+1) cnt++;
    if (w-j > j+1) cnt++;
    if (cnt == 3) cnt++;
    need[cnt]++;
  }
  vi cnt(26);
  rep(i, h) rep(j, w) cnt[grid[i][j]-'a']++;
  int s4 = 0, s2 = 0, s1 = 0;
  rep(i, 26) {
    s4 += cnt[i] / 4;
    cnt[i] -= (cnt[i] / 4) * 4;
    s2 += cnt[i] / 2;
    cnt[i] -= (cnt[i] / 2) * 2;
    s1 += cnt[i];
  }
  bool ok = true;
  if (s4 < need[4]) ok = false;
  else s2 += (s4-need[4]) * 2;
  if (s2 < need[2]) ok = false;
  else s1 += (s2-need[2]) * 2;
  if (s1 < need[1]) ok = false;
  std::cout << (ok ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;

bool pali(string s)
{
  int l = 0, h = s.length() - 1;
  while (l < h)
  {
    if (s[l] != s[h])
      return false;
    l++;
    h--;
  }
  return true;
}

int main()
{
  string s;
  cin >> s;
  int n = s.length();
  bool ok = true;
  string a = s.substr(0, (n - 1) / 2);
  string b = s.substr(((n + 3) / 2) - 1);
  if (!pali(s) || !pali(a) || !pali(b))
    ok = false;
  puts(ok ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
/**
*ALDS1_7_A:ROOted Tree
**/
#include<iostream>
using namespace std;
const int Max = 1000001;
const int NIL = -1;
typedef struct Node{
        int parent;//?????????????????¶??????
        int leftChild;//????????????????????????????????????
        int rightBrother;//??????????????????????????????
};
Node node[Max];
int Depth[Max];
int setDepth(int root, int depth){
        Depth[root] = depth;//????????±???
        if(node[root].rightBrother!=NIL){//??\???????????????,??????????????????
                setDepth(node[root].rightBrother, depth);
        }
        if(node[root].leftChild!=NIL){//??\???????????????????????????????????±???
                setDepth(node[root].leftChild, depth+1);
        }

}
void print(int pos){
        cout<<"node "<<pos<<": parent = "<<node[pos].parent<<", depth = "<<Depth[pos]<<",";
        if(node[pos].parent == NIL){//??¶?????????????????´???????????????
                cout<<" root, [";
        }
        else if(node[pos].leftChild == NIL){//????????¨????????????????????¨????????£?????´????????¶??????
                cout<<" leaf, [";
        }
        else{
                cout<<" internal node, [";
        }
        int i = node[pos].leftChild;//?????????????§??????????pos???????????????????????????????§?
        while(i!=NIL){
                if(node[i].rightBrother!=NIL){//?????¢?????????????????????
                        cout<<i<<", ";
                }
                else{
                        cout<<i;//?????¶?????????????????????

                }
                i = node[i].rightBrother;
        }
        cout<<"]"<<endl;

}
int main(){
        int n, id, k, c, root,leftChild;
        cin>>n;
        for(int i = 0; i < n; i++){
                node[i].parent = node[i].leftChild = node[i].rightBrother = NIL;
        }
        for(int i = 0; i < n; i++){
                cin>>id>>k;

                for(int j = 0; j < k; j++){//????????????
                        cin>>c;
                        if(j == 0){
                                node[id].leftChild = c;//????????????
                        }
                        else{
                                node[leftChild].rightBrother = c;
                        }
                        leftChild = c;
                        node[c].parent = id;//?????????????????????????????¶??????
                }
        }
        for(int i = 0; i < n; i++){
                if(node[i].parent == NIL){
                        root = i;
                        break;
                }
        }
        setDepth(root, 0);//????????????????§???????????????????????????±???
        for(int i = 0; i < n; i++){
                print(i);//????????????????????????
        }

        return 0;
}

Measured memory_bytes: 7760