akhauriyash/Code-Regression huggingface dataset:
dx = [-1, 0, 1, 0]
dy = [0, -1, 0, 1]
tanks = "<^>v"
flat = "."
brick = "*"
iron = "#"
water = "-"

case = input()
for t in xrange(case):
    h, w = map(int, raw_input().split())
    m = [list(raw_input()) for i in xrange(h)]
    n = input()
    s = raw_input()
    x, y = 0, 0
    d = 0
    for i in xrange(h):
        for j in xrange(w):
            if m[i][j] in tanks:
                x = j
                y = i
                d = tanks.index(m[i][j])
                m[i][j] = flat
    for comm in s:
        if comm=="U":
            d = 1
            if y>0 and m[y-1][x]==flat:
                y -= 1
        elif comm=="D":
            d = 3
            if y<h-1 and m[y+1][x]==flat:
                y += 1
        elif comm=="L":
            d = 0
            if x>0 and m[y][x-1]==flat:
                x -= 1
        elif comm=="R":
            d = 2
            if x<w-1 and m[y][x+1]==flat:
                x += 1
        else:
            # "S"
            nx = x + dx[d]
            ny = y + dy[d]
            while 0<=nx<=w-1 and 0<=ny<=h-1:
                obj = m[ny][nx]
                if obj==brick:
                    m[ny][nx] = flat
                    break
                elif obj==iron:
                    break
                nx += dx[d]
                ny += dy[d]
    m[y][x] = tanks[d]
    for i in xrange(h):
        print "".join(m[i])
    if t<case-1:
        print

Measured memory_bytes: 4364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> Pii;
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1000000000
#define rep(i,a,b) for(int i =(a);i<(b);i++)
#define first fs
#define second ss
inline int Scan() {
    int x=0;int f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

template<typename T, typename U>
static inline void amin(T &x, U y)
{
    if (y < x)
        x = y;
}

// call by reference is used in x
template<typename T, typename U>
static inline void amax(T &x, U y)
{
    if (x < y)
        x = y;
}
//////////////////////////////////////end of template//////////////////////////////////////

int main(){
 
 int h,w;
 cin >> h >> w;
 
 ll mat[h][w];
 char c;
 rep(i,0,h){
    rep(j,0,w){
	    cin >> c;
	    if( c == '#') mat[i][j] = 0;
	    else {
			
			if( i == 0 && j == 0) mat[i][j] = 1;
			else if( i == 0) mat[i][j] = mat[i][j-1];
			else if( j == 0) mat[i][j] = mat[i-1][j];
			else mat[i][j] = (mat[i-1][j] + mat[i][j-1])%MOD;	
		} 
	 }
 }
  
 cout << mat[h-1][w-1] << endl;
  

}




Measured memory_bytes: 8064
# coding: utf-8
# Your code here!
N = int(input())

def kazu(x):
    if x == 0:
        return 0,0
    else:
        a = x
        top = 0
        keta = 0
        while(a!=0):
            top = a
            a = a//10
            keta += 1
        return keta,top
#print(N,keta,top)

def digsum(x):
#    print(x)
    xketa, xtop = kazu(x)
 #   print(xketa, xtop)
    if x == 0:
        return 0
    else:
        xdown = x - (10**(xketa-1))*xtop
  #      print(xdown)
        return max((xtop -1) + 9*(xketa-1), xtop + digsum(xdown))
print(digsum(N))

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

using ll = long long;
using namespace std;


int main()
{
    int n, m;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    cin >> m;
    vector<int> q(m);
    for(int i = 0; i < m; i++)cin >> q[i];
    sort(a.begin(), a.end());

    int cnt = 0;
    for(int i = 0; i < m;i++){
        cnt += binary_search(a.begin(), a.end(), q[i]);
    }
    cout << cnt << endl;
}



Measured memory_bytes: 3340
import sys

#input_line1 = raw_input()
#input_line2 = raw_input()
#input_line3 = raw_input()



data = sys.stdin.readline()
data = data.rstrip()

#data[1] = sys.stdin.readline()
#data[2] = sys.stdin.readline()
data = data.split()

#data[0] = data[0].rstrip()
#data[1] = data[1].rstrip()
#data[2] = data[2].rstrip()


for i in range(3):
    j = i + 1
    for j in range(j,3):

        #print(j)
        if data[i] > data[j]:
           
           temp = data[i]
           data[i] = data[j]
           data[j] = temp


print"%s %s %s" % (data[0], data[1], data[2])

    

#print(input_line1)
#print(input_line2)
#print(input_line3)

Measured memory_bytes: 4216
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<vector>
using namespace std;
int main() {
	vector<int> s,t;
	int a,i,j,k,l,len;
	int max = 0;
	for (i = 0; i <= 100; i++) {
		s.push_back(0);
	}
	while (cin >> a) {
		s[a] += 1;
	}
	for (j = 0; j <= 100; j++) {
		if (max < s[j]) {
			max = s[j];
		}
	}
	for (k = 0; k <= 100; k++) {
		if (s[k] == max) {
			t.push_back(k);
		}
	}
	len = t.size();
	for (l = 0; l < len; l++) {
		cout << t[l] << endl;
	}
	return 0;
}

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

namespace TestProject20180923
{
    class Program
    {
        static void Main(string[] args)
        {
            var vs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var ab = vs[0] * vs[1];
            if(ab%2 == 0)
            {
                Console.WriteLine("Even");
            }
            else
            {
                Console.WriteLine("Odd");
            }
        }
    }
}


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

const long long int mod=1000000007;
const long long int INF=99999999999999999;

string str;
long long int n,m,sum,res=0;
int main() {
	cout << fixed << setprecision(10);
	cin>>n;
	if(n%2==1){
	cout<<(1+n/2)/(double)n<<endl;
	}else{cout<<"0.500000000"<<endl;}
} 


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int x, n;
int p[110];

int main()
{
	scanf("%d%d", &x, &n);
	bool hasNum = false;
	for (int i = 0 ; i < n ; i++) {
		scanf("%d", &(p[i]));
		if (p[i] == x) {
			hasNum = true;
		}
	}
	
	if (hasNum == false) {
		printf("%d\n", x);
		return 0;
	}
		
	sort(p, p + n);
	int pos;
	for (int i = 0 ; i < n ; i++) {
		if (p[i] == x) {
			pos = i;
			break;
		}
	}
	
	int l = pos - 1;
	int lVal = x - 1;
	while (l >= 0) {
		if (p[l] == lVal) {
			lVal--;
			l--;
		} else {
			break;
		}
	}
	
	int h = pos + 1;
	int hVal = x + 1;
	while (h < n) {
		if (p[h] == hVal) {
			hVal++;
			h++;
		} else {
			break;
		}		
	}
	
	int lDist = x - lVal;
	int hDist = hVal - x;
	if (lDist <= hDist) {
		printf("%d\n", lVal);
	} else {
		printf("%d\n", hVal);
	}
		
	return 0;
}


Measured memory_bytes: 1724
#include <iostream>
 
using namespace std;
 
void solve()
{
    int N;
    cin >> N;
    int sum = 100000;
    for(int i = 0; i < N; ++i)
    {
        sum *= 1.05;
        if(sum % 1000 != 0)
        {
            sum += 1000 - (sum % 1000);
        }
    }
    cout << sum << endl;
}
 
int main()
{
    solve();
    return(0);
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <list>
#include <set>
using namespace  std;

#define int long long int

constexpr int INF = std::numeric_limits<int>::max();
constexpr int MAGIC = 753;

int N;

int count(const string &s, char c) {
    int ret = 0;
    for (char x : s) {
        if (x == c) {
            ret++;
        }
    }
    return ret;
}

int dfs(string s) {
    if (stoll(s) > N) {
        return 0;
    }

    int ret = 0;
    if (count(s, '7') > 0 && count(s, '5') > 0 && count(s, '3') > 0) {
        ret = 1;
    }

    for (char c : {'7', '5', '3'}) {
        ret += dfs(s + c);
    }
    return ret;
}

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

    cin >> N;
    cout << dfs("0") << endl;
}

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

using namespace std;

int main()
{
    int M,N,temp;
    vector<int> A;

    cin >> N >> M;

    for(int i=0; i<N; ++i) {
        cin >> temp;
        A.push_back(temp);
    }

    for(int k=1; k<=M; ++k) {
        for(int i=0; i<N-1; ++i) {
            if(A[i]%k > A[i+1]%k) {
                swap(A[i],A[i+1]);
            }
        }
    }

    for(int i=0; i<N; ++i) {
        cout << A[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3148
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  a[i]=-a[i]
heapq.heapify(a)
for _ in range(m):
  t=heapq.heappop(a)
  heapq.heappush(a,(-1)*(-t//2))
print(-sum(a))

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

int main(){
  int n,m;
  cin >> n >> m;

  int rmin=1000000,lmax=0;

  for (int i = 0; i < m; i++)
  {
    int l,r;
    cin >> l >> r;
    lmax=max(lmax,l);
    rmin=min(rmin,r);
  }
  cout << max(rmin-lmax+1,0) << endl;
  
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0)
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000

int main()
{
  int n; cin >> n;
  vector<string> s(n);
  REP(i, n) cin >> s.at(i);


  sort(ALL(s));
  string str = s.at(0);
  int cnt = 1;
  REP(i, n) {
    if (str != s.at(i)) {
      cnt++;
      str = s.at(i);
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 9596
import itertools

s=dict()
for i in itertools.product(["A","C","G","T"], repeat=3):
    s[i]=1
s[("A","G","C")]=0
s[("G","A","C")]=0
s[("A","C","G")]=0

n=int(input())

mod=10**9+7
nn=3
t=dict()
while nn<n:
    for i in itertools.product(["A","C","G","T"], repeat=3):
        t[i]=0
    nn+=1
    for ky in s.keys():
        if ky[0]=="G" and ky[1]=="C":
            t[("A",ky[0],ky[1])]=0
            t[("C",ky[0],ky[1])]+=s[(ky[0],ky[1],ky[2])]
            t[("G",ky[0],ky[1])]+=s[(ky[0],ky[1],ky[2])]
            t[("T",ky[0],ky[1])]+=s[(ky[0],ky[1],ky[2])]
        elif ky[0]=="A" and ky[1]=="C":
            t[("A",ky[0],ky[1])]+=s[(ky[0],ky[1],ky[2])]
            t[("C",ky[0],ky[1])]+=s[(ky[0],ky[1],ky[2])]
            t[("G",ky[0],ky[1])]=0
            t[("T",ky[0],ky[1])]+=s[(ky[0],ky[1],ky[2])]
        elif ky[0]=="C" and ky[1]=="G":
            t[("A",ky[0],ky[1])]=0
            t[("C",ky[0],ky[1])]+=s[(ky[0],ky[1],ky[2])]
            t[("G",ky[0],ky[1])]+=s[(ky[0],ky[1],ky[2])]
            t[("T",ky[0],ky[1])]+=s[(ky[0],ky[1],ky[2])]
        elif ky[0]=="G" and ky[2]=="C":
            t[("C",ky[0],ky[1])]+=s[(ky[0],ky[1],ky[2])]
            t[("G",ky[0],ky[1])]+=s[(ky[0],ky[1],ky[2])]
            t[("T",ky[0],ky[1])]+=s[(ky[0],ky[1],ky[2])]
        elif ky[1]=="G" and ky[2]=="C":
            t[("C",ky[0],ky[1])]+=s[(ky[0],ky[1],ky[2])]
            t[("G",ky[0],ky[1])]+=s[(ky[0],ky[1],ky[2])]
            t[("T",ky[0],ky[1])]+=s[(ky[0],ky[1],ky[2])]
        else:
            t[("A",ky[0],ky[1])]+=s[(ky[0],ky[1],ky[2])]
            t[("C",ky[0],ky[1])]+=s[(ky[0],ky[1],ky[2])]
            t[("G",ky[0],ky[1])]+=s[(ky[0],ky[1],ky[2])]
            t[("T",ky[0],ky[1])]+=s[(ky[0],ky[1],ky[2])]
    for ky in s.keys():
        s[ky]=t[ky]           

icnt=0
for i in s.values():
    icnt=(icnt+i)%mod
print(icnt)



Measured memory_bytes: 72516
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>

using namespace std;

int main(){

    int N, M;
    cin>> N>> M;
    int x[M], y[M];
    for(int i=0; i<M; i++){
        cin>> x[i]>> y[i];
        x[i]--; y[i]--;

    }

    map<int, int> mp;
    for(int i=0; i<N; i++){
        mp[i]=1;
    }
    set<int> st;
    st.insert(0);
    for(int i=0; i<M; i++){
        if(st.count(x[i])){
            st.insert(y[i]);
        }
        if(mp[x[i]]>0){
            mp[x[i]]--;
            mp[y[i]]++;
        }
        if(mp[x[i]]==0) st.erase(x[i]);
    }

    cout<< st.size()<< endl;

    return 0;
}



Measured memory_bytes: 10368
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,a[100005];
int main()
{
	scanf("%d%d",&n,&m);
	int ct=0;
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]%2) ct++;
	}
	if(ct>2)
	{
		printf("Impossible\n");
		return 0;
	}
	int id1=0,id2=0;
	for(int i=1;i<=m;i++)
		if(a[i]%2)
		{
			if(!id1) id1=i;
			else if(!id2) id2=i;
		}
	if(id1)
	{
		if(id2==1) id2=id1;
		swap(a[1],a[id1]);
	}
	if(id2) swap(a[m],a[id2]);
	if(m==1)
	{
		if(a[1]==1) printf("1\n1\n1\n");
		else printf("%d\n2\n%d 1\n",a[1],a[1]-1);
		return 0;
	}
	if(!id2)
	{
		for(int i=1;i<=m;i++)
			printf("%d ",a[i]);
		printf("\n%d\n",m);
		for(int i=1;i<=m;i++)
		{
			if(i==1) printf("%d ",a[i]+1);
			else if(i==m) printf("%d ",a[i]-1);
			else printf("%d ",a[i]);
		}
		return 0;
	}
	if(n==2&&m==2)
	{
		printf("1 1\n1\n2\n");
		return 0;
	}
	if(n==4&&m==3)
	{
		printf("1 2 1\n2\n2 2\n");
		return 0;
	}
	if(a[1]==1&&a[m]==1)
	{
		for(int i=1;i<=m;i++)
			printf("%d ",a[i]);
		printf("\n%d\n",m-1);
		for(int i=2;i<=m;i++)
		{
			if(i==m) printf("%d ",a[i]+1);
			else printf("%d ",a[i]);
		}
		return 0;
	}
	for(int i=1;i<=m;i++)
		printf("%d ",a[i]);
	printf("\n%d\n",m);
	for(int i=1;i<=m;i++)
	{
		if(i==1) printf("%d ",a[i]+1);
		else if(i==m) printf("%d ",a[i]-1);
		else printf("%d ",a[i]);
	}
	return 0;
}

Measured memory_bytes: 1696
#include<cstdio>
#include<algorithm>
using namespace std;
char mde[20];int cnt;
int main()
{
	scanf("%s",mde+1);
	if(mde[1]!='A'){printf("WA");return 0;}
	for(int i=2;mde[i]!='\0';i++)if(mde[i]!='C'&&mde[i]<'a')
	{
		printf("WA");return 0;
	}
	if(mde[2]<'a')
	{
		printf("WA");return 0;
	}
	int len;for(len=1;mde[len+1]!='\0';len++);
	if(mde[len]<'a'){printf("WA");return 0;}
	for(int i=3;i<=len-1;i++)cnt+=(mde[i]=='C');
	printf("%s",cnt==1?"AC":"WA");return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	int A;
  	cin >> A;
  	if (A/10%111 == 0 || A%1000%111 == 0 ) {
  		cout << "Yes";
  	}else{
  		cout << "No";
	}
}

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

int main()
{
    string s;
    cin >> s;
    if (s.compare("AAA") == 0 || s.compare("BBB") == 0)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	String fileName = "prizes";

	public void solve() throws IOException {
		int x = nextInt();
		int a = nextInt();
		int b = nextInt();
		x -= a;
		x %= b;
		out.println(x);

	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out, true);
			solve();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	BufferedReader br;
	StringTokenizer in;
	static PrintWriter out;

	public String nextToken() throws IOException {
		while (in == null || !in.hasMoreTokens()) {
			in = new StringTokenizer(br.readLine());
		}
		return in.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

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

}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long
#define endl '\n'
int len=-1;
int p(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b%2)
            res*=a;
        a*=a;
        b/=2;
    }
    return res;
}
void f(int i,int n)
{
    if(i==len)
        return;
    int poss=p(26,len-i-1);
    for(int a=0;a<26;a++)
    {
        if(poss>=n)
        {
            cout<<(char)(a+'a');
            f(i+1,n);
            return;
        }
        n-=poss;
    }
}
int32_t main()  
{
    IOS;
    int n;
    cin>>n; 
    int curr=0;
    int tmp=n;
    for(int i=1;;i++)
    {
        if(p(26,i)>=tmp)
        {
            len=i;
            break;
        }
        tmp-=p(26,i);
    }
    f(0,tmp);
}


Measured memory_bytes: 3588
import java.util.Scanner;

/**
 * @author author
 *
 */
public class Main {

  /**
   * @param args
   */
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    

    if (6 <= a && a <= 12) {
      b /= 2;
    }
    else if (a <=5) {
      b = 0;
    }

    System.out.println(b);
    
  }

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int a, b; cin >> a >> b;
  auto ans = std::max(0, a - b * 2);
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

mod = 10 ** 9 + 7

x, y = 0, 0

for i in range(N):
    for j in range(i+1, N):
        if A[i] > A[j]:
            x += 1
    for j in range(i):
        if A[i] > A[j]:
            y += 1

ans = x * K * (K+1) // 2 + y * (K-1) * K // 2

print(ans % mod)

Measured memory_bytes: 3188
import math

a,b,C = map(float,input().split())
S = 0
L = 0
h = 0

S = 0.5 * a * b *math.sin(math.radians(C))
L = (a**2 + b**2 - 2*a*b*math.cos(math.radians(C)))**0.5 + a + b
h = b*math.sin(math.radians(C))
print(S)
print(L)
print(h)



Measured memory_bytes: 5700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
	ll ans[1002];	bool ok[1002];
int main() {
	ll n,m;
	cin>>n>>m;
	vector<ll>ch[1002],ch2[1002];
	for(ll i=0;i<m;i++){
		ll x,y;
		cin>>x>>y;
		x--;y--;
		ch[x].push_back(y);
		ch2[y].push_back(x);
	}	ll re[1002];
	for(ll i=0;i<n;i++){
		
		for(ll j=0;j<n;j++){
			re[j]=-1;
		}
		queue<ll>q;
		q.push(i);
		re[i]=0;
		while(q.size()!=0){
			ll now=q.front();
			q.pop();
			bool go=false;
			for(ll j=0;j<ch[now].size();j++){
				ll nex=ch[now][j];
				if(nex==i){
					ans[i]=re[now]+1;
					go=true;
					break;
				}
				if(re[nex]!=-1){
					continue;
				}
				re[nex]=re[now]+1;
				q.push(nex);
			}
			if(go){
				break;
			}
		}
	}
	ll ANS=INF;
	for(ll i=0;i<n;i++){
		if(ANS>ans[i]&&ans[i]!=0){
			ANS=ans[i];
		}
	}
	if(ANS==INF){
		cout << -1;
		return 0;
	}
//	cout <<ANS;
	for(ll i=0;i<n;i++){
		
		if(ans[i]!=ANS){
			continue;
		}
	//	cout << i;
	//	return 0;
		for(ll j=0;j<n;j++){
			re[j]=-1;
		}	
		queue<ll>q;
		q.push(i);
		re[i]=0;
	//	return 0;
		while(q.size()!=0){
			ll now=q.front();
			ok[now]=true;
			q.pop();
			bool go=false;
			for(ll j=0;j<ch[now].size();j++){
				ll nex=ch[now][j];
				if(nex==i){
					vector<ll>fa;
					nex=now;
					fa.push_back(nex);
			//		return 0;
					while(nex!=i){
						for(ll k=0;k<ch2[nex].size();k++){
							if(ok[ch2[nex][k]]){
								fa.push_back(ch2[nex][k]);
								nex=ch2[nex][k];
								break;
							}
						}
					}
				//	return 0;
					cout << fa.size()<<endl;
					for(ll k=0;k<fa.size();k++){
						cout << fa[fa.size()-1-k]+1<<endl;
					}
					return 0;
					ans[i]=re[now]+1;
					go=true;
					break;
				}
				if(re[nex]!=-1){
					continue;
				}
				re[nex]=re[now]+1;
				q.push(nex);
			}
			if(go){
				break;
			}
		}		
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll x;
  cin >> x;
  cout << (!x) << endl;
}

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

int main() {

	while (1) {
		int a, b;
		char c;
		cin >> a >> c >> b;
		if (c == '?')
			break;

		if (c == '+')
			cout << a + b;
		else if (c == '-')
			cout << a - b;
		else if (c == '*')
			cout << a * b;
		else if (c == '/')
			cout << a / b;
		cout << endl;
	}

	return 0;
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N;
    cin >> N;
    vector<ll> T(N), A(N);
    REP(i, N) cin >> T[i] >> A[i];

    ll t=1, a=1;
    REP(i, N){
    	ll x = (t+T[i]-1)/T[i];
    	ll y = (a+A[i]-1)/A[i];

    	ll k = max(x, y);

    	t = k*T[i];
    	a = k*A[i];
    	//dump(k)
    	//dump(t)
    	//dump(a)
    }
    cout << (a+t) << endl;
    return 0;
}

Measured memory_bytes: 256
/*
    Created by Rahul Goel.
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/*******************************************************************************/
using namespace std;
using namespace __gnu_pbds;
template < typename T >
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*******************************************************************************/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const int INF = 1e9;
const ll LINF = 1e18;
/*******************************************************************************/
ll mod_sum() { return 0LL; }
template < typename T, typename... Args >
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%MOD + MOD)%MOD; }
/*******************************************************************************/
ll mod_prod() { return 1LL; }
template< typename T, typename... Args >
T mod_prod(T a, Args... args) { return (a * mod_prod(args...))%MOD; }
/*******************************************************************************/
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
#define fastio          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c)          (c).begin(), (c).end()
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(all(c),x) != (c).end())
#define uniq(c)         (c).resize(distance((c).begin(), unique(all(c))))
#define min_pq(t)       priority_queue < t, vector < t >, greater < t > >
#define max_pq(t)       priority_queue < t >
#define pb              push_back
#define ff              first
#define ss              second
/*******************************************************************************/
using pii = pair < ll, ll >;
using vi = vector < ll >;
using vb = vector < bool >;
using vvi = vector < vector < ll > >;
using vvb = vector < vector < bool > >;
using vpii = vector < pii >;
using vvpii = vector < vector < pii > >;
/*******************************************************************************/
//.-.. . -. -.- .- .. ... .-.. --- ...- .
/*
    Code begins after this.
*/

ll solve() {
    ll x;
    cin >> x;
    cout << !x << endl;
    return 0;
}

signed main() {
    fastio;

    ll t = 1;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define lo long long
using namespace std;
int n,A[55],konum[55],flag;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&A[i]);
	for(int i=1;i<=n;i++){
		konum[A[i]]=i;
	}
	for(int i=1;i<=n;i++){
		if(i!=konum[i] && flag==0){
			swap(A[i],A[konum[i]]);
			flag=1;
		}
	}
	for(int i=1;i<=n;i++){
		if(i!=A[i]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}




Measured memory_bytes: 256
/**
 *   @FileName	c.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.14 21:08:47
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int x,n;cin >> x >> n;
    vector<int> v(201,0);
    int ans1 = 1000000,ans2;
    for (int i = 0; i < n; i++) {
        int a;cin >> a;
        v[a] = 1;
    }
    for (int i = -100; i <= 200; i++) {
        if (i < 0 || i >= 0 && v[i] == 0) {
            if (ans1 > abs(x - i)) {
                ans1 = abs(x-i);
                ans2 = i;
            }
        }
    }
    cout << ans2 << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
#define mod 1000000007

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    double x,ans;
    cin >> x;
    ans=x/3.0;
    ans=ans*ans*ans;
    printf("%.10f",ans);

    return 0;
}

Measured memory_bytes: 256
import numpy as np
n, m = map(int, input().split())
record = np.zeros(n)
penalty = np.zeros(n)
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    if record[p]:
        continue
    else:
        if s == "AC":
            record[p] = 1
        elif s == "WA":
            penalty[p] += 1

ans1 = int(sum(record))
ans2 = int(np.dot(record, penalty))
print(ans1, ans2)

Measured memory_bytes: 21228
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

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

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

    int mn[N];
    mn[0] = A[0];
    for(int i=1; i<N; i++){
        mn[i] = min(mn[i-1], A[i]);
    }

    int mx = 0;
    for(int i=0; i<N; i++){
        mx = max(mx, A[i] - mn[i]);
    }

    int cnt = 0;
    for(int i=0; i<N; i++){
        int t = A[i] - mn[i];
        if(t == mx) cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define N 500000
#define INF (1e9)
using namespace std;
long long n,s[N],ans;
 
void merge(int *A,int left,int mid,int right){
  int n1=mid-left,n2=right-mid;
  int L[N/2+1],R[N/2+1];
  for(int i=0;i<n1;i++)L[i]=A[left+i];
  for(int i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=R[n2]=INF;
  int i=0,j=0;
  for(int k=left;k<right;k++){
    if(L[i]<=R[j])A[k]=L[i],i++;
    else A[k]=R[j],j++,ans+=n1-i;
  }
}

void mergeSort(int *A,int left,int right){
  if(left+1<right){
    int mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

int main(){
  int A[N];
  cin>>n;
  for(int i=0;i<n;i++)cin>>A[i];
  mergeSort(A,0,n);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 2748
import java.util.Scanner;
class Main{
  public static void main(String args[]){
    Scanner in = new Scanner(System.in);
  int a = in.nextInt(),b=in.nextInt(),c= in.nextInt();
    if(a==b &&a==c)System.out.println("Yes");
    else System.out.println("No");
  }
}

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

typedef modint998244353 mint;

const mint inv9 = mint(1) / 9;

struct S {
    mint x, pot;
};

typedef int F;

S op(S l, S r) {
    return {
        l.x * r.pot + r.x,
        l.pot * r.pot,
    };
}

S e() {
    return {0, 1};
}

S mapping(F l, S r) {
    if (l == 0) return r;
    return {
        (r.pot - 1) * inv9 * l,
        r.pot,
    };
}

F composition(F l, F r) {
    if(l == 0) 
        return r;
    else 
        return l;
}

F id() {
    return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, q;
    cin >> n >> q;

    vector<S> init(n, S{1, 10});
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(init);

    while (q--) {
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        seg.apply(l, r, d);
        cout << seg.all_prod().x.val() << endl;
    }
}




Measured memory_bytes: 10000
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19

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

    vector<double> vs(n);
    for (int i = 0; i < n; i++) {
        cin >> vs[i];
    }
    sort(vs.begin(), vs.end());
    double ans = vs[0];
    for (int i = 1; i < n; i++) {
        ans = (ans + vs[i]) / 2;
    }

    // double ans = accumulate(vs.begin() + 1, vs.end(), vs[0], [](double a, double b) {
    //     return (a + b) / 2.0;
    // });
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 999999999
const int mod = 1000000007;
ll cnt = 0;
ll int gcd(ll x,ll y){
   return y ? gcd( y , x%y ) : x;
}
 ll ngcd(vector<ll> a){/*gcd呼ぶのを忘れない*/
 int res;  res=a[0];
 for(int i=0;i<a.size() && res != 1 ; i++){
    res = gcd( a[i] , res );
 }
 return res;
 }
int main(){
 ll n , X;  cin >> n >> X;
 vector<ll>a;
 for(int i=0;i<n;i++){
     ll b;
     cin >> b;
     a.push_back(b);
 }
 a.push_back(X);
 sort(a.begin(),a.end());
 vector<ll>b;
 for(int i=0;i<n;i++){
     ll c;
     c=a[i+1]-a[i];
     b.push_back(c);
 }
 cout << ngcd(b) << endl;


}

Measured memory_bytes: 2676
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (max(a, b) - min(a,b) >= 2){
    cout << 2 * max(a, b) - 1 << endl;
  }
  else {
    cout << a + b << endl;
  }
}


Measured memory_bytes: 256
#####segfunc#####
def segfunc(x, y):
    return min(x, y)
#################

#####ide_ele#####
ide_ele = float('inf')
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res


N, Q = map(int, input().split())
black = (N - 2) * (N - 2)
tate = [N - 1] * (N)
yoko = [N - 1] * (N)
seg_t = SegTree(tate, segfunc, ide_ele)
seg_y = SegTree(yoko, segfunc, ide_ele)
#2 - N - 1
for i in range(Q):
  x, y = map(int, input().split())
  if x == 1:
    xx = seg_t.query(y - 1, N)
    if seg_y.query(xx - 1, xx) > y - 1:
      seg_y.update(xx - 1, y - 1)
    black -= xx - 1
  else:#x == 2
    xx = seg_y.query(y - 1, N)
    if seg_t.query(xx - 1, xx) > y - 1:  
      seg_t.update(xx - 1, y - 1)
    black -= xx - 1
  
  
  #print(xx, black)
print(black)  

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

using ll = long long;

const int MAXN = 5.1e5;
int N;
ll D0;
ll D[MAXN];
ll reach[MAXN];
bool ans[MAXN];

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> N >> D0;
  for (int i = 0; i < N; i++) cin >> D[i];
  reach[N] = 0;
  for (int i = N-1; i >= 0; i--) reach[i] = reach[i+1] < D[i]/2 ? reach[i+1] : reach[i+1] + D[i];
  ll curD = D0;
  for (int i = 0; i < N; i++) {
    ans[i] = curD <= reach[i+1];
    curD = min(curD, abs(curD - D[i]));
  }
  int Q; cin >> Q; while (Q--) { int v; cin >> v; cout << (ans[v-1] ? "NO" : "YES") << '\n'; }
}

Measured memory_bytes: 10368
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?(c=getchar()):0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
const int N=200010,O=924844033;
inline int fpow(int x,int n){
	int a=1;
	for(;n;n>>=1,x=(lint)x*x%O){
		if(n&1){
			a=(lint)a*x%O;
		}
	}
	return a;
}
inline int inv(int x){
	return fpow(x,O-2);
}
namespace poly{
	const int SH=19,N=1<<SH;
	int sh,n,invn;
	int rev[N],o[SH][N<<1],io[SH][N<<1];
	inline void init(int _n){//g=5
		for(sh=0;(1<<sh)<_n;sh++);
		n=1<<sh,invn=inv(n);
		rev[0]=0;
		for(int i=0;i<n;i++){
			rev[i]=(rev[i>>1]>>1)|((i&1)<<(sh-1));
		}
		for(int i=0;i<sh;i++){
			int half=1<<i,full=half<<1;
			lint w=1,iw=1,wn=fpow(5,(O-1)/full),iwn=inv(wn);
			for(int j=0;j<half;j++,(w*=wn)%=O,(iw*=iwn)%=O){
				o[i][j]=w,io[i][j]=iw;
			}
		}
	}
	inline void ntt(int a[],int d=1){
		for(int i=0;i<n;i++){
			if(rev[i]>i){
				swap(a[i],a[rev[i]]);
			}
		}
		for(int i=0;i<sh;i++){
			int half=1<<i,full=half<<1;
			for(int j=0;j<half;j++){
				int w=(d==1?o:io)[i][j];
				for(int k=j;k<n;k+=full){
					int p=a[k],q=(lint)a[k+half]*w%O;
					a[k]=(p+q)%O;
					a[k+half]=(p+O-q)%O;
				}
			}
		}
		if(d==-1){
			for(int i=0;i<n;i++){
				a[i]=(lint)a[i]*invn%O;
			}
		}
	}
}
int n,cnt[N];
namespace T{
	const int E=N<<1;
	int to[E],bro[E],head[N],e=0;
	inline void init(){
		memset(head,-1,sizeof(head));
	}
	inline void ae(int u,int v){
		to[e]=v,bro[e]=head[u],head[u]=e++;
	}
	inline void add(int u,int v){
		ae(u,v),ae(v,u);
	}
	int dfs(int x,int fa){
		int size=1;
		for(int i=head[x],v;~i;i=bro[i]){
			if((v=to[i])!=fa){
				size+=dfs(v,x);
			}
		}
		if(fa){
			cnt[size]++;
			cnt[n-size]++;
		}
		return size;
	}
}
int fac[N],invfac[N];
inline void gmath(int n){
	fac[0]=1;
	for(int i=1;i<=n;i++){
		fac[i]=(lint)fac[i-1]*i%O;
	}
	invfac[n]=inv(fac[n]);
	for(int i=n;i>=1;i--){
		invfac[i-1]=(lint)invfac[i]*i%O;
	}
}
int a[poly::N],b[poly::N];
int main(){
	n=ni;
	gmath(n),T::init();
	for(int i=1;i<n;T::add(ni,ni),i++);
	T::dfs(1,0);
	poly::init(n<<1);
	memset(a,0,sizeof(a));
	memset(b,0,sizeof(b));
	for(int i=0;i<n;i++){
		a[i]=(lint)fac[n-i]*cnt[n-i]%O;
		b[i]=invfac[i];
	}
	poly::ntt(a),poly::ntt(b);
	for(int i=0;i<poly::n;i++){
		a[i]=(lint)a[i]*b[i]%O;
	}
	poly::ntt(a,-1);
	for(int k=1;k<=n;k++){
		lint ans=(lint)fac[n]*invfac[k]%O*invfac[n-k]%O*n%O;
		ans-=(lint)a[n-k]*invfac[k]%O;
		printf("%lld\n",(ans%O+O)%O);
	}
	return 0;
}

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

int main()
{
	int n,v[20],c[20];
	cin>>n;
	for(int i=0;i<n;i++) cin>>v[i];
	for(int i=0;i<n;i++) cin>>c[i];
	
	int sum=0,d[20];
	for(int i=0;i<n;i++){
		d[i]=v[i]-c[i];
		if(d[i]>0) sum+=d[i];
	}
	
	cout<<sum<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#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>;
 
 
int main() {
    int N;
    cin >>  N;
    string S;
    cin >> S;
    int count=N;
    rep(i,N-1){
        if(S.at(i)==S.at(i+1))count--;
    }
    cout << count << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
 
using namespace std;
 
int partition(int *A, int p, int r){
  int x = A[r];
  int i = p - 1;
  for(int j = p;j < r;j++){
    if(A[j] <= x){ //if A[j] <= x, swap A[j] for the head of group of number that is larger than x(==A[r])
      i++;
      swap(A[i], A[j]);
    }
  }
  swap(A[i + 1], A[r]); //swap A[r] for the head of group of number that is larger than x(==A[r])
  return i + 1;
}
 
int main(){
 
  int n, a[100000], q;
  
  //input
  cin >> n;
  for(int i = 0;i < n;i++) cin >> a[i];
 
  q = partition(a, 0, n - 1);


  //output
  for(int i = 0;i < n;i++){
    cout << (i?" ":"");
    if(i == q) cout << '[' << a[i] << ']';
    else cout << a[i];
  }
  cout << endl;
 
  return 0;
}



Measured memory_bytes: 3384
import java.util.Scanner;

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

	for (int i=0; i<n; i++) {
	    
	    for (int j=0; j<6; j++) {
	        p[j] = scan.nextDouble();
	    }

	    double a = p[0] - p[2], b = p[1] - p[3], c = p[2] - p[4], d = p[3] - p[5],
		e = (p[0]*p[0])+(p[1]*p[1])-(p[2]*p[2])-(p[3]*p[3]),
		f = (p[2]*p[2])+(p[3]*p[3])-(p[4]*p[4])-(p[5]*p[5]);

	    double x = (d*e - b*f) / (2*(a*d - b*c));
	    double y = (c*e - a*f) / (2*(b*c - a*d));
	    double dx = x - p[0], dy = y - p[1];
	    double r = Math.sqrt((dx*dx) + (dy*dy));

	    x = Math.round(1000 * x);
	    y = Math.round(1000 * y);
	    r = Math.round(1000 * r);

	    x = x / 1000;
	    y = y / 1000;
	    r = r / 1000;

	    System.out.printf("%.3f %.3f %.3f\n", x, y, r);
	}
    }
}

Measured memory_bytes: 28836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

bool prime (int i) {
    if (i == 1) return false;
    if (i == 2 || i == 3) return true;
    for (int j = 2; j * j <= i; j++) {
        if (i % j == 0) return false;
    }
    return true;
}

int main() {
    int n, cnt = 0, x;
    cin >> n;
    rep (i, n) {
        cin >> x;
        if (prime (x)) cnt++;
    }
    cout << cnt << "\n";
}


Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;

#define MP make_pair
typedef pair<int,int> pii;

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

int main(){
    int W,H;
    while(cin>>W>>H){
        if(W==0&&H==0) return 0;

        vector<string> t(H);
        vector<vector<bool>> used(H,vector<bool>(W,false));
        for(int i=0;i<H;i++) cin>>t[i];

        int sx,sy;
        for(int i=0;i<H;i++) for(int j=0;j<W;j++) if(t[i][j]=='@'){
            sx = i;
            sy = j;
        }
        used[sx][sy]=true;

        queue<pii> que;
        que.push(make_pair(sx,sy));

        while(que.size()!=0){
            pii p = que.front();
            que.pop();

            int x = p.first;
            int y = p.second;

            for(int i=0;i<4;i++){
                int nx = x + dx[i];
                int ny = y + dy[i];
                if(nx>=0 && nx<H && ny>=0 && ny<W && t[nx][ny]!='#' && used[nx][ny]==false){
                    used[nx][ny] = true;
                    que.push(MP(nx,ny));
                }
            }
        }

        int cnt = 0;
        for(int i=0;i<H;i++) for(int j=0;j<W;j++) if(used[i][j]==true) cnt++;
        cout << cnt << endl;
    }
}

Measured memory_bytes: 3144
while True:
    value = list(map(int, str(input()).split()))
    if value[0] == -1 and value[1] == -1 and value[2] == -1:
        break



    sum = value[0] + value[1]

    if value[0] == -1 or value[1] == -1:
        print("F")
    elif sum >= 80:
        print("A")
    elif sum >= 65:
        print("B")
    elif sum >= 50:
        print("C")
    elif value[2] >= 50:
        print("C")
    elif sum >= 30:
        print("D")
    else:
        print("F")



Measured memory_bytes: 5592
// atcoder/abc159/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  int n, m;
  while (cin >> n >> m) {
    cout << (n - 1) * n / 2 + (m - 1) * m / 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use num::integer::gcd;
use proconio::*;
use std::cmp::*;
use std::collections::VecDeque;
use std::ops::*;
use std::mem::swap;

fn main() {
   input! {
      s: String,
   }

   let v: Vec<usize> = s.as_bytes().iter().map(|a| (*a as usize) - 48).collect();
   let n = s.len();
   let mut m = vec![0;2019];
   m[0] = 1;
   let mut dp = 0;
   let mut ten = 1;
   for i in (0..n).rev() {
      dp = (dp + ten*v[i]) % 2019;
      m[dp] += 1;
      ten = (ten*10) % 2019;
   }
   let mut ans = 0;
   for m in m.iter().copied() {
      ans += m*(m-1)/2;
   }
   println!("{}", ans);
}


Measured memory_bytes: 3908
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
for i in range(1,10):
    x = n//i
    if x*i == n and x <= 9 and x >= 1:
        print("Yes")
        sys.exit(0)
print("No")


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
 
int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 
             5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2,
             1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 
int main() {
  int k;
  cin >> k;
  cout << A[k-1] << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200010;
int n, m;
ll ans = 1000000000000000000ll, all;
ll a[N], b[N], c[N];
int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++i) scanf("%lld", &c[i]);
	ll now, to;
	for(int i = 2; i <= n; ++i)
	{
		now = c[i - 1] - 1;
		to = c[i] - 1;
		if(now > to) to += m;
		all += to - now;
		--a[to + 1];
		++a[now + 1];
		b[to + 1] -= now;
		b[now + 1] += now;
	}
	for(int i = 2; i <= 2 * m; ++i)
	{
		a[i] += a[i - 1];
		b[i] += b[i - 1];
	}
	for(int i = 1; i <= m; ++i)
	{
		ll t = all;
		t -= (ll)(i) * a[i] - a[i] - b[i];
		t -= (ll)(i + m) * a[i + m] - a[i + m] - b[i + m]; 
		ans = min(ans, t);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
pair<long long, long long> dfs(vector<vector<int>> &c, int v){
  long long ans0 = 1, ans1 = 1;
  for (int w : c[v]){
    pair<long long, long long> P = dfs(c, w);
    ans0 *= (P.first + P.second);
    ans0 %= MOD;
    ans1 *= P.first;
    ans1 %= MOD;
  }
  return make_pair(ans0, ans1);
}
int main(){
  int N;
  cin >> N;
  vector<vector<int>> E(N);
  for (int i = 0; i < N - 1; i++){
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    E[x].push_back(y);
    E[y].push_back(x);
  }
  vector<int> p(N, -1);
  queue<int> Q;
  Q.push(0);
  while (!Q.empty()){
    int v = Q.front();
    Q.pop();
    for (int w : E[v]){
      if (p[w] == -1){
        p[w] = v;
        Q.push(w);
      }
    }
  }
  vector<vector<int>> c(N);
  for (int i = 1; i < N; i++){
    c[p[i]].push_back(i);
  }
  pair<long long, long long> P = dfs(c, 0);
  cout << (P.first + P.second) % MOD<< endl;
}

Measured memory_bytes: 17152