akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> n;
  cout << (n + 1) / 2 << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

int main(void){
    int n; cin>>n;
    vs def(n);
    rep(i,n)cin>>def[i];
    int m; cin>>m;
    bool isOpen=false;
    rep(i,m){
        string s;
        cin>>s;
        if(find(all(def),s)!=def.end()){
            isOpen^=true;
            cout<<(isOpen?"Opened by ":"Closed by ")<<s<<endl;
        }else{
            cout<<"Unknown "<<s<<endl;
        }
    }
}

Measured memory_bytes: 3216
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=[0]*(n+1)
ans=0
for i in range(n):
  d[i+1]=d[i]+l[i]
for i in range(n+1):
  if d[i]<=x:
    ans+=1
print(ans)


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

using i64 = long long;

i64 gcd(i64 a, i64 b) { return a ? gcd(b % a, a) : b; }

const int MAXN = 101000;

int n;
int arr[MAXN][2];
int indexs[2][MAXN];
int dsu[MAXN];

inline int find(int u) { return dsu[u] == u ? u : dsu[u] = find(dsu[u]); }
inline void join(int u, int v) { dsu[find(v)] = find(u); }

int main() {
    std::scanf("%d", &n);
    for(int i = 0; i < n; ++i)
        std::scanf("%d%d", &arr[i][0], &arr[i][1]), indexs[0][i] = indexs[1][i] = i, dsu[i] = i;
    std::sort(indexs[0], indexs[0] + n, [](int a, int b) { return arr[a][0] < arr[b][0]; });
    std::sort(indexs[1], indexs[1] + n, [](int a, int b) { return arr[a][1] < arr[b][1]; });
    std::priority_queue<std::tuple<int, int, int>, std::vector<std::tuple<int, int, int>>, std::greater<>> pq;
    for(int i = 0; i < n - 1; ++i) {
        int u0 = indexs[0][i], v0 = indexs[0][i + 1];
        pq.emplace(std::abs(arr[u0][0] - arr[v0][0]), u0, v0);
        int u1 = indexs[1][i], v1 = indexs[1][i + 1];
        pq.emplace(std::abs(arr[u1][1] - arr[v1][1]), u1, v1);
    }
    i64 result = 0;
    while(!pq.empty()) {
        auto t = pq.top();
        pq.pop();
        int u = find(std::get<1>(t)), v = find(std::get<2>(t));
        if(u != v) {
            result += std::get<0>(t);
            join(u, v);
        }
    }
    std::printf("%lld\n", result);
}

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

int main() {
  int64_t n, m;
  cin >> n >> m;
  if (n == 1) {
    if (m == 1) {
      cout << 1 << endl;
    } else {
      cout << m-2 << endl;
    }
  } else if (m == 1) {
    cout << n-2 << endl;
  } else {
    cout << n*m - (n-1)*2 - (m-1)*2;
  }
}

Measured memory_bytes: 256
import copy
n, ma, mb = map(int, input().split())
a, b, c = [0]*n, [0]*n, [0]*n
for i in range(n):
    a[i], b[i], c[i] = map(int, input().split())
   
dp = [[float('inf')] * (sum(b)+1) for _ in range(sum(a)+1)]
dp[0][0] = 0
step = set([(0, 0)])

for i in range(n):
    ai, bi = a[i], b[i]

    s = step.copy()
    tempdp = copy.deepcopy(dp)
    for si in s: 
        if dp[si[0]+ai][si[1]+bi] > dp[si[0]][si[1]] + c[i]:
            tempdp[si[0]+ai][si[1]+bi] = dp[si[0]][si[1]] + c[i]
            step.add((si[0]+ai, si[1]+bi))
        
    dp = tempdp[:]
#28 20

ans = float('inf')
for i in range(1, min(sum(a)//ma, sum(b)//mb)+1):
    ans = min(ans, dp[ma*i][mb*i])
    
if ans == float('inf'): print(-1)
else : print(ans)

Measured memory_bytes: 9308
#include <stdio.h>
int ans = 1234567890;
int check[20];
int S = 0;
int a,b,c;
int x[20],y[20][20];
void func(int k)
{
	if(k>a)
	{
		for(int j=1;j<=b;j++) if(check[j]<c) return;
		ans = ans<S?ans:S;
		return;
	}
	func(k+1);
	S += x[k];
	for(int j=1;j<=b;j++) check[j] += y[k][j];
	func(k+1);
	for(int j=1;j<=b;j++) check[j] -= y[k][j];
	S -= x[k];
}

int main()
{
	scanf("%d%d%d",&a,&b,&c);
	for(int i=1;i<=a;i++)
	{
		scanf("%d",&x[i]);
		for(int j=1;j<=b;j++) scanf("%d",&y[i][j]);
	}
	func(1);
	printf("%d",ans==1234567890?-1:ans);
}


Measured memory_bytes: 1728
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
	while(1){
		int n, m; cin >> n >> m;
		if(!n && !m) break;

		int sum[1005] ={0}; //各生徒の合計点
		for(int i=0; i<m; i++){
			for(int j=0; j<n; j++){
				int p; cin >> p;
				sum[j] += p; //点数を足していく
			}
		}

		int ans = -1;
		for(int i=0; i<n; i++){
			ans = max(ans, sum[i]); //ansとsum[i]の大きい方をansに代入
		}

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


Measured memory_bytes: 3100
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	int h;
	while(cin>>h,h){
		vvint vv;
		initvv(vv,h,5);
		rep(i,h){
			rep(j,5){
				cin>>vv[i][j];
			}
		}
		int ans=0;
		while(1){
			// rep(i,h){
				// rep(j,5){
					// cout<<vv[i][j]<<" ";
				// }
				// cout<<endl;
			// }
			// cout<<endl;
			bool f=false;
			rep(i,h){
				bool ff=false;
				rep(j,1){
					if(vv[i][j]==vv[i][j+1]&&vv[i][j]==vv[i][j+2]&&vv[i][j]==vv[i][j+3]&&vv[i][j]==vv[i][j+4]&&vv[i][j]){
						ff=true;
						f=true;
						ans+=vv[i][j]*5;
						rep(k,5){
							vv[i][j+k]=0;
						}
						break;
					}
				}
				if(ff) continue;
				rep(j,2){
					if(vv[i][j]==vv[i][j+1]&&vv[i][j]==vv[i][j+2]&&vv[i][j]==vv[i][j+3]&&vv[i][j]){
						ff=true;
						f=true;
						ans+=vv[i][j]*4;
						rep(k,4){
							vv[i][j+k]=0;
						}
						break;
					}
				}
				if(ff) continue;
				rep(j,3){
					if(vv[i][j]==vv[i][j+1]&&vv[i][j]==vv[i][j+2]&&vv[i][j]){
						f=true;
						ff=true;
						ans+=vv[i][j]*3;
						rep(k,3){
							vv[i][j+k]=0;
						}
					}
				}
				if(ff) continue;
			}
			for(int i=h-2;i>=0;i--){
				rep(j,5){
					int cnt=i;
					while(vv[cnt+1][j]==0){
						swap(vv[cnt][j],vv[cnt+1][j]);
						cnt++;
						if(cnt+1==h) break;
						// cout<<cnt<<endl;
						// cnt++;
					}
				}
			}
			if(!f) break;
			// else break;
		}
		cout<<ans<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#define ll long long

using namespace std;

const ll mod=1e9+7;
ll n,a[100010],ans=1,cnt[100010];

int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		cnt[a[i]]++;
	}
	if(n%2)
	{
		if(cnt[0]!=1)
		{
			printf("0");
			return 0;
		}
		for(int i=2;i<=n;i+=2)
		{
			if(cnt[i]!=2)
			{
				printf("0");
				return 0;
			}
		}
	}
	else 
	{
		for(int i=1;i<=n;i+=2)
		{
			if(cnt[i]!=2)
			{
				printf("0");
				return 0;
			}
		}
	}
	for(int i=1;i<=n/2;i++)ans=(ans<<1)%mod;
	printf("%lld",ans);
	return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    string t; cin >> t;

    for (int i = 0; i < t.length(); ++i) {
        if (i - 1 >= 0 && t[i] == '?' && t[i - 1] == 'P') {
            t[i] = 'D';
            continue;
        }

        if (i == t.length() - 1 && t[i] == '?') {
            t[i] = 'D';
            continue;
        }

        if (t[i] == '?' && t[i + 1] == 'D') {
            t[i] = 'P';
            continue;
        }

        if (t[i] == '?' && t[i + 1] == 'P') {
            t[i] = 'D';
            continue;
        }

        if (t[i] == '?' && t[i + 1] == '?') {
            if (i - 1 >= 0 && t[i - 1] == 'P') {
                t[i] = 'D';
                t[i + 1] = 'P';
                continue;
            } else {
                t[i] = 'P';
                t[i + 1] = 'D';
                continue;
            }
        }

        if (t[i] == '?') {
            t[i] = 'D';
            continue;
        }
    }

    cout << t << endl;
}

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

int main(){
    ll n;
    scanf("%lld",&n);
    ll m=sqrt(n)+0.5;
    for(ll x=m;x>=1;--x){
        if(n%x==0){
            ll y=n/x;
            printf("%lld\n",x+y-2);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
const double PI=acos(-1.0);
//----------------------------------------------------------------------------------------------------------------------------------//

int main(){
        int n;
        cin>>n;
        if(n>=1200) {
                cout<<"ARC"<<endl;
                return 0;
        }else{
                cout<<"ABC"<<endl;
                return 0;
        }
}


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

#define repeat(i, n) for (auto i = decltype(n)(); (i) < (n); (i)++)

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

    string s;
    cin >> s;

    int64_t ans = 0;
    int64_t numW = 0;
    for (int i = s.size() - 1; i >= 0; i--) {
        if (s[i] == 'W') numW++;
        else {
            ans += numW;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 720
#include<iostream>
    #include<iomanip>
    #include<map>
    #include<set>
    #include<string>
    #include<algorithm>
    #include<cmath>
    #include<vector>
    #include<queue>
    #include<stack>
     
    using namespace std;
     
    #define P(p) cout<<(p)<<endl
    #define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
    #define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
    #define vsort(v) sort(v.begin(), v.end());
    #define rvsort(v) sort(v.begin(), v.end(),greater<int>());
    #define YES cout<<"YES"<< endl
    #define NO cout<<"NO"<<endl
    #define Yes cout<<"Yes"<<endl
    #define No cout<<"No"<<endl  
    #define yes cout<<"yes"<<endl
    #define no cout<<"no"<<endl
    #define ret return
    #define C(i) cin>>i
    #define C2(i,j) cin>>i>>j
    #define C3(i,j,k) cin>>i>>j>>k
    #define C4(i,j,k,m) cin>>i>>j>>k>>m
    ////////////////////////////////////////////////////////////
     
    int main(){
      string s;
      cin >> s;
      string c = "CODEFESTIVAL2016";
      int sum = 0;
      rep(i,0,s.size()){
        if(s[i] != c[i])
          sum++;
      }
      P(sum); 
      ret 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, B;
  cin >> N;
  cin >> A;
  cin >> B;
  
  if (A*N <= B){
    cout << A*N << endl;
  }
  else {
    cout << B << endl;
  }
}

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

int main(){
  char x,y;
  cin >> x >> y;
  if(x < y){
    cout << "<\n";
  }
  else if(x > y){
    cout << ">\n";
  }
  else{
    cout << "=\n";
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			int N  = sc.nextInt();
			int[] A = new int[N+1];
			for(int i = 1 ; i <= N ; i++){
				A[i] = sc.nextInt();
				//System.out.println(A[i]);
			}
		sc.close();

		int[] check = new int[N+1];
		int[] right = new int[N+1];

		if(N%2!=0){
			right[0] = -1;
		}
		for(int i = N-1 ; i >= 0 ; i-=2){
			right[i]+=2;
		}

		for(int i = 1 ; i <= N ; i++){
			int p = A[i];
			check[p]++;
		}
		boolean T = true;

		for(int i = 0 ; i <= N ; i++){
			if(right[i]!=check[i]){
				T = false;
				break;
			}
		}
		long ans = 1;
		long inf = 1000000007;
		if(!T){
			System.out.println(0);
		}
		else{
		for(int i = 1 ; i <= N/2 ; i++){
			ans = (ans*2)%inf;
		}

		System.out.println(ans%inf);
		}
	}
}

Measured memory_bytes: 49148
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Template
{
    class Program
    {
        static void Main(string[] args)
        {
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);
            int d = int.Parse(input[3]);

            if (Math.Abs(c - a) <= d) { Console.WriteLine("Yes"); return; }
            else if (Math.Abs(b - a) <= d && Math.Abs(c - b) <= d) {Console.WriteLine("Yes"); return; }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11220
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
//conversion
//------------------------------------------
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();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
//container util
//------------------------------------------

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define VECMAX(x) *max_element(ALL(x))
#define VECMIN(x) *min_element(ALL(x))
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MULTIPLE(i,n,k) for(int i = (k) ; i<(n) ; i+=k+1)//倍数ループ
//constant
//------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;






#define SIZEOF(x) sizeof(x)/sizeof(x[0])




template <class T>
T max(T *a , LL n){
    T maxi = a[0];
    for(LL i = 0; i < n; ++i){
        if(a[i] > maxi)maxi = a[i];
    }
    return maxi;
}

template <class T>
T maxfrag(T *a , LL n){
    T maxi = a[0];
    T frag = 0;
    for(LL i = 0; i < n; ++i){
        if(a[i] > maxi){
            maxi = a[i];
            frag = i;
        }
    }
    return frag;
}


template <class T>
T min(T *a , LL n){
    T mini = a[0];
    for(LL i = 0; i < n; ++i){
        if(a[i] < mini)mini = a[i];
    }
    return mini;
}

template <class T>
T minfrag(T *a , LL n){
    T mini = a[0];
    T frag = 0;
    for(LL i = 0; i < n; ++i){
        if(a[i] < mini){
            mini = a[i];
            frag = i;
        }
    }
    return frag;
}


template <class T>
T sum(T *a , LL n){
    T s=0;
    for(LL i = 0; i < n; ++i){
       s+=a[i]; 
    }
    return s;
}

#define MAX(x) max(x,SIZEOF(x))
#define MIN(x) min(x,SIZEOF(x))
#define SUM(x) sum(x,SIZEOF(x))



int main(){

    LL a, b, c ;
    cin >> a >> b >> c;
    if( c > a-b)
    cout << c - a + b;
    else cout << 0;


    
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <queue>
#include <stack>
using namespace std; 
typedef pair<long long int,long long int> pa;
#define resize(A) A.resize(unique(A.begin(), A.end()) - A.begin())
#define pb push_back
#define  MAX 1000005
long long int MOD=1e9+7;
long long int INF=1e18;
                                                 /*:-]*/
long long  int modulo(long long int a,long long  int b,long long  int n)
{
    long long int  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()
{
         ios_base::sync_with_stdio(false); 
         cin.tie(NULL);
         cout.tie(NULL);
         long long int i,j,k=0,l=0,r=0,m=0,n,c,p=0,cnt=0,cnt1=0,x,y,z=0,a,b,low,mid,high,ans=0,maxi=0,mini=INF,t,x1,y1;
         string s;
    cin>>n;
    queue<char>q;
    cin>>s;
    p=1;
    for(i=1;i<n;i++)
    {
       if(s[i]==s[i-1])
       {
           
       }
        else
            p++;
    }
    
    cout<<p;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <sstream>

class poland_element_stack {
public:
    poland_element_stack() : _data(), _pos(0) {}

    void push(const std::string& str) {
        if (str == "+") {
            const int e2 = this->pop();
            const int e1 = this->pop();
            this->push(e1 + e2);
            return;
        }
        if (str == "-") {
            const int e2 = this->pop();
            const int e1 = this->pop();
            this->push(e1 - e2);
            return;
        }
        if (str == "*") {
            const int e2 = this->pop();
            const int e1 = this->pop();
            this->push(e1 * e2);
            return;
        }
        if (str == "/") {
            const int e2 = this->pop();
            const int e1 = this->pop();
            this->push(e1 / e2);
            return;
        }
        this->push(std::atoi(str.c_str()));
        return;
    }

    int pop()
    {
        --_pos;
        const int ret = _data[_pos];
        return ret;
    }

private:
    void push(int x)
    {
        _data[_pos] = x;
        ++_pos;
    }

private:
    int _data[100];
    std::size_t _pos;
};

int main() {
    poland_element_stack stack;
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
 
    std::string input;
    getline(std::cin, input);
    std::stringstream stream(input);
    std::string field;
    while (getline(stream, field, ' ')) {
        stack.push(field);
    }
    std::cout << stack.pop() << std::endl;
    return 0;
}

Measured memory_bytes: 3252
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <iomanip>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <time.h>
#include <bitset>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
//#define X first
//#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-6;
const int INF = 1000000007;
const LL LINF = 1e18;
const LL mod = 1000000007;
const LL MAX = 1000047;

LL F[MAX], INV[MAX], FI[MAX], A[MAX];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n;
	cin >> n;
	INV[1] = 1;
	F[0] = FI[0] = 1;
	FOR(i, 1, n)
	{
		if (i > 1)
		{
			INV[i] = (-(mod / i) * INV[mod % i]) % mod;
			if (INV[i] < 0)
				INV[i] += mod;
		}
		F[i] = (F[i - 1] * i) % mod;
		FI[i] = (FI[i - 1] * INV[i]) % mod;
	}
	LL ans = 0, s = 0;
	FOR(i, (n + 1) >> 1, n)
	{
		LL a = (((F[i] * F[i - 1]) % mod) * FI[(i << 1) - n]) % mod;
		ans += i * (a - s);
		ans %= mod;
		s += a - s;
		s %= mod;
	}
	if (ans < 0)
		ans += mod;
	cout << ans << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 25344
n = int(input())
count = 1
ls = [n]
 
while True:
    if n % 2 == 0:
        n = n / 2
    else:
        n = 3 * n + 1
    count+=1
    if n in ls:
        break
    else:
        ls.append(n)
print(count)

Measured memory_bytes: 2940
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	for i := 0; i <= n/4; i++ {
		for j := 0; j <= n/7; j++ {
			if 4*i+7*j == n {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1e9
#define MOD 1e9+7
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<ll> cnt(100010,0);
    ll n,k;
    cin>>n>>k;
    REP(i,n){
        int a,b;
        cin>>a>>b;
        cnt[a]+=b;
    }
    for(int ans=1;ans<=100000;ans++){
        if(k<=cnt[ans]){
            cout<<ans<<endl;
            return 0;
        }
        k-=cnt[ans];
    }
}

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

int main() {
	string s;
 cin>>s;
 int f=0;
 for(int i=0;i<s.length();i++)
 if(s[i]=='7')
 {f=1; break;}
 if(f==1)
 cout<<"Yes"<<endl;
 else
 cout<<"No"<<endl;
	return 0;
}

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

int main() {
    string S;
    cin >> S;
    int A[30];
    for(int i = 0; i < 30; i++){
        A[i] = 0;
    }
    for(int i = 0; i < 4; i++){
        A[S[i] - 'A']++;
    }
    bool judge = true;
    for(int i = 0; i < 30; i++){
        if(A[i] == 0 || A[i] == 2){

        }else{
            judge = false;
        }
    }
    if(judge){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)

def dijkstra(n, start, nbl):
    """n: 頂点数, start: 始点, nbl: 隣接リスト"""
    import heapq
    WHITE = 1<<5
    GRAY = 1<<10
    BLACK = 1<<15
    INF = 1<<20
    color = [WHITE] * n
    distance = [INF] * n
    parent = [-1] * n
    q = []

    distance[start] = 0
    heapq.heappush(q, (0, start))
    while len(q) != 0:
        du, u = heapq.heappop(q)
        # print("u: {}, du: {}".format(u, du))
        color[u] = BLACK
        if distance[u] < du:
            continue
        for next, cost in nbl[u]:
            if color[next] != BLACK and distance[u] + cost < distance[next]:
                distance[next] = distance[u] + cost
                color[next] = GRAY
                heapq.heappush(q, (distance[next], next))
    return distance


def main():
    n = int(input().strip())
    nb = [[] for _ in range(n)]
    for i in range(n):
        l = list(map(int, input().strip().split()))
        for j in range(l[1]):
            nb[i].append((l[2 + 2 * j], l[3 + 2 * j]))
    d = dijkstra(n, 0, nb)
    for i, v in enumerate(d):
        print(i, v)


if __name__ == '__main__':
    main()



Measured memory_bytes: 68580
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<map>
#include<vector>
#include<set>
#include<cctype>

#define rep(a,b) for(register int i=a;i<=b;i++)
#define red(a,b) for(register int i=a;i>=b;i--)
#define ULL unsigned long long
#define LL long long

using namespace std;

int a[1000],b[1000];
int main()
{
   int N,M,X,Y;
   cin>>N>>M>>X>>Y;
   int flag=1;
   int pre1,pre2;
   rep(1,N)
   {
   	 cin>>a[i];
   } 
   rep(1,M)
   {
   	 cin>>b[i];
   }
   sort(a+1,a+1+N);
   sort(b+1,b+1+M);
   pre1=a[N]+1;
   pre2=b[1];
   flag=0;
   if(pre2<pre1)flag=0;
   rep(pre1,pre2)
   {
   	 if(i>X&&i<=Y)
   	 {
 	   	flag=1;
 	   	break;
 	   }
   }
   if(flag)
   {
   	cout<<"No War"<<endl;
   }
   else cout<<"War"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}



ll N, L, M, R;
ll m[105];

int dp[105][20100];

int main() {
    //freopen( "/Users/macuser/Documents/Programming/Contest/input.in", "r", stdin );
    
    while (cin >> N >> L >> M >> R) {
        for (int i = 0; i < N; ++i) cin >> m[i];
        memset(dp, 0, sizeof(dp));
        R *= 2;
        M *= 2;
        
        dp[0][0] = 1;
        for (int i = 0; i <= N; ++i) {
            for (int j = 0; j <= M; ++j) {
                //cout << i << ", " << j << " : " << dp[i][j] << endl;
                
                if (dp[i][j] <= 0) continue;
                
                ll l1 = max(0LL, j + m[i]*R);
                ll r1 = min(M, j + m[i]*L) + 1;
                ll l2, r2;
                if (j - m[i]*L >= 0) {l2 = j - m[i]*L; r2 = min(M, j - m[i]*R) + 1;}
                else if (j - m[i]*R >= 0) {l2 = 0; r2 = min(M, max(abs(j - m[i]*L), abs(j - m[i]*R))) + 1;}
                else {l2 = abs(j - m[i]*R); r2 = min(M, abs(j - m[i]*L)) + 1;}
                
                if (l1 <= r1) {
                    dp[i+1][l1]++; dp[i+1][r1]--;
                }
                if (l2 <= r2) {
                    dp[i+1][l2]++; dp[i+1][r2]--;
                }
            }
            for (int j = 0; j <= M; ++j) {
                dp[i+1][j+1] += dp[i+1][j];
            }
        }
        
        bool exist = false;
        for (int i = 0; i <= M; ++i) {
            if (dp[N][i] > 0) {exist = true; break;}
        }
        
        if (exist) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 9408
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int ans = 0;
		for(int i  = 0;i < 5; ++i){
			int x = scan.nextInt();
			if(x == 0){
				ans = i+1;
			}
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 35668
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
//ll _pfact(ll a);
//static ll pf[100000000];
//static ll pc;
//
//ll _pfact(ll a) {
//	long i, r;
//	if (a % 2 == 0) {
//		pf[pc] = 2; pc++;
//		return(_pfact(a / 2));
//	}
//	r = sqrt(a);
//	for (i = 3; i <= r; i += 2) {
//		if (a % i == 0) {
//			pf[pc] = i; pc++;
//			return(_pfact(a / i));
//		}
//	}
//	if (a != 1) {
//		pf[pc] = a; pc++;
//	}
//	return 0;
//
//}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}

#pragma endregion



//ABC 096 C - Grid Repainting 2
static char s[52][53];
int main(void) {

	int i,j,h, w;
 
	scanf("%d %d",&h,&w);

	for (i = 1; i <= h; i++)
		scanf("%s", &s[i][1]);

	for (i = 1; i <= h; i++) {
		for (j = 1; j <= w; j++) {
			if (s[i][j] == '.') continue;

			if (s[i - 1][j] != '#' &&
				s[i + 1][j] != '#' &&
				s[i][j - 1] != '#' &&
				s[i][j + 1] != '#')
			{
				printf("No\n"); return 0;
			}
		}
	}
	
	printf("Yes\n");
	return 0;
}




Measured memory_bytes: 1668
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
        System.out.println((a+b+c)>21?"bust":"win");
    }
}

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

const int INF = 1001001001;
int n;
int v[100][100];
int d[100]; //?§??????????????????¢

void bfs(int s) //s????§????
{
  queue<int> q;
  q.push(s);
  for (int i = 0; i < n; i++) d[i] = INF;

  d[s] = 0;
  int u;
  while (!q.empty()) {
    u = q.front();
    q.pop();

    for (int i = 0; i < n; i++) {
      if (v[u][i] == 0) continue;
      if (d[i] != INF) continue;
      d[i] = d[u] + 1;
      q.push(i);
    }
  }

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

signed main()
{
  int u, k;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> u >> k;
    u--;
    for (int j = 0; j < k; j++) {
      int tmp;
      cin >> tmp;
      tmp--;
      v[i][tmp] = 1;
    }
  }

  bfs(0);

  return (0);
}

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


int main(){
int n,m;
cin>>n>>m;
int total=0;
vector<int>vec(m+10);
for(int i=0;i<m;++i){
cin>>vec.at(i);
}
for(int i=0;i<m;++i){
total+=vec.at(i);
}
if(total>n)cout<<-1<<endl;
else{cout<<n-total<<endl;


}
}

Measured memory_bytes: 3672
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main()
{
	int X, A, B;
	cin >> X >> A >> B;
	if ((B - (A + X)) > 0)
	{
		cout << "dangerous" << endl;
		return 0;
	}
	if ((B - A) > 0)
	{
		cout << "safe" << endl;
		return 0;
	}
	cout << "delicious" << endl;
	return 0;
}

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

int main(void){
  int N, W;
  cin >> N >> W;
  vector<int> v(N + 1);
  vector<int> w(N + 1);
  v[0] = w[0] = 0;
  for(int i = 1; i <= N; i++){ cin >> v[i] >> w[i]; }

  vector<int> dp(W + 1, 0);
  for(int i = 1; i <= N; i++)
    for(int j = W; j >= w[i]; j--)
        dp[j] = max(dp[j], dp[j - w[i]] + v[i]);

  cout << dp[W] << endl;
  return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <algorithm>
#define INF 1000000010
#define VMAX 100001
using namespace std;
typedef long long ll;
int main(void) {
  int n, wmax;
  cin >> n >> wmax;
  vector<ll> w(n);
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  }
  vector<vector<ll> > dp(101, vector<ll>(VMAX, INF));
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int vsum = 0; vsum < VMAX; vsum++) {
      if (vsum >= v[i - 1]) {
        dp[i][vsum] = min(dp[i][vsum], dp[i - 1][vsum - v[i - 1]] + w[i - 1]);
      }
      dp[i][vsum] = min(dp[i][vsum], dp[i - 1][vsum]);
    }
  }
  int ans = 0;
  for (int vsum = 0; vsum < VMAX; vsum++) {
    if (dp[n][vsum] <= wmax) {
      ans = vsum;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 83236
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,count1,count2,count3,count4,count5,count6;
    count1=0;
    count2=0;
    count3=0;
    count4=0;
    count5=0;
    count6=0;
    double h;
    cin>>n;
    for (int i=0;i<n;i++) {
        cin>>h;
        if (h<165.0) {
            count1++;
        } else if (165.0 <= h && 170.0 > h) {
            count2++;
        } else if (170.0 <= h &&175.0 > h) {
            count3++;
        } else if (175.0 <= h && 180.0 > h) {
            count4++;
        } else if (180.0 <= h && 185.0 > h) {
            count5++;
        } else if (185.0 <= h) {
            count6++;
        }
    }
    cout<<"1:";
    for (int k=0;k<count1;k++) {
            cout<<"*";
    }
    cout<<endl;
    cout<<"2:";
    for (int l=0;l<count2;l++) {
            cout<<"*";
    }
    cout<<endl;
    cout<<"3:";
    for (int m=0;m<count3;m++) {
            cout<<"*";
    }
    cout<<endl;
    cout<<"4:";
    for (int o=0;o<count4;o++) {
            cout<<"*";
    }
    cout<<endl;
    cout<<"5:";
    for (int p=0;p<count5;p++) {
            cout<<"*";
    }
    cout<<endl;
    cout<<"6:";
    for (int q=0;q<count6;q++) {
            cout<<"*";
    }
    cout<<endl;
}



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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int n, m, i, j, k, l;
	cin >> n >> m;
	vector< vector<char> > a(n, vector<char>(n)), b(m, vector<char>(m));
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	for (i = 0; i < m; i++) {
		for (j = 0; j < m; j++) {
			cin >> b[i][j];
		}
	}
	for (i = 0; (i + m) <= n; i++) {
		for (j = 0; (j + m) <= n; j++) {
			bool flag = true;
			for (k = 0; k < m; k++) {
				for (l = 0; l < m; l++) {
					if (b[k][l] != a[k + i][l + j]) {
						flag = false;
					}
				}
			}
			if (flag) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
'''
Created on 2020/09/14

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  N=int(pin())
  x,y=map(int,pin().split())
  z1=x+y
  z2=x+y
  w1=x-y
  w2=x-y
  for i in range(N-1):
    x,y=map(int,pin().split())
    z1=max(z1,x+y)
    z2=min(z2,x+y)
    w1=max(w1,x-y)
    w2=min(w2,x-y)
  print(max(z1-z2,w1-w2))
  return
main()
#解説AC

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

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> II;
typedef vector<II> VII;

#define REP(x, n) for (int x = 0; x < (n); ++x)
#define INF (1e9 + 1)
#define EPS 1e-9
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int sockets, target, cur_sockets = 1;
    cin >> sockets >> target;
    int count = 0;
    while (cur_sockets < target) {
        cur_sockets = cur_sockets + sockets - 1;
        ++count;
    }
    cout << count << '\n';
    return 0;
}

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

int main(){

    int n;
    cin >> n;

    map<string, bool> dictionary;
    for(int i = 0; i < n; ++i){
        string com, x;
        cin >> com >> x;
        if(com == "insert"){
            dictionary[x] = true;
        }
        else if(com == "find"){
            if(dictionary.find(x) != dictionary.end()){
                cout << "yes" << endl;
            }
            else{
                cout << "no" << endl;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 36440
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define reps(i, s, n) for(int i = (s); i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, s, n) for(int i = (n) - 1; i >= (s); i--)
#define INF ~(1 << 31)
#define INFL ~(1LL << 63)
#define mod 1000000007LL

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    rep(i, n){
        cin >> a[i];
        sum = (sum + a[i]) % mod;
    }

    ll ans = 0;
    rep(i, n){
        if(sum - a[i] < 0) sum += mod;
        ans = (ans + (sum - a[i]) * a[i] % mod) % mod;
        sum -= a[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 4800
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <ext/random>
#include <ext/rope>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  os << '{';
  for (size_t i = 0; i < vec.size(); ++i) {
    os << vec[i];
    if (i != vec.size() - 1) os << ',';
  }
  os << '}';
  return os;
}
template<typename T, typename U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '{' << p.first << " " << p.second << '}';
}
// constant
constexpr int INF = std::numeric_limits<int>::max() / 2;  // 1.073741823e9
constexpr int64 INF64 = std::numeric_limits<int64>::max() / 2;  // 4.611686018427387903e18
constexpr int MOD = 1000000007;

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

  int64 n, m, d; cin >> n >> m >> d;
  if (d == 0) {
    cout << setprecision(15) << static_cast<double>(m - 1) / static_cast<double>(n) << endl;
  } else {
    cout << setprecision(15) << static_cast<double>(m - 1) * 2 * static_cast<double>(n - d) / static_cast<double>(n * n) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
# Aizu Problem 0102: Matrix-like Computation
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    N = int(input())
    if N == 0:
        break
    M = [[int(_) for _ in input().split()] for __ in range(N)]
    for i in range(N):
        M[i].append(sum(M[i]))
    last = [sum([M[row][col] for row in range(N)]) for col in range(N + 1)]
    M.append(last)
    fmt = "%5d" * (N + 1)
    for row in M:
        print(fmt % tuple(row))

Measured memory_bytes: 7712
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    rep(i,0,s.size()-1){
        if(s.substr(i,2) == "AC"){
            print("Yes");
            return 0;
        }
    }
    print("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << a + b + c - max({a, b, c}) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
void solve(){
    int n;
    cin>>n;
    vector<int>h(n+1);
    for(int i=1;i<=n;i++) cin>>h[i];
    ll dp[n+1];
    memset(dp,0,sizeof(dp));
    dp[1] = 0;
    dp[2] = abs(h[2]-h[1]);
    dp[3] = min(dp[2]+abs(h[2]-h[3]),dp[1]+abs(h[1]-h[3]));
    for(int i=4;i<=n;i++){
        dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
    }
    cout<<dp[n];
}
int main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

struct Info
{
    string name;
    int score;
    int id;

    Info(string inputted_name, int inputted_age,int inputted_id)
    {
        name = inputted_name;
        score = inputted_age;
        id = inputted_id;
    }
    
    bool operator<( const Info &right ) const {
        return name == right.name ? score > right.score : name < right.name;
    }
};

int main(void){
    int N;
    cin >> N;
    vector<Info> info;
    
    for (int i = 1; i <= N; ++i) {
        string a; 
        int b;
        cin >> a>>b;
        info.push_back(Info(a, b,i));
    }
    
    sort(info.begin(), info.end());
    for (auto itr : info)
    {
        cout << itr.id << endl;
    }
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

ll inv(ll x){
  ll t = MOD - 2;
  ll ans = 1;
  while(t){
    if(t&1)ans=(ans*x)%MOD;
    x=(x*x)%MOD;
    t>>=1;
  }
  return ans;
}

#define N_MAX 220010
ll fact[N_MAX];

ll comb(ll a,ll b){
  if(a<b)return 0;
  return fact[a]*inv(fact[b])%MOD*inv(fact[a-b])%MOD;
}

int main(){
  fact[0]=1;
  REPR(i,N_MAX)fact[i]=fact[i-1]*i%MOD;
  ll n,m,k;
  cin>>n>>m>>k;
  ll result = 0;
  REP(i,k+1){
    ll l = i;
    ll r = n+i;
    ll d = k-i;
    ll u = m+(k-i);
    // http://kakuritsu.com/catalan.html
    ll hor = FIX(comb(r+l,r) - comb(r+l,r+1));
    ll ver = FIX(comb(u+d,u) - comb(u+d,u+1));
    ll v = hor*ver%MOD *comb(r+l+u+d,r+l)%MOD;
    result += v;
    result %= MOD;
  }
  cout<<result<<endl;
  return 0;
}

Measured memory_bytes: 2880
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <vector>
#include <climits>
#include <queue>
#include <utility>
#include <iomanip>
#include <sstream> 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
template<typename T1, typename T2>
inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2>
inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
const ll MOD = 1000000007;
const ll INF = 1LL << 60;



int main()
{
	char a;
	cin >> a;

	char b;
	b = toupper(a);

	if (a == b)
		cout << "A";
	else
		cout << "a";

	
}




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

int main(void){
    int n;
    string s;

    cin >> n;
    cin >> s;

    string t1 = s.substr(0, n/2);
    string t2 = s.substr(n/2);

    if (t1 == t2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256