akhauriyash/Code-Regression huggingface dataset:
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var t = new Test();
            var n = t.ReadInputOneLine();
            var input = t.ParseIntList(t.ReadInput());
            var dic = new Dictionary<int, int>();
            
            for(var i = 1; i<=n; i++)
            {
                dic.Add(i, 0);
            }
            foreach(var v in input)
            {
                if (dic.ContainsKey(v))
                {
                    dic[v]++;
                }
                
            }

            foreach(var v in dic)
            {
                Console.WriteLine(v.Value);
            }
            
        }


        public int ReadInputOneLine()
        {
            return int.Parse(Console.ReadLine());
        }

        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public List<int> ParseIntList(string[] x)
        {
            var convertedList = new List<int>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(int.Parse(x[i]));
            }

            return convertedList;
        }


        public List<double> ParseDoubleList(string[] x)
        {
            var convertedList = new List<double>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(double.Parse(x[i]));
            }

            return convertedList;
        }

        public List<long> ParseLongList(string[] x)
        {
            var convertedList = new List<long>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(long.Parse(x[i]));
            }

            return convertedList;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 42144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

bool isPrime(int e) {
  for (int i = 2; i <= (int)sqrt(e); i++) {
    if (e % i == 0) return false;
  }
  return true;
}

int X;

int main() {
  cin >> X;
  for (int i = X;; ++i) {
    if (isPrime(i)) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import sys
def main():
    while True:
        n = int(input())
        if not n:
            return
        aa = list(map(int,input().split()))
        ans = sys.maxsize
        for i in range(n):
            for j in range(n):
                if i == j:
                    continue
                ans = min(abs(aa[i]-aa[j]),ans)
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5636
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,q,a[100005],k[100005];
ll sa[100005],sb[100005];
int main()
{
    scanf("%d%d",&n,&q);
    for(int i=1+n%2,j=0;j<n;i++,j++) scanf("%d",&a[i]);
    n+=n%2;
    for(int i=1;i<=n/2;i++) k[i]=(a[i*2]+a[n/2+i])/2;
    for(int i=1;i<=n;i++) sa[i]=sa[i-1]+a[i];
    for(int i=1;i<=n;i++) sb[i]=sb[i-1]+(i%2?0:a[i]);
    while(q--)
    {
        int x;
        scanf("%d",&x);
        int t=lower_bound(k,k+n/2,x)-k;
        t=n/2-t+1;
        printf("%lld\n",sa[n]-sa[n-t]+sb[n-t*2]);
    }
}


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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)


int func(string s, ll l)
{
    int maxal = 'a' -1;
    if(s.size() == l) {
        printf("%s\n", s.c_str() );
        return 0;
    }
    REP(i, s.size()) maxal = max(maxal, (int)s[i]);
    char c;
    for(c = 'a'; c <= maxal + 1; c++) {
        func(s + c, l);
    }
    return 0;
}




int main(void)
{
    ll n;
    cin >> n;

    func("a", n);

}


Measured memory_bytes: 1536
n,m = map(int,input().split())
x = sorted(list(map(int,input().split())))

import sys
if n>=m:
    print(0)
    sys.exit()

y = []
for i in range(m-1):
    y += [x[i+1]-x[i]]
y = sorted(y)
print(sum(y[:m-n]))

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

#define debug(x) cerr << #x << ": " << x << endl;

#define iosbase ios_base::sync_with_stdio(false)
#define tie cin.tie();cout.tie();

#define endl '\n'

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

int n, m;
int main(){
  iosbase;
  tie;

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

  if( a <= 9 && a >= 1 && b<= 9 && b>=1){
    cout << a*b << endl;
  }
  else cout << "-1" << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int A, B, K;
    cin >> K;
    cin >> A >> B;
    
    if (A/K > B/K || ( A/K == B/K  && A%K != 0 && B%K !=0 )) {
        cout << "NG" << endl;
    } else {
        cout << "OK" << endl;
    }
    return 0;
} 

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

#define MOD (1000000007)

int dp[2][201][10010];

int main() {
    int N,W; cin >> N >> W;

    vector<int> friends;

    for (int i=0; i<N; ++i) {
        int w; cin >> w;
        // ??????????????????????????????
        if (w <= W) friends.push_back(w);
    }
    // ????????§sort???????????§?????????idx=0??????
    // ?????°????????\???????????\??£?????????????????¨??????????????????
    friends.push_back(W + 1);
    sort(friends.rbegin(), friends.rend());

    int curr = 0;
    dp[curr][0][0] = 1;
    for (int i=1; i<friends.size(); ++i) {
        // init
        for (int j=0; j<friends.size(); ++j)
            for (int k=0; k<=W; k++)
                dp[curr^1][j][k] = 0;

        for (int j=0; j<friends.size(); ++j) { // ??????????????£?????????
            int m = friends[i] <= friends[j] ? i : j;
            for (int k=0; k<=W; k++) {
                // friends[i]????????°??????
                dp[curr^1][m][k] += dp[curr][j][k];
                dp[curr^1][m][k] %= MOD;

                // friends[i]????????¶??¨???
                if (k + friends[i] <= W) {
                    dp[curr^1][j][k + friends[i]] += dp[curr][j][k];
                    dp[curr^1][j][k + friends[i]] %= MOD;
                }
            }
        }
        curr = (curr + 1) % 2;
    }
    /*
    for (int i=0; i<friends.size(); i++) {
        printf("%d:%d\n",i,friends[i]);
    }
    cout << "============" << endl;

    // debug
    for (int i=0; i<friends.size(); i++) {
        printf("%2d: ", i);
        for (int j=0; j<=W; j++) {
            printf("%2d ", dp[curr][i][j]);
        }
        cout << endl;
    }
    */

    // ????¨?
    int ans = 0;
    for (int i=0; i<friends.size(); i++) {
        for (int j=W-friends[i]+1; j<=W; j++) {
            ans += dp[curr][i][j];
            ans %= MOD;
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 18832
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())



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

ll X,Y,Z,K;
ll pmax = 30000000000;
vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }




int main() {



  ll N;
  cin >> N;

  vint c(N,0), v(N,0);

  rep(i,N){cin >> v[i];}
  rep(i,N){cin >> c[i];}

  ll ans = 0;

  rep(i,N){
    ll tmp = v[i] - c[i];
    if(tmp>0) ans += tmp;
  }

  cout << ans << endl;

}

















//


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

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  
  if((A==B && A==C && B==C) || (A!=B && A!=C && B!=C))
  {
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3552
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;

class Program
{
    static void Main()
    {
        Scanner cin = new Scanner();
        //Random rnd = new Random();
        //Stopwatch sw = new Stopwatch();

        // A B C

        int X = cin.Nextint;
        int A = cin.Nextint;
        int B = cin.Nextint;


        // N
        // a1 a2 ... aN
        /*
        int N;
        int[] A;

        N = cin.Nextint;
        A = cin.Scanint;
        */

        // N M
        // a1 b1
        // ...
        // aM bM
        /*
        int N;
        int M;
        int[] A = new int[M];
        int[] B = new int[M];

        N = cin.Nextint;
        M = cin.Nextint;

        for(int i=0; i<M; i++)
        {
            A[i] = cin.Nextint;
            B[i] = cin.Nextint;
        }
         */


        /** ここに記述 */
        string r = "";
        if (B<=A)
        {
            r = "delicious";
        } else if(B <= A + X)
        {
            r = "safe";
        } else if(B > A)
        {
            r = "dangerous";
        }
        Console.WriteLine(r);
        Console.Out.Flush();
    }
}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return Console.ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length)
            {
                return s[i++];
            }
            string st = Console.ReadLine();
            while (st == "")
            {
                st = Console.ReadLine();
            }

            s 
            = st.
                Split
                (cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

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

int reverse(string &s){
	int n = s.size(), n2 = n/2;
	for (int i=0; i<n2; i++){
		swap(s[i], s[n-1-i]);
	}
	return 0;
}

int main(void){
	int n;
	cin>>n;
	for (int i=0; i<n; i++){
		string s1, s2, s3="";
		cin>>s1>>s2;

		reverse(s1);
		reverse(s2);

		while (s1.size()<s2.size()) s1 += '0';
		while (s2.size()<s1.size()) s2 += '0';

		long c=0, stmp;
		for (int i=0; i<s1.size(); i++){
			stmp = s1[i]-'0'+s2[i]-'0'+c;
			c = stmp / 10;
			s3 += stmp%10 +'0';
		}
		if (c!=0) s3 += c + '0';

		reverse(s3);
		if (s3.size()>80)
			cout<<"overflow"<<endl;
		else
			cout<<s3<<endl;

	}
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
#define PRYES(x) PR((x) ? "Yes" : "No")
const long long INF = numeric_limits<long long>::max();
// SourceTest用出力マクロ
#ifdef SOURCE_TEST
#define SPR(x) PR(x)
#define SPS(x) PS(x)
#else
#define SPR(x) \
    {}
#define SPS(x) \
    {}
#endif

template <class T> void dumpVector(const vector<T>& vec) {
#ifdef SOURCE_TEST
    for (ll i = 0; i < vec.size(); ++i) {
        cout << vec[i] << ",";
    }
    cout << endl;
#endif
}

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

    vector<ll> sums(N + 1, 1);
    sums[0] = sums[1] = sums[2] = 0;
    for (ll i = 4; i <= N; ++i) {
        for (ll j = 3; j <= i - 3; ++j) {
            sums[i] = (sums[i] + sums[j]) % MOD;
        }
    }

    dumpVector(sums);

    PR(sums[N]);

    return 0;
}


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

int main(){
	int n,k;cin>>n;
	char s[19];cin>>s+1;
	cin>>k;
	for(int i=1;s[i];++i)
		printf(s[i]==s[k] ? "%c" :  "*"  ,s[k]);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<deque>
#include<string>

int main()
{
	std::deque<char> train;
	std::string str;
	int n;
	
	std::cin>>n;
	for(int i=0;i<n;i++)
	{
		std::cin>>str;
		int pos=0,max=0,min=0;
		train.clear();
		train.push_back(str[0]);

		for(int k=1;k<str.size();k++)
		{
			if(str[k]=='-')
			{
				pos++;
			}
			else
			{
				pos--;
			}
			k+=2;
			if(pos>max)
			{
				train.push_back(str[k]);
				max=pos;
			}
			else if(pos<min)
			{
				train.push_front(str[k]);
				min=pos;
			}
		}
		
		while(!train.empty())
		{
			std::cout<<train.front();
			train.pop_front();
		}
		std::cout<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<algorithm>
#include<cstdio>
using namespace std;
const int mod=1e9+7;
int n,m,fac[4000010],ifc[4000010],dp[2010][2010];
int pow(int k,int i)
{
	int t=1;
	while(i)
	{
		if(i&1) t=1ll*t*k%mod;
		k=1ll*k*k%mod;i>>=1;
	}
	return t;
}
int C(int x,int y)
{
	if(x<y) return 0;
	return 1ll*fac[x]*ifc[y]%mod*ifc[x-y]%mod;
}
int main()
{
	scanf("%d%d",&n,&m);
	if(m==1) {puts("1"); return 0;}
	fac[0]=1;dp[0][0]=1;
	for(int i=1;i<=n*m;++i) fac[i]=1ll*fac[i-1]*i%mod;
	ifc[n*m]=pow(fac[n*m],mod-2);
	for(int i=n*m-1;~i;--i) ifc[i]=1ll*ifc[i+1]*(i+1)%mod;
	for(int i=1;i<=n;++i)
		for(int j=0;j<=i;++j)
		{
			dp[i][j]=dp[i-1][j];
			if(!j) continue;
			dp[i][j]=(dp[i][j]+1ll*dp[i][j-1]*C(n*m-i-(j-1)*(m-1)-1,m-2))%mod;
		}
	printf("%lld\n",1ll*dp[n][n]*fac[n]%mod);
	return 0;
}

Measured memory_bytes: 46336
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int mod =1000000007;
const double PI = acos(-1);

int main(){
    ll n,k;cin>>n;
    ll a[n];
    rep(i,n)cin>>a[i];
    vl res;
    bool f=false;
    ll ans =1000,cnt=0;
    rep(i,n){
        bool x = true;
        if(cnt==0){
            if(i==n-1)continue;
            rep2(j,i+1,n){
                bool y =false;
                if(a[j]<=a[i]){
                    x=false;
                    break;
                }
                else{
                    rep2(k,i+1,n){
                        if(a[i]<a[k])y=true;
                    }
                    if(!y)x=false;
                    break;
                }
            }
            if(x){
                //cout<<i<<endl;
                cnt+=ans/a[i];
                ans-=cnt*a[i];
            }
        }
        else{
            rep2(j,i+1,n){
                if(a[j]>=a[i]){
                    x=false;
                    break;
                }
                else{
                    break;
                }
            }
            if(x){
                ans+=a[i]*cnt;
                cnt=0;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
//#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef pair<int,int> P;
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define lowbit(x) (x&-x)
const ll INF=0x3f3f3f3f;
const double EPS=1e-7;
const int N=2e5+10;
const ll mod=1e9+7;
inline ll read()
{  ll f=1,x=0;char ch=getchar();
   for(;ch>'9'||ch<'0';ch=getchar())if(ch=='-') f=-1;
   for(;ch<='9'&&ch>='0';ch=getchar()) x=x*10+ch-'0';
   return x*f;
}
ll n,k;
double a[N];
bool check(double mid)
{  ll cnt=0;
   for(ll i=1;i<=n;i++)
   {  if(a[i]<=mid)continue;
      ll q=ceil((a[i]-mid)/mid);
      //printf("q=%d\n",q);
      if(q)cnt=cnt+q;
      if(cnt>1000000000)return 0;
   }
   if(cnt>k)return 0;
   else return 1;
}
int main()
{  //printf("%lf",ceil(0.5/0.2-1.0));
   cin>>n>>k;
   for(int i=1;i<=n;i++)cin>>a[i];
   double l=0.000001,r=1e9+5,ans;
   for(int i=1;i<=200;i++)
   {  double mid=(l+r)/2;
      if(check(mid))
      {  r=mid;
      }
      else
      {  l=mid;
      }

   }
   printf("%.0lf\n",ceil(r));
}

Measured memory_bytes: 5364
#include <bits/stdc++.h>
using namespace std;
int main (){
    int N;
    bool ans=true;
    cin >> N;
    vector<vector<int>> v(N+1,vector<int>(3));
    v.at(0).at(0) =0;
    v.at(0).at(1) =0;
    v.at(0).at(2) =0;

    for(int i=1;i<=N;i++){
        cin >> v.at(i).at(0) >> v.at(i).at(1) >> v.at(i).at(2);
    }
    for(int i=0;i<=N;i++){
        if(v.at(i).at(0)%2==0 && (v.at(i).at(1)+v.at(i).at(2))%2 ==1){
            ans = false;
        }
        if(v.at(i).at(0)%2==1 && (v.at(i).at(1)+v.at(i).at(2))%2 ==0){
            ans = false;
        }
        if(i != N && abs(v.at(i+1).at(1)-v.at(i).at(1)) + abs(v.at(i+1).at(2)-v.at(i).at(2)) > v.at(i+1).at(0)-v.at(i).at(0))
        ans = false;
    }
    
    if(ans==true){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
}

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

using namespace std;

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ii> vii;

int n, k;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n;

	for (int i = 0; i <= 100; i++)
		for (int j = 0; j <= 100; j++)
			if (4 * i + 7 * j == n) {
				cout << "Yes" << endl;
				return 0;
			}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(x, n)              for (int x = 0; x < n; x++)
#define forr(x, n)              for (int x = n; x >= 0; x--)
#define fore(x, a, b, c)        for (int x = a; x <= b; x += c)
#define forre(x, a, b, c)       for (int x = a; x >= b; x -= c)
#define clr                     cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define all(container)          (container).begin(), (container).end()
#define rall(container)         (container).rbegin(), (container).rend()
#define FILL(x, val)            memset(x, val, sizeof(x))
#define sz(container)           ((int) (container).size())
#define pb                      push_back
#define eb                      emplace_back
#define fi                      first
#define se                      second
#define mod                     (ll)1000000007
#define INF                     (int)0x3f3f3f3f

using namespace std;

#ifdef LOCAL_DEFINE
    #include "../../CLionProjects/Codeforces/library/DEBUG.hpp"
#endif

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }  

typedef long long ll; 
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<long long, long long>> vpll;

void solve() {
    int n; cin >> n;
    int ans = 0;
    fore(i, 1, n, 1) fore(j, 1, n, 1) fore(k, 1, n, 1) ans += __gcd(i, __gcd(j, k));
    cout << ans << '\n';
}

int main(void) {    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in.txt", "r", stdin);
#endif
    int t = 1; 
//    cin >> t;
    while (t--)
        solve();
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << '\n';
#endif
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>

using namespace std;

int main()
{
	int a,b,c,d;
	int n;
	int cont = 0;
	
	while(cin >> n){
		cont = 0;
		for(int i = 0; i < 10; i++){
			for(int j = 0; j < 10; j++){
				for(int k = 0; k < 10; k++){
					for(int l = 0; l < 10; l++){
						if(i+j+k+l == n){
							cont++;
						}
					}
				}
			}
		}	
		cout << cont << endl;
	}
}

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


using namespace std;

const int maxn = 300010;

int n;

int A[maxn];

priority_queue<int> Q2;

priority_queue<int,vector<int>,greater<int> >Q1;

long long mx[maxn],mn[maxn];

void Work(){
	long long now=0;
	for(int i=1;i<=n*3;i++){
		Q1.push(A[i]);now+=A[i];
		if(i>n)now-=Q1.top(),Q1.pop();
		if(i>=n)mx[i]=now;
	}
	now=0;
	for(int i=n*3;i;i--){
		Q2.push(A[i]);now+=A[i];
		if(i<=n*2)now-=Q2.top(),Q2.pop();
		if(i<=n*2+1)mn[i]=now;
	}
	long long ans=-0x7f7f7f7f7f7f7f7f;
	for(int i=n;i<=n*2;i++)ans=max(ans,mx[i]-mn[i+1]);
	cout<<ans<<endl;
}

void Init(){
	scanf("%d",&n);
	for(int i=1;i<=n*3;i++)scanf("%d",&A[i]);
}

int main(){
	Init();
	Work();
	return 0;
}

Measured memory_bytes: 6520
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
typedef long long ll;
//max ll constant  = LLONG_MAX

using namespace std;


vector <vector <int>> A(100000, vector <int> (3));
vector <vector <int>> dp(100000, vector <int> (3, -1));

int idx,N;
int f,s,ans = -1;

int main() {
  cin >> N;
  for(int i = 0; i < N; i ++){
    cin >> A[i][0] >> A[i][1] >> A[i][2];
  }
  for(int j = 0; j < N; j++ ){
    f = s = -1;
    for(int n = 0; n < 3; n++){
      if(A[j][n] > f){
        f = A[j][n];
        idx = n; 
      }
    }
    if(j == 0){
      for(int x = 0; x < 3; x++){
        if(A[j][x] == f){
          dp[j][x] = f;
        }
      }
    }
    else{
      for(int n = 0; n < 3; n++){
        for(int r = 0; r < 3; r++){  
          if(r == n || dp[j-1][r] == -1){
            continue;
          }
          else{
            dp[j][n] = max(dp[j][n], A[j][n] + dp[j-1][r]);
          }
        }
      }
    }
  }
  // for(int u = 0; u < N; u++){
  //   cout << dp[u][0] << " " << dp[u][1] << " " << dp[u][2] << endl;
  // }
  for(int l = 0; l < 3; l++){
    if(dp[N-1][l] > ans){
      ans = dp[N-1][l];
    }
  }
  cout << ans;
}


Measured memory_bytes: 14348
#include<bits/stdc++.h>
#define int long long 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define ld long double
#define pii pair<int,int>
using namespace std;
signed main(){
    fast;
    int k;
    cin>>k;
    int ans = 0;
    for(int i = 1;i<=k;i++){
        for(int j = 1;j<=k;j++){
            for(int s = 1;s<=k;s++){
                ans+=__gcd(i,__gcd(j,s));
            }
        }
    }
    cout<<ans;
}

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

#define I inline void 

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

using namespace std ; 

const int N = 500 + 7 , mod = 1e9 + 7 ; 

int n; 

int main(){	
	ios_base::sync_with_stdio(0) ; 
	cin.tie(0) ; 
	ll x , k  ,d ; 
	ll ans = 1e18 ; 
	//freopen("in.in" , "r" , stdin) ;  

	cin >> x >> k >> d ; 
	x = abs(x) ; 

	ll mn = x / d ; 
	ll mn2 = (x + d -1 ) / d ; 
	mn = min(mn , k) ; 

	for(ll i = mn - 10 ; i <= mn + 10 ; i++){
		if(i >=0 && i <= k && i %2 == k %2 ){
			ans = min(ans , abs(x - i * d)) ; 
		}
	} 

	cout<< ans ; 

	return 0 ; 
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    string s, t;
    int n, a=0, b=0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s >> t;
        if (s < t) b += 3;
        else if (s > t) a += 3;
        else {
            a++;
            b++;
        }
    }
    printf("%d %d\n", a, b);

}


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

int main() {
  int K; cin >> K;
  int cnt = 0;
  for ( int i = 1; i <=K; i++ ) {
    for ( int j = i+1; j <= K; j++ ) {
      if ( (i % 2 == 0 && j % 2 == 1) ||
	   (i % 2 == 1 && j % 2 == 0 ) )cnt++;
    }
  }
    cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
import sys

# input = lambda : sys.stdin.readline().rstrip()

S = input()
n = len(S)

M = []
m = 0

for i in range(len(S)-1,-1, -1):
    
    m = (pow(10, n-i, 2019) * int(S[i]) + m) % 2019
    M.append(m)
    
    # print(S[i:n], m)

M.append(0)  # S[n:n] = "" = 0 が抜けるので、付け加える

c = Counter(M)

sum = 0
for i in c.values():
    sum += i * (i - 1) / 2

print(int(sum))

Measured memory_bytes: 16812
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, M): (usize, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let a: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    fn gcd(a: i64, b: i64) -> i64 { if b == 0 { a } else { gcd(b, a % b) } }

    let h = a[1..].iter().fold(a[0], |h, &x| if ((h - x) / 2) % gcd(h, x) == 0 {
        h / gcd(h, x) * x
    } else {
        0
    });
    let ans = if h > 0 && M >= h / 2 {
        1 + (M - h / 2) / h
    } else {
        0
    };

    println!("{}", ans);
}

Measured memory_bytes: 8444
import java.util.*;

public class Main{
    void run(){
        Scanner sc = new Scanner(System.in);
        while(true){
            int m = sc.nextInt();
            if(m==0){
                break;
            }
            int[] value = new int[m];
            int[] num = new int[m];
            for(int i = 0; i < m; i++){
                value[i] = sc.nextInt();
                num[i] = sc.nextInt();
            }
            int[] dp = new int[1001];
            dp[0] = 1;
            for(int i = 0; i < m; i++){
                for(int ii = 1000 - value[i]; ii >= 0; ii--){
                    for(int iii = 1; iii <= num[i]; iii++){
                        if(ii + value[i]*iii <= 1000){
                            dp[ii + value[i]*iii] += dp[ii];
                        }
                    }
                }
            }
            /*
              System.out.println(Arrays.toString(dp));
              for(int i = 0; i < 100; i++){
              System.out.println(i + " : " + dp[i]);
              }
            */
            int g = sc.nextInt();
            for(int i = 0; i < g; i++){
                System.out.println(dp[sc.nextInt()]);
            }
        }
    }
    public static void main(String[] args){
        new Main().run();
    }
}

Measured memory_bytes: 20704
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<long long, long long>;

int main() {
  long long N, M;
  vector<long long> a;
  cin >> N >> M;
  rep(i, N) {
    long long temp;
    cin >> temp;
    a.push_back(temp);
  }

  long long sum = 0;
  rep(i, a.size()) {
    sum += a[i];
  }

  sort(a.begin(), a.end());
  long long ans = 0;
  rep(i, M) {
    long long key = a[a.size()-1];
    long long m = (key + 1) / 2;
    ans += m;
    key -= m;
    vector<long long>::iterator ind;
    ind = lower_bound(a.begin(), a.end(), key);
    a.erase(a.end()-1);
    a.insert(ind, key);
  }

  // cout << ans << endl;

  ans = sum - ans;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4252
# include "bits/stdc++.h"
 
using namespace std;
 
#define endl "\n"
typedef long long int ll;
#define f first
#define s second
 
inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}
 
//DEBUG
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
 
ll INF = 1e10;
int MOD = 1e9+7;

int main(){
    fastio();

    int n;
    cin >> n;
    int a[n + 1];
    for(int i = 1; i <= n; ++i)
    	cin >> a[i];
    int b[n + 1];
    for(int i = 1; i <= n; ++i)
    	cin >> b[i];
    int c[n];
    for(int i = 1; i < n; ++i)
    	cin >> c[i];

    int sum = 0;
    int prev = -2;
    for(int i = 1; i <= n; ++i){
    	dbg(prev);
    	sum += (b[a[i]]);
    	if(prev + 1 == a[i]){
    		sum += c[a[i] - 1];
    	}
    	prev = a[i];
    }

    cout << sum;
    return 0;
}

/*

*/

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#pragma GCC optimize("O999")
using namespace std;
int main()
{
 	ios::sync_with_stdio(0);
 	int f=0,ff=0;
	string s;
	getline(cin,s);
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='C')
		f=1;
		
		if(f==1&&s[i]=='F')
		ff=1;
	 } 
	if(ff==1)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main() {
    ll N, Z, W; 
    cin >> N >> Z >> W;
    vector<ll> a(N);
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    if(N==1) cout << abs(a[0]-W) << endl;
    else{
        cout << max(abs(a[N-1]-W), abs(a[N-1]-a[N-2])) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N, A = map(int, input().split(' '))
import collections

X = [int(a) - A for a in input().split(' ')]
sum_positives = sum([x for x in X if x > 0])
sum_negatives = sum([x for x in X if x < 0])

dp = [dict([(i, 0) for i in range(sum_negatives, sum_positives+1)])
            for _ in range(N+1)]
dp[0][0] = 1

for i, x in enumerate(X):
    for j in range(sum_negatives, sum_positives+1):
        dp[i + 1][j] = dp[i][j]
        if (j - x) in dp[i]:
            dp[i + 1][j] += dp[i][j - x]

# for d in dp:
#     print(d)

print(dp[N][0] - 1)
exit()


Measured memory_bytes: 51824
import std.stdio;
import std.string;
import std.array;
import std.conv;

bool isRightTriangle(int a, int b, int c) {
  int a2 = a * a;
  int b2 = b * b;
  int c2 = c * c;

  return a2 + b2 == c2 || b2 + c2 == a2 || c2 + a2 == b2;
}

void main() {
  uint n = to!uint(chomp(readln()));

  int[][] data;
  for(uint i = 0; i < n; i++) {
    auto input = split(readln());

    data ~= [to!int(input[0]), to!int(input[1]), to!int(input[2])];
  }

  foreach(tri; data) {
    if(isRightTriangle(tri[0], tri[1], tri[2])) writeln("YES");
    else writeln("NO");
  }  
}

Measured memory_bytes: 1104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}


int main(){
    string s; cin >> s;
    int n = s.length();
    int j = n-1;
    for(int i = 0; i < j; i++){
        if(s[i] != s[j]){cout << "No" << endl; return 0;}
        j--;
    }
    j = (n-1)/2-1;
    for(int i = 0; i < j; i++){
        if(s[i] != s[j]){cout << "No" << endl; return 0;}
        j--;
    }
    for(int i = ((n+3)/2)-1; i < j; i++){
        if(s[i] != s[j]){cout << "No" << endl; return 0;}
        j--;
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int H,W,D;
  cin>>H>>W>>D;
  int x[H*W],y[H*W];
  REP(i,H)REP(j,W){
    int A;
    cin>>A;
    A--;
    x[A]=i;
    y[A]=j;
  }
  int S[H*W];
  REP(i,H*W)S[i]=0;
  FOR(i,D,H*W)S[i]=S[i-D]+abs(x[i]-x[i-D])+abs(y[i]-y[i-D]);
  int Q;
  cin>>Q;
  int L[Q],R[Q];
  REP(i,Q){
    cin>>L[i]>>R[i];
    L[i]--;R[i]--;
  }
  REP(i,Q)cout<<S[R[i]]-S[L[i]]<<endl;
  // REP(i,H*W)cerr<<S[i]<<endl;
  return 0;
}


Measured memory_bytes: 2944
#include<cstdio>
#include<iostream>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;

	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else cout << "Impossible" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s, t;
  cin >> s >> t;
  int S = s.size(), T = t.size();
  vector<vector<int>> DP(S + 1, vector<int>(T + 1, 0));
  for (int i = 1; i <= S; i++) {
    for (int j = 1; j <= T; j++) {
      if (s.at(i - 1) == t.at(j - 1)) {
        DP.at(i).at(j) = max(DP.at(i - 1).at(j - 1) + 1, DP.at(i).at(j));
      }
      DP.at(i).at(j) = max(DP.at(i).at(j), DP.at(i - 1).at(j));
      DP.at(i).at(j) = max(DP.at(i).at(j), DP.at(i).at(j - 1));
    }
  }
  string ans = " ";
  while (S > 0 && T > 0) {
    if (DP.at(S).at(T) == DP.at(S - 1).at(T)) {
      S--;
    }
    else if (DP.at(S).at(T) == DP.at(S).at(T - 1)) {
      T--;
    }
    else {      
      ans = s.at(S - 1) + ans;
      S--;
      T--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 38908
#include <bits/stdc++.h>
#define pb  push_back
using namespace std;

typedef pair<int,int>  PII;
int n,a[2010],e[2010][2010],vis[2010];

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

vector <int> solve(int x)
{
	int m=0;
	vector <vector <int> > V;
	vector <vector <int> ::iterator> h;
	vector <int> r;
	vis[x]=1;
	for (int y=1; y<=n; y++)
		if ((e[x][y])&&(!vis[y]))
			V.pb(solve(y)),h.pb(V[m].begin()),m++;
	r.pb(a[x]);
	while (1)
		{
			int x=-1;
			for (int i=0; i<m; i++)
				if ((h[i]!=V[i].end())&&((x<0)||(*h[i]>*h[x])))
					x=i;
			if (x<0)  return r;
			r.pb(*h[x]),h[x]++;			
		}
}

void work()
{
	scanf("%d",&n);
	for (int i=1; i<=n; i++)  scanf("%d",&a[i]),e[0][i]=1;
	sort(a+1,a+n+1);
	for (int i=1; i<=n; i++)
		for (int j=i+1; j<=n; j++)
			if (gcd(a[i],a[j])!=1)
				e[i][j]=e[j][i]=1;
	vector <int> ans=solve(0);
	for (int i=1; i<=n; i++)  printf("%d ",ans[i]);
}

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


Measured memory_bytes: 16384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    string s; cin >> s;
    int n = s.size();
    string t;
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    rep(i,n-1){
        if(s[i] == 'B' && s[i+1] == 'C'){
            t += 'D';
            i++;
        }
        else t += s[i];
    }
    if(s[n-1] != 'C' || s[n-2] != 'B') t += s[n-1];

    int m = t.size();
    int cnt = 0;
    ll ans = 0;
    rep(i,m){
        if(t[i] == 'A') cnt++;
        else if(t[i] == 'D') ans += cnt;
        else cnt = 0;
    }
    cout << ans << endl;
}



Measured memory_bytes: 776
#include <bits/stdc++.h>
#define pb emplace_back
#define mp make_pair
#define int long long

using namespace std;

int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10);
	string s; cin >> s;
	int in = 0;
	int cnt = 0;
	for (int i = 0; i < s.size(); ++i)
	{
		if (s[i] == 'W')
		{
			cnt += (i - in);
			in++;
		}
	}
	cout << cnt;
}

Measured memory_bytes: 720
N = int(input())
a = list(map(int, input().split()))

dic = {}
for n in a:
    dic.setdefault(n, 0)
    dic[n] += 1

s = 0
for k, v in dic.items():
    if k < v:
        s += v-k
    elif k > v:
        s += v

print(s)


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

/*
 *
 * */

int main() {
    int A, B;
    cin >> A >> B;

    int ans = 0;
    if(B%A == 0) {
        ans = A + B;
    }else{
        ans = B-A;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  cout<<n-k+1;
  return(0);
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;

public class Main {

	static BufferedReader br;
	static String defSizeAry[];
	static int H;
	static int W;
	static char map[][];
	static boolean visited[][];
	static int x = 0;
	static int y = 0;

	public static void main(String[] args) throws Exception {

		br = new BufferedReader(new InputStreamReader(System.in));

		while(true) {
			defSizeAry = br.readLine().split(" ");
			H = Integer.parseInt(defSizeAry[0]);
			W = Integer.parseInt(defSizeAry[1]);

			if (H == 0 && W == 0) {
				return;
			}

			map = new char[H][W];
			visited = new boolean[H][W];


			for (int i = 0; i < H; i++) {
				String line = br.readLine();
				for (int j = 0; j < W; j ++) {
					map[i][j] = line.charAt(j);
				}
			}

			solve();

			if (x == -1 && y == -1) {
				System.out.println("LOOP");
			} else {
				System.out.println(x + " " + y);
			}
		}
	}

	private static void solve() {

		// initialize
		x = 0;
		y = 0;
		for (int i = 0; i < H; i ++) {
			for (int j = 0; j < W; j ++) {
				visited[i][j] = false;
			}
		}

		while(true) {

			if (visited[y][x] == true) {
				x = -1;
				y = -1;
				return;
			}

			switch (map[y][x]) {
			case '>':
				visited[y][x] = true;
				x++;
				break;
			case '<':
				visited[y][x] = true;
				x--;
				break;
			case '^':
				visited[y][x] = true;
				y--;
				break;
			case 'v':
				visited[y][x] = true;
				y++;
				break;
			case '.':
				return;
			}
		}
	}
}

Measured memory_bytes: 24868
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
  int A, B;
  cin >> A >> B;
  cout << max(A + B, max(A - B, A * B)) << endl;
}


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

using namespace std;

int n, x, y, b, p;

void solve(){
	cin >> x >> y >> b >> p;
	int res = x * b + y * p;
	res = min((x * max(5, b) + y * max(2, p)) * 4 / 5, res);
	cout << res << endl;
}

int main(){
	cin >> n;
	while(n--)solve();
	return 0;
}

Measured memory_bytes: 1164
<?php
  $ary = array();
  while (true) {
    $st = trim(fgets(STDIN));
    if ($st == "0") {
      break;
    }
    array_push($ary, $st);
  }
  $i = 1;
  $count = count($ary);
  foreach ($ary as $val) {
    print ("Case " . $i . ": " . $val);
    if ($i < $count) {
      print "\n";
    }
    $i++;
  }
  unset($val);
?>

Measured memory_bytes: 8368
#include <bits/stdc++.h>
using namespace std;
 
int main() {

	int N,R=0,L=0,work=0;
	cin >> N;
	vector<int> A(N);
	for (int i=0; i<N; i++){
		cin >> A.at(i);
		L += A.at(i);
	}	
	
	sort(A.begin(),A.end());
	
	for (int i=(N-1) % 2; i<N; i +=2){
		R += A.at(i);
	}
	cout << R*2-L << endl;
	
}

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

int GCD(int a, int b)
{
    int asw = 1;
    int tmp;
    if (a > b) {
        while (b >= asw) {
            if (!(b % asw)) {
                tmp = b / asw;
                if (!(a % tmp))
                    break;
            }
            asw++;
        }
    } else {
        while (a >= asw) {
            if (!(a % asw)) {
                tmp = a / asw;
                if (!(b % tmp))
                    break;
            }
            asw++;
        }
    }
    return tmp;
}

int LCM(int a, int b)
{
    int asw;
    if (a < b) {
        asw = b;
        while (asw % a)
            asw += b;
    } else {
        asw = a;
        while (asw % b)
            asw += a;
    }
    return asw;
}

int main()
{
    int a, b;
    while ((cin >> a >> b)) {
        cout << GCD(a, b) << ' ' << LCM(a, b) << endl;
    }
}

Measured memory_bytes: 3032
N=int(input())
alpha=["a","b","c","d","e","f","g","h","i","j","k","l"]
now=["a"]
next_list=[]
for _ in range(N-1):
    for check in now:
        count = len(set(check))

        # くっつくける
        for add in range(count+1):
            next_list.append(check + alpha[add])

    now = next_list[:]
    next_list=[]

for a in now:
    print(a)


Measured memory_bytes: 57180
import heapq

_ = int(input())
a = list(map(int, input().split()))

heapq.heapify(a)

x = 0
y = 0

for i in range(len(a)):
    if i % 2 == 0:
        x += heapq.heappop(a)
    else:
        y += heapq.heappop(a)

print(abs(x - y))



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

  int main()
  {
    int k, x;
	cin >> k >> x;
    if(k > 1){
      for(int i = k - 1;i > 0; i--) cout << x - i << " ";
      rep(i, k) cout << x + i << " ";
    }
    else if(k == 1)
    {
    	cout << x << endl;
    }
    return 0;
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll MAX=303;
ll c[MAX][MAX],N,K,M,dp[MAX][MAX],dps[MAX][MAX];
ll comb(ll x,ll y){
    if(y==x||y==0) return 1;
    if(c[x][y]==-1){
        c[x][y]=(comb(x-1,y-1)+comb(x-1,y))%M;
    }
    return c[x][y];
}
int main(){
    scanf("%lld%lld%lld",&N,&K,&M);
    for(int i=0;i<=N;i++) for(int j=0;j<=N;j++) c[i][j]=-1;
    for(int i=0;i<=K;i++) dp[1][i]=1,dps[1][i]=K-i  ;
    for(int i=2;i<=N+1;i++){
        for(int j=K;j>=0;j--){
            // dp[i][j]
            for(int l=1;l<=i-1;l++){
                ll t=dp[l][j]*comb(i-2,l-1)%M;
                dp[i][j]+=t*dps[i-l][j];
                dp[i][j]%=M;
            }
            dps[i][j-1]=(dps[i][j]+dp[i][j])%M;
        }
    }
    printf("%lld\n",dp[N+1][0]);
}


Measured memory_bytes: 2432
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 110000;
int a[maxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n, m;
    cin >> n >> m;
    forn(i, m) {
        int x, y;
        cin >> x >> y;
        --x; --y;
        a[x] ^= 1;
        a[y] ^= 1;
    }

    cout << (*max_element(a, a + n) == 0 ? "YES" : "NO") << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 1276
import math
import copy
import sys

inputa = input().split()
# inputb = input().split()
# inputc = input().split()

# a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])

# x = int(inputb[0])
# y = int(inputb[1])

inputaList = [int(n) for n in inputa]

# inputb = input().split()
# inputbList = [int(n) for n in inputb]
#
# inputList = []
# inputNumList = []
# for i in range(a):
#     inputNum = input().split()
#     inputNumList = list(inputNum[0])
#     inputList.append(inputNumList)

# inputList = [int(n) for n in inputList]

# b = [int(n) for n in inputb]
# c = [int(n) for n in inputc]

x1 = inputaList[0]
y1 = inputaList[1]
x2 = inputaList[2]
y2 = inputaList[3]

edgeDisx = x2 - x1
edgeDisy = y2 - y1

x3 = x2 - edgeDisy
y3 = y2 + edgeDisx
x4 = x1 - edgeDisy
y4 = y1 + edgeDisx

print(x3, y3, x4, y4)


















Measured memory_bytes: 3572
n,x=map(int,input().split())
if x==1 or x==2*n-1:
  print('No')
elif x==2:
  print('Yes')
  if n==2:
    print(x+1)
    print(x)
    print(x-1)
  else:
    ans=[]
    for i in range(1,2*n):
      if x-1<=i<=x+2:
        continue
      else:
        ans.append(i)
    cnt=0
    for i in range(1,2*n):
      if i==n-1:
        print(x+1)
      elif i==n:
        print(x)
      elif i==n+1:
        print(x-1)
      elif i==n+2:
        print(x+2)
      else:
        print(ans[cnt])
        cnt+=1
else:
  print('Yes')
  if n==2:
    print(x+1)
    print(x)
    print(x-1)
  else:
    ans=[]
    for i in range(1,2*n):
      if x-2<=i<=x+1:
        continue
      else:
        ans.append(i)
    cnt=0
    for i in range(1,2*n):
      if i==n-1:
        print(x-2)
      elif i==n:
        print(x)
      elif i==n+1:
        print(x+1)
      elif i==n+2:
        print(x-1)
      else:
        print(ans[cnt])
        cnt+=1

Measured memory_bytes: 12496