akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

constexpr bool match(const char &a, const char &b) {
    return a == '?' || b == '?' || a == b;
}

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

    string a, b, c;
    cin >> a >> b >> c;

    int A = a.size();
    int B = b.size();
    int C = c.size();

    bitset<20000> ab, ac, bc;
    rep(i, A) rep(j, B) if(!match(a[i], b[j])) ab.set(i - j + 10000);
    rep(i, A) rep(j, C) if(!match(a[i], c[j])) ac.set(i - j + 10000);
    rep(i, B) rep(j, C) if(!match(b[i], c[j])) bc.set(i - j + 10000);

    int ans = 1e9;
    FOR(i, -4000, 4001)
    FOR(j, -4000, 4001) {
        if(!ab[i + 10000] && !ac[j + 10000] && !bc[j - i + 10000]) {
            int L = min<ll>({0, i, j});
            int R = max<ll>({A, B + i, C + j});
            chmin(ans, R - L);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
mod = 10**9 + 7
n, *A = map(int, open(0).read().split())
B = [b % mod for b in accumulate(A[::-1])][::-1][1:]
s = 0
for a, b in zip(A, B):
  s += a*b
  s %= mod
print(s)

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

int main() {
  int n;
  cin >> n;
  
  int sum = 0;
  int work = n;
  
  while (work > 0) {
  	sum += (work % 10);
    work /= 10;
  }
  
  if(n % sum  == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl; 
  }
}


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int H, W;
int N;
VI a;
VI2 color;

int main() {
    std::cin >> H >> W;
    std::cin >> N;
    a.resize(N);
    REP(i, N) {
        std::cin >> a[i];
    }

    color.resize(H, VI(W, -1));

    int cnt = 0, index = 0;
    REP(i, H) {
        if(i%2 == 0) {
            REP(j, W) {
                color[i][j] = index;
                if(++cnt >= a[index]) {
                    ++index;
                    cnt = 0;
                }
            }
        } else {
            RREP(j, W-1){
                color[i][j] = index;
                if(++cnt >= a[index]) {
                    ++index;
                    cnt = 0;
                }
            }       
        }
    }

    REP(i, H) {
        REP(j, W) {
            std::cout << (j == 0 ? "" : " ") << color[i][j]+1;
        }
        std::cout << std::endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int n, x;
  cin >> n >> x;
  vi l(n);
  rep(i, n) cin >> l[i];
  rep(i, n-1) {
    l[i+1] += l[i];
  }

  int ans = 1;
  rep(i, n) {
    if (l[i] <= x) ans++;
    else break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        long[] sumA = new long[n + 1];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
            sumA[i + 1] += sumA[i] + a[i];
        }
        int[] b = new int[m];
        long[] sumB = new long[m + 1];
        for (int i = 0 ; i < m ; i++) {
            b[i] = sc.nextInt();
            sumB[i + 1] += sumB[i] + b[i];
        }
        int c = 0;
        for (int i = 0 ; i <= n ; i++) {
            int temp = 0;
            if (sumA[i] <= k) {
                temp += i;
                temp += binarySearch(sumB, (long)k - sumA[i]);
            }
            c = Math.max(c, temp);
        }
        System.out.println(c);
    }

    static int binarySearch(long[] a, long m) {
        int ok = -1;
        int ng = a.length;
        while (Math.abs(ok - ng)> 1) {
            int mid = (ok + ng) / 2;
            if (isOk(a, m, mid)) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        return Math.max(0, ok);
    }

    static boolean isOk(long[] a, long m, int key) {
        return a[key] <= m;
    }

}


Measured memory_bytes: 64056
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;

// 解説を読んだ　これを思いつけなかったのは反省
int main(){
    int n, m;
    cin >> n >> m;
    vector<int> l(n), r(n);
    for(int i = 0; i < n; i++)  l[i] = r[i] = i;
    priority_queue<pair<int,int>> pq;
    while(m-- > 0){
        int x, y;
        cin >> x >> y;
        pq.push({-x, y});
    }
    while(!pq.empty()){
        auto p = pq.top();  pq.pop();
        int i = p.second;
        r[i-1] = max(r[i-1], r[i]);
        l[i] = min(l[i], l[i-1]);
    }
    for(int i = 0; i < n; i++)  cout << r[i]-l[i]+1 << " \n"[i+1==n];
    return 0;
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}

int main() {
  int n,m,c,count,ans=0;
  cin>>n>>m>>c;
  vector<int> a(m),b(m);
  rep(i,m) cin>>b[i];
  rep(i,n){
    count=c;
    rep(j,m){
      cin>>a[j];
      count+=a[j]*b[j];
    }
    if(count>0){
      ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	/*int a, b;
	cin >> a >> b;
	int ans = max(0, a - 2 * b);
	cout << ans;*/


	/*int n;
	cin >> n;
	vector<int>d(n);
	rep(i, n)cin >> d[i];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			ans += d[i] * d[j];
		}
	}
	cout << ans;*/


	int n;
	string s;
	cin >> n >> s;
	s += " ";
	int ans = 0;
	rep(i, n) {
		if (s[i] != s[i + 1])ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>

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

  std::vector<int> hs(n);
  for (auto&& h : hs) std::cin >> h;

  int m = 0;
  int hmax = hs[0];
  for (auto&& h : hs) {
    if (hmax <= h) {
      hmax = h;
      ++m;
    }
  }
  std::cout << m << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define MAX 400000
#define BEGIN 1
#define DEFAULT_VALUE 0
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
new_data_set s[MAX];
int main()
{
    int A,B,C,D;
    scanf("%d %d %d %d",&A,&B,&C,&D);
    int i;
    for(i=0;A>0&&C>0;i++)
    {
        if(i%2)
        {
            A-=D;
        }
        else
        {
            C-=B;
        }
    }
    if(A>0)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 35044
#include"bits/stdc++.h"
using namespace std;

const int cmp(const long long &a, const long long &b)
{
	return a > b;
}
const int mm = 1e3 + 5;
int main()
{
	long long sum[8][mm];
	long long n, m, a, b, c, ans = 0, tmp = 0;
	cin >> n >> m;
	for (int i = 0;i < n;i++)
	{
		cin >> a >> b >> c;
		sum[1][i] = a + b + c;
		sum[2][i] = -a + b + c;
		sum[3][i] = a - b + c;
		sum[4][i] = a + b - c;
		sum[5][i] = -a - b + c;
		sum[6][i] = a - b - c;
		sum[7][i] = -a + b - c;
		sum[0][i] = -a - b - c;
	}
	for (int i = 0;i < 8;i++)
		sort(sum[i], sum[i] + n, cmp);
	for (int i = 0;i < 8;i++)
	{
		tmp = 0;
		for (int j = 0;j < m;j++) 
			tmp += sum[i][j];
		ans = max(ans, tmp);
	}
	cout << ans;
	return 0;
}

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

class Program
{
    //A, C, G, T が存在し、A と T、C と G がそ

    public static void Main(string[] args)
    {
        var conv = new List<char>()
        {
            'T',
            'A',
            'G',
            'C',
        };


        var aa = Console.ReadLine();

        int currentMax = 0;
        int start = 0;
        for (; start < aa.Length; )
        {
            int i = start;
            for (; i < aa.Length; i++)
            {
                var c = aa[i];
                if (!conv.Contains(c))
                {
                    break;
                }
            }
            int foundLenth = i - start;
            currentMax = Math.Max(currentMax, foundLenth);
            start = i + 1;
        }

        Console.WriteLine(currentMax);
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K, S;
    cin >> K >> S;
    int ans = 0;
    REP(X, 0, K) {
        REP(Y, 0, K) {
            int Z = S - X - Y;
            if(0 <= Z && Z <= K) ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdint>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;
using std::vector;

using std::sort;

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

    sort(a.begin(),a.end());
    int sum=0;
    int ans=N;
    for(int i=N-1;i>=0;i--){
        if(sum+a[i]<K){
            sum+=a[i];
        }
        else{
            ans=i;
        }
    }
    cout << ans << endl;
    return 0;
}



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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int k;
    string s;
    cin>>k>>s;
    int sn=s.size();
    if(k>=sn)
    {
        cout<<s<<endl;
    }
    else
    {
        for(int i=0;i<k;i++)
        {
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 3628
main::IO()
main =do
  whn<-getLine
  let w:h:n:[] = map read (words whn)::[Int]
  dats<-getn n
  print (solver w h dats)

getn::Int -> IO [(Int,(Int,Int))]
getn 0 = return []
getn n = do
  xya<-getLine
  let x:y:a:[]= map read (words xya)::[Int]
  rest<-getn (n-1)
  return ((a,(x,y)):rest)

folding::(Int,Int,Int,Int)->[(Int,(Int,Int))]->(Int,Int,Int,Int)
folding (x1,x2,y1,y2) []                =(x1,x2,y1,y2)
folding (x1,x2,y1,y2) ((a,(x,y)):dats)
                      | a==1 = let x1'= max x1 x in folding (x1',x2,y1,y2) dats
                      | a==2 = let x2'= min x2 x in folding (x1,x2',y1,y2) dats
                      | a==3 = let y1'= max y1 y in folding (x1,x2,y1',y2) dats
                      | a==4 = let y2'= min y2 y in folding (x1,x2,y1,y2') dats

solver::Int -> Int -> [(Int,(Int,Int))]->Int
solver w h dats = let (x1,x2,y1,y2) = folding (0,w,0,h) dats in (max (x2-x1) 0)*(max (y2-y1) 0)

Measured memory_bytes: 1020
#include<iostream>
#include<math.h>

using namespace std;

int main(){
    int n;
    bool p[1000000];
    while(cin>>n){
        int n_sq = (int)sqrt(n);
        for(int i=0; i<n; i++){
            p[i] = true;
        }
        p[0] = false;

        for(int i=1; i<n_sq; i++){
            if(p[i]){
                for(int j=i*2+1; j<n; j=j+(i+1)){
                    p[j] = false;
                }
            }
        }

        int cnt=0;
        for(int i=0; i<n; i++){
            if(p[i]){
                cnt++;
            }
        }

        cout<<cnt <<endl;

    }
    return 0;
}

Measured memory_bytes: 2132
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <ios>
#include <iomanip>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   int N;
   cin >> N;
   if(N < 1000){
      string ans = "ABC";
      //cout << ans << setfill('0')<<setw(3) << to_string(N) << endl;
      cout << ans << endl;
   }else{
      string ans = "ABD";
      //cout << ans << setfill('0')<<setw(3) << to_string(N-999) << endl;
      cout << ans << endl;
   }

   return 0;
}

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


int main(){
   ll X;
   cin >> X;
   ll cnt1,cnt2;
   cnt1 = X / 500;
   X = X - (500 * cnt1);
   cnt2 = X / 5;

   cout << 1000*cnt1 + 5*cnt2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};
int row[MAX];
int col[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll n,q;
    cin>>n>>q;
    ll tot=(n-2)*(n-2);
    int x=n,y=n;
    set<int>r,c;
    r.insert(0);
    c.insert(0);
    row[0]=n-2;
    col[0]=n-2;
    for(int i=0; i<q; i++)
    {
        int a,b;
        cin>>a>>b;
        if(a==1)
        {
            auto it=c.upper_bound(b*-1);

            if(*it==0)
            {
                auto it2=r.rbegin();
                it2++;
                if(r.size()>1)
                {
                    col[b]=(*it2*-1)-2;
                }
                else
                {
                    col[b]=n-2;
                }
            }
            else
            {
               // cout<<col[*it]<<endl;
                col[b]=col[*it*-1];

            }
            tot-=col[b];
            c.insert(b*-1);
        }
        else
        {
            auto it=r.upper_bound(b*-1);
            if(*it==0)
            {
                auto it2=c.rbegin();
                it2++;
                if(c.size()>1)
                {
                    int temp=*it2;
                    row[b]=(temp*-1)-2;
                }
                else
                    row[b]=n-2;
            }
            else{
                row[b]=row[*it*-1];
            }
            tot-=row[b];
         r.insert(b*-1);
        }

    }
    cout<<tot<<endl;
    return 0;
}


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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
#define en "\n"
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>


using namespace std;
const ll maxn=5e5+100,inf=1e18,LOG=23,mod=1e9 + 7;
int block = 300, timer = 0;
const ld EPS = 1e-7;

#define bt(i) (1 << (i))
#define int ll

int a[maxn], n,dp[maxn], mx, ans;

main()
{
	cin >> n;
	ans += (n - 1) * (n) / 2;
	cout << ans;
}

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N = in();
    vector<ll> A(N);
    REP(i,N)A[i] = in();
    vector<ll> num(N+1);
    REP(i,N)num[A[i]]++;
    ll answerbase = 0;
    REP(i,N+1)answerbase += num[i]*(num[i]-1)/2;
    REP(i,N)cout << answerbase + 1 - num[A[i]] << "\n";
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

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

    int A,B; cin >>A>>B;

    cout << (A-1)*(B-1) << endl;
}


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

const int N = 2002;
int n, s0, s1, a[N], f[N][2];

int get(int k, int i) {
    if (i > n) return k == 0? s0 : s1;
    else return a[i];
}

int main() {
    cin >> n >> s0 >> s1;
    for(int i = 1; i <= n; i++) cin >> a[i];
    reverse(a + 1, a + n + 1);

    for(int k = 0; k < 2; k++) f[1][k] = abs(get(1 - k, 2) - a[1]);

    for(int i = 2; i <= n; i++)
        for(int k = 0; k < 2; k++) {
            f[i][k] = abs(get(1 - k, i + 1) - a[1]);
            for(int j = 1; j < i; j++) f[i][k] = k == 0? max(f[i][k], f[j][1]) : min(f[i][k], f[j][0]);
        }

    // for(int i = 1; i <= n; i++) cout << f[i][0] << ' '; cout << endl;
    // for(int i = 1; i <= n; i++) cout << f[i][1] << ' '; cout << endl;
    cout << f[n][0];
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<tuple>
#include<string>

using namespace std;
#define ll long long

int main(){
    ll N;
    string S;
    int a;
    cin >> N;
    vector<tuple<string,int,int> > L;
    for(int i = 0; i < N; i++){
        cin >> S >> a;
        L.push_back(make_tuple(S,-a,i+1));
    }
    sort(L.begin(),L.end());
    
    // ans
    for(int i = 0; i < N; i++){
        cout << get<2>(L[i]) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>
#include<iomanip>

#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define MOD 1000000007

using namespace std;
using ll=long long int;

int main(){
    int N;
    cin >> N;
    vector<pair<ll,ll>> vec;
    ll a,b;
    for(int i=0;i<N;i++){
        cin >> a >> b;
        vec.pb(mp(b,a));
    }
    sort(vec.begin(),vec.end());
    ll t=0;
    for(int i=0;i<N;i++){
        if((t+vec[i].second)<=vec[i].first){
            t+=vec[i].second;
        }
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main(){
    int N, move=0, count=0, maxcount=0;
    cin >> N;
    int H[N];
    cin >> H[0];
    for(int i=1; i<N; i++){
        cin >> H[i];
        if(H[i] <= H[i-1]){
            count++;
        }
        else{
            if(maxcount < count) maxcount = count;
            count = 0;
        }
    }
    if(maxcount < count) maxcount = count;
    cout << maxcount << endl;
}

Measured memory_bytes: 640
N,K = list(map(int, input().split()))
mod = int(1e9+7)
A = [0] * (K+1)
ans = 0

for i in range(K,0,-1):
  #print(i, K//i, N, mod)
  A[i] = pow(K//i, N, mod)
  idx = 2*i
  while idx <= K:
    A[i] = (A[i] - A[idx]) % mod
    idx += i
  ans = (ans + A[i] * i) % mod
print(ans)


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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T 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;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
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;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n,m,d;cin>>n>>m>>d;
  ld x=n-d;
  if(d!=0)x*=2;
  ld ret=x*(m-1)/(n*n);
  /*while(buf>0){
    if(buf&1)ret*=tmp;
    tmp=tmp*tmp;
    buf>>=2;
  }*/
  cout lfs ret<<endl;
  return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())

inf = 10**9+7
def f(num,total):
	for n in range(1,num+1):
		total *= n
		total %= inf
	return total

if abs(n-m) > 1:
	ans = 0
elif abs(n-m) == 1:
	ans = f(n,1)*f(m,1)
	ans %= inf
else:
	ans = f(n,1)*f(m,1)*2
	ans %= inf
print(ans)

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

using namespace std;

template <class T> void mini(T &l, T r) {l = min(l, r);}
template <class T> void maxi(T &l, T r) {l = max(l, r);}

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(bool a) {
    return a ? "T" : "F";
}

string to_string(const char* s) {
    return to_string((string) s);
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define X first
#define Y second

using ll = long long;
using ld = long double;

const int N = 2e5 + 10;
const ll inf = (ll)1e18 + 10;

int l;
int a[N];
ll lef[N], lef2[N], rig[N], cost[N];
ll d[N];

ll get(int a) {
    if (a == 0) return 1;
    if (a % 2 == 0) return 1;
    return 0;
}

ll getsum(int l, int r) {
    if (l > r) return 0;
    return d[r] - d[l - 1];
}

int get2(int a) {
    if (a == 0) return 2;
    if (a % 2 == 0) return 0;
    return 1;
}

void run() {
    scanf("%d", &l);
    for (int i = 1; i <= l; ++i) {
        scanf("%d", a + i);
    }
    for (int i = 1; i <= l; ++i) {
        d[i] = d[i - 1] + a[i];
    }
    for (int i = 1; i <= l; ++i) {
        lef2[i] = min(lef2[i - 1] + get2(a[i]), getsum(1, i));
    }
    for (int i = 1; i <= l; ++i) {
        lef[i] = lef[i - 1] + get(a[i]);
    }
    for (int i = l - 1; i >= 0; --i) {
        rig[i] = min(rig[i + 1] + get2(a[i + 1]), getsum(i + 1, l));
    }

    for (int i = 0; i <= l; ++i) {
        cost[i] = lef[i] + rig[i];
    }

    debug(vector <ll> (rig + 1, rig + 8));
    debug(vector <ll> (cost + 1, cost + 8));

    set < pair <ll, int> > st;
    for (int i = 0; i <= l; ++i) {
        st.insert(make_pair(cost[i], i));
    }

    ll ans = inf;
    ll bs = 0;
    mini(ans, bs + st.begin()->X);

    for (int i = 1; i <= l; ++i) {
        st.erase(make_pair(cost[i - 1], i - 1));
        bs += lef2[i] - (lef2[i - 1] + get(a[i]));
        mini(ans, bs + st.begin()->X);
    }

    printf("%lld\n", ans);
}

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


Measured memory_bytes: 21376
def inv(a,m):
    b=m
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return lastx % m

mod=998244353
n,m,k=map(int,input().split())
frac=[1 for i in range(n+1)]
frac_inv=[1 for i in range(n+1)]
beki=[m for i in range(n+1)]

for i in range(1,n+1):
    frac[i]=frac[i-1]*i%mod
    frac_inv[i]=inv(frac[i],mod)
    beki[i]=beki[i-1]*(m-1)%mod
ans=0
for i in range(n-k,n+1):
    ans+=beki[i-1]*frac_inv[n-i]*frac_inv[i-1]
    ans%=mod
print(ans*frac[n-1]%mod)

Measured memory_bytes: 94100
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
typedef pair<int,ll> P;
ll inf = 1000000000000000000;

struct edge{
  int s,t;
  ll cost;
};

int main(){
  int N,M;
  cin >> N >> M;
  edge e[M];
  for(int i=0;i<M;i++){
    cin >> e[i].s >> e[i].t >> e[i].cost;
    e[i].s--; e[i].t--;
    e[i].cost *= -1;
  }

  ll d[N]; //d[i]: 0からiまでの最短距離
  fill(d,d+N,inf);
  d[0] = 0;

  //n-1回ループ　負の閉路が無ければ更新が終わる
  for(int i=0;i<N-1;i++){
    for(int j=0;j<M;j++){
      if(d[e[j].s] != inf && d[e[j].t] > d[e[j].s] + e[j].cost){
        d[e[j].t] = d[e[j].s] + e[j].cost;
      }
    }
  }

  //さらにn回ループ　ここで更新がある点はいくらでも小さくなる
  bool neg[N];
  fill(neg,neg+N,false);
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      if(d[e[j].s] != inf && d[e[j].t] > d[e[j].s] + e[j].cost){
        d[e[j].t] = d[e[j].s] + e[j].cost;
        neg[e[j].t] = true;
      }
    }
  }

  if(neg[N-1]) cout << "inf" << endl;
  else cout << -d[N-1] << endl;
  return 0;
}

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

int main() {
  int H, W, A, B, N;
  int y=0;
  long int x=1;
  string S;
  cin >> N >> S;
  vector<int> vec(N);

  
  for ( int i=0; i < N-1; i++) {
    if (S.at(i)!=S.at(i+1)) x++;
    }

  cout << x << endl;

    
}


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

int main(){
    int n;cin>>n;
    int adj[n][n];
    rep(i,n)rep(j,n)adj[i][j]=0;
    rep(i,n){
        int node,k,id;
        scanf("%d %d",&node,&k);
        node--;
        rep(j,k){
            scanf("%d",&id);
            id--;
            adj[node][id]=1;
        }
    }
    rep(i,n){
        rep(j,n){
            if(j!=0)printf(" ");
            printf("%d",adj[i][j]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 3216
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
int main() {
	int a[3];
	for (int i = 0; i < 3; i++)
		cin >> a[i];

	sort(a, a + 3);
	cout << a[2]-a[0]<< endl;

	return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;

int main(){
        int n;
        while(cin>>n&&n){
                ll ans=0;
                vector<int>s(n);
                for(int i=0;i<n;i++){
                        cin>>s[i];
                        ans+=s[i];
                }
                sort(s.begin(),s.end());
                ans=ans-s[0]-s[n-1];
                cout<<ans/(n-2)<<endl;
        }
        return 0;
}



Measured memory_bytes: 3060
n,q = map(int,input().split())
s = input()
ans =[0]*n
for i in range(1,n):
    if s[i-1] == 'A' and s[i] == 'C':
        ans[i] = 1
    ans[i] += ans[i-1]

for i in range(q):
    l,r = map(int,input().split())
    print(ans[r-1]-ans[l-1])


Measured memory_bytes: 53720
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int count = 0;
		for (int X=0; X<=K; X++) {
			for (int Y=0; Y<=K; Y++) {
				int Z = S-(X+Y);
				if ( Z <= K && Z>=0) count++;
			}			
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23764
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int x = in.nextInt();
        int y = in.nextInt();
        int z;
        if (k > n) {
            System.out.println(x * n);
        } else {
            z = n - k;
            System.out.println((x * k) + (y * z));
        }
    }
}


Measured memory_bytes: 27096
#include<bits/stdc++.h>
#define LL long long 
#define mod 1000000007
using namespace std;

int ans,cnt;
int n,m,tot;
int book[400005];
int head[400006];
int nxt[400006],to[400006],siz[400005];

inline int qr()
{
	char a=0;int x=0,w=1;
	while(a<'0'||a>'9'){if(a=='-')w=-1;a=getchar();}
	while(a<='9'&&a>='0'){x=(x<<1)+(x<<3)+(a^48);a=getchar();}
	return x*w;
}

inline void add(int x,int y)
{
	to[++tot]=y;
	nxt[tot]=head[x];
	head[x]=tot;
}

void dfs(int x)
{
	book[x]=1;
	cnt++;
	for(register int j=head[x];j;j=nxt[j])
		if(!book[to[j]])
			dfs(to[j]);
} 

int main()
{
	n=qr();
	m=qr();
	for(register int i=1;i<=m;i++)
	{
		int x=qr();
		int y=qr();
		add(x,y);
		add(y,x);
	}
	for(register int i=1;i<=n;i++)
		if(!book[i])
		{
			cnt=0;
			dfs(i);
			ans=max(ans,cnt);
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 17612
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long a[200020];
int main() {
	long long n;
	cin >> n;
	long long m = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (m <= a[i]) {
			m = a[i];
		}
		else {
			ans += m - a[i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5124
// 2010/07/20 Tazoe

#include <iostream>
using namespace std;

void eratos(bool prm[], int n)
{
	if(n>=1)
		prm[0] = false;
	if(n>=2)
		prm[1] = false;

	for(int i=2; i<n; i++)
		prm[i] = true;

	for(int i=2; i<n; i++)
		if(prm[i])
			for(int j=i+i; j<n; j+=i)
				prm[j] = false;
}

int main()
{
	bool prm[10000001];
	eratos(prm, 10000001);

	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		for(int i=n; i>=13; i--)
			if(prm[i]&&prm[i-2]&&prm[i-6]&&prm[i-8]){
				cout << i << endl;
				break;
			}
	}

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#define N 100

int n,m[N+1][N+1],p[N+1];
void matrix();

int main()
{
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
  {
    scanf("%d%d",&p[i-1],&p[i]);
  }

  matrix();

  printf("%d\n",m[1][n]);

  return 0;
}

void matrix()
{
  int q,i,j,k,l;
  for(i=1;i<=n;i++) m[i][i] = 0;
  for(l=2;l<=n;l++)
  {
    for(i=1;i<=n-l+1;i++)
    {
      j = i+l-1;
      m[i][j] = 10000000;
      for(k=i;k<=j-1;k++)
      {
        q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
        if(m[i][j] > q)  m[i][j] = q;
      }
    }
  }
}



Measured memory_bytes: 2112
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c for j in range(b)] for i in range(a)]
def list3d(a, b, c, d): return [[[d for k in range(c)] for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10**9)
INF = 10**19
MOD = 10**9 + 7
EPS = 10**-10

N = INT()
ans = 0
for a in range(1, N+1):
    for b in range(1, N+1):
        if a*b >= N:
            break
        ans += 1
print(ans)


Measured memory_bytes: 68024
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#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;
const double PI = acos(-1);

int main(){
  double A, B, H, M; cin >> A >> B >> H >> M;

  double do_a = 0.5 * (H * 60 + M), do_b = 6 * M;
  double diff;
  if (do_a >= do_b) diff = do_a - do_b;
  else diff = do_b - do_a;
  diff = diff * PI / 180;
  double ans = sqrt(A * A + B * B - 2 * A * B * cos(diff));

  printf("%.15f\n", ans);
}


Measured memory_bytes: 4256
#!/usr/bin/env python3

import itertools

n, m, x = map(int, input().split())
_list = [list(map(int, input().split())) for _ in range(n)]
n_list = [i for i in range(n)]
all_list = []
a = [0]*(m+1)
ans = 100000000000000000000000

for i in range(n):
    for j in itertools.combinations(n_list, i+1):
        all_list.append(j)

for i in all_list:
    a = [0]*(m+1)
    for j in i:
        for k in range(m+1):
            a[k] += _list[j][k]
    if a[0] < ans:
        if all(x <= a[i] for i in range(1, m+1)):
            ans = a[0]

if ans == 100000000000000000000000:
    print(-1)
else:
    print(ans)
        

Measured memory_bytes: 9388
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    string S;
    cin >> S;
    
    cout << ( string( 3, S[0] ) < S ? string( 3, S[0]+1 ) : string( 3, S[0] ) ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
int data[1000];

int main()
{
	int n;
	
	while(~scanf("%d",&n))
	{
		int i,j,sum=0,a;
		for(i=0;i<n;i++)
		{
			scanf("%d",&data[i]);
			if(data[i]%2==0)
			{
				sum++;
			}
		}
		
		a = pow(3,n)-pow(2,sum);
		
		printf("%d\n",a);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <climits>
#include <cmath>
using namespace std;
int main (void) {
    int N;

    cin >> N;
    int a[N];
    for (int i = 0; i < N; i++) cin >> a[i];

    int ans = INT_MAX;
    for (int i = -100; i <= 100; i++) {
        int sum = 0;
        for (int j = 0; j < N; j++) {
            sum += pow(a[j] - i, 2);
        }
        ans = min(ans, sum);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#高橋君の夏休みは N 日間です。
#夏休みの宿題が M 個出されており
#i 番目の宿題をやるには Ai 日間かかります。
#夏休み中に全ての宿題を終わらせるぉとができないときは、かわりに '-1' を出力

N,M =map(int,input().split())
A =list(map(int,input().split()))

if sum(A) > N:
    print(-1)
else:
    print(N-sum(A))

Measured memory_bytes: 9948
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n, i, j, a[100002], b[100002], c[100002];
    cin >> n;
    int final[100002][3];
    for(i = 0; i < n; i++) {
    	cin >> a[i] >> b[i] >> c[i];
    }
    final[0][0] = a[0];
    final[0][1] = b[0];
    final[0][2] = c[0];
    for(i = 1; i < n; i++) {
    	final[i][0] = max(final[i - 1][1], final[i - 1][2]) + a[i];
    	final[i][1] = max(final[i - 1][0], final[i - 1][2]) + b[i];
    	final[i][2] = max(final[i - 1][0], final[i - 1][1]) + c[i];
    }
    int mx = max(final[n - 1][0], final[n - 1][1]);
    mx = max(final[n - 1][2], mx);
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int n,x,l[105],num,ans=1; 
int main(){
	cin>>n>>x;
	for(int i=1;i<=n;i++) cin>>l[i];
	for(int i=1;i<=n;i++)
	{
		num+=l[i];
		if(num<=x) ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a[200005],b[200005];
   int n,k;
   cin>>n>>k;
   for(int i=0;i<n;i++)
   {
       a[i]=999999;
   }
   for(int i=0;i<n;i++)
   {
       cin>>b[i];
       if(a[b[i]-1]==999999) a[b[i]-1]=1;
       else a[b[i]-1]++;
   }
   sort(a,a+n);
   int sum=0,f=0;
   for(int i=n-1;i>=0;i--)
   {
       if(a[i]==999999) continue;
       f++;
       if(f>k) sum+=a[i];
   }
   cout<<sum;
}

Measured memory_bytes: 1792
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  transform(s1.begin(), s1.end(), s1.begin(), ::toupper);
  transform(s2.begin(), s2.end(), s2.begin(), ::toupper);
  transform(s3.begin(), s3.end(), s3.begin(), ::toupper);
  string ans = s1.substr(0,1) + s2.substr(0,1) + s3.substr(0,1);
  cout << ans << endl;
  return 0;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
	int n;
	while(cin >> n,n){
		rep(i,n){
			int pm,pe,pj;
			cin >> pm >> pe >> pj;
			int cmax=max({pm,pe,pj}),sum=pm+pe+pj;
			char ans='C';
			if(sum>=150&&(pm>=80||pe>=80)) ans='B';
			if(sum>=210) ans='B';
			if(sum>=240) ans='A';
			if(pm+pe>=180) ans='A';
			if(cmax==100) ans='A';
			printf("%c\n",ans);
		}
	}
	return 0;
}

Measured memory_bytes: 3072
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
int b=scan.nextInt();
int c=scan.nextInt();
if(a+b>=c) {
	System.out.println("Yes");
}
else {
	System.out.println("No");
}
}
	}

Measured memory_bytes: 23124
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

ll flg[1010];

int main(){

	ll N, M;
	cin >> N >> M;
	
	rep(i, M){
		ll a, b;
		cin >> a >> b;
		for(ll i = a; i < b; i++)flg[i] = 1;
	}
	ll ans = N + 1;
	for(ll i = 1; i <= N; i++)ans += 2 * flg[i];
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
    int n,ans;
    double t,a,tmp = 1000000.0;
    cin >> n >> t >> a;
    vector<int>v(n);

    for(int i = 0;i < n;i++){
        cin >> v[i];
        if(tmp >= fabs(a-(t-v[i]*0.006))){
            tmp = fabs(a-(t-v[i]*0.006));
            ans = i+1;
        }
    }
    
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define PB push_back
#define MP make_pair
#define PI 3.14159265358979323846
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define endl '\n'
#define show(a) for(auto el:a)cout<<el<<" "
const ll INF=LLONG_MAX/2;
const ll N=2e5+1;
#define yesno(f) yes(f);no(f);
#define yes(f) if(f)cout<<"YES\n";
#define no(f) if(!f)cout<<"NO\n";
using  namespace std;
ll pow1(ll n,ll p)
{
	if(p==0)	return 1;
	ll x=pow1(n, p/2);
	x=(x*x);
	if(p%2==0)
		return x;
	else
		return (x*n);
}
int main()
{
    fast;
   ll t=1;
    //std::cin >> t;
   while(t--)
   {
       ll n,w,x=0,sum=0;
       std::cin >> n;
       string s;
       map<string,ll>mp;
       fr(i,0,n)
       {
           std::cin >> s;
           mp[s]++;
           sum=max(sum,mp[s]);
       }
       for(auto it=mp.begin();it!=mp.end();it++)
       {
           if(it->S==sum)
           cout<<it->F<<"\n";
       }

   }
}

Measured memory_bytes: 19196
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>

int ans[201000];
int c[201000];
vector<vi> v;

void dfs(int k,int s){
  s+=c[k];
  ans[k]=s;
  
  for(auto e:v[k]){
    dfs(e,s);
  }

}


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

  int n,q;
  cin>>n>>q;
  v = vector<vi>(n);
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    v[a].PB(b);
  }


  rep(i,q){
    int p,x;
    cin>>p>>x;
    p--;
    c[p]+=x;
  }

  dfs(0,0);

  rep(i,n){
    if(i) cout<<' ';
    cout<<ans[i];
  }
  cout<<endl;

}

Measured memory_bytes: 22528