akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool> vecbool;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<string> vecstr;
typedef vector<vecint> vec2int;
typedef vector<vecbool> vec2bool;
int dx[4]{-1, +1, 0, 0};
int dy[4]{0, 0, -1, +1};

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int main() {
  init();
  int n;
  cin >> n;
  vec2int g(n, vecint(n, 0));
  REP(i, n) REP(j, n) cin >> g[i][j];
  vecll dp(vecll((1 << n), 0));
  dp[0] = 1;
  vector<set<int> > bv(n + 1);
  for (int bit = 0; bit < (1 << n); bit++) {
    bv[__builtin_popcount(bit)].insert(bit);
  }
  REP(i, n) {
    for (auto& bit : bv[i]) {
      for (int j = 0; j < n; j++) {
        if (!((1 << j) & bit) && g[i][j] == 1) {
          dp[(bit | 1 << j)] += dp[bit];
          if (dp[(bit | 1 << j)] > MOD) dp[(bit | 1 << j)] %= MOD;
        }
      }
    }
  }
  cout << dp[(1 << n) - 1] << endl;
}


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

using namespace std;

bool a[10000];

int main()
{
	int n, k;

	cin >> n >> k;


	for (int i = 1; i <= n; ++i)
	{
		a[n] = false;
	}

	for (int i = 0; i < k; ++i)
	{
		int d;
		cin >> d;
		for (int j = 0; j < d; ++j)
		{
			int tmp;
			cin >> tmp;
			a[tmp] = true;
		}
	}


	int ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (!a[i])
		{
			++ans;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;
int main(){
	int n;
	while(cin>>n&&n){
		double a[n];
		double sum=0;
		for(int i=0;i<n;i++){
			cin>>a[i];
			sum+=a[i];
		}
		double ave=sum/n;
		double ans=0;
		for(int i=0;i<n;i++){
			ans+=(a[i]-ave)*(a[i]-ave); 
		}
		ans=sqrt(ans/n);
		printf("%0.8f\n",ans);
	}
	return 0;
} 


Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  int k;
  string s;
  cin >> k >> s;
  if(s.size() <= k) cout << s << endl;
  else{
    cout << s.substr(0,k) << "..." << endl;
  }
}

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

using namespace std;

const int MAX_N = 100000, INDEX = 1;
const int INF = 2000000001;

int n, c, k, t[MAX_N + 1 + INDEX];

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

    cin >> n >> c >> k;

    for (int i = 1; i <= n; i++) {
        cin >> t[i];
    }

    t[n + 1] = INF;

    sort(t + INDEX, t + INDEX + n, less<int>());

    int ans = 0, last = n + 1;
    for (int i = n; i >= 1; i--) {
        if (last - i >= c || t[last] - t[i] > k) {
            ans++, last = i;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;


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

    int N, K;
    cin >> N >> K;
    vi A(N), B(N);
    rep(i, N)cin >> A[i] >> B[i];

    ll ans = 0;

    auto f = [&](ll x) {
        ll res = 0;
        rep(i, N) {
            int ok = 1;
            rep(j, 30)if (!(x >> j & 1) && (A[i] >> j & 1)) {
                ok = 0;
                break;
            }
            if (ok)res += B[i];
        }
        return res;
    };

    ans = f(K);
    for (int i = 1; i < 30; ++i)if (K >> i & 1) {
        ll x = (K ^ (1 << i)) | ((1 << i) - 1);
        smax(ans, f(x));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1152
#include <stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h> 
typedef unsigned long long ll;
#define length 100000   //10万
#define kw_len 10
ll factor[300];
ll memory[300]; 
/*素朴法で計算
factorは必ずmemset(factor,0,sizeof(factor));
グローバルであるmemoryに個数を書き込む
memory配列の走査にはfactorの要素を使う*/
void primefac(ll num){
    int i = 0,kosuu=0;
    while(*(factor+i) != 0){
        while(num % *(factor+i)==0){
            num /= *(factor+i);
            memory[*(factor+i)] +=1;
        }
        if(num==1)break;
        i++;
    }
}
/*グローバルにあるfactorに素数書き込む.個数を返すので配列は-1しろ*/
int elast(ll number){    
    ll tmp=0;
    int flag=0;
    *factor = 2;
    for(int i=3;i <= number;i++){
        flag=0;
        for(int j=0;j <= tmp ;j++){
            if(i % (*(factor+j)) == 0){
                flag=1;
                break;
            }
        }
        if(flag)continue;
        tmp += 1;
        *(factor+tmp) = i;
    }
        return tmp+2;
}

int compare(const int*a,const int *b){
    if(*a<*b)
      return -1;
    else if(*a>*b)
      return 1;
    return 0;
}

ll nCr(int n,int r){
  ll val=1;
  int i;
  if(r==0)return 1;
  for(i=0;i<n-r;i++){
		val *= (n-i);
		val /= (i+1);
	}
  return val;
}

ll nPr(int n,int r){
  ll val=1;
  int i;
  for(i=0;i<r;i++){
    val *= (n-i);
  }
  return val;
}
/*
qsort(array,length,sizeof(int),(int(*)(const int*, const int*))compare);
使う時これをコピペ
*/
int main(){
    int array[length];
    int N,K,i,j,A,B;
    int *inp;
    char *chp;
    ll sum=0;
    scanf("%d%d",&A,&B);
    if((A>0)&&(B>0)){
        if((10>A)&&(10>B)){
            printf("%d",A*B);
            return 0;
        }
    }
    printf("%d",-1);

    return 0;
}


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

// macros
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define INT_IN(a) int a; cin >> a
#define STR_IN(s) string s; cin >> s
#define PRINTLN(s) cout << s << endl
#define PRINTDOUBLELN(s) cout << setprecision(12) << (s) << endl;

// util functions
template<class T> inline T sqr(T x) {return x*x;}

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

template <typename T>inline T max(vector<T> v){T max=v[0]; FOR(i, 1, v.size())max=MAX(v[i], max); return max;}
template <typename T>inline T min(vector<T> v){T min=v[0]; FOR(i, 1, v.size())min=MIN(v[i], min); return min;}
template <typename T>inline vector<T> concat(vector<T> a, vector<T> b){vector<T> ab; ab.reserve(a.size()+b.size());ab.insert(ab.end(),a.begin(),a.end());ab.insert(ab.end(),b.begin(),b.end());return ab;}

// types
typedef long long LL;

// consts
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//debug
#define dump(x)  #x << " = " << (x) << endl
#define debug(x) #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

int main(){
    char op;
    while(true){
        INT_IN(a);
        cin >> op;
        if(op == '?') break;
        INT_IN(b);
        PRINTLN((op == '+' ? a + b :
                 op == '-' ? a - b :
                 op == '*' ? a * b : a / b));
    }
   return 0;
}

Measured memory_bytes: 3076
/**Bismillahir Rahmanir Rahim.**/
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;
#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  ll               long long
#define  vi               std::vector<int>
#define  pb               push_back
#define  MAX              100007
#define  End              return 0;
#define                   pi acos(-1)
map<string,int>mp;

int main () {
    int n,m;
    cin>>n>>m;
    if(m%2!=0 || 2*n>m || 4*n<m) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    End
}
/* pray for me
Do before die
*/


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 100;
ll c[N];

struct Node {
    int x, h;
    inline bool operator < (const Node& t) const {
        return x < t.x;
    }
} p[N];

int main()
{
    int n, a, d;
    cin >> n >> d >> a;
    for(int i = 1; i <= n; ++i)
        cin >> p[i].x >> p[i].h;
    sort(p + 1, p + n + 1);
    
    ll ans = 0;
    // 双指针
    for(int i = 1, j = 1; i <= n; ++i) {
        while(j <= n && p[j].x <= p[i].x + 2 * d) ++j;
        ll need = max((p[i].h - c[i] * a + a - 1) / a, 0ll);
        ans += need;
        // 构造差分序列
        c[i] += need;
        c[j] -= need;
        c[i + 1] += c[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>

int main() {
  int N;
  int B[101];
  int S[101];
  int tmp=0;
  scanf("%d\n",&N);
  for (int i = 0; i < N-1; i++) {
    scanf("%d",&B[i]);
  }
//ここまで入力

  S[0]=B[0];
  S[N-1]=B[N-2];
  if (N>2) {
    for (int i = 1; i < N-1; i++) {
      if (B[i]>=B[i-1]) {
        S[i]=B[i-1];
      }else{
        S[i]=B[i];
      }
    }
  }
  for (int i = 0; i < N; i++) {
  tmp = tmp+S[i];
  }
  printf("%d",tmp);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF INT_MAX
#define MINF INT_MIN
#define ll long long
#define PB push_back 
#define PF push_front
#define P_F pop_front
#define P_B pop_back
#define F front
#define B back
#define MP make_pair
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define forit(i, s) for(__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define foritr(i, s) for(__typeof ((s).rend ()) i = (s).rbegin (); i != (s).rend (); ++i)
 
using namespace std;

int main() {
  ll n, wei;
  cin >> n >> wei;
  ll dp[n][wei+1];
  vector<int> pesos(n), valores(n);
  
  FOR(i, 0, n)
    cin >> pesos[i] >> valores[i];
    
  FOR(i, 0, wei+1){
    if(pesos[0] <= i)
      dp[0][i] = valores[0];
    else
      dp[0][i] = 0;
  }
  
  FOR(i, 1, n){
    FOR(j, 0, wei+1){
      if(pesos[i] <= j){
        dp[i][j] = max(dp[i-1][j], valores[i] + dp[i-1][j - pesos[i]]);
      }else
        dp[i][j] = dp[i-1][j];
    }
  }
  
  cout << dp[n-1][wei] << "\n";

  return 0;
}

Measured memory_bytes: 81716
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (w, h, n) = listOfInt()
    var x1 = 0
    var y1 = 0
    var x2 = w
    var y2 = h

    repeat(n, {
        val (x, y, a) = listOfInt()
        when(a) {
            1 -> if (x1 < x) x1 = x
            2 -> if (x2 > x) x2 = x
            3 -> if (y1 < y) y1 = y
            else -> if (y2 > y) y2 = y
        }
    })

    if (x2 <= x1 || y2 <= y1) {
        println(0)
    } else {
        println((x2-x1)*(y2-y1))
    }
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 38008
#include<stdio.h>

int main(void){
  char s[4];
  int i;
  int a_count=0,b_count=0,c_count=0;
  scanf("%s",s);
  for(i=0;i<4;i++){
    if('a'==s[i]) a_count++;
  }
  for(i=0;i<4;i++){
    if('b'==s[i]) b_count++;
  }
  for(i=0;i<4;i++){
    if('c'==s[i]) c_count++;
  }
  if(a_count==1 && b_count==1 && c_count==1) printf("Yes");
  else printf("No");
  
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int k = parseInt(sc.next());
		long r = parseLong(sc.next());
		long s = parseLong(sc.next());
		long p = parseLong(sc.next());
		char[] t = sc.next().toCharArray();
		sc.close();
		long total=0;
		for (i = 0; i < n; i++) {
			switch(t[i]) {
			case 'r':
				total+=p;
				break;
			case 's':
				total+=r;
				break;
			case 'p':
				total+=s;
				break;
			}
		}
		for (i = k; i < n; i++) {
			if(t[i]==t[i-k]) {
				switch(t[i]) {
				case 'r':
					total-=p;
					break;
				case 's':
					total-=r;
					break;
				case 'p':
					total-=s;
					break;
				}
				t[i]='x';
			}
		}
		out.println(total);
	}
}


Measured memory_bytes: 30620
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstdio>
#include<vector>
#define LL long long 
using namespace std;

const int maxn=200005;
struct line
{
	int p,len;
}l[maxn];
vector<string>str;
int n;
bool cmp(line a,line b)
{
	return a.len<b.len;
}
struct trie
{
	int ch[26],num[26];
}tr[1000005];
int bag[26],root,cnt;
LL ans;
string a;
void query(int x,int p)
{
	int i;
	if(!x||p==-1) return;
	for(i=0;i<26;i++)
		if(bag[i]&&tr[x].num[i])
			ans+=tr[x].num[i];
	bag[a[p]-'a']--;
	query(tr[x].ch[a[p]-'a'],p-1);
}
void ins(int &x,int p)
{
	if(!x) x=++cnt;
	if(p==0)
	{
		tr[x].num[a[p]-'a']++;
		return;
	}
	ins(tr[x].ch[a[p]-'a'],p-1);
}
int main()
{
	int i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		cin>>a;
		l[i].p=i;
		l[i].len=a.length();
		str.push_back(a);
	}
	sort(l,l+n,cmp);
	for(i=0;i<n;++i)
	{
		a=str[l[i].p];
		memset(bag,0,sizeof bag);
		int len=l[i].len;
		for(j=0;j<len;++j)
			bag[a[j]-'a']++;
		query(root,len-1);
		ins(root,len-1);
	}
	printf("%lld",ans);
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;
int n;
int l;
int check(vector<int >&v){
  if(v[0]>=0){
    return v[0];
  }
  if(v[n-1]<0){
    return v[n-1];
  }
  REP(i,n){
    if(v[i]==0)return v[i];
  }
}
int main(){
  cin>>n>>l;
  vector<int > v(n);
  int sum=0;
  REP(i,n){
    v[i]=l+i;
    sum+=v[i];
  }
  //cout<<sum<<endl;
  sum-=check(v);
  cout<<sum<<endl;
}


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

using namespace std;

typedef long long ll;

ll n, luu;

int main()
{
  	ios_base::sync_with_stdio(false);
  	cin.tie(NULL); cout.tie(NULL);
  	cin >> n;
  	luu = n % 10;
  	if (luu == 2 || luu == 5 || luu == 4 || luu == 7 || luu == 9) cout << "hon";
  	else if (luu == 0 || luu == 1 || luu == 6 || luu == 8) cout << "pon";
  	else cout << "bon";
}

Measured memory_bytes: 3692
K = int(input())
print(50)
s, t = K//50, K%50
ANS = [ s + i for i in range(50)]
for j in range(t):
    for i in range(50):
        if j == i:
            ANS[i] += 50
        else:
            ANS[i] -= 1
print(" ".join( map( str, ANS)))

Measured memory_bytes: 3060
package main

import (
  "bufio"
  "container/heap"
  "fmt"
  "os"
  "strconv"
  "strings"
)

const INF int64 = 1001001001001001001

func main() {
  io := IO{bufio.NewReaderSize(os.Stdin,100),bufio.NewWriterSize(os.Stdout,100)}
  n,m := io.Next2Ints()
  g := NewGraph(n)
  for i:=n-1;i>0;i-- { g.Add(i,i-1,0) }
  for i:=0;i<m;i++ {
    l,r,c := io.Next3Ints()
    g.Add(l-1,r-1,int64(c))
  }
  d := g.Dijkstra(0)
  if d[n-1] == INF { d[n-1] = -1 }
  io.Println(d[n-1])
  io.Flush()
}

type Item struct {
  id int
  wt int64
}

type PriorityQueue []*Item
func(pq PriorityQueue) Len() int { return len(pq) }
func(pq PriorityQueue) Less(i,j int) bool { return pq[i].wt < pq[j].wt }
func(pq PriorityQueue) Swap(i,j int) { pq[i],pq[j] = pq[j],pq[i] }
func(pq *PriorityQueue) Push(x interface{}) {
  item := x.(*Item)
  *pq = append(*pq,item)
}
func(pq *PriorityQueue) Pop() interface{} {
  old := *pq
  n := len(old)
  item := old[n-1]
  *pq = old[0:n-1]
  return item
}

type Graph [][]Item
func NewGraph(n int) Graph { return make([][]Item,n) }
func(g Graph) AddEdge(from int,item Item) { g[from] = append(g[from],item) }
func(g Graph) Add(from,to int,wt int64) { g.AddEdge(from,Item{to,wt}) }
func(g Graph) Dijkstra(s int) []int64 {
  n := len(g)
  d := make([]int64,n)
  for i:=0;i<n;i++ { d[i] = INF }
  d[s] = 0
  var pq PriorityQueue
  heap.Init(&pq)
  heap.Push(&pq,&Item{s,d[s]})
  for pq.Len() > 0 {
    i := heap.Pop(&pq).(*Item)
    if i.wt > d[i.id] { continue }
    for _,e := range g[i.id] {
      if d[e.id] > i.wt+e.wt {
        d[e.id] = i.wt+e.wt
        heap.Push(&pq,&Item{e.id,d[e.id]})
      }
    }
  }
  return d
}

type IO struct {
  reader *bufio.Reader
  writer *bufio.Writer
}
func(io *IO) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := io.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(io *IO) Println(a ...interface{}) (int,error) {
  return fmt.Fprintln(io.writer,a...)
}
func(io *IO) Flush() error {
  return io.writer.Flush()
}
func(io *IO) Next2Ints() (int,int) {
  s := strings.Fields(io.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  return x,y
}
func(io *IO) Next3Ints() (int,int,int) {
  s := strings.Fields(io.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  z,_ := strconv.Atoi(s[2])
  return x,y,z
}

Measured memory_bytes: 13568
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n)cin >> a[i];
    int d[n];
    int v=0;
    rep(i,n){
        v += pow(-1,i)*a[i];
    }
    d[0] = v;
    rep(i,n){
        if(!i)continue;
        d[i]=2*a[i-1]-d[i-1];
    }
    rep(i,n)cout << d[i] << " ";
    cout << endl;
}

Measured memory_bytes: 2048
#include <cstdio>
#include <cmath>
int n;
double x[1005], y[1005], X, Y, d, e;
double dist(double a, double b) {
  return a*a + b*b;
}
int main() {
 
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lf%lf", &x[i], &y[i]);
    X += x[i]; Y += y[i];
  }
  X /= n; Y /= n;
  double P = 0.1;
  for (int i = 0; i < 30000; i++) {
    int f = 0;
    d = dist(X - x[0], Y - y[0]);
    for (int j = 1; j < n; j++) {
      e = dist(X - x[j], Y - y[j]);
      if (d < e) { d = e; f = j; }
    }
    X += (x[f] - X)*P;
    Y += (y[f] - Y)*P;
    P *= 0.999;
  }
  printf("%.12lf",  sqrt(d));
}

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

template <typename T>
void print_vec(vector<T> v) {
  for (T i : v) cout << i << " ";
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  vector<int> w(n);
  rep(i, n) {
    cin >> w[i];
    if (i > 0) w[i] += w[i - 1];
  }

  int ans = INF;
  rep(i, n) {
    int a = w[i];
    int b = w[n-1] - w[i];
    ans = min(ans, abs(b - a));
  }
  cout << ans << endl;
  return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine();

        switch (input)
        {
            case "SUN":
                Console.WriteLine(7);
                break;
            case "MON":
                Console.WriteLine(6);
                break;
            case "TUE":
                Console.WriteLine(5);
                break;
            case "WED":
                Console.WriteLine(4);
                break;
            case "THU":
                Console.WriteLine(3);
                break;
            case "FRI":
                Console.WriteLine(2);
                break;
            case "SAT":
                Console.WriteLine(1);
                break;
            default:
                break;
        }
    }
}


Measured memory_bytes: 13152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dbl;
#define sqr(int) (int * int)
#define sqr3(int) (int * int * int)
#define pi M_PI
#define nl "\n"
#define vi vector<int>
#define vc vector<char>
#define vll vector<ll>
#define vd vector<dbl>
#define vf vector<float>
#define vs vector<string>

void solve(){
	int a,b;
	cin >> a >> b;
	if(a >= b){
		for(int i = 0; i<a; i++){
			cout << b;
		}
	}
	else if(b >= a){
		for(int i = 0; i<b; i++){
			cout << a;
		}
	}
	
}







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




Measured memory_bytes: 3660
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
ll pow_ex(int i){
  if(i<=0){
    return 1;
  }else{
    return pow(2,i);
  }
}
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string s;cin>>s;
  // 登場する数の列挙
  ll num;
  ll count=0;
  int l=s.size();
  REP(i,l){
    for(int j=i;j<l;j++){
      num=stoll(s.substr(i,j-i+1));
      // numで列挙はできてる
      count+=num*pow_ex(i-1)*pow_ex(l-j-2);
    }
  }
  // P(pow(2,-1));
  P(count);
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

char s[20000];
int n;

int solve(int i){
    if(s[i + 1] >= '0' && s[i + 1] <= '9'){
        return atoi(&s[i + 1]) / 2 + 1;
    }

    int m[10000];
    i++;int j = 0;
    while(s[i] == '['){
        m[j++] = solve(i);
        i++;
        int q = 1;
        while(q > 0 /*&& (s[i] >= '0' && s[i] <= '9') || s[i] == '[' || s[i] == ']'*/){
            if(s[i] == '[')
                q++;
            if(s[i] == ']')
                q--;
            i++;
        }
    }
    sort(m,m+j);
    int sum = 0;
    for(int k = 0;k < j / 2 + 1;k++)
        sum += m[k];
    return sum;
}

int main(){
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%s",s);
        printf("%d\n",solve(0));
    }
    return 0;
}

Measured memory_bytes: 3160
module ABC125

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public :: task_D

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_D

    ! variables for this <subroutine>
    integer(INT32) :: len_sequence
    
    ! arrays for this <subroutine>
    integer(INT64), allocatable :: val_sequence(:)
    integer(INT64), allocatable :: dp(:,:)

    ! support variables for this <subroutine>
    integer(INT32) :: itr

    ! STEP.01
    ! read out the length of the given sequence
    read(unit=INPUT_UNIT, fmt=*) len_sequence

    ! STEP.02
    ! allocate to store ...
    ! 1. the sequence of values
    ! 2. the process of the dynamic planning
    allocate( val_sequence(1:len_sequence) )
    allocate( dp(1:2, 1:len_sequence+1) )

    ! STEP.03
    ! read out the given sequence of values
    read(unit=INPUT_UNIT, fmt=*) val_sequence(1:len_sequence)

    ! STEP.04
    ! dynamic planning
    dp(1,1) = 0_INT64
    dp(2,1) = - sum( abs( val_sequence(1:len_sequence) ) )

    do itr = 1_INT32, len_sequence, 1_INT32
      dp(1, itr + 1) = max( dp(1, itr) + val_sequence(itr), dp(2, itr) - val_sequence(itr) )
      dp(2, itr + 1) = max( dp(1, itr) - val_sequence(itr), dp(2, itr) + val_sequence(itr) )
    end do

    ! STEP.05
    ! output the maximum value of the summation that can be realized in a given sequence
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') dp(1, len_sequence + 1)

    ! STEP.END
    return

  end subroutine task_D

end module ABC125


program main

  ! <module>s to import
  use, non_intrinsic :: ABC125

  ! require all variables to be explicitly declared
  implicit none

  call task_D

end program main

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

int main(){
  int N;
  cin >> N;
  int H[N+1];
  int i,j,k;
  for(i=0; i<N; ++i)cin >> H[i];
  H[N]=0;
  int head, end, count;
  count=0;
  while(1){
    head=N;
    end=N;
    for(i=0; i<N; ++i){
      if(H[i]>0){
        head=i;
        for(j=i+1; j<N+1; ++j){
          if(H[j]==0){
            end=j;
            break;
          }
        }
        break;
      }
    }
    if(head==N)break;
    else for(k=head; k<end; ++k)H[k] -= 1;
    count += 1;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	int H, W;
	cin >> H >> W;

	string S[101];
	rep(i, H) cin >> S[i];

	int D[101][101] = {};
	rep(i, H) rep(j, W) D[i][j] = 100000;

	queue<pair<int, int>> Q1, Q2;
	if (S[0][0] == '.') Q1.push(mp(0, 0));
	else Q2.push(mp(0, 0));

	int d = 0;
	while (Q1.size() || Q2.size()) {
		while (Q1.size()) {
			auto to = Q1.front();
			Q1.pop();
			if (D[to.first][to.second] > d) {
				D[to.first][to.second] = d;
				if (to.first < H - 1) {
					if (S[to.first + 1][to.second] == '#') Q2.push(mp(to.first + 1, to.second));
					else Q1.push(mp(to.first + 1, to.second));
				}
				if (to.second < W - 1) {
					if (S[to.first][to.second + 1] == '#') Q2.push(mp(to.first, to.second + 1));
					else Q1.push(mp(to.first, to.second + 1));
				}
			}
		}
		d++;
		while (Q2.size()) {
			auto to = Q2.front();
			Q2.pop();
			if (D[to.first][to.second] > d) {
				D[to.first][to.second] = d;
				if (to.first < H - 1) {
					if (S[to.first + 1][to.second] == '#') Q2.push(mp(to.first + 1, to.second));
					else Q1.push(mp(to.first + 1, to.second));
				}
				if (to.second < W - 1) {
					if (S[to.first][to.second + 1] == '#') Q2.push(mp(to.first, to.second + 1));
					else Q1.push(mp(to.first, to.second + 1));
				}
			}
		}
	}


	co(D[H - 1][W - 1]);

	Would you please return 0;
}

Measured memory_bytes: 384
import scala.io.StdIn.readInt

object Main {
  val c = Math.cos(Math.PI/3)
  val s = Math.sin(Math.PI/3)

  def main(args:Array[String]) = {
    val n = readInt
    var list = IndexedSeq((0D,0D),(100D,0D))
    (1 to n).foreach { _=>
      list = for{
        k<-0 until list.length-1; i = list(k); j = list(k+1)
        p1 = (i._1*2/3+j._1/3,i._2*2/3+j._2/3)
        p2 = (i._1/3+j._1*2/3,i._2/3+j._2*2/3)
        x = (p2._1-p1._1)*c-(p2._2-p1._2)*s+p1._1
        y = (p2._1-p1._1)*s+(p2._2-p1._2)*c+p1._2
        list2 = if(k==0) Iterator(i,p1,(x,y),p2,j) else Iterator(p1,(x,y),p2,j)
        q<-list2
      } yield q
    }

    for((i,j)<-list) printf("%.8f %.8f\n",i,j)
  }
}

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

#define N 2000

int judge(int, int);
int n, a[N];

int main(){
  int i, q, m[N];

  scanf("%d", &n);

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

  scanf("%d", &q);

  for(i = 0; i < q; i++){
    scanf("%d", &m[i]);

    if(judge(0, m[i]) == 0)
      printf("no\n");

    else printf("yes\n");
  }

  return 0;
}

int judge(int i, int m){
  int calc;
  if(m == 0)
    return 1;

  else if(i >= n)
    return 0;

  calc = judge(i + 1, m) || judge(i + 1, m - a[i]);
  return calc;
}


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

namespace _1_1_a
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            List<long> inputs = Console.ReadLine().Split(' ').Select(t => long.Parse(t)).ToList();

            Console.WriteLine("{0} {1} {2}", inputs.Min(), inputs.Max(), inputs.Sum());
        }
    }
}


Measured memory_bytes: 20700
#include <stdio.h>
#include <math.h>
 
int main()
{
	double x1,y1,x2,y2,x3,y3,xp,yp;
	double s,s1,s2,s3;
	double ab,bc,ca,ap,bp,cp;
	while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
	ab=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	bc=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
	ca=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
	ap=sqrt((x1-xp)*(x1-xp)+(y1-yp)*(y1-yp));
	bp=sqrt((x2-xp)*(x2-xp)+(y2-yp)*(y2-yp));
	cp=sqrt((x3-xp)*(x3-xp)+(y3-yp)*(y3-yp));
	s=sqrt(((ab+bc+ca)*(-ab+bc+ca)*(ab-bc+ca)*(ab+bc-ca))/16);
	s1=sqrt(((ap+ab+bp)*(-ap+ab+bp)*(ap-ab+bp)*(ap+ab-bp))/16);
	s2=sqrt(((bp+bc+cp)*(-bp+bc+cp)*(bp-bc+cp)*(bp+bc-cp))/16);
	s3=sqrt(((cp+ca+ap)*(-cp+ca+ap)*(cp-ca+ap)*(cp+ca-ap))/16);
	if(fabs(s1+s2+s3-s)<0.00001)puts("YES");
	else puts("NO");
	}
	return 0;
}

Measured memory_bytes: 612
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 0;
    for(int k = 1;k < N;k++){
        int count = 0;
        for(char l = 'a';l <= 'z';l++){
            bool left = false;
            bool right = false;
            for(int i = 0;i < k;i++){
                if(S[i] == l)left = true;
            }
            for(int j = k;j < N;j++){
                if(S[j] == l)right = true;
            }
            if(left == true && right == true)count++;
        }
        if(count > ans)ans = count;
    }
    cout << ans;
}


Measured memory_bytes: 256
s = list(input())
ans = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] in ['R', 'U', 'D']:
            ans += 1
    else:
        if s[i] in ['L', 'U', 'D']:
            ans += 1
if ans == len(s):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
h , w = map(int,input().split())
a = [''] * h 
for i in range(h):
    a[i] = input()

row = [False]*h
col = [False]*w

for i in range(h):
    for j  in range(w):
        if a[i][j] =='#':
            row[i] = True
            col[j] = True

for i  in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j],end='')
        print()


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

const int MAX_N = 10010;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> Array;
typedef vector<Array> Graph;
typedef pair<double, double> pdd;
const ull mod = 1000000000 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> count(200010, 0);
    REP(i, N){
        ll a, b;
        cin >> a >> b;
        count[a+1] += b;
    }
    ll i=0;
    while(i<200010){
        K -= count[i];
        if(K<=0){
            cout << i-1 << endl;
            break;
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 1792
import collections as c
import sys
input = sys.stdin.readline
ip = lambda : map(int, input().split())
mod = 10**9+7
# ##############
A = []
for i in range(3):
    A.append(list(ip()))
N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if A[j][k] == b:
                A[j][k] = 0
# print(A)
if sum(A[0]) == 0 or sum(A[1]) == 0 or sum(A[2]) == 0 or (A[0][0] + A[1][0] + A[2][0] == 0) or (A[0][1] + A[1][1] + A[2][1] == 0) or (A[0][2] + A[1][2] + A[2][2] == 0) or (A[0][0] + A[1][1] + A[2][2] == 0) or (A[0][2] + A[1][1] + A[2][0] == 0):
    print('Yes')
else:print('No')

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

map<pair<string, string>, int> cnt;

int main(){
  fastIO;
  int n;
  cin >> n;
  string t;
  cin >> t;
  string A, B;
  for(int i = 0 ; i < (1 << n); i ++ ){
    A.clear();
    B.clear();
    for(int j = n-1 ; j >= 0; j -- ){
      if(i & (1 << j)){
        A.push_back(t[n + j]);
      }
    }
    for(int j = 0 ; j < n; j ++ ){
      if(!(i & (1 << j))){
        B.push_back(t[n + j]);
      }
    }
    cnt[mp(A,B)] ++ ;
  }
  ll res = 0;
  for(int i = 0 ; i < (1 << n); i ++ ){
    A.clear();
    B.clear();
    for(int j = 0 ; j < n ; j ++ ){
      if(i & (1 << j)){
        A.push_back(t[j]);
      }
    }
    for(int j = n - 1; j >= 0 ; j -- ){
      if(!(i & (1 << j))){
        B.push_back(t[j]);
      }
    }
    res += cnt[mp(A,B)];
  }
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 91904
using System;
using System.Linq;

namespace ConsoleApp22
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Convert.ToInt32(Console.ReadLine());
            double[] a = Console.ReadLine().Split(' ').Select(double.Parse).Take(n).OrderBy(x=>x).ToArray();

            var ans = a[0];

            for (int i = 1; i < a.Length; i++)
            {
                ans = (ans + a[i]) / 2;
            }

            Console.WriteLine(ans.ToString());

        }

    }


}


Measured memory_bytes: 13524
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}



//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}


int main() {
	int N;
	int mp[100010] = { 0 };
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;
		mp[a]++;
	}
	int max = 0;
	for (int i = 1; i < 100000; i++)
	{
		int tmp = mp[i - 1] + mp[i] + mp[i + 1];
		if (tmp > max) {
			max = tmp;
		}
	}

	cout << max << endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;
const int max_n = 1500;
long long cnt[111];
long long m,n,a=0,b;
const int INF = 1e8;
const int mod = 1e9 + 7;
long dist[max_n][max_n];
long long dp[max_n][max_n];
vector<vector<int> > G;
bool isprime(long long xx){
    if(xx == 2) return true;
    if(xx % 2==0 || xx<2)    return false;
    long long ii = 3;
    while(ii*ii <= xx){
        if(xx %ii == 0) return false;
        ii += 2;
    }
    return true;
}
long long gcd(long long xx, long long yy){
    if(yy == 0) return xx;
    long long k = xx/yy;
    long long c = xx - k*yy;
    return gcd(yy, c);
}
void solve(){
    for(int i=0 ; i<n ; i++){
        for(int j=0 ; j<m ; j++){
            if(dist[i][j] == 0){
                dp[i+1][j+1] = min(dp[i+1][j], min(dp[i][j],dp[i][j+1])) + 1;
            }else{
                dp[i+1][j+1] = 0;
            }
            a = max(dp[i+1][j+1], a);
        }
        
    }
    cout << a*a << endl;
}
int main(){
    cin >> n >> m;
    for(int i=0 ; i<n ; i++){
        for(int j=0 ; j<m ; j++){
            cin >> dist[i][j];
        }
    }
    solve();
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  string ans(7, ' ');
  for (int i = 0; i < 4; i++) {
    ans[2 * i] = S[i];
  }
  for (int i = 0; i < pow(2, 3); i++) {
    int x = i, s = S[0] - '0';
    for (int j = 0; j < 3; j++) {
      int tmp = S[j+1] - '0';
      if (x % 2) {
        s += tmp;
        ans[2 * j + 1] = '+';
      } else {
        s -= tmp;
        ans[2 * j + 1] = '-';
      }
      x >>= 1;
    }
    if (s == 7) {
      cout << ans << "=7" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		bool prime[1000000];
		for(int l=2;l<=n;l++){
			prime[l] =true;
		}
		for(int i=2;i<=n;i++){
			if(prime[i]==true){
				for(int j=i*2;j<=n;j+=i){
					prime[j]=false;
				}
			}
		}
		int count=0;
		for(int k=2;k<=n;k++){
			if(prime[k]==true) count++;
		}
		cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 2136
num = [[[0 for i in range(10)] for i in range(3)] for i in range(4)]

n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    num[b-1][f-1][r-1] += v

for b in range(4):
    for f in range(3):
        print(" " + " ".join(map(str, num[b][f])))
    if b < 3:
        print("#"*20)


Measured memory_bytes: 5608
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()

	ans := make([]int, n+1)
	for x := 1; x*x <= n; x++ {
		for y := 1; y*y <= n; y++ {
			s := x*x + y*y + x*y
			if s > n {
				break
			}
			for z := 1; z*z <= n; z++ {
				t := s + z*z + (x+y)*z
				if t <= n {
					ans[t]++
				}
			}
		}
	}

	for i := 1; i <= n; i++ {
		puts(ans[i])
	}
}


Measured memory_bytes: 1928
s = input()
n = len(s)
s1 = s[0:(n-1)//2]
s2 = s[(n+3)//2 - 1:]

if s == "".join(list(reversed(s))) and s1 == "".join(list(reversed(s1))) and s2 == "".join(list(reversed(s2))):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <stdio.h>

void sort_asc(int *v, int cnt){
    int i, j;
    int t;

    for(i = 0; i < cnt - 1; i++){
        if(v[i] > v[i + 1]){
            t = v[i + 1];
            v[i + 1] = v[i];
            v[i] = t;
            for(j = i; j > 0; j--){
                if(v[j] < v[j - 1]){
                    t = v[j - 1];
                    v[j - 1] = v[j];
                    v[j] = t;
                }else{
                    break;
                }
            }
        }
    }
    return;
}

int main(){
    int cnt, i;
    int v[3];
    
    scanf("%d", &cnt);
    if(1 <= cnt && cnt <= 1000){
        for(i = 0; i < cnt; i++){
            scanf("%d %d %d", &v[0], &v[1], &v[2]);
            sort_asc(v, 3);
            if(v[2] * v[2] == v[0] * v[0] + v[1] * v[1]){
                printf("YES\n");
            }else{
                printf("NO\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 580
//Code By CXY07
#include<bits/stdc++.h>
using namespace std;

//#define FILE
//#define int long long
//#define LL long long
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fst first
#define scd second
#define inv(x) ksm(x,mod - 2)

const int MAXN = 1;
const int INF = 2e9;
const int G = 3;
const double PI = acos(-1);
//const int mod = 1e9 + 7;
//const int mod = 998244353;

int k,now;

template<typename T> inline void read(T &a) {
	a = 0; char c = getchar(); int f = 1;
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9') {a = a * 10 + (c ^ 48); c = getchar();}
	a *= f;
}

signed main () {
#ifdef FILE
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	read(k);
	now = 7;
	for(int i = 1;i <= k; ++i) {
		if(now % k == 0) return cout << i << endl,0;
		now *= 10;
		now += 7;
		now %= k;
	}
	puts("-1");
	return 0;
}



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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int N, C;
    std::cin >> N >> C;

    vector<vector<int>> table(C, vector<int>(100001, 0));
    REP(i, N) {
        int s, t, c;
        std::cin >> s >> t >> c;
        fill(table[c - 1].begin() + s, table[c - 1].begin() + t + 1, 1);
    }

    int ans = 0;
    REP(i, 100001) {
        ans = max(ans, [&]() -> int {
                           int num = 0;
                           REP(ci, C) num += table[ci][i];
                           return num;
                       }());
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 12416
n = int(input())

a = n // 100
b = (n%100) // 10
c = n % 10


if a < b:
    ans = (a+1)*100 + (a+1)*10 + a+1
elif a == b:
    if c <= b:
        ans = a*100 + a*10 + a
    else:
        ans = (a+1)*100 + (a+1)*10 + a+1
else:
    ans = a*100 + a*10 + a

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define fi first
#define se second
#define pb push_back 
using namespace std;

long long ans,a[200005],s[200005],ss[200005];
int n;

int main(){
	scanf("%d",&n);
	rep(i,1,n+1) scanf("%lld",&a[i]),s[i]=s[i-1]+a[i];
	for (int i=n;i>=1;i--) ss[i]=ss[i+1]+a[i];
	ans=1ll<<62;
	rep(i,1,n) ans=min(ans,abs(s[i]-ss[i+1]));
	printf("%lld",ans);

}

Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef long double ld;

int MOD=1000000007;

int main(){
  ll N,M,ans=0;
  cin >> N >> M;
  for(ll i=0; i<N; i++){
    ans+=i;
  }for(ll i=0; i<M; i++) ans+=i;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

        if(R < 1200){
            System.out.println("ABC");
        }else if(R < 2800){
            System.out.println("ARC");
        }else{
            System.out.println("AGC");
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
#include <fstream>
#include <stdio.h>
#include <math.h>

using namespace std;

int main(int argc, const char * argv[]) {
   string s;
   int K,len,i=0,cost=0;
   getline(cin,s);
   cin>>K;
   len=s.length();
   while (i<len && K>0){
      if (s[i]=='a'){
        i++;
        continue;
      }
      cost=26-s[i]+'a';
      if (cost<=K){
        s[i]='a';
        K=K-cost;
      }
      i++;
   }
   if (K>0){
    s[len-1]=s[len-1]+K%26;
   }
   cout<<s<<endl;
   return 0;
}

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

int main() {
  std::string S;
  std::cin >> S;
  int cnt = 0;
  for (int i = 0; i < S.length() / 2; i++) {
    if (S[i] != S[S.length() - i - 1]) cnt++;
  }
  printf("%d", cnt);
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String arg[]){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		HashSet<Integer> hs=new HashSet<>();
		for(int i=0;i<n;i++)
			hs.add(sc.nextInt());
		if(hs.size()==n)
			System.out.println("YES");
		else 
			System.out.println("NO");
		
	}
}

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




namespace ConsoleApplication1 {

    

    class ClassMain {

        public static void Main(String[] args) {
           string line;
            while ((line = Console.ReadLine()) != null) {
                //int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                //int n = ints[0];
                int n = int.Parse(line);                
                if (n == 0) { break; }
                Console.WriteLine(count(n));
                break;
            }
        }

        public static int count(int num) {
            if (num <= 3) { return 1; }
            else { return count((num - 1) / 3 + 1)+1; }
        }
    }

    


}

Measured memory_bytes: 9688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#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 x,count=0;
    cin>>x;
    while(true){
        if(x<100){
            break;
        }
        x=x-100;
        count++;
    }
    int count2=0;
    while(true){
        if(x<5){
            break;
        }
        x=x-5;
        count2++;
    }
    while(true){
        if(x<4){
            break;
        }
        x=x-4;
        count2++;
    }
    while(true){
        if(x<3){
            break;
        }
        x=x-3;
        count2++;
    }
    while(true){
        if(x<2){
            break;
        }
        x=x-2;
        count2++;
    }
    if(x==1){
        count2++;
    }
    if(count2<=count){
        cout<<1<<'\n';
    }
    else{
        cout<<0<<'\n';
    }
    return(0);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
using namespace std;
#include <stdio.h>
int main()
{
	int n, b, f, r, v, bfr[4][3][10] = { 0 };
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> b >> f >> r >> v; bfr[b-1][f-1][r-1]+=v;
	}
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 3; j++){
			for (int k = 0; k < 10; k++){
				printf(" %d",bfr[i][j][k]);
			}
			printf("\n");
		}
		for (int l = 0; i < 3 && l < 20; l++) {
			printf("#");
			if(l==20-1) printf("\n");
		}
	}
}

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

int main() {
  string str, com, p;
  int q, a, b;
  cin >> str >> q;
  
  for (int i = 0; i < q; i++) {
    cin >> com >> a >> b;
    if (com == "print") {
      cout << str.substr(a, b-a+1) << endl;
    }
    else if (com == "reverse") {
      string s = str.substr(a, b-a+1);
      int n = s.size();
      for (int i = 0; i < n; i++) {
        str[a+i] = s[n-1-i];
      }
    } 
    else {
      cin >> p;
      str.replace(a, b-a+1, p);
    }
  }
      
}



Measured memory_bytes: 3228
#include <stdio.h>
int main(){

  int a, b, c, d, e, f, g, h, i, sum; 
  
  while(1)
    {
      scanf("%d", &sum);
      if( sum == 0 ) break;
      scanf("%d", &a);
      scanf("%d", &b);
      scanf("%d", &c);
      scanf("%d", &d);
      scanf("%d", &e);
      scanf("%d", &f);
      scanf("%d", &g);
      scanf("%d", &h);
      scanf("%d", &i);
      printf("%d\n", sum - (a + b + c + d + e + f + g + h + i));
    }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;




int main(){
	string s; cin>>s;
	ll n = s.size();

	bool able=false;
	for(int i=0;i<n-1;i++){
		if(s[i]==s[i+1]) {
			able=true;
			cout<<i+1<<" "<<i+2<<endl;
			return 0;
		}
	}

	for(int i=0;i<n-2;i++){
		if(s[i]==s[i+2]) {
			able=true;
			cout<<i+1<<" "<<i+3<<endl;
			return 0;
		}
	}

	cout<<-1<<" "<<-1<<endl;
}


Measured memory_bytes: 512